Skip to content

fix(crawler): Ctrl-C records the crawl stopped through the guarded status write - #1702

Closed
nc9 wants to merge 1 commit into
mainfrom
fix/stop-interrupted-crawl-1672
Closed

nc9 wants to merge 1 commit into
mainfrom
fix/stop-interrupted-crawl-1672

Conversation

@nc9

@nc9 nc9 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1672.

After Ctrl-C the crawler's own stop() writes paused first (while the loop is live). The interrupt handler marked only crawls still running, with raw SQL and a filter of its own, so it matched nothing and the crawl stayed paused; it also bypassed the transition table.

Decision (documented in the handler and docs/configuration/storage.mdx): Ctrl-C ends the crawl as stopped. The table lists stopped as legal from running, paused and stopped, so it covers both the plain case and the paused stop() left. A crawl that already finished (completed, crawled, analyzed, failed) is not turned into stopped. --resume accepts stopped as before.

How

  • New packages/crawler/src/storage/crawl-status-write.ts: the guard predicate and its bound allowed-from list (CRAWL_STATUS_GUARD_SQL, crawlStatusAllowedFrom) and a synchronous writeCrawlStatusGuarded(db, id, to) for a caller that cannot await (a signal handler).
  • SQLiteStorage.updateCrawl now builds its check from the same two exports, so the storage write and the handler cannot disagree. Behaviour of updateCrawl is unchanged.
  • stop-interrupted-crawl.ts calls writeCrawlStatusGuarded(db, id, "stopped"). Still synchronous, best-effort, never creates a database, owned-crawl-by-id, and the lease release is untouched.

Acceptance criteria

  • Stored status after Ctrl-C is the one the table says, decided and documented (stopped): stop-interrupted-crawl.test.ts (a crawl stop() left paused becomes stopped)
  • The write goes through the same guarded path as every other status write, not raw SQL with its own filter: shared predicate, and a 49-edge table test over every (from, to) in crawl-status-write-1672.test.ts
  • A test interrupts a crawl and asserts the stored status and that --resume still resumes it (decideResume returns { resume: true })

Checks

stop-interrupted-crawl (11), crawl-status-write-1672 (50), status-transitions-1659 (40, unchanged and passing). tsgo (crawler, cli), root lint, cli format:check, make validate. Temp HOME throughout. One existing assertion changed: a second signal on an already-stopped crawl no longer reports 0 marked, because the table lists stopped -> stopped; the status stays stopped. CHANGELOG bullet and the storage docs paragraph included.

Agent skill and docs

  • squirrelscan agent skill (squirrelscan/skills): No change. The skill mentions --resume only as "continue an interrupted crawl", which is exactly what still happens; the stored status changes from paused to stopped, and both resume.
  • Docs: docs/configuration/storage.mdx (the status table and the Ctrl-C paragraph) and docs/crawl.mdx are updated: present.

…atus write, from running or paused #1672

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the fix/stop-interrupted-crawl-1672 branch from 284ee76 to ca3343d Compare November 11, 2026 00:44
@nc9

nc9 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Landed on main as 8294d4e (later commits there carry the review fixes). Closing this draft as superseded.

nik

@nc9 nc9 closed this Nov 11, 2026
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.

stop-interrupted-crawl leaves a Ctrl-C'd crawl paused instead of stopped

1 participant