/** * Reads completed loop records from ~/.martin/runs/ for analysis. * Used by the Trust Calibration Engine and other offline analytics. * * Supports both storage layouts: * - legacy root JSONL files: /*.jsonl * - canonical run trees: //loop-record.json */ import type { CostProvenance } from "../../contracts/index.js"; export interface LoopAttemptRecord { index: number; model?: string; adapterId?: string; failureClass?: string; intervention?: string; startedAt?: string; completedAt?: string; } export interface LoopRunRecord { loopId: string; status: string; lifecycleState: string; createdAt: string; updatedAt: string; budget: { maxUsd: number; softLimitUsd: number; maxIterations: number; maxTokens: number; }; cost: { actualUsd: number; tokensIn: number; tokensOut: number; avoidedUsd?: number; provenance?: CostProvenance; }; attempts: LoopAttemptRecord[]; task: { title: string; objective: string; }; } export interface LoopRecordsRollup { generatedAt: string; totalRuns: number; statusBreakdown: Record; lifecycleBreakdown: Record; latestByLoopId: Record; } export declare function readLoopRecordsFromFile(file: string): Promise; export declare function readLatestLoopRecordFromFile(file: string): Promise; /** * Reads all loop records from the given directory (default: ~/.martin/runs/). * Returns an empty array if the directory doesn't exist or has no records. */ export declare function readAllLoopRecords(runsDir?: string): Promise; /** * Returns the most recently updated loop record, or null if none exist. */ export declare function readLatestLoopRecord(runsDir?: string): Promise; export declare function buildLoopRecordsRollup(records: LoopRunRecord[]): LoopRecordsRollup;