An empty reservoir is not an unowned one

Two defects from review of 380d609.

Materialization treated an empty reservoir as available. A vacant cohort, or one
holding nothing, still owns its store, so a draw could credit it while the owning
record went on recording nothing: the same inventory in two places, reached from
the opposite direction to the destination defect in 1a59b63. Destinations are
checked against the registry's ownership now, not just their balance, and the
registry answers whether a reservoir is used rather than callers inferring it from
what the reservoir contains.

The same hole existed on the collapse side in a worse form, found by asking
whether the reported defect had a sibling. Nothing verified the destination was
unowned, so the shared-reservoir rule added in M4.3 would have refused the install
only after the transfer had run, leaving the members emptied and their biomass in
a reservoir nothing accounted for. That is exactly the stranding the M4.2 ordering
was chosen to prevent, defeated by a check that ran too late. Whichever registry
step follows a transfer is now proved to succeed before it, through may_install
and may_replace queries that install and replace delegate to, so there is one rule
and not a restatement that can drift.

The second finding was a functional gap the oscillation test hid by discarding its
registry each cycle. A full draw leaves a vacant record, which ADR-0036 retains
because absence is not extinction, and collapse then refused that habitat and
genome as occupied: a full materialization was a one-way door out of a habitat and
the lineage could never return. Collapse repopulates a vacant record in place now,
continuing its ownership and revision series rather than restarting them, and a
record still holding a population is refused, because merging two silently is not
a conversion. The test keeps one registry for all twelve cycles and asserts the
revision continues.

Four of the five new guards are load-bearing. The fifth is not and is recorded as
such: the may_replace pre-check in commit_materialize is unreachable given the
checks before it, since the installed record is already proved equal to the plan's
origin and the result differs only by a later revision. It is kept because it is
the right place for the guard and its collapse-side sibling is genuinely
reachable, not because it is exercised.

Release 37/37, analysis, ASan 37/37 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 17:47:37 -04:00
co-authored by Claude Opus 5
parent 380d609f06
commit 14e0c1af5e
13 changed files with 332 additions and 37 deletions
+20
View File
@@ -448,3 +448,23 @@ Eleven guards were confirmed load-bearing by removing each and observing a faili
run, including the two that are the risk itself: rounding shares up, and drawing
ages from the bottom of a class. Native Release, analysis, ASan and formatting
passed 37/37; Linux CI has not run yet.
Review of `380d609` found two defects, both fixed with regressions confirmed to
fail without them. Materialization treated an empty reservoir as an available one,
so it credited a store that another installed cohort owned while leaving that
cohort's record unchanged: the same inventory in two places, reached from the
opposite direction to the M4.2 defect. Destinations are now checked against the
registry's ownership as well as their balance, on both the collapse and the
materialize side. The collapse side had the worse form of it: the shared-reservoir
rule would have refused the install only after the transfer had run, stranding the
members' biomass in a reservoir nothing accounted for, so whichever registry step
will follow a transfer is now proved to succeed before it.
The second was a functional gap the oscillation test had been hiding by discarding
its registry each cycle. A full draw leaves a vacant record, which ADR-0036 retains
because absence is not extinction, and collapse then refused that habitat and
genome as occupied, making a full materialization a one-way door out of a habitat.
Collapse now repopulates a vacant record in place, continuing its ownership and
revision series rather than restarting them, and refuses a record that still holds
a population. The test keeps one registry throughout and asserts the revision
continues.
+16
View File
@@ -70,6 +70,22 @@ carries a cohort already validated and the destination was already proved
available. Every rejection therefore leaves the ledger and the registry exactly as
they were.
Two things were added here after review, and both are corrections rather than
refinements. A destination reservoir that another cohort owns is refused, because
emptiness is not availability: a vacant cohort still owns its store, and the
shared-reservoir rule would otherwise have refused the install only after the
transfer had run, leaving the members emptied and their biomass in a reservoir
nothing accounts for. Whichever registry step will follow the transfer is now
checked before it, through the registry rather than by restating its rules.
And a habitat and genome already holding a vacant record is repopulated rather than
refused. ADR-0036 keeps a record whose population reached zero because absence is
not extinction, so without this a lineage could never return to a habitat it had
once emptied, and a full materialization would be a one-way door. The retained
record's ownership and revision series continue: the plan has to be a strictly
later view of it, which is the rule every other replacement obeys. A record that is
not vacant is a population, and merging two silently is not a conversion.
The reservoir's emptiness is checked after the sample rather than beside the other
destination checks. Both run before anything moves, so this is a reporting choice:
when a committed plan is replayed into a fresh registry both would refuse it, and
+13 -3
View File
@@ -61,6 +61,14 @@ member's reservoir must be empty first, so a member's reserve is the whole of wh
backs it rather than a part sharing a store with inventory nobody counted. That is
the same rule the destination of a collapse has.
Emptiness is not availability, and that distinction had to be added after review. A
vacant cohort, or one simply holding nothing, still owns its reservoir, so crediting
it would put inventory there that the owning record does not account for: the same
inventory in two places, arrived at from the other direction. Every destination is
therefore checked against the registry's ownership as well as against its balance,
and the registry answers whether a reservoir is used rather than callers guessing
from what it contains.
What the resolution discards is stated, not mitigated. A round trip is exact when
each class holds one member and smooths within a class otherwise, and the tests
demonstrate both rather than only the flattering one. The available mitigation is
@@ -123,8 +131,10 @@ many cycles: the conserved total never moves, no member ever holds more than the
largest starting member held, and ages never decrease. Test scarcity, where a
class holding nothing materializes members holding nothing rather than refusing or
inventing. Test that drawing more than a class holds, an unknown or repeated class,
a reservoir that is not empty, a repeated reservoir, a stale view and a wrong owner
are each refused, and that every rejection leaves the ledger and the registry
unchanged. No genome schema, mutation catalog, archive, ledger, episode driver,
a reservoir that is not empty, a reservoir another cohort owns however empty, a
repeated reservoir, a stale view and a wrong owner are each refused, and that every
rejection leaves the ledger and the registry unchanged. Test the round trip through
one registry that is never discarded, so a full draw and the collapse that follows
it have to work against the record the draw left behind. No genome schema, mutation catalog, archive, ledger, episode driver,
ensemble, cohort record, collapse, interval accounting, renderer or deployment
changes.
+12
View File
@@ -258,6 +258,18 @@ any individual is right. A round trip is exact when each class holds one member,
and the mitigation available to a caller is to declare narrower classes when it
collapses; nothing here can recover what a coarse class threw away.
A destination reservoir must be unowned as well as empty. A vacant cohort, or one
holding nothing, still owns its store, so crediting it would put inventory there
that the owning record does not account for. This holds on both sides of the
conversion, and the registry is asked rather than inferred from what a reservoir
contains.
A habitat and genome holding a vacant record is repopulated rather than refused,
because this document requires the record to be retained and a retained record
would otherwise bar the lineage from ever returning. The repopulation continues the
retained record's ownership and revision series; it does not reset them, and a
record that still holds a population is never merged into silently.
A materialized member carries the cohort's genome, its habitat and a fresh
identity, and nothing else. It has no parentage, no history and no condition,
because a cohort never carried them, and none of that may later be invented from a
+50
View File
@@ -1192,3 +1192,53 @@ fingerprint `2cd4a15f9fbe9949`, the ensemble fingerprint `5ec59d390909b526` and
the frozen genome fixture are unchanged, and the other 36 tests pass untouched. No
deployment manifest or image pin changed. Linux validation is pending; no Gitea
result is claimed since `b01a824`.
Review of `380d609` found two defects (2026-09-24), both fixed with regressions
confirmed to fail against the unfixed code.
Materialization treated an empty reservoir as an available one. A vacant cohort, or
one simply holding nothing, still owns its store, so a draw could credit that store
while the owning record went on recording nothing: the same inventory in two places,
reached from the opposite direction to the destination defect found in `1a59b63`.
Destinations are now checked against the registry's ownership as well as their
balance, and the registry answers whether a reservoir is used rather than callers
inferring availability from what it contains.
The same hole existed on the collapse side in a worse form, and was found by
checking whether the reported defect had a sibling rather than by being reported.
Nothing verified that the destination reservoir was unowned, so the shared-reservoir
rule added in M4.3 would have refused the install only after the ledger transfer had
already run, leaving the members emptied and their biomass in a reservoir nothing
accounted for. That is exactly the stranding the M4.2 ordering was chosen to prevent,
defeated by a check that ran too late. Whichever registry step will follow a transfer
is now proved to succeed before it, through new `may_install` and `may_replace`
queries that `install` and `replace` themselves delegate to, so there is one rule
rather than a restatement that could drift.
The second finding was a functional gap the oscillation test had been hiding by
discarding its registry every cycle. A full draw leaves a vacant record, which
ADR-0036 retains because absence is not extinction, and collapse then refused that
habitat and genome as occupied. A full materialization was therefore a one-way door
out of a habitat: the lineage that had been there could never return. Collapse now
repopulates a vacant record in place, continuing its ownership and revision series
rather than restarting them, and a record that still holds a population is still
refused, because merging two silently is not a conversion. The oscillation test keeps
one registry for all twelve cycles and asserts the revision continues across each
repopulation, so the round trip is exercised against the world it left behind.
Four of the five new guards were confirmed load-bearing by removing each alone: the
ownership check on both sides, the collapse pre-check ordering, and the repopulation
path. The fifth is not, and is recorded rather than presented as tested. The
`may_replace` pre-check in `commit_materialize` is unreachable given the checks
before it: the installed record has already been proved equal to the one the plan
was built from, and the plan's result carries the same habitat, genome, reservoir and
tick with a strictly later revision, so the replacement cannot be refused. Removing
it changes nothing the tests can see. It is kept because it is the structurally
correct place for the guard and its sibling on the collapse path is genuinely
reachable, not because it is exercised.
An environment note for the record: a Bash heredoc containing apostrophes failed to
parse, so the larger test edits in this increment were written to a scratchpad file
and run from there. That is the third distinct way heredocs have mangled content in
this project, after backslash escapes and `/tmp` resolving differently between
shells.