Skip to content

chore(cli,crawler): remove dead link-analysis and csr-detect code, one CrawlerEvent declaration, notices bundler guard (#261, #700, #251, #657) - #888

Merged
nc9 merged 4 commits into
mainfrom
chore/batch-b-dead-code
Oct 16, 2026
Merged

nc9 merged 4 commits into
mainfrom
chore/batch-b-dead-code

Conversation

@nc9

@nc9 nc9 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Four small chores. Each has its own commit.

Closes #261, closes #700, closes #251, closes #657.

#261: unreachable link-analysis module

apps/cli/src/links/index.ts (extractEnhancedLinks, analyzeInternalLinks, analyzeAnchorText, validateInternalLinks, validateAnchorText) had no production caller: only tests/link-analysis.test.ts imported it. This PR removes it, along with:

  • that test,
  • its two HTML fixtures (nothing else read them),
  • the three types only it used: EnhancedLinkData, InternalLinkAnalysis, AnchorTextAnalysis.

PageAudit.links stays unpopulated, as #1938 left it. The report's link findings come from packages/rules/src/links and are untouched.

#700: legacy crawl modules

#782 had already removed crawl/sitemaps.ts, robots.ts and index.ts. What was left:

  • apps/cli/src/crawl/csr-detect.ts: a 7-line re-export of @squirrelscan/fetchers, imported only by its test. Removed. The test now imports @squirrelscan/fetchers directly.
  • The robots and sitemap fixtures the removed modules' tests read: nothing references them anymore. Removed.

src/crawl/hybrid-fetcher.ts, which controllers/audit.ts imports, is the only file left under src/crawl/.

#251: one CrawlerEvent

The crawler's hand-kept copy had already drifted. Its page:fetched lacked ttfbMs, fetcherId and rendered, which core-contracts declares and the cloud's debug events read.

  • packages/core-contracts now declares the named per-event interfaces (CrawlerStartedEvent through CrawlerErrorEvent) and the union of them.
  • packages/crawler/src/core/types.ts re-exports them instead of restating them. Existing importers of the named types, such as crawler.ts's CrawlerPageUnchangedEvent, resolve as before.
  • An event added in one place now compiles everywhere or fails everywhere.
  • completed.stats is CrawlStats, which the crawler already emitted. It replaces a narrower inline copy and every field consumers read is still there.

Not changed here: the crawler still does not emit ttfbMs or fetcherId on page:fetched, although its page record has both. Wiring them into the event would change what the cloud records, so that is left for its own change.

#657: notices guard for bundled packages

The bundled-package scan moves to scripts/third-party-bundled.ts. notices:generate and notices:check now fail when @modelcontextprotocol/server, the one runtime dependency known to bundle packages, yields nothing from the marker scan. The error names the dependency and says to check its dist by hand, then update the scan or scripts/third-party-embedded/.

A dependency that is not installed is never visited, so it cannot trip the guard. scripts/third-party-bundled.test.ts covers:

  • plain and scoped markers,
  • skipping nested node_modules,
  • the guard on a marker-free dist and its message,
  • the installed @modelcontextprotocol/server, which still carries markers.

Checks

  • tsgo --noEmit: packages/core-contracts, packages/crawler, packages/audit-engine and apps/cli are all clean. The scripts were type-checked strict.
  • bun test:
    • apps/cli tests/crawler/csr-detect.test.ts and tests/crawler/hybrid-fetcher.test.ts: 14 pass.
    • packages/crawler tests/seed-base-collapse.test.ts and tests/preamble-budget.test.ts: 32 pass.
    • scripts/third-party-bundled.test.ts: 3 pass.
  • bun run notices:check: up to date (67 packages).
  • Engine golden suite once at this sha: 209 pass, 0 fail.
  • oxfmt and oxlint on the changed CLI files: clean.
  • Codex review: no findings. A whole-repo search found no remaining reference to any removed file or fixture.

Docs: no user-facing change. Agent skill: no change needed.

@nc9
nc9 marked this pull request as ready for review October 16, 2026 16:00
@claude

claude Bot commented Oct 16, 2026

Copy link
Copy Markdown

Reviewed the diff. The removals look clean: I found no remaining references to the deleted link-analysis module, crawl/csr-detect, the removed fixtures, or the three dropped types. The CrawlerEvent consolidation moves the contract into core-contracts and re-exports it from the crawler. CI typecheck and lint pass. Some checks (golden tests) were still pending when I looked.

  • (nit) scripts/third-party-bundled.ts: match[1]!.replace("+", "/") only replaces the first +. This was already the case before the move, and scoped names have only one +, so it's harmless.
  • (nit) The silent-bundler guard only checks KNOWN_BUNDLERS by exact name. A new bundling dependency won't be covered until someone adds it to the set. The set's doc comment mentions this, so it's acceptable.
  • (low) The crawler still doesn't emit ttfbMs or fetcherId on page:fetched. The PR description says this is intentional. A follow-up issue would keep it from being forgotten.

No blocking issues.

@nc9

nc9 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Review triage, no code change:

nc9 added 4 commits October 17, 2026 03:26
apps/cli/src/links/index.ts (extractEnhancedLinks, analyzeInternalLinks, analyzeAnchorText, validateInternalLinks, validateAnchorText) had no production caller: only its own test imported it. Removed with that test, its two HTML fixtures and the three types only it used (EnhancedLinkData, InternalLinkAnalysis, AnchorTextAnalysis). PageAudit.links stays unpopulated as #1938 left it; the report's link findings come from packages/rules/src/links.

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

pub#782 already removed the CLI's legacy crawl/sitemaps, robots and index modules. Left: apps/cli/src/crawl/csr-detect.ts, a re-export of @squirrelscan/fetchers that only its test imported. The test now imports the fetchers module directly. The robots/sitemap fixtures those removed modules' tests read are gone too; nothing referenced them. hybrid-fetcher.ts, imported by the audit controller, is the only file left under src/crawl.

Signed-off-by: Nik Cubrilovic <[email protected]>
#251)

The crawler kept a second, hand-maintained CrawlerEvent union that had already drifted: its page:fetched lacked ttfbMs, fetcherId and rendered, which core-contracts declares and the cloud's debug events read. core-contracts now declares the named per-event interfaces (CrawlerStartedEvent ... CrawlerErrorEvent) and the union of them; packages/crawler re-exports them instead of restating them, so an event added in one place compiles everywhere or fails everywhere. completed.stats is CrawlStats, which the crawler already emitted.

Signed-off-by: Nik Cubrilovic <[email protected]>
…ed packages (#657)

The bundled-package scan moves to scripts/third-party-bundled.ts. notices:generate and notices:check now fail, naming the dependency and what to check by hand, when @modelcontextprotocol/server (the one runtime dependency known to bundle packages) yields nothing from the marker scan, instead of silently dropping its bundled packages from THIRD_PARTY_NOTICES.md. Tested on fixtures and on the installed package.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the chore/batch-b-dead-code branch from 08306ea to 849fccb Compare October 16, 2026 16:27
@claude

claude Bot commented Oct 16, 2026

Copy link
Copy Markdown

Review of #888: dead-code removal, event-type dedup, and a third-party-notices guard.

I found no blocking problems. A grep of the repo found no remaining references to the deleted apps/cli/src/links, the crawl/csr-detect shim, the removed link-analysis types, or the deleted fixtures. I did not run the build or tests, and CI was still pending when I looked.

  • (low) packages/crawler/src/core/types.ts: the crawler's CrawlerPageFetchedEvent now picks up ttfbMs, fetcherId and rendered, which the old local copy did not have. That is probably intended, since it is the point of the dedup. Please confirm that no emit site or exhaustive consumer is affected, and that CI typecheck is green.
  • (low) The PR mixes three unrelated changes: dead-code removal, the event-type dedup, and the third-party-notices guard. Splitting them would make review and revert easier.
  • (nit) scripts/third-party-bundled.ts: KNOWN_BUNDLERS is a hard-coded single entry. A comment at the list pointing to the place to add new bundlers would help the next person.
  • (nit) apps/cli/tests/crawler/csr-detect.test.ts: this test now imports from @squirrelscan/fetchers. It could move next to the fetchers package so it sits with the code it tests.
  • (nit) apps/cli/tests/link-analysis.test.ts is deleted along with its fixtures. The link rules in packages/rules have their own tests, so this is fine. The commit message should say that coverage lives there.

The new third-party-bundled.test.ts covers the silent-bundler guard.

@nc9
nc9 merged commit 7bd9bd9 into main Oct 16, 2026
15 checks passed
@nc9
nc9 deleted the chore/batch-b-dead-code branch October 16, 2026 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant