M12.6: add bounded regional cellular census and lineage queries
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 2m33s
Foundation / checks (network) (push) Successful in 21m15s
Foundation / checks (client) (push) Successful in 22m8s
Foundation / checks (tsan) (push) Successful in 25m2s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 38m24s
Foundation / checks (postgres) (push) Canceled after 38m24s

This commit is contained in:
dingo
2026-10-18 13:57:52 -04:00
parent df680810af
commit da39fc8095
17 changed files with 757 additions and 4 deletions
+32
View File
@@ -1,3 +1,4 @@
#include "evo/server/lifecycle/cellular_census.hpp"
#include "evo/server/lifecycle/cellular_migration.hpp"
#include "evo/server/lifecycle/cellular_migration_trace.hpp"
#include "evo/server/lifecycle/cellular_population_batch.hpp"
@@ -411,6 +412,18 @@ void upgrade_and_move() {
require(moved.source->archive().encode() == source->archive().encode() &&
moved.source->boundary_ledger().nonresident_organisms == moved.members,
"departure erased history or recorded death");
const auto departure = checked(CellularCensus::observe(*moved.source), "departure census");
const auto arrival = checked(CellularCensus::observe(*moved.destination), "arrival census");
const auto departed =
checked(departure.query(genome, CellularCensusScope::exact_genome), "departure carriers");
const auto arrived =
checked(arrival.query(genome, CellularCensusScope::exact_genome), "arrival carriers");
require(departed.retained_nonresident_records == moved.members.size() &&
departed.resident[0] == CellularCensusStock{} &&
arrived.retained_nonresident_records == 0 &&
arrived.resident[0].count == moved.members.size(),
"regional census counted departed archive history as owned wildlife");
Inventory migrant_bodies, migrant_reserves;
for (const auto id : moved.members) {
const auto before = std::ranges::find(source->lives(), id,
[](const auto& life) { return life.identity.life; });
@@ -421,7 +434,12 @@ void upgrade_and_move() {
"member was relabeled/healed/resampled");
require(moved.destination->archive().organism(id) == source->archive().organism(id),
"birth history changed");
migrant_bodies = plus(migrant_bodies, before->body);
migrant_reserves = plus(migrant_reserves, before->reserve);
}
require(arrived.resident[0].body == migrant_bodies &&
arrived.resident[0].reserve == migrant_reserves,
"census migrant inventory differs from exact individual stock");
require(moved.destination->next_bud_sequence() == target->next_bud_sequence(),
"import consumed a local bud identity");
auto source_after = decode(*moved.source, moved.source->snapshot());
@@ -433,6 +451,12 @@ void upgrade_and_move() {
checked(CellularMigration::prepare(back ? *target_after : *source_after,
back ? *source_after : *target_after, genome),
"migration return trip");
const auto returning = checked(CellularCensus::observe(*next.destination), "return census");
const auto returned = checked(returning.query(genome, CellularCensusScope::exact_genome),
"returned carriers");
require(returned.retained_nonresident_records == 0 &&
returned.resident[0].count == members.size(),
"returned stock was still classified as nonresident history");
if (back) {
source_after = std::move(next.destination);
target_after = std::move(next.source);
@@ -512,6 +536,14 @@ void population_envelope() {
peer->state().region(), peer->state().frame(),
peer->state().tick()),
"migrated cohort restore");
const auto cohort_census =
checked(CellularCensus::observe(*restored), "imported cohort census");
const auto cohort_stock = checked(
cohort_census.query(genome, CellularCensusScope::exact_genome), "imported cohort carriers");
require(cohort_census.boundary().population_format == 2 &&
cohort_stock.resident[0].count == 0 &&
cohort_stock.resident[1].count == restored->members().size(),
"imported cohort census duplicated or lost exact members");
require(std::ranges::equal(restored->members(), next->members()),
"cohort tags lost on restore");
checked(next->materialize(genome), "new envelope materialization");