Skip to content

fix(swift): keep canvas refresh responses from being dropped in tests - #120106

Merged
vincentkoc merged 1 commit into
mainfrom
fix/websocket-inbound-frame-queue
Aug 7, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/websocket-inbound-frame-queue

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 7, 2026 •

Copy link
Copy Markdown
Member

Related: #120081

What Problem This Solves

Fixes an issue where OpenClawKit websocket tests could lose a response when the gateway delivered two frames before the test actor registered its next receive callback. This surfaced as the canvas surface refresh test timing out after protocol feature publication.

Why This Change Was Made

The fake websocket now preserves inbound results in FIFO order until a receive callback is registered, matching URLSession websocket behavior. The protocol feature responder no longer polls for a callback, and the existing surface-sharing test deterministically emits the protocol feature and surface responses back-to-back.

The change is confined to the OpenClawKit test fixture. Production LOC delta: 0. Test LOC delta: +3 net.

User Impact

No runtime behavior changes. OpenClawKit CI now tests back-to-back gateway responses without dropping frames or relying on timing sleeps.

Evidence

  • Failing provenance: OpenClawKit tests in Actions run 31137514056 timed out the shared canvas surface refresh after about 8 seconds.
  • swift test --package-path apps/shared/OpenClawKit --filter GatewayNodeSessionTests: 82 tests passed.
  • Exact back-to-back surface regression: 10/10 bounded runs passed.
  • Adjacent surface timeout regression passed.
  • Immediate post-negotiation invoke regression passed after removal of callback polling.
  • Blacksmith Testbox changed gate tbx_01kzczcx9hp1dp1782xdv4d6q3: passed with wrapper exit 0 (Actions run 31140036822).
  • Hosted macos-swift, including the exact OpenClawKit tests lane: passed on Actions run 31140104670.
  • git diff --check passed.

@vincentkoc vincentkoc self-assigned this Aug 7, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 7, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@vincentkoc
vincentkoc marked this pull request as ready for review August 7, 2026 02:05
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member Author

ClawSweeper rank-up proof is satisfied on the exact clean merge head.

@clawsweeper clawsweeper Bot added 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 6, 2026, 10:39 PM ET / August 7, 2026, 02:39 UTC.

ClawSweeper review

What this changes

This PR changes the OpenClawKit fake WebSocket so Swift tests retain back-to-back gateway frames until the next receive callback is registered.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this maintainer-owned PR open: the FIFO fixture repair correctly models the production receive gap and current main does not contain it; no blocking patch defect was found.

Priority: P3
Reviewed head: 2a6a8fd48ca6c3e1f2d6d20a7e4b25d80c364a0e
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-backed test-fixture repair with strong reported validation and no identified correctness or security defect.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, test-only PR is exempt from the external-contributor real-behavior gate; its reported focused Swift and hosted macOS results remain useful supplemental evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored, test-only PR is exempt from the external-contributor real-behavior gate; its reported focused Swift and hosted macOS results remain useful supplemental evidence.
Evidence reviewed 5 items Current-main failure mechanism: The production receive loop waits for message handling before registering its next callback, leaving a real interval in which a second frame can arrive; current main's fake transport drops such a frame when no handler is pending.
Fixture repair and regression coverage: The PR atomically queues an inbound result when no receive callback exists, drains one queued result on the next receive, and emits protocol-feature and canvas responses consecutively in the regression scenario.
Current main does not supersede the branch: The PR base is an ancestor of current main, and the intervening main commits do not touch the fixture or its production receive path; the repair remains unique to this branch.
Findings None None.
Security None None.

How this fits together

OpenClawKit gateway-session tests simulate native WebSocket delivery while the gateway client processes protocol-feature and canvas-refresh responses. The fake transport feeds frames into the receive loop, which drives concurrent request completion and canvas assertions.

flowchart LR
A[Gateway test scenario] --> B[Fake WebSocket]
B --> C[Inbound frame queue]
C --> D[Gateway receive loop]
D --> E[Protocol and canvas requests]
E --> F[Canvas refresh assertion]
Loading

Decision needed

Question Recommendation
Should this maintainer-owned fixture repair be merged after the latest ClawSweeper rank-up guidance and an exact-current-main validation are reviewed? Refresh and merge: Review the latest rank-up moves and obtain an exact-current-main green merge result, then merge the test-only repair.

Why: The patch is correct, but the protected maintainer label and a newer main base require an explicit maintainer readiness decision rather than automated cleanup.

Before merge

  • Resolve merge risk (P1) - GitHub reports the clean PR as behind main; review the latest ClawSweeper rank-up moves and refresh the exact merge result before merging.
Agent review details

Security

None.

PR surface

Other +3. Total +3 across 1 file.

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 1 62 59 +3
Total 1 62 59 +3

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests +62/-59 (net +3) The added behavior is confined to the test transport and directly models the existing receive-ordering gap.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the FIFO buffering at the fake transport boundary and merge only after exact-current-main validation confirms the fixture remains clean.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the FIFO buffering at the fake transport boundary and merge only after exact-current-main validation confirms the fixture remains clean.

Do we have a high-confidence way to reproduce the issue?

Yes, in source: the sequential production receive loop and the prior fake transport's no-handler drop create the documented back-to-back-frame loss window; the changed test recreates that ordering.

Is this the best way to solve the issue?

Yes: buffering at the fake transport producer is the narrowest maintainable repair, while retaining polling or sleeps would hide the ordering bug instead of modeling the real receive boundary.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 21e9634f1084.

Labels

Label changes:

  • add P3: This improves deterministic native test reliability without changing runtime behavior or user configuration.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored, test-only PR is exempt from the external-contributor real-behavior gate; its reported focused Swift and hosted macOS results remain useful supplemental evidence.

Label justifications:

  • P3: This improves deterministic native test reliability without changing runtime behavior or user configuration.
  • 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 maintainer-authored, test-only PR is exempt from the external-contributor real-behavior gate; its reported focused Swift and hosted macOS results remain useful supplemental evidence.

Evidence

What I checked:

Likely related people:

  • vincentkoc: Authored the main-history commit introducing this fixture/protocol area and the current repair. (role: recent feature and test-fixture owner; confidence: high; commits: 735f176b0121, 2a6a8fd48ca6; files: apps/shared/OpenClawKit/Tests/OpenClawKitTests/GatewayNodeSessionTests.swift, apps/shared/OpenClawKit/Sources/OpenClawKit/GatewayChannel.swift)
  • Shakker: Recent history includes a nearby GatewayNodeSession test/source contribution, though the ownership trail is secondary to the fixture author. (role: adjacent recent contributor; confidence: medium; commits: e118e607bc68; files: apps/shared/OpenClawKit/Tests/OpenClawKitTests/GatewayNodeSessionTests.swift)

Rank-up moves

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

  • Review the latest ClawSweeper rank-up moves and refresh exact-current-main validation 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.

@vincentkoc

Copy link
Copy Markdown
Member Author

Exact-current-main validation is green without moving the PR head.

  • current origin/main: 0f92db6a5ad55b2cfb46e71ed7da04889a31fc35
  • reviewed PR head: 2a6a8fd48ca6c3e1f2d6d20a7e4b25d80c364a0e
  • local no-commit merge: clean
  • swift test --package-path apps/shared/OpenClawKit --filter GatewayNodeSessionTests: 82/82 passed on the merged tree

This satisfies the latest ClawSweeper rank-up and before-merge request while preserving the signed PR head.

@vincentkoc
vincentkoc merged commit bc5b29a into main Aug 7, 2026
118 checks passed
@vincentkoc
vincentkoc deleted the fix/websocket-inbound-frame-queue branch August 7, 2026 02:44
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit to VACInc/openclaw that referenced this pull request Aug 7, 2026
* origin/main: (58 commits)
  fix(test): restart shared gateway after migration convergence (openclaw#120089)
  fix(ui): make active-run steering reliable (openclaw#120083)
  fix(telegram): preserve voice fallback text
  test(swift): preserve queued websocket frames (openclaw#120106)
  fix: reject missing oxlint shard selectors (openclaw#120096)
  test(channels): align prerelease fallback catalog spec (openclaw#120092)
  fix(node-cli): warn when systemd user lingering is disabled after install (openclaw#118430)
  fix(diagnostics): preserve CLI turn usage totals (openclaw#120100)
  fix(gateway): derive lock and coordinator paths from the resolved state dir (openclaw#120110)
  fix(release): isolate private Telegram QA harness (openclaw#120088)
  test(agents): exercise execution attribution ingress guard
  fix(gateway): defer attribution until admission succeeds
  refactor(agents): centralize exact execution attribution
  fix(google): accept base64url provider media (openclaw#116204)
  fix(plugins): warn when registerHook uses a typed hook event name (openclaw#118601)
  fix(canvas): serve Content-Length on A2UI HEAD responses (openclaw#117961)
  fix(gateway): make doctor dreaming timestamp comparators NaN-safe (openclaw#118749)
  fix(heartbeat): explain target-none skips (openclaw#119689)
  fix(security): stop recommending retired install-policy bypasses (openclaw#120011)
  fix(plugins): preserve startup release during repair (openclaw#120085)
  ...

# Conflicts:
#	CHANGELOG.md
#	src/config/sessions/session-accessor.sqlite-transcript-write.ts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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: S 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