Repository navigation
Description
Retiring a crawl keeps the page rows that are, at that moment, the freshest record of their url: that is what stops a retirement turning the next re-audit into a cold crawl. A later audit can crawl one of those urls again, which supersedes the kept row, and the crawl it belongs to is by then retired.
Automatic retention (#285) collects those, but only for the urls the audit that just ran actually wrote:
DELETE FROM pages WHERE rowid IN (
SELECT p.rowid FROM pages p
WHERE p.normalized_url IN (SELECT normalized_url FROM pages WHERE crawl_id = ?)
AND EXISTS (... a newer row for this url ...)
AND (SELECT retired_at FROM crawls c WHERE c.id = p.crawl_id) IS NOT NULL
)That is deliberate. It keeps the pass proportional to the audit rather than to the project's history, and it is complete for everything that happens from #285 onwards, because a row can only become superseded by an audit crawling its url again, and that audit sweeps its own urls.
What it does not cover is supersessions that happened before #285 shipped. The only thing that retired a crawl before it was squirrel self disk --prune (#259), so the population is limited to users who ran that command in the days between the two, and the leak is at most one dead page row per url they have since re-crawled. Small, but it is the one case where the invariant "a retired crawl holds no superseded page rows" is not true, and anything reasoning from that invariant later would be wrong.
The obvious fix is the wrong one. Sweeping every retired crawl costs one index probe per audit the project has ever retired, on every audit, forever, which is the shape of cost #285 spent three attempts removing (see the benchmarks file). Options worth weighing: fold it into self disk --prune, which already rewrites the file and is explicitly user-triggered; or run it once per project behind a marker, so it is a one-time repair rather than a recurring pass.
Acceptance Criteria
- Page rows belonging to a retired crawl that a newer row supersedes are removed even when the supersession predates automatic retention
- A url whose only row belongs to a retired crawl still keeps that row, so an incremental re-audit still serves it from cache
- The repair does not add per-audit work proportional to the number of crawls the project has retired, asserted through a query plan
- A test covers a project in the pre-feat(cli): keep the last 3 audits of a project and retire the rest (#1912) #285 state: a crawl retired by
self disk --prune, then a later audit that re-crawls one of the urls it kept
Follow-up from #285. Part of squirrelscan/repo#1912.
Activity
nc9 commentedon Oct 11, 2026
Checked against current main (ad95fb2): STILL TRUE, but the leak is narrower than the title says.
collectSupersededPages(packages/crawler/src/storage/sqlite.ts, from line 4602) is keyed on the urls the current crawl wrote. It deletes any row for those urls that has a newer row and belongs to a retired crawl. A row superseded before #285 is therefore collected the next time any audit crawls its url again. The doc comment at lines 4615 to 4619 says the same: "Rows superseded before this existed are collected the next time their url is crawled rather than swept eagerly".What actually leaks is a pre-#285 superseded row whose url is never crawled again, for example a page that has left the site or now falls outside the crawl scope.
apps/cli/src/self/disk.tscounts retired crawls but has no superseded-row repair, so the options in the issue (fold it intoself disk --prune, or a one-time pass behind a marker) still apply. The test in criterion 4 should use a url that is not re-crawled afterwards.fix(crawler): migration 39 repair is a no-op on a database without th…
fix(crawler,cli): conservative recovery of interrupted report builds;…
fix(crawler,cli): interrupted report builds are recovered conservativ…
fix(crawler): superseded-page repair runs 500-row chunks so the write…
fix(crawler,cli): interrupted report builds are recovered conservativ…
fix(crawler): superseded-page repair runs 500-row chunks so the write…
nc9 commentedon Oct 30, 2026
Verified against main after v0.0.145. Met: criteria 1, 2 and 4 (the repair removes superseded rows, keeps the only copy of a page, and the pre-retention state is reproduced in a test). Open: criterion 3 has no
EXPLAIN QUERY PLANassertion for the repair or its per-audit marker probe (cost per audit is bounded by a done-marker, a cursor, chunks and a time budget, covered by behaviour tests only). Leaving this open for that assertion.nik
test(crawler): repair query-plan assertions tolerate Linux SQLite wor…
test(crawler): query-plan assertions for the superseded-page repair a…
test(crawler): repair query-plan assertions tolerate Linux SQLite wor…
nc9 commentedon Oct 31, 2026
Shipped in v0.0.148 (
982219cd8cf6df9d), verified against main: every acceptance criterion is met. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.148nik
test(install,crawler): give shell-spawning install tests and the #289 …