/** * Flow Store - State persistence layer for Ralph Loop Runner * * Persists run state to `.ai-eng/runs//.flow/`: * - state.json: Main run state * - checkpoint.json: Last successful checkpoint for fast resume * - iterations/.json: Per-cycle detailed outputs * - contexts/.md: Re-anchoring context snapshots * - gates/.json: Quality gate results */ import type { Checkpoint, CycleState, FlowState } from "./flow-types"; import { RunStatus, type StopReason } from "./flow-types"; /** Flow store options */ export interface FlowStoreOptions { flowDir: string; runId: string; } /** * Flow Store - manages persistence of loop run state */ export declare class FlowStore { private flowDir; private runId; constructor(options: FlowStoreOptions); /** Get the base flow directory path */ get basePath(): string; /** Get path to a specific file in .flow */ private path; /** Initialize flow directory structure */ initialize(): Promise; /** Check if flow state exists (for resume) */ exists(): boolean; /** Load existing run state for resume */ load(): Promise; /** Create initial run state */ createInitialState(options: { prompt: string; completionPromise: string; maxCycles: number; stuckThreshold: number; gates: string[]; }): Promise; /** Save run state to state.json */ saveState(state: FlowState): Promise; /** Save a checkpoint for fast resume */ saveCheckpoint(state: FlowState, lastPhaseOutputs: CycleState["phases"]): Promise; /** Load checkpoint for resume */ loadCheckpoint(): Promise; /** Save iteration cycle output */ saveIteration(cycle: CycleState): Promise; /** Save gate results for iteration */ saveGateResults(cycleNumber: number, results: CycleState["gateResults"]): Promise; /** Generate re-anchoring context content for a cycle */ private generateContextContent; /** Get iteration by number */ getIteration(cycleNumber: number): Promise; /** Get all iterations */ getAllIterations(): Promise; /** Update state status */ updateStatus(status: RunStatus, stopReason?: StopReason, error?: string): Promise; /** Increment cycle counter */ incrementCycle(): Promise; /** Record a failed cycle */ recordFailedCycle(cycle: CycleState): Promise; /** Record a successful cycle */ recordSuccessfulCycle(cycle: CycleState, summary: string): Promise; /** Clean up flow directory */ cleanup(): Promise; }