Skip to content

fix(android): require explicit retry after interrupted sends - #103273

Merged
steipete merged 23 commits into
openclaw:mainfrom
NianJiuZst:codex/fix-android-outbox-ambiguous-delivery
Jul 11, 2026
Merged

steipete merged 23 commits into
openclaw:mainfrom
NianJiuZst:codex/fix-android-outbox-ambiguous-delivery

Conversation

@NianJiuZst

@NianJiuZst NianJiuZst commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where Android could resend a chat command after the app was killed or disconnected after the gateway accepted it but before the local outbox row was deleted.

Why This Change Was Made

Interrupted sending rows and post-dispatch unknown outcomes now become visible failed rows with a delivery-unconfirmed reason. Only requests known not to have entered the socket queue and requests definitively rejected by the gateway remain eligible for automatic retry. The existing user-driven Retry action is the only path that can replay an ambiguous command.

User Impact

Android no longer silently repeats agent runs or tool side effects after a crash, timeout, or disconnect when durable gateway deduplication is unavailable. Users can inspect, delete, or explicitly retry an affected command.

Evidence

  • Exact reviewed head: 8b27ba8e8f13f0162b29de8ae04fcf6b38a40b9f; tree: 9fd8b86ce04d02c43ba05634801f210404c301da.
  • Testbox tbx_01kx6ge0n3rg6e8syvh8nryvvv independently fetched the pull ref, asserted the exact SHA/tree and clean checkout, then passed 37 focused tests across the controller outbox, Room persistence, and a real MockWebServer disconnect/outcome-unknown path.
  • The same Testbox overlaid the dropped-ACK regression test on current main; the isolated test failed there as intended because the old path automatically replays the dispatched command. A harness-only message grep then made that delegated job report failure before its changed gate.
  • Exact-head hosted Android CI 29109968978 passed both Android test variants, APK build, ktlint, native i18n, preflight, and security checks.
  • :app:ktlintFormat, :app:ktlintCheck, and git diff --check passed before the final push.
  • Fresh full-diff autoreview: clean, no actionable findings, correctness confidence 0.94.

AI-assisted: built with Codex.

@NianJiuZst
NianJiuZst marked this pull request as ready for review July 10, 2026 05:12
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 10, 2026
@clawsweeper

clawsweeper Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 10, 2026, 3:35 PM ET / 19:35 UTC.

Summary
The PR changes Android durable outbox recovery, acknowledgement classification, Room migration, and retry transitions so ambiguous sends require explicit user retry.

PR surface: Other +1020. Total +1020 across 8 files.

Reproducibility: yes. from current-main source and the supplied negative-control evidence: a dropped acknowledgement can cause the old durable outbox path to dispatch the same command again. I did not independently execute the scenario during this read-only review.

Review metrics: 1 noteworthy metric.

  • Persisted upgrade surface: 1 Room schema version bump and 1 row-rewriting migration. Existing durable outbox rows change state during upgrade, so compatibility evidence matters before merge.

Stored data model
Persistent data-model change detected: migration/backfill/repair: apps/android/app/src/main/java/ai/openclaw/app/chat/ChatTranscriptCache.kt, migration/backfill/repair: apps/android/app/src/test/java/ai/openclaw/app/chat/ChatCacheDatabaseMigrationTest.kt, persistent cache schema: apps/android/app/src/test/java/ai/openclaw/app/chat/ChatCacheDatabaseMigrationTest.kt. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Root-cause cluster
Relationship: canonical
Canonical: #103273
Summary: This PR now contains the complete current candidate, while the related PR preserves only the earlier narrower repair.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦐 gold shrimp
Patch quality: 🐚 platinum hermit
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted exact-head Testbox or emulator evidence covering dropped ACK, process restart, explicit Retry, and Room v2→v3 upgrade behavior.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The linked Testbox evidence strongly proves the earlier 8b27ba8e head, but the current a17909a head adds migration and durability behavior; add redacted exact-head Testbox or emulator evidence, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.

Risk before merge

  • [P1] The Room v2→v3 migration rewrites durable user-input rows during upgrade, and the final head has not been demonstrated in a real installation or Testbox upgrade scenario.
  • [P1] The deliberate change from automatic replay to explicit user retry is compatibility-sensitive for users whose sends time out, disconnect, or are interrupted during process shutdown.
  • [P1] Landing the narrower related PR instead would omit the later migration and durability barriers now present on this branch.

Maintainer options:

  1. Prove the final persisted-state behavior (recommended)
    Run the exact current head through dropped-ACK, process-restart, explicit Retry, and Room v2→v3 upgrade scenarios before merge.
  2. Own the proof waiver
    Merge based on deterministic tests and hosted CI while explicitly accepting that final upgrade and recovery behavior was not demonstrated in a real setup.

Next step before merge

  • [P1] No concrete code repair remains; maintainers should require or explicitly waive exact-head real-behavior and upgrade proof, then consolidate the duplicate branch.

Maintainer decision needed

  • Question: Must this PR provide fresh real-behavior proof for head a17909a before merge, or will maintainers explicitly accept the earlier-head Testbox evidence for the final migration and durability additions?
  • Rationale: The code and hosted checks are clean, but repository policy treats after-fix real setup evidence as a merge gate for an external PR, and the cited Testbox run predates material persisted-state changes.
  • Likely owner: steipete — The live assignee authored the final hardening commits and previously supplied the proof assessment for the earlier head.
  • Options:
    • Require exact-head proof (recommended): Obtain redacted Testbox or emulator evidence covering the final dropped-ACK, restart, Retry, and v2→v3 upgrade paths before merge.
    • Accept earlier-head proof: Explicitly waive source drift and merge based on deterministic tests and hosted CI without real setup proof for the final additions.

Security
Cleared: The Android source and test changes introduce no dependency, workflow-permission, secret-handling, downloaded-code, or other concrete security or supply-chain concern.

Review details

Best possible solution:

Rebase this complete branch, attach redacted exact-head Testbox or emulator proof for dropped acknowledgement, restart recovery, explicit Retry, and Room v2→v3 upgrade behavior, then close the narrower replacement as superseded.

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

Yes, from current-main source and the supplied negative-control evidence: a dropped acknowledgement can cause the old durable outbox path to dispatch the same command again. I did not independently execute the scenario during this read-only review.

Is this the best way to solve the issue?

Yes. Typed gateway outcomes, serialized restart recovery, gateway-scoped retry transitions, and durable persistence barriers address the defect at the Android transport/outbox boundary without creating a second retry source of truth.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1bcc4c5e7063.

Label changes

Label justifications:

  • P1: The underlying Android defect can silently repeat agent runs or tool side effects after an ambiguous delivery outcome.
  • merge-risk: 🚨 compatibility: The PR changes persisted upgrade handling and replaces automatic ambiguous-send recovery with explicit user retry.
  • merge-risk: 🚨 message-delivery: The state machine directly controls whether durable commands are replayed, parked, removed, or exposed for Retry.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The linked Testbox evidence strongly proves the earlier 8b27ba8e head, but the current a17909a head adds migration and durability behavior; add redacted exact-head Testbox or emulator evidence, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.
Evidence reviewed

PR surface:

Other +1020. Total +1020 across 8 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 8 1231 211 +1020
Total 8 1231 211 +1020

What I checked:

  • Exact-head proof gap: The PR body and maintainer proof cite head 8b27ba8e, while the live head is a17909a and includes later migration, persistence-barrier, and flush-coalescing commits not exercised by that Testbox run. (a17909afb379)
  • Current-head validation: The live head passes both Android test variants, APK build, ktlint, preflight, security-fast, and the repository proof-presence check, resolving the prior review's test and formatting findings. (a17909afb379)
  • Closed delivery state machine: The final send path durably claims rows, automatically requeues only requests known not to have entered the socket queue, parks ambiguous delivery as failed, and blocks younger work when persistence cannot safely advance. (apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt:1563, a17909afb379)
  • Upgrade migration: The branch bumps the Room schema from v2 to v3, parks legacy queued-error and interrupted-sending rows as delivery-unconfirmed, preserves pristine queued and failed rows, and limits destructive fallback to transcript-only v1 databases. (apps/android/app/src/main/java/ai/openclaw/app/chat/ChatTranscriptCache.kt:159, a17909afb379)
  • Gateway acknowledgement contract: Gateway started, in_flight, and ok responses include the client run/idempotency ID, so the Android branch's conservative handling of run-ID-less responses addresses malformed input rather than rejecting a normal response. (src/gateway/server-methods/chat.ts:3981, 1bcc4c5e7063)
  • Related branch comparison: The related replacement contains the earlier four-file repair, while this branch additionally includes the Room migration, acknowledgement handling, retry ownership guards, durable persistence barriers, and flush coalescing. (a17909afb379)

Likely related people:

  • steipete: Authored the final acknowledgement, migration, persistence-barrier, and flush-coalescing changes and is assigned to the live PR. (role: recent area contributor and assignee; confidence: high; commits: e2724667411e, e829013fe638, 33b509ee3a45; files: apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt, apps/android/app/src/main/java/ai/openclaw/app/chat/ChatTranscriptCache.kt)
  • Vincent Koc: Commit daa653c introduced the current Android outbox files and the original recovery and automatic-retry implementation being corrected. (role: introduced current Android outbox behavior; confidence: medium; commits: daa653c5cc34; files: apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt, apps/android/app/src/main/java/ai/openclaw/app/chat/ChatCommandOutbox.kt)
  • Ayaan Zaidi: Recent merged history shows repeated maintenance of Android chat identity, queue, and controller behavior adjacent to this state machine. (role: recent Android chat contributor; confidence: medium; commits: 34a5c47351d1, a41be2585fca; files: apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-10T18:45:06.913Z sha 15ee1925d85451b9e3af31889752e4f4912a875a :: needs real behavior proof before merge. :: [P1] Reconcile delivered rows before offering Retry | [P2] Make the Room upgrade regression pass | [P2] Restore the reconnect thinking regression | [P2] Format the acknowledgement status chain

@steipete steipete self-assigned this Jul 10, 2026
@steipete
steipete force-pushed the codex/fix-android-outbox-ambiguous-delivery branch 4 times, most recently from 8f9dca2 to d34e4ac Compare July 10, 2026 16:54
@steipete
steipete force-pushed the codex/fix-android-outbox-ambiguous-delivery branch from d34e4ac to 8b27ba8 Compare July 10, 2026 17:09
@clawsweeper

clawsweeper Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(android): require explicit retry after interrupted sends This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete

steipete commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Land-ready proof after final maintainer fixups. Thanks @NianJiuZst for identifying the interrupted-send replay risk and supplying the initial persistence regression.

Best-fix verdict: the final patch carries the Gateway's typed delivery outcome into one closed Android outbox state machine. A request known not to be enqueued remains automatically retryable; a definitive Gateway rejection consumes the bounded retry budget; a post-dispatch timeout/disconnect or process-interrupted Sending row becomes visible as delivery-unconfirmed and requires explicit Retry. Startup recovery is serialized and blocks younger queued work if recovery itself fails.

Exact proof at head a17909afb379870b182d4e71785da4e1cf9b5b9c:

  • Hosted CI 29117589199 is green, including both Android test variants, Play APK build, ktlint, native i18n, preflight, and security-fast.
  • Sanitized AWS live run run_83aa208e9121 built and installed the exact-head third-party APK on an API 36 AOSP ATD emulator and onboarded through the normal UI.
  • The relay forwarded one chat.send, observed the Gateway accept it with status started, and dropped only that acknowledgement. The app showed delivery unconfirmed; retry manually with visible Retry.
  • Send count remained exactly 1 through another reconnect, a real force-stop/process restart, and a visible Refresh that completed successful chat.history and health responses.
  • Android recorded PID 2671 being killed and PID 5290 starting MainActivity; the failed row and Retry action survived that restart.
  • Immediately before the user action, send count was still 1. One visible Retry produced exactly one second send, and both nonempty idempotency keys were byte-identical.
  • Independent source-blind validation passed every behavior-contract and anti-cheat check with no blocking gap.
  • Fresh full-diff autoreview is clean: no findings, patch correct, confidence 0.86.
  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 103273 passed the repository-native exact-head hosted gates and confirmed the remote PR head still matches this SHA.

Known gap: no physical-device or Play Store smoke. The exact installed API 36 flow covers the affected user-visible lifecycle, reconnect, persistence, Refresh, and Retry behavior.

No remaining merge blocker.

@steipete
steipete force-pushed the codex/fix-android-outbox-ambiguous-delivery branch from 8b27ba8 to 4f06021 Compare July 10, 2026 17:28
@clawsweeper clawsweeper Bot removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 10, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 10, 2026
@clawsweeper

clawsweeper Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(android): require explicit retry after interrupted sends This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete
steipete force-pushed the codex/fix-android-outbox-ambiguous-delivery branch from 4f06021 to afb654a Compare July 10, 2026 17:44
@steipete
steipete force-pushed the codex/fix-android-outbox-ambiguous-delivery branch from 15ee192 to 932f4ed Compare July 10, 2026 19:08
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 10, 2026
@steipete
steipete merged commit df36c82 into openclaw:main Jul 11, 2026
53 of 55 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

steipete added a commit that referenced this pull request Jul 11, 2026
…f retirement

Every chat send is journaled to the per-gateway Room outbox before any
network attempt, so process death always has one durable recovery owner.
Rows survive gateway ACKs as 'accepted' and retire only once the turn is
proven in canonical chat.history by idempotency key; ambiguous outcomes
(lost ACK, kill mid-send, gateway restart before the transcript write)
park as delivery-unconfirmed for explicit retry, per the fail-closed
model #103273 landed. An unproven accepted head briefly holds only its
own session's queue, and retrying a parked head re-orders still-queued
successors behind it. Offline sends now accept picked images and voice
notes; attachment bytes persist as chunked BLOBs (512 KB chunks, 8 MB
per message, 48 MB per gateway) admitted and retired atomically with
their row. Pre-hello 'main' rows pin to the canonical session at first
dispatch so later default-agent changes cannot retarget captured input;
slash commands are connection-gated by a persisted epoch (legacy queued
command rows migrate to a never-matching sentinel) and never auto-replay
across reconnects. The Room store moves to schema v4 on top of v3's
data-parking migration, adding the epoch column and attachment tables
while preserving queued rows. The queued->sending claim is an atomic
compare-and-set shared by the direct dispatch and the flush loop, the
direct path waits for the startup recovery sweep before claiming, and
failed reconnect attempts republish outbox rows so queued sends stay
visible on offline cold starts.

Proof: 1151 Android unit tests and :app:ktlintCheck green (new
migration, storage, and controller coverage for admission, restarts,
claims, pinning, gating, ordering, and byte round-trips); a live
emulator scenario on the pre-integration build queued text+image
offline, survived force-stop plus a device reboot, resent exactly once
on reconnect (single <rowId>:user turn in the gateway transcript), and
drained the outbox after canonical-history confirmation.

Closes #104087.
steipete added a commit that referenced this pull request Jul 11, 2026
…f retirement (#104089)

* feat(android): durable offline chat with attachments and history-proof retirement

Every chat send is journaled to the per-gateway Room outbox before any
network attempt, so process death always has one durable recovery owner.
Rows survive gateway ACKs as 'accepted' and retire only once the turn is
proven in canonical chat.history by idempotency key; ambiguous outcomes
(lost ACK, kill mid-send, gateway restart before the transcript write)
park as delivery-unconfirmed for explicit retry, per the fail-closed
model #103273 landed. An unproven accepted head briefly holds only its
own session's queue, and retrying a parked head re-orders still-queued
successors behind it. Offline sends now accept picked images and voice
notes; attachment bytes persist as chunked BLOBs (512 KB chunks, 8 MB
per message, 48 MB per gateway) admitted and retired atomically with
their row. Pre-hello 'main' rows pin to the canonical session at first
dispatch so later default-agent changes cannot retarget captured input;
slash commands are connection-gated by a persisted epoch (legacy queued
command rows migrate to a never-matching sentinel) and never auto-replay
across reconnects. The Room store moves to schema v4 on top of v3's
data-parking migration, adding the epoch column and attachment tables
while preserving queued rows. The queued->sending claim is an atomic
compare-and-set shared by the direct dispatch and the flush loop, the
direct path waits for the startup recovery sweep before claiming, and
failed reconnect attempts republish outbox rows so queued sends stay
visible on offline cold starts.

Proof: 1151 Android unit tests and :app:ktlintCheck green (new
migration, storage, and controller coverage for admission, restarts,
claims, pinning, gating, ordering, and byte round-trips); a live
emulator scenario on the pre-integration build queued text+image
offline, survived force-stop plus a device reboot, resent exactly once
on reconnect (single <rowId>:user turn in the gateway transcript), and
drained the outbox after canonical-history confirmation.

Closes #104087.

* fix(android): rearm outbox recovery when direct-send state persistence fails

* fix(android): keep direct dispatch alive across caller cancellation

The direct send's network phase now runs in the controller scope, so a
cancelled UI scope (leaving the chat screen mid-send) can no longer
strand a claimed row in 'sending' with no user action available; the
dispatch completes and settles the row exactly once. Direct-path state
persistence failures also re-arm the startup recovery sweep, mirroring
the flush path's fail-closed handling.

* fix(android): hand claim-persistence failures to the flush lane

A direct-send claim that fails to persist no longer reads as a lost race:
the admitted row is handed to the flush lane so a healthy connection still
delivers it, and the flush path's fail-closed handling owns any repeated
storage failure instead of the UI reporting success with no active owner.

* fix(android): enforce connection gating and fail-closed parking on every send path

The direct dispatch now rechecks a slash command's connection epoch after
its durable claim, so a reconnect between admission and dispatch parks the
command instead of replaying it on the new connection. Parking a stale
gated row only counts once the write persists; a storage failure drops
health, re-arms recovery, and halts the flush pass instead of spinning or
dispatching the stale row.

* fix(android): recognize gateway-acknowledged run ids in outbox ownership checks

A chat.send ACK can return a run id that differs from the row's
idempotency key (the direct path transfers local run ownership to it).
Ownership, in-flight, backlog, and timeout-park checks now consider both
ids, so reconciliation can no longer park — and Retry can no longer
duplicate — a turn that is still running on the gateway.

* fix(android): close remaining ack-ownership and persistence-failure gaps in the outbox

Flushed sends acked under a divergent run id now transfer local run
ownership like the direct path, so live runs cannot time out and surface
spurious errors for delivered turns. A session pin that cannot persist
stops the dispatch while the row is still safely queued. Reconcile and
timeout parking only report changes their writes actually persisted,
failing closed on storage errors.

* docs(android): record why acknowledged run ids stay in-memory
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 11, 2026
…w#103273)

* fix(android): require retry after interrupted outbox sends

* fix(android): fail ambiguous outbox sends closed

Co-authored-by: NianJiuZst <[email protected]>

* fix(android): preserve run-id-only acknowledgements

* style(android): format outbox assertion

* fix(android): fail outbox recovery closed

Co-authored-by: NianJiuZst <[email protected]>

* test(android): prove dropped ack is not replayed

Co-authored-by: NianJiuZst <[email protected]>

* fix(android): accept terminal outbox acknowledgements

Co-authored-by: NianJiuZst <[email protected]>

* fix(android): persist rejected outbox retries

Co-authored-by: NianJiuZst <[email protected]>

* fix(android): require manual retry after transmitted failures

* fix(android): migrate ambiguous outbox rows safely

* test(android): import outbox cancellation type

* fix(android): limit destructive chat cache migration

* fix(android): guard outbox retry transitions

* fix(android): reject malformed chat acknowledgements

* test(android): type migration bind arguments

* test(android): separate migration and replay proof

* fix(android): accept admitted outbox acknowledgements

* fix(android): preserve gateway health after acknowledged outbox failures

* fix(android): stop outbox flush on persistence failure

* fix(android): stop outbox flush when claims fail

* fix(android): enforce durable outbox barriers

* fix(android): coalesce outbox flush requests

* style(android): format outbox assertions

---------

Co-authored-by: NianJiuZst <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 11, 2026
…f retirement (openclaw#104089)

* feat(android): durable offline chat with attachments and history-proof retirement

Every chat send is journaled to the per-gateway Room outbox before any
network attempt, so process death always has one durable recovery owner.
Rows survive gateway ACKs as 'accepted' and retire only once the turn is
proven in canonical chat.history by idempotency key; ambiguous outcomes
(lost ACK, kill mid-send, gateway restart before the transcript write)
park as delivery-unconfirmed for explicit retry, per the fail-closed
model openclaw#103273 landed. An unproven accepted head briefly holds only its
own session's queue, and retrying a parked head re-orders still-queued
successors behind it. Offline sends now accept picked images and voice
notes; attachment bytes persist as chunked BLOBs (512 KB chunks, 8 MB
per message, 48 MB per gateway) admitted and retired atomically with
their row. Pre-hello 'main' rows pin to the canonical session at first
dispatch so later default-agent changes cannot retarget captured input;
slash commands are connection-gated by a persisted epoch (legacy queued
command rows migrate to a never-matching sentinel) and never auto-replay
across reconnects. The Room store moves to schema v4 on top of v3's
data-parking migration, adding the epoch column and attachment tables
while preserving queued rows. The queued->sending claim is an atomic
compare-and-set shared by the direct dispatch and the flush loop, the
direct path waits for the startup recovery sweep before claiming, and
failed reconnect attempts republish outbox rows so queued sends stay
visible on offline cold starts.

Proof: 1151 Android unit tests and :app:ktlintCheck green (new
migration, storage, and controller coverage for admission, restarts,
claims, pinning, gating, ordering, and byte round-trips); a live
emulator scenario on the pre-integration build queued text+image
offline, survived force-stop plus a device reboot, resent exactly once
on reconnect (single <rowId>:user turn in the gateway transcript), and
drained the outbox after canonical-history confirmation.

Closes openclaw#104087.

* fix(android): rearm outbox recovery when direct-send state persistence fails

* fix(android): keep direct dispatch alive across caller cancellation

The direct send's network phase now runs in the controller scope, so a
cancelled UI scope (leaving the chat screen mid-send) can no longer
strand a claimed row in 'sending' with no user action available; the
dispatch completes and settles the row exactly once. Direct-path state
persistence failures also re-arm the startup recovery sweep, mirroring
the flush path's fail-closed handling.

* fix(android): hand claim-persistence failures to the flush lane

A direct-send claim that fails to persist no longer reads as a lost race:
the admitted row is handed to the flush lane so a healthy connection still
delivers it, and the flush path's fail-closed handling owns any repeated
storage failure instead of the UI reporting success with no active owner.

* fix(android): enforce connection gating and fail-closed parking on every send path

The direct dispatch now rechecks a slash command's connection epoch after
its durable claim, so a reconnect between admission and dispatch parks the
command instead of replaying it on the new connection. Parking a stale
gated row only counts once the write persists; a storage failure drops
health, re-arms recovery, and halts the flush pass instead of spinning or
dispatching the stale row.

* fix(android): recognize gateway-acknowledged run ids in outbox ownership checks

A chat.send ACK can return a run id that differs from the row's
idempotency key (the direct path transfers local run ownership to it).
Ownership, in-flight, backlog, and timeout-park checks now consider both
ids, so reconciliation can no longer park — and Retry can no longer
duplicate — a turn that is still running on the gateway.

* fix(android): close remaining ack-ownership and persistence-failure gaps in the outbox

Flushed sends acked under a divergent run id now transfer local run
ownership like the direct path, so live runs cannot time out and surface
spurious errors for delivered turns. A session pin that cannot persist
stops the dispatch while the row is still safely queued. Reconcile and
timeout parking only report changes their writes actually persisted,
failing closed on storage errors.

* docs(android): record why acknowledged run ids stay in-memory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: android App: android merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants