Repository navigation
feat(crawler): say when the crawl's base is the wrong host of a pair - #249
Merged
Merged
Conversation
The second detector for squirrelscan/repo#1899. #248 stopped a mis-pinned base from collapsing the crawl to one page, which fixed the damage but not the silence: the audit still describes a host the site redirects away from, and now it does so while looking entirely healthy. That is how this went unnoticed for weeks and how a paying customer was charged for a one-page audit of a ten-page site. The base is pinned from one probe of the seed before anything is fetched. The seed page's own fetch is the first thing that can contradict it, and three things about it are evidence, in descending strength: - where the fetch LANDED. Outside the HTML branch and needing no body, so a seed serving a PDF still proves which host the site is on. - the CANONICAL the page declares, resolved against the page since it may be relative, and only on a 2xx: an error page's canonical describes the error template. - the page's LINKS, when not one of them points back at the base. Read off parsed.links rather than the crawlable set, because that set is already filtered to the page's own hostname and so is empty on exactly the origin this describes. One link home is enough to stay silent; a single stray same-site link proves nothing. A different SITE is not this. That is the #1418 case, refused deliberately by resolveSeedRedirect and logged where it happens; repeating it here would turn a security decision into a bug report. It reports and does not move the base. It cannot: the root probes have already run against it, and re-basing mid-crawl would file one origin's content under another's name. So it fires on crawls that then succeed, deliberately. The message says what was observed and offers the missed redirect as the likely cause rather than asserting it, since an apex can serve content and canonicalise elsewhere without ever redirecting. Carried on a new `warning` member of CrawlerEvent rather than logger.warn alone: a log line reaches a terminal or a container's stdout, neither of which is where a hosted run is investigated weeks later. Note that CrawlerEvent is DUPLICATED between core-contracts and the crawler's own types.ts; both move here, and the shared CrawlWarningCode keeps the machine key from drifting. No consumer handles the type yet, so it is inert until one does. The test collector now records every event and joins its fiber instead of ignoring the timeout, so a silent-warning assertion cannot pass against a dead subscription. squirrelscan/repo#1899 Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
fix/seed-base-mismatch-warning-1915
branch
from
September 7, 2026 19:08
201f828 to
34aedac
Compare
4 tasks
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.
The second detector for squirrelscan/repo#1899, requested after #248 merged.
#248 stopped a mis-pinned base from collapsing the crawl to one page. That fixed the damage but not the silence: the audit still describes a host the site redirects away from, and now it does so while looking entirely healthy. That silence is how this went unnoticed for weeks, and how a paying customer was charged in full for a one-page audit of a ten-page site.
What it detects
The base is pinned from one probe of the seed before anything is fetched. The seed page's own fetch is the first thing that can contradict it, and three things about it are evidence, in descending strength:
parsed.linksrather than the crawlable set, because that set is already filtered to the page's own hostname and so is empty on exactly the origin this describes: an apex serving the site while every link points atwww. One link home is enough to stay silent.A different site is not this. That is the #1418 case, refused deliberately by
resolveSeedRedirectand logged where it happens; repeating it here would turn a security decision into a bug report.It reports once per crawl and does not move the base. It cannot: the root probes have already run against it, and re-basing mid-crawl would file one origin's content under another's name. So it fires on crawls that then succeed, deliberately. The message states what was observed and offers the missed redirect as the likely cause rather than asserting it, since an apex can serve content and canonicalise elsewhere without ever redirecting.
Why an event and not just a log line
logger.warnreaches a terminal or a container's stdout, neither of which is where a hosted run is investigated weeks later. This rides the event stream the run already records, on a newwarningmember ofCrawlerEvent.Two things a reviewer should know:
CrawlerEventis duplicated, inpackages/core-contracts/src/index.tsand in the crawler's ownsrc/core/types.ts. Consumers outside the crawler package read the core-contracts copy, so an event added to one and not the other type-checks locally and is invisible to every consumer. Both move here, and the sharedCrawlWarningCodekeeps the machine key from drifting.page:*,progress,completed,started,resumedandurl:*, and the hosted container forwards onlyprogress,page:fetchedandpage:failed. A small handler on the private side is what lands it inagent_run_events, and is tracked separately.Tests
packages/crawler/tests/seed-base-collapse.test.tsgrows to 21 cases, covering each detector, the once-per-crawl guard, and the cases that must stay silent: a base that agrees with its seed page, one link back to the base, an in-page anchor ormailto:that must not veto the link evidence, and unrelated domains that must neither trigger it nor be named in the message.The collector now records every event type and joins its fiber with a failing timeout instead of ignoring it, so a silent-warning assertion can no longer pass against a dead subscription. The silent case asserts it saw
page:fetchedandcompleted.Two codex rounds on the diff; every finding addressed or answered with evidence. The fragment-veto concern turned out not to be reachable, because
shouldSkipUrldrops#-only hrefs and non-crawlable schemes beforeparsed.linksis built, and there is now a test pinning that.Green locally: the new suite, plus
seed-redirect-pinning,carried-seed-crawl,full-crawl-harness,trailing-slash-canonical-crawl,incremental-freshness,sitemap-gate,rate-limit-crawl,slow-origin-crawl,injectable-cache-store,deterministic-ordering.tsgo --noEmitclean for the crawler and the CLI, oxfmt and oxlint clean.Refs squirrelscan/repo#1899