Skip to content

Write HTML. Render video. Built for agents.

fix(cli): recognize textual motion in sweep checks (#3707)

Miguel Ángele8659cb65364
diff --git a/.fallowrc.jsonc b/.fallowrc.jsonc
index cee55ad865..c94e4cb47b 100644
--- a/.fallowrc.jsonc
+++ b/.fallowrc.jsonc
@@ -39,6 +39,7 @@
"packages/cli/src/commands/layout-audit.browser.js",
"packages/cli/src/commands/contrast-audit.browser.js",
"packages/cli/src/commands/motion-sample.browser.js",
+ "packages/cli/src/commands/motion-signature.browser.js",
// Worker entry points loaded dynamically by their *Pool.ts companions.
"packages/producer/src/services/pngDecodeBlitWorker.ts",
"packages/producer/src/services/shaderTransitionWorker.ts",
diff --git a/docs/packages/cli.mdx b/docs/packages/cli.mdx
index 8b2d3d2b8d..c242d059f8 100644
--- a/docs/packages/cli.mdx
+++ b/docs/packages/cli.mdx
@@ -747,6 +747,16 @@ HTML. Without a sidecar, nothing changes.
| `staysInFrame(selector)` | Off-frame drift — once visible, the box never leaves the canvas (`motion_off_frame`) |
| `keepsMoving(withinSelector?)` | A frozen shot — no fully static window longer than `maxStaticSec`, default 2s (`motion_frozen`) |
+`keepsMoving` uses the same motion classifier as the frozen-sweep guard: box
+geometry, opacity, text and generated content, form-control state, painted CSS
+counters, clip-path, variable-font axes, and the pixels of visible
+canvas/video/img elements all count as motion — so a playing same-origin (or
+CORS-readable) background video keeps a scope live on its own. Elements under
+`data-layout-ignore` inside the scope never count; the opt-out does not apply to
+the scope element itself, since naming it in an assertion outranks it. Content
+the browser does not paint (`display: none` subtrees, `visibility: hidden`
+boxes, skipped `content-visibility` contents) never counts as motion either.
+
`duration`, `keepsMoving.withinSelector`, and `keepsMoving.maxStaticSec` are
optional. Findings use the same shape and envelope as layout findings and are
errors by default, so a failed assertion fails the run. A selector that matches
diff --git a/packages/cli/scripts/build-copy.mjs b/packages/cli/scripts/build-copy.mjs
index 83e0fbc5c3..177ab7d1e7 100644
--- a/packages/cli/scripts/build-copy.mjs
+++ b/packages/cli/scripts/build-copy.mjs
@@ -118,6 +118,11 @@ async function main() {
cpSync(contrastAuditScript, join(DIST, "commands", "contrast-audit.browser.js"));
}
+ const motionSignatureScript = join(CLI_ROOT, "src", "commands", "motion-signature.browser.js");
+ if (existsSync(motionSignatureScript)) {
+ cpSync(motionSignatureScript, join(DIST, "commands", "motion-signature.browser.js"));
+ }
+
const motionSampleScript = join(CLI_ROOT, "src", "commands", "motion-sample.browser.js");
if (existsSync(motionSampleScript)) {
cpSync(motionSampleScript, join(DIST, "commands", "motion-sample.browser.js"));
diff --git a/packages/cli/src/commands/layout-audit.browser.js b/packages/cli/src/commands/layout-audit.browser.js
index 8a9c90485a..99519273b6 100644
--- a/packages/cli/src/commands/layout-audit.browser.js
+++ b/packages/cli/src/commands/layout-audit.browser.js
@@ -1851,78 +1851,10 @@
return contentOverlapIssues(root, time);
};
- // Frozen-sweep guard (#U10, checkPipeline.ts): a compact per-sample
- // fingerprint of every visible element's box + opacity, in DOM order. Node
- // calls this once per seeked grid point and compares the strings across the
- // whole run — if every sample produces the identical string, the seek never
- // actually moved anything and the whole audit run is unreliable. Deliberately
- // a single opaque string (not a structured array) since Node only ever needs
- // equality, not per-element diffing.
- // Pixel-only media motion (a 2D/WebGL canvas repainting or a playing video
- // without any element moving) is invisible to a geometry+opacity fingerprint
- // and false-positives sweep_static. Downsample each visible canvas/video to
- // 8x8 and fold its pixels into the fingerprint. Tainted, zero-sized, or
- // unreadable media hashes to a constant — no worse than geometry-only
- // detection and never a new false negative for DOM-motion compositions.
- // Media inside iframes is intentionally outside this fingerprint: it lives
- // in a separate document, and cross-origin frames are inaccessible under SOP.
- function mediaPixelHash(element) {
- try {
- const rect = element.getBoundingClientRect();
- const sourceWidth = element.videoWidth || element.width || rect.width;
- const sourceHeight = element.videoHeight || element.height || rect.height;
- if (!sourceWidth || !sourceHeight) return "x";
- const off = document.createElement("canvas");
- off.width = 8;
- off.height = 8;
- const ctx = off.getContext("2d");
- if (!ctx) return "x";
- ctx.drawImage(element, 0, 0, 8, 8);
- const data = ctx.getImageData(0, 0, 8, 8).data;
- let hash = 0;
- for (let i = 0; i < data.length; i++) hash = (hash * 31 + data[i]) >>> 0;
- return String(hash);
- } catch {
- return "x";
- }
- }
-
- window.__hyperframesLayoutGeometry = function collectLayoutGeometry() {
- const root =
- document.querySelector("[data-composition-id][data-width][data-height]") ||
- document.querySelector("[data-composition-id]") ||
- document.body;
- const elements = Array.from(root.querySelectorAll("*")).filter((element) =>
- isVisibleElement(element),
- );
- const parts = elements.map((element) => {
- const rect = toRect(element.getBoundingClientRect());
- const opacity = round(opacityChain(element));
- // Variable-font axis animation (font-variation-settings) is a real,
- // visible motion channel that moves no geometry and no opacity, so a
- // box+opacity fingerprint reads it as a frozen timeline. Worse in a
- // DUPLEXED face (Recursive holds an identical advance width at every
- // weight by design), where not even the line width shifts — the whole
- // run then false-positives sweep_static. Fold the computed axis string
- // in; it is "normal" for every element that does not use it, so this
- // adds nothing to the fingerprint of an ordinary composition.
- const axes = getComputedStyle(element).fontVariationSettings;
- return `${rect.left},${rect.top},${rect.width},${rect.height},${opacity},${
- axes && axes !== "normal" ? axes : ""
- }`;
- });
- // img shares the same pixel-only-motion blind spot as canvas/video: an
- // equal-size, equal-position opaque src/visibility swap moves no
- // geometry and no opacity. mediaPixelHash already handles it generically
- // (drawImage accepts any CanvasImageSource; width/height fall back to
- // rect.width/height same as canvas/video), so only the element selector
- // needed widening.
- for (const media of root.querySelectorAll("canvas, video, img")) {
- if (!isVisibleElement(media)) continue;
- parts.push(`p:${mediaPixelHash(media)}`);
- }
- return parts.join("|");
- };
+ // The frozen-sweep fingerprint (window.__hyperframesLayoutGeometry, #U10 in
+ // checkPipeline.ts) lives in motion-signature.browser.js, the single owner
+ // of "what counts as motion" shared with motion-sample.browser.js's
+ // liveness signature.
// Rotation-pivot sampling (rotation_pivot_drift). Per sample, report every
// rotatable candidate's bbox center, size, and current rotation angle. Node
diff --git a/packages/cli/src/commands/layout-audit.browser.test.ts b/packages/cli/src/commands/layout-audit.browser.test.ts
index 82c2be313a..9c05c7fb34 100644
--- a/packages/cli/src/commands/layout-audit.browser.test.ts
+++ b/packages/cli/src/commands/layout-audit.browser.test.ts
@@ -31,192 +31,6 @@ describe("layout-audit.browser", () => {
clearGeometryCollector();
});
- it("changes the sweep fingerprint when visible video pixels advance", () => {
- document.body.innerHTML = `
- <div id="root" data-composition-id="main" data-width="640" data-height="360">
- <video id="footage"></video>
- </div>
- `;
- installGeometry({
- root: rect({ left: 0, top: 0, width: 640, height: 360 }),
- footage: rect({ left: 0, top: 0, width: 640, height: 360 }),
- });
-
- let pixelValue = 20;
- const getContextSpy = vi.spyOn(HTMLCanvasElement.prototype, "getContext") as unknown as {
- mockReturnValue(value: CanvasRenderingContext2D): void;
- };
- getContextSpy.mockReturnValue({
- drawImage() {},
- getImageData() {
- return { data: new Uint8ClampedArray(8 * 8 * 4).fill(pixelValue) };
- },
- } as unknown as CanvasRenderingContext2D);
-
- installAuditScript();
- const collect = (window as unknown as { __hyperframesLayoutGeometry: () => string })
- .__hyperframesLayoutGeometry;
- const before = collect();
- pixelValue = 220;
- const after = collect();
-
- expect(after).not.toBe(before);
- });
-
- // PRINFRA-666: an equal-size, equal-position opaque <img> src/visibility
- // swap (the authoring pattern for a paused-GSAP-cursor-driven "reveal
- // frame N of a still sequence" composition) moves no geometry and no
- // opacity, so it was invisible to the fingerprint and false-positived
- // sweep_static — mediaPixelHash already existed for exactly this pixel-only
- // motion class, it just wasn't applied to img.
- it("changes the sweep fingerprint when a same-size opaque img is swapped", () => {
- document.body.innerHTML = `
- <div id="root" data-composition-id="main" data-width="640" data-height="360">
- <img id="frame" />
- </div>
- `;
- installGeometry({
- root: rect({ left: 0, top: 0, width: 640, height: 360 }),
- frame: rect({ left: 0, top: 0, width: 640, height: 360 }),
- });
-
- let pixelValue = 20;
- const getContextSpy = vi.spyOn(HTMLCanvasElement.prototype, "getContext") as unknown as {
- mockReturnValue(value: CanvasRenderingContext2D): void;
- };
- getContextSpy.mockReturnValue({
- drawImage() {},
- getImageData() {
- return { data: new Uint8ClampedArray(8 * 8 * 4).fill(pixelValue) };
- },
- } as unknown as CanvasRenderingContext2D);
-
- installAuditScript();
- const collect = (window as unknown as { __hyperframesLayoutGeometry: () => string })
- .__hyperframesLayoutGeometry;
- const before = collect();
- pixelValue = 220;
- const after = collect();
-
- expect(after).not.toBe(before);
- });
-
- // Opacity-reveal fixture (CLI feedback digest 2026-07-14): code-typing style
- // scenes reveal pre-laid-out characters via opacity only — no geometry ever
- // moves. The sweep fingerprint must treat that as motion, both while a glyph
- // fades (opacity value changes) and when it crosses the 0.2 visibility floor
- // (element enters the signature); otherwise `check` misfires `sweep_static`
- // and authors reach for geometry hacks (a slow host y-drift) to pass.
- it("changes the sweep fingerprint when text reveals via opacity alone", () => {
- document.body.innerHTML = `
- <div id="root" data-composition-id="main" data-width="640" data-height="360">
- <div id="code"><span id="char">c</span></div>
- </div>
- `;
-
- let charOpacity = "0";
- installGeometry(
- {
- root: rect({ left: 0, top: 0, width: 640, height: 360 }),
- code: rect({ left: 40, top: 40, width: 560, height: 48 }),
- char: rect({ left: 40, top: 40, width: 18, height: 48 }),
- },
- {
- char: {
- get opacity() {
- return charOpacity;
- },
- } as Partial<CSSStyleDeclaration>,
- },
- );
-
- installAuditScript();
- const collect = (window as unknown as { __hyperframesLayoutGeometry: () => string })
- .__hyperframesLayoutGeometry;
-
- const hidden = collect(); // below the 0.2 visibility floor — not in the signature
- charOpacity = "0.5";
- const fading = collect(); // mid-fade — present, opacity part of the signature
- charOpacity = "1";
- const revealed = collect(); // settled
-
- expect(fading).not.toBe(hidden);
- expect(revealed).not.toBe(fading);
- });
-
- // Variable-font axis animation (registry block `weight-wave`): a crest of
- // weight travels along a headline by rewriting each character's
- // font-variation-settings, and NOTHING else changes — no geometry, no
- // opacity, no canvas. A duplexed face makes it total: Recursive holds one
- // advance width at every weight by design, so not even the line width
- // shifts and all six sweep samples hashed identically until the axis string
- // joined the fingerprint. `check` then failed a working composition with
- // sweep_static, and the documented remedies (spread the reveal, keep an
- // element animating) cannot help — the motion is real, the fingerprint was
- // just blind to it.
- it("changes the sweep fingerprint when only font-variation-settings moves", () => {
- document.body.innerHTML = `
- <div id="root" data-composition-id="main" data-width="640" data-height="360">
- <div id="line"><span id="char">P</span></div>
- </div>
- `;
-
- let axes = '"wght" 400, "slnt" 0';
- installGeometry(
- {
- root: rect({ left: 0, top: 0, width: 640, height: 360 }),
- line: rect({ left: 40, top: 40, width: 560, height: 48 }),
- char: rect({ left: 40, top: 40, width: 18, height: 48 }),
- },
- {
- char: {
- get fontVariationSettings() {
- return axes;
- },
- } as Partial<CSSStyleDeclaration>,
- },
- );
-
- installAuditScript();
- const collect = (window as unknown as { __hyperframesLayoutGeometry: () => string })
- .__hyperframesLayoutGeometry;
-
- const rest = collect();
- axes = '"wght" 1000, "slnt" -12'; // the crest arrives over this character
- const crest = collect();
-
- expect(crest).not.toBe(rest);
- });
-
- // The other direction, and it guards the more dangerous failure: a
- // fingerprint that varies on its own would make sweep_static unfireable and
- // every green layout verdict meaningless. Identical scene, axes included,
- // must hash identically.
- it("keeps the sweep fingerprint identical when nothing moves, font axes included", () => {
- document.body.innerHTML = `
- <div id="root" data-composition-id="main" data-width="640" data-height="360">
- <div id="line"><span id="char">P</span></div>
- </div>
- `;
-
- installGeometry(
- {
- root: rect({ left: 0, top: 0, width: 640, height: 360 }),
- line: rect({ left: 40, top: 40, width: 560, height: 48 }),
- char: rect({ left: 40, top: 40, width: 18, height: 48 }),
- },
- {
- char: { fontVariationSettings: '"wght" 400, "slnt" 0' } as Partial<CSSStyleDeclaration>,
- },
- );
-
- installAuditScript();
- const collect = (window as unknown as { __hyperframesLayoutGeometry: () => string })
- .__hyperframesLayoutGeometry;
-
- expect(collect()).toBe(collect());
- });
-
it("uses authored canvas dimensions when the root bounding rect is degenerate", () => {
document.body.innerHTML = `
<div id="root" data-composition-id="main" data-width="640" data-height="360">
diff --git a/packages/cli/src/commands/layout.ts b/packages/cli/src/commands/layout.ts
index 64ffa8ccbc..7a03d3b61e 100644
--- a/packages/cli/src/commands/layout.ts
+++ b/packages/cli/src/commands/layout.ts
@@ -395,6 +395,7 @@ async function runMotionPass(
width: window.innerWidth,
height: window.innerHeight,
}));
+ await page.addScriptTag({ content: loadBrowserScript("motion-signature.browser.js") });
await page.addScriptTag({ content: loadBrowserScript("motion-sample.browser.js") });
const frames = await collectMotionFrames(page, times, selectors, livenessScopes);
return { issues: evaluateMotion(frames, spec.assertions, canvas), sampleCount: frames.length };
diff --git a/packages/cli/src/commands/motion-sample.browser.js b/packages/cli/src/commands/motion-sample.browser.js
index 9d3e520d5f..3893e33212 100644
--- a/packages/cli/src/commands/motion-sample.browser.js
+++ b/packages/cli/src/commands/motion-sample.browser.js
@@ -4,88 +4,32 @@
// scope it returns a bucketed signature of all visible elements, so the Node-side
// evaluator can detect frozen windows by comparing signatures across frames.
(function () {
- const IGNORE_TAGS = new Set(["SCRIPT", "STYLE", "TEMPLATE", "NOSCRIPT", "META", "LINK"]);
-
- function round(value) {
- return Math.round(value * 100) / 100;
- }
+ // Visibility, opacity and the liveness signature come from the shared classifier
+ // (motion-signature.browser.js), so this sampler and the frozen-sweep guard agree on what moves.
+ // Resolved at install, checked at call: an install-time throw would only surface as an opaque
+ // "__hyperframesMotionSample is not a function" from the driver's evaluate.
+ const shared = window.__hyperframesMotionSignature;
function toRect(rect) {
return {
- left: round(rect.left),
- top: round(rect.top),
- right: round(rect.right),
- bottom: round(rect.bottom),
- width: round(rect.width),
- height: round(rect.height),
+ left: shared.round(rect.left),
+ top: shared.round(rect.top),
+ right: shared.round(rect.right),
+ bottom: shared.round(rect.bottom),
+ width: shared.round(rect.width),
+ height: shared.round(rect.height),
};
}
- function opacityChain(element) {
- let opacity = 1;
- for (let current = element; current; current = current.parentElement) {
- const parsed = Number.parseFloat(getComputedStyle(current).opacity || "1");
- if (Number.isFinite(parsed)) opacity *= parsed;
- }
- return opacity;
- }
-
- // Mirrors layout-audit.browser.js isVisibleElement.
- // fallow-ignore-next-line complexity
- function isVisibleElement(element) {
- if (IGNORE_TAGS.has(element.tagName)) return false;
- const style = getComputedStyle(element);
- if (
- style.display === "none" ||
- style.visibility === "hidden" ||
- style.visibility === "collapse"
- ) {
- return false;
- }
- if (opacityChain(element) < 0.2) return false;
- const rect = element.getBoundingClientRect();
- return rect.width > 0.5 && rect.height > 0.5;
- }
-
function sampleElement(element) {
const rect = element.getBoundingClientRect();
return {
rect: toRect(rect),
- opacity: round(opacityChain(element)),
- visible: isVisibleElement(element),
+ opacity: shared.round(shared.opacityChain(element)),
+ visible: shared.isVisibleElement(element),
};
}
- function compositionRoot() {
- return document.querySelector("[data-composition-id]") || document.body;
- }
-
- // ponytail: bucket position to 2px and opacity to 0.08 so the RFC's "moves ≥2px /
- // opacity ≥0.08" thresholds fall out of bucketing. Boundary-straddling moves are
- // approximate — good enough for liveness; tighten only if false negatives show up.
- function elementSignature(element) {
- const rect = element.getBoundingClientRect();
- const bx = Math.round(rect.left / 2);
- const by = Math.round(rect.top / 2);
- const bw = Math.round(rect.width / 2);
- const bh = Math.round(rect.height / 2);
- const bo = Math.round(opacityChain(element) / 0.08);
- return bx + "," + by + "," + bw + "," + bh + "," + bo;
- }
-
- function livenessSignature(root) {
- if (!root) return "";
- const parts = [];
- // ponytail: O(DOM) × MOTION_MAX_SAMPLES (300) — fine for typical compositions;
- // narrow selector (e.g. "[id],[class]") if heavy-DOM compositions slow this down.
- const all = root.querySelectorAll("*");
- for (const element of all) {
- if (!isVisibleElement(element)) continue;
- parts.push(elementSignature(element));
- }
- return parts.join("|");
- }
-
function safeQuery(selector) {
try {
return document.querySelector(selector);
@@ -108,13 +52,22 @@
function sampleLiveness(scopes) {
const liveness = {};
for (const scope of scopes) {
- const root = scope === "*" ? compositionRoot() : safeQuery(scope);
- liveness[scope] = livenessSignature(root);
+ const root = scope === "*" ? shared.compositionRoot() : safeQuery(scope);
+ // ponytail: O(DOM) × MOTION_MAX_SAMPLES (300), with three computed-style
+ // reads (element + ::before/::after) plus an ancestor walk per box-generating
+ // element — fine for typical compositions; narrow the scope if heavy-DOM
+ // compositions slow down.
+ liveness[scope] = shared.compositionSignature(root, { quantize: true });
}
return liveness;
}
window.__hyperframesMotionSample = function motionSample(options) {
+ if (!shared) {
+ throw new Error(
+ "motion-signature.browser.js must be injected before motion-sample.browser.js",
+ );
+ }
const { selectors = [], livenessScopes = [] } = options || {};
return { data: sampleSelectors(selectors), liveness: sampleLiveness(livenessScopes) };
};
diff --git a/packages/cli/src/commands/motion-sample.browser.test.ts b/packages/cli/src/commands/motion-sample.browser.test.ts
index d8003cf646..1349864946 100644
--- a/packages/cli/src/commands/motion-sample.browser.test.ts
+++ b/packages/cli/src/commands/motion-sample.browser.test.ts
@@ -6,6 +6,7 @@ import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
+const signatureScript = readFileSync(join(__dirname, "motion-signature.browser.js"), "utf-8");
const script = readFileSync(join(__dirname, "motion-sample.browser.js"), "utf-8");
interface Geo {
@@ -13,6 +14,8 @@ interface Geo {
opacity?: string;
display?: string;
visibility?: string;
+ /** `::after` computed `content`; re-read on every call when a getter. */
+ afterContent?: string;
}
interface SampleResult {
@@ -24,8 +27,13 @@ interface SampleResult {
}
function installGeometry(byId: Record<string, Geo>): void {
- vi.spyOn(window, "getComputedStyle").mockImplementation((element) => {
+ vi.spyOn(window, "getComputedStyle").mockImplementation((element, pseudoElement) => {
const geo = byId[(element as Element).id] ?? {};
+ if (pseudoElement) {
+ return {
+ content: pseudoElement === "::after" ? (geo.afterContent ?? "none") : "none",
+ } as unknown as CSSStyleDeclaration;
+ }
return {
display: geo.display ?? "block",
visibility: geo.visibility ?? "visible",
@@ -47,6 +55,9 @@ function installGeometry(byId: Record<string, Geo>): void {
}
function installScript(): void {
+ // The sampler reads the shared motion classifier at install time.
+ // eslint-disable-next-line no-new-func
+ new Function(signatureScript)();
// eslint-disable-next-line no-new-func
new Function(script)();
}
@@ -62,6 +73,16 @@ describe("motion-sample.browser", () => {
vi.restoreAllMocks();
document.body.innerHTML = "";
delete (window as unknown as { __hyperframesMotionSample?: unknown }).__hyperframesMotionSample;
+ Reflect.deleteProperty(window, "__hyperframesMotionSignature");
+ Reflect.deleteProperty(window, "__hyperframesLayoutGeometry");
+ });
+
+ it("installs without the shared motion classifier and names it on the first call", () => {
+ // Installing must not throw: addScriptTag resolves on load regardless, so
+ // the driver only ever sees the error from its evaluate call.
+ // eslint-disable-next-line no-new-func
+ expect(() => new Function(script)()).not.toThrow();
+ expect(() => sample({ livenessScopes: ["*"] })).toThrow(/motion-signature\.browser\.js/);
});
it("samples a present, visible selector and returns null for an absent one", () => {
@@ -79,6 +100,18 @@ describe("motion-sample.browser", () => {
expect(result.data["#missing"]).toBeNull();
});
+ it("reports an explicitly asserted data-layout-ignore element as visible", () => {
+ document.body.innerHTML = `
+ <div data-composition-id="main"><div id="glow" data-layout-ignore>x</div></div>
+ `;
+ installGeometry({ glow: { rect: { left: 100, top: 50, width: 300, height: 80 } } });
+ installScript();
+
+ // The layout-audit opt-out excludes the layer from liveness, not from an
+ // assertion that names it.
+ expect(sample({ selectors: ["#glow"] }).data["#glow"]?.visible).toBe(true);
+ });
+
it("reflects inherited ancestor opacity", () => {
document.body.innerHTML = `
<div data-composition-id="main"><div id="wrap"><div id="headline">Hi</div></div></div>
@@ -114,6 +147,46 @@ describe("motion-sample.browser", () => {
expect(moved).not.toBe(before);
});
+ // Liveness and the frozen-sweep guard share one classifier: a fixed-width
+ // attr()-backed countdown that the sweep guard accepts as motion must not be
+ // reported frozen by keepsMoving.
+ it("changes the liveness signature when attr-backed generated content changes, in step with the sweep fingerprint", () => {
+ document.body.innerHTML = `
+ <div data-composition-id="main"><span id="countdown" data-txt="10"></span></div>
+ `;
+ installGeometry({
+ countdown: {
+ rect: { left: 280, top: 140, width: 80, height: 48 },
+ get afterContent() {
+ return JSON.stringify(document.getElementById("countdown")!.getAttribute("data-txt"));
+ },
+ },
+ });
+ installScript();
+ const sweep = (window as unknown as { __hyperframesLayoutGeometry: () => string })
+ .__hyperframesLayoutGeometry;
+
+ const livenessBefore = sample({ livenessScopes: ["*"] }).liveness["*"];
+ const sweepBefore = sweep();
+ document.getElementById("countdown")!.setAttribute("data-txt", "09");
+
+ expect(sample({ livenessScopes: ["*"] }).liveness["*"]).not.toBe(livenessBefore);
+ expect(sweep()).not.toBe(sweepBefore);
+ });
+
+ it("signs a leaf withinSelector scope by the scope element itself", () => {
+ document.body.innerHTML = `
+ <div data-composition-id="main"><div id="logo">x</div></div>
+ `;
+ installGeometry({ logo: { rect: { left: 10, top: 10, width: 50, height: 50 } } });
+ installScript();
+
+ // The scope root is part of its own signature; a leaf scope is never "missing".
+ expect((sample({ livenessScopes: ["#logo"] }).liveness["#logo"] ?? "").length).toBeGreaterThan(
+ 0,
+ );
+ });
+
it("scopes liveness to a withinSelector and returns empty for a missing scope", () => {
document.body.innerHTML = `
<div data-composition-id="main"><div id="scene"><div id="box">x</div></div></div>
diff --git a/packages/cli/src/commands/motion-signature.browser.chromium.test.ts b/packages/cli/src/commands/motion-signature.browser.chromium.test.ts
new file mode 100644
index 0000000000..c337d00182
--- /dev/null
+++ b/packages/cli/src/commands/motion-signature.browser.chromium.test.ts
@@ -0,0 +1,636 @@
+// fallow-ignore-file code-duplication
+// Real-Chromium pins for motion-signature.browser.js: the happy-dom suite fakes getComputedStyle, this one
+// asserts the same branches against Blink, using the exact scripts `hyperframes check` injects.
+// Skipped without a local Chrome; opt-in on Windows (HYPERFRAMES_BROWSER_TESTS=1), where its launch timed out.
+import { existsSync, readFileSync } from "node:fs";
+import { dirname, join } from "node:path";
+import { fileURLToPath } from "node:url";
+import type { Browser, Page } from "puppeteer-core";
+import { afterAll, beforeAll, describe, expect, it } from "vitest";
+import { findSystemBrowser } from "../browser/manager.js";
+
+const __dirname = dirname(fileURLToPath(import.meta.url));
+const signatureScript = readFileSync(join(__dirname, "motion-signature.browser.js"), "utf-8");
+const motionSampleScript = readFileSync(join(__dirname, "motion-sample.browser.js"), "utf-8");
+
+function resolveExecutable(): string | undefined {
+ for (const name of ["HYPERFRAMES_BROWSER_PATH", "PUPPETEER_EXECUTABLE_PATH"]) {
+ const candidate = process.env[name];
+ if (candidate && existsSync(candidate)) return candidate;
+ }
+ return findSystemBrowser()?.executablePath;
+}
+
+const executablePath = resolveExecutable();
+const RUNS_CHROMIUM =
+ !!executablePath &&
+ (process.platform !== "win32" || process.env.HYPERFRAMES_BROWSER_TESTS === "1");
+// The package hookTimeout is sized for cold module imports, not for launching
+// a browser; give the launch its own ceiling.
+const BROWSER_LAUNCH_TIMEOUT_MS = 120_000;
+
+interface Samples {
+ sweep: string;
+ liveness: string;
+}
+
+declare global {
+ interface Window {
+ __hyperframesLayoutGeometry: () => string;
+ __hyperframesMotionSample: (options: { selectors?: string[]; livenessScopes?: string[] }) => {
+ data: Record<string, { visible: boolean } | null>;
+ liveness: Record<string, string>;
+ };
+ }
+}
+
+function composition(css: string, body: string): string {
+ return `<!doctype html><html><head><style>
+ html, body { margin: 0; }
+ #root { position: relative; width: 640px; height: 360px; }
+ .fixed { display: inline-block; width: 80px; height: 48px; font: 32px/48px monospace; text-align: center; }
+ ${css}
+ </style></head><body>
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">${body}</div>
+ </body></html>`;
+}
+
+describe.skipIf(!RUNS_CHROMIUM)("motion-signature.browser in Chromium", () => {
+ let browser: Browser;
+ let page: Page;
+
+ beforeAll(async () => {
+ const puppeteer = await import("puppeteer-core");
+ browser = await puppeteer.default.launch({
+ headless: true,
+ executablePath,
+ args: ["--no-sandbox", "--disable-dev-shm-usage", "--disable-gpu"],
+ });
+ page = await browser.newPage();
+ await page.setViewport({ width: 640, height: 360 });
+ }, BROWSER_LAUNCH_TIMEOUT_MS);
+
+ afterAll(async () => {
+ await browser?.close();
+ });
+
+ async function load(html: string): Promise<void> {
+ await page.setContent(html);
+ await page.addScriptTag({ content: signatureScript });
+ await page.addScriptTag({ content: motionSampleScript });
+ }
+
+ async function sample(scope = "*"): Promise<Samples> {
+ return page.evaluate(
+ (livenessScope) => ({
+ sweep: window.__hyperframesLayoutGeometry(),
+ liveness:
+ window.__hyperframesMotionSample({ livenessScopes: [livenessScope] }).liveness[
+ livenessScope
+ ] ?? "",
+ }),
+ scope,
+ );
+ }
+
+ async function mutate(script: string): Promise<void> {
+ await page.evaluate(script);
+ }
+
+ // motion-sample's per-selector visibility bit (isVisibleElement on an
+ // explicitly asserted element).
+ async function visible(selector: string): Promise<boolean | undefined> {
+ return page.evaluate(
+ (sel) => window.__hyperframesMotionSample({ selectors: [sel] }).data[sel]?.visible,
+ selector,
+ );
+ }
+
+ it("treats an attr()-backed fixed-width countdown as motion in both samplers", async () => {
+ await load(
+ composition(
+ "#countdown::after { content: attr(data-txt); }",
+ '<span id="countdown" class="fixed" data-txt="10"></span>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.getElementById("countdown").setAttribute("data-txt", "09")');
+ const after = await sample();
+
+ expect(after.sweep).not.toBe(before.sweep);
+ expect(after.liveness).not.toBe(before.liveness);
+ });
+
+ it("keeps both signatures identical when a countdown with every textual channel is frozen", async () => {
+ await load(
+ composition(
+ "body { counter-reset: countdown 10; } #countdown::after { content: attr(data-txt) counter(countdown); }",
+ '<span id="countdown" class="fixed" data-txt="10">10</span><textarea id="note">10</textarea>',
+ ),
+ );
+ const first = await sample();
+ const second = await sample();
+
+ expect(second).toEqual(first);
+ });
+
+ it("ignores a display:none decoy counter owner in a frozen composition", async () => {
+ await load(
+ composition(
+ "#decoy { display: none; counter-reset: countdown 10; } #countdown::after { content: counter(countdown); }",
+ '<div id="decoy"></div><span id="countdown" class="fixed"></span>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.getElementById("decoy").style.counterReset = "countdown 9"');
+ const after = await sample();
+
+ expect(after).toEqual(before);
+ });
+
+ it("ignores a decoy counter owner nested inside a display:none subtree", async () => {
+ await load(
+ composition(
+ "#hidden-parent { display: none; } #decoy { display: block; counter-reset: countdown 10; } #countdown::after { content: counter(countdown); }",
+ '<div id="hidden-parent"><div id="decoy"></div></div><span id="countdown" class="fixed"></span>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.getElementById("decoy").style.counterReset = "countdown 9"');
+ const after = await sample();
+
+ expect(after).toEqual(before);
+ });
+
+ it("ignores counter state when nothing paints a counter", async () => {
+ await load(
+ composition(
+ "#owner { height: 0; counter-reset: countdown 10; }",
+ '<div id="owner"></div><span id="countdown" class="fixed">10</span>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.getElementById("owner").style.counterReset = "countdown 9"');
+ const after = await sample();
+
+ expect(after).toEqual(before);
+ });
+
+ it("ignores a zero-box decoy whose counter name nothing paints even when a list marker exists", async () => {
+ await load(
+ composition(
+ "li { width: 80px; height: 48px; } #decoy { height: 0; counter-reset: decoy 10; }",
+ '<ul><li>item</li></ul><div id="decoy"></div>',
+ ),
+ );
+ expect(await page.evaluate(() => getComputedStyle(document.querySelector("li")!).display)).toBe(
+ "list-item",
+ );
+ const before = await sample();
+ await mutate('document.getElementById("decoy").style.counterReset = "decoy 9"');
+ const after = await sample();
+
+ expect(after).toEqual(before);
+ });
+
+ it("ignores a counter consumed only by a pseudo-element under a data-layout-ignore layer", async () => {
+ await load(
+ composition(
+ "#owner { height: 0; counter-reset: countdown 10; } #a::after { content: counter(countdown); }",
+ '<div id="owner"></div><div data-layout-ignore><span id="a" class="fixed"></span></div>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.getElementById("owner").style.counterReset = "countdown 9"');
+ const after = await sample();
+
+ expect(after).toEqual(before);
+ });
+
+ it("ignores a counter consumed only by a pseudo-element that inherits visibility:hidden", async () => {
+ await load(
+ composition(
+ "#owner { height: 0; counter-reset: countdown 10; } #a { visibility: hidden; } #a::after { content: counter(countdown); }",
+ '<div id="owner"></div><span id="a" class="fixed"></span>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.getElementById("owner").style.counterReset = "countdown 9"');
+ const after = await sample();
+
+ expect(after).toEqual(before);
+ });
+
+ it("sees a counter painted by a visible pseudo-element on a visibility:hidden host", async () => {
+ await load(
+ composition(
+ "body { counter-reset: countdown 10; } #a { visibility: hidden; } #a::after { visibility: visible; content: counter(countdown); }",
+ '<span id="a" class="fixed"></span>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.body.style.counterReset = "countdown 9"');
+ const after = await sample();
+
+ expect(after.sweep).not.toBe(before.sweep);
+ });
+
+ it("sees a counter painted only through a ::marker", async () => {
+ await load(
+ composition(
+ "#owner { height: 0; counter-reset: countdown 10; } li { width: 80px; height: 48px; } li::marker { content: counter(countdown); }",
+ '<div id="owner"></div><ul><li>item</li></ul>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.getElementById("owner").style.counterReset = "countdown 9"');
+ const after = await sample();
+
+ expect(after.sweep).not.toBe(before.sweep);
+ });
+
+ it("sees counters(), styled counter(), and counter-set owners", async () => {
+ await load(
+ composition(
+ "#owner { height: 0; counter-reset: outer 1 inner 5; counter-set: styled 10; } #a::after { content: counters(outer, '.') ' ' counter(styled, upper-roman); }",
+ '<div id="owner"></div><span id="a" class="fixed"></span>',
+ ),
+ );
+ const start = await sample();
+ await mutate('document.getElementById("owner").style.counterReset = "outer 2 inner 5"');
+ const afterCounters = await sample();
+ await mutate('document.getElementById("owner").style.counterSet = "styled 9"');
+ const afterSet = await sample();
+
+ expect(afterCounters.sweep).not.toBe(start.sweep);
+ expect(afterSet.sweep).not.toBe(afterCounters.sweep);
+ });
+
+ it("sees a zero-box owner's counter change when a visible pseudo-element paints it", async () => {
+ await load(
+ composition(
+ "#owner { counter-reset: countdown 10; } #countdown::after { content: counter(countdown); }",
+ '<div id="owner"><span id="countdown" class="fixed"></span></div>',
+ ),
+ );
+ // Blink leaves counter() unsubstituted in computed content, so the only
+ // signal is the owner's counter state.
+ expect(
+ await page.evaluate(
+ () => getComputedStyle(document.getElementById("countdown")!, "::after").content,
+ ),
+ ).toBe("counter(countdown)");
+ const before = await sample();
+ await mutate('document.getElementById("owner").style.counterReset = "countdown 9"');
+ const after = await sample();
+
+ expect(after.sweep).not.toBe(before.sweep);
+ expect(after.liveness).not.toBe(before.liveness);
+ });
+
+ it("sees a counter painted by a zero-box host's absolutely positioned pseudo-element", async () => {
+ await load(
+ composition(
+ "body { counter-reset: countdown 10; } #host { width: 0; height: 0; } #host::after { position: absolute; left: 100px; top: 100px; content: counter(countdown); }",
+ '<div id="host"></div>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.body.style.counterReset = "countdown 9"');
+ const after = await sample();
+
+ expect(after.sweep).not.toBe(before.sweep);
+ });
+
+ it("sees a counter owned above the composition root change", async () => {
+ await load(
+ composition(
+ "body { counter-reset: countdown 10; } #countdown::after { content: counter(countdown); }",
+ '<span id="countdown" class="fixed"></span>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.body.style.counterReset = "countdown 9"');
+ const after = await sample();
+
+ expect(after.sweep).not.toBe(before.sweep);
+ });
+
+ it("sees a pseudo-element's own counter-increment change", async () => {
+ await load(
+ composition(
+ "#countdown::after { counter-increment: countdown 10; content: counter(countdown); } #countdown.next::after { counter-increment: countdown 9; }",
+ '<span id="countdown" class="fixed"></span>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.getElementById("countdown").classList.add("next")');
+ const after = await sample();
+
+ expect(after.sweep).not.toBe(before.sweep);
+ });
+
+ it("sees a clip-path wipe over a box that never moves", async () => {
+ await load(
+ composition(
+ "#panel { width: 200px; height: 100px; background: #f00; clip-path: inset(0 100% 0 0); }",
+ '<div id="panel"></div>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.getElementById("panel").style.clipPath = "inset(0 50% 0 0)"');
+ const after = await sample();
+
+ expect(after.sweep).not.toBe(before.sweep);
+ expect(after.liveness).not.toBe(before.liveness);
+ });
+
+ it("sees textarea value and checkbox indeterminate changes", async () => {
+ await load(
+ composition(
+ "",
+ '<textarea id="note" class="fixed">10</textarea><input id="toggle" type="checkbox" />',
+ ),
+ );
+ const start = await sample();
+ await mutate('document.getElementById("note").value = "09"');
+ const afterText = await sample();
+ await mutate('document.getElementById("toggle").indeterminate = true');
+ const afterIndeterminate = await sample();
+
+ expect(afterText.sweep).not.toBe(start.sweep);
+ expect(afterIndeterminate.sweep).not.toBe(afterText.sweep);
+ });
+
+ it("sees the composition root's own text change", async () => {
+ await load(composition("", "10"));
+ const before = await sample();
+ await mutate('document.getElementById("root").firstChild.textContent = "09"');
+ const after = await sample();
+
+ expect(after.sweep).not.toBe(before.sweep);
+ expect(after.liveness).not.toBe(before.liveness);
+ });
+
+ it("ignores text mutations inside a display:none descendant", async () => {
+ await load(
+ composition(
+ "#hidden { display: none; }",
+ '<span id="countdown" class="fixed">10<span id="hidden">10</span></span>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.getElementById("hidden").textContent = "09"');
+ const after = await sample();
+
+ expect(after).toEqual(before);
+ });
+
+ it("ignores motion on a data-layout-ignore layer", async () => {
+ await load(
+ composition(
+ "#glow { position: absolute; width: 100px; height: 100px; background: #0f0; }",
+ '<div id="glow" data-layout-ignore></div><span id="countdown" class="fixed">10</span>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.getElementById("glow").style.left = "200px"');
+ const after = await sample();
+
+ expect(after).toEqual(before);
+ });
+
+ // A keepsMoving scope names the element explicitly, so the layout-audit
+ // opt-out on the scope itself does not empty its signature (which the Node
+ // side would otherwise report as motion_selector_missing for an element that
+ // exists). Opt-outs INSIDE the scope still apply.
+ it("measures a keepsMoving scope that is itself data-layout-ignore, but not opted-out layers inside it", async () => {
+ await load(
+ composition(
+ "#scene { position: absolute; width: 300px; height: 200px; } #logo, #glow { position: absolute; width: 50px; height: 50px; background: #00f; }",
+ '<div id="scene" data-layout-ignore><div id="logo"></div><div id="glow" data-layout-ignore></div></div>',
+ ),
+ );
+ const before = await sample("#scene");
+ expect(before.liveness).not.toBe("");
+ await mutate('document.getElementById("glow").style.left = "100px"');
+ const afterIgnoredMove = await sample("#scene");
+ await mutate('document.getElementById("logo").style.left = "100px"');
+ const afterMove = await sample("#scene");
+
+ expect(afterIgnoredMove.liveness).toBe(before.liveness);
+ expect(afterMove.liveness).not.toBe(before.liveness);
+ });
+
+ it("ignores text mutations inside content-visibility:hidden contents", async () => {
+ await load(
+ composition(
+ "#wrap { content-visibility: hidden; }",
+ '<div id="wrap"><span id="skipped" class="fixed">10</span></div><span class="fixed">10</span>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.getElementById("skipped").textContent = "09"');
+ const after = await sample();
+
+ expect(after).toEqual(before);
+ });
+
+ it("ignores a decoy counter owner inside content-visibility:hidden contents", async () => {
+ await load(
+ composition(
+ "#wrap { content-visibility: hidden; } #decoy { counter-reset: countdown 10; } #countdown::after { content: counter(countdown); }",
+ '<div id="wrap"><div id="decoy"></div></div><span id="countdown" class="fixed"></span>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.getElementById("decoy").style.counterReset = "countdown 9"');
+ const after = await sample();
+
+ expect(after).toEqual(before);
+ });
+
+ it("ignores a decoy counter owner inside off-screen content-visibility:auto contents", async () => {
+ await load(
+ composition(
+ "#far { content-visibility: auto; position: absolute; top: 5000px; width: 10px; height: 10px; } #decoy { counter-reset: countdown 10; } #countdown::after { content: counter(countdown); }",
+ '<div id="far"><div id="decoy"></div></div><span id="countdown" class="fixed"></span>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.getElementById("decoy").style.counterReset = "countdown 9"');
+ const after = await sample();
+
+ expect(after).toEqual(before);
+ });
+
+ it("ignores a repaint of a canvas whose contents are skipped by content-visibility:hidden", async () => {
+ await load(
+ composition(
+ "#c { content-visibility: hidden; width: 100px; height: 100px; }",
+ '<canvas id="c" width="100" height="100"></canvas>',
+ ),
+ );
+ const before = await sample();
+ await mutate(
+ 'const ctx = document.getElementById("c").getContext("2d"); ctx.fillStyle = "#f00"; ctx.fillRect(0, 0, 100, 100);',
+ );
+ const after = await sample();
+
+ expect(after).toEqual(before);
+ });
+
+ // content-visibility only skips contents where size containment applies; on
+ // a non-atomic inline host it is a no-op and everything inside still paints.
+ it("keeps signing text and pseudo content inside an inline content-visibility:hidden host", async () => {
+ await load(
+ composition(
+ "#host { content-visibility: hidden; } #host::after { content: attr(data-txt); }",
+ '<span id="host" data-txt="10"><span id="kid" class="fixed">10</span></span>',
+ ),
+ );
+ const start = await sample();
+ await mutate('document.getElementById("kid").textContent = "09"');
+ const afterText = await sample();
+ await mutate('document.getElementById("host").setAttribute("data-txt", "09")');
+ const afterPseudo = await sample();
+
+ expect(afterText.sweep).not.toBe(start.sweep);
+ expect(afterText.liveness).not.toBe(start.liveness);
+ expect(afterPseudo.sweep).not.toBe(afterText.sweep);
+ });
+
+ it("sees a checkbox toggle on a content-visibility:hidden control", async () => {
+ await load(
+ composition(
+ "#toggle { content-visibility: hidden; width: 24px; height: 24px; }",
+ '<input id="toggle" type="checkbox" />',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.getElementById("toggle").checked = true');
+ const after = await sample();
+
+ expect(after.sweep).not.toBe(before.sweep);
+ });
+
+ it("ignores a value change on a text input whose contents are skipped by content-visibility:hidden", async () => {
+ await load(
+ composition(
+ "#note { content-visibility: hidden; width: 120px; height: 40px; font: 24px monospace; }",
+ '<input id="note" value="10" />',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.getElementById("note").value = "09"');
+ const after = await sample();
+
+ expect(after).toEqual(before);
+ });
+
+ it("sees a counter painted only by a display:contents host's pseudo-element", async () => {
+ await load(
+ composition(
+ "body { counter-reset: countdown 10; } #host { display: contents; } #host::after { content: counter(countdown); font: 32px/48px monospace; }",
+ '<div id="host"></div>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.body.style.counterReset = "countdown 9"');
+ const after = await sample();
+
+ expect(after.sweep).not.toBe(before.sweep);
+ });
+
+ it("ignores a content-visibility:hidden host's own text and pseudo content but still sees its box move", async () => {
+ await load(
+ composition(
+ "#host { content-visibility: hidden; position: absolute; width: 80px; height: 48px; background: #f00; } #host::after { content: attr(data-txt); }",
+ '<div id="host" data-txt="10">10</div>',
+ ),
+ );
+ const start = await sample();
+ await mutate('document.getElementById("host").firstChild.textContent = "09"');
+ await mutate('document.getElementById("host").setAttribute("data-txt", "09")');
+ const afterContents = await sample();
+ await mutate('document.getElementById("host").style.left = "100px"');
+ const afterMove = await sample();
+
+ expect(afterContents).toEqual(start);
+ expect(afterMove.sweep).not.toBe(start.sweep);
+ });
+
+ // A display:contents host has no box of its own, so the platform cannot tell
+ // it apart from skipped contents; inside a content-visibility:hidden host its
+ // pseudo-elements paint nothing and must not keep a counter consumed.
+ it("ignores a counter painted only by a display:contents host's pseudo-element inside skipped contents", async () => {
+ await load(
+ composition(
+ "body { counter-reset: countdown 10; } #wrap { content-visibility: hidden; width: 80px; height: 48px; } #host { display: contents; } #host::after { content: counter(countdown); font: 32px/48px monospace; }",
+ '<div id="wrap"><div id="host"></div></div>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.body.style.counterReset = "countdown 9"');
+ const after = await sample();
+
+ expect(after).toEqual(before);
+ });
+
+ // Chromium (152) skips the contents of a table-cell host but not of a
+ // table-caption host; NOT_CONTAINABLE_DISPLAY mirrors the platform here
+ // rather than css-contain-2's exemption list. This test and the next pin
+ // both halves.
+ it("ignores a table-cell content-visibility:hidden host's own text and pseudo content", async () => {
+ await load(
+ composition(
+ "#host { display: table-cell; content-visibility: hidden; width: 80px; height: 48px; font: 32px/48px monospace; } #host::after { content: attr(data-txt); }",
+ '<div id="host" data-txt="10">10</div><span class="fixed">10</span>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.getElementById("host").firstChild.textContent = "09"');
+ await mutate('document.getElementById("host").setAttribute("data-txt", "09")');
+ const after = await sample();
+
+ expect(after).toEqual(before);
+ });
+
+ it("keeps signing a table-caption content-visibility:hidden host's own text and pseudo content", async () => {
+ await load(
+ composition(
+ "#host { content-visibility: hidden; width: 80px; height: 48px; font: 32px/48px monospace; } #host::after { content: attr(data-txt); }",
+ '<table><caption id="host" data-txt="10">10</caption></table>',
+ ),
+ );
+ const start = await sample();
+ await mutate('document.getElementById("host").firstChild.textContent = "09"');
+ const afterText = await sample();
+ await mutate('document.getElementById("host").setAttribute("data-txt", "09")');
+ const afterPseudo = await sample();
+
+ expect(afterText.sweep).not.toBe(start.sweep);
+ expect(afterText.liveness).not.toBe(start.liveness);
+ expect(afterPseudo.sweep).not.toBe(afterText.sweep);
+ });
+
+ // The only counter consumers are hidden pseudo-elements of a host that skips its contents; `shown` gives
+ // the host's hidden counter-increment a consumed name. Nothing the host declares or paints may count as motion.
+ it("ignores a counter reachable only through a skipped host's hidden pseudo-elements", async () => {
+ await load(
+ composition(
+ "html { counter-reset: shown 1; } body { counter-reset: countdown 10; } #host { content-visibility: hidden; display: list-item; list-style-position: inside; width: 80px; height: 48px; } #host::marker { content: counter(countdown); } #host::after { content: counter(countdown); counter-increment: shown 0; } #host.stepped::after { counter-increment: shown 5; } #shown::after { content: counter(shown); }",
+ '<div id="host"><span id="kid" class="fixed"></span></div><span id="shown" class="fixed"></span>',
+ ),
+ );
+ const before = await sample();
+ await mutate('document.body.style.counterReset = "countdown 9"');
+ const afterOwner = await sample();
+ await mutate('document.getElementById("host").classList.add("stepped")');
+ const afterHiddenIncrement = await sample();
+
+ expect(await visible("#kid")).toBe(false);
+ expect(afterOwner).toEqual(before);
+ expect(afterHiddenIncrement).toEqual(before);
+ });
+});
diff --git a/packages/cli/src/commands/motion-signature.browser.js b/packages/cli/src/commands/motion-signature.browser.js
new file mode 100644
index 0000000000..9b11c084b0
--- /dev/null
+++ b/packages/cli/src/commands/motion-signature.browser.js
@@ -0,0 +1,374 @@
+// Shared "what counts as motion" classifier, injected before layout-audit.browser.js and motion-sample.browser.js.
+// The frozen-sweep guard (sweep_static) and keepsMoving liveness (motion_frozen) meet in one decision, so both
+// must count the same channels as motion; only quantization differs (liveness buckets 2px and 0.08 opacity).
+// A channel reader returns a string equal across samples iff it did not visibly change, "" when it does not apply.
+(function () {
+ const IGNORE_TAGS = new Set(["SCRIPT", "STYLE", "TEMPLATE", "NOSCRIPT", "META", "LINK"]);
+ const MEDIA_TAGS = new Set(["CANVAS", "VIDEO", "IMG"]);
+ const FNV_OFFSET_BASIS = 2166136261;
+ const FNV_PRIME = 16777619;
+ const LIVENESS_POSITION_BUCKET_PX = 2;
+ const LIVENESS_OPACITY_BUCKET = 0.08;
+ const IGNORE_SELECTOR = "[data-layout-ignore], [data-layout-check='ignore']";
+ // counter(name) / counters(name, sep) in generated content. A list-item box
+ // whose ::marker content is `normal` paints counter(list-item) implicitly.
+ const COUNTER_FUNCTION = /counters?\(\s*([^\s,)]+)/g;
+ const IMPLICIT_MARKER_CONTENT = "counter(list-item)";
+ const LIST_ITEM_DISPLAY = /\blist-item\b/;
+ // Whether an element sits inside skipped contents is not on its computed style; only checkVisibility knows.
+ // PAINTED_OPTIONS matches layout-audit.browser.js isVisibleElement's opacity-floor path. happy-dom lacks
+ // checkVisibility, so callers keep a computed-style fallback.
+ const RENDERED_BOX_OPTIONS = { contentVisibilityAuto: true };
+ const PAINTED_OPTIONS = {
+ opacityProperty: true,
+ visibilityProperty: true,
+ contentVisibilityAuto: true,
+ };
+ // Stand-in for the ::before/::after of an element whose contents are skipped:
+ // no pseudo box exists, so nothing it declares (content, counter-*) paints.
+ const NO_BOX = Object.freeze({ display: "none" });
+ const SKIPPED_PSEUDO = Object.freeze({ before: NO_BOX, after: NO_BOX });
+ // content-visibility skips contents only where size containment applies (css-contain-2); hosts matching this
+ // paint everything. It mirrors Chromium 152 where that differs from the spec: a table-cell host skips, a
+ // table-caption host does not. Replaced elements (MEDIA_TAGS) are atomic even at display:inline.
+ const NOT_CONTAINABLE_DISPLAY =
+ /^(inline( list-item)?|contents|table|inline-table|table-(?!cell$)[a-z-]+|ruby[a-z-]*)$/;
+
+ function skipsContents(element, style) {
+ if (style.contentVisibility !== "hidden") return false;
+ return MEDIA_TAGS.has(element.tagName) || !NOT_CONTAINABLE_DISPLAY.test(style.display);
+ }
+
+ function round(value) {
+ return Math.round(value * 100) / 100;
+ }
+
+ function opacityChain(element) {
+ let opacity = 1;
+ for (let current = element; current; current = current.parentElement) {
+ const parsed = Number.parseFloat(getComputedStyle(current).opacity || "1");
+ if (Number.isFinite(parsed)) opacity *= parsed;
+ }
+ return opacity;
+ }
+
+ function compositionRoot() {
+ return (
+ document.querySelector("[data-composition-id][data-width][data-height]") ||
+ document.querySelector("[data-composition-id]") ||
+ document.body
+ );
+ }
+
+ function isHiddenStyle(style) {
+ return (
+ style.display === "none" || style.visibility === "hidden" || style.visibility === "collapse"
+ );
+ }
+
+ // Kept local rather than shared with layout-audit, which is installed and tested on its own. The author
+ // opt-out is not applied: an asserted selector outranks it, and compositionSignature applies it itself.
+ // clip-path is a channel, not a visibility probe, so a wipe over a static box counts as motion.
+ // fallow-ignore-next-line complexity
+ function isVisibleElement(element, style, opacity) {
+ if (IGNORE_TAGS.has(element.tagName)) return false;
+ if (
+ typeof element.checkVisibility === "function" &&
+ !element.checkVisibility(PAINTED_OPTIONS)
+ ) {
+ return false;
+ }
+ if (isHiddenStyle(style || getComputedStyle(element))) return false;
+ if ((opacity === undefined ? opacityChain(element) : opacity) < 0.2) return false;
+ const rect = element.getBoundingClientRect();
+ return rect.width > 0.5 && rect.height > 0.5;
+ }
+
+ function foldField(hash, value) {
+ hash ^= value.length;
+ hash = Math.imul(hash, FNV_PRIME);
+ for (let i = 0; i < value.length; i++) {
+ hash ^= value.charCodeAt(i);
+ hash = Math.imul(hash, FNV_PRIME);
+ }
+ return hash;
+ }
+
+ function hashFields(fields) {
+ let hash = FNV_OFFSET_BASIS;
+ for (const field of fields) hash = foldField(hash, field);
+ return (hash >>> 0).toString(36);
+ }
+
+ // `none` / `normal` are the computed initial values of content, counter-*,
+ // clip-path, and font-variation-settings; collapse them so unused channels
+ // stay "".
+ function cssValue(value) {
+ return value === "none" || value === "normal" ? "" : value || "";
+ }
+
+ // --- Per-element channels: (element, ctx) => string --------------------------
+
+ function boxChannel(element, ctx) {
+ const rect = element.getBoundingClientRect();
+ const box = [rect.left, rect.top, rect.width, rect.height];
+ if (ctx.quantize) {
+ return box.map((value) => Math.round(value / LIVENESS_POSITION_BUCKET_PX)).join(",");
+ }
+ return box.map(round).join(",");
+ }
+
+ function opacityChannel(element, ctx) {
+ return String(
+ ctx.quantize ? Math.round(ctx.opacity / LIVENESS_OPACITY_BUCKET) : round(ctx.opacity),
+ );
+ }
+
+ // Variable-font axis animation moves no geometry and no opacity; in a
+ // DUPLEXED face (Recursive holds one advance width at every weight) not even
+ // the line width shifts, so without this channel the whole run reads frozen.
+ function fontAxesChannel(element, ctx) {
+ const axes = cssValue(ctx.style.fontVariationSettings);
+ return axes ? hashFields([axes]) : "";
+ }
+
+ // A clip-path wipe (inset(0 100% 0 0) → inset(0)) reveals a box that never
+ // moves; the computed clip-path string is the only thing that changes.
+ function clipPathChannel(element, ctx) {
+ const clip = cssValue(ctx.style.clipPath);
+ return clip ? hashFields([clip]) : "";
+ }
+
+ // Direct text nodes only: descendants are signed separately, and a hidden
+ // descendant's text mutation must not masquerade as visible motion.
+ function textChannel(element) {
+ const text = Array.from(element.childNodes)
+ .filter((node) => node.nodeType === 3)
+ .map((node) => node.textContent)
+ .join("");
+ return text && hashFields([text]);
+ }
+
+ function flag(value) {
+ return value ? "1" : "0";
+ }
+
+ function selectState(element) {
+ const fields = [String(element.selectedIndex), element.value || ""];
+ for (const option of element.options) fields.push(flag(option.selected));
+ return fields;
+ }
+
+ // A control's value is painted by its inner (shadow) contents, which
+ // content-visibility: hidden skips; the widget itself (its type, a
+ // checkbox/radio glyph) is theme paint of the control's own box and still
+ // shows. Hence two channels.
+ const CONTROL_VALUE = {
+ INPUT: (element) => [element.value || ""],
+ TEXTAREA: (element) => [element.value || ""],
+ SELECT: selectState,
+ };
+
+ function controlValueChannel(element) {
+ const read = CONTROL_VALUE[element.tagName];
+ return read ? hashFields(read(element)) : "";
+ }
+
+ function controlWidgetChannel(element) {
+ if (element.tagName !== "INPUT") return "";
+ return hashFields([element.type || "", flag(element.checked), flag(element.indeterminate)]);
+ }
+
+ // Chromium substitutes attr() in computed pseudo content, so this is the
+ // platform-owned rendered string rather than a CSS expression to reparse.
+ // counter() is NOT substituted — that is what the counter channel is for.
+ function generatedContentChannel(element, ctx) {
+ const before = cssValue(ctx.pseudo.before.content);
+ const after = cssValue(ctx.pseudo.after.content);
+ return before || after ? hashFields([before, after]) : "";
+ }
+
+ // Pixel-only media motion (canvas repaint, playing video, same-size <img> swap) is invisible to DOM channels,
+ // so fold in an 8x8 downsample. Unreadable media hashes to a constant; iframe media is a separate document.
+ // fallow-ignore-next-line complexity
+ function mediaPixelChannel(element) {
+ if (!MEDIA_TAGS.has(element.tagName)) return "";
+ try {
+ const rect = element.getBoundingClientRect();
+ const sourceWidth = element.videoWidth || element.width || rect.width;
+ const sourceHeight = element.videoHeight || element.height || rect.height;
+ if (!sourceWidth || !sourceHeight) return "x";
+ const off = document.createElement("canvas");
+ off.width = 8;
+ off.height = 8;
+ const ctx2d = off.getContext("2d");
+ if (!ctx2d) return "x";
+ ctx2d.drawImage(element, 0, 0, 8, 8);
+ const data = ctx2d.getImageData(0, 0, 8, 8).data;
+ let hash = 0;
+ for (let i = 0; i < data.length; i++) hash = (hash * 31 + data[i]) >>> 0;
+ return String(hash);
+ } catch {
+ return "x";
+ }
+ }
+
+ // The element's own box still paints when its contents are skipped
+ // (content-visibility: hidden) — including a checkbox's check glyph; its
+ // text, pseudo boxes, control value, and replaced content (a canvas/video/img's
+ // pixels) do not.
+ const BOX_CHANNELS = [
+ boxChannel,
+ opacityChannel,
+ fontAxesChannel,
+ clipPathChannel,
+ controlWidgetChannel,
+ ];
+ const CONTENT_CHANNELS = [
+ textChannel,
+ controlValueChannel,
+ generatedContentChannel,
+ mediaPixelChannel,
+ ];
+ const ELEMENT_CHANNELS = [...BOX_CHANNELS, ...CONTENT_CHANNELS];
+
+ // --- Composition-level counter channel ------------------------------------
+ // Counter declarations often live on zero-box owners while a pseudo-element elsewhere paints the value, so
+ // every box-generating element is an owner, but only declarations naming a painted counter fold in.
+ // The gate is by name, not scope: enough for catching frozen timelines. <ol start> and <li value> are missed.
+
+ // Generated content of one box owner that reaches the screen, including a list-item's ::marker.
+ // Callers have already excluded opted-out hosts and hosts whose contents are skipped.
+ function markerContent(element, style) {
+ if (isHiddenStyle(style) || !LIST_ITEM_DISPLAY.test(style.display)) return "";
+ return cssValue(getComputedStyle(element, "::marker").content) || IMPLICIT_MARKER_CONTENT;
+ }
+
+ function paintedContent(element, style, pseudo, opacity) {
+ if (opacity < 0.2) return [];
+ const boxes = [pseudo.before, pseudo.after].filter((box) => !isHiddenStyle(box));
+ return [...boxes.map((box) => cssValue(box.content)), markerContent(element, style)];
+ }
+
+ // The author opt-out applies to elements INSIDE the measured root, never to
+ // the root itself or its ancestors: a keepsMoving scope (or the composition
+ // root) is explicitly asserted, and an assertion naming an element outranks
+ // a layout-audit opt-out — see isVisibleElement.
+ function isOptedOut(element, root) {
+ for (let current = element; current && current !== root; current = current.parentElement) {
+ if (current.matches(IGNORE_SELECTOR)) return true;
+ }
+ return false;
+ }
+
+ function consumedCounterNames(owners) {
+ const names = new Set();
+ for (const owner of owners) {
+ for (const content of owner.painted) {
+ for (const match of content.matchAll(COUNTER_FUNCTION)) names.add(match[1]);
+ }
+ }
+ return names;
+ }
+
+ // `counter-reset: a 10 b 3` → does any named counter get painted?
+ function namesConsumedCounter(declaration, consumed) {
+ return declaration.split(/\s+/).some((token) => consumed.has(token));
+ }
+
+ function counterState(style, consumed) {
+ const fields = [style.counterReset, style.counterIncrement, style.counterSet]
+ .map(cssValue)
+ .filter((declaration) => declaration && namesConsumedCounter(declaration, consumed));
+ return fields.length > 0 ? "c:" + hashFields(fields) : "";
+ }
+
+ function counterParts(root, owners) {
+ const consumed = consumedCounterNames(owners);
+ if (consumed.size === 0) return [];
+ const parts = [];
+ function push(style) {
+ const state = counterState(style, consumed);
+ if (state) parts.push(state);
+ }
+ for (let ancestor = root.parentElement; ancestor; ancestor = ancestor.parentElement) {
+ push(getComputedStyle(ancestor));
+ }
+ for (const owner of owners) {
+ push(owner.style);
+ push(owner.pseudo.before);
+ push(owner.pseudo.after);
+ }
+ return parts;
+ }
+
+ // One signature of everything under `root`, root included, that a viewer could see change between seeks.
+ // Opted-out elements inside the root may animate off the timeline, so they are neither signed nor counter
+ // consumers, but stay counter owners; the root itself is always measured.
+ // fallow-ignore-next-line complexity
+ function compositionSignature(root, options) {
+ if (!root) return "";
+ const quantize = !!(options && options.quantize);
+ const parts = [];
+ const boxOwners = [];
+ // Unrendered elements paint nothing and feed no counter(). A display:contents child of a skipping host
+ // paints nothing either, which checkVisibility cannot tell from an ordinary one, so the parent's
+ // skipsContents verdict decides. A display:contents child of an off-screen `auto` host is missed.
+ const unrenderedBelow = new Set();
+ const skippedHosts = new Set();
+ for (const element of [root, ...root.querySelectorAll("*")]) {
+ if (IGNORE_TAGS.has(element.tagName)) continue;
+ const style = getComputedStyle(element);
+ const parent = element.parentElement;
+ const platformDecides = typeof element.checkVisibility === "function";
+ const noBox = platformDecides
+ ? !element.checkVisibility(RENDERED_BOX_OPTIONS)
+ : style.display === "none";
+ const boxlessOwner = style.display === "contents" && !skippedHosts.has(parent);
+ if (unrenderedBelow.has(parent) || (noBox && !boxlessOwner)) {
+ unrenderedBelow.add(element);
+ continue;
+ }
+ // A skipping host paints its box but not its contents. Its counter-* stay in: in Chromium its
+ // increment and set still reach a sibling's painted counter(). Off-screen `auto` hosts are missed.
+ const skipped = skipsContents(element, style);
+ if (skipped) skippedHosts.add(element);
+ if (skipped && !platformDecides) unrenderedBelow.add(element);
+ const pseudo = skipped
+ ? SKIPPED_PSEUDO
+ : {
+ before: getComputedStyle(element, "::before"),
+ after: getComputedStyle(element, "::after"),
+ };
+ const opacity = opacityChain(element);
+ const optedOut = isOptedOut(element, root);
+ const paintsContent = !optedOut && !skipped;
+ boxOwners.push({
+ style,
+ pseudo,
+ painted: paintsContent ? paintedContent(element, style, pseudo, opacity) : [],
+ });
+ if (optedOut || !isVisibleElement(element, style, opacity)) continue;
+ const ctx = { style, pseudo, opacity, quantize };
+ const channels = skipped ? BOX_CHANNELS : ELEMENT_CHANNELS;
+ parts.push(channels.map((channel) => channel(element, ctx)).join(","));
+ }
+ parts.push(...counterParts(root, boxOwners));
+ return parts.join("|");
+ }
+
+ window.__hyperframesMotionSignature = {
+ compositionRoot,
+ isVisibleElement,
+ opacityChain,
+ round,
+ compositionSignature,
+ };
+
+ // Frozen-sweep guard entry point (checkBrowser.ts collectLayoutGeometry).
+ // The name predates the textual/media channels and is kept for driver
+ // compatibility.
+ window.__hyperframesLayoutGeometry = function collectLayoutGeometry() {
+ return compositionSignature(compositionRoot(), { quantize: false });
+ };
+})();
diff --git a/packages/cli/src/commands/motion-signature.browser.test.ts b/packages/cli/src/commands/motion-signature.browser.test.ts
new file mode 100644
index 0000000000..264b5a72a7
--- /dev/null
+++ b/packages/cli/src/commands/motion-signature.browser.test.ts
@@ -0,0 +1,826 @@
+// @vitest-environment happy-dom
+// fallow-ignore-file code-duplication
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { readFileSync } from "node:fs";
+import { dirname, join } from "node:path";
+import { fileURLToPath } from "node:url";
+
+const __dirname = dirname(fileURLToPath(import.meta.url));
+const script = readFileSync(join(__dirname, "motion-signature.browser.js"), "utf-8");
+
+interface RectInput {
+ left: number;
+ top: number;
+ width: number;
+ height: number;
+}
+
+type StyleOverride = Partial<CSSStyleDeclaration>;
+
+interface Fixture {
+ /** Bounding rects keyed by element id (or lower-case tag name for id-less elements). */
+ rects: Record<string, RectInput>;
+ /** Computed-style overrides keyed like `rects`; getters are re-read on every call. */
+ styles?: Record<string, StyleOverride>;
+ /** `::before` / `::after` computed-style overrides keyed like `rects`. */
+ pseudo?: Record<string, { before?: StyleOverride; after?: StyleOverride }>;
+}
+
+const BASE_STYLE: StyleOverride = {
+ display: "block",
+ visibility: "visible",
+ opacity: "1",
+ fontVariationSettings: "normal",
+ clipPath: "none",
+ counterReset: "none",
+ counterIncrement: "none",
+ counterSet: "none",
+};
+
+const BASE_PSEUDO_STYLE: StyleOverride = {
+ content: "none",
+ counterReset: "none",
+ counterIncrement: "none",
+ counterSet: "none",
+};
+
+function keyFor(element: Element): string {
+ return element.id || element.tagName.toLowerCase();
+}
+
+// A per-element fake getComputedStyle: each element reports only its own declared style, like the platform,
+// so ancestor awareness (hidden subtrees, counter owners above the root) must come from the classifier.
+function installFixture({ rects, styles = {}, pseudo = {} }: Fixture): void {
+ vi.spyOn(window, "getComputedStyle").mockImplementation((element, pseudoElement) => {
+ const key = keyFor(element as Element);
+ if (pseudoElement === "::before" || pseudoElement === "::after") {
+ const override = pseudoElement === "::before" ? pseudo[key]?.before : pseudo[key]?.after;
+ return { ...BASE_PSEUDO_STYLE, ...override } as CSSStyleDeclaration;
+ }
+ return { ...BASE_STYLE, ...styles[key] } as CSSStyleDeclaration;
+ });
+ for (const element of Array.from(document.querySelectorAll("*"))) {
+ const input = rects[keyFor(element)] ?? { left: 0, top: 0, width: 0, height: 0 };
+ vi.spyOn(element, "getBoundingClientRect").mockReturnValue(rect(input));
+ }
+}
+
+function rect({ left, top, width, height }: RectInput): DOMRect {
+ return {
+ left,
+ top,
+ right: left + width,
+ bottom: top + height,
+ width,
+ height,
+ x: left,
+ y: top,
+ toJSON() {
+ return this;
+ },
+ } as DOMRect;
+}
+
+interface SignatureWindow {
+ __hyperframesLayoutGeometry: () => string;
+ __hyperframesMotionSignature: {
+ compositionRoot(): Element;
+ compositionSignature(root: Element | null, options?: { quantize?: boolean }): string;
+ };
+}
+
+function signatureWindow(): SignatureWindow {
+ return window as unknown as SignatureWindow;
+}
+
+function installScript(): () => string {
+ window.eval(script);
+ return signatureWindow().__hyperframesLayoutGeometry;
+}
+
+function mockMediaPixels(read: () => number): void {
+ const getContextSpy = vi.spyOn(HTMLCanvasElement.prototype, "getContext") as unknown as {
+ mockReturnValue(value: CanvasRenderingContext2D): void;
+ };
+ getContextSpy.mockReturnValue({
+ drawImage() {},
+ getImageData() {
+ return { data: new Uint8ClampedArray(8 * 8 * 4).fill(read()) };
+ },
+ } as unknown as CanvasRenderingContext2D);
+}
+
+const ROOT = { left: 0, top: 0, width: 640, height: 360 };
+const COUNTDOWN = { left: 280, top: 140, width: 80, height: 48 };
+const ZERO_BOX = { left: 0, top: 0, width: 0, height: 0 };
+const COUNTER_CONSUMER = { after: { content: "counter(countdown)" } };
+
+afterEach(() => {
+ vi.restoreAllMocks();
+ document.body.innerHTML = "";
+ Reflect.deleteProperty(window, "__hyperframesLayoutGeometry");
+ Reflect.deleteProperty(window, "__hyperframesMotionSignature");
+});
+
+describe("motion-signature.browser media and geometry channels", () => {
+ it("changes the sweep fingerprint when visible video pixels advance", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <video id="footage"></video>
+ </div>
+ `;
+ installFixture({ rects: { root: ROOT, footage: ROOT } });
+ let pixelValue = 20;
+ mockMediaPixels(() => pixelValue);
+
+ const collect = installScript();
+ const before = collect();
+ pixelValue = 220;
+
+ expect(collect()).not.toBe(before);
+ });
+
+ // An equal-size opaque <img> swap moves no geometry or opacity; only the media pixel channel sees it.
+ it("changes the sweep fingerprint when a same-size opaque img is swapped", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <img id="frame" />
+ </div>
+ `;
+ installFixture({ rects: { root: ROOT, frame: ROOT } });
+ let pixelValue = 20;
+ mockMediaPixels(() => pixelValue);
+
+ const collect = installScript();
+ const before = collect();
+ pixelValue = 220;
+
+ expect(collect()).not.toBe(before);
+ });
+
+ // Opacity-only reveals (code-typing scenes) must count as motion both mid-fade and when a glyph crosses
+ // the 0.2 visibility floor; otherwise `check` misfires sweep_static.
+ it("changes the sweep fingerprint when text reveals via opacity alone", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <div id="code"><span id="char">c</span></div>
+ </div>
+ `;
+ let charOpacity = "0";
+ installFixture({
+ rects: {
+ root: ROOT,
+ code: { left: 40, top: 40, width: 560, height: 48 },
+ char: { left: 40, top: 40, width: 18, height: 48 },
+ },
+ styles: {
+ char: {
+ get opacity() {
+ return charOpacity;
+ },
+ } as StyleOverride,
+ },
+ });
+
+ const collect = installScript();
+ const hidden = collect(); // below the 0.2 visibility floor — not in the signature
+ charOpacity = "0.5";
+ const fading = collect(); // mid-fade — present, opacity part of the signature
+ charOpacity = "1";
+ const revealed = collect(); // settled
+
+ expect(fading).not.toBe(hidden);
+ expect(revealed).not.toBe(fading);
+ });
+
+ // Variable-font axis animation (registry block `weight-wave`): a crest of
+ // weight travels across a line of text. In a duplexed face nothing moves
+ // but the axis string — the fingerprint must still see it.
+ it("changes the sweep fingerprint when only font-variation-settings moves", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <div id="line"><span id="char">P</span></div>
+ </div>
+ `;
+ let axes = '"wght" 400, "slnt" 0';
+ installFixture({
+ rects: {
+ root: ROOT,
+ line: { left: 40, top: 40, width: 560, height: 48 },
+ char: { left: 40, top: 40, width: 18, height: 48 },
+ },
+ styles: {
+ char: {
+ get fontVariationSettings() {
+ return axes;
+ },
+ } as StyleOverride,
+ },
+ });
+
+ const collect = installScript();
+ const rest = collect();
+ axes = '"wght" 1000, "slnt" -12'; // the crest arrives over this character
+
+ expect(collect()).not.toBe(rest);
+ });
+
+ // The other direction, and it guards the more dangerous failure: a
+ // fingerprint that varies on its own would make sweep_static unfireable and
+ // every green layout verdict meaningless. Identical scene, axes included,
+ // must hash identically.
+ it("keeps the sweep fingerprint identical when nothing moves, font axes included", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <div id="line"><span id="char">P</span></div>
+ </div>
+ `;
+ installFixture({
+ rects: {
+ root: ROOT,
+ line: { left: 40, top: 40, width: 560, height: 48 },
+ char: { left: 40, top: 40, width: 18, height: 48 },
+ },
+ styles: { char: { fontVariationSettings: '"wght" 400, "slnt" 0' } },
+ });
+
+ const collect = installScript();
+
+ expect(collect()).toBe(collect());
+ });
+
+ it("changes the sweep fingerprint when only clip-path moves", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <div id="panel"></div>
+ </div>
+ `;
+ let clipPath = "inset(0px 100% 0px 0px)";
+ installFixture({
+ rects: { root: ROOT, panel: { left: 40, top: 40, width: 200, height: 100 } },
+ styles: {
+ panel: {
+ get clipPath() {
+ return clipPath;
+ },
+ } as StyleOverride,
+ },
+ });
+
+ const collect = installScript();
+ const before = collect();
+ clipPath = "inset(0px 50% 0px 0px)";
+
+ expect(collect()).not.toBe(before);
+ });
+
+ it("ignores motion on a data-layout-ignore layer", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <div id="glow" data-layout-ignore></div>
+ <span id="countdown">10</span>
+ </div>
+ `;
+ let left = 40;
+ installFixture({ rects: { root: ROOT, countdown: COUNTDOWN } });
+ vi.spyOn(document.getElementById("glow")!, "getBoundingClientRect").mockImplementation(() =>
+ rect({ left, top: 40, width: 100, height: 100 }),
+ );
+
+ const collect = installScript();
+ const before = collect();
+ left = 200;
+
+ expect(collect()).toBe(before);
+ });
+
+ it("measures a root that is itself data-layout-ignore while still excluding opted-out layers inside it", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <div id="scene" data-layout-ignore>
+ <div id="logo"></div>
+ <div id="glow" data-layout-ignore></div>
+ </div>
+ </div>
+ `;
+ let logoLeft = 40;
+ let glowLeft = 40;
+ installFixture({ rects: { root: ROOT, scene: { left: 0, top: 0, width: 300, height: 200 } } });
+ vi.spyOn(document.getElementById("logo")!, "getBoundingClientRect").mockImplementation(() =>
+ rect({ left: logoLeft, top: 40, width: 50, height: 50 }),
+ );
+ vi.spyOn(document.getElementById("glow")!, "getBoundingClientRect").mockImplementation(() =>
+ rect({ left: glowLeft, top: 40, width: 50, height: 50 }),
+ );
+ installScript();
+ const { compositionSignature } = signatureWindow().__hyperframesMotionSignature;
+ const scene = document.getElementById("scene")!;
+
+ const before = compositionSignature(scene);
+ expect(before).not.toBe("");
+ glowLeft = 200;
+ expect(compositionSignature(scene)).toBe(before);
+ logoLeft = 200;
+ expect(compositionSignature(scene)).not.toBe(before);
+ });
+
+ it("buckets sub-threshold moves out of the quantized liveness signature only", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <div id="box"></div>
+ </div>
+ `;
+ let left = 100;
+ installFixture({ rects: { root: ROOT } });
+ vi.spyOn(document.getElementById("box")!, "getBoundingClientRect").mockImplementation(() =>
+ rect({ left, top: 100, width: 50, height: 50 }),
+ );
+ installScript();
+ const { compositionSignature, compositionRoot } =
+ signatureWindow().__hyperframesMotionSignature;
+ const root = compositionRoot();
+
+ const exactBefore = compositionSignature(root);
+ const bucketedBefore = compositionSignature(root, { quantize: true });
+ left = 100.6; // moves, but stays inside the 2px liveness bucket
+
+ expect(compositionSignature(root)).not.toBe(exactBefore);
+ expect(compositionSignature(root, { quantize: true })).toBe(bucketedBefore);
+ });
+});
+
+describe("motion-signature.browser textual channels", () => {
+ it("changes the sweep fingerprint when fixed-width text content changes", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <span id="countdown">10</span>
+ </div>
+ `;
+ installFixture({ rects: { root: ROOT, countdown: COUNTDOWN } });
+
+ const collect = installScript();
+ const before = collect();
+ document.getElementById("countdown")!.textContent = "09";
+
+ expect(collect()).not.toBe(before);
+ });
+
+ it("ignores text mutations inside a display:none descendant", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <span id="countdown">10<span id="hidden">10</span></span>
+ </div>
+ `;
+ installFixture({
+ rects: { root: ROOT, countdown: COUNTDOWN, hidden: COUNTDOWN },
+ styles: { hidden: { display: "none" } },
+ });
+
+ const collect = installScript();
+ const before = collect();
+ document.getElementById("hidden")!.textContent = "09";
+
+ expect(collect()).toBe(before);
+ });
+
+ it("changes the sweep fingerprint when the composition root's own text changes", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">10</div>
+ `;
+ installFixture({ rects: { root: ROOT } });
+
+ const collect = installScript();
+ const before = collect();
+ document.getElementById("root")!.textContent = "09";
+
+ expect(collect()).not.toBe(before);
+ });
+
+ it("changes the sweep fingerprint when an attr-backed data value changes", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <span id="countdown" data-txt="10"></span>
+ </div>
+ `;
+ installFixture({
+ rects: { root: ROOT, countdown: COUNTDOWN },
+ pseudo: {
+ countdown: {
+ after: {
+ // Chromium substitutes attr() in computed pseudo content.
+ get content() {
+ return JSON.stringify(document.getElementById("countdown")!.getAttribute("data-txt"));
+ },
+ } as StyleOverride,
+ },
+ },
+ });
+
+ const collect = installScript();
+ const before = collect();
+ document.getElementById("countdown")!.setAttribute("data-txt", "09");
+
+ expect(collect()).not.toBe(before);
+ });
+
+ it("changes the sweep fingerprint when pseudo-element content changes", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <span id="countdown"></span>
+ </div>
+ `;
+ let generatedContent = '"10"';
+ installFixture({
+ rects: { root: ROOT, countdown: COUNTDOWN },
+ pseudo: {
+ countdown: {
+ after: {
+ get content() {
+ return generatedContent;
+ },
+ } as StyleOverride,
+ },
+ },
+ });
+
+ const collect = installScript();
+ const before = collect();
+ generatedContent = '"09"';
+
+ expect(collect()).not.toBe(before);
+ });
+
+ it("changes the sweep fingerprint when checkbox state changes", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <input id="toggle" type="checkbox" />
+ </div>
+ `;
+ installFixture({
+ rects: { root: ROOT, toggle: { left: 280, top: 140, width: 24, height: 24 } },
+ });
+
+ const collect = installScript();
+ const before = collect();
+ (document.getElementById("toggle") as HTMLInputElement).checked = true;
+
+ expect(collect()).not.toBe(before);
+ });
+
+ it("changes the sweep fingerprint when a checkbox becomes indeterminate", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <input id="toggle" type="checkbox" />
+ </div>
+ `;
+ installFixture({
+ rects: { root: ROOT, toggle: { left: 280, top: 140, width: 24, height: 24 } },
+ });
+
+ const collect = installScript();
+ const before = collect();
+ (document.getElementById("toggle") as HTMLInputElement).indeterminate = true;
+
+ expect(collect()).not.toBe(before);
+ });
+
+ it("changes the sweep fingerprint when a secondary select option changes", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <select id="choices" multiple><option selected>A</option><option>B</option></select>
+ </div>
+ `;
+ installFixture({
+ rects: { root: ROOT, choices: { left: 280, top: 140, width: 120, height: 48 } },
+ });
+
+ const collect = installScript();
+ const before = collect();
+ (document.getElementById("choices") as HTMLSelectElement).options[1]!.selected = true;
+
+ expect(collect()).not.toBe(before);
+ });
+
+ it("changes the sweep fingerprint when a fixed-width form value changes", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <input id="countdown" value="10" />
+ </div>
+ `;
+ installFixture({ rects: { root: ROOT, countdown: COUNTDOWN } });
+
+ const collect = installScript();
+ const before = collect();
+ (document.getElementById("countdown") as HTMLInputElement).value = "09";
+
+ expect(collect()).not.toBe(before);
+ });
+
+ it("changes the sweep fingerprint when a textarea value changes", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <textarea id="countdown">10</textarea>
+ </div>
+ `;
+ installFixture({ rects: { root: ROOT, countdown: COUNTDOWN } });
+
+ const collect = installScript();
+ const before = collect();
+ (document.getElementById("countdown") as HTMLTextAreaElement).value = "09";
+
+ expect(collect()).not.toBe(before);
+ });
+
+ it("keeps textual sweep channels identical when the countdown is truly frozen", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <span id="countdown" data-txt="10">10</span>
+ </div>
+ `;
+ installFixture({
+ rects: { root: ROOT, countdown: COUNTDOWN },
+ styles: { countdown: { counterReset: "countdown 10" } },
+ pseudo: { countdown: { after: { content: '"10"' } } },
+ });
+
+ const collect = installScript();
+
+ expect(collect()).toBe(collect());
+ });
+});
+
+describe("motion-signature.browser counter channel", () => {
+ it("changes the sweep fingerprint when a zero-box owner's counter state changes", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <div id="counter-owner"><span id="countdown"></span></div>
+ </div>
+ `;
+ let counterReset = "countdown 10";
+ installFixture({
+ rects: { root: ROOT, "counter-owner": ZERO_BOX, countdown: COUNTDOWN },
+ styles: {
+ "counter-owner": {
+ get counterReset() {
+ return counterReset;
+ },
+ } as StyleOverride,
+ },
+ pseudo: { countdown: COUNTER_CONSUMER },
+ });
+
+ const collect = installScript();
+ const before = collect();
+ counterReset = "countdown 9";
+
+ expect(collect()).not.toBe(before);
+ });
+
+ it("changes the sweep fingerprint when a counter owned above the composition root changes", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <span id="countdown"></span>
+ </div>
+ `;
+ let counterReset = "countdown 10";
+ installFixture({
+ rects: { root: ROOT, countdown: COUNTDOWN },
+ styles: {
+ body: {
+ get counterReset() {
+ return counterReset;
+ },
+ } as StyleOverride,
+ },
+ pseudo: { countdown: COUNTER_CONSUMER },
+ });
+
+ const collect = installScript();
+ const before = collect();
+ counterReset = "countdown 9";
+
+ expect(collect()).not.toBe(before);
+ });
+
+ it("changes the sweep fingerprint when a pseudo-element's own counter-increment changes", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <span id="countdown"></span>
+ </div>
+ `;
+ let counterIncrement = "countdown 10";
+ installFixture({
+ rects: { root: ROOT, countdown: COUNTDOWN },
+ pseudo: {
+ countdown: {
+ after: {
+ content: "counter(countdown)",
+ get counterIncrement() {
+ return counterIncrement;
+ },
+ } as StyleOverride,
+ },
+ },
+ });
+
+ const collect = installScript();
+ const before = collect();
+ counterIncrement = "countdown 9";
+
+ expect(collect()).not.toBe(before);
+ });
+
+ it("changes the sweep fingerprint when a zero-box host's own pseudo-element paints the counter", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <div id="host"></div>
+ </div>
+ `;
+ let counterReset = "countdown 10";
+ installFixture({
+ rects: { root: ROOT, host: ZERO_BOX },
+ styles: {
+ body: {
+ get counterReset() {
+ return counterReset;
+ },
+ } as StyleOverride,
+ },
+ pseudo: { host: COUNTER_CONSUMER },
+ });
+
+ const collect = installScript();
+ const before = collect();
+ counterReset = "countdown 9";
+
+ expect(collect()).not.toBe(before);
+ });
+
+ it("ignores a zero-box decoy whose counter name nothing paints even when a list marker exists", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <ul><li id="item">item</li></ul>
+ <div id="decoy"></div>
+ </div>
+ `;
+ let counterReset = "decoy 10";
+ installFixture({
+ rects: { root: ROOT, item: COUNTDOWN, decoy: ZERO_BOX },
+ styles: {
+ item: { display: "list-item" },
+ decoy: {
+ get counterReset() {
+ return counterReset;
+ },
+ } as StyleOverride,
+ },
+ });
+
+ const collect = installScript();
+ const before = collect();
+ counterReset = "decoy 9";
+
+ expect(collect()).toBe(before);
+ });
+
+ it("ignores a counter consumed only under a data-layout-ignore layer", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <div id="counter-owner"></div>
+ <div data-layout-ignore><span id="countdown"></span></div>
+ </div>
+ `;
+ let counterReset = "countdown 10";
+ installFixture({
+ rects: { root: ROOT, "counter-owner": ZERO_BOX, countdown: COUNTDOWN },
+ styles: {
+ "counter-owner": {
+ get counterReset() {
+ return counterReset;
+ },
+ } as StyleOverride,
+ },
+ pseudo: { countdown: COUNTER_CONSUMER },
+ });
+
+ const collect = installScript();
+ const before = collect();
+ counterReset = "countdown 9";
+
+ expect(collect()).toBe(before);
+ });
+
+ it("keeps a visibility:hidden owner whose counter feeds a visible consumer", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <div id="counter-owner"><span id="countdown"></span></div>
+ </div>
+ `;
+ let counterReset = "countdown 10";
+ installFixture({
+ rects: { root: ROOT, "counter-owner": COUNTDOWN, countdown: COUNTDOWN },
+ styles: {
+ "counter-owner": {
+ visibility: "hidden",
+ get counterReset() {
+ return counterReset;
+ },
+ } as StyleOverride,
+ },
+ pseudo: { countdown: COUNTER_CONSUMER },
+ });
+
+ const collect = installScript();
+ const before = collect();
+ counterReset = "countdown 9";
+
+ expect(collect()).not.toBe(before);
+ });
+
+ // A display:none element generates no box, so its counters cannot reach any
+ // painted counter() — a varying counter-reset there must not make a frozen
+ // composition read as live.
+ it("ignores a display:none decoy counter owner in a frozen composition", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <div id="decoy"></div>
+ <span id="countdown"></span>
+ </div>
+ `;
+ let counterReset = "countdown 10";
+ installFixture({
+ rects: { root: ROOT, decoy: ZERO_BOX, countdown: COUNTDOWN },
+ styles: {
+ decoy: {
+ display: "none",
+ get counterReset() {
+ return counterReset;
+ },
+ } as StyleOverride,
+ },
+ pseudo: { countdown: COUNTER_CONSUMER },
+ });
+
+ const collect = installScript();
+ const before = collect();
+ counterReset = "countdown 9";
+
+ expect(collect()).toBe(before);
+ });
+
+ it("ignores a decoy counter owner nested inside a display:none subtree", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <div id="hidden-parent"><div id="decoy"></div></div>
+ <span id="countdown"></span>
+ </div>
+ `;
+ let counterReset = "countdown 10";
+ installFixture({
+ rects: { root: ROOT, "hidden-parent": ZERO_BOX, decoy: ZERO_BOX, countdown: COUNTDOWN },
+ styles: {
+ "hidden-parent": { display: "none" },
+ // The decoy itself computes display:block — only its ancestry hides it.
+ decoy: {
+ display: "block",
+ get counterReset() {
+ return counterReset;
+ },
+ } as StyleOverride,
+ },
+ pseudo: { countdown: COUNTER_CONSUMER },
+ });
+
+ const collect = installScript();
+ const before = collect();
+ counterReset = "countdown 9";
+
+ expect(collect()).toBe(before);
+ });
+
+ it("ignores counter declarations when no visible generated content consumes a counter", () => {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <div id="counter-owner"></div>
+ <span id="countdown">10</span>
+ </div>
+ `;
+ let counterReset = "countdown 10";
+ installFixture({
+ rects: { root: ROOT, "counter-owner": ZERO_BOX, countdown: COUNTDOWN },
+ styles: {
+ "counter-owner": {
+ get counterReset() {
+ return counterReset;
+ },
+ } as StyleOverride,
+ },
+ });
+
+ const collect = installScript();
+ const before = collect();
+ counterReset = "countdown 9";
+
+ expect(collect()).toBe(before);
+ });
+});
diff --git a/packages/cli/src/utils/checkBrowser.ts b/packages/cli/src/utils/checkBrowser.ts
index c15ab95f45..d7bb3cf438 100644
--- a/packages/cli/src/utils/checkBrowser.ts
+++ b/packages/cli/src/utils/checkBrowser.ts
@@ -434,6 +434,7 @@ async function hasNoTimelineDeclaration(page: Page): Promise<boolean> {
}
async function injectAuditScripts(page: Page, contrast: boolean): Promise<void> {
+ await page.addScriptTag({ content: loadBrowserScript("motion-signature.browser.js") });
await page.addScriptTag({ content: loadBrowserScript("layout-audit.browser.js") });
await page.addScriptTag({ content: loadBrowserScript("motion-sample.browser.js") });
if (contrast) {
diff --git a/packages/cli/src/utils/checkPipeline.ts b/packages/cli/src/utils/checkPipeline.ts
index a687c7e2f0..1dc0dd40bd 100644
--- a/packages/cli/src/utils/checkPipeline.ts
+++ b/packages/cli/src/utils/checkPipeline.ts
@@ -215,8 +215,8 @@ interface GridSamples {
contrastEntries: ContrastAuditEntry[];
screenshots: CheckScreenshot[];
contrastMs: number;
- /** One geometry+opacity fingerprint per layout sample (#U10 frozen-sweep guard). */
- geometrySignatures: { time: number; signature: string }[];
+ /** One visible-state fingerprint per layout sample (#U10 frozen-sweep guard). */
+ layoutStateSignatures: { time: number; signature: string }[];
/** Every rotatable element's geometry at each layout sample; grouped by
* selector after the run to detect rotation_pivot_drift. */
rotationSamples: RotationSample[];
@@ -406,7 +406,7 @@ async function collectGridSamples(
contrastEntries: [],
screenshots: [],
contrastMs: 0,
- geometrySignatures: [],
+ layoutStateSignatures: [],
rotationSamples: [],
indicatorFrames: [],
};
@@ -420,7 +420,10 @@ async function collectGridSamples(
const layoutIssues = await driver.collectLayout(time, options.tolerance, options.layout);
collected.layoutIssues.push(...layoutIssues);
issuesAtTime.push(...layoutIssues);
- collected.geometrySignatures.push({ time, signature: await driver.collectLayoutGeometry() });
+ collected.layoutStateSignatures.push({
+ time,
+ signature: await driver.collectLayoutGeometry(),
+ });
collected.rotationSamples.push(...(await driver.collectRotationSample(time)));
collected.indicatorFrames.push(await driver.collectOffPivotRotationSample(time));
}
@@ -504,7 +507,7 @@ const ZERO_LAYOUT_RECT: LayoutRect = {
/**
* Frozen-sweep guard (#U10): if every layout-grid sample produced the exact
- * same geometry+opacity fingerprint (see layout-audit.browser.js), the seek
+ * same visible-state fingerprint (see motion-signature.browser.js), the seek
* never actually advanced the composition's timeline — every other green
* verdict from this run is meaningless, not just a missed defect. Skips
* short (<3s) compositions, single-sample runs (nothing to compare), and
@@ -513,15 +516,15 @@ const ZERO_LAYOUT_RECT: LayoutRect = {
*/
function detectSweepStatic(
duration: number,
- geometrySignatures: string[],
+ layoutStateSignatures: string[],
motionIssues: AnchoredLayoutIssue[],
hasNoTimelineDeclaration: boolean,
): AnchoredLayoutIssue[] {
if (hasNoTimelineDeclaration) return [];
if (duration < SWEEP_STATIC_MIN_DURATION_SEC) return [];
- if (geometrySignatures.length < 2) return [];
+ if (layoutStateSignatures.length < 2) return [];
if (motionIssues.some((issue) => issue.code === "motion_frozen")) return [];
- const [first, ...rest] = geometrySignatures;
+ const [first, ...rest] = layoutStateSignatures;
if (!first || rest.some((signature) => signature !== first)) return [];
return [
{
@@ -1095,7 +1098,7 @@ export async function runAuditGrid(
const userPicked = new Set(grid.userPickedSamples);
const sweepFindings = detectSweepStatic(
grid.duration,
- collected.geometrySignatures
+ collected.layoutStateSignatures
.filter((sample) => !userPicked.has(sample.time))
.map((sample) => sample.signature),
motionIssues,
diff --git a/packages/cli/src/utils/checkTypes.ts b/packages/cli/src/utils/checkTypes.ts
index dd0fea2bae..0b3607b83e 100644
--- a/packages/cli/src/utils/checkTypes.ts
+++ b/packages/cli/src/utils/checkTypes.ts
@@ -195,9 +195,8 @@ export interface CheckAuditDriver {
): Promise<AnchoredLayoutIssue[]>;
/** content_overlap only, for the dense re-sampling grid — catches transient text collisions the sparse grid seeks past. */
collectOverlap(time: number): Promise<AnchoredLayoutIssue[]>;
- /** Frozen-sweep guard (#U10): an opaque per-sample geometry+opacity
- * fingerprint of the current seeked state, for detecting a timeline that
- * never advances under seek. See layout-audit.browser.js. */
+ /** Frozen-sweep guard (#U10): an opaque fingerprint of the seeked visual state, from
+ * motion-signature.browser.js (shared with motion-sample's liveness). Legacy name kept. */
collectLayoutGeometry(): Promise<string>;
/** rotation_pivot_drift: every rotatable element's bbox center/size/angle at
* the current seeked state. Accumulated across the grid — see checkPipeline. */