fix-surprise-startup-archival

Prevent surprise backlog archival on daemon restart

Metadata

Statusdone
Agent identityfbb2d89fe44d6b761bcb4b67748ab3d417f29df70a65f8d9403308f5bb2bab78
Created2026-08-01T07:14:11.405826078+00:00
Started2026-08-01T07:14:27.971931743+00:00
Completed2026-08-03T09:42:51.782626346+00:00
Tokens29876801 in / 45514 out

Description

Fix the destructive visibility regression observed in /home/bot/jobs on 2026-08-01. Restarting a 38-day-old legacy daemon on the current binary caused the first maintenance pass to apply the configured/default dispatcher.archive_retention_days=7 retroactively and auto-archive 57 historical terminal tasks immediately. The attended TUI went from showing the completed body of work to only chats/open recurring tasks, making it appear that all history was cleared. Recovery required stopping the service, backing up graph/archive/batch/config, setting retention=0, and wg archive --undo; all 57 records were restored exactly. Evidence backup: /home/bot/jobs/.wg/recovery/auto-archive-20260801T071318Z.

Required product behavior: daemon start/restart/upgrade must never silently apply a large overdue archival backlog. Automatic archival should be opt-in and/or require a persisted acknowledgment/watermark before first destructive application. A legacy/unverified daemon migration, long downtime, build change, absent prior archival receipt, or backlog above a small bound must fail closed into a visible archival pending operator confirmation state. Routine already-acknowledged incremental archival may continue when explicitly enabled. Preserve exact tasks and archive boundaries; no task status mutation, WIP loss, or graph-edge loss. TUI/service status must explain the hold and provide a dry-run/confirm command. Default attended-project behavior should preserve visible history.

Validation

  • Candidate-binary smoke: month-old graph + 7d retention + legacy daemon state + current daemon restart => zero tasks archived before explicit confirmation.
  • Dry-run reports exact IDs/count; confirmation archives that exact batch once; undo restores exact bytes/status/log/dependencies.
  • retention=0 disables automatic archival.
  • restart after an acknowledged watermark archives only newly eligible incremental tasks, without reprocessing backlog.
  • TUI/status makes pending archival visible and actionable.
  • cargo fmt --check, focused archive/service restart tests, cargo check, cargo clippy.

Depends on

Required by

Log