fix(mobile): stream and event durability - #4987
Conversation
Groups 2 and 3 were formatted with prettier, which this repo does not declare. Reformat the affected files with oxfmt. No code changes.
Code Review SummaryStatus: 2 Issues Found | Recommendation: Merge — both remaining findings are carried items with recorded author dispositions; the new tmux keep-alive test fix and both main-merge conflict resolutions introduce no new issues. Executive SummaryThe incremental scope — a tmux keep-alive fix for the stale-environment test plus two merges of Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (7 files, incremental)
Fix these issues in Kilo Cloud Previous Review Summaries (7 snapshots, latest commit 3f12c37)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 3f12c37)Status: 2 Issues Found | Recommendation: Merge — both remaining findings are carried items with recorded author dispositions; every previously flagged new issue is resolved in the latest commits. Executive SummaryThe incremental changes correctly close the Overview
Issue Details (click to expand)WARNING
SUGGESTION
Resolved in new commits
Files Reviewed (2 files, incremental)
Fix these issues in Kilo Cloud Previous review (commit fc4c6c8)Status: 4 Issues Found | Recommendation: Address before merge Executive SummaryThe new cross-sweep claim gates close the double-delivery window and the initial-write rejection path now cleans its stash, but the same change removed the only Overview
Issue Details (click to expand)WARNING
SUGGESTION
Resolved in new commits
Files Reviewed (2 files, incremental)
Fix these issues in Kilo Cloud Previous review (commit 57e4530)Status: 4 Issues Found | Recommendation: Address before merge Executive SummaryThe new terminal-write fencing closes the live-send-vs-durable-write window, but the concurrent durable-sweep double-delivery gap remains open, and the new initial-write rejection path leaks the stashed terminal entry and fence marker until Durable Object eviction. Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (2 files, incremental)
Fix these issues in Kilo Cloud Previous review (commit fe32137)Status: 3 Issues Found | Recommendation: Address before merge Executive SummaryThe new durable terminal-delivery paths close the memory-vs-durable duplicate window but leave a sweep-vs-sweep gap: two concurrent durable terminal sweeps (expiry on every web command/alarm vs CLI-disconnect/owner-change) read the same stale storage snapshot and can both deliver terminal responses for one correlationId; the author-acknowledged done-entry cap counting and a rejected comment typo carry forward unchanged. Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (2 files, incremental)
Fix these issues in Kilo Cloud Previous review (commit b06820c)Status: 2 Issues Found | Recommendation: Address before merge Executive SummaryThe latest commit verifiably fixes the two open UserConnectionDO warnings — the rehydrated-path duplicate window is now fenced by a synchronous Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (2 files, incremental)
Fix these issues in Kilo Cloud Previous review (commit 3c3a5f7)Status: 3 Issues Found | Recommendation: Address before merge Executive SummaryThe latest commits verifiably fix 7 prior findings (durable result bounding below the 128 KiB DO limit, kiloclaw synced-schema regeneration, rehydration/live expiry guards, bounded mutationId, fromId=0 replay closing the materialization gap, raised zombie-close threshold, resync state ordering), while the three previously reported UserConnectionDO warnings — rehydrated-path duplicate delivery, completion-marker leak on a failed durable put, and the recorded D8 done-entry cap counting — remain open on current HEAD. Overview
Issue Details (click to expand)WARNING
Files Reviewed (11 files, incremental)
Fix these issues in Kilo Cloud Previous review (commit b833068)Status: 3 Issues Found | Recommendation: Address before merge Executive SummaryThe follow-up commit verifiably fixes 8 of 9 previous findings (durable result bounding below the 128 KiB DO limit, kiloclaw sync regeneration, rehydration/live expiry guards, bounded mutationId, Overview
Issue Details (click to expand)WARNING
Files Reviewed (11 files, incremental)
Reviewed by kimi-k3 · Input: 97.7K · Output: 19.4K · Cached: 1.3M Review guidance: REVIEW.md from base branch |
Persist terminal outcomes before delivery and prevent duplicate responses during CLI disconnect and ownership changes.
Keep durable write ordering assertions type-safe in the session ingest tests.
Keep terminal command outcomes durable while delayed initial writes settle.
Reserve terminal durable correlations across concurrent sweep paths.
Drop expired durable correlation markers after their done entries expire.
…bility-75e6 # Conflicts: # apps/mobile/src/lib/trpc.test.ts # apps/mobile/src/lib/trpc.ts
set-environment -g fails when no tmux server is running, which broke the test on CI runners without a leftover server (and on main).
Summary
Why
Mobile streams, remote CLI commands, and Event Service state could lose updates, duplicate updates, or hang during lifecycle changes.
How
seq, ack, gap detection, and consumer resync invalidation without an Event Service event log.AbortControllerplussetTimeoutdeadline helper because Hermes does not reliably provide static AbortSignal helpers.Evidence and decisions
/streamderivesCLOUD_AGENT_SESSIONfrom${userId}:${cloudAgentSessionId}inservices/cloud-agent-next/src/server.ts:316-318, so the event table andmax(events.id)are session-local.getSessionMessagesPagereadsgetSession(...).latestEventIdbefore the history page. The stream-ticket route remains rejected because it reads no Durable Object state and the client fetches ticket and page concurrently.replay=falserule, so they remain unchanged.execution_idis non-unique, so IDs remain monotonic across execution changes.activeContextsis refcounted andon()returns per-handler unsubscribe.Unknown; agedlastAtrendersIdleorOfflineinbot-send-state.ts.useBotStatuscallers: both mobile conversation screens were updated for active-state polling.hasAttachmentsCapabilitystill checks the filtered list.onResync; no Event Service consumer needs background delivery. Screen subscriptions release on blur, and push plus AppState invalidation handles badges.CloudAgentSession.cleanupOldEventsretains events forLimits.SESSION_TTL_MS; this section does not change it.CloudAgentSession.cleanupOldEvents; listener isolation inEventServiceClient.activeContexts; device-network banner inConnectivityBanner.Verification
pnpm typecheckpnpm lintpnpm format:checkkilo-auto/efficient: iOS stream reconnect, remote CLI reconstruction, and iOS plus Android background/foreground lifecycle. The live harness has no force-hibernate control, so EV-03 used mid-flight background reconstruction.kilo_pixel7; the workflow now fails fast on AVD contention. This run used freekilo_pixel9_api35and did not stop the foreign emulator.Visual Changes
N/A