Skip to content

refactor(history): cora.db as sole SoT — remove legacy .cora/history JSON dual-write (audit 2026-11-14) #724

Closed

Description

@ajianaz

What

Make cora.db the sole source of truth for review/debt history and delete the legacy .cora/history/ JSON layer:

  1. Stop writing DebtSnapshot JSON on every review (engine/finalize.rs:166 is the only remaining writer).
  2. Fix MCP get_debt (mcp/tools.rs:853) — it reads only legacy JSON snapshots; CLI debt reads DB-first. MCP agents get stale/empty data on repos whose DB history exists but local JSON doesn't.
  3. Drop the legacy load_snapshots fallback and the cleanup_old_snapshots call in commands/debt.rs (DB path is primary since schema v5).
  4. Fleet cleanup: archive once, then delete .cora/history/ across repos (audit 2026-11-14: 21 repos, 948 files, 0.28 MB, incl. 170 pre-v5 files; newest entry 5 Nov). Ensure .cora/ is gitignored everywhere.

Why

Audit numbers (global cora.db, 20 MB): reviews = 2,230, findings = 11,026, finding_events = 16,317 (5,266 auto_resolved — auto-resolve is healthy). Schema v5's own doc says the DB "replaces the legacy JSON snapshot files in .cora/history/", but two code paths still keep the dead layer alive — and MCP get_debt is actually still on the legacy path, contradicting the CLI. Keeping dual-write costs write time per review, accumulates untracked junk in every working tree, and creates a second stale source of truth.

Testing

  • cora debt --trend output identical before/after on a repo with rich DB history.
  • MCP get_debt returns a DB-based report (before: empty/stale on repos without local JSON).
  • grep -rn "cora/history" src/ returns no writer/reader outside tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpriority:mediumscope:core

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions