feat(lifecycle): add opt-in funded cellular maturation
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 2m25s
Foundation / checks (network) (push) Successful in 21m0s
Foundation / checks (client) (push) Successful in 22m13s
Foundation / checks (tsan) (push) Successful in 26m35s
Foundation / checks (postgres) (push) Successful in 1h1m27s
Foundation / checks (checks) (push) Successful in 1h14m29s
Foundation / postgres-tools (push) Successful in 1m19s
Foundation / server-image (push) Successful in 3m46s
Foundation / image (push) Successful in 4m57s

This commit is contained in:
dingo
2026-10-18 21:48:27 -04:00
parent 27ec5729bf
commit a5307c768b
22 changed files with 889 additions and 19 deletions
+4 -1
View File
@@ -55,8 +55,11 @@ struct MetabolicBudget {
metabolic_rules_for(std::uint32_t development_version);
// The single place the genome's description of capability becomes ledger
// quantities. The genome record itself stays free of accounting types.
// max_growth_per_thousand caps this proposal, not a time rate; the caller owns
// its versioned cadence. The default preserves earlier budget results exactly.
[[nodiscard]] std::expected<MetabolicBudget, DevelopmentError>
metabolic_budget(const Genome& genome, GrowthState growth, EnvironmentState environment);
metabolic_budget(const Genome& genome, GrowthState growth, EnvironmentState environment,
std::uint32_t max_growth_per_thousand = 1000);
// An analysis, not a rule (ADR-0098 decision 7): whole seconds until feeding funds the
// budget's reproduction investment, channel by channel and in energy, when the organism
// takes in its full intake limit for `feeding_per_thousand` of the time and pays its
+7
View File
@@ -88,4 +88,11 @@ select_mutation(const Genome& genome, const MutationContext& context, const Muta
fund_mutation(const Genome& genome, const MutationContext& context, const MutationOffer& offered,
std::uint16_t chosen, std::uint64_t successor_id, std::uint64_t origin_event,
const accounting::Inventory& reserve);
// ADR-0157: preserve and validate the original draw, but fund its selected genome
// at the organism's current growth. No redraw or reset to the offer's old body.
[[nodiscard]] std::expected<MutationTransition, MutationError>
fund_mutation_at_growth(const Genome& genome, const MutationContext& context,
const MutationOffer& offered, std::uint16_t chosen,
std::uint64_t successor_id, std::uint64_t origin_event,
const accounting::Inventory& reserve, GrowthState current_growth);
} // namespace evo::biology
@@ -43,8 +43,11 @@ inline constexpr std::uint32_t cellular_lives_reproduction_rules = 7;
// carries the new state, so they keep owner format 6.
inline constexpr std::uint32_t cellular_lives_foraging_rules = 8;
// ADR-0144: opt-in boundary accounting and retained nonresident history. Biology
// remains rules 8; every earlier envelope retains its original meaning.
// starts on rules 8; every earlier envelope retains its original meaning.
inline constexpr std::uint32_t cellular_lives_migration_format = 7;
// ADR-0157: opt-in funded maturation, using the unchanged format-7 fields.
inline constexpr std::uint32_t cellular_lives_maturation_rules = 9;
inline constexpr std::uint32_t cellular_growth_per_tick = 5; // Per 50 ms; trial rate.
// The founder a region of these rules creates.
[[nodiscard]] constexpr biology::FounderVersion
cellular_founder_version(std::uint32_t rules) noexcept {
@@ -158,10 +161,17 @@ struct CellularBudExecution {
CellularBudResult result{};
auto operator<=>(const CellularBudExecution&) const = default;
};
struct CellularGrowthExecution {
std::uint64_t life_id{};
biology::GrowthState before{}, after{};
accounting::Inventory intake{}, release{};
auto operator<=>(const CellularGrowthExecution&) const = default;
};
struct CellularTickExecution {
biology::CellularRegionStepCandidate step;
std::vector<CellularMutationExecution> mutations;
std::vector<CellularBudExecution> buds; // Rules 4, in parent life order.
std::vector<CellularBudExecution> buds; // Rules 4, in parent life order.
std::vector<CellularGrowthExecution> growth; // Rules 9: funded expansions only, life order.
};
struct CellularLifeTickFeedback {
std::uint64_t life_id{}, tick{};
@@ -253,6 +263,9 @@ class CellularLives {
// Explicit detached format-6/rules-8 -> format-7 upgrade. No biology advances.
[[nodiscard]] std::expected<std::unique_ptr<CellularLives>, CellularLivesError>
migration_upgrade_candidate() const;
// ADR-0157: detached no-tick rules-8/format-7 -> rules-9 candidate. No grant.
[[nodiscard]] std::expected<std::unique_ptr<CellularLives>, CellularLivesError>
maturation_upgrade_candidate() const;
// Latest successful in-memory step report; omitted from snapshots and empty after restore.
[[nodiscard]] std::span<const CellularLifeTickFeedback> last_tick_feedback() const noexcept;
[[nodiscard]] std::vector<std::uint8_t> snapshot() const;
@@ -53,6 +53,9 @@ class CellularPopulation {
// Explicit no-tick envelope-1 -> envelope-2 upgrade, retaining all cohort tags.
[[nodiscard]] std::expected<std::unique_ptr<CellularPopulation>, CellularPopulationError>
migration_upgrade_candidate() const;
// ADR-0157: preserve exact membership while upgrading nested biology to rules 9.
[[nodiscard]] std::expected<std::unique_ptr<CellularPopulation>, CellularPopulationError>
maturation_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,