Files
aevolution/docs/adr/0032-metabolic-budgets-from-genome.md
T
dingoandClaude Opus 5 e0fd4680f6 Make construction reproduce the body it claims to build
Construction composed the mass difference instead of differencing the two
composed bodies. Those are not the same: composing the difference throws
away the rounding the existing body already carries, so the budget summed
to the right total while funding individual channels short or over. At
target mass 1001 growing from 10 to 60 it funded C25 N7 P2 other16,
leaving nitrogen and phosphorus one short each and other two over, so
spending it could not produce the body the same rules derive.

Construction is now the per-channel difference between the composed
bodies, which funds C25 N8 P3 other14 for that case.

That difference can be negative on a channel, because the remainder rule
is not monotone: a body growing from 13 to 14 femtograms sees other fall
from 6 to 5. Construction is therefore a transition with an intake and a
release rather than a single requirement, and the release is a rounding
artifact bounded by a few femtograms, not excretion.

The invariant held + intake - release == reached is asserted per channel
for the reported case, for the releasing case, across six target sizes by
seven growth fractions by four material budgets, and across a forty-step
walk from nothing to full growth where accumulated intake and release are
checked against the whole history. The net of every transition is also
asserted to equal what a plan charges material for. These tests were
confirmed to fail against the previous implementation.

Native Release, clang-tidy analysis, ASan and format checks pass 19/19.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-23 12:26:40 -04:00

6.4 KiB

ADR-0032: Metabolic budgets derived from a phenotype

Status

Adopted for M3.3. Running seeded ensembles on genome-derived strategies is M3.6. Mutation is M3.4. No gameplay balance, mortality rule or fitness score is selected, and no existing M2 fixture behaviour changes.

Context

M3.2 derives dimensioned physical parameters but nothing spends them. The M2 fixtures still run on hand-written constants, so capability and cost are still unrelated. This is the increment where a genome first reaches the ledger, and the roadmap names its risk precisely: reintroducing RPG modifiers, where a capability parameter becomes a flat percentage applied uniformly to every budget.

M3.1 deliberately kept the genome free of accounting types so its units could not imply ledger semantics. That boundary now has to be crossed somewhere explicit rather than everywhere implicitly.

Decision

Add evo::biology::metabolic_budget, one entry point returning every budget a phenotype implies, in accounting types. The genome record itself stays free of those types: metabolism is the single translation layer, and the genome remains a description of capability rather than of resources.

The budgets are body composition, maintenance per tick, movement per tick at full speed, total demand, the next construction step, the per-tick intake limit and the reproduction investment. They are derived from different phenotype quantities on purpose: maintenance from total mass plus a membrane upkeep term, movement from total mass and speed, intake from surface, construction from the mass difference a growth step implies, and investment from the body a parent would divide. A change to one genome parameter therefore moves some budgets and not others, by different amounts. That is the whole point: a thicker membrane costs more matter to build and more energy to hold, while changing neither uptake nor speed. Nothing here is a multiplier applied to a total.

Composition is declared per compartment in thousandths. Structure and membrane have different compositions, so a thicker membrane changes what the body is made of and not only how much. A split assigns the first three channels by share and gives the remainder to the last, so mass is conserved exactly and a body can be spent through the ledger without a rounding leak.

Construction is the difference between the two composed bodies, not the composition of the mass difference. Those are not the same: composing the difference discards the rounding the existing body already carries, so a budget built that way sums to the right total while funding individual channels short or over, and spending it could not produce the body the same rules derive. Because that remainder rule is not monotone per channel, a step can also free a femtogram as the shares rebalance, so construction is a transition with both an intake and a release rather than a single requirement. The release is a rounding artifact bounded by a few femtograms, not excretion, and the invariant is exact: the body held, plus intake, minus release, is the body reached, on every channel.

Reproduction investment is the body scaled by the genome's reproduction fraction, with its energy priced at the same construction rate as the organism's own tissue: building offspring tissue costs what building your own does. A genome without the reproduction capability invests nothing, rather than investing a default.

The rule constants are selected by the same development version as M3.2 and fail closed on an unknown one. They are chosen so the budgets are of comparable magnitude, because budgets that differ by orders of magnitude make every tradeoff invisible. That is a legibility choice for tests, not tuning, and it must be re-derived before any of it is balanced.

processes::consumer_for converts a budget into the existing ConsumerConfig. Opening inventory stays the caller's: a genome describes what an organism can do, never the resources it happens to hold, and a derived config that also invented an opening balance would be creating matter. Nothing else in the M2 fixtures changes, and no existing fixture starts reading genomes.

Alternatives Considered

A single efficiency multiplier over one budget would be exactly the modifier this increment exists to avoid. Putting accounting types into the genome record would undo the M3.1 boundary and let a stored parameter imply a ledger channel. Deriving composition from the phenotype rather than declaring it per compartment would hide the one place the membrane's different chemistry is stated. Giving the rounding remainder to the largest channel instead of a fixed one would make a split depend on the mass being split. Having consumer_for supply an opening inventory would create matter from a description.

Benefits

Capability now has cost, and the cost is not uniform. Size, membrane thickness and movement each move a different subset of budgets, so the tradeoffs are visible and testable rather than asserted. Mass splits conserve exactly, so a derived body can be spent through the ledger. The M2 fixtures gain a genome-driven path without any of them changing behaviour.

Costs

Every constant is chosen, including two compositions, a movement coefficient and an intake energy density. Intake is distributed by the structure composition, which assumes an organism takes up what it builds from. Movement is priced at full speed whether or not an organism moves, so it is a capacity rather than an expenditure. The small integer helpers are duplicated rather than shared through an internal header.

Risks

Do not read any budget as balance or a power score, and do not let the constants become tuning by having been measured. Comparable magnitudes were chosen for legibility and say nothing about what an organism should be able to afford. A budget is a derived quantity, not a rule: nothing here decides starvation, death, repair or whether demand is ever met. No organism spends any of this yet.

Consequences

Test that each budget is hand-calculable, that mass splits conserve exactly on both compartments and at the remainder boundary, that a thicker membrane raises matter cost and maintenance while leaving uptake and speed untouched, that a larger body raises maintenance and uptake together, that an absent capability yields a zero budget rather than a default, that unknown rule versions fail closed, and that a derived consumer drives a real feeding tick with the ledger conserving. No genome, snapshot, ledger, existing fixture, renderer or deployment changes.