feat(lifecycle): qualify portable maturing wildlife transfers
Foundation / checks (ecs) (push) Successful in 2m26s
Foundation / checks (deploy) (push) Successful in 4m12s
Foundation / checks (network) (push) Successful in 20m57s
Foundation / checks (client) (push) Successful in 22m9s
Foundation / checks (tsan) (push) Successful in 28m49s
Foundation / checks (postgres) (push) Successful in 1h5m2s
Foundation / checks (checks) (push) Successful in 1h17m42s
Foundation / postgres-tools (push) Successful in 1m10s
Foundation / server-image (push) Successful in 3m51s
Foundation / image (push) Successful in 4m54s
Foundation / checks (ecs) (push) Successful in 2m26s
Foundation / checks (deploy) (push) Successful in 4m12s
Foundation / checks (network) (push) Successful in 20m57s
Foundation / checks (client) (push) Successful in 22m9s
Foundation / checks (tsan) (push) Successful in 28m49s
Foundation / checks (postgres) (push) Successful in 1h5m2s
Foundation / checks (checks) (push) Successful in 1h17m42s
Foundation / postgres-tools (push) Successful in 1m10s
Foundation / server-image (push) Successful in 3m51s
Foundation / image (push) Successful in 4m54s
This commit is contained in:
@@ -162,9 +162,13 @@ CellularPopulationExecution continuation(const CellularPopulation& population) {
|
||||
auto inputs = checked(unattended_population_inputs(s, header), "transferred interval inputs");
|
||||
return checked(prepare_population_batch(population, std::move(inputs)), "transferred interval");
|
||||
}
|
||||
void trace_contract() {
|
||||
void trace_contract(bool maturing = false) {
|
||||
auto source = checked(funded()->migration_upgrade_candidate(), "trace source");
|
||||
auto target = checked(destination(*source, 1)->migration_upgrade_candidate(), "trace target");
|
||||
if (maturing) {
|
||||
source = checked(source->maturation_upgrade_candidate(), "trace maturing source");
|
||||
target = checked(target->maturation_upgrade_candidate(), "trace maturing target");
|
||||
}
|
||||
const auto before = source->snapshot(), peer_before = target->snapshot();
|
||||
const auto request = request_for(*source, *target);
|
||||
auto recorded = checked(prepare_migration_trace(*source, *target, request), "record pair");
|
||||
@@ -172,7 +176,20 @@ void trace_contract() {
|
||||
require(bytes.size() == migration_trace_header_bytes + 8 * recorded.trace.members.size() + 8,
|
||||
"trace length changed");
|
||||
const auto trace = checked(decode_migration_trace(bytes), "decode pair");
|
||||
require(trace == recorded.trace, "trace canonical roundtrip");
|
||||
require(trace == recorded.trace && trace.format_version == (maturing ? 2U : 1U),
|
||||
"trace canonical roundtrip or rule version");
|
||||
auto wrong_version = trace;
|
||||
wrong_version.format_version = maturing ? 1 : 2;
|
||||
require(!replay_migration_trace(*source, *target, request, wrong_version),
|
||||
"transfer trace reinterpreted under different biological rules");
|
||||
wrong_version.format_version = 3;
|
||||
require(!encode_migration_trace(wrong_version), "unknown transfer trace version");
|
||||
for (const auto offset : {std::size_t{7}, std::size_t{8}}) {
|
||||
auto mixed = bytes;
|
||||
mixed.at(offset) = offset == 7 ? (maturing ? '1' : '2') : (maturing ? 1 : 2);
|
||||
checksum(mixed);
|
||||
require(!decode_migration_trace(mixed), "mixed transfer magic/version");
|
||||
}
|
||||
auto replayed =
|
||||
checked(replay_migration_trace(*source, *target, request, trace), "replay pair");
|
||||
require(replayed.source->snapshot() == recorded.execution.source->snapshot() &&
|
||||
@@ -302,6 +319,85 @@ void trace_contract() {
|
||||
require(source->snapshot() == before && target->snapshot() == peer_before,
|
||||
"trace validation changed its input");
|
||||
}
|
||||
void maturing_growth_transfer() {
|
||||
auto old = checked(funded()->migration_upgrade_candidate(), "growth migration source");
|
||||
auto old_peer = checked(destination(*old)->migration_upgrade_candidate(), "growth old peer");
|
||||
auto source = checked(old->maturation_upgrade_candidate(), "growth rules-9 source");
|
||||
auto peer = checked(old_peer->maturation_upgrade_candidate(), "growth rules-9 peer");
|
||||
const auto genome = wildlife_genome(*source);
|
||||
const auto before = source->snapshot(), old_bytes = old->snapshot();
|
||||
for (const auto& result : {CellularMigration::prepare(*source, *old_peer, genome),
|
||||
CellularMigration::prepare(*old, *peer, genome)})
|
||||
require(!result && result.error() == CellularMigrationError::version,
|
||||
"mixed rules entered raw transfer");
|
||||
auto population = checked(CellularPopulation::create(restore(*source)), "growth population");
|
||||
auto old_population =
|
||||
checked(CellularPopulation::create(restore(*old_peer)), "old population peer");
|
||||
const auto mixed = CellularMigration::prepare(*population, *old_population, genome);
|
||||
require(!mixed && mixed.error() == CellularMigrationError::version &&
|
||||
source->snapshot() == before && old->snapshot() == old_bytes &&
|
||||
!source->migration_upgrade_candidate(),
|
||||
"mixed cohort transfer changed input or rules-9 repeated the format upgrade");
|
||||
auto active = checked(funded(false)->migration_upgrade_candidate(), "active boundary owner");
|
||||
auto active_peer = checked(destination(*active)->migration_upgrade_candidate(), "active peer");
|
||||
active = checked(active->maturation_upgrade_candidate(), "active maturing owner");
|
||||
active_peer = checked(active_peer->maturation_upgrade_candidate(), "active maturing peer");
|
||||
const auto vulnerable =
|
||||
CellularMigration::prepare(*active, *active_peer, wildlife_genome(*active));
|
||||
require(!vulnerable && vulnerable.error() == CellularMigrationError::ineligible,
|
||||
"rules-9 transfer bypassed vulnerable controlled life");
|
||||
for (unsigned tick = 0; tick < 64; ++tick)
|
||||
step(*source);
|
||||
bool grew_before = false;
|
||||
for (const auto& life : source->lives()) {
|
||||
const auto prior = std::ranges::find(old->lives(), life.identity.life,
|
||||
[](const auto& value) { return value.identity.life; });
|
||||
grew_before |= prior != old->lives().end() &&
|
||||
life.growth.realized_per_thousand > prior->growth.realized_per_thousand;
|
||||
}
|
||||
require(grew_before, "migration fixture never funded pre-transfer growth");
|
||||
// Finite destination food is declared in its opening fixture, not credited
|
||||
// to a migrant's reserve or copied from the source's spending ledger.
|
||||
peer = checked(checked(destination(*source, 0, 0, true)->migration_upgrade_candidate(),
|
||||
"funded destination boundary")
|
||||
->maturation_upgrade_candidate(),
|
||||
"funded destination maturation");
|
||||
const auto request = request_for(*source, *peer);
|
||||
auto raw = checked(prepare_migration_trace(*source, *peer, request), "growing raw transfer");
|
||||
population = checked(CellularPopulation::create(restore(*source)), "growing source cohort");
|
||||
auto destination_population =
|
||||
checked(CellularPopulation::create(restore(*peer)), "growing destination cohort");
|
||||
checked(population->collapse(genome), "growing cohort membership");
|
||||
auto recorded = checked(prepare_migration_trace(*population, *destination_population, request),
|
||||
"growing cohort transfer");
|
||||
require(raw.execution.source->snapshot() == recorded.execution.source->state().snapshot() &&
|
||||
raw.execution.destination->snapshot() ==
|
||||
recorded.execution.destination->state().snapshot() &&
|
||||
recorded.trace.format_version == 2,
|
||||
"growing transfer changed biology across representations");
|
||||
const auto total = plus(source->current_total(), peer->current_total());
|
||||
const auto arrival = recorded.execution.destination->state().snapshot();
|
||||
auto continued = continuation(*recorded.execution.destination);
|
||||
bool grew_after = false;
|
||||
for (const auto& life : continued.state->state().lives()) {
|
||||
const auto prior = std::ranges::find(source->lives(), life.identity.life,
|
||||
[](const auto& value) { return value.identity.life; });
|
||||
grew_after |= prior != source->lives().end() &&
|
||||
life.growth.realized_per_thousand > prior->growth.realized_per_thousand;
|
||||
}
|
||||
require(grew_after &&
|
||||
plus(recorded.execution.source->state().current_total(),
|
||||
continued.state->state().current_total()) == total &&
|
||||
continued.state->state().boundary_ledger() ==
|
||||
recorded.execution.destination->state().boundary_ledger() &&
|
||||
recorded.execution.destination->state().snapshot() == arrival,
|
||||
"imported juvenile failed funded growth or spent boundary flow as stock");
|
||||
const auto replay =
|
||||
checked(replay_population_batch(*recorded.execution.destination, continued.batch),
|
||||
"growing destination interval replay");
|
||||
require(replay->snapshot() == continued.state->snapshot(),
|
||||
"post-transfer growth replay differs");
|
||||
}
|
||||
void write_bytes(const std::string& path, std::span<const std::uint8_t> bytes) {
|
||||
std::ofstream out(path, std::ios::binary | std::ios::trunc);
|
||||
out.write(reinterpret_cast<const char*>(bytes.data()),
|
||||
@@ -320,9 +416,13 @@ std::vector<std::uint8_t> read_bytes(const std::string& path) {
|
||||
require(in.good(), "restart fixture read");
|
||||
return bytes;
|
||||
}
|
||||
void record_restart(const std::string& prefix) {
|
||||
void record_restart(const std::string& prefix, bool maturing = false) {
|
||||
auto source = checked(funded()->migration_upgrade_candidate(), "restart source");
|
||||
auto target = checked(destination(*source, 1)->migration_upgrade_candidate(), "restart target");
|
||||
if (maturing) {
|
||||
source = checked(source->maturation_upgrade_candidate(), "restart maturing source");
|
||||
target = checked(target->maturation_upgrade_candidate(), "restart maturing target");
|
||||
}
|
||||
const auto request = request_for(*source, *target);
|
||||
auto recorded = checked(prepare_migration_trace(*source, *target, request), "restart raw pair");
|
||||
write_bytes(prefix + ".raw.source", source->snapshot());
|
||||
@@ -381,7 +481,7 @@ void replay_restart(const std::string& prefix) {
|
||||
"fresh transferred continuation");
|
||||
write_bytes(prefix + ".pop.continuation.resumed", continued->snapshot());
|
||||
}
|
||||
void upgrade_and_move() {
|
||||
void upgrade_and_move(bool maturing = false) {
|
||||
auto original = funded();
|
||||
auto other = destination(*original, 1);
|
||||
const auto original_bytes = original->snapshot();
|
||||
@@ -397,6 +497,10 @@ void upgrade_and_move() {
|
||||
source->boundary_ledger() == CellularBoundaryLedger{} &&
|
||||
original->snapshot() == original_bytes,
|
||||
"upgrade changed biology/funding");
|
||||
if (maturing) {
|
||||
source = checked(source->maturation_upgrade_candidate(), "moving maturing source");
|
||||
target = checked(target->maturation_upgrade_candidate(), "moving maturing target");
|
||||
}
|
||||
const auto source_before = source->snapshot(), target_before = target->snapshot();
|
||||
const auto total = plus(source->current_total(), target->current_total());
|
||||
const auto genome = wildlife_genome(*source);
|
||||
@@ -597,7 +701,7 @@ void population_envelope() {
|
||||
}
|
||||
checked(next->advance_tick(controlled), "new envelope continued biology");
|
||||
}
|
||||
void overlap_refusal() {
|
||||
void overlap_refusal(bool maturing = false) {
|
||||
auto raw = funded(false);
|
||||
for (unsigned i = 0; i < 128; ++i)
|
||||
step(*raw, false);
|
||||
@@ -605,6 +709,10 @@ void overlap_refusal() {
|
||||
step(*raw);
|
||||
auto source = checked(raw->migration_upgrade_candidate(), "overlap source upgrade");
|
||||
auto target = checked(destination(*source)->migration_upgrade_candidate(), "overlap peer");
|
||||
if (maturing) {
|
||||
source = checked(source->maturation_upgrade_candidate(), "overlap maturing source");
|
||||
target = checked(target->maturation_upgrade_candidate(), "overlap maturing target");
|
||||
}
|
||||
const auto first = wildlife_genome(*source);
|
||||
auto initial =
|
||||
checked(CellularMigration::prepare(*source, *target, first), "overlap first group");
|
||||
@@ -710,11 +818,15 @@ void refusal_and_codec() {
|
||||
require(source->snapshot() == before && target->snapshot() == target_before,
|
||||
"rejection modified a peer");
|
||||
}
|
||||
void capacity() {
|
||||
void capacity(bool maturing = false) {
|
||||
auto raw = funded(true, 1);
|
||||
auto crowded = destination(*raw, 256);
|
||||
auto source = checked(raw->migration_upgrade_candidate(), "capacity source upgrade");
|
||||
auto target = checked(crowded->migration_upgrade_candidate(), "capacity target upgrade");
|
||||
if (maturing) {
|
||||
source = checked(source->maturation_upgrade_candidate(), "capacity maturing source");
|
||||
target = checked(target->maturation_upgrade_candidate(), "capacity maturing target");
|
||||
}
|
||||
const auto before = source->snapshot(), other = target->snapshot();
|
||||
const auto result = CellularMigration::prepare(*source, *target, wildlife_genome(*source));
|
||||
require(!result && result.error() == CellularMigrationError::capacity &&
|
||||
@@ -761,11 +873,13 @@ void local_budding_among_imports() {
|
||||
int main(int argc, char** argv) try {
|
||||
if (argc == 3) {
|
||||
const std::string_view mode{argv[1]};
|
||||
if (mode == "--record")
|
||||
if (mode == "--record") {
|
||||
record_restart(argv[2]);
|
||||
else if (mode == "--replay")
|
||||
record_restart(std::string{argv[2]} + ".maturing", true);
|
||||
} else if (mode == "--replay") {
|
||||
replay_restart(argv[2]);
|
||||
else
|
||||
replay_restart(std::string{argv[2]} + ".maturing");
|
||||
} else
|
||||
throw std::runtime_error("unknown migration fixture mode");
|
||||
return 0;
|
||||
}
|
||||
@@ -777,6 +891,11 @@ int main(int argc, char** argv) try {
|
||||
overlap_refusal();
|
||||
local_budding_among_imports();
|
||||
trace_contract();
|
||||
upgrade_and_move(true);
|
||||
capacity(true);
|
||||
overlap_refusal(true);
|
||||
trace_contract(true);
|
||||
maturing_growth_transfer();
|
||||
return 0;
|
||||
} catch (const std::exception& error) {
|
||||
std::cerr << error.what() << '\n';
|
||||
|
||||
Reference in New Issue
Block a user