Files
workinf_Blender_Wasm/tools/web/generate-wbv2-high-value-domain-gate.mjs
mes123456 ea18416ff2
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 high-value domains through P13
2026-08-28 07:11:47 +08:00

251 lines
14 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-P13-005";
const reportPath = `${outputRoot}/high-value-domain-gate-report.json`;
const statusPath = "docs/status/WBV2-P13-005.md";
const planPath = `${outputRoot}/high-value-task-plan.json`;
const manifestPath = `${outputRoot}/manifest.json`;
const parentPath = "tests/golden/WBV2-P13-004/manifest.json";
const ledgerPath = "tests/golden/WBV2-P13-001/advanced-ledger-report.json";
const p12ReportPath = "tests/golden/WBV2-P12-005/domain-parity-gate-report.json";
const p12ManifestPath = "tests/golden/WBV2-P12-005/manifest.json";
const nodesManifestPath = "tests/golden/WBV2-P13-002/manifest.json";
const nodesReportPath = "tests/golden/WBV2-P13-002/geometry-nodes-receipt-report.json";
const rigManifestPath = "tests/golden/WBV2-P13-003/manifest.json";
const rigReportPath = "tests/golden/WBV2-P13-003/rig-pose-receipt-report.json";
const advancedManifestPath = "tests/golden/WBV2-P13-004/manifest.json";
const advancedReportPath = "tests/golden/WBV2-P13-004/advanced-domain-receipt-report.json";
const approvalPath = "docs/status/M12-PROVENANCE-EPOCH-2-APPROVAL.json";
const parent = readJson(parentPath);
assert.equal(parent.task, "WBV2-P13-004");
assert.equal(parent.status, "done");
assert.equal(parent.nextTask, "WBV2-P13-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.inventory.total, 6900);
assert.equal(ledger.inventory.pending, 6618);
assert.equal(ledger.inventory.claimedComplete, 0);
assert.equal(ledger.inventory.remainderExplicit, true);
assert.equal(ledger.reuse.repeatedBlenderRuns, 0);
assert.equal(ledger.reuse.repeatedChromiumRuns, 0);
const p12 = readJson(p12ReportPath);
const p12Manifest = readJson(p12ManifestPath);
assert.equal(p12.status, "PASS");
assert.equal(p12.decision.provenanceEpoch, 2);
assert.equal(p12.decision.releaseScope, "AUTHORIZED_REBASELINE_ONLY");
assert.equal(p12.decision.fullHistoricalReproduction, false);
assert.equal(p12Manifest.status, "done");
const approval = readJson(approvalPath);
assert.equal(approval.decision, "APPROVED");
assert.equal(approval.epoch, 2);
assert.equal(approval.limitations.releaseLabel, "AUTHORIZED_REBASELINE_ONLY");
assert.equal(approval.limitations.fullHistoricalReproduction, false);
function readReceipt(manifestPathValue, reportPathValue, task) {
const manifest = readJson(manifestPathValue);
const report = readJson(reportPathValue);
assert.equal(manifest.task, task);
assert.equal(manifest.status, "done");
assert.equal(report.task, task);
assert.equal(report.status, "PASS");
assert.equal(report.browser, "chromium");
assert.equal(report.queueMutation, false);
assert.equal(report.assertions?.historicalReproduction ?? report.policy?.historicalReproduction, false);
const bound = Object.values(manifest.artifacts ?? {}).find((artifact) => artifact.path === reportPathValue);
assert.ok(bound, `${task} report is not manifest-bound`);
assert.equal(bound.sha256, sha256(reportPathValue));
return { manifest, report, manifestSha256: sha256(manifestPathValue), reportSha256: sha256(reportPathValue) };
}
const nodes = readReceipt(nodesManifestPath, nodesReportPath, "WBV2-P13-002");
assert.equal(nodes.report.production.deterministic, true);
assert.equal(nodes.report.production.saveReopen, "EXACT");
assert.equal(nodes.report.production.revisionPreserved, true);
assert.equal(nodes.report.assertions.graphHashesStable, true);
assert.equal(nodes.report.assertions.unsupportedGraphRejected, true);
assert.equal(nodes.report.assertions.mainUnchangedOnFailure, true);
const rig = readReceipt(rigManifestPath, rigReportPath, "WBV2-P13-003");
assert.equal(rig.report.production.deterministic, true);
assert.equal(rig.report.production.saveReopen, "EXACT");
assert.equal(rig.report.assertions.stableBoneIds, true);
assert.equal(rig.report.assertions.skinIdentityPreserved, true);
assert.equal(rig.report.assertions.malformedConstraintRejected, true);
assert.equal(rig.report.assertions.unsupportedShapeKeyObservationExplicit, true);
const advanced = readReceipt(advancedManifestPath, advancedReportPath, "WBV2-P13-004");
assert.equal(advanced.report.policy.noFalseLocalParity, true);
assert.equal(advanced.report.policy.blockedRoutesExplicit, true);
assert.equal(advanced.report.policy.repeatedBlenderRuns, 0);
assert.equal(advanced.report.policy.repeatedChromiumRuns, 0);
assert.equal(advanced.report.domains.length, 7);
assert(advanced.report.domains.every((domain) => domain.evidenceClass === "EXACT_RECORDED" && domain.saveReopen === "EXACT"));
const featureParityClaims = [...p12.decision.featureParityClaims, "NODES.GEOMETRY_ENGINE", "RIG.POSE_ENGINE"];
const gate = {
schemaVersion: 1,
task: "WBV2-P13-005",
operation: "RECOMPUTE_HIGH_VALUE_DOMAIN_GATE",
status: "PASS",
decision: {
status: "READY_WITH_HIGH_VALUE_DOMAIN_PARITY",
code: "HIGH_VALUE_DOMAIN_AUTHORIZED_REBASELINE",
featureParityClaims,
featureParityClaimCount: featureParityClaims.length,
advancedSourceDomains: advanced.report.domains.map((domain) => domain.domain),
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 },
p12Gate: { path: p12ReportPath, sha256: sha256(p12ReportPath), manifest: p12ManifestPath, manifestSha256: sha256(p12ManifestPath), claims: p12.decision.featureParityClaimCount },
geometryNodes: { path: nodesReportPath, sha256: nodes.reportSha256, manifest: nodesManifestPath, manifestSha256: nodes.manifestSha256, claims: ["NODES.GEOMETRY_ENGINE"], graphCount: nodes.report.production.graphCount, saveReopen: "EXACT" },
rigPose: { path: rigReportPath, sha256: rig.reportSha256, manifest: rigManifestPath, manifestSha256: rig.manifestSha256, claims: ["RIG.POSE_ENGINE"], boneCount: rig.report.production.boneCount, saveReopen: "EXACT", shapeKeyObservation: rig.report.source.shapeKeyObservation },
advancedDomains: { path: advancedReportPath, sha256: advanced.reportSha256, manifest: advancedManifestPath, manifestSha256: advanced.manifestSha256, domains: advanced.report.domains, featureClaimsPromoted: false },
approval: { path: approvalPath, sha256: sha256(approvalPath), epoch: approval.epoch, releaseScope: approval.limitations.releaseLabel },
},
efficiency: {
batchLedgerScan: true,
existingReceiptsReused: ledger.summary.manifestsDone + advanced.report.domains.length,
repeatedBlenderRuns: 0,
repeatedChromiumRuns: 0,
newEngineReceipts: 2,
inventoryTasksCreated: 0,
duplicateValidationAvoided: true,
},
coverage: {
inventoryTotal: ledger.inventory.total,
inventoryPending: ledger.inventory.pending,
inventoryClaimedComplete: ledger.inventory.claimedComplete,
engineBoundFeatureClaims: featureParityClaims.length,
advancedSourceDomains: advanced.report.domains.length,
},
negative: {
missingReceipt: "REJECTED",
receiptHashDrift: "REJECTED",
unsupportedBrowser: "REJECTED",
nonExactSaveReopen: "REJECTED",
falseInventoryCompletion: "REJECTED",
falseHistoricalReproduction: "REJECTED",
undeclaredClaim: "REJECTED",
advancedDomainPromotionWithoutMainReceipt: "REJECTED",
},
policy: {
sourceHistoryReadOnly: true,
authorizedRebaselineOnly: true,
existingEvidenceReused: true,
inventoryRemainderExplicit: true,
noFalseLocalParity: true,
terminalQueuePointer: true,
},
nextTask: null,
};
if (!write) {
process.stdout.write(`wbv2-high-value-domain-gate-ok task=WBV2-P13-005 claims=${gate.decision.featureParityClaimCount} sourceDomains=${advanced.report.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-P13-005 status\n\n- task: \`WBV2-P13-005\`; parent: \`WBV2-P13-004\`; status: \`done\`\n- engine-bound feature claims: \`${gate.decision.featureParityClaimCount}\` (P12: \`${p12.decision.featureParityClaimCount}\`, Geometry Nodes: \`1\`, Rig/Pose: \`1\`)\n- advanced source domains retained without local promotion: \`${advanced.report.domains.length}\`\n- inventory: \`${ledger.inventory.total}\` total, \`${ledger.inventory.pending}\` pending, claimed complete: \`0\`\n- repeated Blender/Chromium validation: \`0\`; existing receipts reused\n- provenance epoch: \`${approval.epoch}\`; release: \`AUTHORIZED_REBASELINE_ONLY\`; fullHistoricalReproduction: \`false\`\n- nextTask: \`NONE\`\n\nThe high-value gate reuses the batch ledger and hash-bound receipts. Only Geometry Nodes and Rig/Pose receive new engine-bound feature claims because they have deterministic Chromium/WASM Main receipts; Simulation, Render, Media, Server, Security, and Reliability remain explicit source evidence with blocked routes and no false local parity. The 6900-entry remainder and provenance limitation remain visible.\n`);
const previousPlan = readJson("tests/golden/WBV2-P13-004/high-value-task-plan.json");
const nextPlan = structuredClone(previousPlan);
nextPlan.status = "COMPLETED_WITH_HIGH_VALUE_DOMAIN_PARITY";
nextPlan.parentRecoveryPlan = { path: "tests/golden/WBV2-P13-004/high-value-task-plan.json", sha256: sha256("tests/golden/WBV2-P13-004/high-value-task-plan.json") };
nextPlan.tasks = nextPlan.tasks.map((task) => 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: in_progress", "- status: done"));
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-005", "--write"], { cwd: root, stdio: "inherit" });
const artifactPaths = {
parentManifest: parentPath,
ledger: ledgerPath,
p12Gate: p12ReportPath,
p12Manifest: p12ManifestPath,
geometryNodesManifest: nodesManifestPath,
geometryNodesReport: nodesReportPath,
rigPoseManifest: rigManifestPath,
rigPoseReport: rigReportPath,
advancedManifest: advancedManifestPath,
advancedReport: advancedReportPath,
approval: approvalPath,
generator: "tools/web/generate-wbv2-high-value-domain-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-P13-005",
parentTask: "WBV2-P13-004",
operation: "RECOMPUTE_HIGH_VALUE_DOMAIN_GATE",
status: "done",
enablingTask: true,
parityStateChange: true,
runtime: "READ_ONLY_LEDGER_PLUS_PLAYWRIGHT_CHROMIUM_WEBENGINE_WASM",
artifacts,
assertions: {
totalFeatureClaims: featureParityClaims.length,
p12ClaimsReused: p12.decision.featureParityClaimCount,
newGeometryNodesClaims: 1,
newRigPoseClaims: 1,
advancedSourceDomains: advanced.report.domains.length,
advancedDomainsPromoted: 0,
existingManifestsBatchScanned: ledger.summary.manifestsDone,
repeatedBlenderRuns: 0,
repeatedChromiumRuns: 0,
inventoryTotal: ledger.inventory.total,
inventoryPending: ledger.inventory.pending,
inventoryClaimedComplete: ledger.inventory.claimedComplete,
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-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 | `done` |")
.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-high-value-domain-gate-written task=WBV2-P13-005 claims=${gate.decision.featureParityClaimCount} sourceDomains=${advanced.report.domains.length} inventoryPending=${ledger.inventory.pending} repeatedRuns=0 epoch=${approval.epoch} terminal=true artifacts=${Object.keys(artifacts).length}\n`);