/** * Ledger persistence — implements `vines/spec.md` §4.1. * * One row per orchestration in `orchestration_ledger`. Linear stores the * canonical sub-task state; this ledger only records *which orchestrations * exist* and their coarse lifecycle state. Recovery (§4.2) cross-references * Linear to find the resume point. * * Connection management uses the official `mariadb` driver's pool so that * idle connections don't leak when the orchestrator runs as a long-lived * agent. */ import { type DBConfig } from "./config.js"; import { type LedgerState, type OrchestrationRow } from "./types.js"; /** * Persistence layer for the orchestration ledger. * * @example * ```ts * const ledger = Ledger.fromEnv(); * const id = await ledger.create({ objectiveSummary: "Stand up monitoring stack" }); * await ledger.setState(id, "executing", { lastAgentActive: "system-agent" }); * await ledger.close(); * ``` */ export declare class Ledger { readonly config: DBConfig; private readonly pool; private closed; constructor(config: DBConfig); /** Build a {@link Ledger} from the spec §5 env vars. */ static fromEnv(): Ledger; /** Release all pool resources. Idempotent. */ close(): Promise; /** * Insert a ledger row. Returns the orchestration id (a UUID v4 by default; * callers can pass an explicit one for deterministic tests / external * correlation). */ create(args: { objectiveSummary: string; linearParentId?: string | null; state?: LedgerState; lastAgentActive?: string | null; orchestrationId?: string; }): Promise; /** Fetch one row by id. Returns null if absent. */ get(orchestrationId: string): Promise; /** Update state. When `lastAgentActive` is provided it's persisted too. */ setState(orchestrationId: string, state: LedgerState, opts?: { lastAgentActive?: string | null; }): Promise; /** Attach (or update) the Linear parent id after creation. */ attachLinearParent(orchestrationId: string, linearParentId: string): Promise; /** * All rows in an unfinished state (init | planning | executing), ordered by * `updated_at` ascending. Recovery (§4.2) iterates this list. */ listUnfinished(): Promise; /** Recent rows for the `vines status` CLI / dashboards. */ listRecent(limit?: number): Promise; /** Hand a connection to `fn`, releasing it back to the pool on exit. */ private run; } //# sourceMappingURL=persistence.d.ts.map