Skip to content

feat(rules): contact and legal pages are skipped by word-count, title and description floors and keyword density #841 - #1334

Closed
nc9 wants to merge 7 commits into
mainfrom
feat/rules-read-page-type-841
Closed

nc9 wants to merge 7 commits into
mainfrom
feat/rules-read-page-type-841

Conversation

@nc9

@nc9 nc9 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #841

Finishes the page-type half of #841 (the noindex half shipped in #1021). Rules that judge a page the way a searcher meets it skip pages the classifier model reads as contact or legal, when the page body bears the label out.

Trust rule

A page type relaxes a verdict only when ALL hold: the label is the MODEL's (a rules-fallback label is read from the page's own schema), its confidence is at least 0.9 (the bar schema/expected-type uses), and the page body corroborates it. legal needs at least three distinct policy phrases (English plus de, fr, es, it, pt, nl); contact needs a tel:/mailto: link, an email address, a phone number or a message box (a newsletter field or site search does not count). A page with no text is never skipped, so a client-rendered shell at /privacy is reported by word-count like any thin page. The model reads a page's path and heading as much as its text, which is why the body check exists.

Change

  • skipOnPageType rule meta + a runner gate (shared/page-type.ts). The gate emits a rule-wide skip, skipReason: "page-type", details: { foldKey: "page-type", pageType, skippedByType: 1 }, handled like the noindex gate (isRuleNotApplicableReason in core-contracts, read by buildResolutionSignal, merge-core, merge-promise): the page reads as evaluated and clean, so an earlier finding on it RESOLVES.
  • content/word-count: skips contact, legal. content/keyword-stuffing: skips legal (spam injected into a legal page escapes this rule; accepted, documented; hidden-text, dev-leakage and security still run). core/meta-title, core/meta-description: the "too short" finding only, on contact, legal, as a per-check skip named with the real check name (skipReason: "not-applicable").
  • Classifier stamp: PageClassification.model = artifact sha12 : featurizer : CLASSIFIER_RULES_VERSION (2, the first stamped version). The crawler fetches a cached page again when its stored stamp differs from the running classifier's, including the classifier switched off or on, so a new model, a rules change or --no-classifier takes effect on unchanged pages.
  • Template fan-out drops a rule with skipOnPageType (fannableRules, tested). RULES_FINGERPRINT_SOURCES now covers the classifier source, its model manifest and apps/cli/src/classifier.

Evidence

  • Four real small-site audits, before and after: findings on contact and legal pages from these rules 15 to 1 (a "too long" description); 133 findings on every other page unchanged.
  • Label precision: 160 random corpus sites crawled with the shipped model; the 211 pages labelled contact or legal at 0.9 or more were judged blind (label withheld; four Sonnet judges). Judge verdict: contact 39 of 40 (0.975), legal 161 of 171 (0.942); 7 of the 11 misses are text-less shells. With the body check, replaying the real parser and gate on the same pages: 188 skipped, 184 of them judged right (0.979); 184 of the 200 judged-right pages still skip (0.92). The four wrongly skipped are a support page with a contact form, a delete-account page and two policy pages the judge saw as empty. Caveats: corpus sample, model judges, contact n=40.
  • Per-rule decisions are on the issue: h1, reading-level and eeat/* unchanged, with reasons.

Tests and gates

page-type-skip-841.test.ts (before/after, corroboration cases including a law-firm /solutions/legal page, a marketing /contact page, an empty shell, newsletter field, year range, other languages; buildResolutionSignal over real runner output), classifier-cache-stale-841.test.ts (two-pass crawl), template-fanout-gates-841.test.ts, merge tests for page-type in cloud-merge and not-evaluated-carry-508. Rules suite 8,408 pass (one timing test flakes under load, passes alone), crawler cache tests, classifier tests, make validate. Not run: full cli and audit-engine suites (CI).

Docs: docs/rules/index.mdx ("Pages short by nature"), word-count, keyword-stuffing, meta-title, meta-description. Skill: no change. Merge note: #1349's createNotEvaluatedCollector hunk in merge-core.ts resolves as (status !== "skipped" && !inconclusive) || isRuleNotApplicableReason(skipReason) || CHECK_NOT_APPLICABLE || timedOut.

Delta review round

  • Corroboration reads the main content only: the <main> landmark (else the body) without header, nav, footer and aside, flattened with spaces between elements; mailto:/tel: links and a message box count only inside it. A footer that links "Privacy Policy | Terms of Service | Cookies" and carries a mailto:, a tel: and an email no longer corroborates (tests for both the law-firm and the marketing /contact page WITH that footer keep their finding). A support page with a message box is still skipped, accepted and documented.
  • Phone: nine to fifteen digits with a separator pattern or brackets, or eight after +; an IP address, a list of years and a bare digit run are not phones. Legal phrases match whole words and the generic ones (cookies, third parties, warranty, disclaimer, haftung, informativa) are gone.
  • Re-measured on the same 211 judged pages from the 160 sites (real parser and gate): 158 skipped, 157 of them judged right (0.994); the one wrong is a delete-account page. 157 of the 200 judged-right pages still skip (0.785): the rest are mostly long policy pages (over the 300-word floor anyway) or contact pages with a plain input form, so recall costs nothing it did not already cost before this PR.
  • Stamp moved to a top-level classifierVersion on the parsed page (unique key, written whenever a classifier ran, even if it answered nothing), so a page the classifier could not label caches instead of being refetched every run, and a nested JSON-LD key cannot be mistaken for it (tests). Documented: the first crawl after upgrade fetches every cached page once, so does each future bump of CLASSIFIER_RULES_VERSION (comment on the constant and CHANGELOG); toggling --no-classifier refetches each time (accepted).
  • Rebased on main v0.0.144.

@nc9
nc9 force-pushed the feat/rules-read-page-type-841 branch 2 times, most recently from 1c3ce9c to 6f85ce3 Compare October 30, 2026 19:13
nc9 added 7 commits October 31, 2026 07:24
…sity skip contact and legal pages by model page type #841

Signed-off-by: Nik Cubrilovic <[email protected]>
…keyed by rule; classifier in rules fingerprint; fanout disqualifies skipOnPageType #841

Signed-off-by: Nik Cubrilovic <[email protected]>
…ages relabel when the classifier changes #841

Signed-off-by: Nik Cubrilovic <[email protected]>
…e precision, stamp cached pages by classifierVersion #841

Signed-off-by: Nik Cubrilovic <[email protected]>
…stamped labels stale when classifier is off, memoized main content #841

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

nc9 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.145 as 4f378e1c f6b77e4d e9b4e1e1 beeb934d fa107e1c e57bb3ee e796c68e via #1377. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.145. Closing this original.

nik

@nc9 nc9 closed this Oct 30, 2026
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.

Rules should read the page type: thin content and snippet length on contact, legal and noindex pages

2 participants