Repository navigation
Harden native approval and Stop controls - #218
Conversation
There was a problem hiding this comment.
sambitcreate has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
There was a problem hiding this comment.
Important
A late mismatched iOS approval response can hide a newer approval card when its reconciliation read fails; please fix this race before merging.
Reviewed changes This review covers the Android and iOS approval/Stop state machines, control-write transport behavior, focused native tests, and the related plan and memory updates.
- Approval identity and serialization Approval taps now carry the displayed request ID and duplicate control writes are suppressed on both native clients.
- Authoritative reconciliation Uncertain approval outcomes refresh from the Mac instead of replaying a captured card, with terminal and installation fences around delayed work.
- Stop acknowledgement Stop remains active until a matching host acknowledgement and reports mismatched or failed responses without undoing terminal state.
- Capability and transport gates Bot controls require current negotiated grants, legacy Workspace Stop remains available, and Android disables connection-failure retries for the two control POSTs.
- Native coverage Android JUnit and iOS XCTest coverage exercise stale IDs, duplicate taps, uncertain outcomes, revocation, legacy controls, mismatched acknowledgements, and terminal races.
GPT Luna | 𝕏
There was a problem hiding this comment.
Important
The follow-up fixes the already-installed newer-card case, but iOS still allows overlapping approval reconciliations to let an older snapshot hide a newer request. Please add an ordering fence or serialization before merging.
Reviewed changes This run reviewed the changes since the prior Pullfrog review: the iOS stale-acknowledgement guard, its held-response regression coverage, and the tightened shipping source contract.
- Guarded iOS approval refreshes Added pending-card and stream-state checks so a failed refresh does not clear an already-installed newer approval.
- Added stale-acknowledgement coverage Exercised a mismatched receipt while a newer card was present and approval reads failed.
- Tightened the shipping contract Required the approval card to include connection, read-only, in-flight approval, and stopping gates in its disabled state.
GPT Luna | 𝕏
There was a problem hiding this comment.
Important
This PR still permits a failed fallback reconciliation to hide an in-flight newer approval on both native clients.
Reviewed changes This run reviewed the changes since the prior Pullfrog review: the new ordering fence for overlapping approval snapshot reads and its Android/iOS regression coverage.
- Added monotonic snapshot fencing Added a generation token and current card/state/context checks around approval snapshot publication on Android and iOS.
- Added overlap regression coverage Held older and newer approval reads, inserted a stale-stream invocation, and asserted that the newer snapshot wins.
GPT Luna | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes This incremental review covers the final follow-up since the prior Pullfrog review: preserving an authoritative approval snapshot while an ambiguous native response is reconciled.
- Coalesced matching fallback reads Android and iOS now reuse only an in-flight snapshot with the same stream, active client or context, captured approval, and captured stream state, while allowing a fresh fallback for a pre-response read.
- Added deterministic race coverage Held-read regressions exercise both pre-response and post-response ordering, including a failing redundant fallback, and verify that the current approval remains visible.
GPT Luna | 𝕏
Integrate #218's native approval/Stop hardening with this branch's stream recovery and removal fences: iOS stop(), respondToApproval() and restorePendingApproval() keep main's acknowledgement, no-resurrection and snapshot-generation safeguards and add the removal fence on entry and after every await. Android Detail keeps canStop gating and blocks Send while a prior stream reconciles. Test harness conflicts keep the stricter EPIPE and finite capacity assertions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GAkZRgQzUoKWGpgupF3a4D
Integration coverage for the merged stream-recovery and acknowledged run-control state machines: - iOS: removal while a stop, approval response or approval snapshot is held cannot report, restore a card or re-read; URLError(.cancelled) on stop/approval leaves the run live without optimistic cancel or card resurrection. Main's tests pass the now-required chat write token, and the mismatched-receipt test delivers the newer approval through the snapshot read because #217 keeps reopen from re-probing a live stream. - Android: unpair during a held stop or approval snapshot, and a dropped stop write that is not retried. #217 fixtures now encode the Mac wire shape (absent optionals omitted) so main's reasoning validator accepts them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GAkZRgQzUoKWGpgupF3a4D
* Fence Android chat reads and Home summary admission (#225) * fix(android): fence deferred home cache writes * fix(android): reject superseded cross-owner chat reads * fix(android): order Home summary requests and pagination commits * Preserve Android turn receipts across response ownership changes (#227) * Preserve Android accepted turn receipts across response ownership changes * Keep receipt merges under request authority in both completion orders (cherry picked from commit 1a3cd3e) * Preserve iOS Bot navigation and live permission ownership (#233) * Own iOS Bot navigation responses and live permission publication * fix(ios): keep in-flight Bot opens and same-policy grants through restoration Restoration re-ran on an open's own path change and superseded it, and it reset an already-presented chat's live mutation grant to false before revalidating, leaving it disabled after a transient failure. Restoration now adopts an in-flight open under identical inputs, and keeps a prior live grant only when the write and notice policy are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GAkZRgQzUoKWGpgupF3a4D * fix(ios): preserve newer detail state across workspace list responses (#234) * fix(ios): admit workspace lists against newer detail owners * fix(ios): preserve accepted rename titles and coherent chat revisions (#236) * fix(ios): preserve rename receipts without replacing newer chat state * Preserve authoritative list titles across detail hydration * Fence iOS Home responses and preserve admitted row ownership (#238) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit ccb6415) Conflict resolution against #242: saveChats keeps #242's committed-write ordering (older lists are partial companions, rows come from successful detail commits, and the list token is the max). #233's in-memory list, rename-title and fetch authority stay. The durable list extends only the last admitted rows, so a detail whose disk write failed stays a memory-only winner on the read path and never becomes a durable row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GAkZRgQzUoKWGpgupF3a4D * test(mobile): cover #217 x #218 run controls on iOS and Android Integration coverage for the merged stream-recovery and acknowledged run-control state machines: - iOS: removal while a stop, approval response or approval snapshot is held cannot report, restore a card or re-read; URLError(.cancelled) on stop/approval leaves the run live without optimistic cancel or card resurrection, and a second Stop may retry. - Android: unpair during a held stop or approval snapshot, and a dropped stop write that is not retried. #217 fixtures now encode the Mac wire shape (absent optionals omitted) so main's reasoning validator accepts them. (cherry picked from commit d41ad06) Conflict resolution against #242: #242 already added the cancelledControls mode, its URLProtocol failure path and the load()-based mismatched-approval delivery, so those duplicates were dropped. The cancelled Stop test now follows #242's silent-cancellation rule (no "Stop was not confirmed"). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GAkZRgQzUoKWGpgupF3a4D * fix(ios): resolve the 9 failing AidenChatTests on #217 Executed on the iPhone 17 Pro simulator for the first time, the stacked ownership changes exposed real interaction bugs with #217: - Workspace list merges pulled a removed chat's later detail-only re-admission into a list reserved before the removal. - Chat removal minted a fresh summary reservation and cleanup-era Home writes needed the full floor, so unrelated pending-era rows were lost. Removal keeps its deletion token; partial writes are row updates. Test-only corrections: whole-second dates for ISO 8601 round trips, create the cache root before blocking its chats directory, and assert that a fresh detail re-admission owns its Home row (#238 projection). (cherry picked from commit 37b5920) Conflict resolution against #242: #242 already moved the cached-stream check ahead of draft I/O in load(), so that duplicate was dropped. Its committed-write ordering also admits an older create list's own row when the create's detail committed after the omitting list, so create() no longer needs the `!saveChats` fallback. admitCreatedWorkspaceChat stays for the superseded and failed-write create paths carried next. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GAkZRgQzUoKWGpgupF3a4D * fix(ios): superseded create/send read the admitted chat winner A superseded saveChat fell back to cache.loadChat, which reads disk only. saveChat admits the winner in memory before its file write, so a failed winner write left no file (row removed, stream startup aborted) or an older snapshot (rebase onto stale data). Both sites now use cache.admittedChat. Adds failed-write regression tests for both paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GAkZRgQzUoKWGpgupF3a4D (cherry picked from commit eb2dc82) * fix(ios): keep a superseded or failed create's row in the durable list After adopting the admitted winner, the superseded create branch (and the detail disk-failure branch) returned before any workspace-list write, so a failed detail write with a writable list cache lost the created row on an offline cold reopen. Both branches now call admitCreatedWorkspaceChat, which also accepts a newer detail winner only while that winner is newer than the list token, so later removal, purge and newer list omissions win. (cherry picked from commit 1ad6af1) Adjusted for #242: the helper extends the admitted list rows themselves, not the merged memory view, so only the created chat (not other chats' memory-only detail winners) becomes a durable row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GAkZRgQzUoKWGpgupF3a4D * docs(memory): record the #217 follow-up carry onto main Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GAkZRgQzUoKWGpgupF3a4D --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Approval buttons on iOS and Android answer the exact displayed request. Duplicate writes are suppressed, uncertain responses refresh from the Mac, and delayed approval/Stop responses cannot undo a terminal run. Overlapping approval reads publish only the latest valid generation; stale-stream reads cannot supersede it. Stop waits for acknowledgement, reports failures, preserves legacy Workspace compatibility, and requires current Bot grants. Android disables connection retries for these control writes after a disconnect test reproduced repeated POSTs.
Validation: focused Android chat tests pass, including held overlapping snapshots, stale IDs/streams, duplicate taps, real disconnect, revocation, unsupported grants, delayed terminal events and mismatched acknowledgements. Removing the snapshot generation fence makes its regression fail. Full native combined validation with consumer #223 includes 202 passing Android JVM tests and lint. iOS app and XCTest targets compile via unsigned generic-device build-for-testing. Two independent GPT-5.6 Sol medium reviewers cleared the final fixes; review threads are resolved.
Hosted checks at
dd989f54: verify, Android and Pullfrog pass. Electron remains failed because browser.spec.ts:104 passed only on retry; the browser owner is diagnosing it. This is not a green acceptance gate.Physical XCTest execution is blocked by the locked iPhone (
com.apple.dt.deviceprep Code=-3). Compilation is not claimed as an XCTest pass. Queue/Steer consumers are in #223 and require runtime #220; read-only agent inspection is preserved. Nothing is merged or released.Follow-up
5fed6040preserves an authoritative approval read while a prior answer has an ambiguous outcome. Fallback reuse now requires matching stream, client/context, captured card and stream state; deterministic tests cover reads admitted before and after the answer. Both independent reviewers clear; focused Android tests and iOS test compilation pass. Current head0d0ca7716also carries only the separate capacity-test assertion fix from4c00c968; the focused check passes. Combined validation at948c4def4passes 204 Android tests, lint, instrumentation compilation, 157 host checks and unsigned iOS test compilation. New-head hosted checks are pending; earlier checks are historical evidence only.