Fix interrupted sweep presentation recovery - #13
spiky02plateau wants to merge 1 commit into
Conversation
…rds (#37) A source run recorded for claimed recollection work advanced the source checkpoint before any card existed, so an agent that died between judging and presenting silently checkpointed kept mail as handled (the incident behind #13). Checkpoints recorded with --work now stay on the run until work:complete succeeds, inside the same transaction; completion is refused until every review judgment has a card the user can see now or has acted on since the run, and routine_action judgments are covered by cards or by routine action groups proposed since the sweep. A recollection that fails after recording its batch re-offers searching again; the newest run per source owns its checkpoint and a held checkpoint is not written over one that changed after the run was recorded; source and run mirrors are routed through the MirrorWriteCoordinator so refusals leave files untouched. Work-less runs and runs from older builds behave as before. Verified: CI green (build/test/smoke, Supabase, iOS); local replica with Bun 1.3.11 (466 tests on main plus this branch); four Codex review passes with all findings addressed.
|
Thanks for the detailed report and PR. The incident was real: an agent that died between judging and presenting had already checkpointed the kept mail as handled, and nothing pointed at it afterwards. We fixed the underlying problem on main with a narrower change in #37: checkpoints recorded for claimed recollection work now stay on the run until work:complete succeeds, completion is refused until every review judgment has a card the user can actually see (and routine items have a card or a proposed routine group), a recollection that fails after recording its batch re-offers searching again, and a held checkpoint is never written over one that moved in the meantime. We deliberately kept the existing contract rather than requiring a cardId on every judgment, adding recovery cards, or blocking other work while a sweep is pending, which is why we went with our own fix instead of rebasing this one. Closing in favor of that; if you hit a case the narrower fix doesn't cover, please open an issue and we'll look. |
Summary
cardIdobligationssweep:status, including legacy incomplete-batch detectionIncident addressed
An Inbox source run and sweep batch could become current and advance the Gmail checkpoint before later
card:upsertcommands completed.If the agent backend failed while preparing card payloads, kept judgments remained durable but no user-visible card represented them.
The new two-phase protocol keeps the prior batch and checkpoints current until all declared presentations exist.
It creates one recovery card for missing presentations and refuses collection work completion or a newer batch while recovery remains outstanding.
Compatibility
cardIdon everykeepjudgmentsweep:statusis additive and the CLI contract advances to0.5attention_requiredVerification
pnpm install --frozen-lockfilepnpm check- 221 passed, 1 expected local-Supabase skippnpm buildpnpm tend:buildpnpm tend:smokepnpm tend:packagepnpm audit- no known vulnerabilitiesRegression coverage injects failures during recovery-card staging, final card persistence, and checkpoint commit.
It verifies SQLite rollback, unchanged checkpoints, visible pending state, deterministic retry IDs, duplicate-free recovery, evidence completeness, work-completion fencing, legacy incident detection, legitimate empty sweeps, and multi-source batches.
Tend feedback:
feedback_a4d71304-f6c9-457e-9965-f4b012f9d220