fix(android): record sync intents ONLY on legacy-call failure (record-on-failure, F1) #1365
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/sync-intent-ledger-hygiene"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
PR-2 of the 4-PR sync hardening plan (oracle finding F1, HIGH). Base: origin/main
ca438b67(0.10.4) per orchestrator.Problem
The three delete/restore call sites (TimelineViewModel multi-select delete, MediaViewerViewModel delete/restore, TrashViewModel restore) performed the mutation via the LEGACY endpoints and recorded an intent into the Room queue ("record-first", PR-C). The replayed intent's CAS was necessarily stale (
expectedLifecycleState=activevs. item alreadytrashed) → every engine drain seeded the ledger with meaninglessconflict_state_changedREJECTED rows → reject copy surfaced for actions that had SUCCEEDED.Design — record-on-failure (oracle option b, ratified)
The queue becomes the durable RETRY channel, not shadow bookkeeping:
expectedLifecycleState=null): the landing is unknown, so only the server's idempotent C4 goal table may judge the replay (delete-already-deleted / restore-already-active = idempotent ACCEPT). This eliminates the stale-CAS noise class entirely. Verified againstSyncIntentService.reconcileDelete/reconcileRestoredecision tables.not_owner— ledger hygiene).Rejected alternative (oracle option a, intents-only): dropping the legacy calls would delay deletion until the next engine drain; a pull-before-drain would resurrect the just-deleted item in the timeline — broken UX, not viable. Documented in the spec amendment.
Ledger hygiene for existing noise: existing bogus REJECTED rows are historical — left in place as honest history; the drain/purge housekeeping ages them out. No one-time cleanup (a deletion would falsify history and buys nothing).
Untouched by design:
RemovedHistoryViewModel(S11 revert) records unconditionally — its queue write IS the action (intents-only path); also fixed in passing:TrashViewModel.mutate(shared by restore/permanentDelete) now takes an explicit retry type, so a failed permanent delete never queues (it is not an S3 v1 intent type).Spec amendment (spec 044 only)
specs/044-android-backup-app/spec.jsonS3 "Intent path" bullet rewritten to the ratified transitional reality (legacy = immediate mutation path; intents = record-on-failure durable retry; endpoint exists for sync-visible mutations from other/queued contexts), provenance markedRE-AMENDED 2026-10-24, intent-ledger hygiene; description tail gains a FURTHER AMENDED sentence. Edited and verified throughspec-query(sanctioned writer reproduces the file byte-identically).spec-md/specs/044/spec.mdregenerated with the official exporter (scripts/spec-query.py export --out spec-md, same as the CI job); verified the regenerated file differs from the pre-edit export only in the amendment itself. Unrelated pre-existing drift in other spec-md files left to CI (exporter script is byte-identical to main's).Tests (all green)
:core:test+:app:testDebugUnitTest→ 805 tests, 0 failures (664 app + 141 core). New cases:(type, id, expectedLifecycleState=null).ClientIntentQueueTestidempotency suite untouched and green; new CAS-free-row drain test pins the verbatim null-CAS replay and the idempotent ACCEPT.Notes for the orchestrator
KNOWN_ISSUES.md: the pre-assigned ISSUE-194 was taken by the merged issues-audit (PR #1361; main now has ISSUE-194/195/197) — appended as ISSUE-198 (next free) with a historical note; expect a trivial merge conflict in that file against current main.:app:lintDebugfails with 42 errors identical on clean main (pre-existing, not in this lane's gate).ca438b67as pinned; no file overlap with main's 7 newer commits except the KNOWN_ISSUES append noted above.66780fb83035e831b818