The design language that makes your AI harness better at design.
JavaScript
Merge corpus/stack-5-consent into corpus/stack-6-round7
Paul Bakaus26501d017757
diff --cc docs/CLI-CONTRACT.mdindex 4ae7eb381,f737d7f2b..dae648114--- a/docs/CLI-CONTRACT.md+++ b/docs/CLI-CONTRACT.md@@@ -346,11 -344,11 +346,11 @@@ Optional keys added later by engines (a- **One message shape.** Every script-error message reads the way the console prints it, `Uncaught <Type>: <message>`, whatever path the throw took, where the JS printed puppeteer's `err.message` with the type stripped on one path and CDP's typed text on another. CDP's marker comes first: `Uncaught`, or `Uncaught (in promise)` for an unhandled rejection. An `Error` reads the first line of its description, which names its type (`TypeError: ...`, or the name a library gave it, `ChunkLoadError: ...`); a description that names no type gets the class in front, and an empty message is the type alone (`Uncaught AbortError`). A thrown value that is not an `Error` (CDP `type: object` with no `subtype`: a plain object, a class instance, a rejected object) reads its class and V8's property preview, `Uncaught Object {code: "E_CONFIG", message: "config missing"}` (strings JSON-quoted, other values as previewed, `...` when the preview overflowed). A primitive reads as `String(value)`, `Uncaught boom`. A throw that arrives with no exception object (a cross-origin script) keeps CDP's text, which is typed already (`Uncaught TypeError: ...`, or `Uncaught [object Object]`). The body after the marker is its first line, trimmed, and the message after its type (`TypeError: `) is cut at 160 characters, the cut the JS applied to the untyped message, so naming the type costs the message nothing it showed before; a throw whose body is empty reports nothing.- **React invariants read as their message.** A production React build throws `Minified React error #<n>; visit <url> for the full message or use the non-minified dev environment for full errors and additional helpful warnings.` For a common invariant number the boilerplate from `; visit ` on is replaced by the message React's error decoder prints, the number kept: `Uncaught Error: Minified React error #418: Hydration failed because the initial UI does not match what was rendered on the server.` The table (`REACT_INVARIANTS` in `crates/browser/src/cdp.rs`) covers 31, 130, 185, 300, 301, 310, 321, 418, 419, 421, 422, 423, 425 and 426. The message is added after the 160-character cut, so it is never cut. A number the table does not know, text after the number other than `; visit `, and any message that is not an invariant stay as they were. Deduping compares the decoded messages, so both reports of one invariant still share a key.- **One throw, one report.** Deduping compares messages with the `(in promise)` marker read as a plain `Uncaught`, so a throw that surfaces both synchronously and as an unhandled rejection (a consent manager's patched `document.createElement` called from a script and from a promise) reports once, with the first report's text and source. Messages that differ in anything else stay separate. The three-error cap applies after deduping, and after classing (next item): counted errors and advisory ad-tech errors are capped at three each, in arrival order, so ad-tech errors never take a slot a counted error needs. Three failing ad scripts ahead of the site's own broken bundle still leave the bundle's error reported as `error`; a scan reports at most six script errors.- - **Ad-tech script errors are advisory and name the vendor** (corpus decision r3-31-script-error-ad-tech). A script error thrown from a known ad-tech script (its source URL contains `anymind360.com` (AnyMind), a script file name beginning `prebid`, wherever it is hosted (Prebid), `connect.facebook.net` (Meta Pixel), `googletagmanager.com` (Google Tag Manager), `cookielaw.org` (OneTrust, the consent layer that holds ad tags back), or `googlesyndication.com` / `doubleclick.net` / `googleadservices.com` (Google Ads)), or whose message names an ad API (`browsingTopics`, `joinAdInterestGroup`, `runAdAuction` (vendor `ad tech`), `adsbygoogle` (Google Ads)), reports with `severity: 'advisory'`, its snippet ends ` (third-party: <vendor>)`, and it carries `thirdParty: "<vendor>"` after `ignoreValue`. The source is checked first. Product analytics and a site's own bundles and chunks (ad code served from the site's own host included) are not on the list and stay `error`. The list lives in `crates/core/src/third_party.rs` and holds only vendors the corpus has evidence for.- - **Findings on third-party widget markup name the vendor** (corpus decision r4-p24-third-party-widget-markup). A finding whose element is a known widget vendor's markup keeps its severity; its snippet ends ` (third-party: <vendor>)` and it carries `thirdParty: "<vendor>"` (after `selector`). Taboola owns its whole feed: an element with an id starting `taboola-` or `internal_trc_`, a class starting `trc_rbox`, or the class `trc_related_container`, and everything under it. Swiper owns only its structural elements: the element itself has the class `swiper`, `swiper-container`, `swiper-wrapper` or `swiper-slide`, or an id starting `swiper-wrapper-`; the site's content inside a slide is the site's. The rule pass tags in `serialize_findings` (so the in-page bundle and the extension see it too), the visual-contrast pass by its selector's first match. Page-level findings are never tagged. The static engine does not tag.+ - **Ad-tech script errors are advisory and name the vendor** (corpus decision r3-31-script-error-ad-tech). A script error thrown from a known ad-tech script (its source URL contains `anymind360.com` (AnyMind), a script file name beginning `prebid`, wherever it is hosted (Prebid), `connect.facebook.net` (Meta Pixel), `googletagmanager.com` (Google Tag Manager), `cookielaw.org` (OneTrust, the consent layer that holds ad tags back), or `googlesyndication.com` / `doubleclick.net` / `googleadservices.com` (Google Ads), `nagich.co.il` (Nagich, an accessibility overlay), or `asset.chase.com/web/library/digddsautomation/reportingjs/` (Chase Reporting, a shared reporting tag)), or whose message names an ad API (`browsingTopics`, `joinAdInterestGroup`, `runAdAuction` (vendor `ad tech`), `adsbygoogle` (Google Ads), `_prebidjs` (Prebid)), reports with `severity: 'advisory'`, its snippet ends ` (third-party: <vendor>)`, and it carries `thirdParty: "<vendor>"` after `ignoreValue`. The source is checked first. Product analytics and a site's own bundles and chunks (ad code served from the site's own host included) are not on the list and stay `error`. The list lives in `crates/core/src/third_party.rs` and holds only vendors the corpus has evidence for.+ - **Findings on third-party widget markup name the vendor** (corpus decision r4-p24-third-party-widget-markup). A finding whose element is a known widget vendor's markup keeps its severity; its snippet ends ` (third-party: <vendor>)` and it carries `thirdParty: "<vendor>"` (after `selector`). Taboola owns its whole feed: an element with an id starting `taboola-` or `internal_trc_`, a class starting `trc_rbox`, or the class `trc_related_container`, and everything under it. Swiper owns only its structural elements: the element itself has the class `swiper`, `swiper-container`, `swiper-wrapper` or `swiper-slide`, or an id starting `swiper-wrapper-`; the site's content inside a slide is the site's. Slick owns its structural elements the same way (the class `slick-slider`, `slick-list`, `slick-track`, `slick-slide` or `slick-arrow`) and its whole dot list (the class `slick-dots` and everything under it); SuperSlide owns its `tempWrap`; react-fast-marquee owns everything under an element with a class starting `rfm-`; Kaltura owns everything under a class starting `playkit-` or the class `kaltura-player` or `kaltura-player-container`. The rule pass tags in `serialize_findings` (so the in-page bundle and the extension see it too), the visual-contrast pass by its selector's first match. Page-level findings are never tagged. The static engine does not tag.- - **Purple headings in the brand hue** (corpus decision r3-23-ai-color-palette-brand-hue). The heading forms of `ai-color-palette` (a snippet ending ` on heading`) do not report when the heading's computed `color` is within 12 degrees of hue of a brand surface on the same page: the solid `background-color` (alpha at least 0.9, chroma at least 50, no gradient painted over it) of the logo (an element whose `id`, `class`, `alt` or `aria-label` contains `logo`; its text colour too when it has text of its own), the nav bar (`nav`, `header`, `role=navigation|banner`, at least half the viewport wide), or a band across the page (at least 90% of the viewport's width) covering a fifth of the viewport's area or more. Headings are never brand surfaces, and the gradient and neon forms keep reporting: purple that shows up only in headings and gradients is the tell. URL engine only (the static engine has no rendered page to read surfaces from).+ - **Purple headings in the brand hue** (corpus decision r3-23-ai-color-palette-brand-hue). The heading forms of `ai-color-palette` (a snippet ending ` on heading`) do not report when the heading's computed `color` is within 12 degrees of hue of a brand surface on the same page: the solid `background-color` (alpha at least 0.9, chroma at least 50, no gradient painted over it) of the logo (an element whose `id`, `class`, `alt` or `aria-label` contains `logo`; its text colour too, read from the first element in it with text of its own, so a type logo set in a child `span` counts), the nav bar (`nav`, `header`, `role=navigation|banner`, at least half the viewport wide), neither inside `main` or an `article` (an article's own header, a pagination nav and a row of partner logos are local chrome), or a band across the page (at least 90% of the viewport's width) covering a fifth of the viewport's area or more. Headings are never brand surfaces, and the gradient and neon forms keep reporting: purple that shows up only in headings and gradients is the tell. URL engine only (the static engine has no rendered page to read surfaces from).- **Contrast ratios in snippets.** Every `low-contrast` producer (the element text path shared by both engines, which covers links, spans and placeholders, the static engine's `:hover state`, and the URL engine's `browser contrast` sampling and `pixel contrast` passes, verdict and median) prints a ratio against its threshold: one decimal; two when one decimal would round a failing ratio up to the threshold; and those two cut, not rounded, when rounding them would reach it too. A ratio under the bar never prints as the bar: `4.49:1 (need 4.5:1)`, never `4.5:1` or `4.50:1`. A ratio at or above the threshold, such as a median over it, prints one decimal.- - **Page validity gate.** After `goto` (and settle), before injecting anything, the engine classifies the page (`crates/browser/src/validity.rs`) from the main document's final CDP response and an in-page probe (title, visible text length, final URL, challenge-widget markers). Challenge: an `x-amzn-waf-action` header, `cf-mitigated: challenge`, a final URL on a challenge-only host (`perfdrive.com`, `captcha-delivery.com`), or, on a page with at most 3000 characters of visible text, a challenge title prefix ("Just a moment", "Attention Required! | Cloudflare", "Human Verification", "Access Denied", "Radware Bot Manager", "Captcha", ...) or a full-page widget marker (Cloudflare challenge form, PerimeterX, DataDome, Imperva, Akamai, AWS WAF, slider captchas). HTTP error: a final status >= 400 with no challenge signal. A blocked page throws `the page is a bot challenge, not the site (<signals>). Findings would describe the challenge page, so none are reported.` or `the page returned an error (HTTP <status>). Findings would describe the error page, so none are reported.`, which the CLI prints as `Error: ...` and counts as an operational failure (exit 1). A `file://` load has no response, so only the probe signals apply.+ - **Page validity gate.** After `goto` (and settle), before injecting anything, the engine classifies the page (`crates/browser/src/validity.rs`) from the main document's final CDP response and an in-page probe (title, visible text length, final URL, challenge-widget markers). Challenge: an `x-amzn-waf-action` header, `cf-mitigated: challenge`, a final URL on a challenge-only host (`perfdrive.com`, `captcha-delivery.com`), or, on a page with at most 3000 characters of visible text, a challenge title prefix ("Just a moment", "Attention Required! | Cloudflare", "Human Verification", "Access Denied", "Radware Bot Manager", "Captcha", ...) or a full-page widget marker (Cloudflare challenge form, PerimeterX, DataDome, Imperva, Akamai, AWS WAF, slider captchas). On a page of any size, a bot manager's challenge sheet laid over the rendered page is a challenge too: HUMAN Security's (PerimeterX's) "Press & hold" check, `#px-captcha-modal` or `#px-captcha-wrapper`, while it is showing (not `display: none`, not `visibility: hidden`, opacity over 0.02) and covers at least half the viewport; the signal reads `overlay human-press-and-hold`, and the probe records `overlays` only when one shows. HTTP error: a final status >= 400 with no challenge signal. A blocked page throws `the page is a bot challenge, not the site (<signals>). Findings would describe the challenge page, so none are reported.` or `the page returned an error (HTTP <status>). Findings would describe the error page, so none are reported.`, which the CLI prints as `Error: ...` and counts as an operational failure (exit 1). A `file://` load has no response, so only the probe signals apply.Consent wall: a page where a known consent manager (next item) is showing (its text counted with the text of open shadow roots under its roots, where Usercentrics renders), hiding it would leave next to nothing (fewer than 20 visible characters outside its roots, and no visible form control (`input` other than hidden, `select`, `textarea`, `button`) and no `img`, `svg`, `video`, `canvas`, `iframe`, `object` or `embed` of 10,000 square pixels or more outside them), and the manager holds at least 100 characters. It throws `the page is a consent wall, not the site (consent manager <names>, <n> of <total> visible characters outside it, no control or image outside it). Findings would describe the consent dialog, so none are reported.` A short page under an ordinary banner (a sign-in form, a splash page with a button, an image-first page) is scanned. The probe runs before any banner is hidden, and again before the hide pass after the reveal sweep, so a wall that arrives after load is refused too (the evidence then carries that later probe). With `--no-consent-hiding` the gate is off and the page is scanned with its banner, which is what that flag asks for. The probe object (evidence) carries `consent` (the names of the managers showing), `consentChars` (visible characters inside them) and `consentOutside` (visible controls and sizable media outside them, counted up to 20).- **Consent banners** (Rust engine). A consent banner covers copy a visitor reads once they dismiss it: text under it was skipped as covered or scored against the banner, and the banner's own text was scored as the site's. After the validity gate, again after the reveal sweep (so a banner injected after load or on the first scroll is caught before the capture), and once more right after the capture (when that pass changes the page, the page is captured again, so the capture, the live hit tests and the pixel reads agree), the engine hides the roots and backdrops of the consent managers in `crates/browser/src/consent.rs`: OneTrust, Cookiebot, Usercentrics, TrustArc, Didomi, Quantcast Choice, Sourcepoint, Osano, the open-source Cookie Consent library, CookieYes, Complianz, iubenda, Termly, Axeptio, Borlabs Cookie, Klaro, Cookie Notice, Shopify's privacy banner, and Google Funding Choices. Selectors are the vendor's own ids and classes, never a generic word, so a notice a site wrote for itself stays on the page and is scanned. Hiding is one injected `<style id="impeccable-consent-hide">` of `display: none !important` rules (plus an inline `display: none !important` on a matched element whose own inline style outranks the rule); nothing is clicked and no cookie or consent state is set. The scroll lock is undone only where the manager applied it: its own lock classes on `<html>` / `<body>` (Didomi `didomi-popup-open`, Sourcepoint `sp-message-open`) are removed, and an inline `overflow` / `overflow-y: hidden` on `<html>` or `<body>` is removed only while that manager's backdrop was showing the page is not an app shell (an element outside the managers at least half the viewport tall that scrolls itself with `overflow-y: auto` / `scroll`, whose body lock is the site's own), and no modal of the site's own (`dialog[open]`, `[aria-modal="true"]`, `[role="dialog"]`, `[role="alertdialog"]` outside the managers) is showing, since that modal may hold the lock. Every hide pass is best-effort: one that fails hides nothing and does not fail the scan. Every pass, the hit tests, and the evidence screenshot see the page without the banner (a last hide runs before the screenshot). Findings from a scan that hid a showing banner carry `consentHidden: ["<name>", ...]` (after `thirdParty`), and text mode prints the note above. `--no-consent-hiding` turns all of it off. The evidence API (`detect_url_evidence`) leaves the findings untagged, so they replay equal, and records `Evidence.consent`: `{ hidden, matched: { <name>: [selectors] }, unlocked }`. The static (file) engine is unaffected.- **What the visual pass refuses to read.** The JS reported whatever its sampling produced; the engine says nothing where the reading is not the text's own background. The candidate collector applies the element pass's text gates before a candidate takes one of the `maxCandidates` slots, is sampled, or is scrolled into view: text with no letter and no digit (`◯`, `{ }`, `/`) as well as emoji-only text; a disabled control (`[disabled]`, `[aria-disabled="true"]`); a computed font size under 1px; a `color` at alpha 0.02 or less, or a transparent `-webkit-text-fill-color`, unless the element clips its own background to its text; and an element the painted-at-capture predicate (`crates/core/src/browser/painted.rs`, text gate) says is not painted, such as a tab-strip cell past its clipping edge or a carousel slide parked beside the page. A background image read as a surface has to be under the text: an image drawn `no-repeat` (from the computed `background` shorthand's first layer) whose painted rect, at a `background-size` the capture can place (pixels, percentages, `cover`, or any size once the image's intrinsic size is loaded), covers neither the candidate's text box nor its own box (`body` and `html` are asked only about the text) ends the walk `background image does not cover the text` (`stop`), whether or not the pass could load the file. An icon sprite framing a count and a mark beside a button label are refused this way; a repeating tile and a placement the capture cannot state are read as before. In the stack walk (`impeccable_core::browser::visual`): a translucent surface no longer restarts the walk at its own parent (which re-entered the stack above the node it came from and composited that surface over itself until its alpha read as opaque, and which skipped siblings painted between the surface and that parent) — the walk keeps descending the one `elementsFromPoint` stack, collecting translucent surfaces until an opaque one grounds them, then composites them back in order (topmost surface still names the method, `...+alpha`); a walk that reaches the end of the stack with nothing opaque is unresolved rather than reporting the last translucent color as a surface. A gradient answers analytically only when its stops agree: any stop below 0.95 alpha (a scrim, a glow, a `from-x/10` wash composites differently at every point of the box) or two opaque stops more than 2× apart in contrast make it `gradient stops disagree`, and an `svg` in the stack makes it `<tag> paint`; both end the walk (`stop`) rather than letting the nodes under them answer for the text, so the candidate falls to the screenshot pass. In the screenshot flow: a candidate whose reasons include `background-clip text`, `filter`, or `backdrop filter` is refused before the two screenshots are taken; the verdict is the median over the *glyph cores* (channel delta ≥ 90% of the strongest delta in the box, ≥ 8 of them; when fewer than 8 pixels reach 90%, as on small or thin text, the pixels from 75% up) rather than the tenth percentile over every changed pixel, which antialiased edges drive to 1:1; and the pass reports nothing when the diff is not a glyph over its background — more than 55% of the clip changed (the page repainted), more than a quarter of the changed pixels moved the opposite way from the rest (text mid-animation leaves its old position and its new one in the same diff), most fully painted pixels are not the color the text declares (`preferRenderedForeground` aside, where the painted value *is* the claim), the surface under the glyphs stands 2:1 or further from the surface beside them in the same box (the page paints its own text twice, so hiding one copy leaves the other where the glyphs were), or the median of every measured pixel is more than 3× the verdict (the sample is two populations, not one surface). The snippet shape is unchanged. `median` in it is the median over the same glyph cores the verdict reads, so it prints the verdict's number and never reads below it (it used to be the median over every changed pixel, edges included, which printed verdicts above their own median such as `pixel contrast 3.5:1 median 1.7:1`). The median over every changed pixel still decides the bimodal refusal above, but it is not printed.