44 lines
9.7 KiB
JavaScript
44 lines
9.7 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 write = process.argv.includes("--write");
|
|
const absolute = (file) => path.join(root, file);
|
|
const read = (file) => fs.readFileSync(absolute(file), "utf8");
|
|
const json = (file) => JSON.parse(read(file));
|
|
const sha256 = (file) => crypto.createHash("sha256").update(fs.readFileSync(absolute(file))).digest("hex");
|
|
const outputRoot = "tests/golden/WBV2-P13-004";
|
|
const reportPath = `${outputRoot}/advanced-domain-receipt-report.json`;
|
|
const statusPath = "docs/status/WBV2-P13-004.md";
|
|
const planPath = `${outputRoot}/high-value-task-plan.json`;
|
|
const manifestPath = `${outputRoot}/manifest.json`;
|
|
const parentPath = "tests/golden/WBV2-P13-003/manifest.json";
|
|
const ledgerPath = "tests/golden/WBV2-P13-001/advanced-ledger-report.json";
|
|
const sources = [
|
|
{ domain: "SIMULATION", task: "WBV2-P4-004", manifest: "tests/golden/WBV2-P4-004/manifest.json", report: "tests/golden/WBV2-P4-004/simulation-report.json", proof: "cache identity, cancellation, LRU, restart, exact reopen", expected: "EXACT_RECORDED" },
|
|
{ domain: "RENDER", task: "WBV2-P5-001", manifest: "tests/golden/WBV2-P5-001/manifest.json", report: "tests/golden/WBV2-P5-001/render-report.json", proof: "bounded Eevee route READY; unsupported routes BLOCKED; pixel mismatch explicit", expected: "EXACT_RECORDED" },
|
|
{ domain: "MEDIA", task: "WBV2-P5-002", manifest: "tests/golden/WBV2-P5-002/manifest.json", report: "tests/golden/WBV2-P5-002/media-report.json", proof: "compositor/sequencer available; codec and budget boundaries explicit", expected: "EXACT_RECORDED" },
|
|
{ domain: "SERVER", task: "WBV2-P5-003", manifest: "tests/golden/WBV2-P5-003/manifest.json", report: "tests/golden/WBV2-P5-003/server-job-report.json", proof: "idempotency, conflict, hash and cancel/timeout/oom boundaries", expected: "EXACT_RECORDED" },
|
|
{ domain: "SECURITY", task: "WBV2-P6-001", manifest: "tests/golden/WBV2-P6-001/manifest.json", report: "tests/golden/WBV2-P6-001/scripting-report.json", proof: "default deny, audit, sandbox and filesystem/network boundaries", expected: "EXACT_RECORDED" },
|
|
{ domain: "RELIABILITY", task: "WBV2-P6-002", manifest: "tests/golden/WBV2-P6-002/manifest.json", report: "tests/golden/WBV2-P6-002/performance-report.json", proof: "budget thresholds, fault recovery, quarantine and resource release", expected: "EXACT_RECORDED" },
|
|
{ domain: "RELEASE", task: "WBV2-P6-003", manifest: "tests/golden/WBV2-P6-003/manifest.json", report: "tests/golden/WBV2-P6-003/release-report.json", proof: "offline/source/binary package, CI, SBOM and rollback", expected: "EXACT_RECORDED" },
|
|
];
|
|
const parent = json(parentPath); assert.equal(parent.status, "done"); assert.equal(parent.nextTask, "WBV2-P13-004"); for (const artifact of Object.values(parent.artifacts ?? {})) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
|
const ledger = json(ledgerPath); assert.equal(ledger.status, "PASS"); assert.equal(ledger.reuse.repeatedBlenderRuns, 0); assert.equal(ledger.reuse.repeatedChromiumRuns, 0);
|
|
const entries = sources.map((source) => { const manifest = json(source.manifest); const report = json(source.report); assert.equal(manifest.status, "done", source.task); assert.equal(report.desktop.status, "EXACT", source.task); assert.equal(report.wasm.status, "EXACT", source.task); const bound = Object.values(manifest.artifacts ?? {}).find((artifact) => artifact.path === source.report); assert.ok(bound, `${source.task} report not bound`); assert.equal(bound.sha256, sha256(source.report)); return { domain: source.domain, task: source.task, manifest: source.manifest, manifestSha256: sha256(source.manifest), report: source.report, reportSha256: sha256(source.report), proof: source.proof, evidenceClass: source.expected, browser: "chromium", repeatedExecution: false, saveReopen: report.saveReopen ?? report.wasm.saveReopen ?? "EXACT", negativeBoundaryCount: Object.keys(report.negative ?? {}).length, lifecycle: { recovery: report.recovery ?? null, unsupported: report.negative ?? null } }; });
|
|
const receipt = { schemaVersion: 1, task: "WBV2-P13-004", operation: "ADVANCED_DOMAIN_ENGINE_RECEIPT", status: "PASS", browser: "chromium", queueMutation: false, policy: { existingReceiptsReused: true, repeatedBlenderRuns: 0, repeatedChromiumRuns: 0, noFalseLocalParity: true, blockedRoutesExplicit: true, historicalReproduction: false }, sourceLedger: { path: ledgerPath, sha256: sha256(ledgerPath), sourceManifests: ledger.summary.manifestsDone, artifactRecords: ledger.summary.artifactRecords }, domains: entries, summary: { domains: entries.length, exactReports: entries.length, repeatedRuns: 0, unsupportedRoutesExplicit: true, inventoryRemaining: ledger.inventory.pending, inventoryClaimedComplete: 0 }, nextTask: "WBV2-P13-005" };
|
|
if (!write) { process.stdout.write(`wbv2-advanced-domain-receipt-ok task=WBV2-P13-004 domains=${entries.length} repeatedRuns=0 exactReports=${entries.length} inventoryRemaining=${ledger.inventory.pending} next=WBV2-P13-005\n`); process.exit(0); }
|
|
fs.mkdirSync(absolute(outputRoot), { recursive: true }); fs.writeFileSync(absolute(reportPath), `${JSON.stringify(receipt, null, 2)}\n`);
|
|
fs.writeFileSync(absolute(statusPath), `# WBV2-P13-004 status\n\n- task: \`WBV2-P13-004\`; parent: \`WBV2-P13-003\`; status: \`done\`\n- domains batch-reused: \`7\`; exact source reports: \`7/7\`\n- repeated Blender/Chromium runs: \`0\`; blocked routes/lifecycle negatives retained\n- inventory remaining: \`${ledger.inventory.pending}\`; claimed complete: \`0\`\n- nextTask: \`WBV2-P13-005\`\n\nSimulation, Render, Media, Server, Security, Reliability, and Release evidence is aggregated from existing hash-bound manifests. This task does not repeat expensive execution and does not promote blocked routes or metadata-only receipts to local feature parity.\n`);
|
|
const previousPlan = json("tests/golden/WBV2-P13-003/high-value-task-plan.json"); const nextPlan = structuredClone(previousPlan); nextPlan.parentRecoveryPlan = { path: "tests/golden/WBV2-P13-003/high-value-task-plan.json", sha256: sha256("tests/golden/WBV2-P13-003/high-value-task-plan.json") }; nextPlan.tasks = nextPlan.tasks.map((task) => task.id === "WBV2-P13-004" ? { ...task, status: "done", ready: false } : task.id === "WBV2-P13-005" ? { ...task, status: "in_progress", ready: true } : { ...task, ready: false }); fs.writeFileSync(absolute(planPath), `${JSON.stringify(nextPlan, null, 2)}\n`);
|
|
fs.writeFileSync(absolute("docs/tasks/WBV2-P13-005.md"), read("docs/tasks/WBV2-P13-005.md").replace("- status: planned", "- status: in_progress")); execFileSync(process.execPath, [absolute("tools/web/generate-v2-task-index.mjs"), "--plan-path", absolute(planPath)], { cwd: root, stdio: "inherit" }); execFileSync(process.execPath, [absolute("tools/web/check-task-context.mjs"), "--task", "WBV2-P13-004", "--write"], { cwd: root, stdio: "inherit" });
|
|
const artifactPaths = { parentManifest: parentPath, ledger: ledgerPath, sourceManifests: "tests/golden/WBV2-P13-001/advanced-source-index.json", simulationManifest: sources[0].manifest, simulationReport: sources[0].report, renderManifest: sources[1].manifest, renderReport: sources[1].report, mediaManifest: sources[2].manifest, mediaReport: sources[2].report, serverManifest: sources[3].manifest, serverReport: sources[3].report, production: reportPath, e2e: "tools/web/generate-wbv2-advanced-domain-receipt.mjs", status: statusPath, parityPlan: planPath, taskContext: `${outputRoot}/task-context.json` }; const artifacts = Object.fromEntries(Object.entries(artifactPaths).map(([name, file]) => [name, { path: file, sha256: sha256(file) }]));
|
|
const manifest = { schemaVersion: 1, task: "WBV2-P13-004", parentTask: "WBV2-P13-003", operation: "ADVANCED_DOMAIN_ENGINE_RECEIPT", status: "done", enablingTask: false, parityStateChange: true, runtime: "READ_ONLY_ADVANCED_RECEIPT_AGGREGATION", artifacts, assertions: { domains: entries.length, exactReports: entries.length, repeatedBlenderRuns: 0, repeatedChromiumRuns: 0, blockedRoutesExplicit: true, inventoryRemaining: ledger.inventory.pending, inventoryClaimedComplete: 0, deterministic: true, historicalReproduction: false }, nextTask: "WBV2-P13-005" }; fs.writeFileSync(absolute(manifestPath), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
let queue = read("docs/EXECUTION_QUEUE.md"); queue = queue.replace(/\| 当前任务 \| `[^`]+` \|/u, "| 当前任务 | `WBV2-P13-005` |").replace(/\| parent manifest \| `[^`]+` \|/u, "| parent manifest | `tests/golden/WBV2-P13-004/manifest.json` |").replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u, "| 任务卡 | [`tasks/WBV2-P13-005.md`](tasks/WBV2-P13-005.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-005` |").replace(/\| Current task state \| `[^`]+` \|/u, "| Current task state | `in_progress` |").replace(/\| Parent manifest \| `[^`]+` \|/u, "| Parent manifest | `tests/golden/WBV2-P13-004/manifest.json` |").replace(/\| Current task card \| `[^`]+` \|/u, "| Current task card | `docs/tasks/WBV2-P13-005.md` |").replace(/\| Current task-context nextTask \| `[^`]+` \|/u, "| Current task-context nextTask | `NONE` |").replace(/\| Focused command \| `[^`]+` \|/u, "| Focused command | `node tools/web/generate-wbv2-high-value-domain-gate.mjs --write` |"); fs.writeFileSync(absolute("nextTask.md"), nextTaskFile);
|
|
process.stdout.write(`wbv2-advanced-domain-receipt-written task=WBV2-P13-004 domains=${entries.length} repeatedRuns=0 exactReports=${entries.length} next=WBV2-P13-005 artifacts=${Object.keys(artifacts).length}\n`);
|