Keep a distribution, because a mean cannot say who survives

M4.1 defines the tier 2 record and who may act on it, and nothing else: no
collapse transaction, no population advance, no materialization, no habitat
geometry. Those are M4.2 to M4.4 and each needs its own decision.

The named risk for this step is that population averages hide viable outliers,
which is a property of the record rather than of the maths applied to it later,
so it is answered here. Age classes each carry their own count and their own
reserve. A count with a mean reserve cannot tell a provisioned cohort from one
where half the members hold nothing, and nothing downstream can recover what
that discarded. Within a class members are indistinguishable; that is the
declared resolution and a stated loss. No accessor returns a mean, because an
average that is easy to reach becomes the authority.

Totals are summed from the classes rather than stored beside them, following the
archive's rule that a second tally is a thing that can disagree. Lineage is not a
field at all: ancestry is resolved from the genome through the archive, so a
cohort cannot contradict it or invent parentage from membership. Residuals are
integer numerators strictly below one member and are never added to a count.

Ownership is enforced rather than described. One record per habitat and genome
makes no-inventory-spendable-in-two-tiers unrepresentable instead of forbidden,
and replacement is refused under a different worker or an older epoch. That is a
single-process invariant; fencing between workers is M7 and M10. The
approximation bound is carried and never computed, since carrying a bound is not
meeting one.

All nine guards were confirmed load-bearing by removing each and rerunning. An
earlier sweep reporting none of them load-bearing was wrong and discarded: it
wrote to /tmp, which Git Bash and PowerShell resolve differently, so nothing was
ever mutated.

Release 34/34, analysis, ASan 34/34 and clang-format all ran and passed here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-09-24 06:14:07 -04:00
co-authored by Claude Opus 5
parent 72ed03f4dd
commit 1c8b292147
11 changed files with 1045 additions and 2 deletions
+10
View File
@@ -96,6 +96,16 @@ that carried it, ancestry and descendants resolve through dead links, and a
lineage with no living carrier is reported absent and never extinct, because
terminal extinction needs a reconciled watermark this type cannot see. NPC
mutation stays undecided: the archive records an origin event and never an actor.
M4.1 opens M4 (ADR-0036): a validated `Cohort` holding age classes that each carry
their own count and reserve, so the record stores a distribution rather than the
mean the named risk warns about, with totals derived from those classes and no
stored tally that could disagree. Lineage is absent by design, because ancestry is
the archive's answer resolved from the genome. Residuals are integer fractions
strictly below one member. `CohortRegistry` admits one record per habitat and
genome and refuses replacement under a wrong worker or an older epoch, so
ECOLOGY_MODEL's "no inventory spendable in two tiers" is enforced rather than
described. No collapse, advance or materialization exists yet.
M3.6 closes M3 by making the pieces meet (ADR-0035): `strategy_for` turns a genome
into the `StrategyConfig` the M2.6 driver already takes, founders are pre-diverged
variants of one ancestor admitted to the archive, and `evo-sim --ensemble` runs
+29 -2
View File
@@ -7,7 +7,7 @@ persistent simulation server. The founding vision remains unchanged.
## Completed implementation
- Vision, architectural pillars, risks, open-question register, architecture
diagrams, biological contracts, engineering constitution and 35 ADRs.
diagrams, biological contracts, engineering constitution and 36 ADRs.
Proposed/deferred choices remain distinct from accepted proof decisions.
- M0–M4 task breakdowns with dependencies, acceptance evidence and risks,
plus M5–M14 gates in [ROADMAP.md](ROADMAP.md).
@@ -61,7 +61,7 @@ for the bounded proof; the general production ECS remains a later measured choic
| Priority | Work | Completion evidence |
|---|---|---|
| 1 | M4.1 cohort state and ownership | Genome, lineage, counts, age, reserves, residuals and ownership made explicit |
| 1 | M4.2 collapse active individuals | Transfer IDs and reserves into one cohort atomically, with exact ledger conservation |
| 2 | Revisit the ADR-0031/0032 reproduction cost model | Reproduction is affordable only at the genome schema's floor; decide whether that is intended before M4 builds cohorts on it |
| Delivery gate | Add/update the dev workload when a deployable increment needs it; Argo is ready | Observe Job/pod completion separately from image publication; no World0 changes |
@@ -292,3 +292,30 @@ logout treatment, species/extinction rules and multicellular transition remain
open decisions. Renderer/networking remain later milestones. Deployment
availability does not complete M7/M8: fenced ownership, durable outcomes, backup
restore and world-version migration require their own implementation/fault tests.
M4.1 opens M4 (ADR-0036) by defining the tier 2 record and who may act on it, and
nothing else: there is no collapse transaction, no population advance, no
materialization and no habitat geometry. A `Cohort` is validated on construction
and never mutated afterwards. Age classes each carry their own count and their own
reserve, so the record holds a distribution rather than the mean the milestone's
named risk warns about; within a class members are indistinguishable, which is the
record's declared resolution and a stated loss rather than a hidden one. No
accessor returns a mean. Totals are summed from the classes instead of stored
beside them, following the lineage archive's rule that a second tally is a thing
that can disagree. Lineage is deliberately not a field: ancestry is resolved from
the genome through the archive, so a cohort cannot contradict it or invent
parentage from membership. Residuals are integer numerators over a declared scale,
strictly below one member, and are never added to a count.
Ownership is enforced rather than described. `CohortRegistry` admits at most one
record per habitat and genome, so ECOLOGY_MODEL's "no inventory is spendable in
two tiers" is unrepresentable rather than forbidden, and replacement is refused
under a different worker, an older epoch, or a changed habitat or genome. Epochs
make a stale writer fail locally and say nothing about fencing between workers,
which stays M7 and M10. The approximation bound is carried and never computed:
M4.5 measures resolution equivalence, and carrying a bound is not meeting one.
Nothing is serialized, so `schemas/population-v1.md` pins field meaning and
invariants rather than a byte layout. All nine construction and registry guards
were confirmed load-bearing by removing each one and observing the suite fail.
Native Release, analysis, ASan and formatting passed 34/34; Linux CI has not run
yet.
+120
View File
@@ -0,0 +1,120 @@
# ADR-0036: Cohort state, declared resolution and exclusive ownership
## Status
Adopted for M4.1. It defines the tier 2 record and who may act on it, and nothing
else: there is no collapse transaction, no population advance, no materialization
and no habitat geometry. Those are M4.2 to M4.4 and each needs its own decision.
No M1 to M3 contract changes. ECOLOGY_MODEL's population math stays an experiment.
## Context
ECOLOGY_MODEL locks two things about tier 2 and leaves the rest recommended: no
inventory is spendable in two tiers, and distinct genomes are never averaged into
one genome. Everything M4 does afterwards moves inventory between a cohort and
individuals, so the record has to exist and has to be checkable before any of that
is written. M3 supplies what a cohort is about: a genome that validates, a
phenotype that derives from it and an archive that retains its ancestry.
The named risk for this step is that population averages hide viable outliers. A
record holding a count and a mean reserve cannot answer whether anyone in it would
survive, because a well-provisioned member and a starving one reduce to the same
average. That is a property of the record, not of the maths applied to it later,
so it has to be answered here or not at all.
## Decision
A `Cohort` is a validated value. `Cohort::create` takes a draft and either returns
a cohort meeting every invariant below or an error naming the one it broke; there
is no way to assemble one field by field and no way to mutate a field afterwards.
Age structure is a sequence of classes, each carrying its own count and its own
reserve. A cohort therefore stores a distribution and never a mean. Within one
class members are indistinguishable, which is a real loss and is the record's
declared resolution: the class bounds state it, and a reader that needs finer
structure declares narrower classes rather than dividing a total. No accessor
returns a mean, because an average that is easy to reach is an average that will
be used as the authority.
Totals are derived by summing the classes, never stored beside them. The lineage
archive already establishes this: a second tally is a thing that can disagree.
Summation rejects overflow rather than wrapping.
A cohort names the genome it carries and does not store its lineage. Ancestry is
the archive's answer, resolved from the genome, so a cohort cannot claim a
parentage the archive would contradict and cannot invent precise parentage from a
statistical membership, which ECOLOGY_MODEL forbids.
Fractional members are carried per class as a residual: an integer numerator over
a declared scale, strictly less than one member. Integer arithmetic only, as
everywhere else in this project. A residual is owed and not yet present, so it is
not a count and is never added to one. Funding it is M4.3's problem.
Ownership is exclusive and enforced rather than described. A `CohortRegistry`
admits at most one cohort per habitat and genome, because two records of the same
genome in one habitat would be two places the same biomass could be spent, which
is exactly what ECOLOGY_MODEL locks against. Every cohort names an owner and an
epoch, and a registry replacement is refused unless it comes from the recorded
owner under the recorded epoch and leaves the habitat and genome unchanged. A late
writer holding an old view cannot install it.
Approximation error is a declared field, carried and never computed here. M4.5
measures resolution equivalence; a bound this type calculated for itself would be
a claim it has no basis for.
## Alternatives Considered
Storing a count with mean age and mean reserve is smaller and is what the risk
warns about: it cannot distinguish a cohort that is fine from one where half the
members are about to starve, and no later stage can recover what it discarded.
Storing lineage on the cohort would make membership self-describing at the cost of
a second ancestry that can drift from the archive's and of inviting invented
parentage. Storing totals beside the classes would save a summation and introduce
a field that can disagree with the classes it summarises. Floating point would
make residuals natural and determinism impossible. Leaving ownership as a
documented rule with a field to check would repeat the mistake ADR-0034 corrected:
an invariant nothing enforces is an invariant a later change removes quietly.
Making the registry own conversion as well would settle M4.2 by implication.
## Benefits
The record can answer who is viable, because it never averaged that away. Double
ownership of one genome's biomass in one habitat is unrepresentable rather than
forbidden. Every total is derived, so no two fields of a cohort can disagree.
Ancestry has exactly one authority. Residuals are explicit, bounded and integer,
so a fractional member can never be mistaken for an available one.
## Costs
A cohort is larger than a count and a mean, and every class costs an inventory.
Declaring classes is a modelling decision a caller has to make, and a caller that
declares one wide class gets the average it was trying to avoid. Totals cost a
summation on every query. The registry is a bounded in-memory container with no
persistence, no sharding and no cross-worker protocol; nothing here is serialized.
## Risks
A cohort is not evidence that aggregation is ecologically faithful. It holds a
declared approximation bound that nothing yet computes or checks, and carrying a
bound is not meeting one. The class boundaries are a chosen resolution, and
structure finer than one class is genuinely gone. Conservation between a cohort
and the rest of the world is the ledger's property and is not asserted by this
type, which holds an inventory without participating in any transfer. Ownership
here is a single-process invariant: epochs make a stale writer fail locally and
say nothing about fencing across workers, which is M7 and M10. Nothing in this
ADR says a population may advance, collapse or materialize.
## Consequences
Test that a valid cohort round-trips its declared fields, that totals equal the
summed classes, and that every invariant is rejected by name: an unsupported
representation version, a zero identity, no classes, classes that are unordered,
overlapping or empty, a class holding reserve with nothing to hold it, a residual
of one member or more, and a summation that would overflow. Test that a registry
refuses a second cohort for one habitat and genome, that replacement is refused
under a wrong owner, a stale epoch or a changed habitat or genome, and that it
succeeds under the recorded owner. Test that a cohort names a genome the archive
can resolve ancestry for without storing that ancestry. Negative reserves are not
representable, since every quantity here is unsigned; what is rejected instead is
a declared state that would require one. No genome schema, mutation catalog,
archive, ledger, episode driver, ensemble, renderer or deployment changes.
+1
View File
@@ -28,6 +28,7 @@ Each record has the eight required sections.
0033 adopts the bounded mutation catalog and uniform seeded candidate draws.
0034 adopts the permanent lineage archive and absence that is never extinction.
0035 derives strategies from genomes and measures them over a split-half gradient.
0036 defines the tier 2 cohort, its declared resolution and exclusive ownership.
Every dependency adoption records exact version/commit and integrity hash,
transitive license obligations, maintenance/security review, owner and removal
+39
View File
@@ -115,3 +115,42 @@ The shared bounded controller proposal is exercised only as a measurement driver
It has no perception, no learning and no evolving behavior, and its constants are
inputs rather than results. Population math, cohort collapse and resolution
equivalence remain M4 work.
## Implemented M4.1 cohort record
[ADR-0036](../adr/0036-cohort-state-and-ownership.md) defines the tier 2 record
and who may act on it. It settles nothing else above: there is no conversion
transaction, no population advance, no representative materialization and no
habitat geometry. `PlanCollapse`, `CommitCollapse`, `AdvancePopulation`,
`PlanMaterialize`, `CommitMaterialize` and `TransferPopulation` remain contracts
nothing implements.
A cohort is per genome, so distinct genomes are never averaged into one. Its age
classes each carry their own count and their own reserve, which is how the record
answers the risk that population averages hide viable outliers: a count with a
mean reserve cannot distinguish a provisioned cohort from one where half the
members hold nothing, and nothing later can recover that. Within one class members
are indistinguishable, and that is the declared resolution rather than an
oversight. No accessor returns a mean.
Lineage is not stored. It is resolved from the genome through the archive, so a
cohort cannot claim a parentage the archive would contradict and cannot invent
precise parentage from statistical membership. Totals are derived from the classes
rather than stored beside them.
Fractional members are carried per class as integer numerators over a declared
scale, strictly below one member. An expected fractional density is therefore
never mistaken for an available individual. Funding a residual against biomass,
and the seeded rule that turns one into a member, are M4.3 and M4.4.
`CohortRegistry` enforces that no inventory is spendable in two tiers by admitting
at most one record per habitat and genome, and by refusing a replacement from a
different worker or an older epoch. This is a single-process invariant: epochs
make a stale writer fail locally and are not cross-worker fencing, which is M7 and
M10. The registry holds no lock, lease or quorum, and nothing is serialized.
Approximation error is a declared field that nothing computes or checks yet.
Carrying a bound is not meeting one; M4.5 is where resolution equivalence is
measured. Conservation between a cohort and the rest of the world is the ledger's
property and is not asserted by this type, which holds an inventory without
participating in any transfer.
+58
View File
@@ -860,3 +860,61 @@ lifetimes mean a run's mean lifetime is not computable from `lived_ticks` alone
and no test asserts one. Across a run the archive now ends holding living
carriers, which is accurate about what was observed and is not a claim that
anything persists; nothing is serialized.
## M4.1 cohort state and ownership
Executed on this Windows host (2026-09-24): Release configure, build and `ctest`
34/34; the analysis preset (clang-tidy 19, warnings as errors) built clean; the
ASan preset configured, built and ran 34/34; `clang-format` 19.1.5 reported no
violations. All four checks ran and passed on the committed tree. No Clang or GCC
compile happens on this host, so Linux CI remains the first result for the new
`evo::ecology` library.
`evo-cohort-tests` covers six properties: that a cohort keeps exactly the fields
it was given, that totals equal the summed classes, that two cohorts with
identical totals but different structure are distinguishable, that every
construction invariant is rejected by its own named error, that one habitat and
genome holds one record, and that only the recorded owner under a current epoch
may replace it. A sixth checks that a cohort names a genome the archive resolves
ancestry for without storing that ancestry.
Every guard was confirmed load-bearing rather than assumed. Each of the nine was
removed in turn and the suite rebuilt and rerun: the duplicate, stale epoch, wrong
owner, unowned reserve, residual bound, class ordering, empty class and class
range guards each produced a failing run, and removing the overflow guard fails to
compile, because the running totals then have no reader and the Release build
treats that warning as an error. An earlier attempt at this sweep reported all
nine as not load-bearing; that result was false and was discarded. The harness
wrote to `/tmp`, which Git Bash and PowerShell resolve to different directories,
so the mutation script was never found and the source was never modified. The
sweep was rerun against an absolute path.
Two defects in my own test code were found and fixed before the suite was trusted.
The single-argument `CHECK` macro split on the comma inside a braced initializer
such as `Owner{11, 2}`, which is a compile error rather than a silent one, and the
macro is now variadic. More seriously, the rejection tests originally asserted on
`.error()` alone, which is undefined when the call unexpectedly succeeded and would
have let a removed guard pass quietly; they now check the failure first through a
`refused` helper. A regex rewrite applied to make that change spanned lines and
corrupted several positive assertions, so the test file was rewritten rather than
patched.
Coverage limits. Nothing here is serialized, so `schemas/population-v1.md` pins
field meaning and invariants and there is no encoder, no round trip and no
migration to test. The approximation bound is carried and never computed or
checked, so no test asserts that aggregation is faithful; that is M4.5.
Conservation between a cohort and the rest of the world is not asserted, because
this type holds an inventory without participating in any transfer. Ownership is
tested as a single-process invariant only: epochs make a stale writer fail locally
and nothing here exercises fencing between workers, which is M7 and M10. Negative
reserves are not representable at all, since every quantity is unsigned, so what
the suite rejects instead is a declared state that would require one, and two
static assertions record that the underlying types are unsigned. `max_cohorts` is
enforced but not exercised at its limit, since installing 4,096 records would add
nothing to what the duplicate and lookup tests already establish.
No existing contract changed. The proof golden `d61ad5bf0c928c76`, the ecosystem
fingerprint `2cd4a15f9fbe9949`, the ensemble fingerprint `5ec59d390909b526` and
the frozen genome fixture are all unchanged, and the other 33 tests pass
untouched. No deployment manifest or image pin changed. Linux validation is
pending; no Gitea result is claimed since `b01a824`.