An epoch cannot order two writes an owner makes inside it

Two defects from review of 1c8b292.

Replacement checked the ownership epoch and nothing that ordered two writes made
inside one, so an owner could replay its own earlier record: a cohort installed
at tick 1,000 holding 50 picojoules accepted its own tick-900 record holding 100,
restoring inventory the installed one had already spent. A cohort now carries a
revision that strictly increases within an epoch, and a repeated revision is
refused as well as an older one, because a write has to be strictly later rather
than merely not earlier. A newer epoch may restart the series, since re-acquiring
ownership begins a new one, but the interval boundary is checked independently of
both, so neither advancing a revision nor re-acquiring ownership rewinds
simulated time. A later revision at the same boundary stays legitimate: that is a
correction, not a rewind.

The implicit move emptied a cohort's age classes while keeping its habitat,
genome and owner, so a moved-from record was exactly the invalid cohort create
refuses to build, and the registry accepted through a move what it rejects
through construction. The type is copy-only now, so a move decays to a copy and
the source stays whole. ADR-0030 made the genome copy-only for this same reason
in M3.1; the precedent existed and was not applied when this type was written.

Both fixes were confirmed load-bearing by reverting each alone. Removing either
ordering check fails the new regression. Removing the copy declarations fails to
compile, and not only through the static assertion: with that also removed, MSVC
proves the code after the class-count check unreachable, having established that
a moved-from vector is empty and the check always throws. That is a compile-time
proof rather than an execution, so the runtime path was checked separately under
ASan, where the same mutation exits 1.

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 09:05:05 -04:00
co-authored by Claude Opus 5
parent 1c8b292147
commit 5a4c34a903
8 changed files with 273 additions and 33 deletions
+13
View File
@@ -319,3 +319,16 @@ 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.
Review of `1c8b292` found two defects, both fixed with regressions confirmed to
fail without their fix. Replacement checked the ownership epoch but nothing that
ordered two writes inside one: a record installed at tick 1,000 holding 50
picojoules could be replaced by its own earlier tick-900 record holding 100,
restoring inventory the installed one had already spent. Cohorts now carry a
revision that strictly increases within an epoch, and the interval boundary is
checked independently, so neither advancing a revision nor re-acquiring ownership
rewinds simulated time. Separately, the implicit move emptied a cohort's age
classes while keeping its identities, and the registry then accepted through a
move exactly what `create` rejects by name; the type is now copy-only, as ADR-0030
already made the genome for the same reason. That precedent existed and should
have been applied when the type was written.
+31 -7
View File
@@ -53,10 +53,24 @@ 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.
is exactly what ECOLOGY_MODEL locks against.
A replacement must be a strictly later view of the same record by the same owner,
and an epoch alone cannot establish that. Two writes inside one epoch are
otherwise interchangeable, so an owner replaying its own earlier record would
restore inventory the installed one had already spent. Every cohort therefore
carries a revision that strictly increases within an epoch; a newer epoch may
restart the series, because re-acquiring ownership begins a new one. Independently
of both, the interval boundary may not run backwards, so neither advancing a
revision nor re-acquiring ownership is a way to rewind simulated time.
A cohort is copy-only. A moved-from record would keep its habitat, genome, owner
and totals while losing its age classes, which is precisely the invalid cohort
`create` refuses to build, and the registry would then accept through a move what
it rejects through construction. Declaring the copy operations suppresses the
implicit moves, so a move decays to a copy and the source stays valid. ADR-0030
made the genome copy-only for the same reason: a validated value whose move leaves
it invalid is the same defect wherever it appears.
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
@@ -75,6 +89,12 @@ 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.
Ordering replacements by epoch alone was tried and is wrong: it cannot separate
two writes an owner makes inside one epoch. Ordering by the interval boundary
alone would reject a legitimate correction at the same boundary, and ordering by
revision alone would let a newer revision rewind the boundary, so both are
checked. A validity-preserving move was considered and is not possible: leaving
the source valid would mean leaving it its classes, which is not a move.
## Benefits
@@ -112,9 +132,13 @@ 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
under a wrong owner, a stale epoch, a repeated or older revision within an epoch,
a backward interval boundary, or a changed habitat or genome, and that it succeeds
for a strictly later view. Test that a new epoch may restart the revision series
and still may not rewind the boundary, and that a moved-from cohort keeps its
classes so neither installing nor replacing with one bypasses construction. 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.
+5 -2
View File
@@ -144,8 +144,11 @@ 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
at most one record per habitat and genome, and by requiring a replacement to be a
strictly later view of the same record: same worker, no older epoch, an advancing
revision within an epoch, and an interval boundary that never runs backwards. An
epoch alone is too coarse, because an owner replaying its own earlier record
inside one epoch would restore inventory the installed record had already spent. 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.
+43
View File
@@ -918,3 +918,46 @@ 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`.
Review of `1c8b292` found two defects (2026-09-24), both fixed with regressions
confirmed to fail against the unfixed code.
Replacement checked the ownership epoch and nothing that ordered two writes made
inside one. A record installed at tick 1,000 holding 50 picojoules could be
replaced by its own earlier tick-900 record holding 100, restoring inventory the
installed record had already spent, because within an epoch the two were
interchangeable. A cohort now carries a revision that strictly increases within an
epoch, and a repeated revision is refused as well as an older one, since a write
has to be strictly later rather than merely not earlier. A newer epoch may restart
the series, because re-acquiring ownership begins a new one. The interval boundary
is checked independently of both, so neither advancing a revision nor re-acquiring
ownership is a way to rewind simulated time. A later revision at the same boundary
stays legitimate: that is a correction, not a rewind.
The implicit move emptied a cohort's age classes while keeping its habitat, genome
and owner, so a moved-from record was the invalid cohort `create` refuses to build
and the registry accepted through a move what it rejects through construction. The
type is now copy-only, which suppresses the implicit moves so a move decays to a
copy. ADR-0030 made the genome copy-only for exactly this reason in M3.1; the
precedent existed and was not applied when this type was written.
Both fixes were confirmed load-bearing by reverting each alone. Removing the
revision check fails the new ordering regression, as does removing the backward
boundary check. Removing the copy declarations fails to compile in Release, and
not because of the static assertion: with that assertion also removed, MSVC proves
the code after `source.classes().size() == 3` unreachable, having established that
a moved-from vector is empty and the check therefore always throws. That is a
compile-time proof of the assertion rather than an execution of it, so the runtime
path was checked separately under the ASan preset, where the same mutation exits 1.
Coverage limits are unchanged from the increment above, with one addition. The
revision is a caller-supplied counter, not one the registry issues, so nothing
prevents a caller from choosing revisions that are unrelated to its own write
order; what is enforced is only that the registry refuses a record that is not
strictly later than the one it holds. Issuing revisions, and fencing between
workers, remain M7 and M10.
No existing contract changed. The proof golden `d61ad5bf0c928c76`, the ecosystem
fingerprint `2cd4a15f9fbe9949`, the ensemble fingerprint `5ec59d390909b526` and
the frozen genome fixture are unchanged. Linux validation is pending; no Gitea
result is claimed since `b01a824`.