Skip to content

feat(rules): crawl/single-page-site, an unscored note for one-page sites #1209 - #1219

Merged
nc9 merged 6 commits into
mainfrom
feat/single-page-site
Oct 28, 2026
Merged

nc9 merged 6 commits into
mainfrom
feat/single-page-site

Conversation

@nc9

@nc9 nc9 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Closes #1209

What

  • New rule crawl/single-page-site (severity info, site scope). It fires only when the crawl ran to the end (not capped, links followed, no queued URL left unfetched), exactly one HTML page answered 2xx, the sitemap lists at most one in-scope URL, the page links to no other same-site path (a 404 path still counts), and it has 3 or more links to ids that exist on the page. The finding lists up to 10 section ids. When it does not fire the rule returns no checks, so it is left out of scoring.
  • Unscored: info checks and empty runs are excluded from calculateRuleScore. packages/audit-engine/tests/single-page-site-scoring.test.ts asserts identical health and category scores with and without the finding.
  • buildEditorSummaryRequest adds coverage.singlePageSite: true and coverage.sectionCount only when the finding fired and the crawl was not capped, time-stopped or left URLs unfetched. Existing request tests are unchanged. The contract type EditorSummaryCoverageInput gains the two optional fields.
  • SiteData.unfetchedPages (new, optional) is filled from the crawl frontier in both engine paths, so the rule can tell a complete crawl from a stopped one.
  • Reuses the anchor record of links/broken-anchors (anchorLookup is now exported), so the v1 DOM and the streaming collector give the same answer; the rule test runs both.
  • Four places: rule file + category index, docs page docs/rules/crawl/single-page-site.mdx (+ nav, hub table), rule counts (Crawlability 20 to 21 in docs/rules/index.mdx and docs/rules/seo/index.mdx), and the canonical golden perRuleTally pin 312 to 313. The findings pin is unchanged. The new rule is site scope, so no verdictScope or measurement fixture entry is needed.

Verification

scripts/test-suites.ts --run rules (8026 pass), --run rest, --run report (970 pass), audit-engine suite, per-package tsgo typecheck (rules, audit-engine, report, core-contracts, cli), cli lint and format:check, make validate in docs/.

Notes

  • The private service change (#3578 part 2, reading coverage.singlePageSite) is tracked internally. Older servers ignore the new fields.
  • Skill: no change needed.

…tes; editor summary carries coverage.singlePageSite #1209

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the feat/single-page-site branch from 4538d6a to d002c3a Compare October 28, 2026 01:07
@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Review of crawl/single-page-site. The design is sound: it only fires on a complete crawl, stays unscored, and has tests for both anchor paths and for scoring neutrality. The findings below are minor.

  • (low) CHANGELOG.md: the new ### Added block comes after ### Docs in [Unreleased]. Check that there isn't already an ### Added heading in that section and that the order matches the other blocks.
  • (low) packages/rules/src/crawl/single-page-site.ts:567: !sections.includes(fragment) is O(n²) over record.selfFragments. That list is site-controlled. If selfFragments is not already capped, use a Set for the dedupe and stop scanning once the count is known.
  • (low) packages/report/src/editor-summary.ts: singlePageSiteSections only reads ruleResults and details.sections. It does not check that the check's pageUrl or the page count matches the summary. That is fine for now, but note that !unfetchedPages treats an undefined count as "complete", while the rule treats a missing unfetchedPages as 0 too. The two stay consistent, but only through the rule's own gating.
  • (nit) packages/audit-engine/tests/single-page-site-scoring.test.ts: the const singlePageSiteRule = ... line sits between imports. Move it below them. The meta literal on one line will probably fail oxfmt, which CI checks for this package.
  • (nit) Add a test that the rule returns no checks when the sitemap lists more than one in-scope URL, if one is not already in single-page-site.test.ts. I did not read that file in full.

…test, order the changelog blocks #1209

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

nc9 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Triage: changelog blocks reordered (Added first, then Docs; one Added heading). Section dedupe now uses a Set (selfFragments is already capped at 256 by the anchor record). The editor-summary gating note is accepted as is: the report side also checks the scan scope. Scoring test import order and formatting fixed. The more-than-one-sitemap-URL case is already covered ("a sitemap with a second in-scope URL does") on both engines.

@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Review of crawl/single-page-site: I read the diff and found nothing that should block the merge. I did not run the tests.

  • (low) packages/rules/src/crawl/single-page-site.ts: the check limits.pagesCrawled >= limits.maxPages treats a site with exactly maxPages pages as capped. This is the safe direction. It only matters when max_pages is 1, where the rule can never fire. A one-line comment would make that intent clear.
  • (low) packages/rules/src/crawl/single-page-site.ts: the internal-link loop returns not-applicable on any other same-site URL, including mailto:-like or asset links, if isInternal is set for them. I assumed isInternal is limited to http(s) pages. A test with a same-host image or PDF link would confirm that, if there isn't one already.
  • (nit) packages/report/src/editor-summary.ts: !unfetchedPages is also true when unfetchedPages is undefined, so the summary claims singlePageSite when the count is unknown. The rule already gates on site.unfetchedPages, so the result is the same, but the intent is slightly implicit.
  • (nit) packages/rules/src/crawl/single-page-site.ts: hostKey and stripHash look like helpers that probably already exist elsewhere in the repo. Consider reusing them.

Positives:

  • The rule is score-neutral, and a test asserts that.
  • anchorLookup is reused, so the v1 DOM path and the streaming collector are covered by the same test.
  • The docs and golden pins are updated.
  • Bounded output: at most 10 listed sections.

@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Review of #1219 (crawl/single-page-site)

The design holds up. The rule is informational, only fires on a complete crawl, and returns no checks otherwise, so scoring is untouched. It reuses unfetchedFrontierCount, which already exists in report-stream.ts. It reuses the broken-anchors anchor lookup, and the rule test runs both the v1 DOM and the streaming collector. I read the diff only and did not run the tests.

  • (low) single-page-site.ts inScopeSitemapUrls: iterates every sitemap entry with new URL and normalizeUrl with no cap. Sitemaps are site-controlled and can be huge. It could stop as soon as the set reaches 2, since the rule only needs > 1. That bounds the work.
  • (low) single-page-site.ts link loop: the page.parsed.links scan is likewise unbounded. It exits on the first foreign link, so the cost is acceptable. It is worth a quick check that the parser already caps the link count.
  • (nit) editor-summary.ts: singlePageSiteSections reads details.sections through count(). That ties the report to an untyped detail key in the rule. A shared constant or a typed detail would stop the two drifting apart.
  • (nit) hostKey strips www. only on the sitemap side, and baseHost goes through the same function, so it is consistent. A sitemap that lists the apex host while the base is www counts as in-scope, which is probably intended.
  • (nit) Please confirm .secrets.baseline stays clean and that the CHANGELOG ### Added bullet is present. I did not see either in the diff summary I read.

@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Reviewed the rule, the adapter and report changes, and the contract type. I did not run the tests.

  • (low) packages/rules/src/crawl/single-page-site.ts: hostKey strips www. for the sitemap scope check, but the internal-link loop relies on link.isInternal. These are two different notions of "same site". A sitemap on a different subdomain is ignored, which is fine, but a comment saying so would help.
  • (low) packages/rules/src/crawl/single-page-site.ts: pagesCrawled >= maxPages means a site with exactly max_pages pages is never flagged. The comment explains this. Consider also skipping when maxPages === 1 explicitly, so the intent is visible in code and not only in the comment.
  • (nit) packages/report/src/editor-summary.ts: !unfetchedPages treats undefined and 0 the same, which is correct. A short comment would make that clear to the next reader.
  • (nit) packages/report/src/editor-summary.ts: the summary trusts details.sections from stored reports. count() already validates it, so this is fine.

No correctness, security or scoring problems found. The new rule is site scope, returns no checks when it does not fire, and the info severity keeps it out of scoring. Test coverage looks thorough: the rule test, the scoring-neutrality test and the editor-summary test are all in the diff. The rule reuses the already-tested unfetchedFrontierCount helper, and regex use is minimal.

@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Review of #1219 (crawl/single-page-site). I read the rule, the adapter wiring and the helper import. I did not run the tests.

  • (low) single-page-site.ts: the completeness gate uses pagesCrawled >= maxPages, which also suppresses the finding when max_pages is exactly 1. The code comment says so, so I'm not asking for a change.
  • (low) single-page-site.ts: a page that redirects to another path (page.url vs finalUrl) is handled through ownKeys. A test for a link to the pre-redirect URL would pin that.
  • (nit) unfetchedFrontierCount is called in both engine paths. Make sure a storage error there degrades to 0, which unfetched-frontier-count.test.ts appears to cover.

I found no correctness or security problems. The rule scopes are bounded, the output is capped at 10 ids, and it returns no checks when it doesn't fire, so scoring is unchanged. The docs, the golden pin and the CHANGELOG are updated.

@nc9
nc9 merged commit 126ec5b into main Oct 28, 2026
15 checks passed
@nc9
nc9 deleted the feat/single-page-site branch October 28, 2026 08:27
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.

Detect single-page sites: unscored finding plus a summary signal

1 participant