Files
workinf_Blender_Wasm/tools/web/generate-wbv2-domain-parity-gate.mjs
mes123456 2abe7cc220
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
Advance WBV2 domain parity through P12
2026-08-28 06:38:27 +08:00

108 lines
11 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 readJson = (file) => JSON.parse(read(file));
const sha256 = (file) => crypto.createHash("sha256").update(fs.readFileSync(absolute(file))).digest("hex");
const outputRoot = "tests/golden/WBV2-P12-005";
const reportPath = `${outputRoot}/domain-parity-gate-report.json`;
const statusPath = "docs/status/WBV2-P12-005.md";
const planPath = `${outputRoot}/domain-expansion-task-plan.json`;
const manifestPath = `${outputRoot}/manifest.json`;
const parentPath = "tests/golden/WBV2-P12-004/manifest.json";
const ledgerPath = "tests/golden/WBV2-P12-001/capability-ledger-report.json";
const approvalPath = "docs/status/M12-PROVENANCE-EPOCH-2-APPROVAL.json";
const p11GatePath = "tests/golden/WBV2-P11-004/engine-module-gate-report.json";
const domainSources = [
{ id: "CAP-SCENE-OBJECT-ENGINE", family: "SCENE_OBJECT", manifest: "tests/golden/WBV2-P12-002/manifest.json", report: "tests/golden/WBV2-P12-002/scene-object-receipt-report.json", proof: "visibility + transform + exact save/reopen" },
{ id: "CAP-MATERIAL-ANIMATION-ENGINE", family: "MATERIAL_ANIMATION", manifest: "tests/golden/WBV2-P12-003/manifest.json", report: "tests/golden/WBV2-P12-003/material-animation-receipt-report.json", proof: "material/UV + keyframe/interpolation + exact save/reopen" },
{ id: "CAP-VIEWPORT-NONMESH-ENGINE", family: "VIEWPORT_NONMESH", manifest: "tests/golden/WBV2-P12-004/manifest.json", report: "tests/golden/WBV2-P12-004/viewport-nonmesh-receipt-report.json", proof: "nonblank viewport + non-mesh gate/edit + exact save/reopen" },
];
const parent = readJson(parentPath);
assert.equal(parent.task, "WBV2-P12-004");
assert.equal(parent.status, "done");
assert.equal(parent.nextTask, "WBV2-P12-005");
for (const artifact of Object.values(parent.artifacts ?? {})) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
const ledger = readJson(ledgerPath);
assert.equal(ledger.status, "PASS");
assert.equal(ledger.task, "WBV2-P12-001");
assert.equal(ledger.inventory.pending, 6618);
assert.equal(ledger.inventory.claimedComplete, 0);
assert.equal(ledger.reuse.repeatedBlenderRuns, 0);
assert.equal(ledger.reuse.repeatedChromiumRuns, 0);
const approval = readJson(approvalPath);
assert.equal(approval.epoch, 2);
assert.equal(approval.limitations.releaseLabel, "AUTHORIZED_REBASELINE_ONLY");
assert.equal(approval.limitations.fullHistoricalReproduction, false);
const p11Gate = readJson(p11GatePath);
assert.equal(p11Gate.status, "PASS");
assert.equal(p11Gate.decision.engineBound, true);
assert.equal(p11Gate.decision.fullHistoricalReproduction, false);
const domains = domainSources.map((source) => {
const manifest = readJson(source.manifest);
const report = readJson(source.report);
assert.equal(manifest.status, "done", `${source.family} manifest is not done`);
assert.equal(report.status, "PASS", `${source.family} report is not PASS`);
assert.equal(report.browser, "chromium");
assert.equal(report.queueMutation, false);
assert.equal(report.assertions.saveReopenExact, true);
assert.equal(report.assertions.historicalReproduction, false);
const bound = Object.values(manifest.artifacts ?? {}).find((artifact) => artifact.path === source.report);
assert.ok(bound, `${source.family} report is not manifest-bound`);
assert.equal(bound.sha256, sha256(source.report));
return { capabilityId: source.id, family: source.family, manifest: source.manifest, manifestSha256: sha256(source.manifest), report: source.report, reportSha256: sha256(source.report), proof: source.proof, browser: "chromium", engineBound: true, deterministic: true, saveReopen: "EXACT" };
});
const gate = {
schemaVersion: 1,
task: "WBV2-P12-005",
operation: "RECOMPUTE_DOMAIN_PARITY_GATE",
status: "PASS",
decision: { status: "READY_WITH_DOMAIN_ENGINE_PARITY", code: "DOMAIN_PARITY_AUTHORIZED_REBASELINE", featureParityClaims: [...p11Gate.decision.featureParityClaims, ...domains.map((domain) => domain.capabilityId)], featureParityClaimCount: p11Gate.decision.featureParityClaimCount + domains.length, engineBound: true, browser: "chromium", provenanceEpoch: approval.epoch, releaseScope: approval.limitations.releaseLabel, fullHistoricalReproduction: false, inventoryTotal: ledger.inventory.total, inventoryPending: ledger.inventory.pending, inventoryClaimedComplete: ledger.inventory.claimedComplete },
evidence: { ledger: { path: ledgerPath, sha256: sha256(ledgerPath), sourceManifests: ledger.summary.manifestsDone, artifactRecords: ledger.summary.artifactRecords, repeatedRuns: 0 }, p11Gate: { path: p11GatePath, sha256: sha256(p11GatePath), claims: p11Gate.decision.featureParityClaimCount }, domains },
efficiency: { batchLedgerScan: true, existingReceiptsReused: ledger.summary.manifestsDone, repeatedBlenderRuns: 0, repeatedChromiumRuns: 0, newDomainReceipts: domains.length, inventoryTasksCreated: 0 },
coverage: { inventoryTotal: ledger.inventory.total, inventoryPending: ledger.inventory.pending, inventoryClaimedComplete: 0, engineBoundDomainClaims: domains.length + p11Gate.decision.featureParityClaimCount },
negative: { missingReceipt: "REJECTED", receiptHashDrift: "REJECTED", unsupportedBrowser: "REJECTED", nonExactSaveReopen: "REJECTED", falseInventoryCompletion: "REJECTED", falseHistoricalReproduction: "REJECTED", undeclaredClaim: "REJECTED" },
policy: { sourceHistoryReadOnly: true, authorizedRebaselineOnly: true, existingEvidenceReused: true, inventoryRemainderExplicit: true, terminalQueuePointer: true },
nextTask: null,
};
if (!write) { process.stdout.write(`wbv2-domain-parity-gate-ok task=WBV2-P12-005 claims=${gate.decision.featureParityClaimCount} domains=${domains.length} inventoryPending=${ledger.inventory.pending} repeatedRuns=0 epoch=${approval.epoch} terminal=true\n`); process.exit(0); }
fs.mkdirSync(absolute(outputRoot), { recursive: true });
fs.writeFileSync(absolute(reportPath), `${JSON.stringify(gate, null, 2)}\n`);
fs.writeFileSync(absolute(statusPath), `# WBV2-P12-005 status\n\n- task: \`WBV2-P12-005\`; parent: \`WBV2-P12-004\`; status: \`done\`\n- engine-bound domain claims: \`${gate.decision.featureParityClaimCount}\`\n- P11 claims reused: \`${p11Gate.decision.featureParityClaimCount}\`; P12 new domain claims: \`${domains.length}\`\n- inventory: \`${ledger.inventory.total}\` total, \`${ledger.inventory.pending}\` pending, claimed complete: \`0\`\n- repeated Blender/Chromium validation: \`0\` for existing receipts\n- provenance epoch: \`2\`; release: \`AUTHORIZED_REBASELINE_ONLY\`; fullHistoricalReproduction: \`false\`\n- nextTask: \`NONE\`\n\nThe domain gate combines the conservative batch ledger with engine-bound Chromium receipts for scene/object, material/animation, and viewport/non-mesh behavior. Existing evidence was reused read-only; only verified domain claims are emitted. The remaining inventory and provenance limitations stay explicit. P12-005 is the terminal pointer until a separately authorized continuation is created.\n`);
const previousPlan = readJson("tests/golden/WBV2-P12-004/domain-expansion-task-plan.json");
const nextPlan = structuredClone(previousPlan);
nextPlan.status = "COMPLETED_WITH_DOMAIN_PARITY";
nextPlan.parentRecoveryPlan = { path: "tests/golden/WBV2-P12-004/domain-expansion-task-plan.json", sha256: sha256("tests/golden/WBV2-P12-004/domain-expansion-task-plan.json") };
nextPlan.tasks = nextPlan.tasks.map((task) => task.id === "WBV2-P12-005" ? { ...task, status: "in_progress", ready: true } : { ...task, ready: false });
fs.writeFileSync(absolute(planPath), `${JSON.stringify(nextPlan, null, 2)}\n`);
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-P12-005", "--write"], { cwd: root, stdio: "inherit" });
const artifactPaths = { parentManifest: parentPath, ledger: ledgerPath, approval: approvalPath, p11Gate: p11GatePath, sceneObjectManifest: domains[0].manifest, sceneObjectReport: domains[0].report, materialAnimationManifest: domains[1].manifest, materialAnimationReport: domains[1].report, viewportNonMeshManifest: domains[2].manifest, viewportNonMeshReport: domains[2].report, generator: "tools/web/generate-wbv2-domain-parity-gate.mjs", report: reportPath, 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-P12-005", parentTask: "WBV2-P12-004", operation: "RECOMPUTE_DOMAIN_PARITY_GATE", status: "done", enablingTask: true, parityStateChange: true, runtime: "READ_ONLY_LEDGER_PLUS_PLAYWRIGHT_CHROMIUM_WEBENGINE_WASM", artifacts, assertions: { totalClaims: gate.decision.featureParityClaimCount, newDomainClaims: domains.length, reusedP11Claims: p11Gate.decision.featureParityClaimCount, existingManifestsBatchScanned: ledger.summary.manifestsDone, repeatedBlenderRuns: 0, repeatedChromiumRuns: 0, inventoryTotal: ledger.inventory.total, inventoryPending: ledger.inventory.pending, inventoryClaimedComplete: 0, provenanceEpoch: approval.epoch, authorizedRebaselineOnly: true, fullHistoricalReproduction: false, deterministic: true }, nextTask: null };
fs.writeFileSync(absolute(manifestPath), `${JSON.stringify(manifest, null, 2)}\n`);
let queue = read("docs/EXECUTION_QUEUE.md");
queue = queue.replace(/\| 当前任务 \| `[^`]+` \|/u, "| 当前任务 | `WBV2-P12-005` |")
.replace(/\| parent manifest \| `[^`]+` \|/u, "| parent manifest | `tests/golden/WBV2-P12-004/manifest.json` |")
.replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u, "| 任务卡 | [`tasks/WBV2-P12-005.md`](tasks/WBV2-P12-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-P12-005` |")
.replace(/\| Current task state \| `[^`]+` \|/u, "| Current task state | `done` |")
.replace(/\| Parent manifest \| `[^`]+` \|/u, "| Parent manifest | `tests/golden/WBV2-P12-004/manifest.json` |")
.replace(/\| Current task card \| `[^`]+` \|/u, "| Current task card | `docs/tasks/WBV2-P12-005.md` |")
.replace(/\| Current task-context nextTask \| `[^`]+` \|/u, "| Current task-context nextTask | `NONE` |")
.replace(/\| Focused command \| `[^`]+` \|/u, "| Focused command | `node tools/web/generate-wbv2-domain-parity-gate.mjs --write` |");
fs.writeFileSync(absolute("nextTask.md"), nextTaskFile);
process.stdout.write(`wbv2-domain-parity-gate-written task=WBV2-P12-005 claims=${gate.decision.featureParityClaimCount} domains=${domains.length} inventoryPending=${ledger.inventory.pending} repeatedRuns=0 epoch=${approval.epoch} terminal=true artifacts=${Object.keys(artifacts).length}\n`);