Skip to content

The template cluster key does not constrain every input a fanned rule reads #275

Closed

Description

@nc9

Follow-up to the template fan-out (squirrelscan/repo#1951), from an adversarial review of it.

What is true today

The cluster key (#267) is the page's CHROME: external asset hosts, <body> class tokens, CSS custom-property names, stylesheet hrefs, and whether <nav>/<footer> are present. Two pages sharing that key are treated as one template, and a rule declaring verdictScope: "template" runs once for the group.

The key is an approximation on purpose. The intuitive alternative, an exact DOM skeleton, puts 224 of gymshark.com's 247 pages in a cluster of one and reduces the whole idea to a 6.5% win (#1026). So soundness rests on the DECLARATION and its falsifiers, not on the key — which is exactly what #269 says, and it is an empirical claim: a rule constant on two real crawls can vary on a third.

The gap, concretely

A review constructed page pairs that share a key and get different verdicts from a declared rule:

  • The same chrome with the viewport <meta> missing on one page: mobile/viewport passes on one and fails on the other.
  • The same chrome with two <main> elements on one page: a11y/landmark-one-main likewise.
  • The same chrome where a script's PATH differs on the same host (/assets/a.js vs /assets/b.js, which per-route hashed bundles produce): security/sri attributes the representative's resource url to the member, so a finding names a file that is not on that page.

None of these is reachable on gymshark.com, openelectricity.org.au, or the authored parity corpus, which is why every gate is green. They are constructible, and hashed per-route bundle names on a shared CDN host are not exotic.

Two things #1951 did NOT leave to the declaration, because they are properties of the page rather than claims about markup: the page's ORIGIN is part of the fan-out grouping key (security/sri compares it), and core/charset was demoted to page scope because its verdict can come from the Content-Type header.

What to decide

  1. Tighten the fan-out grouping key beyond the stored template_fp, for example by adding the page's <script src> list and the set of <meta> names. Strictly safer: a tighter production grouping than the one the parity gate proves constancy over. The cost is fan-out coverage, and it is unmeasured.
  2. Demote the rules whose inputs the key does not reach, which is most of the 25.
  3. Leave it, and rely on the declaration plus the three falsifiers, which is the current position.

Option 1 needs a number before it can be chosen: how many clusters does gymshark.com have under the tightened key, and how many pages still inherit a verdict?

Acceptance Criteria

  • The cluster count and the number of pages that inherit a verdict are measured on gymshark.com and openelectricity.org.au under the current key and under at least one tightened key, and recorded in benchmarks/2026-09-perf-program.md
  • A decision is recorded on which of the three options ships, with the measurement as its justification
  • If the key is tightened, template-fanout-equivalence-golden.test.ts gains a case built from one of the counterexamples above that fails under the old key and passes under the new one
  • If the key is left as is, the limitation is stated where a rule author declaring verdictScope: "template" will read it (n/a: the key was tightened; the VerdictScope doc states what it still does not cover anyway)

Activity

  1. added
    enhancement
    P2
    size: M
    on Sep 8, 2026
  2. nc9 commented on Oct 7, 2026

    @nc9
    ContributorAuthor

    Current state (2026-10-07): criterion 4's fallback is in place. The limitation (two pages can share the key and still differ in a viewport <meta>, a second <main>, or a script path) and the two falsifiers are documented on VerdictScope (packages/rules/src/types.ts:96-116), where a rule author declaring verdictScope: "template" reads it.

    Remaining: criteria 1-2. Nothing in benchmarks/ measures the cluster count under a tightened key, and no decision is recorded. 25 rules still declare template scope.

  3. nc9 commented on Oct 8, 2026

    @nc9
    ContributorAuthor

    Status: PR #580 is open. It tightens the fan-out grouping key with script srcs, meta names and the main count. The three counterexamples are pinned in template-fanout-equivalence-golden.test.ts, and they fail under the old key.

    Still open: criterion 1. The gymshark.com and openelectricity.org.au crawls are not available to me, so I did not record cluster or inherited-page counts and did not invent any. Someone with the crawls needs to run template-fanout-bench.ts --verify and add the numbers to benchmarks/2026-09-perf-program.md.

  4. nc9 commented on Oct 9, 2026

    @nc9
    ContributorAuthor

    Real-crawl counts are now in benchmarks/2026-09-perf-program.md (via #580). gymshark: 37 clusters / 3946 inherited on the current key, 52 / 3931 on the tightened key. openelectricity (fresh 250-page crawl): 11 / 239 on both. Template-scoped rules that still read inputs outside the key, confirmed in the rule sources: a11y/html-xml-lang-mismatch (<html lang> / xml:lang), a11y/aria-hidden-body (aria-hidden on <html> / <body>) and core/favicon (link[rel*=icon] hrefs). Those, plus a parity check that derives the signature from what declared rules actually read, are what's left here.

  5. nc9 commented on Oct 9, 2026

    @nc9
    ContributorAuthor

    Closed by #580 (25aecef, main CI green). All four criteria were checked on main. The counts are in benchmarks/2026-09-perf-program.md (gymshark 37/3946 -> 52/3931, openelectricity 11/239 on both), the decision and its justification are recorded there, and seven counterexamples in template-fanout-equivalence-golden.test.ts fail on the old key and pass on the new one. The three template rules that still read inputs outside the key are tracked in #614.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2enhancementsize: M

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions