Files
aevolution/docs/adr/0099-time-based-biological-rates.md
T
dingoandClaude Opus 5.5 51cf23dbc9
Foundation / checks (deploy) (push) Successful in 3m28s
Foundation / checks (ecs) (push) Successful in 1m53s
Foundation / checks (client) (push) Successful in 12m36s
Foundation / checks (network) (push) Failing after 10m52s
Foundation / checks (tsan) (push) Successful in 7m50s
Foundation / checks (checks) (push) Successful in 33m6s
Foundation / checks (postgres) (push) Successful in 46m9s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
M11.1: development version 2 and the primitive founder (first bud in 5-15 min)
Development version 2 is defined per second; phenotype/budget rates carry their period
(rate_microseconds: 50 ms for v1, 1 s for v2) and the M2 fixture adapters accept only
v1. Tunable v2 constants (maintenance 10, membrane upkeep 15, movement 50 pJ/s per
1000 fg) and the primitive founder (schema 2: 1 um membrane, 8e6 fg, 200 um/s,
574,000 fg/s ingestion, 500 per-thousand bud) give a first bud in 300/600/901 s when
feeding 100/50/33 % of the time at full-speed movement (bud_funding_seconds; never at
10 %), the maintainer's 5-15 minute target. Tests pin the range; v1 is unchanged.
11.1 complete. Refresh the dev session window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 15:36:02 -04:00

156 lines
8.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ADR-0099: Time-based biological rates
## Status
Accepted for M11.1 (2026-10-09). The maintainer ratified the direction on 2026-10-04
(ADR-0089) and chose directional rounding on 2026-10-09. Segment 1 implements the
conversion. Segments 2 and 3 migrate the genome, development and process fields
listed below.
## Context
Biological and environmental rates are stored per simulation tick:
- genome v1 `micrometres_per_tick` and `femtograms_per_tick`;
- development and metabolism maintenance, movement and intake per tick;
- the feeding decomposition limit;
- the environmental community's decay caps.
The 50 ms tick therefore fixes biological speed in real time. ADR-0089 ratified rates
per unit time, converted deterministically at each tick, with an explicit precision
contract and a versioned migration that preserves 50 ms behaviour.
## Decision
- **Unit.** A rate is an unsigned 64-bit integer **per second**, in its existing base
unit: pJ, fg or um. No fixed-point fraction is added. The base units are already
tiny (pJ, fg) relative to any organism's budget, so one base unit per second is
precision enough.
- **Conversion.** At the simulation tick, an amount is
`per_second * tick_microseconds / 1'000'000`, computed as whole seconds plus the
fractional part. No intermediate exceeds 64 bits, and overflow is an error, never a
wrap (`accounting::per_tick`).
- **Rounding** (maintainer decision): it never favours the organism.
- Capacities, limits, speeds and intake round **down**.
- Costs (maintenance, movement, construction) round **up**.
- No remainder is carried, so no new state is saved. The error is below one base
unit per tick per rate, and always against the organism.
- **Tick bounds.** 1 us to 1 s.
- **Exactness at 50 ms.** A per-tick value `v` migrates to `20 v` per second exactly
(`per_second_from_per_tick`). At 50 ms it converts back to `v` under either rounding,
so migrated behaviour is unchanged. The migration refuses any value that has no exact
per-second form at its recorded tick, and never rounds it.
- **Where conversion happens.** Only at the boundary where a rate becomes a per-tick
amount for the step being simulated: the metabolic budget, the consumer
configuration, the decomposition limit and the decay caps. Stored records hold
per-second values.
### Migration (segments 2 and 3)
- **Genome.** Genome schema v2 declares `micrometres_per_second` and
`femtograms_per_second`. A v1 record is never rewritten: it stays as historical
provenance (GENOME_MODEL), and reading it converts at the recorded 50 ms quantum.
- **Development and processes.** Development version 2 and the process configurations
carry per-second rates. Their checkpoint formats take new versions, and older
versions are migrated at load at the checkpoint's own `tick_microseconds`.
- **Goldens.** Each goldened output must be bit-identical at 50 ms before and after.
Any golden that changes is a defect in the migration, never a reason to replace the
golden.
- **Dev world.** The upgrade uses the existing clone, migrate, compare and approve
procedure. World0 is not involved.
## Alternatives considered
- **Carried remainders** (as `integrate_energy` does for incident energy, ADR-0050):
exact over time, but a saved remainder per organism per rate, with a larger
checkpoint migration. Rejected by the maintainer for M11.
- **Rates per millisecond, or a fixed-point fraction:** more precision than the base
units need, and more overflow surface.
- **Changing only the unit labels:** would leave the 50 ms coupling in place.
## Benefits
- A tick change becomes a reviewable change of rounding, not a silent rescaling of
biology.
- No new saved state; conversion is deterministic and checked for overflow.
- Rounding never creates free energy or matter for an organism.
## Costs and risks
- At a tick that does not divide a rate, an organism pays slightly more and takes in
slightly less than the exact rate, by under one unit per tick. Integer floors already
stop a very slow rate (below one unit per tick) from acting at all as a capacity.
For a cost, the same rate charges one unit per tick. Both are deliberate and bounded.
- The rate fields must be converted exactly once, at the boundary. Converting twice,
or not at all, would rescale biology. The goldens at 50 ms are the guard against
this.
## Segment 2 as implemented (2026-10-09)
- **Genome schema 2** ([genome-v2.md](../../schemas/genome-v2.md)): movement and
ingestion are per second, with ranges ×20. `Genome::per_second` reads either schema.
A schema 1 rate reads as exactly ×20.
- **Drafts** default to schema 1, so every existing literal keeps its per-tick
meaning. New records name schema 2.
- **Development version 1 stays defined in 50 ms ticks**
(`development_v1_tick_microseconds`). It reads genome rates per second and converts
them at that quantum, rounding down (capacities). Its per-tick outputs are unchanged.
A schema 1 genome and its exact schema 2 translation develop identically.
Development's outputs move to per-second rates in segment 3, at the consumers.
- **Mutation** keeps the parent's schema and step. Mutation offers are seeded from the
genome's digest, so migrating a lineage's records would change every later offer;
no lineage is migrated.
- **The lineage archive** header names exactly the highest schema held. An all-schema-1
archive, which is what dev worlds hold, keeps its bytes.
- **The development opening** (`development-v1`) names schema 1 explicitly; it is a
fixed genesis.
- **Tests that used 2 as an unknown future schema** now use the next unknown one. The
archive decoder refuses a header that misstates its contents.
## Segment 3 as implemented (2026-10-09)
- **Environmental community rules 3** is rules 2 with every rate per second:
irradiance and growth as rationals per second, and intake and decay caps per
second.
- At creation and restore, the community derives its per-tick form once. The
rationals convert exactly, because the tick folds into numerator and denominator.
The caps round down.
- Steps run on that form unchanged, the snapshot keeps rules 2's layout, and the
codec reads rules 1 to 3.
- At 50 ms, a ×20 per-second twin of a rules 2 configuration steps identically
through feeding, death and decay, and across a snapshot. At 25 ms the caps halve.
- Rules 1 and 2, including the dev world's fixed `development-v1` opening, are
unchanged.
- **Development version 1 outputs** (maintenance, movement, intake limit) stay per
tick of its 50 ms quantum, which is how that version is defined.
- A live process at another tick reads them through `per_second_from_per_tick` and
`per_tick`.
- Development version 2 (the birth-cost re-derivation, ADR-0098) is defined per
second natively.
- **The M2 ecosystem fixtures** (consumer and producer configurations, the feeding
decomposition limit) are tick-abstract test oracles with no time base, and are not
migrated. New gameplay processes (11.3) use per-second rates from the start.
- **Result:** every rate that a live world can run on is now either per second
(genome schema 2, rules 3) or tied to a declared quantum it converts from.
## Development version 2 and the first bud (2026-10-09)
The maintainer chose to set the birth-cost target now and tune it in playtests
(ADR-0098 decision 7).
- **Development version 2** is defined per second. Phenotype and budget rates carry
their period (`rate_microseconds`: 50 ms for version 1, 1 s for version 2), and the
M2 fixture adapters accept only version 1.
- **Its constants are tunable values, not locked rules:**
- maintenance 10 and membrane upkeep 15 pJ/s per 1000 fg, a quarter of version 1's
per-second equivalent;
- movement 50 pJ/s per 1000 fg at 1 mm/s;
- construction 40 pJ per 1000 fg and intake energy 50 pJ per fg, unchanged;
- the same compositions and geometry as version 1.
- **The primitive founder** (`biology/founder.hpp`; schema 2, development 2; tunable):
energy conversion 400‰, 1 um membrane, 8e6 fg target, movement 200 um/s, ingestion
574,000 fg/s at the reference surface, and a bud of 500‰ of the body.
- **The result** (`bud_funding_seconds`, an analysis): a full-grown founder pays its
whole demand, including full-speed movement, all of the time. Feeding at its intake
limit for 100%, 50% and 33% of the time funds its first bud in 300, 600 and 901 s
(5, 10 and 15 minutes). At 10% of the time it never does.
- Phosphorus binds first: the bud keeps the body's composition, and the membrane is
P-rich, while intake comes in the structure's composition.
- The test pins the decision's range, not exact values.
- **Assumed:** the founder starts fully grown. How a new life's body is funded is
11.2's contract, and may change the first-bud time.
## Consequences
- Segment 1: `accounting/rates.hpp` (`per_tick`, `exact_per_tick`,
`per_second_from_per_tick`) and the `rate-contracts` test.
- Segments 2 and 3 migrate the fields above, with new versions and unchanged 50 ms
goldens.