Skip to content

crawler: crawl and frontier status writes have no from-state guard (stop() can write paused over completed) #1659

Closed

Description

@nc9

updateCrawl (packages/crawler/src/storage/sqlite.ts:1718-1790) is an unconditional SET. Writers: crawler.ts:3402 (stop() writes paused), :2585 (stopped/completed), :3521 and :3558 (running), controllers/crawl.ts:470 and controllers/audit.ts:1612 (crawled), audit.ts:2351 and analyze.ts:352 (analyzed). stop() writes paused with no guard, even after completed was written for the same crawl. updateFrontierStatus (crawler.ts 1265, 1313, 1659, 1717, 1754, 1847, 2137, 2424, 2469) is last-writer-wins too.

Approach: a transition table for crawls.status and frontier status in one place in storage, with writes made conditional (WHERE status IN (allowed_from)). An illegal write is a no-op and logs at debug level. It must never throw mid-crawl. Document the table next to CrawlStatus in core-contracts.

Cloud counterpart: the private runtime leaves soft-timer-stopped crawls as running (tracked privately).

Follow-up, not in scope: fold status + report_status + lease into one derived crawlPhase().

Acceptance Criteria

  • Crawl and frontier status transitions are listed in one table, and storage writes check it
  • stop() after a crawl reached a terminal status leaves that status unchanged (test)
  • A frontier entry only moves to done/failed/skipped from fetching (test), and resetStaleFetching still re-queues on resume (test)
  • An illegal transition does not throw or abort the crawl
  • Existing crawler and resume tests pass unchanged

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2clisize: S

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions