Repository navigation
fix(tests): preserve Gateway reply order in Swift fixtures - #138132
Conversation
Consume each callback once and retain inbound results between receive registrations. Remove the alternate one-shot emitter and the Skills sequence-gap synchronization workaround. Original-source regression fails before the fix; the same regression, 66 signed macOS sibling tests and the isolated iOS lifecycle run pass. Production delta is zero. Source-identical proof retains its original base/toolchain provenance; the overlapping upstream callback counter will be integrated and revalidated separately before publication.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 4, 2026, 7:23 AM ET / 11:23 UTC. ClawSweeper reviewWhat this changesThe PR makes the shared Swift Gateway WebSocket test double queue inbound results in arrival order and updates readiness fixtures to provide selected-profile managed-service ownership evidence. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 3 items remain Keep open. The PR repairs a real shared-test-fixture mismatch: the native Gateway channel re-registers one callback per received result, while current main’s fake retained and reused one callback. The parent-relative patch makes delivery FIFO and aligns named-profile readiness fixtures with the production ownership check; exact-head native CI is still running before merge. Priority: P3 Review scores
Verification
How this fits togethermacOS and iOS tests simulate Gateway request and event traffic through a shared WebSocket test double. Native Gateway clients consume one callback result at a time, while readiness tests combine a listener PID with managed-service status before publishing a healthy Gateway state. flowchart LR
A[Native Gateway tests] --> B[WebSocket test double]
B --> C[One receive callback]
D[Queued inbound replies] --> C
C --> E[Gateway channel handling]
F[Profile readiness fixture] --> G[Managed-service status]
G --> E
Before merge
Agent review detailsSecurityNone. PR surfaceOther +41. Total +41 across 11 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the single FIFO fixture path and profile-accurate readiness setup, then merge once exact-head native CI confirms the focused macOS and iOS suites remain green. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main leaves the callback installed after a result, whereas the Gateway channel processes that result and only then re-registers its next callback. Sequential injected frames can therefore reuse a callback or be lost before re-registration; the added regression directly exercises that order. Is this the best way to solve the issue? Yes. The shared WebSocket fake owns receive callback registration and inbound buffering, so centralizing FIFO delivery there removes per-test synchronization workarounds without changing production behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0019dd424bd5. LabelsLabel 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
HistoryReview history (1 earlier review cycle)
|
Supply matching managed-service PID and selected port through the existing isolated launch-agent fixture. Preserve readiness retries, PID transitions, control-channel refresh behavior and exact default/named daemon calls. Remove one adjacent redundant return caught by SwiftFormat. Signed macOS proof: 139 invocations across 80 distinct definitions; named readiness, ownership siblings and isolated default-profile controls. Production LOC is unchanged; test delta is +16 lines.
|
The Foundation contract evidence is now checked directly for this head. Apple’s receive API describes one complete-message result. I also inspected the installed Darwin Foundation header and Swift overlay: the async receive implementation resumes one throwing continuation from one callback. This matches GatewayChannel’s receive loop, which handles a result before registering its next receive. That closes the direct public-contract evidence gap from the restricted review; it does not claim Foundation’s internal terminal-error ordering or a live socket-peer test. The existing signed native fixture runs remain the execution evidence. Named-profile readiness is separately governed by OpenClaw’s unchanged listener/service PID ownership check. Exact-head native CI and the repository’s prepare/merge gates remain required before landing. |
|
Merged via squash.
|
Integrate main's canonical FIFO repair from #138132 instead of retaining a competing one-shot emitter. Reject callback receives and late inbound frames after cancellation or completion, with the existing regression in the CI-selected iOS lifecycle suite. The exact current-main native reproduction completed with three controls passing and the cancellation case failing. The same four cases pass after the four-line test-support repair. All 12 changed-path checks and an independent Codex review pass. Production behavior and timeouts are unchanged.
…138132) * test: preserve FIFO WebSocket fixture delivery Consume each callback once and retain inbound results between receive registrations. Remove the alternate one-shot emitter and the Skills sequence-gap synchronization workaround. Original-source regression fails before the fix; the same regression, 66 signed macOS sibling tests and the isolated iOS lifecycle run pass. Production delta is zero. Source-identical proof retains its original base/toolchain provenance; the overlapping upstream callback counter will be integrated and revalidated separately before publication. * fix(tests): bind gateway readiness fixtures to profile owner Supply matching managed-service PID and selected port through the existing isolated launch-agent fixture. Preserve readiness retries, PID transitions, control-channel refresh behavior and exact default/named daemon calls. Remove one adjacent redundant return caught by SwiftFormat. Signed macOS proof: 139 invocations across 80 distinct definitions; named readiness, ownership siblings and isolated default-profile controls. Production LOC is unchanged; test delta is +16 lines.
Related: #137734
What Problem This Solves
Resolves a problem where Swift Gateway tests could deliver multiple inbound results to one receive callback, or lose replies arriving before the next callback was registered. This made reconnect/readback and adjacent request or Skills tests report failures unrelated to the channel’s intended receive order.
Validation also exposed five positive readiness fixtures that omitted the managed-service ownership evidence required by a named app profile. Their simulated healthy listener could therefore be correctly rejected before readiness publication.
Why This Change Was Made
The shared WebSocket test double now consumes each callback once and queues later success/failure results in arrival order. All callers use the same emitter; the alternate one-shot emitter and Skills-specific polling/ordering workaround are removed. The upstream callback-registration counter remains intact.
The five readiness fixtures use the existing isolated launch-agent fixture to supply the selected port and matching service PID. They preserve health ordering, retry counts, PID transitions, control-channel refresh behavior, and original deadlines. The other-owners fixture explicitly expects no daemon calls for the default profile or exactly one read-only status call for a named profile. Explicit no-service/default-only siblings retain their existing semantics. One adjacent redundant
returnidentified by SwiftFormat is removed; no production seam or profile bypass is added.User Impact
No direct user-facing behavior change. This repairs test infrastructure used by macOS Gateway and iOS Watch/readback tests; it does not establish that the earlier hosted reconnect failure had only this cause. No production, protocol, configuration, timeout, dependency, or CI-policy changes.
Production LOC: 0. Tests/support: +231/−190, net +41 across 11 files (original FIFO repair +25; readiness/format cleanup +16).
Evidence
Current source: 7e0318fad05be34f69988608120e2b2489a722f4. The committed source matches the signed native proof; required CI on this new head is pending. This PR is not yet landed.
Red/green: The FIFO regression delivers two messages and a connection failure with only the first receive registered: callback ordinals change from
1/1/1to1/2/3, with exactly three registrations. The earlier macOS run retained its real 69/70 outcome: the transient-readiness case failed under a named profile. Four additional unchanged readiness definitions then reproduced four failures / fourteen issues, each with the ownership rejection. All five now pass with both named and isolated default profiles; assertions and deadlines were not relaxed.Fresh signed macOS proof: One clean build and Foundation-signed test product passed all selections, with zero failures or skips:
That is 139 invocations, 85 definition executions, 80 distinct definitions. Exact names and parameterized case starts were checked against raw output. Default controls ran in a separate private HOME/state with the profile variable absent, not against operator defaults. The complete phase finished in 607.73 seconds within its existing 2700-second budget. Source/index, dependency and preserved-product checks passed; temporary state was removed, with no forced signals or surviving owned processes.
Review: The incremental readiness/format diff received four managed source-review passes with no accepted P0–P2 findings, collectively using 51 complete context files. Individual batches had limited visibility—passes 1 and 4 explicitly lacked context supplied elsewhere—so this is not a claim that every pass saw the entire owner/helper surface. Complete fixture, owner and isolation code was also inspected locally. These reviews preceded native completion and are not themselves test or CI proof. The historical R4 nine-pass review of the original ten-file FIFO candidate and its 53 context files remains separate; those ten candidate files are unchanged.
Historical iOS proof: The original integrated FIFO candidate passed 250 definitions / 287 invocations, zero skips or failures, in a Foundation-signed Xcode 27/iOS 27 Simulator run. It covered the complete
NodeAppModelInvokeTestssuite, bothTalkRealtimeConsultCancellationTests, all five targeted Watch definitions and both reconnect variants. The 246.45-second phase stayed within its original 600-second budget, with exact identifier/count checks and normal simulator/process cleanup. This is not physical Watch or hosted-toolchain parity; it was not rerun for the subsequent mac-only fixture edit.Earlier failed enumeration, forced-cleanup and lint attempts remain failed and preserved; their artifact-only harness corrections are not product changes. Strict audit policy is unchanged. The iOS audio-session main-thread warnings remain a named follow-up: a passing simulator suite does not prove they are harmless or establish user-visible impact.