96 lines
7.9 KiB
JavaScript
96 lines
7.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 readJson = (file) => JSON.parse(read(file));
|
|
const sha256 = (file) => crypto.createHash("sha256").update(fs.readFileSync(absolute(file))).digest("hex");
|
|
const outputRoot = "tests/golden/WBV2-P10-003";
|
|
const matrixPath = `${outputRoot}/module-matrix.json`;
|
|
const productionPath = `${outputRoot}/module-matrix-production.json`;
|
|
const productionSecondPath = `${outputRoot}/module-matrix-production.second.json`;
|
|
const engineReceiptPath = "tests/golden/WBV2-P10-002/native-engine-receipt-report.json";
|
|
const parentManifestPath = "tests/golden/WBV2-P10-002/manifest.json";
|
|
const reportPath = `${outputRoot}/module-matrix-receipt-report.json`;
|
|
const statusPath = "docs/status/WBV2-P10-003.md";
|
|
const planPath = `${outputRoot}/native-parity-task-plan.json`;
|
|
const manifestPath = `${outputRoot}/manifest.json`;
|
|
|
|
const parent = readJson(parentManifestPath);
|
|
assert.equal(parent.task, "WBV2-P10-002");
|
|
assert.equal(parent.status, "done");
|
|
assert.equal(parent.nextTask, "WBV2-P10-003");
|
|
for (const artifact of Object.values(parent.artifacts ?? {})) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
|
const engineReceipt = readJson(engineReceiptPath);
|
|
assert.equal(engineReceipt.status, "PASS");
|
|
assert.equal(engineReceipt.assertions.realEngineMainMutation, true);
|
|
const matrix = readJson(matrixPath);
|
|
assert.equal(matrix.task, "WBV2-P10-003");
|
|
assert.equal(matrix.status, "READY");
|
|
assert.equal(matrix.catalog.inventoryEntries, 6900);
|
|
assert.equal(matrix.catalog.pendingEntries, 6618);
|
|
assert.equal(matrix.policy.unmappedInventoryExplicit, true);
|
|
assert.equal(sha256(matrix.catalog.path), matrix.catalog.sha256);
|
|
const production = readJson(productionPath);
|
|
assert.equal(sha256(productionPath), sha256(productionSecondPath), "module matrix report is not deterministic");
|
|
assert.equal(production.task, "WBV2-P10-003");
|
|
assert.equal(production.operation, "CORE_MODULE_OPERATOR_MATRIX_CHROMIUM");
|
|
assert.equal(production.browser, "chromium");
|
|
assert.equal(production.queueMutation, false);
|
|
assert.equal(production.catalogSha256, matrix.catalog.sha256);
|
|
assert.equal(production.cases.length, matrix.cases.length);
|
|
assert.equal(production.cases.filter((entry) => entry.status === "PASS").length, 3);
|
|
assert.equal(production.cases.filter((entry) => entry.status === "RETAINED_NEGATIVE").length, 6);
|
|
for (const entry of production.cases) {
|
|
assert.ok(matrix.cases.some((candidate) => candidate.id === entry.id), `case is not catalog-bound: ${entry.id}`);
|
|
assert.equal(entry.mainMutation, entry.status === "PASS" ? "CHANGED" : "UNCHANGED");
|
|
assert.equal(entry.revisionDelta, entry.status === "PASS" ? 1 : 0);
|
|
if (entry.status === "PASS") assert.equal(entry.saveReopen, true);
|
|
}
|
|
assert.equal(production.shards.length, 2);
|
|
assert.ok(production.shards.every((shard) => shard.catalogSha256 === matrix.catalog.sha256 && shard.exitCode === 0));
|
|
|
|
const receipt = {
|
|
schemaVersion: 1,
|
|
task: "WBV2-P10-003",
|
|
operation: "CORE_MODULE_OPERATOR_MATRIX_RECEIPT",
|
|
status: "PASS",
|
|
browser: "chromium",
|
|
queueMutation: false,
|
|
source: { engineReceipt: engineReceiptPath, engineReceiptSha256: sha256(engineReceiptPath), catalog: matrix.catalog, featureGate: matrix.source.featureGate, featureGateSha256: matrix.source.featureGateSha256 },
|
|
matrix: { definition: matrixPath, definitionSha256: sha256(matrixPath), production: productionPath, productionSha256: sha256(productionPath), secondProduction: productionSecondPath, secondProductionSha256: sha256(productionSecondPath), deterministic: true, modules: matrix.modules, cases: production.cases.length, positive: 3, retainedNegative: 6, shards: production.shards.map((shard) => ({ id: shard.id, catalogSha256: shard.catalogSha256, exitCode: shard.exitCode })) },
|
|
coverage: { inventoryEntries: matrix.coverage.inventoryEntries, claimedComplete: matrix.coverage.inventoryEntriesClaimedComplete, remainingExplicit: matrix.coverage.inventoryEntriesRemainingExplicit, productionCases: production.cases.length, oneCatalogHash: true },
|
|
assertions: { positiveCasesMainChanged: true, negativeCasesMainUnchanged: true, saveReopenExact: 3, unmappedInventoryExplicit: true, retainedNegativeExplicit: true, historicalReproduction: false },
|
|
nextTask: null,
|
|
};
|
|
|
|
if (!write) {
|
|
process.stdout.write("wbv2-module-matrix-receipt-ok task=WBV2-P10-003 cases=9 positive=3 negative=6 shards=2 deterministic=true terminal=true\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-P10-003 status\n\n- task: \`WBV2-P10-003\`; parent: \`WBV2-P10-002\`; status: \`done\`\n- module cases: \`9\`; positive Main mutations: \`3\`; retained negatives: \`6\`\n- shards: \`2\`; one catalog hash; exit codes: \`0/0\`\n- inventory: \`6900\` total, \`6900\` explicitly remaining; no false completion claim\n- nextTask: \`NONE\`\n\nThe data-driven Mesh, Modifier, and Asset Catalog matrix re-runs the real WebEngine WASM Main path with one catalog hash. Positive cases change Main and pass save/reopen; stale, malformed, unknown, and collision cases remain explicit retained negatives. The matrix does not claim all inventory entries are complete or reproduce unavailable historical bytes. P10-003 is the terminal pointer until a separately authorized continuation is created.\n`);
|
|
|
|
const previousPlan = readJson("tests/golden/WBV2-P10-002/native-parity-task-plan.json");
|
|
const nextPlan = structuredClone(previousPlan);
|
|
nextPlan.status = "COMPLETED_WITH_NATIVE_MODULE_MATRIX";
|
|
nextPlan.parentRecoveryPlan = { path: "tests/golden/WBV2-P10-002/native-parity-task-plan.json", sha256: sha256("tests/golden/WBV2-P10-002/native-parity-task-plan.json") };
|
|
nextPlan.tasks = nextPlan.tasks.map((task) => task.id === "WBV2-P10-003" ? { ...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-P10-003", "--write"], { cwd: root, stdio: "inherit" });
|
|
|
|
const artifactPaths = { parentManifest: parentManifestPath, engineReceipt: engineReceiptPath, matrix: matrixPath, production: productionPath, productionSecond: productionSecondPath, e2e: "web/tests/e2e/wbv2-module-matrix.spec.ts", generator: "tools/web/generate-wbv2-module-matrix.mjs", receiptGenerator: "tools/web/generate-wbv2-module-matrix-receipt.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-P10-003", parentTask: "WBV2-P10-002", operation: "CORE_MODULE_OPERATOR_MATRIX_RECEIPT", status: "done", enablingTask: true, parityStateChange: true, runtime: "PLAYWRIGHT_CHROMIUM_WEBENGINE_WASM", artifacts, assertions: { cases: 9, positiveCases: 3, retainedNegative: 6, shards: 2, oneCatalogHash: true, inventoryEntries: 6900, inventoryEntriesRemaining: 6900, deterministic: true, saveReopen: "EXACT", historicalReproduction: false }, nextTask: null };
|
|
fs.writeFileSync(absolute(manifestPath), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
process.stdout.write(`wbv2-module-matrix-receipt-written task=WBV2-P10-003 cases=9 positive=3 negative=6 shards=2 deterministic=true terminal=true artifacts=${Object.keys(artifacts).length}\n`);
|