Repository navigation
Preserve Android turn receipts across response ownership changes - #227
sambitcreate merged 2 commits into
Conversation
|
Run failed. View the logs →
|
Hermes Review BotConfidence: 5 Engine: SummaryAndroid turn receipt processing now reserves a cache write token prior to initiating a turn request and admits 202 Accepted responses through Confidence Score: 5/5Fully traced and verified end-to-end across 📁 Important Files Changed
FindingsNo findings. 📊 Sequence DiagramsequenceDiagram
autonumber
participant VM as AidenChatViewModel
participant Cache as AidenChatCache
participant Server as Aiden Server
participant SSE as Event Stream
VM->>Cache: reserveChatWrite() (requestToken)
VM->>Server: POST /turns (with idempotencyKey)
Server-->>VM: 202 Accepted (turnId, streamId, message)
VM->>Cache: acceptTurnReceipt(candidate, message, stream, instanceId, requestToken)
activate Cache
Cache->>Cache: mergeReceipt into admitted winner
Cache->>Cache: register receipt in receiptMessages overlay
Cache->>Cache: update receiptStreams in memory
Cache-->>VM: AcceptedTurn(chat, stream)
deactivate Cache
VM->>VM: Update _chat StateFlow
VM->>SSE: startStreaming(accepted.stream)
Machine-Readable Findings[]
|
19e689d
into
feature/mobile-response-ownership
* 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
* 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>

A successful Android turn receipt could arrive after another chat view settled the transcript and replace the newer messages. It could also recreate a purged stream, or treat a local disk failure as a failed send after the server had already accepted the POST.
Reserve ownership before the POST and admit the receipt atomically. Preserve the newer transcript and metadata, merge the accepted message once under request-origin authority, and keep stream ownership separate so an older receipt cannot replace a newer stream. Removal and purge invalidate the original receipt authority even after fresh chat re-admission. Accepted receipts retain an in-memory recovery path when persistence fails; no POST is replayed.
This focused draft is stacked on green PR225. PR217/225 heads are unchanged. iOS rename/list/Bot response ownership and physical acceptance remain separate assigned work.
Validation:
Evidence:
.memory/mobile-turn-receipt-ownership.md. No merge, release, or deployment.Completion-order correction: an accepted receipt no longer reserves a new detail or summary ticket. Both POST-first and GET-first held response orders preserve the later GET’s authoritative fields and the accepted stream. Requests already in flight at receipt acceptance retain missing receipt messages through a bounded overlay; a fresh post-receipt snapshot retires it, and deletion/purge clear it. Both inverse ordering failures were executed before correction, including a GET that omitted the accepted message. Fresh-snapshot retirement and delayed-old-read rejection are covered. Final local evidence:186 JVM tests/lint/instrumentation compilation, with both independent GPT-5.6 Sol medium final reviews clear for this correction; hosted CI must run on the corrected head.
Concurrent POST receipts accumulate all still-pending accepted messages in either completion order. The held two-POST regression fails before this correction and now preserves both messages once, the newer stream, and exactly two submitted POSTs.
Exact-head hosted acceptance:3f7154e7b2f9830bf3573ee00334ffc5ec121ddb passes verify, Android build/APK and Deterministic Electron E2E (workflow35770159276; E2E completed2026-09-22 19:26:51 UTC). No unresolved review threads. Combined integration691aed63d accepted213 Android tests/157 host tests and both independent reviews; newer combined3c23dad2b preserves this correction. Physical acceptance remains unexecuted; broader iOS ownership work remains separate and open.