Accumulated uncommitted work: GHOST Web backend, WebGL/GPU web layer, web workflow engine and protocol, tooling, docs and task records. Large generated evidence, user-testing archives, build snapshots and imported test assets remain untracked. Co-Authored-By: Claude Code <noreply@anthropic.com>
88 lines
12 KiB
JavaScript
88 lines
12 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import crypto from "node:crypto";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { execFileSync } from "node:child_process";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
|
const abs = (file) => path.join(root, file);
|
|
const read = (file) => fs.readFileSync(abs(file), "utf8");
|
|
const json = (file) => JSON.parse(read(file));
|
|
const writeJson = (file, value) => { fs.mkdirSync(path.dirname(abs(file)), { recursive: true }); fs.writeFileSync(abs(file), `${JSON.stringify(value, null, 2)}\n`); };
|
|
const writeText = (file, value) => { fs.mkdirSync(path.dirname(abs(file)), { recursive: true }); fs.writeFileSync(abs(file), value); };
|
|
const sha = (file) => crypto.createHash("sha256").update(fs.readFileSync(abs(file))).digest("hex");
|
|
const run = ([entry, ...args]) => execFileSync(process.execPath, [abs(entry), ...args], { cwd: root, stdio: "inherit" });
|
|
|
|
const rootTask = "WBV2-P1137-000";
|
|
const moduleTask = "WBV2-P1137-001";
|
|
const parentTask = "WBV2-P1136-001";
|
|
const parentManifestPath = `tests/golden/${parentTask}/manifest.json`;
|
|
const planPath = "tests/golden/WBV2-P1100-000/module-execution-plan.json";
|
|
const dynamicPath = "tests/golden/WBV2/dynamic-inventory.json";
|
|
const moduleId = "METABALL_ELEMENTS_TRANSACTION";
|
|
const sourcePaths = [
|
|
"blender-5.2.0/source/blender/web_engine/web_engine_api.cpp",
|
|
"blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp",
|
|
"blender-5.2.0/source/blender/web_engine/web_engine_main_state.h",
|
|
"web/protocol/web-engine.ts",
|
|
"web/app/src/workers/web-engine.worker.ts",
|
|
"web/app/src/app/App.tsx",
|
|
"web/tests/e2e/wbv2-metaball-elements-production.spec.ts",
|
|
];
|
|
const commands = [
|
|
"npm --prefix web run typecheck",
|
|
"npm --prefix web run build",
|
|
"WEB_TEST_PORT=5353 npm --prefix web run test:e2e -- --workers=1 tests/e2e/wbv2-metaball-elements-production.spec.ts",
|
|
];
|
|
const dynamic = json(dynamicPath);
|
|
const dynamicSummary = { path: dynamicPath, sha256: sha(dynamicPath), sourceTreeSha256: dynamic.authority.sourceTreeSha256, unitCount: dynamic.summary.unitCount, planningEstimate: dynamic.policy.planningEstimate, hardTarget: dynamic.policy.hardTarget, verifiedUnits: dynamic.coverage.verifiedUnits, unverifiedUnits: dynamic.coverage.unverifiedUnits };
|
|
const queuePath = "docs/EXECUTION_QUEUE.md";
|
|
const queue = read(queuePath);
|
|
const queueTask = queue.match(/\| 当前任务 \| `([^`]+)` \|/u)?.[1];
|
|
const parent = json(parentManifestPath);
|
|
const plan = json(planPath);
|
|
const index = json("tests/golden/WBV2/task-index.json");
|
|
assert.equal(queueTask, parentTask, `expected terminal queue task ${parentTask}, got ${queueTask}`);
|
|
assert.equal(parent.status, "done");
|
|
assert.equal(parent.nextTask, null);
|
|
assert.equal(index.activeTask, null);
|
|
assert.equal(plan.status, "COMPLETED_MODULE_EXECUTION");
|
|
assert.ok(plan.tasks.every((task) => task.status === "done" && task.ready !== true));
|
|
for (const source of sourcePaths) assert.ok(fs.existsSync(abs(source)), `missing source: ${source}`);
|
|
|
|
const module = { moduleId, sourceBacked: true, capabilities: ["CAP-METABALL-ELEMENTS-MAIN", "CAP-METABALL-ELEMENTS-RECOVERY", "CAP-METABALL-ELEMENTS-FAIL-CLOSED"], sourcePaths, reuseReceipts: [{ manifest: "tests/golden/WBV2-P1101-000/manifest.json", report: "tests/golden/WBV2-P1101-000/module-receipt.json" }], positive: ["Metaball element Main mutation", "bounded position/radius/scale retention", "save/reopen preserves elements"], negative: ["unknown Metaball data ID", "invalid radius", "element count topology mismatch"], recovery: ["undo", "redo", "save/reopen", "Worker termination and deterministic element state"], commands, fullFamilyParity: false };
|
|
const rootRecord = { id: rootTask, phase: "1137", title: "authorize_metaball_elements_module", kind: "enabling", owner: "PROGRAM", dependsOn: [parentTask], parityId: null, implementationClass: "QUEUE_ONLY", parallelGroup: "module-root-1137", gate: "MODULE", card: `docs/tasks/${rootTask}.md`, behavior: "Authorize one source-backed Metaball element transaction module after the P1136 Font properties module.", outputs: ["successor authorization", "module plan", "manifest", "status"], acceptance: ["P1136 evidence remains hash-bound", "Metaball element source and protocol are present", "inventory remains immutable", "one source-backed module is active"], commands: ["node tools/web/check-execution-control-plane.mjs"], status: "done", ready: false, queueMutationAllowed: true };
|
|
const moduleRecord = { id: moduleTask, phase: "1137", title: "verify_metaball_elements_module", kind: "module", owner: "GEOMETRY", dependsOn: [rootTask], parityId: moduleId, implementationClass: "LOCAL_EXACT", parallelGroup: "module-metaball_elements_transaction", gate: "MODULE", card: `docs/tasks/${moduleTask}.md`, behavior: "Verify Metaball element replacement through Blender Main, protocol, Worker and Chromium recovery.", outputs: ["module receipt", "negative matrix", "manifest", "status"], acceptance: ["source and protocol hashes are bound", "positive Main mutation is proven", "negative no-mutation and recovery are proven", "Chromium and save/reopen evidence are exact", "full-family parity remains explicit"], status: "in_progress", ready: true, queueMutationAllowed: true, module };
|
|
|
|
plan.status = "ACTIVE_MODULE_EXECUTION_QUEUE";
|
|
plan.modules.push({ id: moduleId, task: moduleTask, owner: "GEOMETRY", sourceBacked: true, capabilities: module.capabilities, reusedReceipts: module.reuseReceipts, fullFamilyParity: false });
|
|
plan.tasks.push(rootRecord, moduleRecord);
|
|
writeJson(planPath, plan);
|
|
run(["tools/web/generate-v2-task-index.mjs", "--plan-path", abs(planPath)]);
|
|
parent.nextTask = rootTask;
|
|
parent.continuation = { authorized: true, root: rootTask, scope: moduleId, priorModule: parentTask };
|
|
parent.artifacts.plan.sha256 = sha(planPath);
|
|
writeJson(parentManifestPath, parent);
|
|
|
|
writeText(`docs/tasks/${rootTask}.md`, `# ${rootTask}: authorize Metaball elements module\n\n- task: ${rootTask}\n- parent: ${parentTask}\n- status: done\n- gap: workflow:authorize_metaball_elements_module\n- ownerFamily: PROGRAM\n- targetImplementationClass: QUEUE_ONLY\n- Implementation entrypoint: \`node tools/web/authorize-wbv2-p1137.mjs\`\n\n## 目标\n\nAuthorize one source-backed Metaball element transaction module while preserving P1136 evidence and the historical inventory.\n\n## 输入与范围\n\n- Parent manifest: \`${parentManifestPath}\`\n- Blender source: \`blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp\`\n- Web protocol: \`web/protocol/web-engine.ts\`\n- New module: \`${moduleTask}\`\n\n## 验收\n\n- P1136 source and receipt hashes remain bound\n- Metaball element Main/protocol/Worker sources are present\n- exactly one source-backed module is active\n- malformed, unsupported, missing source or hash-drift input keeps the module in_progress\n- node tools/web/check-execution-control-plane.mjs\n\n## 交付与回滚\n\n- Manifest: \`tests/golden/${rootTask}/manifest.json\`\n- Rollback: restore ${parentTask} as the terminal queue parent and leave ${moduleTask} unstarted.\n`);
|
|
writeText(`docs/status/${rootTask}.md`, `# ${rootTask} status\n\n- task: \`${rootTask}\`; parent: \`${parentTask}\`; status: \`done\`\n- operation: \`AUTHORIZE_SOURCE_BACKED_MODULE\`; module: \`${moduleId}\`\n- P1136 evidence reused; historical 6900-entry inventory remains immutable\n- dynamic source inventory: \`${dynamicSummary.unitCount}\` units, verified \`${dynamicSummary.verifiedUnits}\`, unverified \`${dynamicSummary.unverifiedUnits}\`, planning estimate \`${dynamicSummary.planningEstimate}\` (non-binding)\n- nextTask: \`${moduleTask}\`\n`);
|
|
let updatedQueue = read(queuePath).replace(/\| 当前任务 \| `[^`]+` \|/u, `| 当前任务 | \`${rootTask}\` |`).replace(/\| parent manifest \| `[^`]+` \|/u, `| parent manifest | \`${parentManifestPath}\` |`).replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u, `| 任务卡 | [\`tasks/${rootTask}.md\`](tasks/${rootTask}.md) |`);
|
|
writeText(queuePath, updatedQueue);
|
|
run(["tools/web/check-task-context.mjs", "--task", rootTask, "--write"]);
|
|
const rootReportPath = `tests/golden/${rootTask}/successor-authorization-report.json`;
|
|
const rootStatusPath = `docs/status/${rootTask}.md`;
|
|
const rootContextPath = `tests/golden/${rootTask}/task-context.json`;
|
|
writeJson(rootReportPath, { schemaVersion: 1, task: rootTask, operation: "AUTHORIZE_SOURCE_BACKED_MODULE", status: "PASS", parent: { task: parentTask, manifest: parentManifestPath, manifestSha256: sha(parentManifestPath) }, successor: { task: moduleTask, moduleId, sourceBacked: true, noRepeatedImplementation: true }, inventory: { ...plan.inventory, boundCaseDelta: 0 }, dynamicInventory: { ...dynamicSummary, boundUnitDelta: 0 }, nextTask: moduleTask });
|
|
const rootManifestPath = `tests/golden/${rootTask}/manifest.json`;
|
|
writeJson(rootManifestPath, { schemaVersion: 1, task: rootTask, parentTask, operation: "AUTHORIZE_SOURCE_BACKED_MODULE", status: "done", enablingTask: true, parityStateChange: false, runtime: "MODULE_EXECUTION_QUEUE_BRIDGE", artifacts: { parentManifest: { path: parentManifestPath, sha256: sha(parentManifestPath) }, plan: { path: planPath, sha256: sha(planPath) }, report: { path: rootReportPath, sha256: sha(rootReportPath) }, status: { path: rootStatusPath, sha256: sha(rootStatusPath) }, taskContext: { path: rootContextPath, sha256: sha(rootContextPath) } }, assertions: { sourceBackedSuccessor: true, priorEvidencePreserved: true, inventoryTotal: 6900, effectiveCompleted: 290, effectivePending: 6609, boundCaseDelta: 0, dynamicInventory: dynamicSummary, fullHistoricalReproduction: false }, nextTask: moduleTask });
|
|
updatedQueue = read(queuePath).replace(/\| 当前任务 \| `[^`]+` \|/u, `| 当前任务 | \`${moduleTask}\` |`).replace(/\| parent manifest \| `[^`]+` \|/u, `| parent manifest | \`tests/golden/${rootTask}/manifest.json\` |`).replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u, `| 任务卡 | [\`tasks/${moduleTask}.md\`](tasks/${moduleTask}.md) |`);
|
|
writeText(queuePath, updatedQueue);
|
|
writeText(`docs/tasks/${moduleTask}.md`, `# ${moduleTask}: verify Metaball elements module\n\n- task: ${moduleTask}\n- parent: ${rootTask}\n- status: in_progress\n- gap: workflow:metaball_elements_transaction\n- ownerFamily: GEOMETRY\n- targetImplementationClass: LOCAL_EXACT\n- moduleId: ${moduleId}\n- Implementation entrypoint: \`node tools/web/run-wbv2-module-task.mjs --task ${moduleTask} --write\`\n\n## 目标\n\nVerify the source-backed Metaball element replacement through Blender Main, protocol, Worker and Chromium recovery paths.\n\n## 输入与范围\n\n- Source paths:\n${sourcePaths.map((file) => `- \`${file}\``).join("\n")}\n- Reused receipts:\n- \`tests/golden/WBV2-P1101-000/manifest.json\` + \`tests/golden/WBV2-P1101-000/module-receipt.json\`\n- Production test: \`web/tests/e2e/wbv2-metaball-elements-production.spec.ts\`\n\n## 验收\n\n- Positive: ${module.positive.join(", ")}\n- Negative: ${module.negative.join(", ")}\n- Recovery: ${module.recovery.join(", ")}\n- Commands:\n${commands.map((command) => `- \`${command}\``).join("\n")}\n- malformed input, missing source, hash drift or Chromium failure remains in_progress and does not advance the queue.\n\n## 交付与回滚\n\n- Receipt: \`tests/golden/${moduleTask}/module-receipt.json\`\n- Manifest: \`tests/golden/${moduleTask}/manifest.json\`\n- Status: \`docs/status/${moduleTask}.md\`\n- Rollback: restore ${rootTask} as the queue parent and leave this module in_progress.\n`);
|
|
run(["tools/web/check-task-context.mjs", "--task", moduleTask, "--write"]);
|
|
let next = read("nextTask.md"); const tick = String.fromCharCode(96);
|
|
next = next.replace(/\| Current task when this file was written \| `[^`]+` \|/u, `| Current task when this file was written | ${tick}${moduleTask}${tick} |`).replace(/\| Current task state \| `[^`]+` \|/u, `| Current task state | ${tick}in_progress${tick} |`).replace(/\| Parent manifest \| `[^`]+` \|/u, `| Parent manifest | ${tick}tests/golden/${rootTask}/manifest.json${tick} |`).replace(/\| Current task card \| `[^`]+` \|/u, `| Current task card | ${tick}docs/tasks/${moduleTask}.md${tick} |`).replace(/\| Current task-context nextTask \| `[^`]+` \|/u, `| Current task-context nextTask | ${tick}NONE${tick} |`).replace(/\| Focused command \| `[^`]+` \|/u, `| Focused command | ${tick}node tools/web/run-wbv2-module-task.mjs --task ${moduleTask} --write${tick} |`);
|
|
writeText("nextTask.md", next);
|
|
run(["tools/web/check-execution-control-plane.mjs"]);
|
|
process.stdout.write(`wbv2-successor-authorized root=${rootTask} next=${moduleTask} module=${moduleId}\n`);
|