fix: keep identity-proven live daemons in inventory - #162
Merged
schickling-assistant merged 1 commit intoAug 8, 2026
Merged
Conversation
When the socket and pidfile disappear, retain lifecycle control through metadata.daemonPid only if the stored process-start token still matches the current OS process. This keeps list, kill, and gc consistent without trusting a reused pid.
schickling-assistant
marked this pull request as ready for review
August 7, 2026 21:32
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.
Fixes #161.
Why
When a live session lost its socket and pidfile but retained metadata, inventory ignored
metadata.daemonPidand classified it asvanished. That madekillrefuse the session and allowedgcto delete its last registry record while the daemon was still alive.Blindly trusting the retained PID would be unsafe because the OS may have reused it for an unrelated process.
What
Keep the pidfile authoritative when present. When it is absent, accept the retained daemon PID only if its current OS process-start token exactly matches the token stored in recovery metadata.
That restores one consistent lifecycle identity for listing,
kill, andgcwithout weakening PID-reuse protection.Verification
025a9034because inventory reportsvanishedwithpid: null.running, provesgcretains the record and process, and then terminates it through the realkillcommand.vanishedand non-actionable.nix build --no-link .#pty: passed.Scope
The change is limited to inventory PID resolution, its recovery regressions, and the disk-layout description. It does not alter the full-absence
pty recoverprotocol.