Files
aevolution/docs/adr/0032-metabolic-budgets-from-genome.md
T
dingoandClaude Opus 5 36ee71cfe9 Decide affordability where composition is known
A construction transition could require more of an element than was
available, because the check compared net mass. A step growing a body
from 13 to 14 femtograms nets one femtogram but acquires a carbon and a
nitrogen while freeing one of other, and released other pays for neither.
Matching totals let one element silently fund another.

Net mass was never the right question, and the layer asking it could not
ask a better one: plan_development has no composition. A single scalar
pool could not carry the answer either, since it cannot say that carbon
is plentiful while nitrogen is not. The environment now states what is
available per ledger channel.

plan_development keeps a total-mass bound, which is sound because net
never exceeds gross, but it is a proposal rather than an authority.
metabolic_budget narrows it to the largest step whose own intake fits
channel by channel, and reports the growth that step actually funds. That
revises ADR-0031 on this point, recorded in both ADRs.

The tests place a single femtogram in each channel in turn and require
that no step needing a different element is funded, that nothing is
acquired beyond what is present, and that the mass-only plan would have
admitted the step; a carbon and a nitrogen together then fund it exactly.
Across six target sizes by seven growth fractions by four stock levels,
every reported intake fits the availability channel by channel and never
exceeds the proposed step. Confirmed to fail with the check removed.

The releasing case moved to a target of 20 femtograms, where the step
occurs at the full rule step rather than depending on a scarce supply
that the corrected plan no longer bounds the same way.

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

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-23 13:02:44 -04:00

129 lines
7.2 KiB
Markdown

# 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.
Affordability therefore has to be decided here too, which revises ADR-0031.
Net mass is the wrong question: a step whose net growth is one femtogram can
still need a carbon and a nitrogen while freeing one of other, and released other
is neither. Matching totals would let one element silently pay for another. The
environment accordingly carries what is available per ledger channel rather than
as a single pool, since a pool cannot say that carbon is plentiful while nitrogen
is not. `plan_development` keeps a total-mass bound, which is sound because net
never exceeds gross, but it is a proposal and not an authority;
`metabolic_budget` narrows it to the largest step whose own intake fits channel by
channel, and reports the growth that step actually funds.
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.