Skip to content

integrity rules: budgets count nodes, not attributes, so 5-7 MB of tiny multi-attribute controls abandons the rules #1462

Closed

Description

@nc9

Found in the review of #1455. It is the same on main, on #1454 and on #1455, so it is not caused by the window change.

What happens

The integrity rules (integrity/brand-impersonation and the ones that share its control scan) have work budgets that count DOM nodes and visits. They do not count the attributes a control carries or the targets its aria-labelledby names. A page of many tiny controls that each have several attributes (or several aria-labelledby references) therefore costs far more than the budget assumes:

  • A page of tiny controls with several attributes each, about 5 to 7 MB, takes 2.05 to 2.1 s and the rules are abandoned at the 2 s rule budget ("Not checked"). A page of <input> controls abandons at about 5 MB; at 3 MB it takes about 1 s.
  • At about 135,000 controls with aria-labelledby, the real control goes unread on main too.
  • 330,000 tiny <img> elements inside one control take about 1.2 s and 1.3 GB on main.

All numbers are from synthetic pages.

Fix direction

Count attributes read and aria-labelledby targets looked up against the same work budget as node visits, so a control's cost is what it reads, not how many nodes it has; when the budget cuts a control, count it in controlsUnread as the other bounds do.

Acceptance Criteria

  • A page of tiny multi-attribute controls (about 5 to 7 MB) finishes inside the default 2 s rule budget, or the rule reports the controls it did not read instead of being abandoned
  • Attributes read per control and aria-labelledby targets are counted against the work budget, with a cap per control
  • A real control placed after 135,000 aria-labelledby controls is found, or the page reports controls unread
  • 330,000 <img> elements inside one control stay under 1 s and well under 1 GB
  • A RuleRunner test at the default budget covers each shape, and removing the new counting makes one fail

Activity

  1. added
    size: M
    rules
    performance
    on Oct 31, 2026
  2. added theissue type on Oct 31, 2026
  3. nc9 commented on Nov 4, 2026

    @nc9
    ContributorAuthor

    Acceptance check against main 7c31d5b (first released in v0.0.160, included in v0.0.161):

    # Criterion Result Evidence
    1 5 to 7 MB of tiny multi-attribute controls finish inside the 2 s budget or report unread PASS integrity-default-budget-1462.test.ts shapes "off-site links with 5 extra attributes (4.9 MB)", "40 extra attributes (7 MB)", "5 aria-labelledby ids (7 MB)". I ran the full-size shapes through RuleRunner at the default budget (the in-file full-size tests skip themselves when the machine is busy): 336 to 763 ms, none abandoned, real control found
    2 Attributes and aria-labelledby targets counted against the budget, with a per-control cap PASS readControlAttributes, prepareBudget and MAX_LABELLEDBY in packages/rules/src/integrity/controls.ts; integrity-attribute-budget-1462.test.ts and integrity-caps-1462.test.ts pin exact unread counts at each cap and edge
    3 Real control after 135,000 aria-labelledby controls is found or reported unread PASS shape "links naming 2 aria-labelledby ids (135,000)": found, 805 ms
    4 330,000 <img> in one control under 1 s and well under 1 GB PASS shape "img inside one control (330,000)": 516 ms, about 59 MB RSS growth, measured under a load average of about 6 on 8 cores. The test file asserts "not abandoned at 2 s", not the 1 s figure
    5 RuleRunner test at the default budget per shape; removing the counting fails one PASS the file above, each shape at full and quarter size. Mutation check: removing the prepareBudget charge failed two tests in integrity-attribute-budget-1462.test.ts ("controls past the budget keep their destination ..." and "an aria-labelledby id costs a unit ..."); file restored

    Tests run on this main: integrity-default-budget-1462.test.ts 18 pass, integrity-attribute-budget-1462.test.ts 13 pass, integrity-caps-1462.test.ts 12 pass, 0 fail.

    Related residuals (a control with more than 4,096 attributes, and others) are tracked in #1559, which stays open; they are counted in controlsUnread today, which is what criterion 1 and 3 allow.

    Ticked all five and closing.

    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

    performancerulessize: M

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions