Repository navigation
refactor(gateway): make fixture teardown wait for owned work - #157114
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. What this changesThis PR makes Gateway test fixtures join pending policy and WebSocket acquisition work before resetting shared state. Example: A Gateway harness connection receives HTTP 403 during WebSocket upgrade.
Review scores
ProductKind: Test only · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR contains useful fixture-lifetime repairs that current main still lacks. No actionable introduced defect was found; exact-head CI remains pending. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway test fixtures create clients, temporary state, and held policy operations; their lifetime helpers coordinate completion and cleanup before shared observers and registries reset. flowchart TD
A[Test scenario] --> B[Existing fixture lifetime]
B --> C[Policy or WebSocket acquisition]
C --> D[Result or cancellation]
D --> E[Release held gates]
E --> F[Join operations and socket closure]
F --> G[Restore state and reset observers]
Technical reviewBest possible solution: Use the existing acquisition and fixture-lifetime owners to drain held work before resetting Gateway test state. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the open-event-only failure path and the premature policy-state reset boundary; supplied validation reports exercise the correction, but this read-only review ran no tests. Is this the best way to solve the issue? The narrowed patch addresses the owning boundaries with existing helpers, removes the replaced acquisition paths, and preserves distinct transport and authority assertions without adding production machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 887a8a1108ea. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -4, Tests +391, Other +1. Total +388 across 6 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed November 5, 2026, 5:54 AM ET / 10:54 UTC (Revision 3). |
Baseline-Refresh: 8f326929873324ed4b01d0f49f7b4641f9babb59
Use canonical WebSocket acquisition and join held policy work before fixture teardown. Cover native transport errors, adapter forwarding, and failure cleanup with real owned peers. Allocate exactly 390 counted test lines; the shared scalar remains unchanged.
|
ClawSweeper reviews are opt-in for maintainers. If a review is required, finish the work and validation first, then comment |
|
@clawsweeper re-review Please review exact head |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…w#157114) * refactor(gateway): own asynchronous test fixture cleanup * refactor(gateway): verify prepared auth fence forwarding * refactor(gateway): assert successful hybrid config patches * refactor(gateway): exercise cron delivery validation * refactor(gateway): use canonical agent mutation fixtures * test(gateway): join acquisition and policy fixture lifetimes Use canonical WebSocket acquisition and join held policy work before fixture teardown. Cover native transport errors, adapter forwarding, and failure cleanup with real owned peers. Allocate exactly 390 counted test lines; the shared scalar remains unchanged. * test(gateway): fix acquisition fixture static checks
What Problem This Solves
Gateway fixtures could reset shared state while policy work or a failed WebSocket acquisition was still running. Some race checks observed a precreated resolver rather than entry into the policy recheck.
User Impact
No production behavior, configuration, migration, or user action changes. This improves the reliability of Gateway tests and their cleanup failures.
Why This Change Was Made
The auth openers and E2E harness now use the existing WebSocket acquisition helper, preserving headers, challenge nonces, connect options, and the actual hello response. Policy and acquisition scenarios release gates and join their owned work before reset. Callback errors still reach the state owner; the isolated rejected-close proof remains intact.
This replaces the original broad rewrite with five existing test/support files. Config, cron, client, agents, ControlUI, and other lifecycle work remain separate, unqualified follow-ups. Named follow-up: preserve callback-error propagation in the excluded
control-ui-session-prs-staleness.test.tsandcontrol-ui.response-authority.test.tswrappers.The final change adds 387 private source lines and no production lines. The native test counter counts +391 because the harness reduction is outside its filename patterns. An exact 391-line allocation covers the acquisition/error/cancellation coverage; the shared scalar baseline is unchanged.
Evidence
5bf55183, Node 26.12.1 passed all 33 acquisition cases. Targeted Oxlint and all four selected Gateway test-type graphs passed.4131c8e9: 42 Node policy/receipt/session/harness cases and 17 pinned-Bun lifetime/cleanup helper cases passed. These are prior-head executions, giving 92 selected cases across both heads. Native processes joined normally; JSON/JUnit identities match where both reporters were used.4131c8e9. Its full line-budget check passed with 39 lines of headroom; the final +1 source/+1 allocation adjustment preserves that headroom arithmetically, without claiming another full counter run.Unresolved local failure: the original Bun Gateway run failed during startup error reporting with
TypeError: code.charCodeAt is not a functionand produced no Gateway case results. Installed Vitest/Vite source explains the reporter failure, but the masked startup cause remains unknown. The passing Node runs do not establish a Bun fix or an inherited failure. This remains recorded as an investigated failure, not green proof.Exact-head hosted CI passed: 37 successful jobs, 29 skipped, none failed or pending. Selected guard, lint, type, test, and PostgreSQL conformance jobs passed. This does not claim a separate full execution of the three broad deadcode commands. The exact-head ClawSweeper review found no actionable findings and no before-merge blocker. Named rank-up follow-up: add a real Vitest timeout control. It is deferred because a runner-level timeout fixture is beyond this correction; current cancellation/join evidence does not constitute direct real-Vitest timeout integration. The queued remote attempt executed no tests; focused local proof was on Darwin, and no live product behavior was exercised. Final merge approval remains with Vincent.