feat(cellular): energy cycles back through the spent pool (ADR-0182 section 14)
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m42s
Foundation / checks (checks) (push) Successful in 6s
Foundation / checks (client) (push) Successful in 5s
Foundation / postgres-tools (push) Successful in 31s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / server-image (push) Successful in 4m45s
Foundation / checks (network) (push) Successful in 4s
Foundation / image (push) Successful in 5m31s

Energy cells used went to the region's heat store and never returned, so a
region without photosynthesizers drained: region 16's wildlife ate its energy
and starved, and its matter-only drip filled the deposit limit.

Two optional rules-13 tuning keys, adoptable live: spent.heat_recycle_per_mille
moves that share of the heat store to the spent pool at the end of every tick,
before the drip (1,000 closes the loop and returns heat built up before), and
spent.drip_absorb lets a drip at the deposit limit join the first existing bubble
at or after its spot. Both use the reserved word after the offer interval, so
rules without them keep their bytes, digests, checkpoints and replays. The DEV
revamp file turns both on. The region view reports heat and the cycle; the
portal counts heat in the region's energy and ledger.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-28 10:18:24 -04:00
co-authored by Claude Opus 5.5
parent 944f6719cf
commit cc2eaf2e05
14 changed files with 264 additions and 25 deletions
@@ -41,6 +41,9 @@ struct CellularRevampTuning {
predation_kill_bubble_per_mille{};
// The spent pool's drip back into the region.
std::int64_t spent_drip_interval_ticks{}, spent_drip_bubble_pj{}, spent_drip_bubble_fg{};
// Optional energy cycle (ADR-0182 section 14): the share of the region's heat returned to
// the spent pool each tick, and whether a drip at the deposit limit joins an existing bubble.
std::int64_t spent_heat_recycle_per_mille{}, spent_drip_absorb{};
// Mutation offers (Cellular_mutation_plan.md section 3).
std::int64_t mutation_options{}, mutation_floor_ppm{}, mutation_cap_ppm{};
std::int64_t mutation_score_min{}, mutation_score_max{};
@@ -12,7 +12,8 @@
// it is not a simulation output, a checkpoint or a client protocol.
//
// {"world":W,"region":R,"tick":T,"rules":N,["rules_sha256":"hex",]"area":[w,h],
// "spent":[e,c,n,p,o],["drip":[interval_ticks,bubble_pj,bubble_fg],]
// "spent":[e,c,n,p,o],"heat":pj,
// ["drip":[interval_ticks,bubble_pj,bubble_fg,heat_recycle_per_mille,absorb],]
// "cells_total":N,"deposits_total":N,
// "counts":[players,wildlife,patches,pools,bubbles],
// "totals":{"reserve":[e,c,n,p,o],"body":[...],"patches":[...],"pools":[...],"bubbles":[...]},
@@ -28,7 +29,9 @@
// in pJ, matter in fg. Cells and deposits beyond the limits are left out (by ascending life id and
// deposit id); the totals still count them. `rules_sha256` is given by the caller (the SHA-256
// of encode_cellular_revamp_rules, which tuning revisions are adopted by) and left out when empty.
// `drip` is the rules-13 spent-pool drip (cellular_drip_spent), left out before rules 13.
// `heat` is the energy the region's cells have used and not yet recycled (CellularLives::heat).
// `drip` is the rules-13 spent-pool drip (cellular_drip_spent) and its energy cycle (ADR-0182
// section 14), left out before rules 13.
// `counts` and `totals` cover every life and deposit, whatever the limits: the region's stock
// is the totals plus `spent`.
namespace evo::server {
@@ -28,6 +28,12 @@ struct CellularRevampRules {
// bubble per non-empty channel of at most these amounts, at seeded random spots.
std::uint32_t drip_interval_ticks{};
std::uint64_t drip_bubble_pj{}, drip_bubble_fg{};
// ADR-0182 section 14 (0 and false keep the historical law): the share of the region's
// heat, per mille, moved to the spent pool at the end of every tick before the drip, so
// energy cycles back like matter; and a drip at the deposit limit joins an existing bubble
// (the first at or after its spot) instead of waiting.
std::uint32_t heat_recycle_per_thousand{};
bool drip_absorb{};
// Share of reserve matter carried as load, per mille: it slows thrust and turning and makes
// thrust costlier, in proportion to the body's mass. Upkeep stays on the body.
std::uint32_t reserve_load_per_thousand{};
@@ -114,8 +120,9 @@ cellular_mutation_cost(const biology::CellularMutationTuning& tuning) noexcept;
// The spent pool's drip for the tick ending at `tick`: on every `drip_interval_ticks`-th tick,
// one bubble per non-empty channel of at most the declared size, taken from `spent`, at a
// seeded random spot (nudged east past taken addresses) with the next deposit id and `source`.
// A habitat at its deposit limit keeps the rest waiting. False only on identity overflow, with
// `config` and `spent` then unusable.
// A habitat at its deposit limit keeps the rest waiting, or with `drip_absorb` adds it to the
// first bubble at or after that spot in address order (wrapping). False only on identity
// overflow, with `config` and `spent` then unusable.
[[nodiscard]] bool cellular_drip_spent(biology::CellularHabitatConfig& config,
accounting::Inventory& spent,
const CellularRevampRules& rules, std::uint64_t world,