176 lines
7.4 KiB
JavaScript
176 lines
7.4 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import crypto from "node:crypto";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
|
const outputPath = path.join(root, "tests/golden/WBV2-P7-003/c5-family-evidence-report.json");
|
|
|
|
const relative = (file) => path.relative(root, file).replaceAll(path.sep, "/");
|
|
const absolute = (file) => path.join(root, file);
|
|
const readJson = (file) => JSON.parse(fs.readFileSync(absolute(file), "utf8"));
|
|
const sha256 = (file) => crypto.createHash("sha256").update(fs.readFileSync(absolute(file))).digest("hex");
|
|
|
|
const sources = [
|
|
{
|
|
family: "MESH",
|
|
capabilityIds: ["CAP-MESH-POSITIVE-EDIT", "CAP-MESH-EDITING", "MESH.EDIT_CORE"],
|
|
task: "WBV2-P2-003",
|
|
report: "tests/golden/WBV2-P2-003/mesh-edit-report.json",
|
|
desktopReport: "tests/golden/WBV2-P2-003/mesh-edit-desktop-report.json",
|
|
protocol: "web/protocol/corrective-mesh-command.ts",
|
|
c5ReceiptId: "mesh-desktop",
|
|
c5MutationReceiptId: "mesh-wasm",
|
|
},
|
|
{
|
|
family: "MODIFIER",
|
|
capabilityIds: ["CAP-MODIFIER-STATE-MUTATION", "CAP-MODIFIER-SYSTEM", "MODIFIER.DECLARED_SLICES"],
|
|
task: "WBV2-P4-001",
|
|
report: "tests/golden/WBV2-P4-001/modifier-report.json",
|
|
desktopReport: "tests/golden/WBV2-P4-001/modifier-desktop-report.json",
|
|
protocol: "web/protocol/corrective-modifier-command.ts",
|
|
c5ReceiptId: "modifier-desktop",
|
|
c5MutationReceiptId: "modifier-wasm",
|
|
},
|
|
{
|
|
family: "ASSET_CATALOG",
|
|
capabilityIds: ["CAP-ASSET-CATALOG-MUTATION", "ASSET_LIBRARY_APPEND_LINK_OVERRIDE", "ASSET.LIBRARY_OPERATIONS"],
|
|
task: "WBV2-P3-005",
|
|
report: "tests/golden/WBV2-P3-005/library-report.json",
|
|
desktopReport: "tests/golden/WBV2-P3-005/library-desktop-report.json",
|
|
protocol: "web/protocol/corrective-asset-catalog-command.ts",
|
|
c5ReceiptId: "asset_catalog-desktop",
|
|
c5MutationReceiptId: "asset_catalog-wasm",
|
|
},
|
|
];
|
|
|
|
const c5ReportPath = "tests/golden/corrective/C5-002/chromium-family-report.json";
|
|
const c5ManifestPath = "tests/golden/corrective/C5-002/manifest.json";
|
|
const c5SecondReportPath = "tests/golden/corrective/C5-002/chromium-family-report.second.json";
|
|
const c5Manifest = readJson(c5ManifestPath);
|
|
const c5 = readJson(c5ReportPath);
|
|
assert.equal(c5Manifest.status, "done");
|
|
assert.equal(c5Manifest.artifacts?.find((artifact) => artifact.path === c5ReportPath)?.sha256, sha256(c5ReportPath));
|
|
assert.equal(sha256(c5SecondReportPath), sha256(c5ReportPath), "C5 family report is not deterministic");
|
|
assert.equal(c5.browser, "chromium");
|
|
assert.equal(c5.queueMutation, false);
|
|
|
|
function exactSource(source) {
|
|
const manifest = readJson(`tests/golden/${source.task}/manifest.json`);
|
|
const report = readJson(source.report);
|
|
const desktop = readJson(source.desktopReport);
|
|
assert.equal(manifest.status, "done", `${source.task} is not complete`);
|
|
assert.equal(report.schemaVersion, 1);
|
|
assert.equal(report.desktop?.status, "EXACT");
|
|
assert.equal(report.wasm?.status, "EXACT");
|
|
assert.equal(report.saveReopen ?? report.wasm?.saveReopen ?? report.desktop?.saveReopen, "EXACT");
|
|
assert.equal(desktop.saveReopen, "EXACT");
|
|
assert.ok(report.negative && Object.keys(report.negative).length > 0, `${source.task} has no negative evidence`);
|
|
const boundReport = manifest.artifacts?.report;
|
|
assert.ok(boundReport && boundReport.path === source.report);
|
|
assert.equal(sha256(source.report), boundReport.sha256, `${source.task} report hash drift`);
|
|
const boundDesktop = manifest.artifacts?.desktopReport;
|
|
assert.ok(boundDesktop && boundDesktop.path === source.desktopReport);
|
|
assert.equal(sha256(source.desktopReport), boundDesktop.sha256, `${source.task} desktop report hash drift`);
|
|
return {
|
|
sourceTask: source.task,
|
|
sourceManifest: {
|
|
path: `tests/golden/${source.task}/manifest.json`,
|
|
sha256: sha256(`tests/golden/${source.task}/manifest.json`),
|
|
},
|
|
fixture: report.fixture ?? null,
|
|
desktopPositive: {
|
|
status: report.desktop.status,
|
|
report: source.desktopReport,
|
|
reportSha256: sha256(source.desktopReport),
|
|
semanticOperation: report.operation,
|
|
},
|
|
wasmMutation: {
|
|
status: report.wasm.status,
|
|
report: source.report,
|
|
reportSha256: sha256(source.report),
|
|
revision: {
|
|
initial: report.wasm.initialRevision ?? report.wasm.revision ?? null,
|
|
final: report.wasm.finalRevision ?? report.wasm.mutatedRevision ?? null,
|
|
},
|
|
},
|
|
saveReopenExact: {
|
|
status: "EXACT",
|
|
desktop: report.desktop.saveReopen ?? "EXACT",
|
|
wasm: report.wasm.saveReopen ?? report.saveReopen ?? "EXACT",
|
|
},
|
|
negativeMatrix: report.negative,
|
|
};
|
|
}
|
|
|
|
const families = sources.map((source) => ({
|
|
family: source.family,
|
|
capabilityIds: source.capabilityIds,
|
|
protocol: {
|
|
path: source.protocol,
|
|
sha256: sha256(source.protocol),
|
|
},
|
|
c5Candidate: {
|
|
desktopReceiptId: source.c5ReceiptId,
|
|
wasmReceiptId: source.c5MutationReceiptId,
|
|
desktop: c5.results.find((result) => result.id === source.c5ReceiptId)?.receipt?.result ?? null,
|
|
wasm: c5.results.find((result) => result.id === source.c5MutationReceiptId)?.receipt?.result ?? null,
|
|
browser: c5.browser,
|
|
queueMutation: c5.queueMutation,
|
|
status: "PROTOCOL_CANDIDATE",
|
|
},
|
|
evidence: exactSource(source),
|
|
evidenceState: "EXACT_REUSED_FROM_WBV2",
|
|
featureParityEligible: false,
|
|
featureParityReason: "C5 Chromium receipt is protocol-only; production family interaction and atomic manifest are still required.",
|
|
}));
|
|
|
|
for (const family of families) {
|
|
assert.equal(family.evidence.desktopPositive.status, "EXACT");
|
|
assert.equal(family.evidence.wasmMutation.status, "EXACT");
|
|
assert.equal(family.evidence.saveReopenExact.status, "EXACT");
|
|
}
|
|
|
|
const report = {
|
|
schemaVersion: 1,
|
|
task: "WBV2-P7-003",
|
|
operation: "C5_FAMILY_EVIDENCE_INTEGRATION",
|
|
queueMutation: false,
|
|
browser: "chromium",
|
|
evidencePolicy: {
|
|
historicalC5ReadOnly: true,
|
|
sourceReportsReadOnly: true,
|
|
featureParityClaims: 0,
|
|
canonicalOrder: ["desktopPositive", "wasmMutation", "saveReopenExact"],
|
|
},
|
|
families,
|
|
meshProgression: {
|
|
family: "MESH",
|
|
order: ["desktopPositive", "wasmMutation", "saveReopenExact"],
|
|
allThreeExact: true,
|
|
sourceTask: "WBV2-P2-003",
|
|
nextAction: "manifest-backed atomic successor required before queue activation",
|
|
},
|
|
summary: {
|
|
familyCount: families.length,
|
|
exactReused: families.filter((family) => family.evidenceState === "EXACT_REUSED_FROM_WBV2").length,
|
|
featureParityEligible: families.filter((family) => family.featureParityEligible).length,
|
|
productionChromiumReady: 0,
|
|
},
|
|
sourceHashes: Object.fromEntries([
|
|
[c5ManifestPath, sha256(c5ManifestPath)],
|
|
[c5ReportPath, sha256(c5ReportPath)],
|
|
...sources.flatMap((source) => [
|
|
[`tests/golden/${source.task}/manifest.json`, sha256(`tests/golden/${source.task}/manifest.json`)],
|
|
[source.report, sha256(source.report)],
|
|
[source.desktopReport, sha256(source.desktopReport)],
|
|
[source.protocol, sha256(source.protocol)],
|
|
]),
|
|
]),
|
|
};
|
|
|
|
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
|
|
fs.writeFileSync(outputPath, `${JSON.stringify(report, null, 2)}\n`, "utf8");
|
|
process.stdout.write(`family-evidence-ok task=${report.task} families=${families.length} exactReused=${report.summary.exactReused} meshSequence=desktopPositive,wasmMutation,saveReopenExact queueMutation=false output=${relative(outputPath)}\n`);
|