fix: bind performance evidence to production resources

This commit is contained in:
2026-09-02 08:53:00 +03:00
parent 5b7e47c2a2
commit e3ac3a4db4
23 changed files with 642 additions and 60 deletions

View File

@@ -1,11 +1,14 @@
import { verifySignedReferenceRun } from './reference-evidence.mjs';
const median = (values) => {
if (values.length === 0) throw new Error('At least one value is required.');
const sorted = [...values].sort((left, right) => left - right);
return sorted[Math.floor(sorted.length / 2)];
};
export const aggregateFiveDriveTraces = (runs) => {
export const aggregateFiveDriveTraces = (runs, trustPolicy) => {
if (!Array.isArray(runs) || runs.length !== 5) throw new Error('Exactly five drive-trace.v1 runs are required.');
for (const run of runs) verifySignedReferenceRun(run, trustPolicy);
const profile = runs[0]?.profile;
if (typeof profile !== 'string' || runs.some((run) => run?.schema !== 'drive-trace.v1' || run.profile !== profile)) {
throw new Error('All runs must use one drive-trace.v1 profile.');