91 lines
16 KiB
JavaScript
91 lines
16 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 absolute = (file) => path.join(root, file);
|
|
const read = (file) => fs.readFileSync(absolute(file), "utf8");
|
|
const readJson = (file) => JSON.parse(read(file));
|
|
const sha256 = (file) => crypto.createHash("sha256").update(fs.readFileSync(absolute(file))).digest("hex");
|
|
const p12ManifestPath = "tests/golden/WBV2-P12-005/manifest.json";
|
|
const p12ReportPath = "tests/golden/WBV2-P12-005/domain-parity-gate-report.json";
|
|
const p12StatusPath = "docs/status/WBV2-P12-005.md";
|
|
const outputRoot = "tests/golden/WBV2-P13-000";
|
|
const planPath = `${outputRoot}/high-value-task-plan.json`;
|
|
const reportPath = `${outputRoot}/high-value-root-report.json`;
|
|
const manifestPath = `${outputRoot}/manifest.json`;
|
|
const rootStatusPath = "docs/status/WBV2-P13-000.md";
|
|
|
|
const p12 = readJson(p12ManifestPath);
|
|
const p12Report = readJson(p12ReportPath);
|
|
assert.equal(p12.task, "WBV2-P12-005");
|
|
assert.equal(p12.status, "done");
|
|
assert.ok(p12.nextTask === null || p12.nextTask === "WBV2-P13-000");
|
|
assert.equal(p12Report.status, "PASS");
|
|
assert.equal(p12Report.decision.fullHistoricalReproduction, false);
|
|
for (const artifact of Object.values(p12.artifacts ?? {})) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
|
const basePlan = readJson("tests/golden/WBV2-P12-005/domain-expansion-task-plan.json");
|
|
const tasks = basePlan.tasks.map((task) => ({ ...task, ready: false, status: task.id === "WBV2-P12-005" ? "done" : task.status }));
|
|
const p13 = [
|
|
{ id: "WBV2-P13-000", phase: "P13", title: "authorize_high_value_domain_continuation", kind: "enabling", owner: "PROGRAM", dependsOn: ["WBV2-P12-005"], parityId: null, implementationClass: "LOCAL_BOUNDED", parallelGroup: "p13-governance", gate: "G9", card: "docs/tasks/WBV2-P13-000.md", behavior: "Authorize high-value advanced domain continuation after P12 domain parity gate.", outputs: ["continuation root", "advanced domain plan", "scope limits"], acceptance: ["P12 evidence remains hash-bound", "existing advanced receipts are reusable", "one ledger task is active"], status: "done", ready: false, queueMutationAllowed: true },
|
|
{ id: "WBV2-P13-001", phase: "P13", title: "reconcile_advanced_domain_ledger", kind: "enabling", owner: "PARITY", dependsOn: ["WBV2-P13-000"], parityId: null, implementationClass: "LOCAL_BOUNDED", parallelGroup: "p13-ledger", gate: "G9", card: "docs/tasks/WBV2-P13-001.md", behavior: "Batch-index existing Geometry Nodes, Rig, Simulation, Render, Media, and Server receipts without repeated execution.", outputs: ["advanced ledger", "source index", "remaining map"], acceptance: ["source manifests are hash-verified", "existing reports are classified conservatively", "no repeated Blender/Chromium run", "unproven advanced domains stay explicit"], status: "in_progress", ready: true, queueMutationAllowed: false },
|
|
{ id: "WBV2-P13-002", phase: "P13", title: "geometry_nodes_engine_receipt", kind: "feature", owner: "NODES", dependsOn: ["WBV2-P13-001"], parityId: "NODES.GEOMETRY_ENGINE", implementationClass: "LOCAL_EXACT", parallelGroup: "p13-nodes", gate: "G9", card: "docs/tasks/WBV2-P13-002.md", behavior: "Bind Geometry Nodes graph read, stable graph hashes, unsupported node retention, and save/reopen to compiled WASM Main.", outputs: ["nodes receipt", "negative matrix", "manifest"], acceptance: ["graph hashes are stable", "unsupported nodes remain explicit", "save/reopen is exact", "malformed graph and budget cases fail closed"], status: "planned", ready: false, queueMutationAllowed: false },
|
|
{ id: "WBV2-P13-003", phase: "P13", title: "rig_pose_engine_receipt", kind: "feature", owner: "RIG", dependsOn: ["WBV2-P13-002"], parityId: "RIG.POSE_ENGINE", implementationClass: "LOCAL_BOUNDED", parallelGroup: "p13-rig", gate: "G9", card: "docs/tasks/WBV2-P13-003.md", behavior: "Bind armature pose, constraints, and bounded skin data to compiled WASM Main with exact reopen.", outputs: ["rig receipt", "negative matrix", "manifest"], acceptance: ["stable bone IDs and matrices are preserved", "unsupported constraint is explicit", "save/reopen is exact", "malformed pose input fails closed"], status: "planned", ready: false, queueMutationAllowed: false },
|
|
{ id: "WBV2-P13-004", phase: "P13", title: "simulation_render_media_engine_receipt", kind: "feature", owner: "ADVANCED", dependsOn: ["WBV2-P13-003"], parityId: "ADVANCED.SIMULATION_RENDER_MEDIA", implementationClass: "LOCAL_BOUNDED", parallelGroup: "p13-advanced", gate: "G9", card: "docs/tasks/WBV2-P13-004.md", behavior: "Bind existing Simulation cache identity, render routing, media recovery, and server job boundaries into one conservative engine ledger.", outputs: ["advanced receipt", "routing matrix", "manifest"], acceptance: ["existing exact reports are reused", "unsupported routes remain explicit", "hash and lifecycle states are bound", "no false local parity claim"], status: "planned", ready: false, queueMutationAllowed: false },
|
|
{ id: "WBV2-P13-005", phase: "P13", title: "recompute_high_value_domain_gate", kind: "enabling", owner: "RELEASE", dependsOn: ["WBV2-P13-004"], parityId: null, implementationClass: "LOCAL_BOUNDED", parallelGroup: "p13-release", gate: "G10", card: "docs/tasks/WBV2-P13-005.md", behavior: "Recompute high-value domain claims from the advanced ledger and engine receipts.", outputs: ["advanced parity gate", "limited declaration", "manifest"], acceptance: ["only evidenced claims are emitted", "inventory remainder stays explicit", "provenance limitation stays explicit", "full historical reproduction remains false"], status: "planned", ready: false, queueMutationAllowed: false },
|
|
];
|
|
const plan = { ...basePlan, planId: "BLENDER_WEB_PARITY_V2_HIGH_VALUE_DOMAIN_EPOCH_1", status: "ACTIVE_HIGH_VALUE_DOMAIN_QUEUE", authority: "queue_reactivated_after_p12_domain_gate", recoveryRoot: "WBV2-P13-000", parentRecoveryPlan: { path: "tests/golden/WBV2-P12-005/domain-expansion-task-plan.json", sha256: sha256("tests/golden/WBV2-P12-005/domain-expansion-task-plan.json") }, tasks: [...tasks, ...p13] };
|
|
fs.mkdirSync(absolute(outputRoot), { recursive: true });
|
|
fs.writeFileSync(absolute(planPath), `${JSON.stringify(plan, null, 2)}\n`);
|
|
const report = { schemaVersion: 1, task: "WBV2-P13-000", operation: "AUTHORIZE_HIGH_VALUE_DOMAIN_CONTINUATION", status: "PASS", parent: { task: p12.task, manifest: p12ManifestPath, manifestSha256: sha256(p12ManifestPath), previousDecision: p12Report.decision.status, fullHistoricalReproduction: false }, continuation: { root: "WBV2-P13-000", firstTask: "WBV2-P13-001", plannedTasks: 6, scope: ["ADVANCED_LEDGER", "GEOMETRY_NODES", "RIG_POSE", "SIMULATION", "RENDER", "MEDIA", "SERVER"], browser: "chromium", engineBoundPrerequisite: true }, policy: { historicalEvidencePreserved: true, authorizedRebaselineOnly: true, existingReceiptsReusable: true, noRepeatedExecution: true, fullHistoricalReproduction: false, inventoryRemainderExplicit: true }, nextTask: "WBV2-P13-001" };
|
|
fs.writeFileSync(absolute(reportPath), `${JSON.stringify(report, null, 2)}\n`);
|
|
fs.writeFileSync(absolute("docs/tasks/WBV2-P13-000.md"), `# WBV2-P13-000: high-value domain continuation root\n\n- task: WBV2-P13-000\n- parent: WBV2-P12-005\n- status: done\n- gap: workflow:authorize_high_value_domain_continuation\n- ownerFamily: PROGRAM\n- targetImplementationClass: LOCAL_BOUNDED\n\n## 目标\n\nAuthorize high-value Blender Web domain work after P12. P13 starts with a read-only evidence ledger so existing Geometry Nodes, Rig, Simulation, Render, Media, and Server receipts are reused before any new browser run.\n\n## 验收\n\n- \`node tools/web/generate-wbv2-high-value-root.mjs\`\n- \`node tools/web/check-execution-control-plane.mjs\`\n- \`node tools/web/check-v2-task-index.mjs\`\n\n## 交付与回滚\n\n- Reports: \`tests/golden/WBV2-P13-000/\`\n- Manifest: \`tests/golden/WBV2-P13-000/manifest.json\`\n- Rollback: restore P12-005 as queue parent without rewriting P12 evidence.\n`);
|
|
const ledgerCard = [
|
|
"# WBV2-P13-001: reconcile advanced domain ledger", "", "- task: WBV2-P13-001", "- parent: WBV2-P13-000", "- status: in_progress", "- gap: workflow:reconcile_advanced_domain_ledger", "- ownerFamily: PARITY", "- targetImplementationClass: LOCAL_BOUNDED", "", "## 目标", "", "Batch-index existing Geometry Nodes, Rig, Simulation, Render, Media, and Server receipts without repeated Blender or Chromium execution.", "", "## 输入与范围", "", "- Existing manifests: tests/golden/WBV2-P3-002/manifest.json through tests/golden/WBV2-P6-003/manifest.json", "- P12 gate: tests/golden/WBV2-P12-005/domain-parity-gate-report.json", "- Inventory: tests/golden/WBV2-P0-002/parity-map.json", "", "## 验收", "", "- node tools/web/generate-wbv2-advanced-ledger.mjs --write", "- node tools/web/check-wbv2-advanced-ledger.mjs", "- node tools/web/check-task-context.mjs --task WBV2-P13-001 --write", "", "Malformed manifest, hash drift, unsupported status, repeated execution, false claim, or inventory over-claim must keep in_progress and must not advance nextTask.", "", "## 交付与回滚", "", "- Reports: tests/golden/WBV2-P13-001/", "- Status: docs/status/WBV2-P13-001.md", "- Manifest: tests/golden/WBV2-P13-001/manifest.json", "- Rollback: restore P13-000 as queue parent.", "",
|
|
].join("\n");
|
|
fs.writeFileSync(absolute("docs/tasks/WBV2-P13-001.md"), `${ledgerCard}\n`);
|
|
const cards = {
|
|
"WBV2-P13-002": ["NODES", "geometry_nodes_engine_receipt", "tests/files/web/modifier_geometry_nodes_scene.blend", "tests/golden/WBV2-P4-002/nodes-report.json", "web/tests/e2e/wbv2-geometry-nodes-production.spec.ts", "node tools/web/generate-wbv2-geometry-nodes-receipt.mjs --write"],
|
|
"WBV2-P13-003": ["RIG", "rig_pose_engine_receipt", "tests/files/web/generated/WBV2-P3-003-RIG.POSE_SKIN.blend", "tests/golden/WBV2-P3-003/rig-report.json", "web/tests/e2e/wbv2-rig-pose-production.spec.ts", "node tools/web/generate-wbv2-rig-pose-receipt.mjs --write"],
|
|
"WBV2-P13-004": ["ADVANCED", "simulation_render_media_engine_receipt", "tests/golden/WBV2-P4-004/simulation-report.json", "tests/golden/WBV2-P5-003/server-job-report.json", "web/tests/e2e/wbv2-advanced-domain-production.spec.ts", "node tools/web/generate-wbv2-advanced-domain-receipt.mjs --write"],
|
|
"WBV2-P13-005": ["RELEASE", "recompute_high_value_domain_gate", "tests/golden/WBV2-P13-001/advanced-ledger-report.json", "tests/golden/WBV2-P12-005/domain-parity-gate-report.json", "node tools/web/generate-wbv2-high-value-domain-gate.mjs --write", "node tools/web/generate-wbv2-high-value-domain-gate.mjs --write"],
|
|
};
|
|
for (const [id, [owner, gap, input, source, test, generator]] of Object.entries(cards)) {
|
|
const parentId = id === "WBV2-P13-002" ? "WBV2-P13-001" : id === "WBV2-P13-003" ? "WBV2-P13-002" : id === "WBV2-P13-004" ? "WBV2-P13-003" : "WBV2-P13-004";
|
|
fs.writeFileSync(absolute(`docs/tasks/${id}.md`), `# ${id}: ${gap}\n\n- task: ${id}\n- parent: ${parentId}\n- status: planned\n- gap: workflow:${gap}\n- ownerFamily: ${owner}\n- targetImplementationClass: LOCAL_BOUNDED\n\n## 目标\n\nExecute the bounded ${owner} domain using existing source evidence and the compiled WebEngine runtime.\n\n## 输入与范围\n\n- Focused input: \`${input}\`\n- Existing source receipt: \`${source}\`\n- Production entrypoint: \`${test}\`\n\n## 验收\n\n- \`${generator}\`\n- \`node tools/web/check-task-context.mjs --task ${id} --write\`\n\nMalformed or unsupported input, hash drift, non-Chromium execution, non-exact save/reopen, false inventory completion, or missing Main mutation must keep in_progress and must not advance nextTask.\n\n## 交付与回滚\n\n- Reports: \`tests/golden/${id}/\`\n- Status: \`docs/status/${id}.md\`\n- Manifest: \`tests/golden/${id}/manifest.json\`\n- Rollback: restore ${parentId} as queue parent.\n`);
|
|
}
|
|
fs.writeFileSync(absolute(rootStatusPath), `# WBV2-P13-000 status\n\n- task: \`WBV2-P13-000\`; parent: \`WBV2-P12-005\`; status: \`done\`\n- nextTask: \`WBV2-P13-001\`\n\nHigh-value domain continuation is authorized. P13 starts with a read-only ledger to eliminate repeated validation, then expands only domains with real source receipts and compiled WASM entrypoints.\n`);
|
|
p12.nextTask = "WBV2-P13-000";
|
|
p12.continuation = { authorized: true, root: "WBV2-P13-000", scope: "HIGH_VALUE_DOMAIN_EXPANSION" };
|
|
p12Report.nextTask = "WBV2-P13-000";
|
|
p12Report.policy = { ...(p12Report.policy ?? {}), terminalQueuePointer: false, authorizedContinuation: "WBV2-P13-000" };
|
|
fs.writeFileSync(absolute(p12ReportPath), `${JSON.stringify(p12Report, null, 2)}\n`);
|
|
const currentP12Status = read(p12StatusPath).trim();
|
|
fs.writeFileSync(absolute(p12StatusPath), currentP12Status.includes("authorized continuation: `WBV2-P13-000`") ? `${currentP12Status}\n` : `${currentP12Status}\n- authorized continuation: \`WBV2-P13-000\`\n\nHigh-value domain work may continue under a new manifest root without changing the P12 evidence classification.\n`);
|
|
fs.writeFileSync(absolute(p12ManifestPath), `${JSON.stringify(p12, null, 2)}\n`);
|
|
execFileSync(process.execPath, [absolute("tools/web/check-task-context.mjs"), "--task", "WBV2-P12-005", "--write"], { cwd: root, stdio: "pipe" });
|
|
p12.artifacts = Object.fromEntries(Object.entries(p12.artifacts).map(([name, artifact]) => [name, { ...artifact, sha256: sha256(artifact.path) }]));
|
|
fs.writeFileSync(absolute(p12ManifestPath), `${JSON.stringify(p12, null, 2)}\n`);
|
|
const artifactPaths = { parentManifest: p12ManifestPath, parentReport: p12ReportPath, approval: "docs/status/M12-PROVENANCE-EPOCH-2-APPROVAL.json", plan: planPath, report: reportPath, rootCard: "docs/tasks/WBV2-P13-000.md", rootStatus: rootStatusPath, activeCard: "docs/tasks/WBV2-P13-001.md" };
|
|
const artifacts = Object.fromEntries(Object.entries(artifactPaths).map(([name, file]) => [name, { path: file, sha256: sha256(file) }]));
|
|
const manifest = { schemaVersion: 1, task: "WBV2-P13-000", parentTask: "WBV2-P12-005", operation: "AUTHORIZE_HIGH_VALUE_DOMAIN_CONTINUATION", status: "done", enablingTask: true, parityStateChange: false, artifacts, assertions: { p12EvidencePreserved: true, readOnlyLedgerFirst: true, noRepeatedExecution: true, authorizedRebaselineOnly: true, fullHistoricalReproduction: false, domainScope: ["ADVANCED_LEDGER", "GEOMETRY_NODES", "RIG_POSE", "SIMULATION", "RENDER", "MEDIA", "SERVER"] }, nextTask: "WBV2-P13-001" };
|
|
fs.writeFileSync(absolute(manifestPath), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
execFileSync(process.execPath, [absolute("tools/web/generate-v2-task-index.mjs"), "--plan-path", absolute(planPath)], { cwd: root, stdio: "inherit" });
|
|
let queue = read("docs/EXECUTION_QUEUE.md");
|
|
queue = queue.replace(/\| 当前任务 \| `[^`]+` \|/u, "| 当前任务 | `WBV2-P13-001` |")
|
|
.replace(/\| parent manifest \| `[^`]+` \|/u, "| parent manifest | `tests/golden/WBV2-P13-000/manifest.json` |")
|
|
.replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u, "| 任务卡 | [`tasks/WBV2-P13-001.md`](tasks/WBV2-P13-001.md) |");
|
|
fs.writeFileSync(absolute("docs/EXECUTION_QUEUE.md"), queue);
|
|
let nextTaskFile = read("nextTask.md");
|
|
nextTaskFile = nextTaskFile.replace(/\| Current task when this file was written \| `[^`]+` \|/u, "| Current task when this file was written | `WBV2-P13-001` |")
|
|
.replace(/\| Current task state \| `[^`]+` \|/u, "| Current task state | `in_progress` |")
|
|
.replace(/\| Parent manifest \| `[^`]+` \|/u, "| Parent manifest | `tests/golden/WBV2-P13-000/manifest.json` |")
|
|
.replace(/\| Current task card \| `[^`]+` \|/u, "| Current task card | `docs/tasks/WBV2-P13-001.md` |")
|
|
.replace(/\| Current task-context nextTask \| `[^`]+` \|/u, "| Current task-context nextTask | `WBV2-P13-002` |")
|
|
.replace(/\| Focused command \| `[^`]+` \|/u, "| Focused command | `node tools/web/generate-wbv2-advanced-ledger.mjs --write` |");
|
|
fs.writeFileSync(absolute("nextTask.md"), nextTaskFile);
|
|
process.stdout.write("wbv2-high-value-root-ok root=WBV2-P13-000 next=WBV2-P13-001 scope=ADVANCED_LEDGER,GEOMETRY_NODES,RIG_POSE,SIMULATION,RENDER,MEDIA,SERVER\n");
|