60 lines
8.4 KiB
JavaScript
60 lines
8.4 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 sha = (file) => crypto.createHash("sha256").update(fs.readFileSync(abs(file))).digest("hex");
|
|
const parentPath = "tests/golden/WBV2-P30-004/manifest.json";
|
|
const parent = JSON.parse(read(parentPath));
|
|
assert.equal(parent.status, "done");
|
|
assert.equal(parent.nextTask, "WBV2-P31-000");
|
|
const tasks = [
|
|
{ id: "WBV2-P31-000", title: "authorize_resource_scene_workbench", owner: "PROGRAM", parent: "WBV2-P30-004", status: "done", ready: false, kind: "enabling", behavior: "Authorize the next source-backed resource and scene-data implementation wave." },
|
|
{ id: "WBV2-P31-001", title: "implement_resource_workbench", owner: "IO", parent: "WBV2-P31-000", status: "in_progress", ready: true, kind: "feature", family: "IO.RESOURCE_WORKBENCH", behavior: "Expose packed VFonts, sounds, speakers, text blocks, textures and particle settings through a bounded resource workbench." },
|
|
{ id: "WBV2-P31-002", title: "implement_text_datablock_authoring", owner: "IO", parent: "WBV2-P31-001", status: "planned", ready: false, kind: "feature", family: "IO.TEXT_DATABLOCK", behavior: "Connect a typed text-source command to Blender Main Text datablocks with bounded persistence." },
|
|
{ id: "WBV2-P31-003", title: "run_p31_implementation_smoke", owner: "RELEASE", parent: "WBV2-P31-002", status: "planned", ready: false, kind: "enabling", behavior: "Run the bounded production build smoke after P31 resource implementation." },
|
|
];
|
|
const out = "tests/golden/WBV2-P31-000";
|
|
const planPath = `${out}/resource-scene-task-plan.json`;
|
|
const records = tasks.map((task) => ({
|
|
...task,
|
|
dependsOn: [task.parent],
|
|
phase: "P31",
|
|
parityId: null,
|
|
implementationClass: "SOURCE_BACKED",
|
|
parallelGroup: `p31-${task.id.slice(-3)}`,
|
|
gate: task.kind === "enabling" ? "G1" : "IMPLEMENTATION",
|
|
card: `docs/tasks/${task.id}.md`,
|
|
outputs: ["implementation-report", "manifest", "status"],
|
|
acceptance: ["real source or WebEngine Main path is wired", "unsupported input fails closed", "implementation smoke is reproducible", "verification remains deferred"],
|
|
queueMutationAllowed: task.kind === "enabling",
|
|
}));
|
|
fs.mkdirSync(abs(out), { recursive: true });
|
|
fs.writeFileSync(abs(planPath), `${JSON.stringify({ schemaVersion: 1, planId: "BLENDER_WEB_RESOURCE_SCENE_IMPLEMENTATION_P31", status: "ACTIVE_RESOURCE_SCENE_QUEUE", authority: "user_authorized_implementation_first_execution", executionPointer: "docs/EXECUTION_QUEUE.md", runtimePolicy: { blenderSource: "blender-5.2.0", mainAuthority: "blender_main", browserPolicy: "chromium_only_for_later_verification", verificationPolicy: "deferred", reusePolicy: "source_hash_behavior_hash_and_dedupe_key" }, inventoryPolicy: { total: 6900, legacyCompleted: 281, legacyPending: 6618, effectiveCompleted: 290, effectivePending: 6609, overlayMutation: "forbidden_during_implementation_wave" }, tasks: records }, null, 2)}\n`);
|
|
for (const task of tasks) {
|
|
const gap = task.family ?? `workflow:${task.title}`;
|
|
const entrypoint = task.id === "WBV2-P31-001" ? "node tools/web/generate-wbv2-resource-scene-slice.mjs --task WBV2-P31-001 --write" : task.id === "WBV2-P31-002" ? "node tools/web/generate-wbv2-resource-scene-slice.mjs --task WBV2-P31-002 --write" : "node tools/web/generate-wbv2-resource-scene-root.mjs";
|
|
fs.writeFileSync(abs(`docs/tasks/${task.id}.md`), `# ${task.id}: ${task.title}\n\n- task: ${task.id}\n- parent: ${task.parent}\n- status: ${task.status}\n- gap: ${gap}\n- ownerFamily: ${task.owner}\n- targetImplementationClass: SOURCE_BACKED\n\n## 目标\n\n${task.behavior}\n\n## 输入与范围\n\n- Focused protocol: \`web/protocol/web-engine.ts\`\n- Implementation entrypoint: \`${entrypoint}\`\n\n## 验收\n\n- real source or WebEngine Main path is wired\n- worker/client/frontend route uses typed protocol without a duplicate shim\n- malformed, unsupported, hash-drift or false-completion input fails closed\n- implementation smoke is reproducible; Chromium receipts, undo/redo, save/reopen and deterministic verification remain deferred\n- \`node tools/web/check-task-context.mjs --task ${task.id} --write\`\n\n## 失败边界\n\n- malformed and unsupported resource payloads fail closed with a typed diagnostic\n- implementation evidence never changes the historical inventory or provenance epoch\n\n## 交付与回滚\n\n- Reports: \`tests/golden/${task.id}/\`\n- Status: \`docs/status/${task.id}.md\`\n- Manifest: \`tests/golden/${task.id}/manifest.json\`\n- Rollback: restore ${task.parent} as queue parent and leave the task in_progress.\n`);
|
|
}
|
|
const reportPath = `${out}/resource-scene-root-report.json`;
|
|
const statusPath = "docs/status/WBV2-P31-000.md";
|
|
fs.writeFileSync(abs(reportPath), `${JSON.stringify({ schemaVersion: 1, task: "WBV2-P31-000", operation: "AUTHORIZE_RESOURCE_SCENE_WORKBENCH", status: "PASS", parent: { task: parent.task, manifest: parentPath, manifestSha256: sha(parentPath) }, scope: { firstTask: "WBV2-P31-001", plannedTasks: tasks.map((task) => task.id) }, verification: { status: "DEFERRED", chromium: false, completionOverlay: false }, inventory: { total: 6900, legacyCompleted: 281, legacyPending: 6618, effectiveCompleted: 290, effectivePending: 6609 }, nextTask: "WBV2-P31-001" }, null, 2)}\n`);
|
|
fs.writeFileSync(abs(statusPath), "# WBV2-P31-000 status\n\n- task: `WBV2-P31-000`; parent: `WBV2-P30-004`; status: `done`\n- resource and scene-data implementation wave authorized\n- verification receipts and completion overlays: `DEFERRED`\n- inventory unchanged: `6900` total, `281` legacy completed, `6618` legacy pending, `290/6609` effective carried forward\n- nextTask: `WBV2-P31-001`\n");
|
|
const manifestPath = `${out}/manifest.json`;
|
|
fs.writeFileSync(abs(manifestPath), `${JSON.stringify({ schemaVersion: 1, task: "WBV2-P31-000", parentTask: "WBV2-P30-004", operation: "AUTHORIZE_RESOURCE_SCENE_WORKBENCH", status: "done", enablingTask: true, parityStateChange: false, runtime: "SOURCE_BACKED_RESOURCE_SCENE_QUEUE", artifacts: { parentManifest: { path: parentPath, sha256: sha(parentPath) }, plan: { path: planPath, sha256: sha(planPath) }, report: { path: reportPath, sha256: sha(reportPath) }, status: { path: statusPath, sha256: sha(statusPath) } }, assertions: { plannedTasks: tasks.length, verificationDeferred: true, completionOverlayWritten: false, inventoryTotal: 6900, effectiveCompleted: 290, effectivePending: 6609, historicalReproduction: false }, nextTask: "WBV2-P31-001" }, null, 2)}\n`);
|
|
execFileSync(process.execPath, [abs("tools/web/generate-v2-task-index.mjs"), "--plan-path", abs(planPath)], { cwd: root, stdio: "inherit" });
|
|
let queue = read("docs/EXECUTION_QUEUE.md");
|
|
queue = queue.replace(/\| 当前任务 \| `[^`]+` \|/u, "| 当前任务 | `WBV2-P31-001` |").replace(/\| parent manifest \| `[^`]+` \|/u, "| parent manifest | `tests/golden/WBV2-P31-000/manifest.json` |").replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u, "| 任务卡 | [`tasks/WBV2-P31-001.md`](tasks/WBV2-P31-001.md) |");
|
|
fs.writeFileSync(abs("docs/EXECUTION_QUEUE.md"), queue);
|
|
execFileSync(process.execPath, [abs("tools/web/check-task-context.mjs"), "--task", "WBV2-P31-000", "--write"], { cwd: root, stdio: "inherit" });
|
|
execFileSync(process.execPath, [abs("tools/web/check-task-context.mjs"), "--task", "WBV2-P31-001", "--write"], { cwd: root, stdio: "inherit" });
|
|
let next = read("nextTask.md");
|
|
next = next.replace(/\| Current task when this file was written \| `[^`]+` \|/u, "| Current task when this file was written | `WBV2-P31-001` |").replace(/\| Current task state \| `[^`]+` \|/u, "| Current task state | `in_progress` |").replace(/\| Parent manifest \| `[^`]+` \|/u, "| Parent manifest | `tests/golden/WBV2-P31-000/manifest.json` |").replace(/\| Current task card \| `[^`]+` \|/u, "| Current task card | `docs/tasks/WBV2-P31-001.md` |").replace(/\| Current task-context nextTask \| `[^`]+` \|/u, "| Current task-context nextTask | `WBV2-P31-002` |").replace(/\| Focused command \| `[^`]+` \|/u, "| Focused command | `node tools/web/generate-wbv2-resource-scene-slice.mjs --task WBV2-P31-001 --write` |");
|
|
fs.writeFileSync(abs("nextTask.md"), next);
|
|
console.log("wbv2-p31-root-written current=WBV2-P31-001 verification=DEFERRED inventory=6900 effectivePending=6609");
|