Skip to content

feat(rules): internal link checks at every level, external links opt-in at quick, with limits and switches (repo#2729) - #721

Merged
nc9 merged 5 commits into
mainfrom
feat/link-checks-on-by-default
Oct 12, 2026
Merged

nc9 merged 5 commits into
mainfrom
feat/link-checks-on-by-default

Conversation

@nc9

@nc9 nc9 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Refs squirrelscan/repo#2729, phase 2, amended to Nik's decision:

  • Internal link checks are on by default at every level.
  • External link checks keep today's defaults until the shared link checker lands, behind one constant.

This pairs with a private PR (cloud run-time default, nullable opt-out storage, estimates, MCP and pricing copy) and a gitlink bump.

Change

Internal link checks run at every level (#2729 item 3).

  • Each internal link target the crawl did not fetch gets a status-only HEAD. Up to 200 per audit, most-linked first, free.
  • The requests stay inside the crawl scope (include/exclude, allowed domains). They respect robots.txt when respect_robots is on, and use the crawl's user agent and per-host concurrency.

The probe never changes state (packages/audit-engine/src/link-target-probe.ts; a security review flagged the first version). It is safe by construction:

  • Action filter. Path segments, query keys and query values are split into words: on non-alphanumerics, at camelCase, after decoding, and including matrix params.
    • Logout-family verbs count anywhere, even run together (UserLogout.aspx).
    • The other action words are tiered by how unambiguous they are: two-word pairs count in segments of up to 4 words, strong verbs (delete, confirm, verify…) up to 3, weak words (cart, buy, subscribe, reset…) up to 2. Every tier applies in queries.
    • So /logout;jsessionid=…, ?route=account/logout, ?task=user.logout, /users/sign_out, /add-to-cart/7, /confirm/abc123 and ?action=deleteItem are skipped, while /where-to-buy and /blog/how-to-verify-your-domain are checked.
  • Token filter.
    • Secret query keys: token, nonce, _wpnonce, csrf, sig, code, key, state…
    • Token-shaped keys or values: long hex, long separator-free alphanumerics, mixed-case base64, JWT.
    • JWTs in the path; other path tokens when the URL says login, magic, reset, verify and the like.
    • Session ids.
  • Action link text. Short text that is an unambiguous action ("Log out", "Unsubscribe", "Delete account") is skipped whatever the URL says. On rel=nofollow links (read from the DOM), any action text is skipped.
  • Stated limits. The docs say the English word lists are a careful default, not a guarantee, and name --no-internal-links / [internal_links] enabled = false for sites with state-changing GET routes.
  • No credentials. No cookies, no Authorization, and none of the audit's custom headers. Only the crawl's User-Agent, Accept and Accept-Encoding.
  • HEAD only. GET (a one-byte range) only when the server answers 405 or 501.
  • HEAD control. The audited URL, which the crawl already fetched, is asked first. A site that answers it with an error has its targets' 4xx/5xx treated as unanswered, never as broken.
  • Redirects. Followed by hand, at most 5 hops, and every hop must pass scope, robots.txt and the filter. A redirect that fails them is reported as its 3xx.
  • Docs. The model is stated under "What the internal link check never requests" in docs/configuration/external-links.mdx, and linked from the links index and the broken-links page.

How results feed links/broken-links.

  • A probed 404 fails with meta.probed: true.
  • A probed 401 or 403 goes to a refused-links info check.
  • A rate-limited probe goes to the rate-limited bucket.
  • Settings: [internal_links] enabled and max_targets, plus --no-internal-links. --offline keeps the probe, because it only requests the audited site.

External link defaults are unchanged, behind EXTERNAL_LINKS_DEFAULT_ON = false (core-contracts audit-levels.ts).

  • Quick and the four legacy cloud depths read the constant. Surface and Full stay on.
  • The Quick summary copy is derived from the constant.
  • The constant's comment lists the hand-written copy that changes when it flips: the MCP descriptions, the report hint, and the two docs pages.

--external-links checks external links at any level for one run.

  • It beats [external_links] enabled = false.
  • It is refused with --offline or --no-external-links.
  • --external-links=false and --external-links false are off switches.
  • --no-external-links stays.

External link limit: the page budget or 200, whichever is more (externalLinkCheckCap).

  • Order: priority links first (priorityHrefs), then the most-linked, ties broken by URL.
  • The rest are a skipped check, external-links-over-cap, rendered as Not checked.
  • [external_links] max_links overrides the limit.
  • The limit bounds requests, not credits: cloud billing already caps the charge at 1 credit per page of the budget.

Local MCP. audit_website takes externalLinks and internalLinks. offline: true with externalLinks: true is refused, the same as on the CLI.

Report. The external-off reason is unchanged. Its hint now says how to opt in: "in the CLI pass --external-links, or run a Surface or Full audit, without --offline; in the cloud they are a website setting." Each skip reason has its own hint, and the over-cap line shows in every format.

Docs.

  • The links index note is now "Link checking defaults": internal on and free, external opt-in at Quick for now, with a table of switches.
  • Also updated: audit levels, the broken-links, broken-external-links and dead-links pages, the external/internal link config, the output reasons, the CLI flags and the local MCP tools.
  • CHANGELOG [Unreleased] has two entries. Under Changed: the internal checks and the external cap. Under Added: --external-links and the MCP switches.

Removed from the earlier version of this PR:

  • The README Features item and the docs front-page card. They ship with the external default flip.
  • External-on at Quick and at the legacy depths.

Evidence (fixture on 127.0.0.1.nip.io, CLI from source, signed out)

Run broken-links broken-external-links
--level quick (default) fail /missing-page (404), probed: true skipped, Not checked (external-links-not-checked, opt-in hint)
--level quick --external-links fail (probe) warn https://squirrelscan.com/zz-broken-link-probe-404 (404)
--level quick --no-internal-links skipped, Not checked ("internal link checks were off") skipped, Not checked
--offline --external-links refused: "--offline cannot be combined with --external-links"

The banner reads quick · max 25 pages by default and custom (quick + external_links on) · max 25 pages with the flag.

Tests

  • Probe safety, real crawler fixture.

    • The home page links /logout, /unsubscribe?token=…, /cart/add?id=1, /confirm/abc123def456, a nofollow "Delete account", a _wpnonce link, and a link that 302s to /logout.
    • The server records zero requests to any of them, and exactly one HEAD to /missing-page.
    • No probe request carries the custom header, a cookie or Authorization.
    • The redirecting link is reported as 302.
  • Probe safety, unit tests.

    • GET only after 405/501, with Range bytes=0-0.
    • Headers are exactly User-Agent and Accept, credentials: "omit", manual redirects.
    • Redirect hops re-checked.
    • A disallowed target is never sent.
    • The HEAD control, both ways.
    • Bypass and false-positive URL tables.
  • core-contracts: the constant is pinned (false), Quick and the legacy depths read it, Surface and Full are on, and the Quick summary copy is checked.

  • CLI wiring (citty's real parser):

    • Quick defaults.
    • --external-links beats the config.
    • The =false and space forms are off switches.
    • Both refusals.
    • --no-* at surface.
  • CLI options: internalLinksEnabled: false gives internal_links.enabled = false, and --offline keeps the probe.

  • MCP:

    • levelRunOptions link switches beat the level and the config.
    • audit_website refuses offline together with externalLinks.
  • Report: the opt-in hint line in every format, and the over-cap hint line.

  • Rules (18 tests) and the engine e2e on both engines: the probe finds the 404, crawl-scope exclusion, the over-cap limit and priority, and both checks off.

Each touched test file was run 3 times by explicit path, all green. Typecheck is clean across core-contracts, report, rules, audit-engine and cli. CLI format:check and lint are clean, tangly check --strict passes, and detect-secrets-hook over all tracked files is clean.

Codex is out of credits until Oct 18, so an Opus reviewer subagent reviewed this. Its P1 (--external-links=false turned checks on) and P2s are fixed in the second commit. It then reviewed the probe's safety work over two rounds. Its first round found filter bypasses (matrix params, ?route=account/logout, sign_out, run-together verbs, path tokens) and false positives. Both are fixed in the third commit, and the second round confirmed it. Three claude-review rounds followed; their non-blocking findings are fixed or triaged in PR comments.

The reviewer's note that hasNegatedFlag ignores --no-x=value is older than this PR and shared with --no-publish, so it is not changed here. Its other note, that a signed-in CLI's WAF-escalated external link render is billed while the docs call the CLI's checks free, is also older than this PR and is filed as squirrelscan/repo#2757. The external link checker has no action or token filter for third-party links. That is also older than this PR, but --external-links now reaches it at Quick, so it is filed as squirrelscan/repo#2759.

Skill

The squirrelscan skill needs a change, tracked in squirrelscan/repo#2737. It should cover:

  • internal checks at every level;
  • --external-links, --no-external-links and --no-internal-links;
  • [internal_links] and max_links;
  • what Not checked means.

@nc9
nc9 marked this pull request as ready for review October 12, 2026 11:45
@claude

claude Bot commented Oct 12, 2026

Copy link
Copy Markdown

Review of PR 721. I read the diff and the main engine paths (probe selection, external-link cap, CLI flags). I did not run the tests.

  • (medium) packages/audit-engine/src/adapter.ts (internal probe): Quick now sends a GET to every unfetched internal link target, up to 200. Some sites expose state-changing GET links, such as /logout?token=, /cart/remove?id= or /unsubscribe/<id>. The comment covers the exclude list, but only for users who have configured it. Before this PR, Quick never requested those URLs. I'd suggest HEAD-only for targets with a query string, or a default skip pattern for common action paths. At the least, document it under the --no-internal-links docs.
  • (medium) packages/audit-engine/src/streaming-pre-rules.ts:236 and adapter.ts checkExternalLinksOnStorage: the default cap of externalLinkCheckCap(max_pages) is applied only in the streaming path. The resident checkExternalLinksOnStorage path passes neither a default cap nor priorityHrefs. If anything still uses it, a site with 40k external links would be checked in full, which is the case the cap exists for. Either apply the default inside checkCollectedExternalLinks or confirm that path is unused outside tests. The CLI has its own checkExternalLinksOnStorage in apps/cli/src/audit/adapter.ts:1019, which I did not trace.
  • (low) The probe requests go through checkResourceSizes with a pool of their own. Please confirm they respect the crawl's per-host concurrency and delay. 200 extra requests against a rate-limited site could trigger 429s, and those are bucketed as "rate-limited", so it degrades quietly rather than failing.
  • (low) selectExternalLinksToCheck: pagesOf builds a Set per href, and the same input is built again for the cap stat. This is fine at 40k links. Precomputing the page counts once is cheap if you want it.
  • (low) updateStats failures are swallowed with catchAll. If that write fails, externalLinkCheck is missing and the over-cap "Not checked" line silently disappears, so the report could read as complete. A log line would help.
  • (low) Behaviour change: scores and findings will shift for existing users and CI gates (--fail-on), because Quick now finds probed 404s. The CHANGELOG covers this well. It may be worth a mention in the release notes too.
  • (nit) hasNegatedFlag(rawArgs, ...) duplicates flags that citty already declares. A comment saying why rawArgs is read, as the one for --no-publish does, is enough.
  • (nit) Test coverage is strong: e2e on both engines, cap, priority, scope and robots. I'd add one test that a probe target excluded by robots or scope is not requested. The PR says this is covered by e2e, so check it asserts zero requests.

No (critical) or (high) issues found.

@nc9

nc9 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Triage of the review above. Fixes are in eedaddf.

  • State-changing GET links (medium): fixed. The probe now never requests a link that looks like an action. That means a logout, log-off, sign-out, unsubscribe or opt-out path segment, or a query word such as ?action=delete or ?remove=12. Only whole segments match, so /blog/how-to-remove-stains is still probed. Unit tests cover both sides, and the docs on --no-internal-links, [internal_links] and the rule page say so. For context, the crawler already requests these URLs at Surface and Full when it follows links, so the probe only matters for Quick.
  • Default cap on the resident path (medium): no caller outside tests. Neither checkExternalLinksOnStorage (engine) nor the CLI's copy is called from non-test code; the CLI and the cloud both use runStreamingPreRules, which applies the default. Left as is.
  • Per-host politeness (low): fixed. Probe concurrency is now capped at the crawl's per_host_concurrency, and the cloud's shared fetch budget still bounds it. A throttled probe goes to the rate-limited info bucket by design, so it never shows as broken.
  • updateStats failure (low): fixed. It now logs a warning.
  • Behaviour change (low): the CHANGELOG says Surface and Full also gain probed findings and that Links scores move with them. The release notes come from that entry.
  • Test for zero requests (nit): done. The e2e records every path the fixture server is asked for and asserts that an excluded target is never requested.
  • selectExternalLinksToCheck precompute and the rawArgs comment (nits): the cost is fine at the 50k bound. rawArgs gets the same comment as the --no-publish declaration.

nc9 added 2 commits October 12, 2026 23:48
…in at quick, with limits and switches #2729

Internal link targets the crawl did not fetch get a status-only request
(HEAD, then GET) at every level: up to 200 per audit, most-linked first,
inside the crawl scope and robots.txt, never an action link, free.

External link checks stay as they were (surface and full on, quick and the
old cloud depths off) behind one constant, EXTERNAL_LINKS_DEFAULT_ON, so
turning them on everywhere later is one line. --external-links checks them
at any level for one run; --no-external-links and --no-internal-links skip
them. An audit checks at most max(page budget, 200) distinct external links,
most-linked first, and reports the rest as Not checked
(external-links-over-cap). New settings: [external_links] max_links and
[internal_links] enabled / max_targets. The local MCP audit_website takes
externalLinks and internalLinks.

Signed-off-by: Nik Cubrilovic <[email protected]>
…xternalLinks in MCP; docs and tests #2729

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the feat/link-checks-on-by-default branch from eedaddf to a3a63af Compare October 12, 2026 13:09
@nc9 nc9 changed the title feat(rules): link checking on by default at every level, with limits and off switches (repo#2729) feat(rules): internal link checks at every level, external links opt-in at quick, with limits and switches (repo#2729) Oct 12, 2026
@claude

claude Bot commented Oct 12, 2026

Copy link
Copy Markdown

Reviewed the diff for the CLI flags, config schema, engine probe, external cap, audit-levels constant and report copy. I did not run the tests, and I could not read the private pairing PR.

Findings

  • (medium) apps/cli/src/audit/adapter.ts:1019 The default external-link cap (page budget or 200) is applied only in streaming-pre-rules.ts. This CLI-side checkExternalLinksOnStorage still looks uncapped unless max_links is set. The docs say one audit requests at most the page budget or 200 links. If the local CLI takes this path, a site with thousands of outbound links with --external-links or at Surface/Full is unbounded and gets no external-links-over-cap line. Please confirm which path the CLI uses and add a test on it, or apply the cap in checkCollectedExternalLinks itself.
  • (medium) packages/audit-engine/src/adapter.ts:331 The new probe uses checkResourceSizes, which follows redirects by hand. The scope and robots filter (mayProbe) runs only on the original URL. An in-scope internal link that redirects to another host (or to an excluded or action path such as /logout) is still requested. I did not confirm whether the checker re-applies scope per hop. Please either check that, or stop at the first redirect and record the 3xx as the status, since the probe only needs status.
  • (low) packages/audit-engine/src/adapter.ts:407 looksLikeAnAction is a small denylist (logout, unsubscribe, ?action=delete). Other state-changing GET links are common, for example /cart/add/12, /wishlist/remove/3, /delete/5 and /verify?token=. Path segments like delete and remove are not matched, only query words. The probe sends GETs after HEAD fails or is rejected, so this can change state on a site. Consider matching delete, remove and add path segments, and document that --no-internal-links is the escape hatch.
  • (low) apps/cli/src/cli/commands/audit.ts:1150 The flag parsing is fragile. It reads hasFlag/hasNegatedFlag from rawArgs and also from citty's parsed value. It relies on --external-links false being parsed as the value, and the PR notes --no-x=value is already ignored. The tests cover the main forms. Please also cover --external-links --no-external-links in both orders and --no-internal-links=false.
  • (low) packages/config/src/schema.ts:589 max_targets allows 0, which silently turns the probe into a no-op. It then shows up as "not checked" rather than being reported as off. Consider allowing 0 only through enabled = false, or documenting it.
  • (low) packages/audit-engine/src/adapter.ts:218 The asset collector tracks up to 50,000 internal link targets, and each probe run sorts them all. Memory is bounded, but a hot path over a very large crawl would be cheaper with a top-N selection. Fine to leave as is.
  • (nit) packages/core-contracts/src/audit-levels.ts:643 EXTERNAL_LINKS_DEFAULT_ON: boolean = false is annotated boolean so TypeScript does not narrow the ternary in AUDIT_LEVEL_COPY. That is good. A short comment saying so would keep someone from removing it.

Test coverage. Coverage is good: the rules, the e2e on both engines, the CLI parser wiring and the MCP refusals are all tested. The gaps are the redirect case and the uncapped CLI path above.

Security. The probe stays on the audited host and respects robots.txt and scope. The redirect and action-link points above are the open items.

… and token filter, HEAD only, no credentials, every redirect hop rechecked #2729

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9

nc9 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Here is my triage of the claude-review findings on a3a63af. The fixes are in the new head, which also carries a security pass on the internal link probe.

  • (medium) CLI checkExternalLinksOnStorage uncapped: not affected.
    • squirrel audit checks external links through the engine's runStreamingPreRules (apps/cli/src/controllers/audit.ts, the runStreamingPreRules(sqliteStorage, …) call). That path applies externalLinkCheckCap.
    • The CLI's own checkExternalLinksOnStorage in apps/cli/src/audit/adapter.ts has no caller in the audit path. squirrel analyze does not check external links at all.
    • The e2e test link-checks-not-run-e2e.test.ts asserts the cap on the real pre-rules phase.
  • (medium) The probe follows redirects without re-checking scope: fixed. The probe no longer uses checkResourceSizes. The new link-target-probe.ts follows redirects by hand and re-applies scope, robots.txt and the action filter on every hop. A redirect it may not follow is reported as its 3xx. Tested with the unit test and with the fixture, where /old-settings 302s to /logout and the probe stops there.
  • (low) The action denylist was too small: fixed and broadened.
    • Path segments, query keys and query values are split into words. Strong action words match anywhere, weak ones in short segments, and logout-style verbs run-together.
    • Token-carrying links are skipped: secret query keys, token-shaped keys and values, tokens in the path with a credential word, and JWTs.
    • So are rel=nofollow action links.
    • The probe sends HEAD only (GET only on 405/501), and never sends cookies, credentials or the audit's custom headers.
    • A fixture records zero requests to /logout, /unsubscribe?token=…, /cart/add?id=1 and /confirm/abc123def456.
    • The docs state the full model under "What the internal link check never requests". --no-internal-links is documented there as the off switch.
  • (low) Flag parsing:
    • Both orders of --external-links --no-external-links are already covered and refused.
    • --external-links=false and --external-links false are tested as off switches.
    • --no-internal-links=false is not handled: hasNegatedFlag ignores --no-x=value. That predates this PR and is shared with --no-publish, so it is left unchanged here.
  • (low) max_targets = 0: fixed. It is documented ("0 checks none; use enabled = false to switch it off"), and the Not checked message now says internal_links.max_targets is 0.
  • (low) Sorting 50,000 targets: left as is. Memory is bounded, and it runs once per audit.
  • (nit) The : boolean annotation: fixed. It now has a comment saying why.

@claude

claude Bot commented Oct 12, 2026

Copy link
Copy Markdown

Reviewed the diff, with most of my time on link-target-probe.ts and its adapter wiring. I did not run the tests. The design is careful: HEAD only, credentials omitted, manual redirects with every hop re-checked, a HEAD control, and a real-crawler fixture test. I found no blocking problems.

  • (medium) packages/audit-engine/src/link-target-probe.ts:242 The link-text filter only applies when the link is rel=nofollow. A plain <a href="/account/session/end">Log out</a> has no action word in its URL and no nofollow, so the probe sends it a HEAD. Many frameworks route HEAD to the GET handler, so that request can change state. Consider applying ACTION_TEXT to every anchor, since skipping a probe costs little and only produces more "Not checked" results.
  • (medium) packages/audit-engine/src/link-target-probe.ts:186 The action word lists are English only and cannot be complete. Say this plainly in the docs ("What the internal link check never requests") so the model is not read as a guarantee, and name --no-internal-links as the escape hatch for sites with state-changing GET routes. The probe runs by default at every level, so a miss reaches users who never opted in.
  • (low) packages/audit-engine/src/link-target-probe.ts:360 If the control request times out or errors, control.status is null and headUnreliable stays false, so a server that hangs on HEAD is treated as reliable. Treating a control that fails to answer as unreliable would be more conservative.
  • (low) packages/audit-engine/src/link-target-probe.ts:287 One timeout covers the whole redirect chain, and budget.record runs once per target. A chain of slow hops reports a plain "timeout" and loses the last status. Acceptable, just noting it.
  • (low) apps/cli/src/cli/commands/audit.ts:1149 The --external-links / --no-external-links handling combines hasFlag/hasNegatedFlag over rawArgs with citty's parsed value. It is tested but hard to follow, so a short truth-table comment would help.
  • (low) packages/audit-engine/src/link-target-probe.ts:129 looksLikeAToken skips any separator-free alphanumeric string of 20+ characters containing both letters and digits, which also matches long slugs and SKUs. That errs on the safe side, but a debug count of targets skipped as actions would help users see it.
  • (nit) packages/audit-engine/src/link-target-probe.ts:36 The long single-line arrays (RUN_TOGETHER_ACTIONS, SECRET_KEYS) are well over the line width. Format them like the sets below them if the formatter allows.
  • (nit) CHANGELOG.md The first Changed entry is one very long paragraph. Consider splitting the user-facing change from the safety details, which already live in the docs.
  • (nit) The skill update is tracked in repo#2737. Please land it soon after this, or the skill will describe the old defaults.

Test coverage is strong: the fixture checks that nothing is requested for the action URLs, the unit tables cover bypasses and false positives, and there are CLI wiring tests. One gap is a test for an action-text link without nofollow, as in the first finding.

…state the probe's limits in the docs #2729

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9

nc9 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Triage of the claude-review on 1f6f19a. Fixes are in 3585782.

  • (medium) Action text without nofollow: fixed.
    • Short text that is an unambiguous action ("Log out", "Unsubscribe", "Delete account", up to 4 words) is now skipped whatever its URL says.
    • Any action text is still skipped on a nofollow link.
    • Ambiguous text such as "Buy now" or "Subscribe" without nofollow still leaves the URL to decide. Otherwise one "Buy now" link would stop every product page from being checked, which the Opus review flagged.
    • The fixture now links <a href="/account/session/end">Log out</a> and asserts zero requests to it.
  • (medium) The lists are not a guarantee: fixed. The docs now say so plainly: English word lists, and no list can know every route a site wires to a GET. They name --no-internal-links / [internal_links] enabled = false as the off switch for sites with state-changing GET or HEAD routes. The CHANGELOG says the same.
  • (low) A control that fails to answer: kept as "unknown", on purpose.
    • A target that times out is already unanswered, never broken.
    • Only a control that does answer with an error says the site's HEAD is unreliable.
    • Treating a failed control as unreliable would drop every real 404 the targets returned, because of one dropped connection. The Opus review asked for this behaviour.
  • (low) One timeout and one budget record per redirect chain: acknowledged and left as is.
  • (low) The CLI flag logic: a truth-table comment now sits above it.
  • (low) A debug count of action skips: already reported as internalLinkProbe.outOfScope, which feeds the Not checked message ("look like actions … or carry a token").
  • (nit) Long arrays: reformatted.
  • (nit) The long CHANGELOG paragraph: split. The safety summary is now its own bullet.
  • (nit) Skill: tracked in squirrelscan/repo#2737.

@claude

claude Bot commented Oct 12, 2026

Copy link
Copy Markdown

Review of the internal link probe (repo#2729). I read the diff and the probe in full and did not run the tests or check CI.

The probe is built defensively and I found nothing that should block the merge. It sends HEAD only, falls back to GET on 405/501, sends no credentials, follows redirects by hand with the same checks on every hop, and has a HEAD-reliability control. There is also a lot of test coverage for it.

  • (medium) packages/audit-engine/src/adapter.ts (linkTargets in the allResourceChecks Effect.all): the probe's concurrency is capped at per_host_concurrency, but it runs alongside the PDF, sitemap and resource checks, which hit the same host. The combined in-flight requests can therefore exceed the crawl's per-host limit, and the comment saying the probe uses the crawl's per-host concurrency overstates what happens. Consider running the probe after those checks, or sharing one per-host limiter.
  • (medium) packages/audit-engine/src/link-target-probe.ts: the filter is a deny-list of heuristic words, so a state-changing GET with an unusual verb (/export, /send, /publish, /archive, /mark-read) is still probed by default at every level. I understand the tradeoff and the mitigation is good. Because this is now on by default, the docs should say plainly that internal links get a HEAD request, and that internal_links.enabled = false is the opt-out. Please check that docs/configuration/output.mdx and docs/cli/audit.mdx do.
  • (low) link-target-probe.ts probeOne: any response, including 5xx, is recorded to the fetch budget as "ok". That could hide a tarpitting or erroring host from the budget's degradation logic.
  • (low) adapter.ts (mayProbe): robots.txt Crawl-delay is not honoured. It is only an isAllowed check, so up to 200 HEADs can go out faster than the site asked for.
  • (low) adapter.ts (nofollowActionTargets): it runs querySelectorAll("a[href]") over every page's DOM, which is a second full anchor pass in the collector. This is probably fine, but check it on very large crawls. The 50k-target cap bounds the map but not this scan.
  • (low) link-target-probe.ts (looksLikeAToken): the 20+ character mixed-case alphanumeric rule will skip legitimate long slugs or CamelCase page names such as /Documentation2024OverviewGuide. That is a safe false positive. The cost is that those pages never get checked and are counted in outOfScope, so make sure the report text makes that distinction clear.
  • (nit) adapter.ts: looksLikeAnAction is imported and also re-exported from the same module (export { looksLikeAnAction } from "./link-target-probe"). One of the two is redundant.
  • (nit) adapter.ts: the probed: line is over the line length used elsewhere in the file, so run the formatter.

…link check sends HEAD and how to turn it off #2729

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9

nc9 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Triage of the claude-review on 3585782 (no blockers). Fixes are in the new head.

  • (medium) Per-host concurrency: the probe never has more of its own requests in flight than per_host_concurrency. The asset pools that run beside it (CSS, images, PDFs, sitemap) kept their own limits before this PR and still do. I corrected the comment and the docs so they say exactly that: "its own requests". The order is unchanged, because running the probe after the asset pools would add its whole duration to every audit.
  • (medium) Say plainly that it sends HEAD, and how to turn it off: done.
    • docs/cli/audit.mdx (--no-internal-links: "one HEAD request each, on by default at every level").
    • docs/configuration/output.mdx (the link-targets-not-fetched reason).
    • The safety section, which now says the word lists are a default, not a guarantee, and names the off switch for sites with state-changing GET/HEAD routes.
  • (low) A 5xx was recorded as "ok": fixed. It now counts as an error strike.
  • (low) Crawl-delay: acknowledged. The probe's own concurrency is held to the crawl's per-host limit, but it does not pace by Crawl-delay. Neither do the existing asset checks.
  • (low) Second anchor pass: acknowledged. It is one querySelectorAll per page the collector already holds a DOM for.
  • (low) Long CamelCase names counted as tokens: a deliberate safe false positive. They count in outOfScope, and the Not checked message names "carry a token" as a reason.
  • (nit) Import plus re-export: both are needed. export { x } from creates no local binding, and mayProbe uses looksLikeAnAction locally. The re-export keeps the adapter's public API.
  • (nit) Long line: wrapped.

@claude

claude Bot commented Oct 12, 2026

Copy link
Copy Markdown

Review of PR 721. I read the PR description and packages/audit-engine/src/link-target-probe.ts in full. I did not review the CLI/MCP wiring, rules, report or docs diffs, and I did not run the tests.

The probe is built carefully. There are no credentials, HEAD only (with a ranged GET after 405/501), manual redirects with every hop re-checked, and a deliberately conservative action filter. I found nothing that should block the merge.

  • (low) link-target-probe.ts:352-361: one AbortController timer covers the HEAD, the fallback GET and every redirect hop. A slow HEAD followed by a 405 can leave the GET almost no time, so it reports "timeout" even though the target is fine. Consider a per-request timeout, or document that the timeout is per target.
  • (low) link-target-probe.ts:334: response.body?.cancel() is fire-and-forget. That is fine for HEAD. For the ranged GET, a server that ignores Range streams the full body until the cancel lands. It is capped at 200 targets, so this is minor, but you could await the cancel.
  • (low) link-target-probe.ts:398-406: if the control URL's HEAD fails with a network error, headUnreliable stays false and later 4xx/5xx results are trusted. This matches the comment "no answer says nothing", but a control that times out is a weak signal worth a mention in the docs.
  • (nit) link-target-probe.ts:31-38: the doc comment on the word-splitting rules sits above RUN_TOGETHER_ACTIONS and is not attached to anything. Move it onto words or hasActionWords.
  • (nit) credentials: "omit" has no effect in Node/Bun server-side fetch. It does no harm, but the real protection is not sending headers, so the comment could say that.
  • (nit) A false positive is the cheap failure for the action filter: /cart, /like, /follow and ?state= are skipped, so a real 404 there goes unreported. That is the right trade-off, but it may be worth a line in the docs page that lists what is not requested.

@nc9

nc9 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Triage of the claude-review on a75341f. It found nothing blocking, and I am leaving its low findings and nits as they are rather than push again:

  • The timeout is per target, not per request. This is deliberate: one target never holds a slot longer than timeout_ms. A HEAD that times out leaves the target unanswered, never broken.
  • Fire-and-forget body cancel on the ranged GET. A ranged GET is sent only after a 405 or 501, there are at most 200 targets, and the body is never read.
  • A control that gets no answer means "unknown". The docs say an error answer is what stops the targets' errors being trusted.
  • Comment placement and credentials: "omit". The real protection is the explicit header set. The flag is defence in depth for runtimes that do keep cookies.
  • False positives such as /cart and ?state=. The docs list both the words and the tiers, and give /cart and /password/reset as examples of links that are skipped.

@nc9
nc9 merged commit adf0dde into main Oct 12, 2026
15 checks passed
@nc9
nc9 deleted the feat/link-checks-on-by-default branch October 12, 2026 18:02
@nc9 nc9 mentioned this pull request Oct 12, 2026
nc9 pushed a commit that referenced this pull request Oct 12, 2026
Brings in the internal link checks (#721) and release 0.0.111. The one
conflict is in packages/audit-engine/src/adapter.ts: the third-party asset
checks (#703) and the link-target probe both join the same asset Effect.all,
and both fallbacks keep their fields. The fixture test's storage stub gains
getRobotsTxt, which the merged asset phase calls.

Signed-off-by: Claude <[email protected]>
Co-Authored-By: Claude <[email protected]>
Claude-Session: https://claude.ai/code/session_01EAUNUbvoEuJsAyiazrJXLH
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.

1 participant