fix: recover an unlinked live daemon registry - #128
Merged
Conversation
myobie
marked this pull request as ready for review
July 30, 2026 17:29
This was referenced Jul 30, 2026
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.
Problem
A live daemon and PTY child survive when an external cleanup unlinks their pathname socket, pid sidecar, and metadata. Existing clients continue over accepted sockets, but new clients cannot find the daemon. Relaunching the stored command would create a duplicate provider.
Closes #126.
Change
PTY_ROOTand its.recoverydirectory are owned, private, non-symlink directories with bound inode identities.pty recover <name> --snapshot <metadata.json>validates the exact root, recovery directory, daemon PID, generation, process-start token, launch identity, and capability before publishing an HMAC-authenticated request.Fail-closed behavior
Recovery refuses legacy/unsupported snapshots, stale metadata revisions, non-private/replaced/symlink roots or recovery directories, malformed/oversize/symlink requests, wrong secret/PID/generation/start token/launch identity, replayed snapshots, foreign locks, reappeared sidecars, and foreign listener pathnames. Existing pre-protocol daemons never advertise the capability and are not claimed recoverable.
Review-RED closure
.recoveryinode to group/world-accessible after capture: recovery refuses before writing a request, result, lock, socket, pid, or metadata.Verification
Current exact head
f70f85baa89145136a63cc9909fc2423bd3d1e7d(test-only successor to the reviewed implementation):npm run typechecknpm run buildnix build .#pty— passed30565910199— passed30565910196— passedEarlier full-suite flake evidence at predecessor head
2b3d08d600f279e0cf525891808fd6e6183eb552is superseded by the green exact-head Test above. The production code is identical between those heads; the successor adds only the deterministic interruption regression.No production recovery was attempted.
Protocol selection
This is the selected issue #126 implementation. PR #127 used an incompatible unauthenticated root-level request protocol without mutable-metadata revision or private-root authorization binding and is closed as superseded.