Files
workinf_Blender_Wasm/tools/web/generate-wbv2-lighting-gate.mjs
mes123456 4a5c70910b
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 deduplicated lighting capability coverage
2026-08-28 12:19:18 +08:00

42 lines
9.9 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-P15-003";
const reportPath = `${outputRoot}/lighting-gate-report.json`;
const statusPath = "docs/status/WBV2-P15-003.md";
const planPath = `${outputRoot}/lights-task-plan.json`;
const manifestPath = `${outputRoot}/manifest.json`;
const parentPath = "tests/golden/WBV2-P15-002/manifest.json";
const receiptPath = "tests/golden/WBV2-P15-002/lighting-fields-receipt-report.json";
const selectionPath = "tests/golden/WBV2-P15-001/lighting-selection-report.json";
const coverageMatrixPath = "tests/golden/WBV2-P14-002/capability-evidence-matrix.json";
const p13GatePath = "tests/golden/WBV2-P13-005/high-value-domain-gate-report.json";
const approvalPath = "docs/status/M12-PROVENANCE-EPOCH-2-APPROVAL.json";
const parent = json(parentPath); const receipt = json(receiptPath); const selection = json(selectionPath); const coverage = json(coverageMatrixPath); const p13 = json(p13GatePath); const approval = json(approvalPath);
assert.equal(parent.task, "WBV2-P15-002"); assert.equal(parent.status, "done"); assert.equal(parent.nextTask, "WBV2-P15-003");
for (const artifact of Object.values(parent.artifacts ?? {})) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
assert.equal(receipt.status, "PASS"); assert.equal(receipt.browser, "chromium"); assert.equal(receipt.assertions.saveReopenExact, true); assert.equal(receipt.assertions.deterministic, true); assert.equal(receipt.assertions.representativeSliceOnly, true); assert.equal(receipt.assertions.fullFamilyParity, false);
assert.equal(selection.status, "PASS"); assert.equal(selection.candidate.capabilityId, "RENDER.LIGHTING_FIELDS"); assert.equal(selection.inventory.matchedEntries, 197); assert.equal(coverage.inventory.pending, 6618); assert.equal(p13.decision.fullHistoricalReproduction, false); assert.equal(approval.limitations.releaseLabel, "AUTHORIZED_REBASELINE_ONLY");
const claims = [...p13.decision.featureParityClaims, "RENDER.LIGHTING_FIELDS"];
assert.equal(new Set(claims).size, p13.decision.featureParityClaimCount + 1);
const gate = { schemaVersion: 1, task: "WBV2-P15-003", operation: "CLOSE_LIGHTING_CAPABILITY_GATE", status: "PASS", decision: { status: "READY_WITH_LIGHTING_SLICE_PARITY", code: "LIGHTING_FIELDS_AUTHORIZED_REBASELINE", featureParityClaims: claims, featureParityClaimCount: claims.length, newClaim: "RENDER.LIGHTING_FIELDS", representativeInventoryEntries: selection.inventory.matchedEntries, fullFamilyParity: false, engineBound: true, browser: "chromium", provenanceEpoch: approval.epoch, releaseScope: approval.limitations.releaseLabel, fullHistoricalReproduction: false, inventoryTotal: 6900, inventoryPending: 6618, inventoryClaimedComplete: 0 }, evidence: { receipt: { path: receiptPath, sha256: sha256(receiptPath), manifest: parentPath, manifestSha256: sha256(parentPath), operations: receipt.production.operations, saveReopen: receipt.production.saveReopen, deterministic: receipt.production.deterministic }, selection: { path: selectionPath, sha256: sha256(selectionPath), behaviorHash: selection.candidate.behaviorHash, matchedEntries: selection.inventory.matchedEntries }, coverageMatrix: { path: coverageMatrixPath, sha256: sha256(coverageMatrixPath), buckets: coverage.inventory.buckets, pending: coverage.inventory.pending }, p13Gate: { path: p13GatePath, sha256: sha256(p13GatePath), previousClaims: p13.decision.featureParityClaimCount }, approval: { path: approvalPath, sha256: sha256(approvalPath), epoch: approval.epoch, releaseScope: approval.limitations.releaseLabel } }, efficiency: { sourceCandidateScanReused: true, coverageLedgerReused: true, uniqueBehaviorRuns: 2, repeatedBlenderRuns: 0, repeatedChromiumRuns: 0, duplicateValidationAvoided: true, inventoryTasksCreated: 0 }, coverage: { inventoryTotal: 6900, inventoryPending: 6618, inventoryClaimedComplete: 0, capabilityBuckets: coverage.inventory.buckets, lightingRepresentativeEntries: selection.inventory.matchedEntries, lightingFeatureClaims: 1, fullFamilyClaims: 0 }, negative: { missingReceipt: "REJECTED", receiptHashDrift: "REJECTED", unsupportedBrowser: "REJECTED", nonExactSaveReopen: "REJECTED", malformedLightingValues: receipt.production.malformed.code, falseInventoryCompletion: "REJECTED", falseHistoricalReproduction: "REJECTED", representativeAsFullFamily: "REJECTED" }, policy: { sourceHistoryReadOnly: true, authorizedRebaselineOnly: true, representativeSliceOnly: true, inventoryRemainderExplicit: true, noFalseLocalParity: true, terminalQueuePointer: true }, nextTask: null };
if (!write) { process.stdout.write(`wbv2-lighting-gate-ok task=WBV2-P15-003 claims=${claims.length} newClaim=RENDER.LIGHTING_FIELDS representative=197 pending=6618 repeatedRuns=0 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-P15-003 status\n\n- task: \`WBV2-P15-003\`; parent: \`WBV2-P15-002\`; status: \`done\`\n- new engine-bound claim: \`RENDER.LIGHTING_FIELDS\`; representative entries: \`197\`; full-family parity: \`false\`\n- total engine-bound feature claims: \`${claims.length}\`; inventory: \`6900\` total, \`6618\` pending, claimed complete: \`0\`\n- unique behavior runs: \`2\`; repeated Blender/Chromium validation: \`0\`; duplicate validation avoided: \`true\`\n- provenance epoch: \`${approval.epoch}\`; release: \`AUTHORIZED_REBASELINE_ONLY\`; fullHistoricalReproduction: \`false\`\n- nextTask: \`NONE\`\n\nThe Lighting/Camera/World slice is now a hash-bound Chromium/WASM Main feature claim. The 197 matched inventory entries are coverage references only; remaining lighting/render behaviors require unique behavior evidence.\n`);
const previousPlan = json("tests/golden/WBV2-P15-002/lights-task-plan.json"); const nextPlan = structuredClone(previousPlan); nextPlan.status = "COMPLETED_WITH_LIGHTING_SLICE"; nextPlan.parentRecoveryPlan = { path: "tests/golden/WBV2-P15-002/lights-task-plan.json", sha256: sha256("tests/golden/WBV2-P15-002/lights-task-plan.json") }; nextPlan.tasks = nextPlan.tasks.map((task) => task.id === "WBV2-P15-003" ? { ...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-P15-003.md"), read("docs/tasks/WBV2-P15-003.md").replace("- status: planned", "- 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-P15-003", "--write"], { cwd: root, stdio: "inherit" });
const artifactPaths = { parentManifest: parentPath, receipt: receiptPath, selection: selectionPath, coverageMatrix: coverageMatrixPath, p13Gate: p13GatePath, approval: approvalPath, report: reportPath, generator: "tools/web/generate-wbv2-lighting-gate.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-P15-003", parentTask: "WBV2-P15-002", operation: "CLOSE_LIGHTING_CAPABILITY_GATE", status: "done", enablingTask: true, parityStateChange: true, runtime: "READ_ONLY_LIGHTING_GATE", artifacts, assertions: { totalFeatureClaims: claims.length, newLightingClaims: 1, representativeInventoryEntries: 197, fullFamilyParityClaims: 0, inventoryTotal: 6900, inventoryPending: 6618, inventoryClaimedComplete: 0, uniqueBehaviorRuns: 2, repeatedBlenderRuns: 0, repeatedChromiumRuns: 0, duplicateValidationAvoided: true, 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-P15-003` |").replace(/\| parent manifest \| `[^`]+` \|/u, "| parent manifest | `tests/golden/WBV2-P15-002/manifest.json` |").replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u, "| 任务卡 | [`tasks/WBV2-P15-003.md`](tasks/WBV2-P15-003.md) |"); fs.writeFileSync(absolute("docs/EXECUTION_QUEUE.md"), queue);
let nextTask = read("nextTask.md"); nextTask = nextTask.replace(/\| Current task when this file was written \| `[^`]+` \|/u, "| Current task when this file was written | `WBV2-P15-003` |").replace(/\| Current task state \| `[^`]+` \|/u, "| Current task state | `done` |").replace(/\| Parent manifest \| `[^`]+` \|/u, "| Parent manifest | `tests/golden/WBV2-P15-002/manifest.json` |").replace(/\| Current task card \| `[^`]+` \|/u, "| Current task card | `docs/tasks/WBV2-P15-003.md` |").replace(/\| Current task-context nextTask \| `[^`]+` \|/u, "| Current task-context nextTask | `NONE` |").replace(/\| Focused command \| `[^`]+` \|/u, "| Focused command | `node tools/web/generate-wbv2-lighting-gate.mjs --write` |"); fs.writeFileSync(absolute("nextTask.md"), nextTask);
process.stdout.write(`wbv2-lighting-gate-written task=WBV2-P15-003 claims=${claims.length} newClaim=RENDER.LIGHTING_FIELDS representative=197 pending=6618 repeatedRuns=0 terminal=true artifacts=${Object.keys(artifacts).length}\n`);