feat(lifecycle): rules 13 mutation splits, stay-or-become and litter
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m22s
Foundation / postgres-tools (push) Successful in 22s
Foundation / server-image (push) Successful in 4m21s
Foundation / image (push) Successful in 5m6s

Phase 4 of the cellular revamp build plan (ADR-0179), server half.

- A chosen mutation now splits the cell (Cellular_reproduction_plan.md section
  4): split_cell divides body and reserve per channel by the tuned share, each
  cell develops the largest body its own genome builds from its part, and the
  rest joins its reserve, conserving every channel. Both plans carry the
  mutation; only the offspring expresses it. A split is refused, spending
  nothing and keeping the offer, below the tuned growth, without room beside
  the cell or at the region's organism cap.
- Stay or become: a choice (trace mutation byte 34) or a bud (step intent bit 2
  of byte 13) can hand control to the offspring; the parent becomes wildlife.
  Ownership now follows the account under rules 13, so validation and plan
  history accept a founder that became wildlife (ADR-0163 succession).
- Buds under rules 13: litter replaces the 25% twin (whole hundreds plus a
  chance, up to the tuned maximum, sharing one investment), the tuned bud fee is
  charged once and reclaimed, and births stop at the organism cap.
- New results split_applied and split_refused; owners below rules 13 refuse a
  become.

The revamp tuning file gains the reproduction keys. Tests cover the split's
conservation and refusals, stay and become splits with exact restore, a refused
second split, the cap, become validation and the litter count. Refreshes the DEV
session window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-22 22:19:48 -04:00
co-authored by Claude Opus 5.5
parent 7e5775b6f7
commit 9f117c9545
19 changed files with 540 additions and 71 deletions
@@ -178,6 +178,8 @@ struct CellularLifeIntent {
struct CellularMutationSelection {
std::uint64_t life_id{}, event_index{}, offer_tick{}, successor_id{};
std::uint16_t operator_id{};
// Rules 13: the split's offspring becomes the player's cell; the founder becomes wildlife.
bool become{};
auto operator<=>(const CellularMutationSelection&) const = default;
};
// declined (ADR-0120 amendment): operator 0 consumed the offer without changing the genome.
@@ -186,7 +188,9 @@ enum class CellularMutationResult : std::uint8_t {
life_died,
insufficient_funding,
declined,
offspring_plan_applied // Rules 10: inherited plan changed, expressed body did not.
offspring_plan_applied, // Rules 10: inherited plan changed, expressed body did not.
split_applied, // Rules 13: the cell split; the offspring expresses the mutation.
split_refused // Rules 13: no split now (size, room or region cap); offer kept.
};
struct CellularMutationExecution {
std::uint64_t life_id{}, successor_id{};
@@ -39,6 +39,12 @@ struct CellularRevampRules {
biology::CellularCatalogBounds bounds{};
std::uint32_t offer_interval_ticks{500};
std::array<biology::CellularMutationTuning, biology::cellular_catalog_size> mutations{};
// Reproduction: the offspring's share of a split and the growth a cell needs to split; the
// on-demand bud's fee (amounts times scale, reclaimed); the region's organism cap.
std::uint32_t split_share_per_thousand{500}, split_min_growth{1'000};
accounting::Inventory bud_fee{};
std::uint32_t bud_fee_scale_percent{};
std::uint32_t organism_cap{256};
auto operator<=>(const CellularRevampRules&) const = default;
};
@@ -75,6 +81,14 @@ cellular_draw_offer(const biology::Genome& plan, const CellularRevampLife& life,
const CellularRevampRules& rules, std::uint64_t world, std::uint64_t region,
std::uint64_t life_id, std::uint64_t tick);
// How many offspring one bud makes from `litter` (hundredths of an extra offspring) and a roll:
// one, plus every whole hundred, plus one more when roll % 100 falls below the remainder; at most
// max_litter / 100 + 1.
[[nodiscard]] constexpr std::uint32_t
cellular_litter_count(std::uint32_t litter, std::uint64_t roll, std::uint32_t max_litter) noexcept {
const auto count = 1 + litter / 100 + (roll % 100 < litter % 100 ? 1U : 0U);
return count < max_litter / 100 + 1 ? count : max_litter / 100 + 1;
}
// What choosing a mutation costs: its amounts times its scale.
[[nodiscard]] accounting::Inventory
cellular_mutation_cost(const biology::CellularMutationTuning& tuning) noexcept;