M11.1: time-based rate conversion (ADR-0099, segment 1)
Foundation / checks (deploy) (push) Successful in 3m27s
Foundation / checks (ecs) (push) Successful in 1m51s
Foundation / checks (client) (push) Successful in 12m31s
Foundation / checks (network) (push) Successful in 13m30s
Foundation / checks (tsan) (push) Canceled after 8m42s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 27m37s
Foundation / checks (postgres) (push) Canceled after 15m9s
Foundation / checks (deploy) (push) Successful in 3m27s
Foundation / checks (ecs) (push) Successful in 1m51s
Foundation / checks (client) (push) Successful in 12m31s
Foundation / checks (network) (push) Successful in 13m30s
Foundation / checks (tsan) (push) Canceled after 8m42s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 27m37s
Foundation / checks (postgres) (push) Canceled after 15m9s
Rates are stored per second in their integer base units and converted at the tick boundary with no carried state: costs round up, capacities down (maintainer decision), error below one unit per tick. per_second_from_per_tick is the migration's exact inverse (x20 at 50 ms) and refuses inexact values. New rate-contracts test. No biology uses it yet; genome v2, development v2 and process fields follow. Refresh the dev session window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
# 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.
|
||||
|
||||
## 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.
|
||||
Reference in New Issue
Block a user