Skip to content

The design language that makes your AI harness better at design.

JavaScript

Count raster content reached through SVG definitions in text-only capture (#909)

Paul Bakausd05ac2b7cb0a
diff --git a/crates/cli/src/raster_coverage.js b/crates/cli/src/raster_coverage.js
index e2c358dcc..c743dc68b 100644
--- a/crates/cli/src/raster_coverage.js
+++ b/crates/cli/src/raster_coverage.js
@@ -3,33 +3,78 @@
// SVG <image>, and elements or ::before/::after pseudo-elements that paint a
// url() image (background, border, mask, list marker or generated content).
// Gradients and same-document fragment references (url(#mask), a pattern or
-// mask drawn in SVG) are code and do not count. A no-repeat background with an
-// explicit pixel size counts at that size; object-fit contain/scale-down counts
-// the letterboxed picture, not its box. Every box is clipped by the ancestors
-// that clip it (overflow or contain: paint on its containing-block chain), and
-// an element under an ancestor with opacity 0 paints nothing. The union is taken
-// on a 4px grid so tiled or overlapping pieces add up once.
+// mask drawn in SVG) are code and do not count, unless the definition they name
+// holds raster content: an <image>, <feImage> or url() raster anywhere inside
+// it, followed through nested fragment references and hrefs. An <image> inside
+// a definition has no rendered box, so the element that references such a
+// definition counts instead: through mask, clip-path, fill or use at its box
+// (a use also through the fill and stroke it passes to its clones), through
+// stroke at its box widened by half the screen stroke width, through filter at
+// the filter region (the viewport when a region length cannot be resolved), and
+// an inner SVG element through filter or a marker at its outermost <svg>. A no-repeat background with an explicit pixel size counts at
+// that size; object-fit contain/scale-down counts the letterboxed picture, not
+// its box. Every box is clipped by the ancestors that clip it (overflow or
+// contain: paint on its containing-block chain), and an element under an
+// ancestor with opacity 0 paints nothing. The union is taken on a 4px grid so
+// tiled or overlapping pieces add up once.
() => {
const W = innerWidth, H = innerHeight, cell = 4;
const cols = Math.ceil(W / cell), rows = Math.ceil(H / cell);
const grid = new Uint8Array(cols * rows);
const items = [];
const page = location.href.split('#')[0];
- // True when the value references at least one image that is not a fragment of
- // this document. Chromium may report url(#id) resolved against the page URL.
- const url = v => {
- if (typeof v !== 'string') return false;
- for (const m of v.matchAll(/url\(\s*(["']?)(.*?)\1\s*\)/gi)) {
- const ref = m[2];
- if (ref.startsWith('#')) continue;
+ const refs = v => typeof v === 'string' ? [...v.matchAll(/url\(\s*(["']?)(.*?)\1\s*\)/gi)].map(m => m[2]) : [];
+ // The id a same-document fragment reference names, or null for any other
+ // reference. Chromium may report url(#id) resolved against the page URL.
+ const fragment = ref => {
+ let hash = ref.startsWith('#') ? ref : null;
+ if (hash == null) {
try {
const u = new URL(ref, page);
- if (u.hash && u.href.split('#')[0] === page) continue;
+ if (u.hash && u.href.split('#')[0] === page) hash = u.hash;
} catch { /* an unparsable reference is counted, never waived */ }
- return true;
}
- return false;
+ if (hash == null) return null;
+ try { return decodeURIComponent(hash.slice(1)); } catch { return hash.slice(1); }
+ };
+ // Properties through which an element, or a node inside a definition, can
+ // reach an image or another definition.
+ const REFS = ['fill', 'stroke', 'maskImage', 'webkitMaskImage', 'filter', 'clipPath', 'markerStart', 'markerMid', 'markerEnd',
+ 'backgroundImage', 'borderImageSource', 'listStyleImage', 'content'];
+ const href = n => n.getAttribute('href') ?? n.getAttributeNS('http://www.w3.org/1999/xlink', 'href');
+ const defs = new Map();
+ // True when the definition an id names holds raster content: an <image>,
+ // <feImage>, <img>, <video> or <input type=image> anywhere inside it, an href
+ // or url() that leaves the document, or a fragment reference to another
+ // definition that holds raster content. Each query walks the references
+ // depth first with its own visited set, so a cycle adds nothing and cannot
+ // hide raster content further along it; only whole answers are cached.
+ const rasterDef = (id, seen) => {
+ const el = document.getElementById(id);
+ if (!el) return false;
+ if (defs.has(el)) return defs.get(el);
+ const top = !seen;
+ seen ??= new Set();
+ if (seen.has(el)) return false;
+ seen.add(el);
+ const found = [el, ...el.querySelectorAll('*')].some(n => {
+ const tag = n.localName.toLowerCase();
+ if (['image', 'feimage', 'img', 'video'].includes(tag) || (tag === 'input' && n.type === 'image')) return true;
+ const h = n instanceof SVGElement ? href(n) : null;
+ if (h && (fragment(h) == null || rasterDef(fragment(h), seen))) return true;
+ const s = getComputedStyle(n);
+ return REFS.some(p => url(s[p], seen));
+ });
+ if (top) defs.set(el, found);
+ return found;
};
+ // True when the value references at least one image: a reference that is not
+ // a fragment of this document, or a fragment naming a definition that holds
+ // raster content. A fragment naming a vector definition is code.
+ const url = (v, seen) => refs(v).some(ref => {
+ const id = fragment(ref);
+ return id == null || rasterDef(id, seen);
+ });
const px = v => /^-?[\d.]+px$/.test(v) ? parseFloat(v) : null;
const intersect = (a, b) => ({ left: Math.max(a.left, b.left), top: Math.max(a.top, b.top), right: Math.min(a.right, b.right), bottom: Math.min(a.bottom, b.bottom) });
const createsFixedBlock = s => s.transform !== 'none' || s.perspective !== 'none' || s.filter !== 'none'
@@ -92,6 +137,45 @@
const x = c.left + at(ox, cw - w), y = c.top + at(oy, ch - h);
return { left: x, top: y, right: x + w, bottom: y + h };
};
+ // The outermost <svg> an SVG element draws in; its box bounds what a marker or
+ // an inner element's filter can paint.
+ const outer = el => { let o = el; while (o.ownerSVGElement) o = o.ownerSVGElement; return box(o.getBoundingClientRect()); };
+ // The filter region of the first raster filter a filter value names, around
+ // the box r (attributes x, y, width, height; -10%, -10%, 120%, 120% when
+ // absent, in box fractions for objectBoundingBox units and in pixels from the
+ // box corner for userSpaceOnUse). A length this cannot resolve exactly (a unit
+ // such as in, mm or em, or a userSpaceOnUse percentage) counts the whole
+ // viewport. Any other filter counts at the box.
+ const region = (v, r) => {
+ const id = refs(v).map(fragment).find(id => id != null && rasterDef(id));
+ const f = id == null ? null : document.getElementById(id);
+ if (!f || f.localName !== 'filter') return box(r);
+ const user = f.getAttribute('filterUnits') === 'userSpaceOnUse';
+ const viewport = { left: 0, top: 0, right: W, bottom: H };
+ const len = (name, fallback, size) => {
+ const raw = (f.getAttribute(name) ?? fallback).trim();
+ const m = /^([-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)(px|%)?$/i.exec(raw);
+ if (!m || (m[2] === '%' && user) || (m[2] === 'px' && !user)) return null;
+ const n = parseFloat(m[1]);
+ return m[2] === '%' ? n / 100 * size : user ? n : n * size;
+ };
+ const w = r.right - r.left, h = r.bottom - r.top;
+ const [x, y, fw, fh] = [len('x', '-10%', w), len('y', '-10%', h), len('width', '120%', w), len('height', '120%', h)];
+ if ([x, y, fw, fh].some(n => n == null || !Number.isFinite(n))) return viewport;
+ return fw > 0 && fh > 0 ? { left: r.left + x, top: r.top + y, right: r.left + x + fw, bottom: r.top + y + fh } : box(r);
+ };
+ // Half the painted stroke width in screen pixels: the CTM's largest singular
+ // value bounds the stroke's widest direction, and a non-scaling stroke keeps
+ // its own width.
+ const halfStroke = (el, s) => {
+ const m = s.vectorEffect === 'non-scaling-stroke' ? null : el.getScreenCTM?.();
+ let k = 1;
+ if (m) {
+ const sum = m.a * m.a + m.b * m.b + m.c * m.c + m.d * m.d, det = m.a * m.d - m.b * m.c;
+ k = Math.sqrt((sum + Math.sqrt(Math.max(0, sum * sum - 4 * det * det))) / 2);
+ }
+ return (px(s.strokeWidth) ?? 1) * k / 2;
+ };
for (const el of document.querySelectorAll('*')) {
const s = getComputedStyle(el);
if (s.display === 'none' || s.visibility !== 'visible' || transparent(el)) continue;
@@ -103,21 +187,48 @@
if (url(s.backgroundImage)) at(background(s, r), name(el) + ' background');
if (url(s.borderImageSource) || url(s.maskImage) || url(s.webkitMaskImage)) at(box(r), name(el) + ' border/mask image');
if (url(s.listStyleImage) && s.display === 'list-item') at(box(r), name(el) + ' list marker');
+ // SVG paint servers, clips, filters, markers and use references reach a
+ // definition whose own <image> has no box, so this element's painted area
+ // counts when that definition holds raster content. A vector definition
+ // reads false and costs nothing. Content inside a definition paints only
+ // through its referencing element, which is counted instead.
+ if (el instanceof SVGElement && el.closest('defs,mask,pattern,clipPath,marker,symbol,filter')) continue;
+ const inner = el instanceof SVGElement && !!el.ownerSVGElement;
+ const shape = el instanceof SVGGeometryElement || el instanceof SVGTextContentElement;
+ // A use paints its cloned shapes with the fill and stroke it passes down.
+ const paints = shape || tag === 'use';
+ if (url(s.clipPath)) at(box(r), name(el) + ' clip-path');
+ if (paints && url(s.fill)) at(box(r), name(el) + ' fill');
+ if (paints && url(s.stroke)) {
+ const half = halfStroke(el, s);
+ at({ left: r.left - half, top: r.top - half, right: r.right + half, bottom: r.bottom + half }, name(el) + ' stroke');
+ }
+ if (shape && (url(s.markerStart) || url(s.markerMid) || url(s.markerEnd))) at(outer(el), name(el) + ' marker');
+ if (url(s.filter)) at(inner ? outer(el) : region(s.filter, r), name(el) + ' filter');
+ const use = tag === 'use' ? href(el) : null;
+ if (use && (fragment(use) == null || rasterDef(fragment(use)))) at(box(r), name(el) + ' href');
for (const p of ['::before', '::after']) {
const ps = getComputedStyle(el, p);
if (!ps || ps.content === 'none' || ps.content === 'normal' || ps.display === 'none' || ps.visibility !== 'visible' || parseFloat(ps.opacity) === 0) continue;
- if (!(url(ps.content) || url(ps.backgroundImage) || url(ps.borderImageSource) || url(ps.maskImage) || url(ps.webkitMaskImage))) continue;
+ const own = url(ps.content) || url(ps.backgroundImage) || url(ps.borderImageSource) || url(ps.maskImage) || url(ps.webkitMaskImage) || url(ps.clipPath);
+ const filtered = url(ps.filter);
+ if (!own && !filtered) continue;
// A pseudo-element has no client rect. With a used pixel size, count that
// size (at the viewport origin when fixed, else at the host's corner);
// without one, count the host box. Its clipping chain starts at the host.
+ // A raster filter paints its filter region around that box instead.
const mode = ps.position === 'fixed' || ps.position === 'absolute' ? ps.position : 'static';
const w = px(ps.width), h = px(ps.height);
- if (w == null || h == null) { mark(el, mode, box(r), name(el) + p); continue; }
- const left = mode === 'fixed' ? (px(ps.left) ?? 0) : r.left, top = mode === 'fixed' ? (px(ps.top) ?? 0) : r.top;
- mark(el, mode, { left, top, right: left + w, bottom: top + h }, name(el) + p);
+ let pr = box(r);
+ if (w != null && h != null) {
+ const left = mode === 'fixed' ? (px(ps.left) ?? 0) : r.left, top = mode === 'fixed' ? (px(ps.top) ?? 0) : r.top;
+ pr = { left, top, right: left + w, bottom: top + h };
+ }
+ if (own) mark(el, mode, pr, name(el) + p);
+ if (filtered) mark(el, mode, region(ps.filter, pr), name(el) + p + ' filter');
}
}
const covered = grid.reduce((n, v) => n + v, 0);
items.sort((a, b) => b.share - a.share);
- return { share: covered / (cols * rows), cell, largest: items.slice(0, 5), measure: 'painted-box-union-v2' };
+ return { share: covered / (cols * rows), cell, largest: items.slice(0, 5), measure: 'painted-box-union-v3' };
}
diff --git a/crates/cli/tests/text_only_entry.rs b/crates/cli/tests/text_only_entry.rs
index 6af85c733..b6da93a1c 100644
--- a/crates/cli/tests/text_only_entry.rs
+++ b/crates/cli/tests/text_only_entry.rs
@@ -434,6 +434,74 @@ fn svg_fragment_masks_and_patterns_are_code_not_raster() {
capture_with(&f, &format!("{PAGE}{masked}")).unwrap();
let patterned = format!("{svg}<svg style=\"position:absolute;left:0;top:0\" width=\"240\" height=\"160\"><rect width=\"240\" height=\"160\" fill=\"url(#p)\"/></svg>");
capture_with(&f, &format!("{PAGE}{patterned}")).unwrap();
+ // Gradients, vector filters, clips, symbols and markers reached by fragment
+ // are code too, through every reference property at once.
+ let vector = "<svg width=\"0\" height=\"0\" style=\"position:absolute\"><defs>\
+ <mask id=\"m\" maskContentUnits=\"objectBoundingBox\"><rect width=\"1\" height=\"1\" fill=\"white\"/></mask>\
+ <pattern id=\"p\" width=\"8\" height=\"8\" patternUnits=\"userSpaceOnUse\"><rect width=\"4\" height=\"4\" fill=\"url(#g)\"/></pattern>\
+ <linearGradient id=\"g\"><stop offset=\"0\" stop-color=\"#1e5ac8\"/><stop offset=\"1\" stop-color=\"#181c24\"/></linearGradient>\
+ <filter id=\"f\"><feTurbulence baseFrequency=\"0.05\"/><feGaussianBlur stdDeviation=\"2\"/></filter>\
+ <clipPath id=\"c\"><circle cx=\"120\" cy=\"80\" r=\"70\"/></clipPath>\
+ <symbol id=\"s\" viewBox=\"0 0 10 10\"><path d=\"M0 0L10 10\" stroke=\"url(#g)\"/></symbol>\
+ <marker id=\"k\" markerWidth=\"4\" markerHeight=\"4\"><circle cx=\"2\" cy=\"2\" r=\"2\" fill=\"url(#p)\"/></marker></defs></svg>";
+ let drawn = format!("{vector}<svg style=\"position:absolute;left:0;top:0\" width=\"240\" height=\"160\">\
+ <rect width=\"240\" height=\"160\" fill=\"url(#p)\" stroke=\"url(#g)\" stroke-width=\"10\" filter=\"url(#f)\" clip-path=\"url(#c)\" mask=\"url(#m)\"/>\
+ <use href=\"#s\" width=\"240\" height=\"160\"/><path d=\"M0 0L240 160\" stroke=\"#181c24\" marker-start=\"url(#k)\"/></svg>\
+ <div style=\"position:absolute;left:0;top:0;width:240px;height:160px;background:linear-gradient(#1e5ac8,#181c24);filter:url(#f);clip-path:url(#c);mask-image:url(#m);-webkit-mask-image:url(#m)\"></div>");
+ capture_with(&f, &format!("{PAGE}{drawn}")).unwrap();
+}
+
+#[test]
+fn svg_definitions_holding_raster_content_count_through_their_references() {
+ if !browser_available() {
+ return;
+ }
+ let f = Fixture::new();
+ fs::create_dir_all(f.project.join("assets")).unwrap();
+ let big = png_io::encode_png(&raster::create_image(240, 160, [30, 90, 200, 255]), &[]).unwrap();
+ fs::write(f.project.join("assets/big.png"), big).unwrap();
+ // The <image> inside each definition has no rendered box of its own, so the
+ // element that references the definition is what paints the picture.
+ let defs = "<svg width=\"0\" height=\"0\" style=\"position:absolute\"><defs>\
+ <mask id=\"m\" maskContentUnits=\"objectBoundingBox\"><image href=\"assets/big.png\" width=\"1\" height=\"1\" preserveAspectRatio=\"none\"/></mask>\
+ <pattern id=\"p\" width=\"240\" height=\"160\" patternUnits=\"userSpaceOnUse\"><image href=\"assets/big.png\" width=\"240\" height=\"160\"/></pattern>\
+ <pattern id=\"nested\" width=\"8\" height=\"8\" patternUnits=\"userSpaceOnUse\"><rect width=\"8\" height=\"8\" fill=\"url(#p)\"/></pattern>\
+ <filter id=\"f\" x=\"0\" y=\"0\" width=\"1\" height=\"1\"><feImage href=\"assets/big.png\" preserveAspectRatio=\"none\"/></filter>\
+ <symbol id=\"s\" viewBox=\"0 0 240 160\"><image href=\"assets/big.png\" width=\"240\" height=\"160\"/></symbol></defs></svg>";
+ let full = "position:absolute;left:0;top:0;width:240px;height:160px";
+ let svg = |inner: &str| format!("{PAGE}{defs}<svg style=\"position:absolute;left:0;top:0\" width=\"240\" height=\"160\">{inner}</svg>");
+ // A raster mask over a flat block shows the picture through the mask.
+ let e = capture_with(&f, &format!("{PAGE}{defs}<div style=\"{full};background:#181c24;mask-image:url(#m);-webkit-mask-image:url(#m)\"></div>")).unwrap_err();
+ assert!(e.contains("images cover 100% of the viewport") && e.contains("mask"), "{e}");
+ // A pattern holding an image, as fill, through a nested pattern, and as stroke.
+ let e = capture_with(&f, &svg("<rect width=\"240\" height=\"160\" fill=\"url(#p)\"/>")).unwrap_err();
+ assert!(e.contains("images cover 100% of the viewport") && e.contains("rect fill"), "{e}");
+ let e = capture_with(&f, &svg("<rect width=\"240\" height=\"160\" fill=\"url(#nested)\"/>")).unwrap_err();
+ assert!(e.contains("rect fill"), "{e}");
+ let e = capture_with(&f, &svg("<line x1=\"0\" y1=\"80\" x2=\"240\" y2=\"80\" stroke=\"url(#p)\" stroke-width=\"160\"/>")).unwrap_err();
+ assert!(e.contains("line stroke"), "{e}");
+ // An feImage filter paints its image over the filter region of an empty box.
+ let e = capture_with(&f, &format!("{PAGE}{defs}<div style=\"{full};filter:url(#f)\"></div>")).unwrap_err();
+ assert!(e.contains("images cover 100% of the viewport") && e.contains("filter"), "{e}");
+ // A symbol holding an image, drawn through use.
+ let e = capture_with(&f, &svg("<use href=\"#s\" width=\"240\" height=\"160\"/>")).unwrap_err();
+ assert!(e.contains("use href"), "{e}");
+ // A use of a vector symbol that passes the raster pattern down as its fill.
+ let e = capture_with(&f, &svg("<symbol id=\"square\" viewBox=\"0 0 240 160\"><rect width=\"240\" height=\"160\"/></symbol><use href=\"#square\" width=\"240\" height=\"160\" fill=\"url(#p)\"/>")).unwrap_err();
+ assert!(e.contains("use fill"), "{e}");
+ // A thin line stretched sideways paints a wide stroke.
+ let e = capture_with(&f, &svg("<g transform=\"scale(100 1)\"><line x1=\"1.2\" y1=\"0\" x2=\"1.2\" y2=\"160\" stroke=\"url(#p)\" stroke-width=\"2.4\"/></g>")).unwrap_err();
+ assert!(e.contains("line stroke"), "{e}");
+ // A filter region in inches cannot be resolved here, so it counts the viewport;
+ // a pseudo-element's filter counts its region too.
+ let e = capture_with(&f, &format!("{PAGE}{defs}<svg width=\"0\" height=\"0\" style=\"position:absolute\"><filter id=\"inch\" filterUnits=\"userSpaceOnUse\" x=\"-1in\" y=\"-1in\" width=\"5in\" height=\"5in\"><feImage href=\"assets/big.png\"/></filter></svg>\
+ <div style=\"position:absolute;left:100px;top:60px;width:4px;height:4px;filter:url(#inch)\"></div>")).unwrap_err();
+ assert!(e.contains("images cover 100% of the viewport") && e.contains("div filter"), "{e}");
+ let e = capture_with(&f, &format!("{PAGE}{defs}<svg width=\"0\" height=\"0\" style=\"position:absolute\"><filter id=\"wide\" x=\"-20\" y=\"-20\" width=\"40\" height=\"40\"><feImage href=\"assets/big.png\"/></filter></svg>\
+ <style>.dot::before{{content:'';position:absolute;left:100px;top:60px;width:10px;height:10px;filter:url(#wide)}}</style><div class=\"dot\"></div>")).unwrap_err();
+ assert!(e.contains("::before filter"), "{e}");
+ // The same raster pattern on a logo-sized shape stays under the limit.
+ capture_with(&f, &svg("<rect width=\"16\" height=\"16\" fill=\"url(#p)\"/>")).unwrap();
}
#[test]
diff --git a/docs/CLI-CONTRACT.md b/docs/CLI-CONTRACT.md
index 96e799583..098c3a5f3 100644
--- a/docs/CLI-CONTRACT.md
+++ b/docs/CLI-CONTRACT.md
@@ -1956,7 +1956,7 @@ Assembly acceptance closes component and assembly reviews for this journey. The
The hero gate uses the same evidence. When the native hero capture carries an approved first-viewport review, `build-phase` compares the approved screenshot with the current hero frame; a `text`, `control` or `chrome` region that still matches it (verdict match or drift, structure at least 75%) has its contradicted verdict, control drift and ink-box readings, and its type readings turned into advisories marked `accepted in the first-viewport review`. When the approved screenshot and the current hero frame agree as a whole (overall at least 95%, no region missing or contradicted), the user has accepted this first viewport: every non-material reason (the overall bar, the palette check, every numeric reading) becomes an advisory marked `first viewport accepted`, led by an advisory that says the user accepted it. Only material vetoes still block: missing or unreferenced plates, inline SVG illustrations, organic clips, clipped plates, invented ink, a wrong capture size, and the native rendered-presence checks. The hero report records `humanHeroReview` with the proof, that comparison, `acceptedRegions` and `viewportAccepted`. The responsive gate (and so the finish recheck) applies the same rule to its desktop comparison: with the accepted viewport still rendered at desktop width, the desktop score and contradicted regions are advisories and missing regions block. When the current capture no longer matches the approved screenshot, the acceptance lapses: the gate replaces the raw overall-bar reason with one that says the hero (or desktop) capture no longer matches the first viewport the user accepted, names the changed regions, and asks to restore what the user accepted, saying the readings apply until then. It does not offer a new first-viewport review: once one is accepted the review store returns that session, so a new round cannot open. The raw score is kept as a `(measured)` advisory. After three consecutive failed hero attempts the refusal leads with an instruction to present the first-viewport review instead of iterating further; when a first viewport is already accepted (locally, or in a session the host names) it instead says the review is closed and asks to restore what the user accepted.
-Native entry capture covers first viewports with no raster region. When the bound spec names no `raster` region (a code-led Operate screen, for example), the renderer has no artwork to intervene on, so it captures each frame (`hero`, or `desktop` and `mobile`) the way the assembled-page review captures the page it shows the user: pinned local scripts, verified network dependencies, the primary-font check, and two identical viewport screenshots. The page's inputs come from the same frozen snapshot that bound the spec and comp; nothing is read twice. What the page is served follows the review: when `.impeccable/review/hero.json` is a `hero` manifest with one page component whose preview is this entry, the page gets exactly that entry plus the component's declared `dependencies` (a declared path outside the static inventory is refused), so a file the review would not serve fails here as an undeclared dependency too. Before any review manifest names the entry, the page gets the static inventory (every static browser file outside hidden directories and `node_modules`). In both cases the bound spec and comp are never served. The capture is refused when the page requests the comp, or when a file the page loads is a byte copy of the comp or of the approved review screenshot, or is an HTML, CSS, JS or SVG file that inlines either as a base64 data URI (whitespace inside the URI is ignored). These checks run on the files the page actually loads under both policies, so a served file the page never loads (an unused backup of the comp, or one listed in the manifest's `dependencies`) does not block the capture. Byte checks cannot see a re-encoded copy, so the spec itself is the backstop: it declares every raster in the first viewport as a raster region, and this spec declares none. Each frame therefore measures the area images paint, as a union on a 4px grid (`img`, `video`, `input type=image`, SVG `image`, and any element or `::before`/`::after` painting a `url()` background, border, mask, list marker or generated content). Gradients and same-document fragment references (`url(#id)`, an SVG mask or pattern) are code and do not count. A no-repeat background with an explicit pixel size counts at that size, any other at its box; `object-fit: contain` or `scale-down` counts the letterboxed picture, not the element box. Each box is clipped by the ancestors on its containing-block chain that clip (non-visible overflow, or `contain: paint`), so an absolutely positioned or fixed image is not clipped by a wrapper it escapes; an element that is hidden, or under an ancestor with opacity 0, paints nothing. The result is clipped to the viewport, and the capture is refused when images paint 15% or more of it. The refusal names the largest images and says the spec declares no raster region, so a large image contradicts it: declare it as a raster region or remove it and draw that area in code. 15% sits well above logos, avatars and icons (a 200x60 logo is about 1% of a 1440x900 viewport, twelve 40px avatars under 2%) and well below any image that could carry the comparison; the measurement is recorded per frame as `rasterCoverage` in `frameProofs`. The manifest's bytes are bound to the capture like its other inputs. The frames carry no region receipts, so no rendered-presence or placement check runs; the hero and responsive gates read the frames with the same comparison and region readings as any other capture. `inputs.json` (and `nativeCapture.inputs` in the report) records `"captureMethod": "assembled-page-viewport"`, `dependencyPolicy` (`hero-review-manifest` or `static-inventory`), `servedToPage`, the browser version, a `frameProofs` entry per frame and, with a manifest, `reviewManifestSha256`; the report's `nativeCapture.integrityScope` reads `assembled-page viewport from frozen inputs; the comp and approved screenshots are never served to the page; no raster presence or placement check (no raster region); existing visual scores unchanged` (the capture's own `inputs.integrityScope` adds that images cover under 15% of each frame), with no `framePolicy`. The review's other limits apply: a page with a `canvas`, `iframe`, `object` or `embed`, a running animation, an external dependency, or a missing primary font is refused with that reason. Because the gate's frame and the reviewed screenshot come from one capture method, an accepted first-viewport review of a code-only page binds to the current capture like any other and ends the numeric fight as described above. Specs with at least one raster region keep the raster capture unchanged.
+Native entry capture covers first viewports with no raster region. When the bound spec names no `raster` region (a code-led Operate screen, for example), the renderer has no artwork to intervene on, so it captures each frame (`hero`, or `desktop` and `mobile`) the way the assembled-page review captures the page it shows the user: pinned local scripts, verified network dependencies, the primary-font check, and two identical viewport screenshots. The page's inputs come from the same frozen snapshot that bound the spec and comp; nothing is read twice. What the page is served follows the review: when `.impeccable/review/hero.json` is a `hero` manifest with one page component whose preview is this entry, the page gets exactly that entry plus the component's declared `dependencies` (a declared path outside the static inventory is refused), so a file the review would not serve fails here as an undeclared dependency too. Before any review manifest names the entry, the page gets the static inventory (every static browser file outside hidden directories and `node_modules`). In both cases the bound spec and comp are never served. The capture is refused when the page requests the comp, or when a file the page loads is a byte copy of the comp or of the approved review screenshot, or is an HTML, CSS, JS or SVG file that inlines either as a base64 data URI (whitespace inside the URI is ignored). These checks run on the files the page actually loads under both policies, so a served file the page never loads (an unused backup of the comp, or one listed in the manifest's `dependencies`) does not block the capture. Byte checks cannot see a re-encoded copy, so the spec itself is the backstop: it declares every raster in the first viewport as a raster region, and this spec declares none. Each frame therefore measures the area images paint, as a union on a 4px grid (`img`, `video`, `input type=image`, SVG `image`, and any element or `::before`/`::after` painting a `url()` background, border, mask, list marker or generated content). Gradients and same-document fragment references (`url(#id)`, an SVG mask, pattern, gradient, clip path, filter, marker or symbol) are code and do not count, unless the definition they name holds raster content: an `image`, `feImage`, `img`, `video` or `input type=image` anywhere inside it, an `href` or `url()` that leaves the document, or a fragment reference to another definition that holds raster content. An `image` inside a definition has no rendered box, so the element that references such a definition counts instead: through `mask`/`mask-image`, `clip-path`, `fill` or `use` at its box (a `use` also through the `fill` and `stroke` it passes to its clones), through `stroke` at its box widened by half the stroke width on screen (the transform's largest scale, or the stroke's own width for `vector-effect: non-scaling-stroke`), through `filter` at the filter region (the whole viewport when a region length uses a unit other than plain numbers, `px` in user space or percentages in bounding-box units, and the outermost `svg` box for an element inside an `svg`), and through a marker at the outermost `svg` box. A `::before` or `::after` with such a filter also counts its filter region. A no-repeat background with an explicit pixel size counts at that size, any other at its box; `object-fit: contain` or `scale-down` counts the letterboxed picture, not the element box. Each box is clipped by the ancestors on its containing-block chain that clip (non-visible overflow, or `contain: paint`), so an absolutely positioned or fixed image is not clipped by a wrapper it escapes; an element that is hidden, or under an ancestor with opacity 0, paints nothing. The result is clipped to the viewport, and the capture is refused when images paint 15% or more of it. The refusal names the largest images and says the spec declares no raster region, so a large image contradicts it: declare it as a raster region or remove it and draw that area in code. 15% sits well above logos, avatars and icons (a 200x60 logo is about 1% of a 1440x900 viewport, twelve 40px avatars under 2%) and well below any image that could carry the comparison; the measurement is recorded per frame as `rasterCoverage` in `frameProofs`. The manifest's bytes are bound to the capture like its other inputs. The frames carry no region receipts, so no rendered-presence or placement check runs; the hero and responsive gates read the frames with the same comparison and region readings as any other capture. `inputs.json` (and `nativeCapture.inputs` in the report) records `"captureMethod": "assembled-page-viewport"`, `dependencyPolicy` (`hero-review-manifest` or `static-inventory`), `servedToPage`, the browser version, a `frameProofs` entry per frame and, with a manifest, `reviewManifestSha256`; the report's `nativeCapture.integrityScope` reads `assembled-page viewport from frozen inputs; the comp and approved screenshots are never served to the page; no raster presence or placement check (no raster region); existing visual scores unchanged` (the capture's own `inputs.integrityScope` adds that images cover under 15% of each frame), with no `framePolicy`. The review's other limits apply: a page with a `canvas`, `iframe`, `object` or `embed`, a running animation, an external dependency, or a missing primary font is refused with that reason. Because the gate's frame and the reviewed screenshot come from one capture method, an accepted first-viewport review of a code-only page binds to the current capture like any other and ends the numeric fight as described above. Specs with at least one raster region keep the raster capture unchanged.
Through the host capture service (`IMPECCABLE_CAPTURE_PORT` and `IMPECCABLE_CAPTURE_CAPABILITY`), the same capture crosses unchanged: the service returns each frame's receipts as `regions`, and the report with every field above plus `captureService`. The client reads the bound spec from the project, checks its SHA-256 against the spec entry in the capture's input manifest (a spec edited since the capture is refused), and lets the spec decide the kind. A spec with no `raster` region requires `"captureMethod": "assembled-page-viewport"`, an empty `regions` list in every frame, a `frameProofs` entry per frame whose `rasterCoverage.share` is under the 15% limit, a `dependencyPolicy` of `hero-review-manifest` or `static-inventory`, and a `servedToPage` list that names neither the spec nor the comp. A spec with raster regions requires any other capture method and, in each frame, exactly one receipt per raster region the in-process capture measures there (every raster region in `hero` and `desktop`, the first one in `mobile`), at most 32. 32 is the native batch bound: the in-process capture refuses a frame with more raster regions, so the service can never return more. Anything else, including a raster capture with an empty `regions` list or a text-only method claimed for a raster spec, fails with `native entry capture unavailable: invalid native capture regions` (or names the mismatched method) and the capture is released. The service's `/audit` endpoint compares the saved `<frame>-observations.json` (`[]` for a text-only frame), frame PNGs, `inputs.json` and `human-approved.png` against its own capture as for raster captures.