- 新数据链 web/teaching/cases/carrier-partdesign:20 件零件(spec.json 唯一来源)、 内核建造器 parts/*.mjs、traces/FCStd/replay 全量产物;装配 20 插入 + 19 关节。 - 工具包 tools/carrier:catalog / preflight / create-part / create-assembly / create-all / list / self-test / README,按零件与装配拆分为独立工具。 - 共享驱动扩展 web/tools/cad-ui-rebuild:Loft/Pipe/Hole/Fillet/Chamfer/Mirrored/ LinearPattern 交互,Reversed 复选框补齐;装配 saveAssemblyBundle 先 Accept 再保存。 - 教学:lessons.mjs 新增 carrier 组(环境课 + 20 件 + 装配),suite-runner 增加 carrier-part/carrier-assembly,生成 carrier-toolkit.html 并接入 index 与控制台证据。 验证:20 件 210 步全部有头通过(P05 修复后 39640 m³;P06 回归 8/8); 装配 20/20 插入、19/19 关节、20 组件 0 畸形、0 mismatch;check:carrier、 check:reducer、check-console --live 全绿。 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
45 lines
2.4 KiB
JavaScript
Executable File
45 lines
2.4 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
// Pre-flight: prove the current display can actually be captured before a
|
|
// recording lane starts.
|
|
//
|
|
// Four episodes were recorded on a display whose GL surface x11grab could not
|
|
// see, and produced perfectly valid pure-black videos that passed every
|
|
// structural check in verify.mjs. This check exists so that failure is caught
|
|
// in 10 seconds instead of after a 4-minute recording.
|
|
//
|
|
// Usage: node check-capture.mjs [--display :1]
|
|
import { spawnSync } from "node:child_process";
|
|
import fs from "node:fs";
|
|
|
|
const args = process.argv.slice(2);
|
|
const index = args.indexOf("--display");
|
|
const display = index >= 0 ? args[index + 1] : (process.env.COURSE_VIDEO_DISPLAY ?? ":1");
|
|
const out = "/tmp/freecad-capture-probe.png";
|
|
fs.rmSync(out, { force: true });
|
|
|
|
const grab = spawnSync("ffmpeg", ["-y", "-f", "x11grab", "-video_size", "1600x900",
|
|
"-i", `${display}.0+0,0`, "-frames:v", "1", out, "-loglevel", "error"], { encoding: "utf8" });
|
|
if (!fs.existsSync(out)) {
|
|
console.log(JSON.stringify({ ok: false, display, error: "capture produced no frame", stderr: grab.stderr?.slice(0, 200) }));
|
|
process.exit(1);
|
|
}
|
|
const bytes = spawnSync("ffmpeg", ["-y", "-i", out, "-f", "rawvideo", "-pix_fmt", "gray", "-loglevel", "error", "-"],
|
|
{ maxBuffer: 64 << 20 }).stdout ?? Buffer.alloc(0);
|
|
let sum = 0;
|
|
let max = 0;
|
|
for (const value of bytes) { sum += value; if (value > max) max = value; }
|
|
const mean = bytes.length ? sum / bytes.length : 0;
|
|
// A live desktop contains thousands of colours across the whole frame. `max`
|
|
// alone is a false positive: while the display is asleep a stray cursor pixel
|
|
// can still be 255 while the rest of the frame is pure black, which is exactly
|
|
// how the first re-record attempt passed its own preflight and produced four
|
|
// more black episodes. Require real brightness AND real colour spread.
|
|
const distinct = new Set();
|
|
const rgb = spawnSync("ffmpeg", ["-y", "-i", out, "-f", "rawvideo", "-pix_fmt", "rgb24", "-loglevel", "error", "-"],
|
|
{ maxBuffer: 128 << 20 }).stdout ?? Buffer.alloc(0);
|
|
for (let index = 0; index + 2 < rgb.length; index += 3 * 997) distinct.add((rgb[index] << 16) | (rgb[index + 1] << 8) | rgb[index + 2]);
|
|
const awake = mean > 3 && max > 24 && distinct.size > 20;
|
|
console.log(JSON.stringify({ ok: awake, display, mean: Number(mean.toFixed(1)), max,
|
|
distinctColors: distinct.size, bytes: bytes.length }));
|
|
process.exitCode = awake ? 0 : 1;
|