feat(lifecycle): preserve inherited plans in exact populations
Foundation / checks (ecs) (push) Successful in 2m26s
Foundation / checks (deploy) (push) Successful in 4m57s
Foundation / checks (network) (push) Successful in 20m53s
Foundation / checks (client) (push) Successful in 22m12s
Foundation / checks (tsan) (push) Successful in 39m45s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 45m41s
Foundation / checks (checks) (push) Canceled after 45m43s

This commit is contained in:
dingo
2026-10-19 15:19:43 -04:00
parent fad79973e2
commit a898a35e1b
22 changed files with 582 additions and 36 deletions
@@ -60,7 +60,7 @@ enum class CellularCensusError : std::uint8_t {
// It never owns inventory, changes biology or reports terminal extinction.
// ADR-0159: rules 8/owner 6 or 7; rules 9/owner 7 (raw or population envelope 2).
// Growth observes retained body/reserve, never an unfunded adult forecast.
// ADR-0169: raw rules 10/owner 8 uses projection 2 with separate plan references.
// ADR-0169/0171: rules 10/owner 8, raw or envelope 3, uses projection 2.
class CellularCensus {
public:
[[nodiscard]] static std::expected<CellularCensus, CellularCensusError>
@@ -32,6 +32,7 @@ struct CellularTierPolicy {
auto operator<=>(const CellularTierPolicy&) const = default;
};
inline constexpr std::size_t cellular_population_header_bytes = 80;
inline constexpr std::uint32_t cellular_population_inheritance_format = 3;
inline constexpr std::size_t max_cellular_population_bytes = cellular_population_header_bytes +
16 * biology::max_cellular_tick_lives +
max_cellular_lives_bytes + 8;
@@ -56,6 +57,9 @@ class CellularPopulation {
// ADR-0157: preserve exact membership while upgrading nested biology to rules 9.
[[nodiscard]] std::expected<std::unique_ptr<CellularPopulation>, CellularPopulationError>
maturation_upgrade_candidate() const;
// ADR-0171: envelope 3 retains all tags and nested expressed/heritable state.
[[nodiscard]] std::expected<std::unique_ptr<CellularPopulation>, CellularPopulationError>
inheritance_upgrade_candidate() const;
[[nodiscard]] std::vector<std::uint8_t> snapshot() const;
[[nodiscard]] static std::expected<std::unique_ptr<CellularPopulation>, CellularPopulationError>
restore(std::span<const std::uint8_t> bytes, std::uint64_t world, std::uint64_t region,
@@ -20,7 +20,8 @@ struct CellularPopulationBatch {
CellularBatch biology;
std::optional<CellularPopulationConversion> conversion;
std::vector<CellularPopulationBoundary> boundaries;
std::uint32_t format_version{1}; // 1: envelope 1/owner 6; 2: envelope 2/owner 7.
// 1: envelope 1/owner 6; 2: envelope 2/owner 7; 3: envelope 3/owner 8.
std::uint32_t format_version{1};
bool operator==(const CellularPopulationBatch&) const = default;
};
inline constexpr std::size_t population_batch_header_bytes = 136;