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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user