feat(web): reuse verified source dependencies
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

This commit is contained in:
mes123456
2026-09-03 13:50:55 +08:00
parent c3cce050f8
commit c334bb1437
28 changed files with 8504 additions and 70 deletions

View File

@@ -16,15 +16,13 @@ const arg = (name, fallback = null) => {
const task = arg("--task");
if (!task) throw new Error("usage: node tools/web/bind-wbv2-module-coverage.mjs --task <task-id>");
const manifestPath = `tests/golden/${task}/manifest.json`;
const productionPath = arg("--production", `tests/golden/${task}/modifier-reader-batch-production.json`);
const manifest = json(manifestPath);
assert.equal(manifest.status, "done");
const moduleRecord = Object.values(json("tests/golden/WBV2-P1100-000/module-execution-plan.json").tasks ?? {})
.find((candidate) => candidate.id === task);
const planPath = manifest.artifacts.plan.path;
const plan = json(planPath);
const taskRecord = plan.tasks.find((candidate) => candidate.id === task);
const module = taskRecord?.module;
const productionPath = arg("--production", module?.evidencePaths?.[0] ?? `tests/golden/${task}/modifier-reader-batch-production.json`);
const requestedUnits = (arg("--units") ?? "").split(",").map((value) => value.trim()).filter(Boolean);
const coverageBindings = requestedUnits.length > 0 ? requestedUnits : module?.coverageBindings ?? [];
const capabilityId = module?.moduleId ?? arg("--capability", task);
@@ -35,21 +33,38 @@ assert.equal(production.queueMutation, false);
const inventoryPath = "tests/golden/WBV2/dynamic-inventory.json";
const inventory = json(inventoryPath);
const fixturePaths = Array.isArray(production.fixtures) ? production.fixtures : production.fixture ? [production.fixture] : [];
assert.ok(fixturePaths.length, "production evidence has no fixture(s)");
const fixtureEvidence = Array.isArray(production.fixtures)
? fixturePaths.map((fixture) => production[fixture])
: [production];
for (const evidence of fixtureEvidence) {
assert.ok(evidence && typeof evidence === "object", "fixture result is missing");
assert.equal(evidence.error, undefined);
assert.equal(evidence.saveReopenExact, true);
assert.equal(evidence.deterministicExact, true);
}
if (Array.isArray(production.fixtures)) {
assert.equal(typeof production.fixtureSha256, "object");
for (const fixture of fixturePaths) assert.equal(production.fixtureSha256[fixture], sha(fixture), `fixture hash drift: ${fixture}`);
const validateEvidence = (evidencePath) => {
const evidence = json(evidencePath);
assert.equal(evidence.browser, "chromium");
assert.equal(evidence.queueMutation, false);
const paths = Array.isArray(evidence.fixtures) ? evidence.fixtures : evidence.fixture ? [evidence.fixture] : [];
assert.ok(paths.length, `production evidence has no fixture(s): ${evidencePath}`);
const entries = Array.isArray(evidence.fixtures) ? paths.map((fixture) => evidence[fixture]) : [evidence];
for (const entry of entries) {
assert.ok(entry && typeof entry === "object", "fixture result is missing");
assert.equal(entry.error, undefined);
if (entry.saveReopenExact !== undefined) assert.equal(entry.saveReopenExact, true);
if (entry.deterministicExact !== undefined) assert.equal(entry.deterministicExact, true);
if (entry.exact !== undefined) assert.equal(entry.exact, true);
}
if (Array.isArray(evidence.fixtures)) {
assert.equal(typeof evidence.fixtureSha256, "object");
for (const fixture of paths) assert.equal(evidence.fixtureSha256[fixture], sha(fixture), `fixture hash drift: ${fixture}`);
} else {
assert.equal(evidence.fixtureSha256, sha(evidence.fixture));
}
return evidence;
};
if (production.reusedEvidence?.length) {
assert.ok(production.dependencyProofs?.length, "dependency reuse evidence has no proofs");
for (const evidence of production.reusedEvidence) {
assert.ok(evidence.path, "reused evidence path is missing");
validateEvidence(evidence.path);
assert.equal(evidence.sha256, sha(evidence.path), `reused evidence hash drift: ${evidence.path}`);
}
} else {
assert.equal(production.fixtureSha256, sha(production.fixture));
assert.ok(fixturePaths.length, "production evidence has no fixture(s)");
validateEvidence(productionPath);
}
const bindingsPath = "tests/golden/WBV2/dynamic-coverage-bindings.json";
const existing = fs.existsSync(abs(bindingsPath)) ? json(bindingsPath) : [];