import { serializeProofList } from './proof-serializer.js';
export function serializeRun(run) {
    if (!run || typeof run !== 'object') {
        return run ?? null;
    }
    return {
        ...run,
        proofs: serializeProofList(run.proofs),
    };
}
export function serializeRuns(runs) {
    return Array.isArray(runs) ? runs.map((run) => serializeRun(run)) : [];
}
export function serializeGateTimeline(latestRun) {
    if (Array.isArray(latestRun?.plannerState?.reviewGates)) {
        return latestRun.plannerState.reviewGates;
    }
    if (Array.isArray(latestRun?.plannerResult?.reviewGates)) {
        return latestRun.plannerResult.reviewGates;
    }
    return [];
}
export function serializeParallelism(snapshot, runtime) {
    return {
        totalWorkers: Number(snapshot?.workerPlan?.totalWorkers ?? runtime?.getUsageSnapshot?.()?.workerPlan?.totalWorkers ?? 0),
        lanes: snapshot?.workerPlan?.lanes ?? runtime?.getUsageSnapshot?.()?.workerPlan?.lanes ?? [],
    };
}
export function serializeSelectionAudit(usage) {
    return usage?.artifactSelectionAudit ?? { selected: [], rejected: [], summary: 'No selection audit recorded yet.' };
}
