Skip to content

fix(tests): preserve Gateway reply order in Swift fixtures - #138132

Merged
steipete merged 3 commits into
mainfrom
codex/stable-review-watch-fixture-20260903
Sep 4, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/stable-review-watch-fixture-20260903

Conversation

@steipete

@steipete steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

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 return identified 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/1 to 1/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:

Selection Definitions Invocations Suites
Named-profile FIFO/readiness and siblings 74 117 11
Named-profile ownership guards 5 16 3
Isolated default-profile controls, including restart ordering 6 6 1

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 NodeAppModelInvokeTests suite, both TalkRealtimeConsultCancellationTests, 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.

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.
@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added app: ios App: ios app: macos App: macos size: S maintainer Maintainer-authored PR labels Sep 4, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 4, 2026, 7:23 AM ET / 11:23 UTC.

ClawSweeper review

What this changes

The 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 provenance

Possible 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
Reviewed head: 7e0318fad05be34f69988608120e2b2489a722f4

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-aligned native test repair with a direct regression and substantial supplied platform validation; exact-head CI remains the remaining merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored, test-only PR is outside the external-contributor proof gate; its supplied signed native runs are supplemental validation for the fixture and readiness contracts.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored, test-only PR is outside the external-contributor proof gate; its supplied signed native runs are supplemental validation for the fixture and readiness contracts.
Evidence reviewed 6 items FIFO fixture owner: The changed test double consumes and clears the registered callback before invoking it; frames arriving while no callback is registered are retained in an ordered queue and consumed by the next registration.
Production caller contract: The shared Gateway channel registers one callback, handles its result asynchronously, then registers the next callback; this makes per-callback FIFO delivery the appropriate test-double boundary.
Profile ownership contract: For a named profile, production readiness rejects a listener unless its PID matches the managed service PID; the changed fixtures now supply matching port and PID status before asserting readiness.
Findings None None.
Security None None.

How this fits together

macOS 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
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head iOS and macOS native jobs were still queued or running in the supplied snapshot, so merge should wait for their result.
  • Resolve merge risk (P1) - The changed fake models Foundation WebSocket callback behavior; direct upstream Foundation contract inspection was unavailable after the review environment could not resolve the source network, so the supplied signed native runs remain the available platform evidence.
  • Complete next step (P2) - Let the exact-head native iOS and macOS jobs complete green; reconcile any required failure with the FIFO and profile-readiness fixture contracts before merge.
Agent review details

Security

None.

PR surface

Other +41. Total +41 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 11 231 190 +41
Total 11 231 190 +41

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/−0; tests/test support +231/−190 (net +41) Every touched path is native test code or test support, so the PR does not add runtime, configuration, protocol, or persistence surface.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    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.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best 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.

Labels

Label justifications:

  • P3: This is a focused native test-infrastructure repair with no direct user-visible behavior change.
  • 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: This MEMBER-authored, test-only PR is outside the external-contributor proof gate; its supplied signed native runs are supplemental validation for the fixture and readiness contracts.

Evidence

What I checked:

Likely related people:

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

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the exact-head iOS and macOS jobs complete green before merge.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-04T09:40:33.100Z sha f68dcb8 :: needs maintainer review before merge. :: none

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.
@steipete steipete self-assigned this Sep 4, 2026
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

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.

@steipete
steipete merged commit f6ee7e8 into main Sep 4, 2026
101 of 107 checks passed
@steipete
steipete deleted the codex/stable-review-watch-fixture-20260903 branch September 4, 2026 12:34
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 4, 2026
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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: ios App: ios app: macos App: macos maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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