Files
aevolution/docs/adr/0029-ecosystem-driver-and-episodes.md
T
dingoandClaude Opus 5 eaf58f2b85 Drive the energy cycle with measured ecosystem episodes
Close M2 with a deterministic driver that owns one community and one
seeded stream, holds no inventory and emits only the terminal, feeding
and reproduction intents the earlier increments already accept. No
simulation contract changed to make the cycle run unattended.

Two limits shaped the design. Identities are never reused and slots are
capped, so one community supports a bounded number of consumer lifetimes
and is not a population. No maintenance cost exists, so a consumer that
is never eaten never dies, and inventing a starvation rule here would
settle a question ENERGY_MODEL leaves open inside a measurement harness.
The harness therefore measures many bounded episodes, taking mortality
from predation and from a configured lifespan delivered as an ADR-0027
host terminal fact. Lifespan bounds an episode; it is not senescence.

The driver must never submit a batch the community rejects, so it probes
a discarded copy each tick to size bites against the state feeding will
actually see, claims each target for one feeder, and excludes a bitten
consumer from acting. A rejected tick is reported as a driver defect
rather than absorbed as ecology.

Across 64 seeds the suite steps tick by tick, requiring exact conserved
totals at every tick and an identical report on replay, and covers both
mortality paths, slot exhaustion, tick-limit termination, lineage
attribution, episode independence and configuration rejection.
evo-sim --ecosystem reports seeded ensembles: 3,000 episodes advanced
1,093,007 ticks, all reaching extinction, with deaths reconciling exactly
against founders plus births. That demonstrates arithmetic and turnover,
not ecological plausibility; strategy constants are chosen inputs.

Native Release, clang-tidy analysis, ASan and format checks pass 11/11;
golden d61ad5bf0c928c76 is unchanged. Linux CI has not run yet.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 17:38:34 -04:00

115 lines
6.4 KiB
Markdown

# ADR-0029: Deterministic ecosystem driver and bounded episodes
## Status
Adopted for the M2.6 headless measurement harness. No gameplay AI, perception,
behavior model, senescence biology, metabolic rate or population abstraction is
selected. The simulation contracts of ADR-0024 through ADR-0028 are unchanged.
## Context
M2.2 through M2.5 close the transfer cycle, but every intent is supplied by the
caller. Nothing decides what happens, so a long run needs a decision source before
extinction or diversity can be measured at all.
Two structural limits surfaced while scoping this increment. First, ADR-0028
retains identities permanently and caps slots at `max_consumers`, so one community
supports a bounded number of consumer lifetimes and is not a population: a single
million-tick community would spend almost all of those ticks after slot exhaustion
in a static state. Second, no maintenance cost exists, so a consumer that is never
eaten never dies and a run has no endogenous end. ENERGY_MODEL leaves baseline
metabolism and starvation rules open, so inventing them here would settle an open
biological question inside a measurement harness.
## Decision
Add `EcosystemEpisode`, which privately owns one `FeedingCommunity` and one seeded
`Random` stream. It holds no inventory, performs no transfers and calls no public
mutator other than `advance`. It reads committed public state and emits intents.
Measure many bounded episodes rather than one long community. Each episode ends at
extinction, defined here as no living consumer, or at a configured tick limit.
Because births consume permanent slots and every consumer has a finite lifespan,
extinction is reachable in every episode. The long-run figure is the total ticks
advanced across seeded episodes, and each episode reports its own outcome.
Mortality has exactly two sources, both already contracted. Predation: the driver
bites a target's entire remaining balance when that fits the intake cap, which
ADR-0026 already turns into terminal depletion. Lifespan: the driver emits an
ADR-0027 terminal fact once a consumer's age reaches its configured lifespan.
Lifespan is a host scheduling rule that bounds the episode, not senescence, aging
biology or a death cause. No maintenance, starvation or metabolic cost is added.
A founder strategy fixes opening inventory, intake cap, assimilation, an investment
bundle, a reproduction threshold and a lifespan. ADR-0028 makes a child duplicate
its parent, so a founder strategy identifies one lineage for the whole episode and
competing strategies are the only source of variation. Lineage membership is
recovered by walking retained parent references to a founder.
Per tick the driver emits, in this order: terminal facts for every active consumer
that has reached its lifespan; then feed intents; then reproduce intents. It must
never submit a batch the community rejects, so it applies three self-restrictions.
A consumer terminated this tick neither feeds nor is fed upon nor reproduces. Each
target is claimed by at most one feeder per tick, assigned in ascending consumer
ID, which removes contention rejection. A consumer that is a feeding target this
tick does not reproduce this tick, which removes the interaction between a reduced
balance and the later reproduction check. Reproduce intents are truncated to the
number of free slots in ascending parent ID. Bites are per-channel
`min(intake cap, target balance)` and targets with no inventory are skipped.
A rejected `advance` is therefore a driver defect, not an ecological outcome, and
is reported as `community_failure` rather than being retried or absorbed. Target
selection draws from the seeded stream; nothing else consults it.
Each episode reports seed, ticks advanced, births, predation and lifespan deaths,
extinction tick, founder and surviving lineage counts, cumulative decomposition,
conserved totals and a state fingerprint. Conserved totals must be identical at
every tick. The report is data for review, not a pass threshold.
## Alternatives Considered
A maintenance cost with a starvation rule would give endogenous mortality, but
ENERGY_MODEL leaves metabolism and starvation explicitly open and a measurement
harness is the wrong place to settle them. Reusing retired slots would destroy the
ancestry ADR-0028 just established. Raising `max_consumers` delays exhaustion
without removing it and would widen per-tick intent bounds with no evidence. One
continuous million-tick community measures a static post-exhaustion state. Letting
the driver retry a rejected batch would hide driver defects as ecology.
## Benefits
The full cycle runs unattended and deterministically: nutrients fund growth, growth
funds feeding, feeding funds offspring, lifespan and predation produce corpses, and
decomposition returns matter. Extinction and lineage survival become measurable
across seeds, conservation is checked every tick over long horizons, and the driver
is separable from the contracts it exercises.
## Costs
Episode length is bounded by slots times lifespan, so this measures many short
histories rather than one long one. Strategy constants, lifespans and the targeting
rule are chosen, not derived. One-feeder-per-target and the reproduction exclusion
are scheduling conveniences that bias contention away from the ordering ADR-0026
deliberately exposes. Whole-community copies per tick remain the baseline.
## Risks
Do not read episode statistics as population dynamics, life-history theory or
balance. Lifespan is not senescence, targeting is not perception, and a surviving
lineage count is not speciation or fitness. Conservation holding across a million
ticks demonstrates arithmetic, not ecological plausibility, and the explicit risk
of this increment is passing every invariant while modelling nothing interesting.
Strategy constants must not become gameplay by having been measured.
## Consequences
Test per-tick conservation and nonnegative balances across many seeds, identical
reports for one seed on repeated runs, independence of episodes, extinction
reached and recorded, lineage attribution through retained ancestry, both mortality
paths, slot exhaustion, tick-limit termination, a single-founder episode, an
episode whose founders cannot reproduce, and that the driver never provokes a
rejected batch. Cross-platform fingerprints must agree. No snapshot format,
database, renderer, deployment or simulation contract changes. Serialized recovery
of episode state is not provided; M4 aggregation remains the path to real
populations.