Skip to content

fix(cli): squirrel analyze applies keep_audits retention #955 - #961

Merged
nc9 merged 1 commit into
mainfrom
fix/955-keep-audits-retention
Oct 20, 2026
Merged

nc9 merged 1 commit into
mainfrom
fix/955-keep-audits-retention

Conversation

@nc9

@nc9 nc9 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

What

squirrel analyze, the step that finishes an audit in the split pipeline (crawl, analyze, report), now runs the same [storage] keep_audits retention as squirrel audit: windowed audits and the abandoned-crawl pass, one stderr notice, no stdout change.

Gates, same as the audit path plus one: a blocked or failed crawl retires nothing (its status is derived by the new shared deriveCrawlRunStatus, extracted from reconstructReport, behaviour identical) and is recorded on the crawl so later passes can tell it from a real audit; a building sentinel of a concurrent audit is never overwritten (setReportStatus gains keepBuilding); the window applies only to the project named in the directory's [project] name, or, with no name, to the latest crawl's project but never to an --id crawl.

Why

Split-pipeline projects never retired anything and grew to several GB. crawl itself leaves the crawl crawled, so there is nothing to retire there, and report only reads.

Known, same as the audit path (#941): the abandoned-crawl pass can retire an older crawled crawl idle 30+ minutes once a newer audit is finished.

Tests: new analyze-retention-955.test.ts (3-audit repro with keep 1, keep 0, blocked, other project, no name with/without --id, building kept). Docs: configuration/storage, cli/analyze; CHANGELOG. Codex pass done, findings fixed. Golden not affected (no rule verdict change).

skills: no change

Closes #955

@claude

claude Bot commented Oct 20, 2026

Copy link
Copy Markdown

Reviewed the diff: retainAfterAnalyze in controllers/analyze.ts, the shared deriveCrawlRunStatus, the CLI notice, the docs and the tests. I didn't run the test suite.

  • (low) controllers/analyze.ts (retainAfterAnalyze doc comment): one sentence is far past the line width and reads awkwardly. It starts "...to the latest crawl's own project but never to an --id one. Records the outcome...". Please rewrap it.
  • (low) retainAfterAnalyze calls setReportStatus(..., { keepBuilding: true }) before the project and status gates. So an analyze of another project's crawl via --id, or of a blocked crawl, still writes a report status. That seems intended and mirrors the audit path, but a short comment saying so would help.
  • (nit) The "retireCrawlsDetailed" in storage duck-typing followed by a cast to SQLiteStorage is fragile. An instanceof check or a typed helper would be clearer. Check whether audit.ts does the same and share one helper if so.
  • (nit) Test coverage is good: window, keep_audits = 0, blocked crawl, other project, unnamed project with and without --id, and the building sentinel. One case is missing: a failure inside retainRecentAudits (the RetentionReclaimError path) should still leave analyze succeeding. Consider adding it.

The refactor of deriveCrawlRunStatus out of reconstructReport keeps behaviour identical. The changelog and docs are updated. I found no correctness or security problems.

@nc9
nc9 merged commit 26dd8b5 into main Oct 20, 2026
15 checks passed
@nc9
nc9 deleted the fix/955-keep-audits-retention branch October 20, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

keep_audits retention never runs for crawl + analyze + report, only for audit

1 participant