Skip to content

fix(proof): never take the socket from a busy read server - #287

Draft
tonyketcham wants to merge 1 commit into
claude/agent-memory-context-potency-6sniud-find-runsfrom
claude/agent-memory-context-potency-6sniud-serve-busy
Draft

tonyketcham wants to merge 1 commit into
claude/agent-memory-context-potency-6sniud-find-runsfrom
claude/agent-memory-context-potency-6sniud-serve-busy

Conversation

@tonyketcham

Copy link
Copy Markdown
Collaborator

Summary of changes

This is layer 7 of a stack. It sits on #286.

proof serve keeps a Proof graph in memory and answers reads on a Unix socket. Before it starts, it probes the socket, and it takes the socket over if nothing answers. The probe gave up after two seconds. But a server building a large graph, such as the benchmark's 10x graph with 4,980 records, blocks for six to nine seconds. During that build, a second server read the silence as a dead socket, took it over, and left the first server running but unreachable.

This turned up during two benchmark runs started 20 seconds apart. The second run's server was refused only because the first had just finished building.

The fix rests on one difference. A dead socket refuses the connection at once. A busy server accepts it and replies late. So the probe in packages/flatbread/src/cli/serve.ts now counts a timeout as a live server.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • I added doc comments to any new public exports, and inline comments to any hard-to-understand areas
  • My changes generate no new console errors locally
  • If applicable, try to include a test that fails without this PR but passes with it. The new test in serve.test.ts holds a socket with a server that accepts connections but never replies, and checks that serveProofReads refuses to take it. It fails against the old probe. All 4 serve tests pass, and so does pnpm typecheck.

Does this introduce any non-backwards compatible changes?

  • Yes
  • No

Does this include any user config changes?

  • Yes
    • If so, I have updated the relevant areas of documentation
  • No

Generated by Claude Code

`proof serve` probes its socket before it starts, and takes the socket
over when nothing answers. The probe gave up after two seconds. But a
server building a large graph, such as the benchmark's 10x graph,
blocks for six to nine seconds, so a second server took its socket and
left the first one running and unreachable.

A dead socket refuses the connection at once, while a busy server
accepts it and replies late. The probe now counts a timeout as a live
server. A new test holds a socket with a server that never replies, and
checks that `serveProofReads` refuses it. The test fails without the
fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DVVnhYL1Bz7mCfEKDoyLMW
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.

2 participants