Skip to content

🐛 fix(soft): break stale markers without emptying the lock path - #843

Merged
gaborbernat merged 22 commits into
mainfrom
fix/soft-marker-reuse
Oct 17, 2026
Merged

gaborbernat merged 22 commits into
mainfrom
fix/soft-marker-reuse

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

The soft locks identify the marker (the file whose presence says a process holds the lock) by its inode number (the kernel's identity for a file, independent of its name) and modification time. They then acted on the lock path by name. Each of the steps below could remove, publish or displace the wrong file, so two processes held one SoftFileLock, MarkerSoftFileLock or SoftFileLease at once. 🐛 After this PR a contender never leaves the lock path empty while it breaks a marker. Where it cannot avoid that, it does not move the marker at all, as stale lock detection now describes. This resolves GHSA-2g95-wg33-c5x2, GHSA-fq56-3cx3-fjxp and GHSA-crv4-6mhj-j5jh.

A restored marker followed a symlink

When a break found that the marker it had renamed aside was recreated, the restore branch from #786 checked the break name with lstat and then called os.link by name. On CPython 3.14 on Linux that call follows symlinks. A symlink placed under the break name between the two calls therefore got its target published at the lock path as a hard link (a second name for the same file). The restore now links without following, the behavior link(2) gives without AT_SYMLINK_FOLLOW. A swapped-in symlink is then at worst linked as itself and read as a malformed marker. With the exchange below, this path remains only on Windows.

sequenceDiagram
    participant C as contender
    participant P as path lock.break.*
    C->>P: lstat: regular file
    Note over P: replaced by a symlink to another file
    rect rgb(255, 214, 214)
    C->>P: os.link follows it: target linked at the lock path
    end
    rect rgb(216, 243, 220)
    C->>P: link with follow_symlinks=False: the symlink itself
    end
Loading

The judged marker's inode number was reused

A contender read the marker, closed it and decided its owner was gone. Only then did it compare the inode number and the modification time before breaking. Once the stale marker was unlinked, nothing kept its inode allocated. ext4 hands a freed number to the next file created, so the next holder's marker could carry it. A modification time no newer than the one read passed the second check, a time set in the future included. All three soft locks now hold the marker open through pin_inode, with O_PATH where open(2) has it, from before the read until the break ends. They give up when the file they read is not the pinned one, and they compare modification times for equality. Windows pins nothing, since it already refuses to rename a marker its holder keeps open.

sequenceDiagram
    participant C as contender
    participant S as stale marker (inode I)
    participant N as next holder
    C->>S: read record, judge owner gone
    S-->>S: unlinked by a peer, inode I freed
    N->>N: create marker, gets inode I
    rect rgb(255, 214, 214)
    C->>N: inode I matches: break the live marker
    end
    rect rgb(216, 243, 220)
    Note over C,S: now C holds I open, so N gets another number
    end
Loading

The malformed-marker watch inherited another file's age

A contender evicts a malformed marker once it has seen it unchanged for two seconds. _marker_unchanged_for told two looks apart by modification time and inode number, the key #796 introduced. Another file can repeat both, since its owner sets the time and ext4 reuses the number. A fresh, still-empty marker then inherited the time spent watching that file and was evicted milliseconds after creation. SoftFileLease uses the same watch for expiry. The key now includes st_ctime_ns, the change time, which inode(7) defines as set by the kernel on every change and which no process can set.

stateDiagram-v2
    [*] --> Watching: first look (mtime, ino, ctime)
    Watching --> Watching: same key, age grows
    Watching --> Restart: any key part differs
    Restart --> Watching
    Watching --> Evict: unchanged for 2 s
Loading

A failed acquire unlinked a successor's marker

When writing a new marker's record failed, the rollback from #614 closed the descriptor first. It then unlinked the lock path if lstat still reported the marker's (st_dev, st_ino). If a contender had already evicted the still-empty marker, the close freed its inode, the next holder's marker could reuse the number, and the rollback removed that live marker. The rollback now removes its own file while the descriptor is still open, through remove_own_file, the order _release already uses.

sequenceDiagram
    participant A as failing acquirer
    participant B as contender
    participant N as next holder
    B->>A: evict A's empty marker
    rect rgb(255, 214, 214)
    A->>A: close fd, inode freed
    N->>N: new marker reuses the number
    A->>N: identity matches: unlink
    end
    rect rgb(216, 243, 220)
    Note over A: now A removes its file before the close
    end
Loading

The ENOSYS fallback deleted a peer's marker

When flock fails with ENOSYS, the lock removes the empty file its own O_EXCL open created before it switches to SoftFileLock. Since #480, and still after #785, _switch_to_soft_lock closed the file, compared identities and unlinked the path by name. A waiting soft lock evicts an empty file after two seconds and writes its own marker there. A process stalled past those two seconds therefore removed the marker that peer had written. The placeholder is now removed with remove_own_file while its descriptor is open, so a peer's marker found at the path is left in place.

sequenceDiagram
    participant A as creator (stalled)
    participant B as soft peer
    A->>A: lstat: still my placeholder
    B->>B: evict empty placeholder, write own marker
    rect rgb(255, 214, 214)
    A->>B: unlink by name removes B's marker
    end
    rect rgb(216, 243, 220)
    Note over A: now A checks and removes only while its file is open
    end
Loading

The path stood empty while a break decided

A stale break renamed the marker aside and only then checked whether it was the one judged stale. Until a recreated live marker went back, the lock path stood empty. A third process could create its marker there beside the live holder, and where linking failed, the rename back could replace that third marker. On Linux and macOS the contender now writes a complete marker of its own under a private name and swaps it with the lock path in one step. The swap is RENAME_EXCHANGE of renameat2(2) or RENAME_SWAP of renamex_np(2), through exchange_names. On Linux the call goes through syscall(2) with the architecture's number, since bionic before API 30 and musl before 1.2.2 have no wrapper for it.

The contender holds the lock from the moment the exchange took the pinned, judged file, and it removes that file. A peer whose exchange moves the holder's marker aside for the length of that peer's check does not change that: the peer finds the file it took is not the one it judged and swaps the marker back. A holder that releases in that window leaves a record no lock parses, so the marker the peer puts back ages out. A SoftFileLease heartbeat that finds another file at the lock path once, in that window, waits for the next refresh before it reports a compromise. If the file taken is not the judged one, the contender swaps the live marker back. Any failure before that handoff takes its own marker off whichever name holds it and puts back what it took.

The marker swapped in is the record the lock class writes, so a SoftFileLease contender swaps in a lease record with its own token and duration. Windows keeps the rename aside: CreateFile without FILE_SHARE_DELETE makes a live holder's open marker refuse the rename. Elsewhere without an exchange, including NFS and SMB, which refuse it, break_lock_file no longer moves the marker.

sequenceDiagram
    participant C as contender
    participant L as lock path
    participant A as private name
    C->>A: write own complete marker
    C->>L: exchange A and L in one step
    Note over L: never empty: holds C's marker
    alt the file taken is the judged one
        C->>A: remove the stale marker
        rect rgb(216, 243, 220)
        Note over C,L: C holds the lock
        end
    else a peer recreated the marker
        C->>L: exchange back
        C->>A: remove own marker
        rect rgb(207, 228, 255)
        Note over C,L: live holder keeps the lock
        end
    end
Loading

A killed breaker stranded the marker it took

A breaker killed between its exchange and the put-back (SIGKILL, the out-of-memory killer) leaves two files behind. Its own marker sits at the lock path and names its now-dead PID. The live holder's marker sits under the breaker's private <lock>.break.<pid>.<token> name. The next contender reads the marker at the path as stale, takes it over, and holds the lock beside the first holder.

The private name carries the breaker's PID, so a contender that is about to take over a dead breaker's marker now looks for names with that prefix first. It exchanges back a marker whose owner is alive or cannot be proven dead and removes one whose owner is dead. A marker counts as the breaker's own only when it names the breaker's process on this host; the same process number on another host, as on a shared filesystem, is a holder and is exchanged back. Where the filesystem refuses the exchange, the lock counts as held until timeout or break_lock(), as it does wherever no exchange is possible. The placeholder a break writes while it works now records its PID too, so a contender that evicts a placeholder a killed process left finds the same names.

Two contenders can find the same stranded record. Exchanging it takes four separate steps, so one contender's exchange could be reversed by the other's, and the first one's final unlink then removed the live holder's marker. A recoverer now first renames the record to a name of its own, <lock>.restore.<pid>.<token>, with its own PID. The rename succeeds for one contender only, so only that one exchanges. A .restore. record whose PID is alive counts the lock as held for that poll. One whose PID is dead is claimable again. If the lock path changed since the check, the record goes back under a new break name, and an exchange that took a peer's marker is swapped straight back. A claim that a failed put-back left under the recoverer's own PID is retried on the next poll, unless another thread of the same process is still working on it.

sequenceDiagram
    participant B as breaker (killed)
    participant L as lock path
    participant A as private name
    participant H as live holder
    participant C as contender
    B->>L: exchange: B's marker at the path
    Note over A: H's marker now sits under the private name
    rect rgb(255, 214, 214)
    Note over B: killed before the put-back
    C->>L: marker names a dead PID: take it over
    Note over C,H: C and H both hold the lock
    end
    rect rgb(216, 243, 220)
    C->>A: look for names with the dead PID first
    C->>L: exchange H's marker back, remove B's
    Note over H: H keeps the lock, C waits
    end
Loading

The lifetime break judged a marker by a reused inode number

_try_break_expired_lock, the age-based break of #476, read the marker's age with lstat and then broke it by path, with nothing holding the judged inode. A successor's marker created on the freed number with the same modification time passed the break's check and was removed. The contender then acquired beside it. SoftFileLock now judges the age under the same pin and takes the marker over by the same exchange, so the lock is held in the same poll. The base implementation is a no-op, since only existence locks accept a lifetime.

sequenceDiagram
    participant C as contender (lifetime)
    participant E as expired marker (inode I)
    participant N as next holder
    C->>E: lstat: older than lifetime
    E-->>E: broken by a peer, inode I freed
    N->>N: create marker, gets inode I and the same mtime
    rect rgb(255, 214, 214)
    C->>N: inode I matches: remove the live marker
    end
    rect rgb(216, 243, 220)
    Note over C,E: now C holds I open through the exchange, N gets another number
    end
Loading

Behavior changes

On NFS, SMB and other filesystems or platforms without an atomic exchange, except Windows, a stale or expired marker is no longer removed. It waits for timeout or break_lock(). On Linux and macOS a contender that breaks a stale marker holds the lock in the same poll. Any change to a malformed marker restarts the two-second watch.

@gaborbernat gaborbernat changed the title fix(soft): act on the marker that was judged, not its name 🐛 fix(soft): act on the judged marker, not its path Oct 16, 2026
@gaborbernat
gaborbernat force-pushed the fix/soft-owner-identity branch from 1172d46 to 8130fc6 Compare October 16, 2026 02:07
@gaborbernat
gaborbernat force-pushed the fix/soft-marker-reuse branch from a8eaffd to 5cfdf62 Compare October 16, 2026 02:07
@gaborbernat
gaborbernat force-pushed the fix/soft-owner-identity branch from 8130fc6 to d5e4069 Compare October 16, 2026 02:36
@gaborbernat
gaborbernat force-pushed the fix/soft-marker-reuse branch 2 times, most recently from 874f972 to db4696a Compare October 16, 2026 03:04
@gaborbernat
gaborbernat force-pushed the fix/soft-owner-identity branch from d5e4069 to faf4a11 Compare October 16, 2026 04:57
@gaborbernat
gaborbernat force-pushed the fix/soft-marker-reuse branch 2 times, most recently from fd6f986 to d551b66 Compare October 16, 2026 04:58
@gaborbernat gaborbernat changed the title 🐛 fix(soft): act on the judged marker, not its path 🐛 fix(soft): break stale markers without emptying the lock path Oct 16, 2026
@gaborbernat
gaborbernat force-pushed the fix/soft-marker-reuse branch 2 times, most recently from 706a2ee to 78961af Compare October 16, 2026 05:50
@gaborbernat gaborbernat added the security Fixes a published or draft security advisory label Oct 16, 2026
@gaborbernat
gaborbernat force-pushed the fix/soft-marker-reuse branch from 78961af to 2e78892 Compare October 16, 2026 06:09
@gaborbernat
gaborbernat force-pushed the fix/soft-owner-identity branch from d19532f to 97e5859 Compare October 16, 2026 06:29
@gaborbernat
gaborbernat force-pushed the fix/soft-marker-reuse branch 14 times, most recently from c7ab9e2 to f36cd65 Compare October 17, 2026 03:06
gaborbernat and others added 18 commits October 17, 2026 02:39
When flock fails with ENOSYS, the lock removes the empty file its own O_EXCL
open created before it switches to SoftFileLock. It closed that file, compared
the lock path's identity with it, and unlinked the path by name. A waiting
soft contender evicts an empty file after two seconds and writes its own
marker there, so a process stalled between the check and the unlink removed a
live peer's marker and acquired beside it. A stall before the check had the
same effect where the freed inode number went to the peer's marker.

The placeholder is now removed with the rename and re-check a stale break
uses while its descriptor is still open, so a peer's marker found at the path
is put back instead of deleted.
A stale break that renamed aside a marker a peer had just recreated put it
back with os.link. Without os.link (Termux), on a filesystem that refuses hard
links, or where the link cannot be told not to follow a symlink, the live
marker stayed under the break name, the lock path was left free, and the next
contender acquired beside the live holder.

Where linking back fails, the break now renames the marker back while the lock
path is still free. Rename never follows a symlink, so a symlink swapped in
under the break name is at worst published as a symlink, which the next read
treats as a malformed marker.
Windows pins nothing, so the check for a node replaced since the pin never
fires there, and Termux has no os.link, so linking a marker back never runs
there; mark both for coverage on those platforms.
A stale break renamed the marker aside and only then checked whether it was
the one judged stale. Until a recreated live marker was linked or renamed
back, the lock path stood empty and a third process could create its marker
beside the live holder; where linking failed, the rename back could replace
that third marker.

On Linux and macOS the contender now writes a complete marker of its own under
a private name and swaps it with the lock path in one renameat2 or
renamex_np exchange. If the file it took is the judged one, it removes that
file and holds the lock in the same poll; otherwise it swaps the live marker
back. Any failure before the handoff takes its own marker off the path and
puts back what it took. Windows keeps renaming aside, since it refuses to
rename a marker its live holder has open. Elsewhere without an exchange,
including NFS and SMB, the marker is no longer moved and counts as held. The
lifetime break and a failed acquire's cleanup use the same exchange.
The lifetime break read the marker's age with lstat and then broke it by
path, with nothing keeping the judged inode allocated. A successor's marker
created on the freed inode number with the same modification time passed the
break's check and was removed, and the contender acquired beside it.

SoftFileLock now judges the age under the same pin the stale break uses and
takes the marker over by the same exchange, so the judged inode cannot name
another file meanwhile and the lock is held in the same poll. The base
implementation becomes a no-op: only existence locks accept a lifetime.
Shorter sentences and paragraphs, the inode and the change time defined
where they first appear, and the two test helper modules folded into
conftest.py as fixtures, so the break's rules read without prior knowledge
of the filesystem and the tests share one place for their stand-ins.
remove_own_file sits above the break it calls, the inode-reuse fixture is
excluded from Windows coverage as a whole, and the stale-breaker table is
shared by every test that runs all three soft locks.
Two contenders that judged one stale marker both exchanged their own marker
onto the path. The second exchange moved the first contender's marker aside
before its samestat check, so the first gave up its hold, and the second put
that marker back. The marker named a live process, nobody held the lock, and
every contender waited on it.

A contender now holds the lock as soon as the file its exchange took is the
one it judged. A peer's later exchange moves the holder's marker aside only
while that peer checks what it took, and the peer puts it back.
A holder that released while a breaker's exchange had its marker under a break
name found another file at the lock path and skipped the unlink. The breaker
then put the marker back, and it still named the live PID of a lock nobody
held, so every contender waited until that process exited.

The release now overwrites the record through its open descriptor with one no
lock parses. The put-back lands a marker that contenders age out after the
usual grace period.
A peer's stale break exchanges a live marker aside for the length of its
check. The heartbeat treated a missing marker once as transient, but a
refresh that found the peer's marker at the path reported owner-changed at
once, ran on_compromise and ended the heartbeat, though the break put the
marker back. The claim then stopped refreshing and a contender took it after
lease_duration.

The first owner-changed is now tolerated like the first marker-missing.
A second change in a row, which a real takeover produces, is still reported.
A breaker killed between its exchange and the put-back left its own marker
at the lock path and a live holder's marker under its break name. The
marker at the path named a dead PID, so the next contender took it over and
held the lock beside the first holder.

A contender that finds a dead breaker's marker now searches the lock's
directory for names starting with that breaker's PID before it takes the
marker over. It exchanges back a marker whose owner is alive or cannot be
proven dead, removes one whose owner is dead, and waits where the exchange
is refused. The placeholder a break writes carries its PID so an evicted
placeholder leads to the same names.
A stranded marker was treated as the dead breaker's own whenever it
named the breaker's PID. The same number on another host, on a shared
filesystem, is a live holder, so the marker is put back instead of
removed.
Two contenders that found the same dead breaker's marker could both
exchange the record stranded under its break name. The second exchange
reversed the first, and the first one's unlink then removed the live
holder's marker.

A contender now renames the record to <lock>.restore.<pid>.<token>
first, so only one of them acts on it. A record whose recoverer died
is claimable again, and an exchange that took a peer's marker is
swapped back at once.
Replaying #843 over main dropped path handling from its merge with #836.
Restore the relative-path and marker cleanup behavior, and cover a failed
released-record write when another marker takes the path.
@gaborbernat
gaborbernat force-pushed the fix/soft-marker-reuse branch from 49a086e to 737f120 Compare October 17, 2026 09:48
@gaborbernat
gaborbernat merged commit 740ff66 into main Oct 17, 2026
46 checks passed
@gaborbernat
gaborbernat deleted the fix/soft-marker-reuse branch October 17, 2026 09:53
daniel-ospina pushed a commit to daniel-ospina/tortoise that referenced this pull request Nov 24, 2026
… never deletes

Cycle-17 review (PR #14480 @ b17a882), 1 P3, both legs: `_restore_quarantine` and
its Pi twin `restoreQuarantine` deleted the object they promise to honour when
`link` failed for any reason other than EEXIST. The claim path had already been
VACATED by the caller's rename, so a peer's record existed nowhere while the peer
still believed it held — and this process then won the next `link`, the two-holder
window the whole mechanism exists to close, with the only copy of the evidence
destroyed and the warning on a stderr a session discards.

Both legs now never unlink what they could not put back:

* the claim path is still free -> `rename` the object BACK. `rename` needs no hard
  link, which is the reachable failure (EPERM/EXDEV/EMLINK/ENOSYS), and it is the
  fallback filelock's stale break takes for exactly this reason (tox-dev/filelock#843,
  `_util._linked_back`). It runs only after `lexists` says the path is empty, because
  `rename` replaces where `link` never does.
* even that fails -> the quarantined copy is LEFT IN PLACE, and the warning names it.

The answer stays HELD on both legs, deliberately NOT the REFUSED the review
proposed: verified against the consumers, REFUSED raises DrainClaimUnavailable,
whose handler re-lstats the path the caller emptied and runs the whole pass
UNCLAIMED beside the displaced holder (capture_spool.py:4366-4375; the Pi twin
takes that unclaimed arm at tortoise-capture.ts:4546). HELD is the only answer that
keeps the pass off the spool.

Tests (each RED on the pre-fix code, sha256-verified restores):
* Python 3 rows: rename-back restores the peer's bytes; both restores refused ->
  the copy is PRESERVED; end-to-end acquire answers CONTENTION with the claim
  readable at the path. Pre-fix: `3 failed, 74 deselected`.
* Pi 2 rows: same two arms through `clearUnusableClaimPath`, whose restore now takes
  `link`/`move` seams (the same reason it already takes a `rename` seam).
  Pre-fix: `fail 2`.

Record: pr-body.md gains the cycle-17 row; counts re-derived on this tree
(77 / 776 / 323) and the generation-33 seam digest re-cut to the shipped bytes
(105d5667...), in `_PINNED_PI_SEAM_INSTALL_CONTRACT` and `_GENERATION_DIGESTS[33]`.
daniel-ospina pushed a commit to daniel-ospina/tortoise that referenced this pull request Nov 24, 2026
…object rather than only sparing it

`a3a80e68` landed the same cycle-16 finding first (verified independently here
before this branch existed: a non-EEXIST `link` failure left the only copy of a
live holder's claim to be `unlink`ed, and the path it vacated was then won by the
next `link`). This merge keeps that work and adds the part it does not have.

KEPT FROM `a3a80e68`:
* `_dispose_quarantine` / `disposeQuarantine` no longer unlink on a non-EEXIST
  failure — the SECOND restore path, which the first cut of my own row did not
  cover at all.
* the Pi leg's `markRaced()` when `held` is answered over an empty path, so
  `flushSpool` fails closed instead of naming a holder it cannot see.
* the cycle-15/16 record reconciliation (the log had no Cycle 15, and seven
  comments cited a round that does not own the rows), and the row that pins the
  preserve arm on each leg.

ADDED HERE (the reason the merge is not a no-op):
* BOTH restores now RECOVER the object instead of only sparing it. A claim left
  under `*.tmp-clear-*` is swept by mtime, so the holder it belongs to is doomed
  minutes later — the evidence survives the function and not the process. While
  the claim path is still FREE the object is `rename`d BACK (`rename` needs no hard
  link, which is the reachable failure; it runs only after `lexists` says the path
  is empty, because `rename` replaces where `link` never does — the fallback
  filelock's stale break takes, tox-dev/filelock#843 `_util._linked_back`). Only
  when that ALSO fails is the copy left in place, named in the warning.
* `restoreQuarantine` / `disposeQuarantine` take injectable `link`/`move` seams, so
  a test can stand inside the failed restore on the Pi leg too.
* five Python rows and three Pi rows covering both arms on both paths, each RED
  under the mutation it prevents (measured at this merged head, not argued).

Record: the peer row's preserve-only claim is corrected to the recovery rule; the
counts are re-derived on the merged tree (80 / 779 / 325) and the generation-33
seam digest is re-cut to the merged bytes (d27c01ee...), since a merge is a byte
set neither side hashed.
daniel-ospina pushed a commit to daniel-ospina/tortoise that referenced this pull request Nov 24, 2026
…cover the object, not just spare it

Integrates `ac90e28` (which contains `a3a80e68`, `011ae718`, `92dedfe2`), whose
cycle-16/17 rounds found the same defect this branch had already fixed
independently — a non-`EEXIST` `link` failure deleted the only copy of a live
holder's claim and freed the path for the next `link` — and, one round later, that
their own fix had not landed on `_restore_quarantine` at all (signature changed,
body still deleting), which is the P1 that proves their point.

Resolution, keeping both intents:

KEPT: the peer lane's `_dispose_quarantine` / `disposeQuarantine` non-`EEXIST`
protection (the SECOND restore path), the Pi leg's `markRaced()` when `held` is
answered over an empty path, the `return False` / `return True` contract they
landed on `_restore_quarantine`, their cycle-15/16/17 record reconciliation, and
their end-to-end displacement row that drives a real `_takedown`.

ADDED, because sparing the copy is the floor and not the remedy: both restores now
RECOVER the object. A claim left under `*.tmp-clear-*` / `*.tmp-take-*` is swept by
mtime, so its holder is destroyed minutes later and the evidence with it. While the
claim path is still FREE the object is `rename`d BACK (`rename` needs no hard link,
which is the reachable failure; it runs only after `lexists` says the path is empty,
because `rename` replaces where `link` never does — the fallback `filelock`'s stale
break takes for exactly this reason, `tox-dev/filelock#843` `_util._linked_back`).
Only when that ALSO fails is the copy left in place, named in the warning.
`restoreQuarantine` / `disposeQuarantine` take injectable `link`/`move` seams so the
Pi leg's failed restore is testable too.

Tests: their rows are re-pointed at the INVARIANT (the displaced bytes survive
somewhere) rather than at one mechanism, and the both-restores-refused arm keeps its
own row on each leg. Measured at this merged head: drain suite 81 passed, family 780
passed, node pair 325 pass / 0 fail.

Record: their one-row-per-leg disposition now states the recovery rule, the two
rows that described the quarantine-only behaviour are corrected in place, and the
counts (81 / 780 / 325) and the generation-33 seam digest (`d27c01ee…`) are
re-derived on the merged bytes. Also escaped the two pipes in their
`git diff … | grep '^-|'` cell that markdownlint counted as column boundaries
(the docs gate).
daniel-ospina added a commit to daniel-ospina/tortoise that referenced this pull request Nov 24, 2026
…bstruction clear stops running passes unclaimed (#14480)

* fix(14350): the exclusion being OFF becomes a durable fact, not a line nobody reads

Cycle-8 review, five findings. The P1 was a hole in this PR's OWN fix: a pass that ran
without the one-drainer claim answered "run unclaimed and say so" by printing to a
stderr the firing path discards (`session-start.sh`: `nohup … session drain …
>/dev/null 2>&1 &`).

P1 — THE EXCLUSION BEING OFF IS NOW IN THE RECORD, ON BOTH LEGS. A pass that ran
unclaimed may file NOTHING, so every other rule in `_record_capture_status` /
`recordOutcome` wrote no record at all and the box reported `capture: OK`/`DRAINING`
while N drainers POSTed into the same 8-slot ceiling. The status record gains
`claim_unavailable` + `claim_unavailable_reason`, DECORATED onto whatever state the
pass earned (a quota-blocked box with a broken claim path keeps both facts), and the
health line carries `, NO drain exclusion (<reason>)` in byte-identical words on both
legs. Self-healing the other way too — a pass that HELD the claim clears it — because a
one-way latch teaches an operator to ignore the line. Two tests per leg; both mutants
red (dropping the record arm; keeping the stale field on every write).

P2 — `_dispose_quarantine`'s failed restore deleted a LIVE claim with no trace, and the
sentence that justified it was FALSE: the displaced holder does not stop, it keeps
draining until its next refresh, up to `ttl/3`. The failure now WARNS with its cause on
both legs, and the sentence states the bounded double-drain that actually happens. The
bound is quoted by `_ttl_third_hint()` so the prose and `DEFAULT_TTL_S / RENEW_FRACTION`
cannot drift apart — the earlier comment named `CLAIM_TTL_S`, which does not exist.

P2 — the measurement's `overlapped` field could never report what its own comment
claimed (`min(arrivals, done + winners)` is always `processes`), and a winner that
timed out released EARLY, after which a straggler legitimately took the claim and was
counted as a second winner. The winner now prints the bound it observed, an early
release makes the run NO VERDICT (`bounded: false`) instead of a false "two drainers",
and `overlapped` reports the population that actually attempted.

P2 ×2 — two test docstrings cited tests that do not exist (one renamed, one never
written). Both now cite real ones, and the second says plainly that the nearest cover
asserts the GIVE-UP rather than the restore. Same overclaim class this PR has corrected
four times now: a citation to a nonexistent test is how it survives a review.

Generation 33's digest re-cut to `3eef418b…` — derived from this tree, since both
Pi-leg changes above are behaviour on shipped bytes.

Suites: 55 passed (D1 convergence), 744 passed (capture family + install contract +
store_sync + doctor), 312 pass / 0 fail (`node --test`).

(cherry picked from commit c72adfc49e590bf65f766676a4db7793b7622acb)

* fix(14350): the clear tells GONE from REFUSED, and never deletes what it did not judge

Cycle-9 review of the merged head, 1 P1 + 4 P2. Every finding is a hole in the
path that was meant to be the safety valve.

P1 — `_clear_unusable_claim_path` / `clearUnusableClaimPath` answered a BOOLEAN,
so "the object vanished under me" and "I may not delete it" were the same answer.
Two legs meet at a FIFO at the claim path, the peer's own `unlink` lands first,
this one's `unlink` gets ENOENT, and the caller read that as "cannot be cleared"
and ran the WHOLE PASS unclaimed beside a live peer claim — the two-drainer
defect this PR removes, reproduced from the valve. The answer is now tri-state
(GONE / REFUSED / DONE): GONE makes `acquire` retry the loop, only REFUSED raises
`DrainClaimUnavailable`.

P2 — the same clear was the protocol's ONLY uncompared delete. `lstat` -> `unlink`
could remove a claim a peer installed under it and then win the next `link`: two
holders for up to ttl/3, silently. The (dev, ino) judged is now re-read
immediately before the removal, and the object is left alone if it changed — the
rule `_dispose_quarantine` already applied to every other removal.

P2 — the durable `claim_unavailable` fact was STRANDED: the `ok` write is gated on
`attempted > 0`, so a pass that HELD the claim over an empty/backoff-only spool
wrote nothing and the operator kept reading `NO drain exclusion (<path>)` for an
obstruction already removed. A claim-holding pass now clears the two fields even
when it attempts nothing.

P2 — the Pi leg's "a HEALTHY pass clears the fact" test was VACUOUS: it wrote the
healthy record itself and never called the pass, so the mutation it named could
not reach it. It now drives a real pass through the extension over an EMPTY spool
— the shape that discriminates the no-op clearing.

P2 — two docstrings claimed the health-line wording was "pinned by the cross-leg
parity test", and no such pin existed. The pin is now written: a test runs the
real TypeScript leg over a three-row status matrix and byte-compares the FULL
rendered line with the Python leg's.

Each new test names the mutation that reds it and was verified red under it. The
generation-33 seam digest is re-derived from this tree (4cbd1f02...), seventh
re-cut, still an unreleased generation.

(cherry picked from commit 3ba4d75617fa3d0992f3c310144d1161fa4bd7dc)

* fix(14350): the exclusion fact reaches every verdict, and the clear moves the object aside instead of comparing it

Cycle-10 review of #14480 (1 P1, 3 P2). All four are holes in the ANSWERS this
branch gives, not in its mechanism.

F1 (P1) — the durable `claim_unavailable` fact was rendered only on the final
`DRAINING`/`OK` verdict; the four early returns (BLOCKED, SATURATED, INACTIVE,
UNREADABLE) dropped it, and the shape this PR exists for — a capacity 429 WITH a
backlog — is one of them, so the fact was invisible for the whole block. The term
is now applied by one wrapper (`_with_claim_term` / `withClaimTerm`) to every
verdict, on both legs, and the record is read before the scan so UNREADABLE
carries it too. It is an ADDED FACT, not a sixth precedence state: the documented
order is unchanged. The parity matrix now reaches all six verdicts with REAL
spools (its `blocked` row had `queued == 0`, self-healed to `ok`, and never
reached the branch it claimed to pin), plus a direct per-verdict assertion.

F2 (P2) — an identity change answered `REFUSED`, whose comment promised a retry
that never happens and whose message ("the spool root is not writable by this
process") was a false diagnosis, while `flush_spool` read it as "run the pass
unclaimed". A claim that appears in the removal window is now `HELD`: it is put
back and `acquire` answers CONTENTION.

F3 (P2) — `claimHeld` was declared on `CaptureStatus` (the on-disk record) where
nothing writes it, which made `summary.claimHeld` a type error no gate can see
(no tsc project covers `pi-hooks/`) and left `claim_unavailable`'s doc block
attached to the wrong field. It now lives on `FlushSummary` next to
`claimUnavailable`.

P2-4/F4 — the `(st_dev, st_ino)` re-read narrowed the check-then-unlink window
without closing it, and an inode compare is not evidence (ext4/xfs reuse a freed
inode; `filelock` GHSA-fq56-3cx3-fjxp admits two holders exactly that way). The
removal is REPLACED, not narrowed: the object at the claim path is moved aside
with `rename` — the arbiter `_takedown` already uses for every other removal —
and the object that LANDED is what gets judged. `tools/measure_drain_convergence.py`
loses `overlapped` (each process writes exactly one `done` marker, so it was
always `processes`; the barrier that makes it true is what it claimed to verify)
and `bounded: false` now GATES: "NO VERDICT" and a non-zero exit.

Non-vacuity measured, each mutant red and reverted: gating the claim term on the
final verdicts reds the two health-line tests; answering `REFUSED` instead of
`HELD` reds both clear tests; dropping the TS `landedRaw` arm reds the TS twin.

Generation 33 (introduced by this PR, never shipped) is re-cut in place, as the
PR body's residual states.

* chore(14350): re-derive Appendix A and the residue pin on this tree (rows + one receiver)

* copy(14350): un-mangle the residue pin's note and correct the stale pair it quoted

Adopts the `review-11186` lane's integration head `e2d43ad3` (that lane is dead — its
claim's pid is gone) rather than rewriting it: its pin `(11911, "3e92044bab08cc3d")` is
what `--repin` prints here too, and its merge-tree note is accurate.

What it left behind is a prose defect at `tools/sdk_privatise.py:1654`: the #14480 note
had been inserted MID-SENTENCE, splitting "`--check` prints an" from its own "observed
digest ONLY on its failure path", and it quoted the pre-integration pair
`(11903, "0a80b03111e58c47")` — a number that is not on this tree, in a block whose whole
subject is that a pair nobody can reproduce sends a reader to the wrong place.

The sentence is restored, the note follows it, and it now names the pair the tool actually
prints on the tree being merged. `--check` exits 0; `cypher_inventory.py --check` reports
25 pinned counts matching; `ci_selection.py --integrity` is clean.

* fix(14350): close the cycle-11 review's four P2s — the record's digest and counts, and two Pi-leg test defects

Cycle 11 (fresh-context review at 01064dc1) found no defect in the mechanism; all
four findings are record- and attribution-accuracy, which is this PR's own subject
matter. Each is fixed at the source.

F1 — the committed record quoted a generation-33 digest this PR does not ship
(`3eef418b…`, the blob at the branch's FIRST commit). Re-derived rather than
copied: sha256 of the shipped `tortoise/pi-hooks/tortoise-capture.ts` is
`932d74a2…`, byte-identical to `_PINNED_PI_SEAM_INSTALL_CONTRACT` and
`_GENERATION_DIGESTS[33]`. `pr-body.md` now states it.

F2 — the recorded counts were short by two: `59`/`748` were regenerated at cycle 9
and cycle 10's two new cases never folded in. Re-RUN on the merge tree, not
arithmetic: `61 passed` (54 `def test_` + the 8-way parametrize) and `760 passed`
for the family run — 750 was the reviewer's prediction from the pre-merge tree;
`origin/main` `6a72cfd661` grows that family itself. `node --test` pair unchanged
at `314 pass / 0 fail`.

F3 — the Pi leg's "a HEALTHY pass clears the recorded claim fact" test named a
mutation it cannot reach (`keep previous?.claim_unavailable` on the `attempted > 0`
`ok` write; the spool is EMPTY, so `attempted === 0` and that arm never executes).
The comment now names the mutant that does red it: deleting the
`summary.claimHeld && !summary.claimUnavailable` clearing block in `recordOutcome`.
PROVEN by applying that mutant — the row reds (`actual: true, expected: undefined`)
— then restoring.

F4 — the two new Pi-leg tests called `mkfifo` unguarded, so a win32 box (or one
without the binary) THROWS instead of grading: a one-leg regression against the
pre-existing FIFO test beside them and against both Python twins (which skip).
Both now use the file's own guard (win32 return, then try/catch return).

Also: the cycle-11 disposition table is recorded in `pr-body.md`, so the durable
record carries what was found and what was done with it.

* fix(14350): only a pass that HELD the claim may clear the durable fact (review F1), and the measurement refuses a race nobody won (F2)

Two findings from the fresh-context review at `e2d43ad37577`, both verified against
the source before being applied.

F1 (P1) — THE DURABLE FACT WAS ERASED BY THE PASS THAT RUNS MOST OFTEN.
`_record_capture_status`'s `attempted > 0` arm wrote a fresh `ok` record carrying no
claim field, which DELETED `claim_unavailable` / `claim_unavailable_reason`. A TARGETED
pass (`only_session_id` — the SessionEnd path and the store-sync replay) takes no claim
by design, so it reported neither `claim_unavailable` nor `held_claim` and took that
arm: on an obstructed box one successful `tortoise session capture` wiped the warning
until the next general pass re-recorded it. That is the false-PASS direction the field
exists to remove, through the writer that runs most often — and cross-leg, because
`status.json` is shared.

The rule is now the one the comments already claimed: ONLY a pass that HELD the claim
may clear it; every other write CARRIES IT FORWARD. The record is built and written ONCE
at the tail (both legs) instead of at four call sites, so the policy is one rule rather
than a property of whichever arm ran. The Pi leg's is exported as `applyClaimPolicy`
and is the same matrix as the Python twin's, row for row.

F2 (P2) — THE MEASUREMENT SIGNED OFF A RUN THAT MEASURED NOTHING.
`_claim_race` returned `supported: bounded`, and `bounded` is a statement about the
probe's own hold. A run whose processes never reached their attempt reported
`winners: 0`, `bounded: true`, `supported: true` — exit 0. The `BARREN` marker that says
exactly this was printed by nobody that parsed it, and the tool had NO test at all
(`git grep measure_drain_convergence -- tests/` → 0 hits), so deleting the verdict gate
redded nothing. `supported` is now `bounded and barren == 0 and winners == 1`; `barren`
is counted; `_no_verdict` covers all three ways of measuring nothing; and `winners == 2`
stays a FINDING (exit 0), because that is the defect the harness exists to report.

Both legs, and every mutation above was verified RED under the edit it names:

```
uv run python tools/test_lane.py run -- tests/test_14350_drain_convergence.py \
    tests/test_capture_install.py tests/test_docs_citation_refs.py \
    tests/test_12184_shifted_cites.py -q
node --test tortoise/pi-hooks/tortoise-capture.test.ts
```

The seam generation stays 33 (it has never shipped, so it freezes when this lands) and
`_PINNED_PI_SEAM_INSTALL_CONTRACT` / `_GENERATION_DIGESTS[33]` are re-derived from this
tree's bytes, as every earlier re-cut of this unreleased seam did.

* test(14350): re-derive the residue block's graded extent figure — 1921 -> 1930

`tests/test_sdk_privatise_sweep.py::test_the_extent_figure_is_the_walks_own_count`
was RED on this branch before this commit: the sentence published 1921 while
`_residue_block()`'s own walk over `tools/sdk_privatise.py` returns 1930.

The delta is attributed line by line rather than adjusted by arithmetic:
`origin/main`'s tree reads 1921 and publishes 1921 correctly there; this branch's
two record notes inside the walked `#:` run add nine — the predecessor's re-pin
note (6) and this lane's merge-tree derivation note (3). The peer reflow of the
first note and the `origin/main` integration add nothing.

This is the file's own prescribed repair ("re-derive the figure instead of
carrying it forward"), and the cause is recorded beside the figure so the next
reader can see where the nine came from.

`TORTOISE_TEST_CARVE_OUT=1 .venv/bin/python -m pytest
tests/test_sdk_privatise_sweep.py -q -p no:cacheprovider` -> 36 passed.

* record(14350): fold cycle 12's dispositions in, and re-derive the record on the merged tree

Merges the peer lane's cycle-11 head (`a5061134`) — that lane is dead (its processes are
gone; both of its pushes came from lanes that have since exited), so its work is adopted
rather than rewritten.

`pr-body.md` carries the cycle-12 disposition table for the F1 (durable fact erased by the
targeted pass, both legs) and F2 (the measurement signed off a run that measured nothing)
fixes, plus the P2-minor prose correction.

Every number in the record is RE-MEASURED on this merged tree, not carried:

  tests/test_14350_drain_convergence.py                 69 passed
  the capture family (9 files, as the record names them)  768 passed
  node --test capture + volunteer                       317 pass / 0 fail

The generation-33 seam digest moves to `c139da33…` (cycle 12's `applyClaimPolicy`
extraction is a byte change on the shipped artifact) and stays generation 33, for the
reason every earlier re-cut stated: 33 has never shipped, so it freezes when this reaches
`main`. The residue pin is unchanged at `(11911, "3e92044bab08cc3d")` — cycle 12's Python
edits added no untyped `.update(` receiver — and `--check` exits 0 on it.

Also re-aims the Pi leg's "a HEALTHY pass clears the recorded claim fact" mutation name at
where the clearing now lives (`applyClaimPolicy`'s `claimHeld` arm, not a block inside
`recordOutcome`), and PROVES it: deleting that arm reds the row.

* fix(14350): judge the object that landed even when it cannot be read (review F3), and stop the race barrier deadlocking on the finding it exists for (F1)

Cycle-13 review of PR #14480, findings F1–F4 (F5's record figures follow in the
next commit).

F3 (P3) — a regular file we could not READ was deleted as junk, on both legs.
`_read_raw` / the Pi leg's `lstatSync(...).isFile() ? readFileSync(...)` answer
`None` for TWO different facts: "not a regular file" (a FIFO/socket/symlink —
corruption, safe to drop) and "a regular file whose bytes could not be had"
(EMFILE/EIO/EACCES). The second is a peer's claim that arrived in the clear
window; unlinking it let this process win the next `link` and two holders
coexisted for up to ttl/3 — silently, the class GHSA-fq56-3cx3-fjxp describes.
The landed object now has its TYPE checked separately, and an unreadable regular
file is put BACK (`link`, create-if-absent, so a newer claim still wins) and
answered HELD/CONTENTION. That is the doctrine `acquire` already states for a
regular file it cannot read, applied where the object was being deleted instead.

F1 (P2) — the measurement could not report the finding it exists for, and two
tests certified that it could. The hold waited for `processes - 1` `done`
markers while a winner wrote its own only AFTER releasing, so with k winners the
marker population topped out at `processes - k`: every winner blocked to the
60 s deadline, `bounded` flipped False, and a two-drainer race came out as
"NO VERDICT — re-run on a quieter box" (exit 2). Each process now marks its
ATTEMPT as finished (won or lost) before the hold, and the hold waits for all
`processes` attempts — the fact the hold actually needs. `bounded: true,
winners: 2+` is now reachable, and a new test drives the real `_claim_race` with
a stubbed protocol that admits every contender to prove it.

F2 (P2) — the Pi leg's `held` → CONTENTION wiring had no assertion; the sibling
test called the primitive directly, so reverting the arm (`state.obstruction =
path`) redded nothing. A `clearClaimPath` test seam (same reason `takedown`
exists) lets a test stand inside the clear's window and drive
`acquireDrainClaim` into the `held` arm end to end.

F4 (P3) — the `gone`/`done` retry was the one lost-race arm that did not
`markRaced()`, so two exhausted attempts left the path empty with no race
recorded and `flushSpool` ran the whole pass UNCLAIMED under the false reason
"the spool root cannot hold a claim".

Every new case was verified RED under the mutation it names (all four legs:
Python clear, measurement barrier, Pi clear-honours, Pi raced marker, Pi
contention arm). Generation 33's seam digest is re-cut in place — it is this
PR's own unreleased generation, re-derived from the merged tree as at every
prior head.

* record(14350): state cycle 13's dispositions, and date the two figures that were re-cut

Cycle-13 review of PR #14480: 2 P2 (F1, F2), 3 P3 (F3, F4, F5) — every one is
answered in the fix commit that precedes this one; this commit is the record.

* A cycle-13 disposition table, row per finding, each naming the mutation it was
  verified RED under.
* `pr-body.md:247` — the fold paragraph said `SWEEP_RESIDUE` "stays
  (11901, 953c70c0…)", which is not the pin this tree ships. It now states that
  the pair belongs to that fold and names `(11911, 3e92044bab08cc3d)` at the head
  this record ships, with the command that re-derives it.
* The cycle-11 row's present-tense seam-digest claim is now past tense ("then
  stated 932d74a2… at that head") with this head's re-derived `ce6d8f53…`
  beside it — a digest not quoted AT A HEAD is not a claim a reader can check.
* Test counts re-measured on this tree, not arithmetic'd: 71 for
  tests/test_14350_drain_convergence.py, 770 for the nine-file capture family,
  320 for the two Pi test files.

* fix(14350): close cycle 15's five P3s — the two legs disagreed in writing about one shared record

Fresh-context review at `c7c4d013`: 5 P3, no mechanism defect (the review verified the
durable-fact rule, the clear's HELD/GONE judgement, the measurement gate, the residue pin
and the generation-33 digest by reading the code AND by running the named mutants). All
five are fixed at the source.

1. `withClaimTerm`'s doc block was STILL stacked above `applyClaimPolicy`, so the
   operator-line function — this PR's headline claim — carried no doc comment and a hover
   on the policy showed two blocks describing different functions. This was cycle 14's
   F2: its fix commit closed the P2 and left this one standing, and the record's log
   stopped at cycle 13, so nothing said the finding had been raised. The block is back
   above `withClaimTerm`, and `pr-body.md` now carries the cycle-14 row (marked as NOT
   fixed in that round, which is the accurate record) plus a cycle-15 table.

2. THE TWO LEGS WROTE DIFFERENT RECORDS FOR THE SAME PASS. With
   `claim_unavailable_reason = ""`, Python tested truthiness (`""` → the default) and the
   Pi leg tested nullish (`""` written verbatim) — two different
   `<spool>/status.json` bytes from one pass, in a SHARED on-disk record whose whole
   justification is field-level identity, and in the predicate class
   `client_captured_at_source` was fixed for in this same file. Both legs now test
   truthiness, and a `("", unavailable)` row is added to BOTH cross-leg matrices —
   flipping either leg back to nullish reds the parity row on that leg (verified).

3. `test_a_HEALTHY_pass_CLEARS_the_recorded_claim_fact` (Python) named a mutant that
   cannot red it — merging the prior record into every write leaves it GREEN, because the
   `elif held_claim:` clearing arm pops the fields again afterwards — while its Pi twin
   documented exactly that defect. The docstring now names the mutant that does red it
   (deleting that clearing arm; verified RED) and says why the old one is green.

4/5. Two record-accuracy fixes: the cycle-13 Python-case count said "four" while the same
   sentence's arithmetic said `+2` (it is two), and the `tools/sdk_privatise.py:1654`
   anchor no longer holds the sentence it describes because the fix rewrote that block —
   the row now says "at that head".

The generation-33 seam digest is re-derived from this tree (`fc1b7c71…`); generation
stays 33 (never shipped, so it freezes when this lands). Verified on this head:
`tests/test_14350_drain_convergence.py` 71 passed, the nine-file capture family 770
passed, `node --test` capture+volunteer 320 pass / 0 fail, `sdk_privatise.py --check`
rc 0 at `(11911, "3e92044bab08cc3d")`, cypher census 25 pins, ci_selection integrity
clean, ruff clean.

* test(14350): pin the two mechanisms where a mutation could still re-ship them green

Reconciles the late-posted review at `ef4c1405` (3 P2 + 5 P3), which arrived
after `c7c4d013` had already been reviewed clean. Four findings were real gaps
in the GUARDS; four were already closed. Each fix was verified RED under the
exact mutation it prevents (patch, run the named row, restore, sha256-check).

P2 — the Pi leg's F1 was pinned only as a pure function. The pre-fix call site
(`if (summary.claimHeld || next === null) next = applyClaimPolicy(…)`) — a
claim-less pass with an earned record BYPASSES the policy — left the suite
green. Now an end-to-end row installs a REAL peer claim through
`acquireDrainClaim`, so the general pass is genuine contention ("another
drainer holds this spool … nothing attempted") and the only writer is the
targeted/live pass that files the session. Verified RED under that call site.

P2 — both legs could INVENT the durable fact; no matrix row had "no prior
fact". Added `("targeted, earned ok, NO prior fact")` on both legs. Verified RED
on Python under the widened arm (`elif record is not None:`).

P2 — the third no-verdict way had no discriminating row, and neither the
`barren` COUNTER nor `supported`'s new conjuncts were graded at the producer.
Added a `bounded:false, winners:1, barren:0` row and a row that drives the real
`_claim_race` with the arrival barrier expiring for every process. Verified RED
by deleting the `bounded is False` arm and by deleting
`barren += out.count("BARREN")`.

P3 — the nested-race scan was unguarded: `--scenario all` nests `claim_race`
under `baseline`/`saturated`, so deleting the loop left `_no_verdict`
permanently False in the tool's only multi-race mode. Added a bidirectional row;
verified RED by deleting the loop.

P3 — the module docstring named `claim_winners` (the receipt field is `winners`),
said "MUST be 1" without noting 0 exits 2, and omitted `barren`. Corrected, and
`bounded`/`supported`/`_no_verdict`'s exit-code contract are now stated.

P3 — the TS matrix reused ONE mutable `earned` object across rows while
`applyClaimPolicy` mutates `next`, so a missing `delete` was detected only
because an earlier row had already stamped the fact onto it. Both inputs are now
copied per row.

P3 — the record's per-row case counts were off by one each way. Measured, not
arithmetic: 8 new `def test_` in `7cf106b6be` (3 claim-policy + 5 measurement);
rows corrected to Three / Five.

Also: the two-winner barrier row called `_no_verdict(receipt)` on a bare RACE
dict, which `_no_verdict` never reads (it looks under `claim_race`) — so that
assertion passed vacuously. Now wrapped.

P3 — `pr-body.md:247`'s `SWEEP_RESIDUE` pair was already closed at `c7c4d013`;
re-verified, no change owed.

* record(14350): correct three record-accuracy defects the re-review found (no code change)

Fresh-context re-review of `a8d84327` returned 3 P3s, all record accuracy, and no code
finding: it re-measured the digest (`fc1b7c71…`), the residue pin (11911, rc 0), all three
counts (71 / 770 / 320), and both directions of the new cross-leg reason row, and applied
both mutants the previous commit names.

1. `pr-body.md` claimed "cycle 14's one" Python case — a phantom: cycle 13's attribution
   already accounts for both cases, and this delta adds ZERO collected tests (its new `""`
   row is data inside an existing loop, not a parametrize row). The clause is gone.
2. The cycle-14 table I added re-credited cycle 13's F1 as a separate, independently fixed
   P2 — one defect and one fix, counted twice, with the fix living inside the very commit
   the row's header named. That whole block is removed; the surviving round table is the
   one for `c7c4d013`.
3. The `withClaimTerm` doc-block finding had been raised by more than one earlier round and
   recorded NOWHERE (verified: `grep -n withClaimTerm pr-body.md` matched only the cycle-10
   P1 row, which is about the parity pin). The row now says that plainly instead of
   attributing it to a round whose table cannot carry it.
4. `test_a_HEALTHY_pass_CLEARS_the_recorded_claim_fact`'s docstring said the Pi twin "says
   the same thing for the same reason" — it does not: the twins reach the same verdict by
   different routes (that spool is empty on purpose, so `attempted == 0` and the `ok` write
   never executes). The paragraph above it already stated the difference, so the trailing
   clause reintroduced the unattributable-justification class this delta exists to close.

No source or test behaviour changes, so the seam digest, the residue pin and the counts
are unchanged and were re-checked rather than re-derived.

* fix(14350): escape the two pipes that split record table cells (docs gate)

The required `docs` check failed on `pr-body.md` alone:

    pr-body.md:337:161 error MD056/table-column-count [Expected: 2; Actual: 3]
    pr-body.md:348:125 error MD056/table-column-count [Expected: 2; Actual: 4]

Two `|` characters inside a two-column table cell were read as cell
delimiters by markdownlint: the shell pipeline in the cycle-15 row
(`git show … | grep -c`) and the `||` in the cycle-16 row's TypeScript
call site. Escaped as `\|`, which renders as a literal pipe inside the
code span.

Verified with the job's own producer and differ, not by eyeballing it:

    bash .github/scripts/docs-markdownlint.sh --cli2 [email protected] \
        --files-from /tmp/pr-md.nul --output /tmp/mdlint-pr-14480.txt
    # Summary: 0 issues in 0 files
    python3 tools/docs_lint_baseline.py check ... --baseline config/docs-lint-baseline.json
    # docs-lint baseline: 0 new, 0 known (baseline), 0 in generated files  (exit 0)

No code, test or contract change: this is the record file and nothing else.

* record(14350): re-derive the three counts on the merged head

`74` collected for `tests/test_14350_drain_convergence.py` (67 `def test_` with one 8-way
parametrize), `773` for the nine-file capture family, `321` for the `node` pair — all
re-RUN on this merged tree, not carried. The prose now states the collection MODEL beside
the total and names the figures each later round moved, because a carried count has been
the wrong number in this record four times.

* fix(14350): a failed restore must not delete the only copy of a live claim (both legs)

Fresh-context review at `b17a8828`: 3 P3, and one of them is CODE. The other two are record
accuracy in the log this PR is largely about.

THE CODE ONE — a failed restore DESTROYED the claim it promised to honour.
`restoreQuarantine` / `_restore_quarantine` and `disposeQuarantine` / `_dispose_quarantine`
printed a warning on any `link` failure that was not `EEXIST` and then ran an UNCONDITIONAL
`unlink`. Because the rename had already vacated the claim path, the quarantined file was
the ONLY copy of that holder's claim: the next `link` won the emptied path, and two holders
coexisted for up to `ttl/3`, silently, with the moved-aside evidence gone too. `link(2)`
lists EACCES/EDQUOT/EIO/EMLINK/ENOSPC/EPERM/EROFS/EXDEV beside EEXIST, and ENOSPC/EDQUOT on
a spool directory is the ordinary case. It also contradicted this module's own doctrine
("an unprovable read is ALIVE") and four statements in the record.

Fixed on BOTH legs: a non-`EEXIST` failure leaves the quarantined object in place (the
`*.tmp-*` shape is swept by the scratch sweeper on mtime, so nothing outlives the process)
and the answer stays HELD — the fail-CLOSED one.

⛔ NOT `_CLEAR_REFUSED`, which the review proposed and which is WORSE here: REFUSED raises
`DrainClaimUnavailable`, whose handler stats the path, finds nothing, and runs the pass
UNCLAIMED with the false reason "the spool root cannot hold a claim" — the same false
diagnosis this PR exists to remove. On the Pi leg a HELD answer over an empty path also
records the lost race, because `flushSpool`'s first arm looks for a record and would
otherwise fall through to its unclaimed arm.

RECORD — the cycle log had no Cycle 15 (headings ran 13, 14, 16), seven new comments cited
"cycle 13" for rows that live in another round's table, and that round's header claimed
"four … and four" against its own eight rows. The reconciliation round is now Cycle 15, its
header COUNTS its rows (5 pinning gaps + 2 record fixes + 1 already closed), the citations
point at the round that owns them, and this round is recorded as Cycle 16.

One row per leg for the restore rule, each verified RED under the unconditional `unlink`;
the record's counts and the generation-33 seam digest are re-derived on this tree
(`7e8ee041…`): 75 collected (68 `def test_` + one 8-way parametrize), family 774, node pair
322.

* fix(14350): the failed quarantine restore renames back or preserves — never deletes

Cycle-17 review (PR #14480 @ b17a8828), 1 P3, both legs: `_restore_quarantine` and
its Pi twin `restoreQuarantine` deleted the object they promise to honour when
`link` failed for any reason other than EEXIST. The claim path had already been
VACATED by the caller's rename, so a peer's record existed nowhere while the peer
still believed it held — and this process then won the next `link`, the two-holder
window the whole mechanism exists to close, with the only copy of the evidence
destroyed and the warning on a stderr a session discards.

Both legs now never unlink what they could not put back:

* the claim path is still free -> `rename` the object BACK. `rename` needs no hard
  link, which is the reachable failure (EPERM/EXDEV/EMLINK/ENOSYS), and it is the
  fallback filelock's stale break takes for exactly this reason (tox-dev/filelock#843,
  `_util._linked_back`). It runs only after `lexists` says the path is empty, because
  `rename` replaces where `link` never does.
* even that fails -> the quarantined copy is LEFT IN PLACE, and the warning names it.

The answer stays HELD on both legs, deliberately NOT the REFUSED the review
proposed: verified against the consumers, REFUSED raises DrainClaimUnavailable,
whose handler re-lstats the path the caller emptied and runs the whole pass
UNCLAIMED beside the displaced holder (capture_spool.py:4366-4375; the Pi twin
takes that unclaimed arm at tortoise-capture.ts:4546). HELD is the only answer that
keeps the pass off the spool.

Tests (each RED on the pre-fix code, sha256-verified restores):
* Python 3 rows: rename-back restores the peer's bytes; both restores refused ->
  the copy is PRESERVED; end-to-end acquire answers CONTENTION with the claim
  readable at the path. Pre-fix: `3 failed, 74 deselected`.
* Pi 2 rows: same two arms through `clearUnusableClaimPath`, whose restore now takes
  `link`/`move` seams (the same reason it already takes a `rename` seam).
  Pre-fix: `fail 2`.

Record: pr-body.md gains the cycle-17 row; counts re-derived on this tree
(77 / 776 / 323) and the generation-33 seam digest re-cut to the shipped bytes
(105d5667...), in `_PINNED_PI_SEAM_INSTALL_CONTRACT` and `_GENERATION_DIGESTS[33]`.

* test(14350): pin the Python half of the failed-restore rule (review P3, both legs)

The cycle-16 fix touched TWO helpers per leg — `restoreQuarantine`/
`_restore_quarantine` and `disposeQuarantine`/`_dispose_quarantine` — and only
one of them was pinned on the Python leg: its row drives
`_clear_unusable_claim_path`, so `_dispose_quarantine`'s new `return False`
(keep the displaced claim in the quarantine when the `link` back fails for a
reason other than EEXIST) had no discriminating assertion. Reverting it left the
suite green, and the failure mode is the one cycle 16 fixed: on ENOSPC/EDQUOT/
EPERM the quarantined file is the ONLY copy of that holder's claim. The Pi leg's
own row already asserts both of its primitives, so this is a cross-leg pinning
asymmetry, not a new rule.

The new row drives the real `_takedown`, refuses only the `link` back with
ENOSPC, and asserts the quarantine still holds the displaced bytes. The RETURN
VALUE cannot carry the pin — the pre-fix code also returned `False`, after
unlinking — so the preservation assertion is the whole test. Verified RED under
the pre-fix unconditional `unlink`, file restored sha256-verified.

Counts re-derived at this head: 76 collected (69 `def test_` + one 8-way
parametrize), family 775, node pair 322 (unchanged — no shipped bytes moved, so
the generation-33 seam digest does not move either).

* fix(14350): the only-copy rule now actually lands on `_restore_quarantine` (cycle 16's P1)

Fresh-context review at `a3a80e68` returned 1 P1 + 2 P3, and the P1 is cycle 16's OWN fix,
measured as not landed:

`tortoise/drain_claim.py`'s `_restore_quarantine` had its signature changed to `-> bool`
and its body left byte-identical to the pre-fix version. So the only-copy deletion was
STILL live on the Python leg (a non-`EEXIST` `link` failure warned and then unlinked the
quarantined object — the only copy of a live holder's claim, since the rename had vacated
the path), `if not _restore_quarantine(…)` printed a FALSE diagnosis on the healthy path
because `None` is falsy, and `grep -rn _restore_quarantine tests/` was still zero hits, so
nothing redded.

Fixed for real and pinned AT THAT BRANCH: `return False` in the `except OSError` arm (the
object stays in the quarantine; the `.tmp-` infix is what the sweepers collect by mtime, so
nothing outlives the process) and `return True` after a successful sweep, with the contract
in the docstring. The new row makes the quarantined object UNREADABLE (so `landed is None`
and the lstat says regular) and makes `link` raise `ENOSPC`, then asserts HELD plus the
peer's bytes still on disk — RED under the unconditional `unlink` (verified). The previous
round's row only reached `_dispose_quarantine` (its peer claim was READABLE, so
`landed is not None`); the two functions are adjacent and only one was covered.

Also: one of the seven re-pointed citations still said "cycle 13" for a finding owned by
cycle 15's table (fixed, and it now says which two P2s cycle 13 does own), and the cycle-16
table asserted that unverifiable rows "were deleted" when no row had been deleted (the claim
is removed rather than reworded — the diff shows only the two digest rows, each re-added).
The cycle-17 table records all three, including the retraction in cycle 16's own row.

Counts re-derived on this tree: 76 collected (69 `def test_` + one 8-way parametrize), the
nine-file family 775, the node pair 322. The generation-33 seam digest is unchanged
(`7e8ee041…`) because no `.ts` byte moved this round.

* record(14350): fold the second lane's cycle-17 row in and re-derive the counts

The head `a3a80e68` drew two independent reviews; the second one is a pinning gap (the
Python leg's `_dispose_quarantine` half), fixed by the other lane and merged here. The
record now says the numbering repeats because the head does, rather than leaving two
"Cycle 17" tables that read as a bookkeeping error.

Counts re-measured on the merged tree: 77 collected (70 `def test_` + one 8-way
parametrize), the nine-file family 776, the node pair 322. The generation-33 seam digest is
unchanged (`7e8ee041…`) — no `.ts` byte moved.

* fix(14350): escape the pipes that would fail the docs gate, restore the P3 label, and correct the docstring the code invalidated

Fresh-context review at `ac90e280`: 1 P2 + 2 P3, all record/docs, and the P2 would have
failed a REQUIRED check.

P2 — THE DOCS GATE. My cycle-16 row quoted a shell pipeline inside a table cell with
UNESCAPED pipes, splitting the 2-cell row into 4. Verified with the pinned linter
(`npx [email protected]` → `MD056 Table column count [Expected: 2; Actual: 4]` at
`pr-body.md:365`), verified delta-introduced (the previous head lints `0 issues`), and
verified the gate fails CLOSED on it: `pr-body.md` is a tracked changed `.md`, the baseline
holds no `markdownlint` entry keyed for it, and `tools/docs_lint_baseline.py` appends every
un-baselined finding to `new` and returns non-zero. Both pipes are now escaped, as the
earlier docs fix did for the other rows; the file lints clean.

P3 — ONE FINDING, TWO GRADINGS. My delta re-labelled cycle 16's row from P3 to "P1", which
left six code comments citing "cycle 16, P3" resolving to no cycle-16 P3 row. The label is
restored: cycle 16 graded it P3, and the P1 is cycle 17's own finding — that cycle 16's fix
did not LAND — which cycle 17's table already owns. The header now says so.

P3 — A DOCSTRING THE CODE INVALIDATED. `_dispose_quarantine`'s paragraph still said a
failed restore means "its claim file is gone", which is exactly what this PR removed: on a
non-`EEXIST` failure the object is LEFT in the quarantine. The sentence now says that, and
says plainly that the earlier wording described an unlink this branch no longer performs —
the paragraph carries its own "a false sentence is worse than no sentence" disclaimer, so
leaving it would have been the defect it warns about.

Verified on this head: `test_lane … tests/test_14350_drain_convergence.py -q` → 77 passed;
markdownlint 0 issues; no table row's unescaped-pipe count differs from its header;
`sdk_privatise.py --check` → 0; the generation-33 seam digest is unchanged (`7e8ee041…`,
no `.ts` byte moved); ruff clean. The record's counts are unchanged by this commit (77 /
776 / 322, re-measured last commit).

* fix(14350): a FIFO at status.json cannot wedge the claimed pass, and an unreadable claim is a durable stall

Two findings from the fresh-context review at 23ac4a97 (P1, P2), both Python-leg
first; the Pi twin follows in the next commit.

P1 — `read_capture_status` read the status path with no `lstat` gate. Reading a
FIFO blocks in `open(2)` until a writer appears, and this diff had just put that
read on the DRAIN path inside the claimed section (the claim-policy carry-forward
reads `status.json` after the pass's POSTs and before `release()`), so a FIFO
there wedged the pass while it HELD the one-drainer claim and hung
`session health` on the same path. The gate is the one `drain_claim._read_raw`
already puts on the CLAIM file for the same measured reason: only a regular file
is read; anything else is "nothing recorded", never a crash, and the next write
replaces it (the write is rename-based).

P2 — an unreadable regular `drain.claim` (mode 000, an expired lease) made
`flush_spool` return `held_by_claim=True, attempted=0, claim_holder=None` on
every pass and write nothing durable, so the box filed nothing while the health
line said `capture: DRAINING`. `claim_is_stale` reports that claim reclaimable
while no reader can reach it, which is the permanent block #14350's own row
forbids, and the pid/lease `holder()` renders are exactly the bytes that cannot
be read. The stall is now a durable fact (`claim_unreadable` /
`claim_unreadable_reason`), carried by the one claim policy: a pass that HOLDS
the claim clears it (that pass proved the path readable), a targeted pass carries
it forward, a healthy pass with no prior fact never invents it. The operator line
gains one term — `, drain claim UNREADABLE (<reason>)` — after the exclusion
term, in a fixed order both legs share.

Also fixes the same-leg half of the review's P3: the rendered reason must be a
non-empty STRING (Python already gated on `isinstance(reason, str)`), and the Pi
leg's truthiness/nullish tests are aligned to it in the next commit.

Tests (+2, both in tests/test_14350_drain_convergence.py):
* a FIFO at status.json does not block `read_capture_status` nor
  `capture_health_line` (watchdog thread: pre-fix it BLOCKS, so the row fails
  rather than hangs);
* an unreadable regular claim is a durable stall AND is cleared by the pass that
  holds the claim.

tests/test_14350_drain_convergence.py: 83 passed (was 81).

* fix(14350): make the Pi leg's "PRESERVED" warning true, and finish the citation re-grades

Fresh-context review at `557a394d`: 1 P2 + 4 P3, all closed here.

P2 — THE PI LEG'S WARNING CONTRADICTED ITS OWN CODE. `disposeQuarantine`'s OCCUPIED arm
warned "the copy is PRESERVED at <quarantine>" and then FELL THROUGH to the `unlinkSync` at
the bottom of the function, destroying the only copy of the displaced holder's claim — the
code contradicting its own sentence, which is this PR's subject, and a divergence from the
Python twin, which returns inside that arm. It was also unpinned: adding the missing
`return false;` redded nothing (272 pass / 0 fail measured with the row absent).
Fixed: the arm returns, with a comment saying why the fall-through was the defect, and every
failure path now returns (the bottom `unlinkSync` is reachable only after a SUCCESSFUL link,
where the quarantined copy is a duplicate). A new row drives the arm — an occupied path plus
a `link` refusal that is not `EEXIST` — and is RED without the return (verified).

P3s:
* `_dispose_quarantine`'s docstring said a non-`EEXIST` failure leaves the claim at `path`
  ABSENT, which the delta's own rename-back makes false in the dominant arm. Scoped: the
  object is put back while the path is free, and only a failed rename-back or an occupied
  path leaves it in the quarantine.
* a row's comment credited `_restore_quarantine` with a mechanism the row actually drives in
  `_dispose_quarantine` (verified by mutation: the `_restore_quarantine` mutant leaves that
  row green, the `_dispose_quarantine` mutant reds it). The comment now names the right
  helper, and points at the rows that cover the other.
* five citations were left at "cycle 16, P3" / a bare "P3" after the re-grade; they now cite
  the round's P1, including the Pi `held`-over-empty-path guard the previous delta missed.
* `pr-body.md` claimed `WORKTREE-REPORT.md` carries the commands verbatim and there was no
  such file: created with `tools/worktree_report.py init` + `run --cmd '<verbatim>'` for all
  three suites. It records one intermediate FAILING suite honestly (the seam-digest red
  before this commit's re-pin) followed by the green re-run, so `check` exits 3 — red-but-
  valid evidence, never a pass (AGENTS.md).

Re-derived at this head: generation-33 seam digest `041c80bb…` (both pins + every "capture
half" quote), 81 collected (74 `def test_` + one 8-way parametrize), family 780, node pair
326. markdownlint 0 issues, `sdk_privatise.py --check` 0, cypher 25 pins, ci_selection clean.

* copy(14350): correct the comment that over-claimed which failure paths return

The confirmation review at `08fd0891` found one P3, in a comment this PR itself added:
"Falling through here means `linkSync` SUCCEEDED … Every FAILURE path above returns". The
`EEXIST` arm is a `linkSync` FAILURE that does NOT return — it warns and falls through to
the same `unlinkSync`, which is CORRECT and matches the Python twin's
`except FileExistsError` arm ("the displaced record's bytes are gone, and the only honest
thing left is to say so": a newer claim holds the path, so the copy is a superseded one).
Only the two PRESERVED arms return, and that is exactly what keeps that word true.

The comment now states both fall-through routes and pins the `EEXIST` arm's intent, which
had no other description in the code (no test row covers that arm — the nearby rows are all
non-`EEXIST`). No behaviour change.

The generation-33 seam digest is re-derived from the new bytes (`6652dd6b…`, both pins and
every "capture half" quote); `node --test` 272 pass / 0 fail on the capture file,
`test_capture_install.py` + `test_14350_drain_convergence.py` 303 passed, markdownlint 0
issues, `sdk_privatise.py --check` 0.

* fix(14350): the Pi leg gets the same status gate and the same durable stall, and the record is re-derived

Pi twin of 2bb71d72 (review P1/P2), plus the P3 the Python half could not
close on its own.

* `readCaptureStatus` now `lstat`s before it reads: `readFileSync` on a FIFO
  blocks forever, and this accessor runs inside the claimed section, so a
  non-regular object at `status.json` wedged the pass that HELD the claim and
  hung the health line on the same file.
* `applyClaimPolicy` gains the `claimUnreadable` arm (durable stall), clears it
  when a pass HELD the claim, carries it for a targeted pass, and drops it when a
  pass could not install a claim at all — the one-way-latch direction, which the
  Python arm now also refuses.
* `withClaimTerm` renders `, drain claim UNREADABLE (<reason>)` as a second term
  in a fixed order, and gates the suffix on `typeof reason === "string"` —
  the Python predicate, so a foreign record renders one sentence on both legs.
  The carry gate becomes `!= null` (Python `is not None`), so a JSON `null` reason
  is dropped on both sides.

Tests (+4 Pi, +1 Python) and the seam pins re-cut to `2b2f91d6…`, because this
commit changes the seam's bytes.

Verified RED under each named mutant (mutate, run, restore, sha256-check):
removing the lstat gate (child times out), the `withClaimTerm` stall arm, the
policy's `claimUnavailable` arm keeping a stale stall, the carry loop, the
held-clear, the truthiness suffix test, the `!== undefined` carry gate, and the
pass's own `claimUnreadable` flag.

tests/test_14350_drain_convergence.py 86 passed; the 9-file capture family 785
passed; `node --test tortoise-capture.test.ts tortoise-volunteer.test.ts` 329
pass / 0 fail; `ruff check` clean; `ci_selection.py --integrity` OK;
`tools/sdk_privatise.py --check` exit 0 (pin (11911, "3e92044bab08cc3d") unmoved).
pr-body.md carries the cycle-18 table and this head's re-derived figures.

* fix(14350): a pass that could not install a claim REPLACES a recorded stall

The Python half of the policy row the Pi commit adds: the `claim_unavailable`
arm re-measured the claim path, so a `claim_unreadable` fact recorded earlier
(the unreadable object it describes is not what is there any more) must not
survive it. Carrying it would be a one-way latch — the same defect the clear
and carry arms exist to avoid, pointing the other way (#14480 review, P2).

Red by the "stalled, pass could not install a claim" row in
`test_the_claim_policy_carries_a_stall_only_while_it_is_still_true`, and by its
Pi twin, on both legs (verified: restoring the two fields reds that row).

* fix(14350): gate the status read, surface the permanent claim stall, align both legs' words

Cycle 18's review (a stale export at 23ac4a97d1fd, 15 commits behind this branch)
found 1 P1, 1 P2 and 2 P3. Each is re-verified against this tree, not restated:

P1 — `read_capture_status` / `readCaptureStatus` read `status.json` with no
`lstat`/`S_ISREG` gate, so a FIFO or socket there blocks `open(2)` FOREVER. This
diff is what put that read on the DRAIN path (`_record_capture_status`, at the tail
of `_flush_claimed`, while the one-drainer claim is still HELD — `claim.release()`
runs in `flush_spool`'s `finally`), and `capture_health_line` blocked on the same
path, so `session health` hung instead of reporting the box. Fixed on both legs by
the module's own doctrine, applied one path short: only a REGULAR file is read
(`drain_claim._read_raw` gates the CLAIM file for exactly this reason, cycle-5 P1).

P2 — a regular `drain.claim` this process cannot read is HONOURED, so every pass
answers `held_by_claim` with no holder identity and the spool stops moving. The
residual justified that with "blocks the drain until a human looks" and nothing
told the human: the line read `capture: DRAINING (1 queued)` over a spool that can
never move. Fixed with a LIVE PROBE (`drain_claim.claim_path_unreadable` / the Pi
twin `claimPathUnreadable`) that adds `, drain claim UNREADABLE (a regular file
exists but could not be read)` to the operator line. Probed rather than recorded on
purpose: this fact is about the PRESENT state of the spool root, so a recorded copy
would need a clearing arm, a carry-forward arm and a staleness story — and a
long-dead lock could then keep the warning alive. The probe cannot, and it costs one
`lstat` + one `open` on a healthy box.

P3 — the two legs disagreed about a NON-STRING `claim_unavailable_reason` (Python
gated on `isinstance(…, str)`, the Pi leg on truthiness), about a JSON `null`
reason at the carry-forward arm, and — the same class in a third place — about
which claim-axis keys the SELF-HEAL keeps (the Pi leg copied only the truthy ones,
so `claim_unavailable: false` and a `null` reason vanished on one leg and survived
on the other, in the ONE file the two legs share).

P3 — the record counts were stale at the head they claimed: already fixed by
21a2c5e9b0, and re-derived again here because this round adds cases (84 / 783 /
326 measured on this tree).

Every fix is pinned by a case that was measured RED against the pre-fix code:
dropping the status-path gate hangs the reader (asserted at a bounded join on the
Python leg, times out the Pi case); reverting the probe to `False` reds the operator
line, the stall assertion and the cross-leg row; reverting the suffix's string gate
or the null-reason carry-forward or the self-heal's key-existence reds the parity
matrix. The generation-33 seam digest is re-cut from this tree (`49a2c0a8…`); 33 has
never shipped, so it freezes when this reaches `main`.

* record(14350): date the one comment that cited a row this record cannot hold

The confirmation review at `08fd0891` found one P3, and it is the citation class this PR
policies: the comment added by the previous delta cited `(review, cycle 16, P3)` for a
finding no cycle-16 row can carry — cycle 16 reviewed `b17a8828`, an ANCESTOR of the commit
that wrote the false comment, and the round that raised it (reviewing `08fd0891`) had no row
at all.

Fixed by DATING the citation instead of round-citing it, which is the one form that cannot
dangle, and by adding a `Cycle 18` row so the round exists in the log. The substance needed
no change: both `disposeQuarantine` and `_dispose_quarantine` were verified against the
sentence, including that the Python twin's `except FileExistsError` arm also sweeps a
superseded copy and its warning never says PRESERVED.

Generation-33 seam digest re-derived from the new bytes (`b775fcab…`, both pins and every
"capture half" quote). `node --test` capture file 272 pass / 0 fail;
`test_capture_install.py`'s seam rows 38 passed; markdownlint 0 issues.

* record(14350): split the merged cycle-18 row, and fix a citation that named the wrong round's F3

The confirmation review at `dd60e41a` found two record defects, both verified against
`git show <sha>:<path> | grep -c` and the PR's posted review comments:

1. The `Cycle 18` row I added merged TWO rounds into one and attributed the wrong finding to
   the wrong head: the citation-class P3 was CREATED by `92bbfb76`, so no review OF
   `08fd0891` could have found it, and the round that reviewed `08fd0891` actually raised the
   over-claim P3 in the "falling through" comment. The row is now one row per head — the
   over-claim (fixed in `92bbfb76`) and the dead citation (fixed in `dd60e41a`) — so both
   findings exist in the log and each citation points at a row that holds it. `dd60e41a`'s
   own commit message carries the merged provenance the table corrects; that is corrected
   here rather than by rewriting history.

2. `tests/test_14350_drain_convergence.py`'s docstring cited `cycle 12 F3`, which cycle 12
   records as the `sdk_privatise.py` pin-prose item. The finding it describes is **cycle 11
   F3** (the Pi twin's unreachable mutant, `pr-body.md:300`, whose text matches the docstring
   verbatim). One word; the citation now resolves.

No code change: the generation-33 seam digest is unchanged (`b775fcab…`), markdownlint reports
0 issues, the affected row passes, `sdk_privatise.py --check` exits 0.

* copy(14350): state the status-gate's replace window instead of implying the gate is race-free

Rung 2 (`web_search` model=sonar) on the external half of the cycle-18 research pass
turned up the canonical treatment of "read a path that may not be a regular file":
CERT C `FIO32` (Prevent Blocking on Special Files), `fifo(7)` (opening a FIFO blocks
until a writer appears; `O_NONBLOCK` makes a read-only open return immediately), and
`xz`'s `file_io.c`, which uses `O_RDONLY|O_NONBLOCK` plus an fd `fstat` precisely to
close the check-then-open window.

So the `lstat` → read gate this lane added closes the reported hang but not the race
that CERT names: an object swapped for a FIFO between the two syscalls still blocks.
That is now a STATED RESIDUAL in the code (both legs) and in the record, with the
sources and with the reason the race-free form is not adopted here (the claim-file
reader is gated the same way on both legs, and a second, stronger gate on one path is
a divergence a later reader would have to re-derive; the exposure already presupposes
a local writer who can replace the box's own state file).

No behaviour change: the gate is exactly as shipped in `ffad4ae6e8`. The generation-33
pin still moves, because the Pi leg's doc comment (shipped bytes) changed — re-cut
from this tree, `738b16f7…`.

* copy(14350): state the probes' replace window, finish the 18→19 relabel, drop a stranded JSdoc

Four P3s from the review at `bcb52e1d`, all record/doc, all verified against the tree:

1. The 18→19 relabel had been applied in the cycle table only: three sites still attributed
   cycle-19 findings to cycle 18 (whose rows hold neither), and a `tortoise-capture.ts:6320`
   line reference now points at unrelated code. The three sites say cycle 19; the line
   reference is head-qualified (`… at 23ac4a97d1fd`), since a bare line number in a record
   this long is a claim that rots.

2. `claim_path_unreadable` / `claimPathUnreadable` docstrings claimed "Only a REGULAR file is
   opened" as an ABSOLUTE. They are `lstat` then `open` — two syscalls — so an object
   swapped for a FIFO between them IS opened and the call blocks. The reviewer measured it
   (a real FIFO behind a patched `lstat` never returned). Both now state the REPLACE WINDOW
   as a residual, in the same words and with the same CERT C `FIO32` reference the sibling
   status gate already uses, and say why `O_NONBLOCK`+`fstat` is deliberately not adopted
   here (the probe and the status gate are one mechanism with one stated residual).

3. A head-relative figure ("15 commits behind the branch head") was present tense about a
   quantity that has moved: it is 31 behind this shipping head. Now dated, with the measured
   count beside it.

4. The merge left `withClaimTerm`'s old JSdoc stranded above `UNREADABLE_CLAIM_TEXT`, so the
   constant carried a comment about a function and the same prose existed twice. Deleted;
   the constant keeps its own block and the function keeps the expanded one.

Generation-33 seam digest re-derived (`0c4e960d…`, both pins and every "capture half" quote).
`node --test` capture file 273 pass / 0 fail; `test_14350_drain_convergence.py` +
`test_capture_install.py` 306 passed; markdownlint 0 issues; `sdk_privatise.py --check` 0; ruff
clean.

* record(14350): date the figure and the citation the last delta left head-relative

Three P3s from the review at `e66a5a15`, all of them the "figure quoted without its head"
class this record polices — and two of the three were introduced by the fix for that same
class, which is why they are recorded rather than quietly corrected:

1. `pr-body.md`'s cycle-19 header stated "31 behind this shipping head" while citing the
   range to `bcb52e1d` — right for the head the row was AUTHORED at, wrong for the head it
   ships at (32). It also left a parenthetical closed twice. Now all three figures are dated
   to the head each belongs to (`..ffad4ae6` = 15, `..bcb52e1d` = 31, `..HEAD` = 32).

2. Both probe docstrings cited "(review, cycle 19, P3)" for the over-claim, and cycle 19's
   recorded P3s hold different findings — nor COULD they: the over-claiming sentence did not
   exist at either head that round touched (it arrived in `ffad4ae6`, a sibling of
   `08fd0891`). Both now DATE the citation (`the confirmation review AT bcb52e1d`), the form
   this record already prescribes for a round it has not numbered.

3. `cycle 18 is the confirmation pair below` pointed the wrong way — Cycle 18 is recorded
   ABOVE that header. Now "above".

Generation-33 seam digest re-derived (`f36b8c84…`, both pins and every "capture half" quote).
markdownlint 0 issues; `test_14350_drain_convergence.py` 84 passed; `node --test` capture file
273 pass / 0 fail; `test_capture_install.py` seam rows 38 passed; `sdk_privatise.py --check`
0; ruff clean.

* record(14350): remove the `..HEAD` figure that rots on every commit

The confirmation review at `0116f07b` found the third count false at the head that ships: the
sentence said "32 behind THIS shipping head (`git rev-list --count 23ac4a97d1fd..HEAD`)" and
that command returns 33 at HEAD — 32 was true only of `e66a5a15`, the head it was written at.
It is a moving target by construction: ANY count to the live head rots on the next commit.

So the form is gone rather than corrected. The sentence quotes two figures, each bound to the
head it belongs to (15 to `ffad4ae6`, 31 to `bcb52e1d`), and says outright why there is no
`..HEAD` number and that this one already rotted once. That is the record's own dated-figures
rule applied to the sentence that was violating it.

markdownlint 0 issues. No code or test byte changed, so the generation-33 digest is unchanged
(`f36b8c84…`); `test_capture_install.py`'s seam rows, `test_14350_drain_convergence.py`,
`node --test` and the three tool gates were all green at the parent commit.

* fix(14350): ship generation 34 — generation 33 already shipped on main, so the in-place re-cut would have blocked every install

Cycle-19 review's P1, verified against `main` and against production code:

    origin/main:tortoise/pi-hooks/tortoise-capture.ts  ->  // tortoise-hook-version: 33
    sha256sum                                           ->  746075470aab…a2a00aa
    origin/main:tests/test_capture_install.py:5158      ->  33: "746075470aab…",
    commit                                              ->  da82ece4226
                                                            fix(14350): D1 — the drain
                                                            converges … (#14423)

So generation 33 reached `main` in #14423 — the direct predecessor this PR is the
follow-up to — with a self-consistent pin. Every earlier head of this branch
re-cut `_GENERATION_DIGESTS[33]` in place on the premise "33 has never shipped",
which was FALSE.

Why that is not cosmetic: `tortoise/hook_install.py`'s `detect_artifact_install`
compares the marker FIRST and the bytes when they match, and the mismatch arm
files `modified-artifact` — a BLOCKING finding (the arm beside it,
`ahead-artifact`, is the one that passes `blocking=False`). Leaving the marker at
33 while moving the bytes would therefore have made every Pi hook installed from
`main` read as a local edit after this merged. That is the #3512 class the pin
machinery exists to prevent, and this file's own doctrine already said it: a byte
change at a shipped generation moves the generation.

Fix:
  * `// tortoise-hook-version: 33` -> `34` in BOTH `tortoise-capture.ts` and
    `tortoise-volunteer.ts` (a marker on one half alone makes
    `contract_version_for("pi")` answer `None`, which is worse than the bug; the
    read half is marker-only, its behaviour is untouched);
  * `_GENERATION_DIGESTS[33]` restored to `main`'s frozen `746075470aab…`, with
    the branch's bytes added as `34` — an existing entry is never rewritten;
  * `_READ_SEAM_GENERATION_DIGESTS[33]` left as `main`'s `904d2742…`, `34` added
    for the marker-only read half;
  * both `_PINNED_*_INSTALL_CONTRACT` pairs moved to `(34, …)`, and
    `_EXPECTED_INSTALL_CONTRACT["pi"]` to 34 (the parametrised generation test
    and the canonical-marker test both hardcode it by design — they are the
    revert detector);
  * the four "33 has never shipped" statements corrected rather than restated.

Also closes three record defects the same review found: the `state.raced`
residual (it claimed no forcing test and "three sites"; the tree has a forcing
row and six `markRaced()` sites, and the claim contradicted this record's own
cycle-13 F4 row), `tools/sdk_privatise.py`'s citation of
`capture_spool.py:4037` for the untyped `.update(` receiver (it is `:4107`), and
R6's "everything else is the same on both sides", narrowed to the properties it
can actually claim with the known holder-sentence gap named as FILED (#14508).

Measured at this tree: `tests/test_capture_install.py` 222 passed;
`tests/test_sdk_privatise_sweep.py` + `test_13098_cypher_inventory.py` 113
passed / 14 skipped; `contract_version_for("pi")` -> 34 with one canonical
marker per artifact.

* record(14350): cycle 19 — the generation-33 P1, and three rows the tree refutes

Documents the P1 exactly as measured: generation 33 shipped on `main` in #14423,
so the in-place re-cut would have graded every Pi install made from `main` as a
blocking `modified-artifact`; this PR now ships generation 34, 33's entries are
frozen at `main`'s digests, and the four "33 has never shipped" statements are
corrected to say it DID ship rather than restated.

Also, three rows the tree refutes:
* the `state.raced` residual said the flag had no forcing test and was set at
  "three sites" — the tree has a forcing row and six `markRaced()` sites, and the
  claim contradicted this record's own cycle-13 F4 row;
* the two Summary cells describing `drain_claim.py` as "new" and the hook
  generation as "32 -> 33";
* R6's "everything else is the same on both sides", narrowed to the enumerated
  surface it can claim, with the known holder-sentence divergence named as FILED
  (#14508) rather than left inside a contract that says it cannot exist.

Digests in the body are re-derived at this head, not carried.

* record(14350): cycle 20 — the seam digest the generation-34 bump left stale in four places

The cycle-19 P1 fix (ship generation 34 instead of re-cutting 33 in place) moved the
capture half's bytes, so every figure this record quoted for the seam digest was stale
at the head it now ships — the exact rot class the record's own cycle-11 F5 and
cycle-19 P3 rows ex…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug security Fixes a published or draft security advisory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant