feat(ecology): distinguish inherited plans in verified census
Foundation / checks (tsan) (push) Canceled after 0s
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 1m13s
Foundation / checks (client) (push) Canceled after 1m14s
Foundation / checks (postgres) (push) Canceled after 1m7s
Foundation / checks (deploy) (push) Canceled after 1m13s
Foundation / checks (ecs) (push) Canceled after 1m13s
Foundation / checks (network) (push) Canceled after 1m14s

This commit is contained in:
dingo
2026-10-19 15:06:47 -04:00
parent c60cdf8e19
commit dc7c0e1fa1
20 changed files with 492 additions and 23 deletions
+29 -6
View File
@@ -21,12 +21,14 @@ bool add(accounting::Inventory& target, const accounting::Inventory& value) {
return true;
}
bool add(CellularCensusTotals& target, const CellularCensusTotals& value) {
if (!add(target.retained_nonresident_records, value.retained_nonresident_records))
if (!add(target.retained_nonresident_records, value.retained_nonresident_records) ||
!add(target.retained_dead_plan_records, value.retained_dead_plan_records))
return false;
for (std::size_t kind = 0; kind < target.resident.size(); ++kind) {
auto& stock = target.resident[kind];
const auto& source = value.resident[kind];
if (!add(stock.count, source.count) || !add(stock.body, source.body) ||
if (!add(target.living_plan_holders[kind], value.living_plan_holders[kind]) ||
!add(stock.count, source.count) || !add(stock.body, source.body) ||
!add(stock.reserve, source.reserve))
return false;
}
@@ -54,14 +56,19 @@ CellularCensus::observe(const CellularLives& state, std::span<const CellularCoho
const bool maturing = state.rules_version() == cellular_lives_maturation_rules &&
state.format_version() == cellular_lives_migration_format &&
(population == 0 || population == 2);
if ((!maturing && state.rules_version() != cellular_lives_foraging_rules) ||
(state.format_version() != cellular_lives_presence_format &&
state.format_version() != cellular_lives_migration_format) ||
(population != 0 && population != 1 && population != 2))
const bool inherited = state.rules_version() == cellular_lives_inheritance_rules &&
state.format_version() == cellular_lives_inheritance_format &&
population == 0;
if (!inherited && ((!maturing && state.rules_version() != cellular_lives_foraging_rules) ||
(state.format_version() != cellular_lives_presence_format &&
state.format_version() != cellular_lives_migration_format) ||
(population != 0 && population != 1 && population != 2)))
return std::unexpected(CellularCensusError::unsupported);
CellularCensus result;
result.boundary_ = {state.world(), state.region(), state.frame(), state.tick(),
state.format_version(), state.rules_version(), population};
if (inherited)
result.boundary_.projection_version = cellular_plan_census_projection_version;
const auto& archive = state.archive();
result.genomes_.assign(archive.genomes().begin(), archive.genomes().end());
result.rows_.reserve(archive.archived());
@@ -107,7 +114,23 @@ CellularCensus::observe(const CellularLives& state, std::span<const CellularCoho
if (!add(stock.count, 1) || !add(stock.body, life.body) ||
!add(stock.reserve, life.reserve))
return std::unexpected(CellularCensusError::overflow);
if (inherited) {
const auto plan = result.locate(life.offspring_genome);
if (plan == result.rows_.size())
return std::unexpected(CellularCensusError::history);
if (!add(result.rows_[plan].totals.living_plan_holders[static_cast<std::size_t>(kind)],
1))
return std::unexpected(CellularCensusError::overflow);
}
}
if (inherited)
for (const auto& corpse : state.corpses()) {
const auto plan = result.locate(corpse.offspring_genome);
if (plan == result.rows_.size())
return std::unexpected(CellularCensusError::history);
if (!add(result.rows_[plan].totals.retained_dead_plan_records, 1))
return std::unexpected(CellularCensusError::overflow);
}
const auto& nonresident = state.boundary_ledger().nonresident_organisms;
std::vector<std::uint64_t> nonresident_genomes;
nonresident_genomes.reserve(nonresident.size());