Repository navigation
fix: drain bridge replies before reporting disconnects - #9
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 3:32 PM ET / 19:32 UTC (Revision 18). ClawSweeper reviewWhat this changesClawgo drains buffered bridge replies and events before reporting disconnects, with regression tests and documentation for handshake ordering and reader shutdown. Merge readiness✅ Ready for maintainer review This PR remains useful: current main still permits EOF to win over buffered handshake replies. The pinned patch resolves that ordering defect, has convincing production TCP proof, and has no actionable review findings. Priority: P2 Review scores
Verification
How this fits togetherClawgo is a headless node client that receives handshake replies and events from a gateway bridge over TCP. Its bridge reader feeds pairing, connection setup, and the connected event loop. flowchart TD
A[Gateway TCP frames] --> B[Bridge reader]
B --> C[Buffered frame stream]
C --> D[Pairing and hello waits]
C --> E[Connected event loop]
B --> F[Stream closes after final frame]
F --> G[Report disconnect and reconnect]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Preserve one ordered bridge frame stream whose terminal error becomes observable only after buffered replies and events are consumed. Do we have a high-confidence way to reproduce the issue? Yes: the main source permits EOF to beat a buffered reply, and the posted real-CLI TCP transcript demonstrates that failure at the exact main SHA. This reviewer did not execute the reproduction. Is this the best way to solve the issue? Yes: publishing the terminal error through stream closure removes the competing notification path while preserving cancellation, deadlines, and read-error reporting. AGENTS.md: not found in the target repository. Codex review notes: model internal, reasoning medium; reviewed against 9d0188637d96. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (17 earlier review cycles; latest 8 shown)
|
55aa826 to
b286a2b
Compare
|
@clawsweeper re-review Production saturation proof is now a live First server close fills the buffer-1 Tip is |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Publish the reader error through frame-stream closure so EOF cannot win a select against pending pair-ok, hello-ok, or event frames. Closing the stream also avoids needing a separate blocking error send after consumer shutdown. Replace the artificial saturated-client tests with one-reader pipe regressions for reply ordering, EOF, read errors, and departed consumers. Co-authored-by: Sebastien Tardif <sebtardif@ncf.ca>
b286a2b to
ed3f5dc
Compare
Add -tts-system-timeout to bound one hung speech command so the queue can continue. The default remains 0, preserving unlimited healthy playback; shutdown cancellation and the espeak option separator remain intact. The baseline regression failed after the child ran to completion, while the opt-in deadline passed. Linux module verification, tests, race tests, build, and deadcode passed again after integrating #9. Independent Codex review found no actionable P0–P2 issues, and exact-head CI passed at ae8b6d7. Co-authored-by: Sebastien Tardif <sebtardif@ncf.ca>
A bridge can send
pair-okorhello-okimmediately before closing its socket. The reader previously published frames and EOF to separate channels, so a consumer could select EOF first and lose the successful reply. A realnet.Piperegression fails on main for both handshakes.Use frame-stream closure to publish the terminal read error after all buffered frames. Pairing, hello, and the connected-node loop now drain frames before observing disconnect. This also removes the separate terminal error send raised by this PR; a departed consumer cannot strand the reader on that send. The previous saturated-error tests reused one client for two reader loops, which production never does. The replacement tests exercise the actual one-reader lifecycle, EOF, non-EOF read errors, and shutdown with a full frame buffer.
Thanks @SebTardif for the original reader-shutdown work. Contributor credit is retained in the commit.
Validation:
go test ./cmd/clawgo -run "TestBridgeHandshakeBeforeEOF|TestBridgeReaderStopsWithoutConsumer" -count=1 -v: both handshake cases fail with unexpected EOF; ordinary abandoned-consumer shutdown already passes.go mod download,go test ./...,go test -race ./...,go build ./cmd/clawgo, anddeadcode -test ./...with v0.49.0 produced no findings.The first remote attempt stopped before testing because Go was absent from the bare image; the rerun installed the official checksum-verified Go 1.27.0 archive and passed all gates. No live gateway or speech hardware was required for this transport-level regression.
Production TCP proof (September 29, 2026)
Built the unmodified CLI at main
9d0188637d966f3c50b2977e2bce44fbf42835dband PR headed3f5dc64ccbb779d96d2fb674c40ba2a6a26650on Linux amd64 / Go 1.27.1. A Python loopback TCP peer received the realpair-requestorhello, paused the CLI with SIGSTOP, sent a harmless event followed by the successful handshake reply and FIN, then resumed it with SIGCONT. Each connection had one production reader. The harmless event exposes the buffered-reply/EOF selection window after it is handled; a direct single-reply probe did not reproduce that timing window. Each binary was run withGOMAXPROCS=1for 64 fresh connections per case.For pairing, the probe asserted successful CLI exit and that the synthetic token was saved. For hello, the peer also sent a named synthetic event immediately after
hello-ok; the probe asserted that the CLI processed that event before logging EOF and exited cleanly on SIGTERM. All state and frames were synthetic.The PR head also passed
go mod verify,go test ./...,go test -race ./...,go build ./cmd/clawgo, anddeadcode -test ./...using the CI-pinned v0.49.0. Exact-head CI is green. No gateway deployment or speech hardware was used.