Derive a phenotype from the genome without touching it

M3.2 adds derive_phenotype and plan_development as pure integer
functions of a genome, a growth state and an environment. Nothing is
stored: a phenotype is recomputed from retained inputs rather than
cached, so a cached copy can always be checked against a recomputation.

The risk this increment was scoped against is confusing the genome with
runtime damage. Growth and damage live in a separate state that no
function may write back, and no entry point takes a mutable genome.
Damage changes the phenotype and leaves the encoded bytes and content
digest identical, so heredity cannot carry acquired condition.

The genome's development version selects a rule set, which is what makes
that field worth carrying; an unknown version fails closed rather than
deriving under the wrong rules. Version 1 declares every constant. The
shape model is explicit rather than implied: the body is a cube of
uniform declared density, so extent is an exact integer cube root and
surface is six extents squared. Membrane mass follows surface and the
genome's thickness, maintenance follows total mass plus a membrane
upkeep term, and uptake scales with surface, so size trades uptake
against maintenance. A capability the genome does not carry yields zero.

A plan advances growth by at most the rule step, reduced to the largest
step the available material funds exactly, never a partial one and never
a grant. It reserves nothing and pays for nothing: the matching transfer
does not exist until M3.3, and an apply that moved no inventory would
look like a committed operation while conserving nothing.

The fixture genome is an exact 20 micrometre cube, so every derived value
is asserted as a hand-calculated literal, as are the half-built, damaged,
maximum and cube-root-boundary cases. Determinism is checked over 45
growth and temperature combinations. The declared flooring is pinned
rather than hidden: a body whose mass floors to zero advances its counter
for no material, granting no structure because none exists either way.

Omitted physics is a documented model limitation, not a modifier. Nothing
here is balance, and no organism yet develops. Native Release, clang-tidy
analysis, ASan and format checks pass 18/18; every existing golden and
fingerprint is unchanged. Linux CI has not run yet.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-09-22 21:48:24 -04:00
co-authored by Claude Opus 5
parent 64a12c4dfc
commit 3f86dada0e
11 changed files with 703 additions and 6 deletions
+115
View File
@@ -0,0 +1,115 @@
# ADR-0031: Deterministic development and derived phenotype
## Status
Adopted for M3.2. The transfer half of ApplyDevelopment, energetic budgets and
any coupling to the M2 process fixtures are M3.3. Mutation is M3.4. No gameplay
balance, mortality rule or fitness score is selected.
## Context
M3.1 produced a validated genome that nothing reads. GENOME_MODEL requires two
things before capability can reach a budget: DerivePhenotype, producing dimensioned
mass, geometry, maintenance and enabled component descriptions, and
PlanDevelopment, returning a bounded construction plan and its resource
requirements from genome, growth and environment.
The named risk is confusing the genome with runtime damage. A genome is immutable
and shared by a lineage; what an organism has actually built, and what it has
lost, are per-organism runtime state. If development wrote either back into the
genome, heredity would silently carry acquired condition.
## Decision
Add `evo::biology` free functions over the existing record. Nothing is stored:
`derive_phenotype` and `plan_development` are pure functions of a genome, a
`GrowthState` and an `EnvironmentState`, so a phenotype is recomputed from
retained inputs rather than cached, and a cached copy can always be checked
against a recomputation.
`GrowthState` holds what the organism has built and lost, both in thousandths:
realized fraction of target size, and damage. `EnvironmentState` holds the
ambient temperature and the material available for building. Neither is ever
written to the genome, and no function takes a mutable genome. Damage reduces
realized structure and therefore the phenotype; it changes no genome field and
leaves the content digest untouched.
The genome's development version selects a rule set. Version 1 declares every
constant the derivation uses: densities, a maintenance rate, a membrane upkeep
factor, a construction energy cost, a reference surface for uptake scaling, a
reference temperature, and a maximum growth step per plan. An unknown version
fails closed rather than silently deriving under the wrong rules, which is what
makes that field worth carrying.
Derivation is exact integer arithmetic with declared flooring, no floating point,
no clock and no randomness, so the same inputs always produce the same phenotype.
Every step is checked for overflow and reports an error rather than wrapping.
The shape model is explicit: the body is a cube of uniform declared density, so
extent is the exact integer cube root of volume and surface is six extents
squared. Membrane mass is surface times the genome's thickness times membrane
density. Maintenance is proportional to total mass plus a membrane upkeep term,
so a thicker membrane costs more to hold. Uptake scales with surface against a
declared reference, so size is a real tradeoff rather than a free gain. A
capability the genome does not carry yields zero for its component: permitted
capability still requires the record to carry it, and later the material to build
it. Thermal shortfall is the amount by which the ambient temperature exceeds the
genome's tolerance around the reference, reported as a physical quantity and not
as a mortality, penalty or damage rule.
`plan_development` advances realized growth toward the target by at most the rule
step, computes the mass difference between the current and proposed phenotype, and
reports the material and construction energy that difference requires. When the
available material cannot fund the whole step it returns the largest step the
material does fund, exactly, rather than a partially funded one or a grant. The
plan carries the growth state it would produce, so committing is storing that
state; no function applies a plan on its own, because the matching transfer does
not exist until M3.3 and an apply that moved nothing would invite exactly the
unpaid commit this project keeps rejecting.
## Alternatives Considered
Caching a phenotype on the organism would need invalidation on every input change
and would let a stale cache outlive the record it came from. Writing realized
growth back into the genome would make heredity carry acquired condition, the
explicit risk here. Floating point would end determinism across platforms for no
gain at these magnitudes. A geometry solver or a real surface-to-volume physics
model is unjustified before any of it reaches a budget. An `apply` that returned
a new growth state without moving inventory would look like a committed operation
while conserving nothing.
## Benefits
Capability becomes dimensioned physical parameters without touching the genome or
any ledger. Development is reproducible from retained inputs, so a phenotype can
be recomputed and compared rather than trusted. Material shortfall reduces what is
built instead of granting it. M3.3 can attach budgets to a phenotype that is
already deterministic and already tested.
## Costs
The rule constants are chosen, not derived, and the cube shape model is a
deliberate simplification. Flooring at each step biases small organisms slightly
downward. Recomputing instead of caching costs a cube root and a few
multiplications per query. Repair is not modelled: a plan advances growth and
never reduces damage, which leaves damaged structure permanent for now.
## Risks
Omitted physics is a documented model limitation, not an unrelated modifier: do
not read extent, maintenance or uptake as balance, stats or a power score, and do
not let the constants become tuning by having been written down. A derived
phenotype is not a viability claim, and thermal shortfall is a reported quantity,
not a death rule. Nothing here decides repair, ageing, starvation, morphology or
how any of this is spent; a plan reserves nothing and pays for nothing.
## Consequences
Test that identical inputs give identical phenotypes and that the genome and its
digest are unchanged by every call, that damage changes the phenotype while
leaving the genome identical, that absent capabilities yield zero components,
that every rule constant is exercised, that the cube root is exact at boundaries,
that unknown rule versions and out-of-range growth fail closed, that overflow is
reported rather than wrapped, and that an underfunded plan returns the exact
largest affordable step. No genome, snapshot, ledger, process fixture, renderer or
deployment changes, and no organism yet develops.
+1
View File
@@ -23,6 +23,7 @@ Each record has the eight required sections.
0028 adopts funded reproduction, bounded slot capacity and retained lineage IDs.
0029 scopes the deterministic ecosystem driver and bounded measured episodes.
0030 adopts the immutable genome v1 record, validation and canonical encoding.
0031 adopts deterministic development, derived phenotype and bounded plans.
Every dependency adoption records exact version/commit and integrity hash,
transitive license obligations, maintenance/security review, owner and removal