M12.4: preserve exact biology across ownership candidates
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 2m18s
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 5m33s
Foundation / checks (postgres) (push) Canceled after 5m29s
Foundation / checks (tsan) (push) Canceled after 5m28s
Foundation / checks (client) (push) Canceled after 5m37s
Foundation / checks (network) (push) Canceled after 5m39s

This commit is contained in:
dingo
2026-10-17 18:17:59 -04:00
parent 0a8962b57e
commit decd4f8043
27 changed files with 1408 additions and 61 deletions
@@ -15,6 +15,8 @@ CellularPopulation::CellularPopulation(std::unique_ptr<CellularLives> state,
std::expected<std::unique_ptr<CellularPopulation>, CellularPopulationError>
CellularPopulation::create(std::unique_ptr<CellularLives> state, CellularTierPolicy policy) {
if (!state || state->rules_version() != cellular_lives_foraging_rules ||
(state->format_version() != cellular_lives_presence_format &&
state->format_version() != cellular_lives_migration_format) ||
policy.materialize_radius_um == 0 ||
policy.collapse_radius_um <= policy.materialize_radius_um ||
policy.collapse_radius_um > biology::cellular_motion_axis_limit_um)
@@ -36,6 +38,21 @@ CellularTierPolicy CellularPopulation::policy() const noexcept {
std::uint64_t CellularPopulation::conversion_sequence() const noexcept {
return conversion_sequence_;
}
std::uint32_t CellularPopulation::format_version() const noexcept {
return state_->format_version() == cellular_lives_migration_format ? 2U : 1U;
}
std::expected<std::unique_ptr<CellularPopulation>, CellularPopulationError>
CellularPopulation::migration_upgrade_candidate() const {
auto biological = state_->migration_upgrade_candidate();
if (!biological)
return std::unexpected(CellularPopulationError::unsupported);
auto candidate = create(std::move(*biological), policy_);
if (!candidate)
return std::unexpected(candidate.error());
(*candidate)->members_ = members_;
(*candidate)->conversion_sequence_ = conversion_sequence_;
return candidate;
}
std::expected<std::size_t, CellularPopulationError>
CellularPopulation::collapse(std::uint64_t genome) {
auto candidate = members_;