Repository navigation
feat(session): age-gated classification-aware auto-archive nightly job #1304
Description
Important
Problem — The archive verb exists and works (amico sessions archive --days/--apply against the engine's archive primitive) but is classification-blind: it archives by age alone. Curation needs an age-gated, classification-aware auto-archive that runs nightly on the hub, is reversible, and never touches real work.
Approach — Gate the archive flow on the classifier from the previous slice (junk buckets only), add the 48 h age gate and todo/ledger protections, and wrap it in a nightly ops job following the skill-freshness pattern (env-driven config, --dry-run default, one JSON receipt line per run with count + session ids).
Acceptance Criteria
- With apply mode on, a
junk-greeting/dead-cast/probesession older than the age gate is archived through the engine's archive primitive — and onlytime_archivedchanges. - A session with pending todos is never archived regardless of bucket or age.
- A session updated within the age gate (default 48 h) is never archived.
- Dry-run (the default) reports what would archive — count + ids — and writes nothing.
- Each run appends one JSON receipt line (timestamp, mode, scanned, archived count, ids) to the shared receipts journal.
- An archived session is restorable via the existing unarchive path (round-trip verified in test).
- The job script runs green under
--dry-runon a seeded temp DB fixture and exits nonzero on a hard failure (DB missing).
Testing Decisions
Extend the sessions-verb test file (it already covers archive/restore change-only-time_archived on seeded temp DBs) with classification-gated cases from the prior slice's classifier. The ops script gets a smoke path exercised in dry-run mode.
Key Decisions
- Archive threshold policy: archive ONLY on a deterministic junk bucket AND age ≥ 48 h — no LLM/model call anywhere in this path (the calibrated Jev middle layer is a deliberate future slice, see parent).
- Job lands as
ops/<name>/run-<name>.sh+ launchd plist + systemd unit pair, cadence nightly on the hub — the skill-freshness pattern, including the receipts journal and escalation convention. - Config rides the session-retention preference file pattern (ops-dir JSON, fail-safe defaults, CLI-pref surfacing where it exists).
Constraints & Invariants
- Reversible only: archive, never delete; every bulk action logged with counts + ids.
- The engine owns archived-field mechanics — the job goes through the archive verb/primitive, never raw SQL writes to the live DB.
- Canonical DB is the only writer target; client DBs are read-only to this job.
Prior Art
- The sessions archive verb + retention module (CLI package) — the flow this gates.
- The skill-freshness ops job — the nightly-job pattern (receipts, dry-run, scheduler units).
- The engine session service's archive primitive — the mechanics, unchanged.
Source
Part of #1301 · Blocked by #1303 · spec of record: personal vault specs/spec-20260920-session-curation.md
Activity
test(session): age-gated classification-aware autoarchive acceptance …
feat(session): age-gated classification-aware autoarchive verb + nigh…
aarontrowbridge commentedon Sep 20, 2026
Merged into the #1301 integration branch (PR #1307) — director-verified green on its slice branch (per-AC tests + full package suite + typecheck) and the merged integration tree. CI on #1307: all 10 checks SUCCESS. Merge to main is gated on human review per branch protection.
feat(session): derived session curation — classifier, auto-archive, o…
fix(app): #1304 — the warm's request storm queued the foreground (the…