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:
@@ -26,7 +26,8 @@ materializes anything.
|
||||
| genome | u64 | The genome every member carries. Nonzero |
|
||||
| owner worker | u64 | Who integrates this cohort. Nonzero |
|
||||
| owner epoch | u64 | Which epoch that ownership is held under. Nonzero |
|
||||
| last tick | u64 | The last interval boundary this record was integrated to |
|
||||
| last tick | u64 | The last interval boundary integrated to. Never runs backwards |
|
||||
| revision | u64 | Nonzero. Strictly increases with every replacement within an epoch |
|
||||
| conversion | u64 | The conversion that produced this record. Nonzero provenance |
|
||||
| age classes | 1 to 64 | Ordered, disjoint, each non-empty. See below |
|
||||
| approximation bound | count + inventory | Declared, never computed here |
|
||||
@@ -72,7 +73,7 @@ error instead.
|
||||
| Rejected | Error |
|
||||
|---|---|
|
||||
| Representation version other than 1 | `unsupported_version` |
|
||||
| Zero habitat, genome, owner worker, owner epoch or conversion | `invalid_identity` |
|
||||
| Zero habitat, genome, owner worker, owner epoch, revision or conversion | `invalid_identity` |
|
||||
| No age classes | `no_age_classes` |
|
||||
| More than 64 age classes | `overflow` |
|
||||
| `age_high <= age_low`, or a class overlapping or preceding the one before it | `unordered_age_classes` |
|
||||
@@ -99,9 +100,23 @@ forbidden by convention.
|
||||
| Replacing a record that is not installed, or naming a different habitat or genome | `unknown_cohort` |
|
||||
| Replacing under a different worker | `wrong_owner` |
|
||||
| Replacing under an older epoch | `stale_epoch` |
|
||||
| Replacing with a repeated or older revision inside one epoch | `stale_revision` |
|
||||
| Replacing with an earlier interval boundary, under any epoch | `backward_tick` |
|
||||
| Installing beyond `max_cohorts` (4,096) | `registry_full` |
|
||||
|
||||
An owner replacing under its own current epoch is the ordinary case and is
|
||||
accepted. Epochs make a stale writer fail locally; they say nothing about fencing
|
||||
between workers, which is M7 and M10. The registry is in-memory, single-process
|
||||
and holds no lock, lease or quorum.
|
||||
A replacement has to be a strictly later view of the same record. An epoch alone
|
||||
cannot establish that, because two writes an owner makes inside one epoch are
|
||||
otherwise interchangeable and replaying the earlier one would restore inventory
|
||||
the installed record had already spent. The revision orders writes within an
|
||||
epoch; a newer epoch may restart the series, since re-acquiring ownership begins a
|
||||
new one. 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 is legitimate and accepted: it is a correction.
|
||||
|
||||
Epochs make a stale writer fail locally; they say nothing about fencing between
|
||||
workers, which is M7 and M10. The registry is in-memory, single-process and holds
|
||||
no lock, lease or quorum.
|
||||
|
||||
A cohort is copy-only. A moved-from record would keep its identities and lose its
|
||||
classes, which is the invalid state construction refuses, so the implicit moves
|
||||
are suppressed and a move decays to a copy.
|
||||
|
||||
Reference in New Issue
Block a user