Skip to content

fix(engine): resolve renamed item locators on a still-failing page #474 - #494

Merged
nc9 merged 1 commit into
mainfrom
fix/engine-474
Oct 6, 2026
Merged

nc9 merged 1 commit into
mainfrom
fix/engine-474

Conversation

@nc9

@nc9 nc9 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Closes #474

Cause

addPrior in packages/audit-engine/src/merge-core.ts only resolves an unmatched prior item when the page drops out of the resolution signal's failingByCheck set. That set is page-level, so on a page that still fails the check for any item, every prior item with no fresh match was carried, with its last-seen refreshed each run. A rule that renamed its item ids (the #462 dialog to dialog.newsletter-popup change) or a fixed item next to an unfixed one stayed open indefinitely.

Only the sampled publish path is affected (every squirrel CLI publish takes it). The local CLI merge and the complete-store cloud finalize have no signal and already resolve unmatched priors on crawled pages.

Fix

  • runCloudSmartAudits (sampled branch) works out which (page, rule, check) item lists are provably complete and passes them to the merge as the new optional completeItemChecks input. computeMerge's output shape is unchanged.
  • In the signal branch, a prior item on a still-failing page resolves when that key is complete. Everything else keeps today's carry.
  • A key is complete only when every fail/warn check under it has items and itemListComplete vouches for it, the rule+check has no folded aggregate in this publish (an unfolded check holds only the fold's attribution, and a sibling aggregate with another foldKey can hold more of the page's items), and the rule's check array was not cut (checksTruncated).
  • itemListComplete rejects a recorded remainder (details.additional, any value other than 0), details.scanTruncated, and an aggregate.

Keeping capped lists out

  • Seven page rules sliced their items without recording the rest: a11y/identical-links-same-purpose, a11y/label-content-name-mismatch, a11y/link-in-text-block, a11y/tabindex (both checks), perf/animated-content (animated-gifs), perf/source-maps (source-maps-inline), schema/rating-scope (both checks). Each now records details.additional, the convention the fold, the publish sampler and the other rules already use. A source-scan test fails if a page rule's fail/warn check writes items: x.slice(0, N) without it.
  • Older CLIs still send those lists bare, so LEGACY_SILENT_ITEM_CAPS treats a bare list sitting exactly at one of those caps as incomplete. Git history since the public source import shows no other page rule gaining a remainder, so these are the only silent caps an older CLI on this codebase sends.
  • content/hidden-text (20,000-element walk, 400,000-char / 4,000-rule stylesheet index) and content/dev-leakage (element, attribute, hit and text caps) now always emit details.scanTruncated. For those two checks only an explicit false counts as complete, so an older CLI that sends no marker never does.
  • Rule-defined limits (carousel-hidden-eager's ancestor depth, rating-scope's JSON-LD depth, hidden-text's descendant heuristic) are not treated as truncation: the rule looked at the page and that is its verdict, the same one the other two merge paths already act on.

Proof

Real run: CLI from source against a local fixture (python3 -m http.server), --http -f json --refresh, two audits. The publish body each audit would POST was rebuilt with the CLI's own slimForPublish (resolution signal included) and both were fed through runCloudSmartAudits over an in-memory SmartAuditStore.

Rename (audit 1 with the pre-#462 aria-dialog-name, audit 2 with the current rule; the page keeps two unnamed dialogs):

=== BEFORE (origin/main merge)
after publish 2: carriedFindings=1
  dialog-name locator="dialog" state=open provenance=carried lastSeenCrawlId=audit_2
  dialog-name locator="dialog.cart-drawer" state=open provenance=fresh lastSeenCrawlId=audit_2
  dialog-name locator="dialog.newsletter-popup" state=open provenance=fresh lastSeenCrawlId=audit_2
=== AFTER (this branch)
after publish 2: carriedFindings=0
  dialog-name locator="dialog" state=resolved provenance=fresh lastSeenCrawlId=audit_2
  dialog-name locator="dialog.cart-drawer" state=open provenance=fresh lastSeenCrawlId=audit_2
  dialog-name locator="dialog.newsletter-popup" state=open provenance=fresh lastSeenCrawlId=audit_2

Kept true positive (12 positive-tabindex buttons; audit 2 moves b10 and b11 first, so b8 and b9 drop out of the ten-item list while still on the page):

=== merge fix + tabindex rule from this branch (10 items + additional: 2)
  tabindex-positive locator="button#b8 (tabindex=9)" state=open provenance=carried
  tabindex-positive locator="button#b9 (tabindex=10)" state=open provenance=carried
=== merge fix + tabindex rule from origin/main (10 bare items, an older CLI)
  tabindex-positive locator="button#b8 (tabindex=9)" state=open provenance=carried
  tabindex-positive locator="button#b9 (tabindex=10)" state=open provenance=carried

Without the rule change and the legacy cap table, the second pair resolved (checked before adding the table), which is the trap this guards.

Tests

  • packages/audit-engine/tests/item-locator-resolve.test.ts (20): computeMerge with and without the signal (rename resolves, capped carries, other page's key ignored, matched locator untouched, not-evaluated page carries); itemListComplete (remainder, malformed remainder, aggregate, no items, scan marker, budgeted check needs explicit false, legacy cap, the real tabindex rule at 12 elements); runCloudSmartAudits end to end (complete list resolves, remainder carries, folded aggregate carries, sibling aggregate with another foldKey carries, checksTruncated carries, two same-name checks with one capped carries). The two resolve tests fail with the new branch disabled, and the two aggregate tests fail with the aggregate guard disabled.
  • packages/rules/tests/item-cap-remainder.test.ts (10): tabindex and label-content-name-mismatch remainders, hidden-text element and stylesheet budgets, dev-leakage hit cap, explicit false on a full scan, and the source guard (fails on the pre-fix tabindex).
  • Existing suites pass: cloud-merge, bounded-carried-merge, carried-provenance-merge, merge-scoring, complete-store-parity, content-dev-leakage, hidden-text, schema-rating-scope, noscript-content, streaming-rules-canonical-golden, streaming-page-rules-golden, streaming-scoring-golden, golden-baseline. Two golden files timed out at the 5 s default on a loaded machine (load average 21) and pass with --timeout 60000.
  • tsgo --noEmit clean in packages/rules and packages/audit-engine. [email protected] check --strict passes.

Side effects

  • Scoring: details.additional counts toward fail units (capped at 20 per check and page). label-content-name-mismatch and tabindex-very-high are fail checks, so a page with more than ten of those now scores the remainder too, as every other capped rule already does. Warn checks stay check-level, so the other five rules' scores do not move.
  • Rule docs for the nine affected pages now say the rest is counted, and hidden-text and dev-leakage document their scan caps and scanTruncated.

Changelog suggestion

  • Fixed: a dashboard finding for an element that was fixed, or renamed by a rule update, now resolves even while the page still fails that check for something else.

@nc9
nc9 marked this pull request as ready for review October 6, 2026 13:12
With the publish resolution signal, an unmatched prior item on a page that
still failed the check was always carried, because the signal is page-level.
A rule that renamed its item ids, or a fixed item next to an unfixed one,
stayed open while the page failed for anything else.

The sampled cloud merge now resolves such an item when this run's list for
that page and check is provably complete: items with no recorded remainder,
not rebuilt from or shadowed by a folded aggregate, no check array cut.

So a capped list is never read as complete:
- seven page rules that sliced items silently now record details.additional
- hidden-text and dev-leakage report details.scanTruncated when a work
  budget stops the scan, and only an explicit false counts as complete
- a bare list at a cap older releases did not record stays incomplete

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 merged commit adff494 into main Oct 6, 2026
14 checks passed
@nc9
nc9 deleted the fix/engine-474 branch October 6, 2026 13:23
@nc9 nc9 mentioned this pull request Oct 6, 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.

merge: a renamed item locator stays open as a carried finding while the page still fails the check

1 participant