- 新数据链 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>
87 lines
4.2 KiB
JavaScript
87 lines
4.2 KiB
JavaScript
#!/usr/bin/env node
|
||
// Verify a project's evidence without re-running the browser.
|
||
//
|
||
// This is the tool's own acceptance profile: it answers "was every modelling
|
||
// step actually performed through the UI, and did the UI produce the same
|
||
// numbers as the scripted build?" from files on disk only.
|
||
//
|
||
// Usage: node accept.mjs --project <dir>
|
||
import fs from "node:fs";
|
||
import path from "node:path";
|
||
import { loadProject, projectFromArgv, readJson, replayPath } from "./manifest.mjs";
|
||
import { readReplay } from "./lib/replay.mjs";
|
||
import { stillName } from "./lib/stills.mjs";
|
||
|
||
const projectDir = projectFromArgv();
|
||
const project = loadProject(projectDir, { requireParts: true });
|
||
|
||
const checks = [];
|
||
const check = (id, name, ok, detail) => checks.push({ id, name, ok: Boolean(ok), detail });
|
||
|
||
const missing = [];
|
||
const volumeMisses = [];
|
||
const stepMismatches = [];
|
||
const noStills = [];
|
||
let totalSteps = 0;
|
||
let partsSeen = 0;
|
||
|
||
for (const part of project.parts) {
|
||
const stepsFile = path.join(project.paths.stepsDir, `${part.document}.json`);
|
||
const runFile = path.join(project.paths.runDir, `${part.document}.json`);
|
||
const replay = project.paths.replayDir ? readReplay(replayPath(project, part.document)) : null;
|
||
|
||
if (!fs.existsSync(stepsFile)) { missing.push(`${part.id}: no ui-steps`); continue; }
|
||
partsSeen++;
|
||
const steps = readJson(stepsFile).steps ?? [];
|
||
totalSteps += steps.length;
|
||
|
||
if (replay && steps.length !== replay.steps.length)
|
||
stepMismatches.push(`${part.id}: ${steps.length} ui steps vs ${replay.steps.length} replay steps`);
|
||
for (const step of steps) if (!step.command) noStills.push(`${part.id} step ${step.step}: no command`);
|
||
|
||
// One still per step, named by the scene id the driver captured.
|
||
const dir = path.join(project.paths.stillsDir, part.id);
|
||
const files = fs.existsSync(dir) ? fs.readdirSync(dir).filter(name => name.endsWith(".png")) : [];
|
||
if (!files.length) noStills.push(`${part.id}: no stills directory`);
|
||
// Ask the same module the writer uses, so the checker cannot drift from it.
|
||
for (const [index, step] of steps.entries()) {
|
||
const stem = `${stillName(project, part, index, steps)}.png`;
|
||
if (!files.includes(stem)) noStills.push(`${part.id} ${step.label} (${stem})`);
|
||
}
|
||
|
||
if (!fs.existsSync(runFile)) { volumeMisses.push(`${part.id}: no ui-run evidence`); continue; }
|
||
const run = readJson(runFile);
|
||
if (!(run.steps === run.stepsTotal && run.failed === 0 && run.volumeMatches === true)) {
|
||
const detail = run.steps === run.stepsTotal
|
||
? `rel ${run.relativeError}` : `aborted at ${run.steps}/${run.stepsTotal ?? "?"}`;
|
||
volumeMisses.push(`${part.id}: ${detail}`);
|
||
}
|
||
}
|
||
|
||
check("U1", "每件都有界面步骤清单", missing.length === 0, { missing: missing.slice(0, 8) });
|
||
check("U2", "步骤数与回放一致且每步有命令", stepMismatches.length === 0 && noStills.every(item => !/no command/.test(item)),
|
||
{ totalSteps, parts: partsSeen, mismatches: stepMismatches.slice(0, 8) });
|
||
check("U3", "每步都有界面截图", noStills.filter(item => !/no command/.test(item)).length === 0,
|
||
{ missing: noStills.slice(0, 8) });
|
||
check("U4", "界面复现体积与回放一致(1e-6)", volumeMisses.length === 0, { failed: volumeMisses.slice(0, 8) });
|
||
|
||
if (project.assembly) {
|
||
const reportFile = path.join(project.paths.runDir, `${project.assembly.document}-assembly.json`);
|
||
if (!fs.existsSync(reportFile)) {
|
||
check("U5", "装配经界面完成", false, { error: `no assembly report at ${reportFile}` });
|
||
} else {
|
||
const report = readJson(reportFile);
|
||
check("U5", "装配插入完整且旋转保留",
|
||
!report.fatal && report.mismatches?.length === 0
|
||
&& report.inserted === report.expected?.inserts
|
||
&& report.rotated === report.expected?.rotated,
|
||
{ inserted: report.inserted, rotated: report.rotated, expected: report.expected,
|
||
mismatches: (report.mismatches ?? []).slice(0, 6), fatal: report.fatal });
|
||
}
|
||
}
|
||
|
||
const failed = checks.filter(item => !item.ok);
|
||
console.log(JSON.stringify({ passed: failed.length === 0, checks: checks.length, failed: failed.length,
|
||
results: checks.map(item => ({ id: item.id, ok: item.ok, name: item.name, detail: item.ok ? undefined : item.detail })) }, null, 2));
|
||
process.exitCode = failed.length ? 1 : 0;
|