85453da49f
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
Docs / Validate docs (push) Waiting to run
CodeQL / Analyze (actions) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Sync skills to ClawHub / Publish changed skills (push) Waiting to run
regression / regression-shards (style-16-prod style-9-prod style-17-prod iframe-render-compat variables-prod mp4-h265-sdr, shard-4) (push) Has been cancelled
regression / regression-shards (style-4-prod style-11-prod style-2-prod animejs-adapter typegpu-adapter parallel-capture-regression, shard-5) (push) Has been cancelled
regression / regression-shards (style-7-prod style-8-prod style-10-prod css-spinner-render-compat webm-transparency mp4-h264-sdr webm-vp9, shard-3) (push) Has been cancelled
regression / regression-shards (sub-composition-video style-18-prod raf-ball-render-compat font-variant-numeric sub-comp-t0 sub-comp-id-selector, shard-7) (push) Has been cancelled
Windows render verification / Detect changes (push) Has been cancelled
Windows render verification / Preflight (lint + format) (push) Has been cancelled
Windows render verification / Render on windows-latest (push) Has been cancelled
Windows render verification / Tests on windows-latest (push) Has been cancelled
CI / Detect changes (push) Has been cancelled
CI / Build (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Fallow audit (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Typecheck (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Producer: integration tests (push) Has been cancelled
CI / Producer: unit tests (push) Has been cancelled
CI / File size check (push) Has been cancelled
CI / Test: skills (push) Has been cancelled
CI / Skills: manifest in sync (push) Has been cancelled
CI / CLI: npx shim (macos-latest) (push) Has been cancelled
CI / CLI: npx shim (ubuntu-latest) (push) Has been cancelled
CI / CLI: npx shim (windows-latest) (push) Has been cancelled
CI / SDK: unit + contract + smoke (push) Has been cancelled
CI / Test: runtime contract (push) Has been cancelled
CI / Studio: load smoke (push) Has been cancelled
CI / Smoke: global install (push) Has been cancelled
CI / CLI smoke (required) (push) Has been cancelled
CI / Semantic PR title (push) Has been cancelled
Player perf / Detect changes (push) Has been cancelled
Player perf / Preflight (lint + format) (push) Has been cancelled
Player perf / player-perf (push) Has been cancelled
Player perf / Perf: drift (push) Has been cancelled
Player perf / Perf: fps (push) Has been cancelled
Player perf / Perf: parity (push) Has been cancelled
Player perf / Perf: scrub (push) Has been cancelled
Player perf / Perf: load (push) Has been cancelled
preview-regression / Detect changes (push) Has been cancelled
preview-regression / Preflight (lint + format) (push) Has been cancelled
preview-regression / Preview parity (push) Has been cancelled
preview-regression / preview-regression (push) Has been cancelled
regression / regression (push) Has been cancelled
regression / Detect changes (push) Has been cancelled
regression / Preflight (lint + format) (push) Has been cancelled
regression / regression-shards (hdr-regression style-5-prod style-3-prod mov-prores, shard-1) (push) Has been cancelled
regression / regression-shards (overlay-montage-prod style-12-prod chat missing-host-comp-id png-sequence portrait-edge-bleed, shard-6) (push) Has been cancelled
regression / regression-shards (style-13-prod style-6-prod vignelli-stacking gsap-letters-render-compat audio-mux-parity, shard-8) (push) Has been cancelled
regression / regression-shards (style-15-prod hdr-hlg-regression style-1-prod many-cuts vfr-screen-recording render-symlinked-assets, shard-2) (push) Has been cancelled
152 lines
4.9 KiB
JavaScript
152 lines
4.9 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Objective fidelity gate for figma-motion imports (skill step 2b).
|
|
*
|
|
* Compares the HyperFrames render against Figma's own `export_video` output
|
|
* using MOTION-ENERGY deltas: for each sample window [t, t+interval], the
|
|
* frame difference ref(t+i)-ref(t) is compared (PSNR) against
|
|
* render(t+i)-render(t). Static import divergence (fonts, rasterized edges,
|
|
* subpixel geometry — the hybrid-fidelity ceiling) cancels out of both
|
|
* deltas, so the score isolates choreography: trajectories, timing, easing.
|
|
*
|
|
* Calibration (SDS "Unlocked" card, 2026-07): a faithful translation scored
|
|
* min 20.3dB / mean 27.7dB; a diverging one (invented retract keyframes,
|
|
* wrong durations) scored min 5.0dB / mean 23.1dB. Default threshold 15dB
|
|
* sits between with margin on both sides.
|
|
*
|
|
* node verify-motion.mjs --reference figma-export.mp4 --render out.mp4 \
|
|
* [--crop WxH+X+Y] [--interval 0.2] [--min-motion-psnr 15]
|
|
*
|
|
* --crop selects the card region inside the (usually larger) composition
|
|
* frame. Measure it from the render (the card's left/top edge + scaled
|
|
* size), don't guess: a wrong crop reads as motion divergence.
|
|
*/
|
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
import { mkdtempSync, rmSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
|
|
function arg(name, fallback) {
|
|
const i = process.argv.indexOf(`--${name}`);
|
|
return i > -1 ? process.argv[i + 1] : fallback;
|
|
}
|
|
const reference = arg("reference");
|
|
const render = arg("render");
|
|
if (!reference || !render) {
|
|
console.error(
|
|
"usage: verify-motion.mjs --reference ref.mp4 --render out.mp4 [--crop WxH+X+Y] [--interval 0.2] [--min-motion-psnr 15]",
|
|
);
|
|
process.exit(2);
|
|
}
|
|
const crop = arg("crop", null);
|
|
const interval = Number(arg("interval", "0.2"));
|
|
const minMotion = Number(arg("min-motion-psnr", "15"));
|
|
|
|
const ffprobe = (file) =>
|
|
Number(
|
|
execFileSync("ffprobe", [
|
|
"-v",
|
|
"error",
|
|
"-show_entries",
|
|
"format=duration",
|
|
"-of",
|
|
"csv=p=0",
|
|
file,
|
|
])
|
|
.toString()
|
|
.trim(),
|
|
);
|
|
const refDur = ffprobe(reference);
|
|
const renderDur = ffprobe(render);
|
|
const end = Math.min(refDur, renderDur) - interval - 0.01;
|
|
|
|
const dims = execFileSync("ffprobe", [
|
|
"-v",
|
|
"error",
|
|
"-select_streams",
|
|
"v",
|
|
"-show_entries",
|
|
"stream=width,height",
|
|
"-of",
|
|
"csv=p=0",
|
|
reference,
|
|
])
|
|
.toString()
|
|
.trim()
|
|
.split(",")
|
|
.map(Number);
|
|
const [rw, rh] = dims;
|
|
|
|
let cropFilter = "";
|
|
if (crop) {
|
|
const m = crop.match(/^(\d+)x(\d+)\+(\d+)\+(\d+)$/);
|
|
if (!m) {
|
|
console.error("bad --crop, expected WxH+X+Y");
|
|
process.exit(2);
|
|
}
|
|
cropFilter = `crop=${m[1]}:${m[2]}:${m[3]}:${m[4]},`;
|
|
}
|
|
|
|
const dir = mkdtempSync(join(tmpdir(), "verify-motion-"));
|
|
const frame = (src, t, vf, dst) => {
|
|
const args = ["-y", "-v", "error", "-ss", String(t), "-i", src, "-frames:v", "1"];
|
|
if (vf) args.push("-vf", vf);
|
|
execFileSync("ffmpeg", args.concat(dst));
|
|
};
|
|
const diff = (a, b, dst) =>
|
|
execFileSync("ffmpeg", [
|
|
"-y",
|
|
"-v",
|
|
"error",
|
|
"-i",
|
|
a,
|
|
"-i",
|
|
b,
|
|
"-filter_complex",
|
|
"blend=all_mode=difference",
|
|
dst,
|
|
]);
|
|
const psnr = (a, b) => {
|
|
// spawnSync with array args (no shell): psnr stats land on stderr
|
|
const r = spawnSync("ffmpeg", ["-i", a, "-i", b, "-lavfi", "psnr", "-f", "null", "-"], {
|
|
encoding: "utf8",
|
|
});
|
|
const m = (r.stderr || "").match(/average:([\d.]+|inf)/);
|
|
return m ? (m[1] === "inf" ? 99 : Number(m[1])) : NaN;
|
|
};
|
|
|
|
const renderVf = `${cropFilter}scale=${rw}:${rh}`;
|
|
const results = [];
|
|
for (let t = 0; t <= end; t = Math.round((t + interval) * 1000) / 1000) {
|
|
const t1 = Math.round((t + interval) * 1000) / 1000;
|
|
frame(reference, t, null, join(dir, "ra.png"));
|
|
frame(reference, t1, null, join(dir, "rb.png"));
|
|
frame(render, t, renderVf, join(dir, "oa.png"));
|
|
frame(render, t1, renderVf, join(dir, "ob.png"));
|
|
diff(join(dir, "ra.png"), join(dir, "rb.png"), join(dir, "rd.png"));
|
|
diff(join(dir, "oa.png"), join(dir, "ob.png"), join(dir, "od.png"));
|
|
results.push({
|
|
t,
|
|
motion: psnr(join(dir, "rd.png"), join(dir, "od.png")),
|
|
abs: psnr(join(dir, "rb.png"), join(dir, "ob.png")),
|
|
});
|
|
}
|
|
rmSync(dir, { recursive: true, force: true });
|
|
|
|
const min = Math.min(...results.map((r) => r.motion));
|
|
const mean = results.reduce((s, r) => s + r.motion, 0) / results.length;
|
|
for (const r of results)
|
|
console.log(
|
|
`window ${r.t.toFixed(2)}s→${(r.t + interval).toFixed(2)}s motion-psnr=${r.motion.toFixed(2)}dB (abs=${r.abs.toFixed(1)}dB)${r.motion < minMotion ? " <-- BELOW THRESHOLD" : ""}`,
|
|
);
|
|
console.log(
|
|
`\nwindows=${results.length} min-motion=${min.toFixed(2)}dB mean-motion=${mean.toFixed(2)}dB threshold=${minMotion}dB`,
|
|
);
|
|
if (min < minMotion) {
|
|
console.log(
|
|
"VERDICT: FAIL — choreography diverges from the Figma export (check timings, invented keyframes, durations)",
|
|
);
|
|
process.exit(1);
|
|
}
|
|
console.log("VERDICT: PASS — motion matches the Figma export within the static-fidelity ceiling");
|