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 -2
View File
@@ -117,7 +117,8 @@ metabolic_rules_for(std::uint32_t development_version) {
}
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) {
const auto phenotype = derive_phenotype(genome, growth, environment);
if (!phenotype) {
return std::unexpected{phenotype.error()};
@@ -164,7 +165,8 @@ metabolic_budget(const Genome& genome, GrowthState growth, EnvironmentState envi
// intake fits channel by channel.
budget.construction.after = growth;
const auto proposed = plan->after.realized_per_thousand - growth.realized_per_thousand;
for (std::uint32_t attempt = proposed; attempt > 0; --attempt) {
for (std::uint32_t attempt = std::min(proposed, max_growth_per_thousand); attempt > 0;
--attempt) {
const GrowthState candidate{growth.realized_per_thousand + attempt,
growth.damage_per_thousand};
const auto grown = derive_phenotype(genome, candidate, environment);
+11 -2
View File
@@ -249,13 +249,22 @@ std::expected<MutationTransition, MutationError>
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) {
return fund_mutation_at_growth(genome, context, offered, chosen, successor_id, origin_event,
reserve, context.growth);
}
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) {
const auto successor =
select_mutation(genome, context, offered, chosen, successor_id, origin_event);
if (!successor) {
return std::unexpected{successor.error()};
}
const auto before = metabolic_budget(genome, context.growth, context.environment);
const auto after = metabolic_budget(*successor, context.growth, context.environment);
const auto before = metabolic_budget(genome, current_growth, context.environment);
const auto after = metabolic_budget(*successor, current_growth, context.environment);
const auto rules = rules_for(genome.development_version());
if (!before || !after || !rules) {
return std::unexpected{MutationError::development};