Repository navigation
test(gateway): await node-session owners and retire the wall-clock waitUntil - #166386
Conversation
Replace the 83 waitUntil polls in the gateway node-session and native device-auth tests with fake arrival continuations, existing gates, and owner completion. A DEBUG-only receipt-join waiter in GatewayNodeSession lets the in-flight receipt test await the join instead of polling.
Run listener and connection callbacks on one private serial queue. Synchronize fixture reads and teardown while preserving the test-facing API. Keep WebSocket frames and device-auth outcomes unchanged under executor load.
|
🦞👀 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, 10:14 PM ET / October 7, 2026, 02:14 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR replaces native Gateway test polling with completion signals, moves WebSocket fixture callbacks to a private serial queue, and removes the unused polling helper. Merge readiness✅ Ready for maintainer review This PR remains useful: current main retains the affected polling helper and MainActor-bound fixture. The reviewed patch has no blocking findings, and the recorded saturation evidence supports the reliability fixes. Priority: P2 Review scores
Verification
How this fits togetherOpenClawKit connects native Apple clients to the Gateway through WebSockets. Its tests exercise connection, authentication, reconnect, and invocation behavior using scripted sockets and a local native WebSocket fixture. flowchart TD
A[Native Gateway tests] --> B[Node session owner]
B --> C[Scripted socket signals]
A --> D[Real URLSession client]
D --> E[Local WebSocket fixture]
E --> F[Private serial queue]
C --> G[Completion and behavior assertions]
F --> G
Before mergeNone. Agent review detailsSecurityNone. PR surfaceOther -34. Total -34 across 6 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep native fixture progress independent of MainActor load and synchronize test assertions with the owners that produce their results. Do we have a high-confidence way to reproduce the issue? Yes: the recorded MainActor and cooperative-pool saturation scenarios establish focused reproduction paths, and current-main source retains the corresponding mechanisms. This read-only review did not execute them. Is this the best way to solve the issue? Yes: owner signals and a single fixture queue address the synchronization failures directly while preserving behavior assertions and the existing transport deadlines. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against feab6b02ff4f. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
…itUntil (openclaw#166386) * test(gateway): await node-session owners instead of wall-clock polls Replace the 83 waitUntil polls in the gateway node-session and native device-auth tests with fake arrival continuations, existing gates, and owner completion. A DEBUG-only receipt-join waiter in GatewayNodeSession lets the in-flight receipt test await the join instead of polling. * test(gateway): handle native fixture connections off the MainActor Run listener and connection callbacks on one private serial queue. Synchronize fixture reads and teardown while preserving the test-facing API. Keep WebSocket frames and device-auth outcomes unchanged under executor load. * test(openclawkit): delete the wall-clock waitUntil helper * test(gateway): fix receipt waiter comment lint
What Problem This Solves
Fixes: the native device-auth tests fail during connection when the MainActor is backed up, as it is when
macos-swift (packages)runs the full OpenClawKit package in parallel. A gateway node-session test can also deadlock a constrained cooperative pool. This PR also removes the last 15 s wall-clock waits in OpenClawKit.User Impact
No user-visible change. These were the last OpenClawKit callers of the 15 s wall-clock
waitUntil, so this PR also deletes the helper.Why This Change Was Made
This finishes the series from #165157, #165170, #165171, #165172, #165178, #165187, and #166373.
GatewayNodeSessionactor. A DEBUG-onlywaitForComputerReceiptJoinsForTestingresumes where that counter increments. The maintainer approved this as an exception to production line-count neutrality; release builds are unchanged.NativeGatewayWebSocketFixturehandled every accepted connection on.mainunderMainActor.assumeIsolated. Under a MainActor backlog, the handshake waited until the client's unchanged 6 s connect deadline expired, so all five device-auth tests failed during connection. The listener had already moved off main for the same reason. Connections and fixture state now live on one private serial queue, and test-facing reads synchronize with it.waitUntilremoved. With no callers left, the helper and its own tests are deleted.waitForObservedStateremains as the shared Observation-driven fallback.After awaiting an owner, each test asserts the condition the old poll checked. No timeouts were lengthened and no retries were added.
Evidence
Deterministic saturation probes (temporary, uncommitted), each held 420 s in the same
swift test --package-path apps/shared/OpenClawKit --skip-build --disable-sandbox --filter '<suites>|<probe>'process, with a private HOME, CFFIXED_USER_HOME, OPENCLAW_STATE_DIR, and TMPDIR:LIBDISPATCH_COOPERATIVE_POOL_STRICT=1, 1,000 high-priority 20 ms spin-yield tasks, so each enqueued pool job waits about 20 s).disconnect during channel shutdown prevents stale channel installblocked the only pool thread inside a synchronousNSConditiongate, so neither the other tests nor the flood could run. This PR replaces that gate with the existing async shutdown gate.waitUntilre-checks once after its deadline. The gateway wait conversions are therefore preventive, removing the deadline class, rather than fixes for a reproduced timeout.✔ Test run with 98 tests in 4 suites passed after 420.005 seconds., with no test skipped.✔ Test run with 6 tests in 2 suites passed after 420.592 seconds..Flake-fix proof bar (writing tests, Flake triage step 4), on this head:
Gateway(303 tests in 30 suites), plus everyChatViewModel*andNativeConversation*suite after the helper deletion.✔ Test run with 303 tests in 30 suites passed after 30.518 seconds.(plus 2 XCTest tests, zero failures);✔ Test run with 1702 tests in 126 suites passed after 5.595 seconds.(plus 18 XCTest tests, zero failures).macos-swift; the full-packagemacos-swift (packages)shard runs in hourly main CI, which covers this change after merge (maintainer decision, same as the earlier series).auth. I declined it, because the fake recordsparams["auth"] ?? [:]for every connect frame, so the wait is already outcome-independent.Checks.
git diff --checkis clean, and SwiftFormat lint is clean on every changed line. I did not run the full OpenClawKit suite locally, because its keychain fixtures reach the login keychain on this Mac.Related: #165157, #165187, #166373