Skip to content

fix(talk): isolate cancellation ownership contract - #127186

Merged
vincentkoc merged 9 commits into
mainfrom
stack/realtime-cancel-contract-l6a
Aug 23, 2026
Merged

vincentkoc merged 9 commits into
mainfrom
stack/realtime-cancel-contract-l6a

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 21, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Delayed or stale realtime Talk cancellation RPCs could cancel a replacement turn, while Web and Android clients accepted unvalidated results and could release delayed work at the wrong ownership boundary. Large provider audio callbacks also needed a canonical browser-event framing boundary.

Later exact-head review exposed connected owner failures:

  • provider response.created required a pre-existing Talk turn, so pre-audio and supported ID-less xAI responses failed visibly;
  • turn-bound cancellation treated tool-result drain completion as provider confirmation and closed the relay before queued replacement audio;
  • forced-consult cancellation drained only the native calls visible in one snapshot, allowing later async waves to escape terminal ownership;
  • the legacy iOS relay ignored malformed, rejected, mismatched, or failed cancellation responses; and
  • Android attempted unbound cancellation without a nonblank active output turn identity; and
  • delayed legacy iOS clear events ignored turn ownership and could stop replacement output.

Why This Change Was Made

This establishes one turn-owned cancellation and drain contract across the Gateway, protocol, Web relay, Android relay, and legacy iOS adapter.

The first unowned response.created claims the canonical Talk turn and binds exact-response or turn-bound ownership. Exact-response cancellation requires its matching response ID; the first provider terminal confirms turn-bound cancellation. Tool-result drain does not impersonate provider confirmation, while the one-second close fallback remains.

Forced-consult dynamic native calls are rescanned after each successful wave until the current owner has no pending work. The legacy iOS client decodes the typed cancellation result, validates ok, status, and optional exact turn identity, and fences failure recovery by lifecycle generation. Android requires a nonblank active output turn and snapshots the normalized turn and relay identity synchronously at the stop or push-to-talk action boundary before later asynchronous work. The legacy iOS relay accepts a non-empty clear identity only when it matches the active output turn; missing identity retains legacy behavior.

The Gateway also splits normalized PCM output into ordered 20 ms frames of at most 960 bytes while preserving turn, item, response, and byte-order identity, including a trailing partial frame.

User Impact

Realtime Talk cancellation remains additive and legacy-compatible as { ok: true, status?, turnId? }. Matching and legacy cancellation applies normally, stale and idle are harmless races, and malformed or rejected responses fail closed. Provider output may start before browser microphone audio, ID-less cancellation can recover on the same relay, forced-consult terminal completion waits for all current async result waves, stale iOS cancellation failure cannot close a replacement lifecycle, Android never sends an unbound output cancellation, and a delayed clear for turn A cannot stop replacement output for turn B.

Exact Artifact

  • Current-main restack base: 69ae91878397f21c7ff79d9aecb6d7b449a68288
  • Landed L5 squash: 87665fab10162bb87430d3c1106d3c6c3fa6110b
  • Immediate parent: 36eb0384520403ad20a04b63cada1a16db6adb55
  • Final head: 53b33b5c2f7a2807ed080044138fb89facaf80a2
  • Tree: e83e27be9621f47afdd3fd1a08c9b47c10a5233e
  • Stable full-layer patch ID: d0452accf0332c8b9f440c56a29241318e9769e1
  • Binary diff SHA-256: ed578d6363c555146e5b8f09c25090a16f80256250f2a0d9d093e21254061030
  • The seven restacked semantic commits retain one-to-one range-diff and stable patch identity. Two signed follow-ups align current-main test formatting and fence stale iOS output clears. All commits retain Zhilong Zheng authorship or co-author credit.

Codex Contract

Direct sibling source inspection at openai/codexa196bbb64b1605a458c2531c47b6 confirms that turn.interrupt carries both thread and turn IDs. An empty turnId is reserved for startup interruption and is acknowledged after submission; a non-empty turnId is validated against the active turn and completes after TurnAborted (codex-rs/app-server-protocol/src/protocol/v2/turn.rs:208-216, codex-rs/app-server/src/request_processors/turn_processor.rs:1351-1413). OpenClaw cancellation remains bound to the current Talk output turn; this PR does not claim that Codex startup interrupts require a turn identity.

Evidence

  • The ID-less xAI-ordering regression uses response.created, cancellation, queued replacement audio, onResponseDone({ status: "cancelled" }), then response.done.
  • With the earlier production fix reversed, queued audio failed with Unknown realtime relay session; restored code passed the targeted regression in both Gateway projects and the focused relay file passed 172/172.
  • The forced-consult regression proves three asynchronously arriving native-call waves are submitted exactly once and terminal completion remains blocked through the third. Pre-fix, native-3 escaped; the repaired targeted regression passed in both Gateway projects.
  • The earlier iOS cancellation suite passed 3 tests / 10 parameterized cases: malformed JSON, ok:false, unknown status, turn mismatch, request failure, legacy, applied, stale, idle, and failure after stop.
  • Exact-head review then found that legacy iOS clear ignored turn identity. The new table regression sends stale clear A after replacement B and then matching clear B; the source now ignores only non-empty mismatched IDs and preserves legacy unscoped clear. Local Xcode 26.6 repeatedly timed out in CreateBuildDescription before compiling, so hosted exact-head iOS/required CI is the explicit execution-proof substitute; no local simulator pass is claimed.
  • The compact Android action-bound regression failed pre-fix because stopTts reread replacement state and left the prior clear waiter active. The repaired path preserves local stop, binds the later RPC to the turn owned when the action began, passed the targeted mutation proof, the complete TalkModeManagerTest suite passed 56/56, and app ktlint passed.
  • The exact-main focused protocol and Gateway run passed 334 + 62 tests. Current oxfmt, core lint stripe 1/5, git diff --check, scoped iOS SwiftLint, protocol schema/registry, Web relay, and type checks are clean. Fresh terminal autoreview is clean.
  • No real browser Web relay proof, live Android device proof, or physical iOS audio proof is claimed.

Scope And LOC

Raw reconciliation against the exact stack base:

  • Production source: +517/-162
  • Tests: +1289/-98
  • Generated protocol clients: +29/-0
  • Docs: +4/-2
  • Tooling: +4/-1

This layer changes no native source inventory, locale JSON, or Apple .xcstrings. Any repository-wide native-i18n baseline movement is inherited and is not claimed as an exact-head regeneration.

Stack And Credit

This PR intentionally remains draft.

@vincentkoc vincentkoc self-assigned this Aug 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 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 docs Improvements or additions to documentation app: android App: android app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts size: XL maintainer Maintainer-authored PR labels Aug 21, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 23, 2026, 6:36 AM ET / 10:36 UTC.

ClawSweeper review

What this changes

This PR makes realtime Talk output cancellation turn-bound across the Gateway, browser, Android, and iOS clients, and frames relay audio output.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open: the previous blank-turn-ID finding remains on the exact head. A defined whitespace turn ID is normalized into the legacy omitted form, so it can cancel the active replacement output instead of being rejected.

Priority: P1
Reviewed head: 53b33b5c2f7a2807ed080044138fb89facaf80a2

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch has substantial focused coverage, but the unresolved blank-ID path prevents merge readiness.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored PR is exempt from the external-contributor real-behavior-proof gate; its supplied focused regressions remain supplemental evidence.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is exempt from the external-contributor real-behavior-proof gate; its supplied focused regressions remain supplemental evidence.
Evidence reviewed 6 items Exact-head handler normalizes supplied IDs: The changed handler normalizes params.turnId before invoking cancellation; a whitespace-only value becomes undefined rather than remaining a supplied identity.
Normalization contract: normalizeOptionalString trims strings and returns undefined when the trimmed value is empty.
Cancellation treats omission as legacy behavior: Only a truthy normalized turn ID is compared with the active turn; undefined proceeds to cancellation of the active turn.
Findings 1 actionable finding [P2] Reject explicitly blank cancellation turn IDs
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

runner@runnervm76f27:/tmp/clawsweeper-live-proof-127186-oMgqZ1/target$ pnpm openclaw --help
$ node scripts/run-node.mjs --help
pnpm openclaw --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 104.94 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 14.1s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4278ms (slowest: built plugin control-plane loads 3544ms)

OpenClaw 2026.8.1 (53b33b5) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console (silent|fatal|error|
… output truncated …

Assertions:

  • PASS expect_output: Usage:

How this fits together

Realtime Talk relays provider audio and cancellation events through the Gateway to browser and mobile clients. The cancellation path must associate a client request with the exact active output turn before it stops provider output.

flowchart LR
  Provider[Realtime provider] --> Relay[Gateway Talk relay]
  Relay --> Event[Turn-tagged audio event]
  Event --> Clients[Web and mobile clients]
  Clients --> Cancel[Cancellation request]
  Cancel --> Validate[Turn ownership validation]
  Validate --> Relay
  Relay --> Output[Provider output stopped]
Loading

Before merge

  • Reject explicitly blank cancellation turn IDs (P2) - A supplied whitespace turnId is normalized to undefined, so the new call takes the legacy branch and cancels the currently active replacement turn. Keep omission compatible if needed, but reject a defined blank ID and cover that boundary.
  • Resolve merge risk (P1) - Merging before rejecting defined blank or whitespace-only turn IDs leaves a request shape that bypasses the new exact-turn cancellation contract and can stop replacement output.
  • Resolve merge risk (P1) - The PR reports production +517/-162; the cross-platform ownership boundary and generated client types make some growth inherent, but the remaining protocol hole must be repaired before accepting that added surface.
  • Complete next step (P2) - The remaining blocker is a narrow, source-proven Gateway-boundary repair with a clear regression path.

Findings

  • [P2] Reject explicitly blank cancellation turn IDs — src/gateway/server-methods/talk-session.ts:435
Agent review details

Security

None.

PR surface

Source +260, Tests +836, Docs +2, Other +482. Total +1580 across 26 files.

View PR surface stats
Area Files Added Removed Net
Source 11 399 139 +260
Tests 6 923 87 +836
Docs 2 4 2 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 7 517 35 +482
Total 26 1843 263 +1580

Review metrics

Metric Value Why it matters
Production versus test LOC production +517/-162, tests +1289/-98 The added cross-client ownership contract is substantial for a bug-fix PR and should be assessed with the remaining boundary defect fixed.

Merge-risk options

Maintainer options:

  1. Reject malformed supplied turn IDs (recommended)
    Preserve omitted-ID compatibility, but reject a defined blank or whitespace-only turn ID before it can take the legacy cancellation path.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Preserve omitted turnId compatibility, reject defined blank or whitespace-only turnId values before cancellation, and add protocol plus Gateway-handler regression coverage.

Technical review

Best possible solution:

Reject a defined blank or whitespace-only turn ID at the Gateway boundary while preserving omitted-ID legacy callers, then add protocol and handler regressions; the platform-specific client changes and generated types have no credible single-owner net-neutral substitute.

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

Yes, from source: call talk.session.cancelOutput with a valid session and a whitespace-only turnId while a replacement turn is active; normalization removes the supplied ID and cancellation proceeds as legacy omission.

Is this the best way to solve the issue?

No. The turn-owned design is the right owner boundary, but it must distinguish an omitted legacy ID from a defined blank ID before it can protect replacement output.

Full review comments:

  • [P2] Reject explicitly blank cancellation turn IDs — src/gateway/server-methods/talk-session.ts:435
    A supplied whitespace turnId is normalized to undefined, so the new call takes the legacy branch and cancels the currently active replacement turn. Keep omission compatible if needed, but reject a defined blank ID and cover that boundary.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5e1a28bb5664.

Labels

Label justifications:

  • P1: The PR changes active realtime Talk cancellation across the Gateway and supported clients, where a wrong cancellation can interrupt live output.
  • merge-risk: 🚨 compatibility: The documented cancel-output RPC gains turn-bound request and typed-result behavior while retaining a legacy omission path.
  • merge-risk: 🚨 session-state: A malformed supplied turn identity can still be treated as the active output turn and cancel replacement audio.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This MEMBER-authored PR is exempt from the external-contributor real-behavior-proof gate; its supplied focused regressions remain supplemental evidence.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs packages/gateway-protocol/src/channels.schema.test.ts packages/gateway-protocol/src/index.test.ts.
  • [P1] node scripts/run-vitest.mjs src/gateway/server-methods/talk.test.ts.
  • [P1] git diff --check.

What I checked:

Likely related people:

  • vincentkoc: Authored the exact-head cancellation paths and the merged relay lifecycle work in commit 87665fa. (role: recent Talk relay lifecycle contributor; confidence: high; commits: 87665fab1016, 53b33b5c2f7a; files: src/gateway/talk-realtime-relay-operations.ts, src/gateway/talk-realtime-relay-session-create.ts, ui/src/pages/chat/realtime-talk-gateway-relay.ts)
  • steipete: Peter Steinberger authored the merged GPT-Live gateway-relay feature that established this relay surface. (role: original gateway-relay feature contributor; confidence: high; commits: dc60a9442d5c, 6c5084f1adb3; files: src/gateway/talk-realtime-relay-session-create.ts, apps/ios/Sources/Voice/RealtimeTalkRelaySession.swift)

Rank-up moves

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

  • Reject a defined blank or whitespace-only cancellation turn ID while preserving omitted-ID compatibility, and add protocol plus handler regression coverage.

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 (14 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-23T01:14:24.445Z sha 81cf278 :: needs changes before merge. :: [P1] Keep draining every late forced-consult result | [P1] Validate the iOS cancellation result
  • reviewed 2026-08-23T04:22:51.292Z sha d3edc43 :: found issues before merge. :: [P1] Reject identityless Android cancellation
  • reviewed 2026-08-23T04:38:48.234Z sha d3edc43 :: needs changes before merge. :: [P1] Reject Android cancellation without a captured turn
  • reviewed 2026-08-23T04:54:14.340Z sha d3edc43 :: found issues before merge. :: [P1] Reject Android cancellation without an output turn
  • reviewed 2026-08-23T05:31:54.484Z sha 3bb4670 :: found issues before merge. :: [P1] Capture the Android turn before scheduling cancellation
  • reviewed 2026-08-23T06:02:16.694Z sha d79d803 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-23T09:11:18.235Z sha 36eb038 :: found issues before merge. :: [P1] Fence stale clear events in the iOS relay
  • reviewed 2026-08-23T10:10:08.804Z sha 53b33b5 :: found issues before merge. :: [P2] Reject explicitly blank cancellation turn IDs

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 21, 2026
@vincentkoc
vincentkoc force-pushed the stack/realtime-cancel-contract-l6a branch from a523228 to 736aa18 Compare August 21, 2026 19:09
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 21, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Exact head moved to f79849486287ee8129ca96e1417edc2a19b5066c; the PR body contains the current artifact and proof.

@clawsweeper

clawsweeper Bot commented Aug 22, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 22, 2026
@vincentkoc
vincentkoc force-pushed the stack/realtime-cancel-contract-l6a branch from d79d803 to 59a2916 Compare August 23, 2026 08:56
@vincentkoc

Copy link
Copy Markdown
Member Author

Maintainer decision: I accept the bounded proof gap for this landing and skip the optional composed-client / physical-client rank-up proof. I own the disconnect-durability policy and the additive SDK compatibility policy in this layer. The focused regressions and exact-head CI are deterministic evidence, not live client proof; no live browser, Android-device, or physical iOS audio claim is being made.

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact restacked head 59a29161f09b0e51b3c5bc25dc79c72cf78cabb6; the PR body and maintainer proof-gap decision are current.

@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head 36eb0384520403ad20a04b63cada1a16db6adb55; the only post-review change is the signed +2/-5 test-only formatter/max-lines alignment required by current-main CI, and the PR body is current.

@clawsweeper

clawsweeper Bot commented Aug 23, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 23, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head 53b33b5c2f7a2807ed080044138fb89facaf80a2. It fixes the exact-head stale iOS clear finding by fencing non-empty mismatched turn IDs and extends the existing cancellation table with stale-A/matching-B clear behavior. Local Xcode 26.6 timed out in CreateBuildDescription; hosted exact-head iOS and required CI are the explicit execution-proof substitute, not a claimed local simulator pass.

@clawsweeper

clawsweeper Bot commented Aug 23, 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 exact_review_queue).
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
vincentkoc marked this pull request as ready for review August 23, 2026 10:30
@clawsweeper

clawsweeper Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@vincentkoc
vincentkoc merged commit 9046ece into main Aug 23, 2026
499 of 501 checks passed
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

@vincentkoc
vincentkoc deleted the stack/realtime-cancel-contract-l6a branch August 23, 2026 10:58
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 24, 2026
* fix(talk): isolate cancellation ownership contract

Co-authored-by: Zhilong Zheng <[email protected]>

* fix(talk): frame realtime relay output audio

Co-authored-by: Zhilong Zheng <[email protected]>

* fix(talk): confirm turn-bound provider cancellation

Co-authored-by: Zhilong Zheng <[email protected]>

* fix(talk): bind legacy iOS output cancellation

Co-authored-by: Zhilong Zheng <[email protected]>

* fix(talk): close cancellation ownership gaps

Drain dynamically arriving forced-consult results before terminal completion and validate legacy iOS cancellation responses against the active lifecycle.

Co-authored-by: Zhilong Zheng <[email protected]>

* fix(talk): require Android output identity for cancellation

Co-authored-by: Zhilong Zheng <[email protected]>

* fix(talk): bind Android cancellation to action turn

Co-authored-by: Zhilong Zheng <[email protected]>

* test(talk): align relay checks with current main

Co-authored-by: Zhilong Zheng <[email protected]>

* fix(talk): fence stale iOS output clear

Co-authored-by: Zhilong Zheng <[email protected]>

---------

Co-authored-by: Zhilong Zheng <[email protected]>
masatohoshino added a commit to masatohoshino/openclaw that referenced this pull request Sep 2, 2026
…ayout owner

Integrates this branch with openclaw#127186, which landed turn-bound cancellation
ownership while this branch was open. The two changes meet in the same three
places, and each place needs both contracts rather than either one.

The clear boundary. Upstream completed the cancellation waiter directly from
handleRealtimeTalkEvent, straight after stopRealtimePlayback(). This branch
made the playout owner the only thing allowed to reach the device, so
completing there would tell cancelOutput the boundary had been reached while
the AudioTrack was still queued for retirement. Turn validation stays on the
receiving thread, where upstream put it; the retirement is queued to the owner,
and the owner completes the waiter after it has actually retired the sink.
RealtimePlaybackCommand.Clear therefore carries the turn id rather than a bare
Unit completion -- the waiter must be answered with the identity the clear
arrived with, because cancelOutput checks it against the turn it asked to
cancel, and a newer turn overwriting the field mid-flight would otherwise
answer with the wrong one.

The capture gate. Upstream fences capture while a cancellation is in flight;
this branch opens capture during playback whenever the platform is cancelling
the echo. Those answer different questions -- which turn owns the uplink,
versus whose voice the microphone hears -- so the merged gate requires both,
and the fence wins even when full duplex is live.

Both paths that release the waiter without a retirement release it with a null
identity rather than the caller's turn: owner exit, and a Clear that could not
be queued. In neither case was a turn physically retired, so nothing may claim
one -- answering with the matching turn would tell cancelOutput the boundary was
reached and lift the capture fence over a live sink. Null fails the turn check
closed and the caller closes the relay, which is the honest outcome. The
un-queued path has no unit test: reaching it needs the 32-slot control headroom
filled by hand, which would exercise the harness rather than the product.

Harness events now carry talkEvent.turnId, which upstream requires on audio.

Three tests cover the merged contract, each verified to fail against the
wrong resolution: removing upstream's fence fails 2 (including upstream's own
realtimeAudioFramesStreamUntilPlaybackOrCancellationStarts), and replacing the
full-duplex rule with upstream's half-duplex one fails 4.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: android App: android app: ios App: ios app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant