Repository navigation
fix(cli): name the local store an audit cannot write, before it starts (#403) - #429
Merged
Merged
Conversation
nc9
marked this pull request as ready for review
October 1, 2026 19:02
…#403 SQLite opens a file it cannot write read-only without saying so, so a store owned by root after a sudo run, or blocked by a coding agent's sandbox, failed at the first page with 'attempt to write a readonly database', and a content store that failed dropped every page and ended 'No pages were crawled'. - squirrel audit and squirrel crawl probe the project database, content store and link cache with a rolled-back write before the run is registered or any request is sent, and stop with the file, the cause (owner, read-only, sandbox, directory, damaged) and the fix. - The crawler ends the crawl on a storage error no retry fixes (read-only, cannot open, not a database, disk full) instead of counting each page as failed. - A crawl that stored nothing because pages failed locally records that as its root failure, so the reason says why instead of only 'No pages were crawled'. Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
fix/cli-local-store-errors
branch
from
October 1, 2026 19:02
c703a0e to
4f4435f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #403.
Two field failures had one root: the CLI never checked that it could write its local stores, and the crawler treated a store failure as one failed page.
Audit failed: Storage error during write: SQLiteError: attempt to write a readonly database(CLI v0.0.98, macOS). SQLite opens a file it cannot write read-only without saying so. Reproduced three ways:project.dbowned by another user orchmod 444, and a macOS sandbox that denies writes to~/.squirrel, which is what coding agents run commands in. The audit got through reachability and run registration, then died at its first write.No pages were crawledon a site that serves 200s. Reproduced with a read-onlycontent-store.dband withSQUIRREL_CONTENT_STORE_PATHpointing at a directory (audit reports success with 0 pages when the content store cannot be opened #403): every page is fetched,upsertPagethrows inside the content store, the crawler logs it at debug and marks the page failed, and the audit ends with no pages and no reason. A signed-in run had already registered, so it was charged.What changed
apps/cli/src/crawler/storage/store-check.ts(new): probes each store with a write inside a transaction that is rolled back (BEGIN IMMEDIATE,CREATE TABLE,ROLLBACK;BEGIN IMMEDIATEalone succeeds on a file SQLite opened read-only). A failure becomes one line with the file, the cause and the fix:sudo chown -R "$(id -un)" ~/.squirrelchmod -R u+w ~/.squirrelEPERMfromaccess(2)ormkdir: blocked by a sandbox or security policy, allow writes to~/.squirrelor run outside the sandboxSQUIRREL_CONTENT_STORE_PATHwhen it came from there), not a database, disk full~/.squirrel; outside it the fix names the file alonesquirrel auditruns the check before the run is registered (the audit base is debited at register) and before any request goes out.runAuditandrunCrawlrun it before creating storage, for the MCP andsquirrel crawlpaths. The link cache is checked only when external links will be checked.packages/crawler: aStorageErrorno retry fixes (read-only, cannot open, not a database, malformed, disk full, I/O error;isPermanentStorageErrorin core-contracts) now ends the crawl instead of being swallowed per page, so a store that breaks mid-crawl fails the audit rather than producing a smaller one. A transient one (locked) still drops the page, and a crawl that stored nothing records the first such failure as its root failure (unknown):No pages were crawled from example.com: a page could not be saved to the local store (it was locked by another squirrel process).guides/failed-audits.mdx.Behaviour change for other
packages/crawlerconsumers: a permanent storage error fromprocessUrlnow failsstart()instead of marking the page failed. Transient errors are unchanged apart from the recorded root failure.Before and after (from source, local fixture site)
project.dbchmod 444Audit failed: Storage error during write: ... readonly databaseafter register✗ Cannot write to ~/.squirrel/projects/<site>/project.db: it is read-only. Fix: chmod -R u+w ~/.squirrel, nothing registeredcontent-store.dbchmod 444No pages were crawled✗ Cannot write to ~/.squirrel/content-store.db: it is read-only. ...~/.squirrel... it is blocked by a sandbox or security policy ... Fix: allow writes to ~/.squirrel in the sandbox settings, or run the audit outside the sandboxSQUIRREL_CONTENT_STORE_PATHis a directoryNo pages were crawled... it is a directory, not a database file. Fix: set SQUIRREL_CONTENT_STORE_PATH to a file path, such as .../content-store.dbTests
apps/cli/tests/crawler/store-check.test.ts(new, 11): writable, new path, directory, not a database, read-only file, read-only directory, uncreatable directory outside~/.squirrel, recursive fix only inside it, busy store left intact, a real macOSsandbox-execrun (darwin only), message dedupe.apps/cli/tests/commands/audit-local-store-wiring.test.ts(new, 3): through citty, signed in: a directory store and a read-only store exit 1 with noPOST /v1/agent-runsand no request to the site; a writable store (control) registers and crawls.packages/crawler/tests/local-store-failure.test.ts(new, 4): permanent failure ends the crawl at the first refused pages, a store that turns read-only after 3 pages fails the crawl, a locked store records the root failure and reason text,isPermanentStorageErrorthrough a FiberFailure.audit-no-publish-wiring,audit-discovery-probes-wiring,audit-non-public-host-wiring,storage-error,content-store,db-lock-warning,storage-project-path,zero-success-breaker,root-failure-classification,entry-fetch-timeout,crawler-stop-hard-cap: all pass.tsgo --noEmitclean inapps/cli,packages/crawler,packages/core-contracts.bun run lintandbun run format:checkclean inapps/cli.tangly check --strictindocs/: all checks passed.detect-secrets-hookon the changed files: clean.