fix: require runtime evidence in budget gate
This commit is contained in:
@@ -10,13 +10,16 @@ import {
|
||||
classifyArtifact,
|
||||
evaluateBudgetTotals,
|
||||
evaluateMediaAssetBudget,
|
||||
resolveBudgetGateMode,
|
||||
validateRuntimeBudgetTraceReport,
|
||||
} from './lib/bundle-budgets.mjs';
|
||||
|
||||
const root = resolve(process.argv[2] ?? 'dist');
|
||||
const transferOnly = process.argv.includes('--transfer-only');
|
||||
const runtimeTraceIndex = process.argv.indexOf('--runtime-trace');
|
||||
const runtimeTracePath = runtimeTraceIndex === -1 ? null : process.argv[runtimeTraceIndex + 1];
|
||||
if (runtimeTraceIndex !== -1 && runtimeTracePath === undefined) throw new Error('--runtime-trace requires one explicit drive-trace JSON path.');
|
||||
const gateMode = resolveBudgetGateMode({ transferOnly, runtimeTracePath });
|
||||
if (!(await stat(root)).isDirectory()) throw new Error('Bundle budget target must be a directory.');
|
||||
|
||||
const listFiles = async (directory) => {
|
||||
@@ -121,8 +124,8 @@ if (!/import\([^)]*environment-/u.test(entrySource)) throw new Error('The live s
|
||||
if (/WebGLRenderer|WebGLProgram|ShaderMaterial/u.test(entrySource)) throw new Error('Three.js/live-scene code leaked into the reduced-motion initial chunk.');
|
||||
|
||||
let runtime = null;
|
||||
if (runtimeTracePath !== null) {
|
||||
const trace = await readJson(resolve(runtimeTracePath), 'Runtime drive trace');
|
||||
if (gateMode.kind === 'full') {
|
||||
const trace = await readJson(resolve(gateMode.runtimeTracePath), 'Runtime drive trace');
|
||||
runtime = validateRuntimeBudgetTraceReport(trace);
|
||||
}
|
||||
const violations = [...evaluateBudgetTotals(totals).violations, ...mediaViolations, ...(runtime?.violations ?? [])];
|
||||
@@ -130,7 +133,9 @@ const report = {
|
||||
schema: 'portfolio-bundle-budget/v1',
|
||||
compression: 'brotli-quality-11-or-raw-already-compressed',
|
||||
totals,
|
||||
runtime: runtime === null ? { status: 'pending-production-path-trace' } : { status: 'verified-production-path-trace', tier: runtime.tier },
|
||||
runtime: runtime === null
|
||||
? { status: 'transfer-only-non-gating', gating: false, runtimeEvidence: 'pending' }
|
||||
: { status: 'verified-production-path-trace', gating: true, tier: runtime.tier },
|
||||
records: records.sort((left, right) => left.path.localeCompare(right.path)),
|
||||
violations,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user