fix(events): serialize orphan-claim reclamation behind a kernel recovery gate and treat zombie owners as dead - #247
Merged
Merged
Conversation
Use an auto-released Linux kernel gate to prevent delayed orphan cleanup from unlinking a replacement claim, and treat zombie owners as provably dead.
Freeze one remover inside the Linux recovery gate and prove a second contender cannot mutate the visible dead claim.
🦋 Changeset detectedLatest commit: 849ed67 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Delay the background child's exit until its shell parent has exec'd sleep so dash cannot reap it before the zombie assertion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses the two unresolved post-merge Codex findings on #229 (round 3 of the endpoint-claim hardening from #216/#229):
rm(stale identity snapshot) could unlink the replacement, yielding dual ownership and live-socket removal. On Linux, reclamation is now serialized behind an abstract-namespace socket recovery gate: acquisition is kernel-atomic, the gate is auto-released on process death (it can never itself be orphaned), and the owner re-verification + identity-matched unlink happen under the gate against a fresh snapshot. Under the gate the lock at the path cannot change between verify and unlink — reclamation removals are excluded by the gate, a provably-dead owner cannot be mid-release, andwxcreation needs a vacancy only a gate holder can produce — so the dual-contender window is closed, not narrowed. A gate squatter can only force the existing bounded-retry fail-closed error, preserving the "unverifiable claims remain fail-closed rather than stolen" invariant. Non-Linux POSIX keeps the previous identity-checked removal unchanged (documented: Node exposes no auto-released filesystem gate there); win32 never reaches reclamation (named pipes).process.kill(pid, 0)succeeds for zombies and their/proc/<pid>/statstart time is unchanged, so a died-but-unreaped owner pinned its claim until retries exhausted. The liveness check now parses the process-state field (comm-aware) and treatsZ/X/xas provably dead alongside the start-time mismatch.Tests
All #216/#229 transport and reclamation tests pass unchanged, plus three new deterministic tests:
serializes concurrent reclamation before either contender can unlink a replacement claim— both contenders freeze on the same dead-claim snapshot; the winner claims; the loser's later attempt leaves the replacement untouched; end-state has one reachable server.excludes a second orphan-claim remover while the recovery gate is held— freezes the first remover inside the gate after its fresh verify and proves a second full reclamation attempt is denied (removed=false, original dead claim's dev/ino still at the path). This test fails if the gate is ever dropped in favor of just re-reading the snapshot.reclaims an endpoint claim owned by a zombie process— creates a real unreaped zombie (sh -c 'true & echo $!; exec sleep 300'), waits for stateZ, and proves its claim is reclaimed.Scoped gates: event-ipc suite (14/14),
pnpm typecheck,pnpm lint— all green.