Repository navigation
fix(watch): preserve companion messages and replies across app restarts - #137463
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 3, 2026, 5:50 PM ET / 21:50 UTC. ClawSweeper reviewWhat this changesThe PR replaces volatile Apple Watch companion-message handling with durable phone and Watch journals so commands and receipts survive restart or disconnection. Warning SQLite table change This PR modifies persisted SQLite tables in Merge readiness⛔ Blocked before merge - 3 items remain No blocking defect was found in the durable Apple Watch message/reply repair. The recorded maintainer acceptance resolves the prior storage-design decision; current main lacks this implementation, so the PR remains necessary pending its normal exact-head CI gate. Priority: P2 Review scores
Verification
How this fits togetherApple Watch chat and quick replies travel through WatchConnectivity to the iPhone, which admits work to the Gateway and returns a result. This change adds app-local durable state around those handoffs so recovery can replay custody or receipts without resending uncertain work. flowchart LR
A[Watch chat or quick reply] --> B[Watch delivery journal]
B --> C[WatchConnectivity transport]
C --> D[iPhone admission journal]
D --> E[Gateway chat request]
E --> F[Saved result receipt]
F --> G[Watch receipt replay and acknowledgment]
Before merge
Agent review detailsSecurityNone. PR surfaceDocs +127, Config +12, Other +4813. Total +4952 across 37 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land after exact-head required CI is green while preserving the documented v8-reader, migration, Forget, and receipt-replay guarantees. Do we have a high-confidence way to reproduce the issue? Yes, from source and reviewed regression coverage: the former acknowledgement/volatile-queue boundary can separate accepted work from durable custody; this reviewer did not execute native tests. Is this the best way to solve the issue? Yes: per-device journals give admission and result delivery one durable owner while explicit uncertainty prevents unsafe resend of ambiguous work; the old Defaults queues are migrated rather than retained as runtime fallbacks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 194b7f2a1619. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Recording the maintainer decision already given in the originating task: the accepted implementation is the app-local journal design in #136617, including the exact migration, retention, Forget and downgrade terms now implemented in this PR. That approval covers the iPhone v9 journal and route-generation column, the Watch-local v1 journal, the nullable command fingerprint, permanent hash-only legacy-import receipts, and receipt-preserving Dismiss. Legacy-import hashes survive targeted Forget to prevent old data from resurrecting; full reset clears them. New commands and results retain their original 48-hour deadline. There is no Gateway shared-state/per-agent schema change or protocol-version bump. The production growth is accepted for replacing the split queues with one durable admission/result owner on each device, not for adding a second delivery path. The actual signed stable v8 → candidate → stable v8 open/use/Forget → candidate compatibility run passed, as did the isolated real-Gateway/provider journal flow described in the body. Physical background WatchConnectivity remains explicitly unverified. CI is still a required gate. On e77fdc8, both Periphery workflows now pass, but the full CI run has an Android reconnect-test failure under investigation. Its tested merge contains newer main commit #137389; the failing test is absent from the literal PR head. No merge is being attempted while that gate is red. |
|
Update: the candidate is now Previous candidate evidence: Ready for native landing of the companion delivery journal at Exact-head CI attempt 2 and the required gate are green. The only retry was an upstream native-dependency download failure before tests; unchanged source then passed 581 tests in 33 files, with five Linux-inapplicable Mac-package cases skipped. Mac, iOS/Watch, Android and screenshot successes were retained. Local proof includes Physical paired-Watch background transport and audio/endurance testing remain unverified; this PR does not claim standalone realtime voice, which remains in #135808. |
Replace volatile companion queues with an app-local SQLite journal. Commit admission before acknowledging Watch custody, retain typed result receipts until Watch acknowledgment, and fence retries by immutable route ownership. Recover accepted quick replies offline without sending again. Preserve ambiguous sends for review instead of assuming Gateway deduplication is durable. Add recovery settings, legacy import receipts, and hash-only command identity that survives Dismiss until the original receipt deadline. The app-local v9 schema and retention design were explicitly approved in
e77fdc8 to
e3edb92
Compare
|
Merged via squash.
|
…ts (openclaw#137463) * feat(ios): persist Watch message custody and delivery receipts Replace volatile companion queues with an app-local SQLite journal. Commit admission before acknowledging Watch custody, retain typed result receipts until Watch acknowledgment, and fence retries by immutable route ownership. Recover accepted quick replies offline without sending again. Preserve ambiguous sends for review instead of assuming Gateway deduplication is durable. Add recovery settings, legacy import receipts, and hash-only command identity that survives Dismiss until the original receipt deadline. The app-local v9 schema and retention design were explicitly approved in * fix(watch): remove obsolete delivery helpers and stabilize reconnect proof
Closes #136617
Related: #135808 (standalone realtime voice; separate work).
What Problem This Solves
Fixes an issue where users sending companion Apple Watch chat or quick replies could lose saved work or its result across app suspension, disconnection, or restart. An interactive WatchConnectivity acknowledgment could precede application admission, and a completed request could be retired before its reply reached the Watch. Retrying an ambiguous Gateway send is not safe evidence that it never executed.
Why This Change Was Made
Give each side one durable delivery owner: the Watch commits its original command before transport, and iPhone commits admission, dispatch state, accepted run identity and the result receipt before acknowledging or forwarding them. Reconnects replay commands still awaiting custody or saved receipts; they do not automatically repeat uncertain execution. This replaces the Watch-specific UserDefaults outbox rather than adding another queue beside it.
The app-local SQLite design, migration, retention and deletion choices were explicitly approved in #136617. The phone uses its existing client-state database; the Watch uses existing native SQLite primitives. No new dependency, setting, Gateway shared-state/per-agent schema change, or Gateway protocol-version bump is included. The new companion command/receipt/ACK family requires updated phone and Watch apps. This is durable companion messaging, not realtime audio or a local model runtime.
User Impact
Saved messages keep their exact Gateway, route generation, agent, session, text and original 48-hour deadline. Results remain available after the short spoken-reply window. The iPhone's Apple Watch settings expose Message Delivery, including completed receipts and legacy text that needs review. Dismiss hides a completed card without deleting its acknowledgment authority or allowing another send; Discard applies only to non-dispatchable legacy text.
Only work known not to have been dispatched is automatically sent. Known Gateway acceptance survives a temporarily failed local state write without another send; an app exit before that commit produces the documented uncertain state. Forget invalidates the exact routing generation and removes its journal rows. Hash-only legacy import receipts survive targeted Forget to prevent old Defaults data from resurrecting deleted text; Full Reset removes them. Legacy text without trustworthy ownership is never silently sent to the currently selected agent.
Current landing status
Current candidate:
e3edb92d4f871c2003e6861a39ce05c3b37838f6, rebased once onto main9acf0d48294c86c09dbb0016b914f75eca567290after the native merge gate refused an obsolete canceled PR-event check. Both commits are patch-identical bygit range-diff; all 35 affected production, test and documentation files remain byte-for-byte identical to the reviewed/testede77fdc8candidate. Only main's CI and native string inventory compose.Canonical pull-request CI, attempt 3 is successful on this head, and the enforced PR-event gate passed. Native prepare/merge can now use the canonical event without a bypass. The earlier manual result remains separately labeled below.
The exact Mac test job checked out merge
e7aeeec0(this head into the pinned main base), then passed the Kit 1,627-test run and Mac 2,013-test run, with their explicitly recorded native opt-in skips and separate XCTest/health/AppState results. The unchanged Windows retry passed the original source/config transform case in 91.327 seconds under its existing 120-second limit. The next Mac attempt failed only at GitHub DNS resolution during checkout; one targeted same-head retry passed. Successful siblings were retained. No source, test assertion, timeout, or global runner-policy workaround was used. Physical Watch/iPhone proof remains outside this CI result.Evidence
Native regression, UI, stable-reader compatibility and real-provider verification passed on head
36bc00e7c312c9603fb75d9d984110a1cab439e0. Follow-upe77fdc826b21bdcc607fea048541967b5e289c35removes unused helpers and corrects a test wait, as described below. Exact-head hosted CI has passed, as recorded below.Verified on the current candidate: all 38 shared journal/Watch-store test methods (67 cases) and all 248 iPhone coordinator methods pass. The delayed-route regression failed on the old claim with the actual stale outbound message, then passed on the command-bound claim; the write-failure and ambiguous-dispatch controls also pass. Coverage includes admission, Dismiss identity, receipt acknowledgment, original expiry, interrupted imports, targeted Forget/re-pair, offline accepted quick replies, transient storage warning recovery and failed dispatch-state writes. An actual signed stable v2026.8.2 reader was exercised in a v8 → candidate → v8 open/use/Forget → candidate sequence, with all four phases and 33 guarded fact groups passing.
The native app and UI-test targets build successfully. The UI test opens Message Delivery through Apple Watch settings, expands the saved reply, dismisses it and verifies that Needs review remains; its three inspected, synthetic-only screenshots are attached below.
node scripts/check-changed.mjs --stagedpasses, including configured Swift lint, repository/schema guards and 20 Vitest files/1,077 tests. A final two-line test-callback compiler correction was subsequently compiled and exercised by the native runs, with formatting checked separately.The isolated real-provider test passed after normal device pairing: Watch SQLite enqueue → phone admission → actual Gateway/provider reply → independent phone SQLite readback → Watch reopen → phone operator reconnect and receipt replay → typed Watch ACK. Fifteen runtime facts passed; canonical history held exactly one correlated user turn, and command replay preserved the claim, run, receipt and original deadline. The first attempt reached its connection deadline while awaiting node-role pairing approval and sent no command; the unchanged test passed on retry. The full test Gateway then closed normally, its owned process group exited, and temporary credentials and state were removed with zero retained exact credential matches. Hardware discovery finds no physical paired iPhone/Watch, so Simulator and direct-delegate coverage must not be mistaken for background WatchConnectivity, microphone/speaker, radio handoff, battery or endurance proof.
The broader native run completed 313 selected methods: 311 passed and two native SDK opt-ins were skipped. An explicit isolated, unpaired SDK run with the required live-test flag then passed all 14 gate methods/21 cases, including both skipped cancellation methods, with zero skips or runtime warnings. The broader run emitted existing audio-session main-thread warnings during app-model tests; these are retained and being traced separately, not counted as delivery failures or silently suppressed.
The owner refactor removes duplicate Watch queue/recent-ID policy and adds durable command/result recovery and its UI. Current diff accounting is 26 production files, +3,495/−1,047 lines (net +2,448), and seven test/test-support files, +3,219/−911 (net +2,308); docs, generated native strings and CI wiring are counted separately. The growth implements the approved two-sided custody/receipt capability and migration, rather than a retry wrapper around the old queue.
CI repair and final local proof
The first hosted run failed two Periphery checks on four unused helpers left by the owner refactor. The follow-up removes those helpers rather than suppressing the checks. Existing tests now check real route admission after import rollback and use the structural decoder used by production; an obsolete predicate-only delayed-refresh test is removed while its stronger command-result/replacement tests remain.
The same hosted run had one shared-library test failure: the ownerless reconnect test observed creation of the replacement socket before its connect frame existed. It now waits for that frame under the existing deadline, then retains all credential-isolation assertions. No production credential or networking behavior changes in this repair.
The exact eight-file follow-up passed independent review with no actionable findings, 117 native shared-library methods/156 cases, and 31 native Watch operation methods/46 cases. Its initially gated native speech test was then explicitly enabled and passed, proving replacement/Stop playback state. The repository changed gate passed again with pinned Swift tools and all 1,077 selected tooling tests. Temporary native process groups and the cleanup Watch Simulator were retired. The earlier real-provider and UI proof remains bound to
36bc00e7; this follow-up changes only unused production code and test observations, not the proven delivery path. Exact-head hosted CI has now passed.Earlier manual hosted CI
CI run 33802556208, attempt 2 passed on exact commit
e77fdc826b21bdcc607fea048541967b5e289c35: 201 jobs succeeded, one unselected Docker job skipped, and the requiredopenclaw/ci-gatesucceeded. The Mac Swift/release, iOS and Watch tests/release, native screenshots and Android families all passed. This run checks the literal PR commit, not a virtual merge with newer main.The first attempt failed only while downloading an upstream native dependency (
ECONNRESETbefore tests). One failed-job retry, with no dependency or source workaround, passed 33 files and 581 tests; five Mac-packaging cases are intentionally skipped on that Linux shard. Previously successful native jobs were retained rather than rerun. The obsolete original queued run was cancelled after this replacement passed.Native UI evidence
Synthetic fixtures only. Before and after refer to the Dismiss interaction in the new Message Delivery screen.