fix: a registered server is trusted only once it has said which repository it serves - #89
Merged
Conversation
…itory it serves A registry knows only its own data directory, so the port a dead server left behind is the first one a prepare server — running in a data directory of its own — picks up. The global registry still named that port for the dead server's worktree, and both the inbox's open route and the agent CLI's server lookup checked no more than that something answered there: one pull request's page came up serving another's checkout and prepared review, with the first one's bundle imported into it. An entry is now used only when its process is alive and the server on its port reports that repository root; a stale one is dropped from the registry. A freshly spawned server is waited for by its own pid, never by a row another server left for the same worktree. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Bwp5QefjsjMFeq6CK6cT6w
… once fails the open at once A live server that did not answer within two seconds is busy, not gone; its row is kept and it is simply not reused this time. A row is dropped when its process is gone or its port answered for another repository. The spawn wait watches the child's exit instead of polling the registry for the full deadline. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Bwp5QefjsjMFeq6CK6cT6w
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.
Opening NCBackend3#14473 from the inbox showed #13444's code and prepared review, with #14473's comments imported on top.
How.
findAvailablePortconsults only its own data directory's registry. A prepare server runs in a per-PR data directory, so it always tries 5391 first and takes it the moment the reviewer's session there has exited. The global registry still had the dead session's row for that port, and both the inbox'sensureServerand the agent CLI's server lookup (which the bundle import goes through) trusted it after checking only that something answered on the port.Fix.
findServingInstance: an entry is used only when its pid is alive and/api/infoon its port names that repository root; otherwise it is deregistered so nothing else trusts it. The inbox's open route and every agent CLI lookup (await,live-status, session resolution) use it. A freshly spawned session is waited for by its child's own pid rather than by any row for the worktree.Tests: registry unit tests for the alive/impostor/dead cases; the real
ensureServertest seeds a live impostor on a registered port and asserts a fresh server starts and the impostor's row is dropped;resolveAgentSessionrefuses a session from an impostor; the precedence test's stubs now identify their repository like a real server does.Bumps to 0.10.16.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Bwp5QefjsjMFeq6CK6cT6w