fix: preserve process lock exclusion across publication and reclaim

Merged
TH
2mo ago
+799-394

Summary

A paused publisher or reclaimer could lose process-lock exclusion through age-based recovery. Hardened users now serialize publication, reclaim and release with one non-expiring guard and one claim check. Failed publication rolls back its own empty directory; partial release preserves owner evidence.

Adds nonblocking acquisition, bounded acquisition with ownership assertion, and read-only inspection. Unknown claims remain retained with recovery guidance.

The exclusive-file guard blocks fresh legacy reclaim admission. It cannot revoke an already-admitted legacy reclaimer: shared paths require draining every legacy user and preventing legacy versions returning. ADR 0030 records that support boundary and manual recovery requirement.

Removes per-test idle-fixture deletion that raced late file writes; shared run cleanup owns these directories.

Foundational slice of #3116; 12 files touched. Registration and session migration follow in dependent PRs.

Validation

Tested commit: e7856a9fc6, rebased on main at be3c8104dd.

  • pnpm check:affected --run at ba51ec2c4d: passed; 5,913 tests, plus format, lint, types, layering, Fallow and build. e7856a9fc6 changes only one test and ADR 0030; the 45 lock tests and the test-size ratchet pass on it.
  • Two-process release under contention, 50 runs on e7856a9fc6: process A holds the lock through withProcessLock while process B polls acquireProcessLock on the same path every 100 ms. 50 of 50 passed, with 0 "Cannot verify ownership" rejections and no lock directory or .reclaim.lock left. B acquired at most 117 ms after A released, which is one poll plus process start. The same run also passed 50 of 50 on the previous code on this host, so it shows that release under contention works; it does not reproduce the slow-ps race.
  • New regressions fail on the previous code: release waits for a guard that another taker holds, and keeps the lock and guard in place while it waits; a contender judges a live owner without taking the guard.
  • At fb23259: planted red regressions for aged-guard stealing, failed publication, partial release and fresh legacy reclaim admission.
  • Real SIGSTOP publisher experiment (at fb23259) against current and pinned c237027 legacy implementations: both contenders refused; only the child published; release removed the lock.
  • The already-admitted legacy reclaimer schedule stays outside the contract, as ADR 0030 records.

Controlled child-process lock proof