Skip to content

fix(talk): share and bound Apple relay lifecycle - #127232

Merged
vincentkoc merged 4 commits into
mainfrom
stack/realtime-apple-relay-l6b
Aug 23, 2026
Merged

vincentkoc merged 4 commits into
mainfrom
stack/realtime-apple-relay-l6b

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 21, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

The iOS-owned realtime Talk relay could not be reused by macOS and had unbounded or ambiguous audio lifecycle failure paths.

Why This Change Was Made

The canonical Apple relay and PCM player now live in OpenClawKit with platform capture and transport injected by the app. Playback, microphone input, cancellation, and terminal recovery are bounded and owned by the exact relay generation.

User Impact

  • at most three scheduled PCM buffers;
  • 32 framed output-buffer slots;
  • visible recovery for microphone saturation, RPC failure, and unfinished playback;
  • exact-turn cancellation fences;
  • pending playback marks acknowledged exactly once on cancellation and supersession; and
  • stale generations cannot affect the active relay.

Exact Artifact

  • Exact parent A squash: 9046ecea730376a4b0f879c1d785108860e33c39
  • Head: 6774fac2dd9b9d93f34d122d0cd4eb5060012ed7
  • Tree: 9c61d6fda14b367d8cb89f1f6d7c73278358196e
  • Current cumulative B-layer patch ID: ac71b3bb826b27e3c662727d9246f233e06366ad
  • Bounded lifecycle commit patch ID: be8c794f61a0b4e1104dae3e99c9997f151db2fa
  • Cancellation-mark repair patch ID: 94227ee76a78900ae94cfe5b571f2d0672d40d25
  • Supersession-mark repair patch ID: fa3d058c777272722ef42177c698792ea45ba362
  • Binary diff SHA-256: f9169be3c43746e0250e5c2cd205e2729c4be08e507dbb1b0ee7ea4774e72f70
  • All commits are signed and preserve Zhilong Zheng authorship or co-author credit.

The migration commit changes mechanically when A moves because it absorbs A's superseded legacy iOS relay implementation and tests; the shared owner remains the sole cancellation state machine. The lifecycle and both mark-repair patch IDs remain stable.

Evidence

  • OpenClawKit relay: 40/40
  • PCM streaming player: 6/6
  • Full OpenClawKit package: 1,434 tests passed
  • Targeted iOS lifecycle/configuration proof: 59 tests passed
  • Matching-clear, stale/idle, wrong/duplicate clear, and supersession regressions prove pending marks are acknowledged exactly once.
  • pnpm ios:build, SwiftLint, SwiftFormat, diff checks, and terminal reviews passed for the reviewed B layer.
  • Restacking onto landed A preserved the final B-owned source and test blobs byte-for-byte; the bounded-lifecycle and both playback-mark repair patch IDs remain exact. The migration commit was re-signed because it absorbs the superseded legacy iOS owner.
  • The composed stack inherits A's current Gateway 172/172, forced-consult three-wave, typed legacy-iOS cancellation, and Android action-bound cancellation proof with 56/56 manager tests.
  • Fresh exact-head diff-scoped autoreview reported no actionable findings.
  • No physical-device microphone, speaker, route-change, or completed relay-turn proof has been performed; tests and hosted CI are not live-device proof.

Scope And LOC

Raw reconciliation against exact parent A:

  • Production source paths: +1090/-1575
  • Tests: +2583/-635
  • Native source inventory: +136/-0

The large deletions are the iOS-to-OpenClawKit ownership move. Native i18n remains source-only with no locale JSON or .xcstrings churn. The prior 4,220-entry layer-local verification predates inherited repository baseline movement and is not claimed as a new exact-head regeneration.

Stack And Credit

Repeated test-fixture construction remains a non-blocking cleanup intentionally deferred to avoid widening this owner boundary. This PR 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 app: ios App: ios size: XL maintainer Maintainer-authored PR labels Aug 21, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. 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: 🐚 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 Aug 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 7:07 AM ET / 11:07 UTC.

ClawSweeper review

What this changes

Moves Apple realtime Talk relay and PCM playback lifecycle into shared OpenClawKit code, with iOS supplying microphone capture and a route-pinned Gateway transport.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open. Static source and local Gateway-contract review found no actionable patch defect, but this protected maintainer-authored draft still needs exact-head iOS build and required CI evidence before landing.

Priority: P1
Reviewed head: 6774fac2dd9b9d93f34d122d0cd4eb5060012ed7

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The source-level owner-boundary repair and focused regression coverage are strong, while current-head native build and real-device evidence remain incomplete.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: This member-authored PR transparently records that focused tests are not physical-device proof; the requested maintainer context accepts that optional gap while retaining exact-head CI and iOS build requirements.
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 PR transparently records that focused tests are not physical-device proof; the requested maintainer context accepts that optional gap while retaining exact-head CI and iOS build requirements.
Evidence reviewed 6 items Shared lifecycle owner: The shared relay creates the session, pins lifecycle generations, cleans up a created session after route loss, and owns bounded output/cancellation state.
iOS caller boundary: iOS captures the current Gateway route before creating the relay and fences every callback with the relay generation.
Current Gateway cancellation contract: Current main validates and dispatches cancellation through the realtime relay, whose cancellation path emits the matching clear event before returning applied.
Findings None None.
Security None None.

Live Verification

Command: pnpm ios:build

Result: FAIL (partial) — step 2 expect_output BUILD SUCCEEDED: expected terminal output was not visible within 30 seconds: "BUILD SUCCEEDED"

pnpm ios:build
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127232-9V60PR/target$ pnpm ios:build
$ bash -c 'export PATH="$PATH:/opt/homebrew/bin:/usr/local/bin"; ./scripts/ios-configure-signing.sh && ./scripts/ios-write-version-xcconfig.sh && node scripts/i
os-write-swift-filelist.mjs && cd apps/ios && xcodegen generate && xcodebuild -project OpenClaw.xcodeproj -scheme OpenClaw -destination "${IOS_DEST:-generic/pla
tform=iOS Simulator}" -configuration Debug build'
WARN: Unable to detect an Apple Team ID; keeping existing iOS signing override (if any).
Prepared iOS version settings: ios=2026.8.1 marketing=2026.8.1 build=1 commit=6774fac2dd9b9d93f34d122d0cd4eb5060012ed7 built=2026-08-23T11:08:28.000Z
Prepared iOS Swift file list: apps/ios/SwiftSources.input.xcfilelist
bash: line 1: xcodegen: command not found
[ELIFECYCLE] Command failed.
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127232-9V60PR/target$ pnpm ios:build
$ bash -c 'export PATH="$PATH:/opt/homebrew/bin:/usr/local/bin"; ./scripts/ios-configure-signing.sh && ./scripts/ios-write-version-xcconfig.sh && node scripts/i
os-write-swift-filelist.mjs && cd apps/ios && xcodegen generate && xcodebuild -project OpenClaw.xcodeproj -scheme OpenClaw -destination "${IOS_DEST:-generic/pla
tform=iOS Simulator}" -configuration Debug build'
WARN: Unable to detect an Apple Team ID; keeping existing iOS signing override (if any).
Prepared iOS version settings: ios=2026.8.1 marketing=2026.8.1 build=1 commit=6774fac2dd9b9d93f34d122d0cd4eb5060012ed7 built=2026-08-23T11:08:29.000Z
Prepared iOS Swift file list: apps/ios/SwiftSources.input.xcfilelist
bash: line 1: xcodegen: command not found
[ELIFECYCLE] Command failed.
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127232-9V60PR/target$































Assertions:

  • FAIL expect_output: BUILD SUCCEEDED

How this fits together

Apple Talk captures microphone PCM, relays it through the Gateway, and plays returned PCM to the operator. The shared relay now owns lifecycle, buffering, cancellation, and recovery while each Apple app supplies platform-specific capture and transport.

flowchart LR
  A[Apple microphone capture] --> B[Shared relay lifecycle]
  C[Route-pinned Gateway transport] --> B
  D[Gateway Talk events] --> B
  B --> E[Bounded PCM queue]
  E --> F[Apple audio output]
  B --> G[Talk status and recovery]
Loading

Before merge

  • Resolve merge risk (P1) - The current exact head is still a draft and its iOS build and required CI checks are skipped, so the requested mandatory validation has not yet run on this restack.
  • Resolve merge risk (P1) - Physical-device microphone, speaker, route-change, and restart behavior remains unproven; the maintainer request explicitly accepts this as optional rank-up evidence rather than a replacement for exact-head CI.
  • Complete next step (P2) - This protected maintainer-authored draft needs normal exact-head validation, not an automated repair branch.
Agent review details

Security

None.

PR surface

Other +2822. Total +2822 across 10 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 10 4647 1825 +2822
Total 10 4647 1825 +2822

Review metrics

Metric Value Why it matters
Production versus tests production +1,928/-1,190; tests +2,583/-635; native i18n inventory +136 The net production growth is the deliberate move from iOS-only ownership into reusable OpenClawKit; the large test move preserves lifecycle coverage at the new owner boundary.

Merge-risk options

Maintainer options:

  1. Run exact-head Apple validation (recommended)
    Run the iOS build and required CI for commit 6774fac before landing the shared relay lifecycle change.
  2. Pause the extraction
    Keep the draft open if exact-head Apple validation cannot run, because lifecycle and playback behavior then lacks its required build proof.

Technical review

Best possible solution:

Retain the shared owner-boundary refactor, run the iOS build and required CI on the current head, then land with the recorded acceptance of the remaining device-proof gap.

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

No physical-device reproduction is available on this head. Source and focused regressions provide a clear lifecycle and cancellation path, but do not prove real microphone, speaker, restart, or route-change behavior.

Is this the best way to solve the issue?

Yes. Moving the shared lifecycle owner into OpenClawKit while retaining iOS-specific capture and route-pinned transport is the cleaner boundary than maintaining parallel Apple relay implementations.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9046ecea7303.

Labels

Label justifications:

  • P1: This changes active realtime Talk cancellation, input, output, and recovery behavior for Apple clients.
  • merge-risk: 🚨 session-state: Relay generations, exact output turns, and pending playback marks must remain associated with the active lifecycle.
  • merge-risk: 🚨 availability: Capture, PCM playback, and relay teardown changes can interrupt a live Talk session if the native build/runtime path regresses.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp 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 PR transparently records that focused tests are not physical-device proof; the requested maintainer context accepts that optional gap while retaining exact-head CI and iOS build requirements.

Evidence

What I checked:

Likely related people:

  • vincentkoc: Authored the current shared lifecycle and supersession-mark repair; also authored the merged cancellation-contract precursor on main. (role: recent area contributor; confidence: high; commits: 6774fac2dd9b, 9046ecea7303; files: apps/shared/OpenClawKit/Sources/OpenClawKit/RealtimeTalkRelaySession.swift, apps/ios/Sources/Voice/TalkModeManager.swift)
  • zhilong1115: The PR’s preserved extraction commit credits this contributor for moving the relay into the shared Apple runtime. (role: shared-relay extraction author; confidence: medium; commits: f76c00a342c5; files: apps/ios/Sources/Voice/RealtimeTalkRelaySession.swift, apps/shared/OpenClawKit/Sources/OpenClawKit/RealtimeTalkRelaySession.swift)

Rank-up moves

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

  • Run the exact-head iOS build and required CI.
  • If an Apple owner wants higher confidence, add a redacted device relay run covering capture, output, teardown, restart, and a route change.

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 (13 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-22T21:40:27.076Z sha fed4660 :: found issues before merge. :: [P2] Acknowledge marks when a new turn replaces playback
  • reviewed 2026-08-23T00:51:10.755Z sha 20e9e1a :: needs maintainer review before merge. :: none
  • reviewed 2026-08-23T01:37:34.373Z sha 20e9e1a :: needs maintainer review before merge. :: none
  • reviewed 2026-08-23T04:22:06.899Z sha 277d477 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-23T04:40:50.265Z sha 277d477 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-23T04:55:02.431Z sha 277d477 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-23T05:31:15.918Z sha de6f690d21c3b94a00f11f6099cd1dd35161a11f :: needs maintainer review before merge. :: none
  • reviewed 2026-08-23T06:03:14.010Z sha 262ac67 :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc force-pushed the stack/realtime-cancel-contract-l6a branch from a523228 to 736aa18 Compare August 21, 2026 19:09
@vincentkoc
vincentkoc force-pushed the stack/realtime-apple-relay-l6b branch from 72d0289 to cae11ff Compare August 22, 2026 07:22
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Exact head moved to cae11ff5826df6e1d69e344ae34592f3cb38647a; 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 added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 22, 2026
@vincentkoc
vincentkoc force-pushed the stack/realtime-cancel-contract-l6a branch from f798494 to 9bf2fba Compare August 22, 2026 07:40
@vincentkoc
vincentkoc force-pushed the stack/realtime-apple-relay-l6b branch from cae11ff to e9055a8 Compare August 22, 2026 07:40
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head e9055a8aefa3dd156ce6001a4e62fb9b4b87252e; the prior run is stale after the lint-only restack, and the PR body contains current 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 added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 22, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Exact head moved to 47c1d158ff67c079bbda4e74c78d64fed690150c for the playback-mark cancellation repair. The PR body has current exact-head 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 added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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-apple-relay-l6b branch from 262ac67 to 6774fac Compare August 23, 2026 11:00
@openclaw-barnacle openclaw-barnacle Bot removed docs Improvements or additions to documentation app: android App: android app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts extensions: openai labels Aug 23, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

Restacked onto landed precursor A.

  • old B head: 262ac6778dcc35101f9ffe3742d03cbb4c485517
  • new B head: 6774fac2dd9b9d93f34d122d0cd4eb5060012ed7
  • new parent: 9046ecea730376a4b0f879c1d785108860e33c39
  • the bounded-lifecycle and both playback-mark repair patch IDs are unchanged
  • the migration commit was re-signed after resolving the expected legacy-iOS ownership move; final B-owned source and test blobs remain byte-identical to the reviewed B head

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Exact head moved to 6774fac2dd9b9d93f34d122d0cd4eb5060012ed7 after restacking onto landed A; the PR body now contains the current artifact and proof.

Maintainer proof disposition: no physical-device iOS microphone, speaker, completed relay-turn, restart, or route-change proof is available. Focused tests, hosted CI, and screenshot artifacts are not live-device proof. I am explicitly accepting that missing optional rank-up evidence for this landing; exact-head required CI and iOS build proof remain mandatory.

@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 11:26
@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 057ed79 into main Aug 23, 2026
198 checks passed
@vincentkoc
vincentkoc deleted the stack/realtime-apple-relay-l6b branch August 23, 2026 11:47
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 24, 2026
* refactor(talk): move Apple relay into OpenClawKit

* fix(talk): bound Apple relay audio lifecycle

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

* fix(talk): acknowledge cancellation playback marks

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

* fix(talk): acknowledge superseded playback marks

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

---------

Co-authored-by: Zhilong Zheng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: ios App: ios maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. 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. size: XL 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.

2 participants