Skip to content

fix: a registered server is trusted only once it has said which repository it serves - #89

Merged
fiddur merged 2 commits into
developfrom
inbox-open-identity
Sep 3, 2026
Merged

fix: a registered server is trusted only once it has said which repository it serves#89
fiddur merged 2 commits into
developfrom
inbox-open-identity

Conversation

@fiddur

@fiddur fiddur commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Opening NCBackend3#14473 from the inbox showed #13444's code and prepared review, with #14473's comments imported on top.

How. findAvailablePort consults 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's ensureServer and 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/info on 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 ensureServer test seeds a live impostor on a registered port and asserts a fresh server starts and the impostor's row is dropped; resolveAgentSession refuses 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

fiddur and others added 2 commits September 3, 2026 15:27
…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
@fiddur
fiddur marked this pull request as ready for review September 3, 2026 13:32
@fiddur
fiddur merged commit 6564745 into develop Sep 3, 2026
2 checks passed
@fiddur
fiddur deleted the inbox-open-identity branch September 3, 2026 13:32
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.

1 participant