perf(web): enforce batch-scoped source inventory checks
This commit is contained in:
@@ -12,16 +12,18 @@ const sha = (file) => crypto.createHash("sha256").update(fs.readFileSync(abs(fil
|
||||
const argIndex = process.argv.indexOf("--task");
|
||||
const task = argIndex >= 0 ? process.argv[argIndex + 1] : null;
|
||||
if (!task) throw new Error("usage: node tools/web/finalize-wbv2-module-batch.mjs --task <task-id>");
|
||||
const fullInventoryAudit = process.argv.includes("--full-inventory") || process.env.WBV2_FULL_SOURCE_AUDIT === "1";
|
||||
const manifestPath = `tests/golden/${task}/manifest.json`;
|
||||
const manifest = json(manifestPath);
|
||||
const receiptPath = manifest.artifacts.moduleReceipt.path;
|
||||
const statusPath = manifest.artifacts.status.path;
|
||||
const inventory = json("tests/golden/WBV2/dynamic-inventory.json");
|
||||
const verifiedUnits = inventory.coverage.verifiedUnits;
|
||||
const unverifiedUnits = inventory.coverage.unverifiedUnits;
|
||||
const taskPlan = json(manifest.artifacts.plan.path);
|
||||
const taskRecord = taskPlan.tasks.find((candidate) => candidate.id === task);
|
||||
const bindingDelta = taskRecord?.module?.coverageBindings?.length ?? 0;
|
||||
execFileSync(process.execPath, [abs("tools/web/bind-wbv2-module-coverage.mjs"), "--task", task], { cwd: root, stdio: "inherit" });
|
||||
const inventory = json("tests/golden/WBV2/dynamic-inventory.json");
|
||||
const verifiedUnits = inventory.coverage.verifiedUnits;
|
||||
const unverifiedUnits = inventory.coverage.unverifiedUnits;
|
||||
const receipt = json(receiptPath);
|
||||
if (receipt.inventory?.dynamic) {
|
||||
receipt.inventory.dynamic.verifiedUnits = verifiedUnits;
|
||||
@@ -39,8 +41,9 @@ for (const artifact of Object.values(manifest.artifacts ?? {})) {
|
||||
manifest.assertions.dynamicVerifiedUnits = verifiedUnits;
|
||||
manifest.assertions.dynamicUnverifiedUnits = unverifiedUnits;
|
||||
write(manifestPath, manifest);
|
||||
execFileSync(process.execPath, [abs("tools/web/bind-wbv2-module-coverage.mjs"), "--task", task], { cwd: root, stdio: "inherit" });
|
||||
execFileSync(process.execPath, [abs("tools/web/generate-source-dynamic-inventory.mjs"), "--output", abs("tests/golden/WBV2/dynamic-inventory.json")], { cwd: root, stdio: "inherit" });
|
||||
if (fullInventoryAudit) {
|
||||
execFileSync(process.execPath, [abs("tools/web/generate-source-dynamic-inventory.mjs"), "--output", abs("tests/golden/WBV2/dynamic-inventory.json")], { cwd: root, stdio: "inherit" });
|
||||
}
|
||||
const inventoryPath = "tests/golden/WBV2/dynamic-inventory.json";
|
||||
const checkReportPath = "tests/golden/WBV2/dynamic-inventory-check-report.json";
|
||||
const inventoryManifestPath = "tests/golden/WBV2/dynamic-inventory-manifest.json";
|
||||
@@ -51,10 +54,12 @@ const auditPath = "tests/golden/WBV2/dynamic-coverage-audit.json";
|
||||
// Bind the newly generated inventory and the previous report first, then run
|
||||
// the checker once, and finally bind the report it produced.
|
||||
const inventoryManifest = json(inventoryManifestPath);
|
||||
inventoryManifest.artifacts.checker.sha256 = sha("tools/web/check-source-dynamic-inventory.mjs");
|
||||
inventoryManifest.artifacts.inventory.sha256 = sha(inventoryPath);
|
||||
inventoryManifest.artifacts.report.sha256 = sha(checkReportPath);
|
||||
write(inventoryManifestPath, inventoryManifest);
|
||||
execFileSync(process.execPath, [abs("tools/web/check-source-dynamic-inventory.mjs")], { cwd: root, stdio: "inherit" });
|
||||
const inventoryCheckArgs = fullInventoryAudit ? [] : ["--task", task];
|
||||
execFileSync(process.execPath, [abs("tools/web/check-source-dynamic-inventory.mjs"), ...inventoryCheckArgs], { cwd: root, stdio: "inherit" });
|
||||
const refreshedInventoryManifest = json(inventoryManifestPath);
|
||||
refreshedInventoryManifest.artifacts.inventory.sha256 = sha(inventoryPath);
|
||||
refreshedInventoryManifest.artifacts.report.sha256 = sha(checkReportPath);
|
||||
@@ -66,4 +71,4 @@ coverageManifest.artifacts.bindings.sha256 = sha(bindingsPath);
|
||||
coverageManifest.artifacts.report.sha256 = sha(auditPath);
|
||||
coverageManifest.coverage = { ...coverageManifest.coverage, unitCount: inventory.summary.unitCount, verifiedUnits, unverifiedUnits, sourceTreeSha256: inventory.authority.sourceTreeSha256 };
|
||||
write(coverageManifestPath, coverageManifest);
|
||||
process.stdout.write(`wbv2-module-batch-finalized task=${task} verified=${verifiedUnits} unverified=${unverifiedUnits}\n`);
|
||||
process.stdout.write(`wbv2-module-batch-finalized task=${task} verified=${verifiedUnits} unverified=${unverifiedUnits} inventoryAudit=${fullInventoryAudit ? "full" : "batch"}\n`);
|
||||
|
||||
Reference in New Issue
Block a user