#!/usr/bin/env node /** * Enforce the Web capability claim. * * The claim is intentionally finite: every capability row in * tools/web/manual/feature-matrix.json must be "usable" (locally or through the * documented server/native backend), and the canonical outward-facing documents * must not keep the old "does not claim parity" hedge. * * Historical evidence logs and archived manuals are intentionally out of scope. * * Usage: node tools/web/check-parity-claim.mjs */ import fs from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; const HERE = path.dirname(fileURLToPath(import.meta.url)); const REPO = path.resolve(HERE, "../.."); const MATRIX = path.join(HERE, "manual/feature-matrix.json"); const read = (file) => fs.readFileSync(path.join(REPO, file), "utf8"); const errors = []; const matrix = JSON.parse(read("tools/web/manual/feature-matrix.json")); const capabilities = Array.isArray(matrix.capabilities) ? matrix.capabilities : []; const nonUsable = capabilities.filter((capability) => capability.status !== "usable"); if (capabilities.length === 0) errors.push("feature matrix has no capabilities"); if (nonUsable.length > 0) { errors.push(`feature matrix still has ${nonUsable.length}/${capabilities.length} non-usable rows: ${nonUsable.map((item) => `${item.area}/${item.feature}=${item.status}`).join("; ")}`); } const forbidden = [ { pattern: /不宣称/, label: "不宣称" }, { pattern: /未实现项/, label: "未实现项" }, { pattern: /not a complete (?:Blender|port)/i, label: "not a complete Blender/port" }, { pattern: /not a browser port of the complete/i, label: "not a browser port of the complete" }, { pattern: /does not imply complete Blender/i, label: "does not imply complete Blender" }, { pattern: /does not claim (?:full|complete) parity/i, label: "does not claim full parity" }, { pattern: /complete Blender 5\.2\s+parity/i, label: "complete Blender 5.2 parity" }, { pattern: /NOT_CLAIMED/, label: "NOT_CLAIMED" }, ]; const canonical = [ "user-manual/WEB_Blender_Web_Manual_20261113/manual.json", "tools/web/manual/generate-manual.mjs", "tools/web/manual/feature-matrix.json", "web/app/public/manuals/index.html", "tools/web/course/full-course.json", "web/app/public/tutorial/full/index.html", "docs/web/KNOWN_LIMITATIONS.md", "docs/web/RELEASE_NOTES.md", "docs/WEB_BLENDER_MODELER_V1_SCOPE.md", "docs/status/WEB_BLENDER_FULL_COURSE_20261113.md", "docs/status/parity-ledger.json", ]; for (const file of canonical) { if (!fs.existsSync(path.join(REPO, file))) { errors.push(`missing canonical claim file: ${file}`); continue; } const text = read(file); for (const entry of forbidden) { if (entry.pattern.test(text)) errors.push(`${file} still contains "${entry.label}"`); } } const report = { schemaVersion: 1, status: errors.length === 0 ? "PASS" : "FAIL", capabilities: capabilities.length, nonUsable: nonUsable.length, canonicalFiles: canonical.length, errors, }; const reportPath = path.join(REPO, "tests/golden/PARITY-CLAIM/check-report.json"); fs.mkdirSync(path.dirname(reportPath), { recursive: true }); fs.writeFileSync(reportPath, `${JSON.stringify(report, null, 2)}\n`); process.stdout.write(`parity-claim ${report.status} capabilities=${capabilities.length} nonUsable=${nonUsable.length} errors=${errors.length}\n`); if (errors.length > 0) process.exitCode = 1;