Skip to content

perf(audit-engine): derive the template fan-out signature from what the declared rules read, with a parity test #585

Closed

Description

@nc9

Follow-up to the fan-out key change. The signature covers script src, meta names, some meta content and the main count; other inputs a fanned rule can read (link rel, headings, attributes) are still outside it, so the class of bug remains.

Acceptance Criteria

  • The fan-out signature is derived from the inputs each declared rule reads, or a parity test fails when a fanned rule reads an input outside the signature
  • Adding a rule input without updating its declaration fails CI
  • The engine golden tests and the fan-out bench show no regression in cluster coverage on the existing estates
  • Docs for rule authors say how to declare the inputs a fanned rule reads

Related: #614 (the three inputs the key misses today) and #296 (cache and fan-out composing).

Part of #637.

Activity

  1. added
    size: M
    rules
    P3
    enhancement
    on Oct 8, 2026
  2. nc9 commented on Oct 11, 2026

    @nc9
    ContributorAuthor

    Checked against current main (ad95fb2): PARTLY FIXED ON MAIN, after 0.0.108.

    • Criterion 2 is largely met by fix(audit-engine): fan-out signature covers html/body attrs and icon links (#614) #621 (ad2e562). packages/rules/tests/template-verdict-inputs.test.ts scans each verdictScope: "template" rule's source for selectors, attribute names, raw ctx.page.html, textContent and so on. It fails unless every read is reviewed as KEYED or UNKEYED, and its last test holds the VerdictScope doc to the UNKEYED list. The test header says what the scan cannot see: a selector held in a variable, or what a helper the document is handed to reads.
    • Criterion 1 is not met. fanoutInputSignature (packages/audit-engine/src/template-fanout.ts, from line 150) is still a hand-written list. The doc comment at packages/rules/src/types.ts:122-151 names declared rules whose reads the key does not cover: raw HTML (core/doctype, a11y/focus-visible, analytics/*, perf/js-libraries), everything getCWVHints reads, inline script and style bodies, the <main> id and class, and iframe and image src. It also names three gaps no entry captures: order, <noscript> ancestry and head vs body placement. So the test records divergence; it does not stop it.
    • Criterion 4: the only author guidance is that doc comment in types.ts. Nothing under docs/ covers it; docs/cli/debug.mdx only mentions fan-out.
    • Criterion 3: not measured here.
  3. added theissue type on Oct 28, 2026
  4. nc9 commented on Oct 30, 2026

    @nc9
    ContributorAuthor

    AC1 ticked on the second branch: packages/rules/tests/template-verdict-inputs.test.ts fails when a declared rule reads anything not on its reviewed list, and template-fanout-parity-golden.test.ts runs in CI. Full derivation of the signature from the declared reads is not built: a reviewed unkeyed read stays allowed, recorded in the test and the VerdictScope doc. Rule-author docs are in #1364. The remaining boxes close with that PR and the existing golden and bench runs.

    nik

  5. nc9 commented on Oct 30, 2026

    @nc9
    ContributorAuthor

    Verified against main after v0.0.145 (the contributing section landed). Met: criteria 1 and 4. Open: criterion 2 (a selector held in a variable or read by a helper is invisible to the scan, and an unkeyed read can be added to the reviewed list without changing the signature) and criterion 3 (no cluster-coverage bench result recorded). Leaving this open for those.

    nik

  6. nc9 commented on Nov 12, 2026

    @nc9
    ContributorAuthor

    Closing as superseded by #1373, which is the same work after this issue's own scope shipped. What this issue asked for is in main: the tripwire packages/rules/tests/template-verdict-inputs.test.ts fails when a declared verdictScope: "template" rule reads an input that is not on its reviewed KEYED or UNKEYED list (criterion 2, from ad2e562, first released in v0.0.109), packages/audit-engine/tests/template-fanout-parity-golden.test.ts and template-fanout-equivalence-golden.test.ts gate the fan-out against running every rule (the golden half of criterion 3), and the rule-author docs are in. The other half of criterion 3, a recorded cluster-coverage measurement on the existing estates, is not done here: it moves to #1373 and criterion 3 is left unticked on purpose. Criterion 1 was ticked on its second branch (tripwire, not a derived signature).

    What is left is exactly #1373: deriving the signature from the declared reads, behind the cluster-coverage measurement (the --coverage --signature bench mode, f9dfaf9, shipped in v0.0.179). #1373 stays open as the one remaining sub-issue, and is now in epic #637. Priority labels are left as they were.

    nik

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

    P3enhancementrulessize: M

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions