Skip to content

feat(crawler): let users turn off the pre-crawl discovery probes (#409) - #419

Merged
nc9 merged 3 commits into
mainfrom
feat/discovery-probes-switch-409
Sep 30, 2026
Merged

nc9 merged 3 commits into
mainfrom
feat/discovery-probes-switch-409

Conversation

@nc9

@nc9 nc9 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #409

A common fail2ban "sensitive files" jail bans the auditing IP when an audit asks for /swagger.json or /openapi.json, and every request after that gets connection refused. This adds a switch for the pre-crawl discovery probes, makes them follow the rule selection, reports a probe that was not sent or got no answer as "not checked", and puts the probes behind the per-host throttle.

What the switch covers

Every pre-crawl request except robots.txt, sitemap discovery and the seed page, in the order they go out:

Probe Requests Read by
llms-txt /llms.txt, /llms-full.txt ax/llms-txt, ax/agents-md
markdown / with Accept: text/markdown, /index.md ax/markdown-response
agent-access / as browser, GPTBot, Claude-User ax/agent-blocking, ax/pay-per-crawl
20 well-known paths, one probe each /.well-known/mcp*, agent-card.json, agent-skills/index.json, api-catalog, /openapi.json, /swagger.json, /api/openapi.json, the two OAuth docs, four AGENTS.md paths, two ai-plugin.json, two alt llms.txt ax/well-known-agent, ax/api-discovery, ax/agents-md, ax/llms-txt
rsl the robots.txt re-read for License: plus the documents it names ax/rsl-license

The AI-crawler homepage fetches are in: a WAF that blocks GPTBot can ban on them too. They go out before the well-known sweep, so the weight-3 ax/agent-blocking is the last reader to lose the budget on a slow host.

How

  • Switch. [crawler] disable_discovery_probes = true and squirrel audit --disable-discovery-probes send none (named per the decision on the issue: "disable would be preferred"; nothing has shipped, so no alias). The zod field is optional and unset means probes on, so a config without it (every cloud run) and code that builds a Config by hand are unchanged. The flag is a plain boolean citty delivers itself and overrides the config both ways: --disable-discovery-probes=false sends the probes for one run when the config turns them off; repeated, the last one wins. squirrel crawl honours the config value; the flag is on audit only.
  • Rule selection. Rules declare what they read (RuleMeta.discoveryProbes, typed against WELL_KNOWN_PATHS, now in core-contracts). selectDiscoveryProbes takes the union over the enabled rules (config enable/disable, --rule-include/--rule-exclude, per-rule enabled = false, the ai alias, plugin namespaces when a caller has them), and the CLI passes it as CrawlerConfig.discoveryProbes. Unset sends everything, so the cloud runtime, which builds its own crawler config, sends what it always sent. --rule-exclude ax/api-discovery drops only the six API/OAuth paths.
  • Not checked. A probe that was not sent (turned off, unselected, cut by the preamble budget) or that went out and got no answer (refused, timed out, aborted at the deadline) is reported as <thing> not checked: <reason> at info status with value not-checked, never as a missing file, and is not scored. llms, markdown and the RSL robots read store no row in those cases (test(cli): request-deadline 'checkReachability ... stalled body' test fails on macOS (127.0.0.2 is not routable) #1733 stored an empty shape there, so the rule said "No /llms.txt found" for a file never answered; preamble-budget.test.ts is updated to match). The well-known and pay-per-crawl readers treat status: 0 as unchecked. ax/agent-blocking keeps skipped/inconclusive, and ax/rsl-license still calls a named license document it could not fetch a broken reference. ax/llms-txt still reports a real /.well-known/llms.txt or /docs/llms.txt when the root got no answer.
  • Throttle. Probes take slots from their own per-host scheduler and space their starts through the shared page scheduler, at per_host_concurrency and per_host_delay_ms. A cloud-rendered CLI audit clamps pages to the plan's render concurrency (1 on free, 0ms), so the CLI passes the unclamped values as discoveryProbePerHost: the probes are plain HTTP, and behind the clamp all 28 ran in series. Not a robots.txt Crawl-delay: at the 2s cap, 28 probes would outlast the 45s budget on every respect_robots audit of such a site. Queueing never outlasts the budget (a start slot past the deadline is not reserved), the gate is acquireUseRelease, and interrupting the crawl aborts the probes still waiting for a slot.
  • Letting the audit through instead. The docs say how, for a CLI audit from your own machine: your IP in fail2ban's ignoreip, or a secret header sent with -H that a WAF rule skips on (the probes, robots.txt, sitemaps and pages carry it; the checks that resolve the start URL before the crawl do not). They link Firewall and WAF exceptions, and so does the failed-audits guide.
  • Test hygiene. The content store and link cache are process-wide singletons. The --no-publish wiring test from fix(cli): --no-publish stops the auto-publish attempt (#404) #417 left them open inside its deleted scratch dir, and every later file's offline audits then failed with "No pages were crawled". Its afterAll now closes both, and the new wiring test closes them on entry and exit, so the pair passes in either order.

Request logs

Local server that logs every request, squirrel audit http://localhost:48409/ -m 2 -C quick --offline, scratch HOME. Leading GET / lines are the reachability check and seed resolution.

default: all 28 probes, including the browser-UA homepage and the second robots.txt (RSL)
  1215ms GET /
  1241ms GET /
  1252ms GET /
  1253ms GET /robots.txt
  1255ms GET /llms.txt
  1255ms GET /llms-full.txt
  1256ms GET / [Accept: text/markdown]
  1256ms GET /index.md [Accept: text/markdown]
  1256ms GET /
  1257ms GET / [GPTBot]
  1257ms GET / [Claude-User]
  1257ms GET /.well-known/mcp/server-card.json
  1258ms GET /.well-known/mcp.json
  1258ms GET /.well-known/mcp
  1258ms GET /.well-known/mcp-server
  1258ms GET /swagger.json
  1258ms GET /.well-known/agent-card.json
  1258ms GET /.well-known/api-catalog
  1258ms GET /openapi.json
  1258ms GET /.well-known/agent-skills/index.json
  1258ms GET /agents.md
  1259ms GET /AGENTS.md
  1259ms GET /.well-known/oauth-protected-resource
  1259ms GET /.well-known/agents.md
  1259ms GET /docs/AGENTS.md
  1259ms GET /.well-known/oauth-authorization-server
  1259ms GET /api/openapi.json
  1259ms GET /ai-plugin.json
  1259ms GET /.well-known/ai-plugin.json
  1259ms GET /.well-known/llms.txt
  1259ms GET /docs/llms.txt
  1261ms GET /robots.txt
  1265ms GET /sitemap.xml
  1266ms GET /sitemap_index.xml
  1266ms GET /sitemap-index.xml
  1266ms GET /sitemaps.xml
  1266ms GET /sitemap1.xml
  1268ms GET /post-sitemap.xml
  1268ms GET /page-sitemap.xml
  1268ms GET /news-sitemap.xml
  1277ms GET /about
  1277ms GET /
--disable-discovery-probes: no probes; robots.txt once, sitemaps, pages
  1073ms GET /
  1097ms GET /
  1104ms GET /
  1105ms GET /robots.txt
  1108ms GET /sitemap.xml
  1108ms GET /sitemap_index.xml
  1108ms GET /sitemaps.xml
  1109ms GET /sitemap-index.xml
  1109ms GET /sitemap1.xml
  1111ms GET /post-sitemap.xml
  1111ms GET /page-sitemap.xml
  1111ms GET /news-sitemap.xml
  1120ms GET /about
  1120ms GET /
stored checks:
   ax/agent-blocking agent-blocking [skipped] not-checked: Agent access not checked: the discovery probe was not sent
   ax/agents-md agents-md [info] not-checked: AGENTS.md not checked: the discovery probe was not sent
   ax/api-discovery api-discovery [info] not-checked: API and OAuth discovery documents not checked: the discovery probe was not sent
   ax/llms-txt llms-txt [info] not-checked: /llms.txt not checked: the discovery probe was not sent or got no answer
   ax/markdown-response markdown-response [info] not-checked: Markdown response not checked: the discovery probe was not sent or got no answer
   ax/pay-per-crawl pay-per-crawl [info] not-checked: Monetized agent access not checked: the discovery probe was not sent
   ax/rsl-license rsl-license [info] not-checked: RSL licensing not checked: the discovery probe was not sent or got no answer
   ax/well-known-agent well-known-agent [info] not-checked: Agent manifests not checked: the discovery probe was not sent
report: score 47, ax issues: []
[crawler] disable_discovery_probes = true
  1062ms GET /
  1084ms GET /
  1092ms GET /
  1093ms GET /robots.txt
  1096ms GET /sitemap.xml
  1096ms GET /sitemap_index.xml
  1096ms GET /sitemap1.xml
  1096ms GET /sitemaps.xml
  1096ms GET /sitemap-index.xml
  1099ms GET /post-sitemap.xml
  1099ms GET /page-sitemap.xml
  1099ms GET /news-sitemap.xml
  1108ms GET /about
  1108ms GET /
disable_discovery_probes = true plus --disable-discovery-probes=false: the flag wins, all probes go out
  1060ms GET /
  1086ms GET /
  1093ms GET /
  1094ms GET /robots.txt
  1096ms GET /llms.txt
  1096ms GET /llms-full.txt
  1097ms GET / [Accept: text/markdown]
  1097ms GET /index.md [Accept: text/markdown]
  1098ms GET /
  1098ms GET / [GPTBot]
  1098ms GET / [Claude-User]
  1098ms GET /.well-known/mcp/server-card.json
  1098ms GET /.well-known/mcp.json
  1098ms GET /.well-known/mcp
  1099ms GET /.well-known/mcp-server
  1099ms GET /.well-known/agent-card.json
  1099ms GET /.well-known/agent-skills/index.json
  1099ms GET /.well-known/api-catalog
  1099ms GET /openapi.json
  1099ms GET /swagger.json
  1099ms GET /AGENTS.md
  1100ms GET /api/openapi.json
  1100ms GET /.well-known/oauth-authorization-server
  1100ms GET /.well-known/oauth-protected-resource
  1100ms GET /agents.md
  1100ms GET /docs/AGENTS.md
  1100ms GET /.well-known/agents.md
  1100ms GET /ai-plugin.json
  1100ms GET /.well-known/ai-plugin.json
  1100ms GET /.well-known/llms.txt
  1100ms GET /docs/llms.txt
  1102ms GET /robots.txt
  1104ms GET /sitemap.xml
  1104ms GET /sitemap_index.xml
  1104ms GET /sitemap-index.xml
  1104ms GET /sitemaps.xml
  1104ms GET /sitemap1.xml
  1106ms GET /post-sitemap.xml
  1106ms GET /page-sitemap.xml
  1106ms GET /news-sitemap.xml
  1116ms GET /about
  1116ms GET /
--rule-exclude ax (no other setting)
  1052ms GET /
  1082ms GET /
  1090ms GET /
  1090ms GET /robots.txt
  1094ms GET /sitemap.xml
  1094ms GET /sitemap_index.xml
  1094ms GET /sitemaps.xml
  1094ms GET /sitemap-index.xml
  1094ms GET /sitemap1.xml
  1097ms GET /post-sitemap.xml
  1097ms GET /page-sitemap.xml
  1097ms GET /news-sitemap.xml
  1105ms GET /about
  1105ms GET /
--per-host 1 with per_host_delay_ms = 150: one probe at a time, ~150ms apart
  1077ms GET /
  1101ms GET /
  1108ms GET /
  1109ms GET /robots.txt
  1111ms GET /llms.txt
  1261ms GET /llms-full.txt
  1412ms GET / [Accept: text/markdown]
  1562ms GET /index.md [Accept: text/markdown]
  1712ms GET /
  1861ms GET / [GPTBot]
  2012ms GET / [Claude-User]
  2166ms GET /.well-known/mcp/server-card.json
  2317ms GET /.well-known/mcp.json
  2461ms GET /.well-known/mcp
  2613ms GET /.well-known/mcp-server
  2764ms GET /.well-known/agent-card.json
  2911ms GET /.well-known/agent-skills/index.json
  3062ms GET /.well-known/api-catalog
  3212ms GET /openapi.json
  3362ms GET /swagger.json
  3512ms GET /api/openapi.json
  3663ms GET /.well-known/oauth-authorization-server
  3814ms GET /.well-known/oauth-protected-resource
  3962ms GET /AGENTS.md
  4115ms GET /agents.md
  4262ms GET /.well-known/agents.md
  4412ms GET /docs/AGENTS.md
  4562ms GET /ai-plugin.json
  4712ms GET /.well-known/ai-plugin.json
  4862ms GET /.well-known/llms.txt
  5012ms GET /docs/llms.txt
  5162ms GET /robots.txt
  5172ms GET /sitemap.xml
  5173ms GET /sitemap_index.xml
  5173ms GET /sitemap1.xml
  5174ms GET /sitemaps.xml
  5174ms GET /sitemap-index.xml
  5182ms GET /post-sitemap.xml
  5183ms GET /page-sitemap.xml
  5183ms GET /news-sitemap.xml
  5317ms GET /about
  5462ms GET /

Preamble timing (real site, default settings)

squirrelscan.com, createCrawler defaults (per_host_concurrency 5, per_host_delay_ms 50), 5 runs each, window from the end of the first robots.txt read to the start of sitemap discovery:

probe window (min / median / max) start to first page (median)
before 593 / 680 / 1037 ms 1279 ms
after 1455 / 1493 / 1499 ms 2323 ms

About +0.8s, which is the 50ms stagger over 28 requests. The budget is 45s, so a normal site uses about 3% of it.

Tests

  • crawler: tests/discovery-probes.test.ts (all on / none / a subset; per-host concurrency 1 and 3; delay spacing; discoveryProbePerHost sizing the probe slots apart from a render-clamped page limit; queue bounded by the budget; interruption stops queued probes; no answer keeps no llms/markdown/RSL row), preamble-budget.test.ts updated.
  • rules: tests/discovery-probes.test.ts (selection, every probe has a reader, plugin namespaces), not-checked cases (not sent, budget-skipped, no answer) in the eight ax rule tests, the llms.txt alt-path hit with no root answer.
  • cli: tests/commands/audit-discovery-probes-wiring.test.ts drives runCommand(audit, { rawArgs }) and asserts on requests: default, --disable-discovery-probes, config true, flag over config false, =false over config true, --rule-exclude ax, --rule-exclude ax/api-discovery; plus citty's own parse of the flag (absent, set, =false, =true, before the URL, repeated). tests/controllers/crawl-concurrency.test.ts: the free-plan render case keeps the probes on the configured per-host limits.
  • tsgo clean in core-contracts, config, crawler, rules, audit-engine, report, cli; oxfmt and oxlint clean on apps/cli; tangly check --strict passes.

Not in this PR

  • --disable-discovery-probes on squirrel crawl (the config value applies there).
  • The RSL probe still re-reads robots.txt instead of reusing the first read, and sitemap discovery is not behind the per-host throttle.
  • restartCrawl (no production caller) keeps the instance's discoveryProbes/discoveryProbePerHost rather than persisting them in the stored crawl config, like the other instance-level options (documentFetcher).

nc9 added 3 commits September 30, 2026 11:39
Before the first page every audit sent ~28 root requests for agent files:
llms.txt, markdown negotiation, 20 well-known paths including /swagger.json
and /openapi.json, the homepage as GPTBot/Claude-User, and an RSL robots.txt
re-read. A common fail2ban "sensitive files" jail bans the auditing IP for
/swagger.json, so the audit failed right after it started.

- [crawler] discovery_probes = false and squirrel audit --no-discovery-probes
  send none of them; robots.txt, sitemap discovery and the seed still run.
  The config field is optional and unset means on, so cloud runs are unchanged.
- Rules declare the probes they read (RuleMeta.discoveryProbes) and the CLI
  sends only the ones an enabled rule reads: --rule-exclude ax sends none,
  --rule-exclude ax/api-discovery drops only its paths.
- A probe that was not sent, turned off, unselected or cut by the preamble
  budget, reports "not checked" (value not-checked), never a missing file.
- Probes queue behind per_host_concurrency and per_host_delay_ms. Queueing
  never outlasts the preamble budget, and interrupting the crawl aborts the
  probes still waiting for a slot.
- --no-discovery-probes is read from argv (cli/flags.ts, same helper as the
  --no-publish fix): citty never sets a declared no-* arg.

Signed-off-by: Nik Cubrilovic <[email protected]>
…ceptions (#409)

Per the decision on the issue ("disable would be preferred"), and nothing has
shipped yet, so no alias:

- --no-discovery-probes becomes --disable-discovery-probes, a plain boolean
  citty delivers itself (no rawArgs read). It overrides the config both ways:
  --disable-discovery-probes=false sends the probes when the config turns
  them off. A repeated flag arrives as an array; the last one wins.
- [crawler] discovery_probes = false becomes disable_discovery_probes = true.
  Still optional in the shared schema, so absent means probes on.
- Docs say how to let the audit through instead of turning the probes off (own
  IP in fail2ban's ignoreip, or a secret -H header a WAF rule skips on) and
  link the firewall exceptions page, also from the failed-audits guide.
- The CLI wiring test closes the process-wide content store and link cache on
  entry and exit: a handle left in another file's deleted scratch dir made
  every later offline audit fail with "No pages were crawled".

Signed-off-by: Nik Cubrilovic <[email protected]>
- Probes take slots from their own per-host scheduler, sized by
  discoveryProbePerHost: a cloud-rendered CLI audit clamps pages to the plan's
  render concurrency (1 on free, no delay), and the plain-HTTP probes queued
  behind it ran in series and could lose the budget on a slow host. The CLI
  passes the unclamped per_host_concurrency and per_host_delay_ms.
- agent-access goes out before the 20-path well-known sweep, so the weight-3
  ax/agent-blocking is the last reader to lose its budget.
- The gate uses acquireUseRelease (acquire kept interruptible), so an
  interrupt between acquire and use cannot leak a slot.
- No answer is not checked: a probe that went out and got none (refused,
  timed out, cut at the deadline) no longer reads as a missing file. llms,
  markdown and RSL store no row; the well-known and pay-per-crawl readers
  treat status 0 as unchecked, and the message says which.
- ax/llms-txt reports a real /.well-known/llms.txt or /docs/llms.txt even when
  the root /llms.txt got no answer.
- selectDiscoveryProbes takes plugin namespaces like the runner does.
- The --no-publish wiring test closes the process-wide content store and link
  cache in afterAll; left open in its deleted scratch dir they failed every
  later file's offline audits.
- Docs: "is not scored"; suggest per_host_concurrency = 1 for touchy sites.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the feat/discovery-probes-switch-409 branch from 839df75 to 4294b2d Compare September 30, 2026 02:01
@nc9
nc9 marked this pull request as ready for review September 30, 2026 02:17
@nc9
nc9 merged commit 0bf05c0 into main Sep 30, 2026
14 checks passed
@nc9
nc9 deleted the feat/discovery-probes-switch-409 branch September 30, 2026 02:17
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.

crawler: let users turn off the pre-crawl discovery probes (swagger.json/openapi.json get the audit IP banned by fail2ban)

1 participant