/** * Shared owner for the workbench surface audit coverage rule. * * The record count is not a constant: it is modules x viewports. * tools/ui-workbench-surface-audit.mjs scrapes module names out of * web/src/module-registry.generated.ts and iterates two viewports, so removing a * module changes the expected count (OpenSCAD removal moved 32x2=64 to 31x2=62). * Every gate that used to hard-assert 64 must ask here instead. */ /** Derive the covered/expected matrix from an audit snapshot. */ export function auditCoverage(snapshot) { const records = Array.isArray(snapshot?.records) ? snapshot.records : []; const modules = new Set(records.map(record => record?.module)).size; const viewports = new Set(records.map(record => record?.viewport?.name)).size; return { modules, viewports, expected: modules * viewports, actual: records.length }; } /** True when the snapshot covers every module x viewport pair exactly once. */ export function auditCoverageComplete(snapshot) { const { modules, viewports, expected, actual } = auditCoverage(snapshot); return modules > 0 && viewports > 0 && expected === actual; } /** * Success test for a downstream audit64 summary. * * Accepts both freshly produced evidence (records=62, expectedRecords=62) and * historical evidence captured before the module removal (records=64, expected * unset or 64): each snapshot is judged against its own coverage rather than a * frozen constant, so previously verified evidence is not reclassified as a * regression. */ export function audit64Satisfied(summary) { if (!summary || summary.status !== "passed") return false; if ((summary.failures ?? 0) !== 0) return false; if (summary.expectedRecords != null && summary.records !== summary.expectedRecords) return false; return true; }