Skip to content

test(cli): pin that the link cache keeps only settled dead-links answers #764 - #832

Merged
nc9 merged 1 commit into
mainfrom
fix/764-link-cache-unsettled-answers
Oct 15, 2026
Merged

nc9 merged 1 commit into
mainfrom
fix/764-link-cache-unsettled-answers

Conversation

@nc9

@nc9 nc9 commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Closes #764.

What changes

Test only. Both behaviours the issue asks for are already on main:

The first criterion asks for a test that pins the rate-limited case, and none drove the bulk path with throttled answers. The only coverage was a cacheableVerdict unit assertion. This adds one that goes through the CLI's real SQLite LinkCacheStorage and the engine's checkExternalLinks:

  • The bulk answers are a rate-limited 503 (rateLimited: true), a 429, a 430, an unverifiable wafBlocked with null status, a 404 and a 200. Only the 404 and the 200 are written.
  • The 503 keeps its rateLimited flag for the rules. filterRateLimitedLinks returns the three throttled links, and filterBrokenLinks returns only the 404.
  • On a second run, the service is asked again about exactly the four unsettled links and their new answers win. The 404 and the 200 come from the cache.

I checked that the test fails when cacheableVerdict lets throttled and unverifiable answers through (both tests go red), then restored it.

Third criterion ("a WAF-blocked 403 from the CLI's own local checker is cached as it is today"): superseded. pub#800 deliberately stopped caching local walls and timeouts, so a later signed-in run asks the cloud link checker instead of reading a week-old wall. packages/audit-engine/tests/local-link-walls-800.test.ts pins that ("walls and timeouts are not cached, so a signed-in run asks the cloud next time"). I left a note on the issue suggesting the criterion be updated to match.

Tests

  • apps/cli/tests/crawler/link-cache-unsettled-764.test.ts (new, 2 tests, in the cli suite).
  • tsgo is clean for apps/cli, oxlint and oxfmt are clean on the file, and test-suites.ts --check and the detect-secrets hook pass.

Docs and skill

  • No user-facing change, so no CHANGELOG entry and no docs change.
  • The squirrelscan agent skill needs no change.

@claude

claude Bot commented Oct 15, 2026

Copy link
Copy Markdown

Reviewed the diff. It adds one test file, link-cache-unsettled-764.test.ts, and changes no production code. I found no problems.

  • The test uses a real SQLite cache in a temp dir, cleans up in afterEach, and closes the cache in finally.
  • It checks that rate-limited and unverified answers are not cached, and that the next run asks the service again about only those links.
  • I confirmed LinkCacheStorage.getCachedBulk exists. I did not run the tests or check the engine imports (checkExternalLinks, filterRateLimitedLinks, the egress and bulkChecker options).

…ers #764

A rate-limited bulk answer (rateLimited 503, 429, 430) or one the
service could not verify (wafBlocked, null status) is never written to
the local link cache, and the next run asks the service again. Fixed in
the engine by #755 and #800; this pins it through the real SQLite cache.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the fix/764-link-cache-unsettled-answers branch from 8d4afd3 to 90bf506 Compare October 15, 2026 17:46
@claude

claude Bot commented Oct 15, 2026

Copy link
Copy Markdown

Reviewed the diff; this PR only adds a test file. I found no problems, so there are no tagged findings.

  • The test goes through the real SQLite LinkCacheStorage and the engine's checkExternalLinks. It sets egress to a private-resolving policy, so a link the bulk checker doesn't answer is refused locally and nothing leaves the machine.
  • It covers the throttled 503, 429 and 430, the unverifiable wafBlocked answer, and the settled 404 and 200 cases. Both the first-run cache contents and the second-run re-ask are asserted.
  • Temp dirs are cleaned up in afterEach, and cache.close() runs in finally.
  • I confirmed that checkExternalLinks, filterBrokenLinks and filterRateLimitedLinks are exported from external-checker.ts, and that bulkChecker, egress and ttlSeconds exist as options. I did not run the tests.

Looks good to merge.

@nc9
nc9 merged commit 1b6ace6 into main Oct 15, 2026
15 checks passed
@nc9
nc9 deleted the fix/764-link-cache-unsettled-answers branch October 15, 2026 18:11
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.

fix(cli): the local link cache keeps cloud rate-limited and unverified answers for 7 days

1 participant