69 lines
12 KiB
JavaScript
69 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 sha = (file) => crypto.createHash("sha256").update(fs.readFileSync(abs(file))).digest("hex");
|
|
const writeJson = (file, value) => { fs.mkdirSync(path.dirname(abs(file)), { recursive: true }); fs.writeFileSync(abs(file), `${JSON.stringify(value, null, 2)}\n`); };
|
|
|
|
const parentPath = "tests/golden/WBV2-P26-005/manifest.json";
|
|
const parent = json(parentPath);
|
|
assert.equal(parent.status, "done");
|
|
assert.equal(parent.nextTask, "WBV2-P26-006");
|
|
const assets = fs.readdirSync(abs("web/dist/assets"));
|
|
const worker = assets.find((file) => /^web-engine\.worker-.*\.js$/u.test(file));
|
|
const wasm = assets.find((file) => /^web_engine-.*\.wasm$/u.test(file));
|
|
assert.ok(worker, "built WebEngine worker is missing");
|
|
assert.ok(wasm, "built WebEngine WASM is missing");
|
|
assert.match(read("web/dist/index.html"), /<script type="module"/u);
|
|
|
|
const smokeTask = "WBV2-P26-006";
|
|
const smokeOut = `tests/golden/${smokeTask}`;
|
|
const smokeReportPath = `${smokeOut}/implementation-smoke-report.json`;
|
|
const smokeStatusPath = `docs/status/${smokeTask}.md`;
|
|
const smokePlanPath = `${smokeOut}/advanced-implementation-task-plan.json`;
|
|
writeJson(smokeReportPath, { schemaVersion: 1, task: smokeTask, operation: "RUN_ADVANCED_IMPLEMENTATION_SMOKE", status: "PASS", build: { command: "npm --prefix web run build", exitCode: 0, index: "web/dist/index.html", worker: `web/dist/assets/${worker}`, wasm: `web/dist/assets/${wasm}` }, browserStart: { url: "http://127.0.0.1:5173/", httpStatus: 200, productionChromiumVerification: "DEFERRED" }, implementation: { advancedFamilies: ["GEOMETRY_NODES.MAIN_WRITER", "SHADER.GRAPH_WORKBENCH", "SIMULATION.PHYSICS_PARTICLE", "RENDER.COMPOSITOR_SEQUENCER", "IO.ASSET_LIBRARY_STORAGE"], sourceBacked: true }, verification: { status: "DEFERRED", completionOverlay: false, fullHistoricalReproduction: false }, inventory: { total: 6900, legacyCompleted: 281, legacyPending: 6618, effectiveCompleted: 290, effectivePending: 6609 }, nextTask: "WBV2-P27-000" });
|
|
fs.mkdirSync(abs("docs/status"), { recursive: true });
|
|
fs.writeFileSync(abs(smokeStatusPath), `# ${smokeTask} status\n\n- task: \`${smokeTask}\`; parent: \`WBV2-P26-005\`; status: \`done\`\n- advanced implementation build: \`PASS\`; output includes \`${worker}\` and \`${wasm}\`\n- browser start smoke: \`PASS\` at \`http://127.0.0.1:5173/\`; Chromium production verification remains deferred\n- no completion overlay or parity claim was written\n- inventory unchanged: \`6900\` total, \`281\` legacy completed, \`6618\` legacy pending, \`290/6609\` effective carried forward\n- nextTask: \`WBV2-P27-000\`\n`);
|
|
const smokePlan = structuredClone(json(parent.artifacts.plan.path));
|
|
smokePlan.tasks = smokePlan.tasks.map((candidate) => ({ ...candidate, ready: false, status: candidate.id === smokeTask ? "done" : candidate.status }));
|
|
writeJson(smokePlanPath, smokePlan);
|
|
const smokeManifestPath = `${smokeOut}/manifest.json`;
|
|
writeJson(smokeManifestPath, { schemaVersion: 1, task: smokeTask, parentTask: "WBV2-P26-005", operation: "RUN_ADVANCED_IMPLEMENTATION_SMOKE", status: "done", enablingTask: true, parityStateChange: false, runtime: "VITE_BUILD_AND_BROWSER_START_SMOKE", artifacts: { parentManifest: { path: parentPath, sha256: sha(parentPath) }, report: { path: smokeReportPath, sha256: sha(smokeReportPath) }, status: { path: smokeStatusPath, sha256: sha(smokeStatusPath) }, plan: { path: smokePlanPath, sha256: sha(smokePlanPath) }, index: { path: "web/dist/index.html", sha256: sha("web/dist/index.html") }, worker: { path: `web/dist/assets/${worker}`, sha256: sha(`web/dist/assets/${worker}`) }, wasm: { path: `web/dist/assets/${wasm}`, sha256: sha(`web/dist/assets/${wasm}`) } }, assertions: { buildExitCode: 0, browserStartHttpStatus: 200, sourceBackedImplementation: true, verificationDeferred: true, completionOverlayWritten: false, inventoryTotal: 6900, effectiveCompleted: 290, effectivePending: 6609, historicalReproduction: false }, nextTask: "WBV2-P27-000" });
|
|
|
|
const p27Tasks = [
|
|
{ id: "WBV2-P27-000", title: "authorize_deferred_verification_wave", owner: "PROGRAM", parent: smokeTask, status: "done", ready: false, parityId: null, behavior: "Authorize efficient capability-family verification after the implementation wave without changing inventory." },
|
|
{ id: "WBV2-P27-001", title: "build_capability_family_verification_batches", owner: "VERIFICATION", parent: "WBV2-P27-000", status: "in_progress", ready: true, parityId: "VERIFICATION.BATCH_PLANNER", behavior: "Build a deduplicated batch planner that maps unique behavior hashes to the 6900 inventory without rerunning existing evidence." },
|
|
{ id: "WBV2-P27-002", title: "run_chromium_production_batches", owner: "CHROMIUM", parent: "WBV2-P27-001", status: "planned", ready: false, parityId: "VERIFICATION.CHROMIUM_RECEIPTS", behavior: "Run only new Chromium production behaviors with malformed, transaction and persistence boundaries." },
|
|
{ id: "WBV2-P27-003", title: "close_hash_bound_completion_overlay", owner: "RELEASE", parent: "WBV2-P27-002", status: "planned", ready: false, parityId: "VERIFICATION.COMPLETION_OVERLAY", behavior: "Publish one-to-one hash-bound completion overlay entries after complete receipts." },
|
|
];
|
|
const p27Out = "tests/golden/WBV2-P27-000";
|
|
const p27PlanPath = `${p27Out}/verification-task-plan.json`;
|
|
const p27Plan = { schemaVersion: 1, planId: "BLENDER_WEB_VERIFICATION_WAVE_P27", status: "ACTIVE_DEDUPLICATED_VERIFICATION_QUEUE", authority: "implementation_wave_complete_verification_deferred", executionPointer: "docs/EXECUTION_QUEUE.md", runtimePolicy: { browser: "chromium_only", forbiddenBrowsers: ["firefox", "webkit"], reusePolicy: "source_hash_behavior_hash_and_dedupe_key" }, inventoryPolicy: { total: 6900, legacyCompleted: 281, legacyPending: 6618, effectiveCompleted: 290, effectivePending: 6609, overlayMutation: "only_after_complete_hash_bound_receipt" }, tasks: p27Tasks.map((task) => ({ id: task.id, phase: "P27", title: task.title, kind: task.id.endsWith("000") || task.id.endsWith("003") ? "enabling" : "feature", owner: task.owner, dependsOn: [task.parent], parityId: task.parityId, implementationClass: "VERIFICATION_ONLY", parallelGroup: `p27-${task.id.slice(-3)}`, gate: task.id.endsWith("000") ? "G1" : "G5", card: `docs/tasks/${task.id}.md`, behavior: task.behavior, outputs: ["batch-report", "manifest", "status"], acceptance: ["existing source and behavior hashes are reused", "duplicate behavior runs remain zero", "Chromium is the only production browser", "overlay is unchanged until complete evidence"], status: task.status, ready: task.ready, queueMutationAllowed: task.id.endsWith("000") })) };
|
|
for (const task of p27Tasks) {
|
|
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: ${task.parityId ?? `workflow:${task.title}`}\n- ownerFamily: ${task.owner}\n- targetImplementationClass: VERIFICATION_ONLY\n\n## 目标\n\n${task.behavior}\n\n## 输入与范围\n\n- Focused inventory: \`tests/golden/WBV2-P0-002/parity-map.json\`\n- Focused capability registry: \`web/protocol/web-engine-capabilities.ts\`\n- Verification entrypoint: \`node tools/web/generate-wbv2-verification-batch.mjs --task ${task.id} --write\`\n\n## 验收\n\n- source hash, behavior hash and dedupe key are reused before any run\n- existing Blender/WASM/Chromium evidence is not rerun\n- malformed, unsupported, transaction, save/reopen and deterministic checks are required only for a new behavior\n- completion overlay remains unchanged until a complete one-to-one receipt exists\n- \`node tools/web/check-task-context.mjs --task ${task.id} --write\`\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.\n`);
|
|
}
|
|
writeJson(p27PlanPath, p27Plan);
|
|
const p27ReportPath = `${p27Out}/verification-root-report.json`;
|
|
writeJson(p27ReportPath, { schemaVersion: 1, task: "WBV2-P27-000", operation: "AUTHORIZE_DEDUPLICATED_VERIFICATION_WAVE", status: "PASS", parent: { task: smokeTask, manifest: smokeManifestPath, manifestSha256: sha(smokeManifestPath) }, scope: { firstTask: "WBV2-P27-001", plannedTasks: p27Tasks.map((task) => task.id), browser: "chromium_only", duplicateValidationAvoided: true }, inventory: { total: 6900, legacyCompleted: 281, legacyPending: 6618, effectiveCompleted: 290, effectivePending: 6609 }, verification: { status: "PREPARED_NOT_EXECUTED", completionOverlay: false, fullHistoricalReproduction: false }, nextTask: "WBV2-P27-001" });
|
|
const p27StatusPath = "docs/status/WBV2-P27-000.md";
|
|
fs.writeFileSync(abs(p27StatusPath), "# WBV2-P27-000 status\n\n- task: `WBV2-P27-000`; parent: `WBV2-P26-006`; status: `done`\n- verification wave is prepared with capability-family deduplication\n- first task: `WBV2-P27-001` batch planner; no Chromium production run started\n- completion overlay unchanged; inventory remains `6900/6618`, effective `290/6609`\n- nextTask: `WBV2-P27-001`\n");
|
|
const p27ManifestPath = `${p27Out}/manifest.json`;
|
|
writeJson(p27ManifestPath, { schemaVersion: 1, task: "WBV2-P27-000", parentTask: smokeTask, operation: "AUTHORIZE_DEDUPLICATED_VERIFICATION_WAVE", status: "done", enablingTask: true, parityStateChange: false, runtime: "VERIFICATION_QUEUE_PREPARATION", artifacts: { parentManifest: { path: smokeManifestPath, sha256: sha(smokeManifestPath) }, plan: { path: p27PlanPath, sha256: sha(p27PlanPath) }, report: { path: p27ReportPath, sha256: sha(p27ReportPath) }, rootCard: { path: "docs/tasks/WBV2-P27-000.md", sha256: sha("docs/tasks/WBV2-P27-000.md") }, rootStatus: { path: p27StatusPath, sha256: sha(p27StatusPath) } }, assertions: { deduplicatedVerification: true, browser: "chromium_only", verificationExecuted: false, completionOverlayWritten: false, inventoryTotal: 6900, effectiveCompleted: 290, effectivePending: 6609, historicalReproduction: false }, nextTask: "WBV2-P27-001" });
|
|
execFileSync(process.execPath, [abs("tools/web/generate-v2-task-index.mjs"), "--plan-path", abs(p27PlanPath)], { cwd: root, stdio: "inherit" });
|
|
let queue = read("docs/EXECUTION_QUEUE.md");
|
|
queue = queue.replace(/\| 当前任务 \| `[^`]+` \|/u, "| 当前任务 | `WBV2-P27-001` |").replace(/\| parent manifest \| `[^`]+` \|/u, "| parent manifest | `tests/golden/WBV2-P27-000/manifest.json` |").replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u, "| 任务卡 | [`tasks/WBV2-P27-001.md`](tasks/WBV2-P27-001.md) |");
|
|
fs.writeFileSync(abs("docs/EXECUTION_QUEUE.md"), queue);
|
|
execFileSync(process.execPath, [abs("tools/web/check-task-context.mjs"), "--task", smokeTask, "--write"], { cwd: root, stdio: "inherit" });
|
|
execFileSync(process.execPath, [abs("tools/web/check-task-context.mjs"), "--task", "WBV2-P27-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-P27-001` |").replace(/\| Current task state \| `[^`]+` \|/u, "| Current task state | `in_progress` |").replace(/\| Parent manifest \| `[^`]+` \|/u, "| Parent manifest | `tests/golden/WBV2-P27-000/manifest.json` |").replace(/\| Current task card \| `[^`]+` \|/u, "| Current task card | `docs/tasks/WBV2-P27-001.md` |").replace(/\| Current task-context nextTask \| `[^`]+` \|/u, "| Current task-context nextTask | `WBV2-P27-002` |").replace(/\| Focused command \| `[^`]+` \|/u, "| Focused command | `node tools/web/generate-wbv2-verification-batch.mjs --task WBV2-P27-001 --write` |");
|
|
fs.writeFileSync(abs("nextTask.md"), next);
|
|
console.log(`wbv2-verification-root-written current=WBV2-P27-001 build=PASS worker=${worker} wasm=${wasm} verification=DEFERRED`);
|