import { failureFingerprint } from "./failure-fingerprint.js"; import { guardedExec } from "./guarded-exec.js"; import type { VerificationPlan, VerificationResult } from "../types.js"; export async function verify(plan: VerificationPlan, cwd: string): Promise { const results: VerificationResult[] = []; for (const check of plan.checks) { const execution = await guardedExec(check.command, cwd, check.timeoutMs); const passed = execution.exitCode === check.expectedExitCode && !execution.timedOut; const result: VerificationResult = { checkId: check.id, passed, command: check.command, exitCode: execution.exitCode, durationMs: execution.durationMs, stdout: execution.stdout.slice(-16_000), stderr: execution.stderr.slice(-16_000), ...(passed ? {} : { fingerprint: failureFingerprint(check.command, execution.stdout, execution.stderr) }) }; results.push(result); if (!passed && check.required) break; } return results; } export function isVerified(results: VerificationResult[]): boolean { return results.length > 0 && results.every((result) => result.passed); }