Skip to content

fix: keep identity-proven live daemons in inventory - #162

Merged
schickling-assistant merged 1 commit into
mainfrom
schickling-assistant/2026-08-07-live-daemon-inventory
Aug 8, 2026
Merged

fix: keep identity-proven live daemons in inventory#162
schickling-assistant merged 1 commit into
mainfrom
schickling-assistant/2026-08-07-live-daemon-inventory

Conversation

@schickling-assistant

Copy link
Copy Markdown
Contributor

Fixes #161.

Why

When a live session lost its socket and pidfile but retained metadata, inventory ignored metadata.daemonPid and classified it as vanished. That made kill refuse the session and allowed gc to 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, and gc without weakening PID-reuse protection.

Verification

  • The real-daemon regression fails on 025a9034 because inventory reports vanished with pid: null.
  • The fixed test removes the socket and pidfile, proves inventory remains running, proves gc retains the record and process, and then terminates it through the real kill command.
  • An adversarial live-PID/mismatched-token control remains vanished and non-actionable.
  • Focused lifecycle slice: 46 passed, 0 failed.
  • TypeScript typecheck, docs verification, and nix build --no-link .#pty: passed.
  • Full suite: 1569 passed, 20 skipped, 4 failed. An independent exact-parent run reproduced the same four environment failures by test name and signature (zsh startup, vim welcome, and two nano UI cases); the subject adds exactly two passing recovery tests.

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 recover protocol.

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
schickling-assistant marked this pull request as ready for review August 7, 2026 21:32
@schickling-assistant
schickling-assistant merged commit c65818a into main Aug 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vanished session with a live daemon: kill/rm/recover all fail, and gc orphans the live process tree

1 participant