Repository navigation
fix(test): retain Gateway setup owners through authentication - #138037
Conversation
Keep the complete awaited authentication callback inside the shared WebSocket acquisition owner. Roll back newly acquired servers before restoring selectors, preserve setup and cleanup errors independently, and capture the E2E helper config-path mutation. Extend native failure-boundary coverage without changing production runtime or timeout budgets. Builds on #137982 and #137924; fixture lifetime accounting remains with #136146.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 4, 2026, 3:50 AM ET / 07:50 UTC. ClawSweeper reviewWhat this changesGateway test helpers retain sockets through authentication, clean up newly started servers when setup fails, and restore test environment selectors only after successful shutdown. Merge readiness⛔ Blocked before merge - 4 items remain This remains a useful, distinct follow-up to the merged acquisition fixes. No introduced correctness defect was found; direct dependency-contract inspection remains incomplete. Priority: P3 Review scores
Verification
How this fits togetherGateway test fixtures create servers and authenticated WebSocket clients for integration tests. Their acquisition helpers must either return usable resources or finish cleanup before releasing the fixture’s environment. flowchart TD
A[Test fixture] --> B[Open socket]
B --> C[Await authentication]
C --> D[Return acquired resources]
B -->|Failure| E[Join socket cleanup]
C -->|Failure| E
E -->|Borrowed server| H[Report setup and cleanup errors]
E -->|Newly owned server| F[Close server]
F -->|Success| G[Restore test selectors]
G --> H
F -->|Failure| H
Before merge
Agent review detailsSecurityNone. PR surfaceSource +29, Tests +258. Total +287 across 5 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one acquisition owner through authentication and rollback, with dependency-contract verification and applicable owner involvement completed before landing. Do we have a high-confidence way to reproduce the issue? Yes, at source level: authentication rejection after startServerWithClient leaves the acquired server without rollback on current main. The native regression suite targets this boundary; it was not rerun during this read-only review. Is this the best way to solve the issue? The owner-boundary design is appropriate: extending shared acquisition removes duplicate observation and avoids abandoning awaited preparation. Final confirmation remains limited by the unavailable direct ws contract inspection. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0d2169fdabc4. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Land-ready review evidence for The ClawSweeper review found no code/security defect and identified dependency-proof and owner-involvement gaps in its environment. Disposition:
CI recovery: attempt1 security-fast job100949617742 exhausted the existing 240-second budget after four npm bulk request timeouts, returning Additional recovery command, run against the unchanged candidate after bounded backoff: node scripts/pre-commit/pnpm-audit-prod.mjs --audit-level=highScope remains production runtime 0 LOC; test support +89/-74 (net+15); tests +288/-16 (net+272). Fixture lifetime accounting and the |
|
Merged via squash.
|
…aw#138037) Keep the complete awaited authentication callback inside the shared WebSocket acquisition owner. Roll back newly acquired servers before restoring selectors, preserve setup and cleanup errors independently, and capture the E2E helper config-path mutation. Extend native failure-boundary coverage without changing production runtime or timeout budgets. Builds on openclaw#137982 and openclaw#137924; fixture lifetime accounting remains with openclaw#136146.
Related: #137982 (landed raw WebSocket opening ownership) and #137924 (shared acquisition helpers). Fixture registration/accounting remains owned by the separate active lifetime work in #136146; this PR does not modify that checkout, its
ownServerwork, orserver.e2e-ws-harness.ts.Additional instructions
Keep Allow edits from maintainers enabled so maintainers can update this branch.
What Problem This Solves
Resolves a problem where Gateway test setup could return an unauthenticated or failed socket, lose a newly started server when client setup rejected, or restore process selectors while required shutdown had failed. Transport errors during awaited authentication preparation could also be replaced by later preparation errors, and a cleanup failure could hide the original setup failure.
Why This Change Was Made
Keep opening and the complete awaited authentication callback inside the existing WebSocket acquisition owner, with a fresh failure check before authentication and before handoff; this removes the separate shared-auth observer without racing away preparation work. A single private server/client acquisition flow now joins failed setup cleanup before restoring its token selector, while the GatewayClient-based E2E wrapper preserves setup and cleanup errors and restores exactly the selectors it changed only after successful close.
The E2E wrapper now captures its existing
OPENCLAW_CONFIG_PATHmutation as well. This adds no configuration key or production seam. Raw socket close-event joining and GatewayClient's existing bounded shutdown contract remain distinct. All opening, nonce, RPC, and cleanup budgets remain unchanged.User Impact
No production-runtime or user-facing API/configuration change. Test setup failures become deterministic: unreturned resources remain owned through cleanup, the original transport/setup error stays visible, and a failed cleanup does not falsely release the test environment. A failed client on a borrowed server never shuts that server down.
Evidence
The existing native HTTP/WebSocket peer is extended rather than copied into another test file. Coverage includes authenticated rejection, a coalesced hello plus malformed frame, a native error during held preparation, startup failure, construction/open/authentication failure with successful or rejected server cleanup, and returned-server selector ownership.
f113b70b285b223eb3346715d7167f37aa2d4c62, observed 14 intended failures and 13 passing controls. The identical repaired suite passed 27/27 in run_262cd5705693.a550b3f7a1c3611c574f3c073ef2268de74b1a23, passed 29 acquisition cases plus 22 real Gateway caller tests, with no selected cases skipped. The two extra cases are the already-landed raw-opening regressions, preserved during composition.Exact application commands ran only in the credential-free physical VM:
Proof used fresh VMs with no instance role, auth hydration, Tailnet, or shared cache volumes. The canonical bootstrap verified native IMDS returned 404 for IAM credentials and checked the immutable base. Exact hashes of all five changed files were verified; all application state was synthetic and VM-owned. One superseded composed run was stopped during synchronization and is not counted as proof.
LOC: production runtime 0; test support +89/-74 (net +15); tests +288/-16 (net +272). Total +377/-90 (net +287), five files. The small support increase adds missing authentication/composite rollback ownership while deleting duplicated observers. No changelog, dependency, lockfile, schema, or protocol-version changes.