Skip to content

test(gateway): wait for stream diagnostics before ending each fixture - #143133

Merged
steipete merged 1 commit into
mainfrom
codex/node-stream-fixture-current
Sep 9, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/node-stream-fixture-current

Conversation

@steipete

@steipete steipete commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Related: #142242, #134931

What Problem This Solves

Fixes a desktop stream test fixture that can attribute a previous connection's close diagnostic to the next test. This blocked CI for the separately reviewed workspace-manifest compression fix in #142242: the actual cancelled client closed with 1008, but the next test captured an earlier connection's 1006 diagnostic.

Why This Change Was Made

HTTP server shutdown does not wait for upgraded sockets, and client termination returns before the server observes closure. The fixture now records each upgraded socket's close promise before broker handoff and joins those promises during cleanup, before diagnostic capture is flushed and reset.

User Impact

No production behavior changes. Existing stream cancellation, idle connection, backpressure and diagnostic assertions remain unchanged; this makes their execution order reliable.

Evidence

A real loopback probe in the original test order, without scheduler mocks or inserted delays, reproduced previous-connection diagnostic leakage in 25/25 runs with the old cleanup and 0/25 with this fix. Current-connection close codes remained 1008. The complete existing test file passes all 19 cases. Full changed checks and independent P2 review pass with no findings, including review of the installed WebSocket receiver completion order.

This is a one-file fixture repair required to validate #142242, split from that production PR. The PR does not increase timeouts, relax assertions, suppress diagnostics or change runtime code.

@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 9, 2026 13:43
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS maintainer Maintainer-authored PR labels Sep 9, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 9, 2026
@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 9, 2026, 9:49 AM ET / 13:49 UTC.

ClawSweeper review

What this changes

The desktop-stream test fixture waits for upgraded sockets to close before flushing and resetting diagnostic capture, preventing records from leaking into subsequent tests.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fixture repair: current main retains the cleanup race, and no introduced correctness defect was found. The related compression PR depends on reliable validation, rather than superseding this work.

Priority: P2
Reviewed head: 848625ecdc35c9a3995a38ad1734479fd4e702e0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow lifecycle repair with unchanged assertions, relevant reported validation, and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies maintainer-authored work, so the external-contributor proof gate does not apply. The body additionally reports ordered real-loopback broker validation reducing leaked diagnostics from 25/25 to 0/25; those results were not independently rerun.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies maintainer-authored work, so the external-contributor proof gate does not apply. The body additionally reports ordered real-loopback broker validation reducing leaked diagnostics from 25/25 to 0/25; those results were not independently rerun.
Evidence reviewed 9 items Verified introduced change: The pinned merge-base-to-head diff changes only fixture teardown: socket close listeners are registered before broker handoff, and cleanup awaits those promises. Existing assertions and production code remain unchanged.
Cleanup and diagnostic ownership: The complete test file runs client termination and server cleanup concurrently, then flushes diagnostics before unsubscribing capture. The production broker emits its diagnostic from the WebSocket close handler; capture flushing drains queued records but cannot await a future socket event.
Current main still needs the repair: The fetched main revision still waits only for HTTP server.close, without joining upgraded sockets.
Findings None None.
Security None None.

How this fits together

The Gateway stream broker connects authenticated node desktop and portal streams over WebSockets. Its test fixture owns loopback connections and diagnostic capture, so teardown must finish before the next test begins.

flowchart TD
  A[Loopback test client] --> B[HTTP upgrade fixture]
  B --> C[Desktop and portal stream broker]
  B --> D[Track socket closure]
  C --> E[Stream close diagnostics]
  D --> F[Await fixture cleanup]
  E --> G[Flush diagnostic capture]
  F --> G
  G --> H[Reset for next test]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +7. Total +7 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 13 6 +7
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 13 6 +7

Review metrics

None.

Technical review

Best possible solution:

Keep fixture teardown responsible for completing socket lifecycles before diagnostic capture resets, preserving the existing runtime and assertions.

Do we have a high-confidence way to reproduce the issue?

Yes: current-main teardown can finish before upgraded sockets emit close diagnostics, and the supplied ordered loopback comparison reports that exact failure. This read-only review did not execute the reproduction.

Is this the best way to solve the issue?

Yes: joining the fixture-owned sockets repairs the lifecycle boundary without delays, broader mocks, relaxed assertions, or production changes.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2c191557f381.

Labels

Label justifications:

  • P2: A bounded fixture race undermines diagnostic assertions and validation of related work, without changing production behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies maintainer-authored work, so the external-contributor proof gate does not apply. The body additionally reports ordered real-loopback broker validation reducing leaked diagnostics from 25/25 to 0/25; those results were not independently rerun.

Evidence

What I checked:

  • Verified introduced change: The pinned merge-base-to-head diff changes only fixture teardown: socket close listeners are registered before broker handoff, and cleanup awaits those promises. Existing assertions and production code remain unchanged. (src/gateway/desktop/node-stream-broker.test.ts:50, 848625ecdc35)
  • Cleanup and diagnostic ownership: The complete test file runs client termination and server cleanup concurrently, then flushes diagnostics before unsubscribing capture. The production broker emits its diagnostic from the WebSocket close handler; capture flushing drains queued records but cannot await a future socket event. (src/gateway/desktop/node-stream-broker.test.ts:20, 848625ecdc35)
  • Current main still needs the repair: The fetched main revision still waits only for HTTP server.close, without joining upgraded sockets. (src/gateway/desktop/node-stream-broker.test.ts:60, 2c191557f381)
  • Latest release check: The supplied latest release, v2026.9.3, also contains the old HTTP-only cleanup. (src/gateway/desktop/node-stream-broker.test.ts:60, 1391f7cd2d40)
  • Dependency contract signal: The fixture imports ws and exercises the real broker, whose WebSocketServer enables neither compression nor deferred message delivery. package.json pins ws 8.21.3, making its receiver-close ordering relevant; no Codex contract is involved. (src/gateway/desktop/node-stream-broker.ts:162, 848625ecdc35)
  • WebSocket close ordering: Inspected ws 8.21.3 socketOnClose, receiver completion, and server defaults. The server defaults to synchronous events with compression disabled, supporting the fixture's close barrier for these cases. Package metadata verifies websockets/ws ownership; its tag resolves to the recorded SHA. (lib/websocket.js:1317, c791e707eab3)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit e137077 into main Sep 9, 2026
169 checks passed
@steipete
steipete deleted the codex/node-stream-fixture-current branch September 9, 2026 13:58
@steipete

steipete commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant