/** * Decision transition ledger — append-only audit trail for every decision * status transition, in every mode. (change: add-decision-autopilot) * * One JSONL line per transition in `.openlore/decisions/ledger.jsonl`: * { id, title, from, to, actor, at, commit? } * * `from: null` marks creation (a new decision entering the store). Actors: * - 'human' — explicit approve / reject / review (CLI, TUI, MCP on behalf of a human) * - 'autopilot' — the decision autopilot auto-accepting a verified decision * - 'agent' — an agent recording a draft (record_decision) * - 'sync' — system transitions (consolidation, verification, spec sync) * * Writes are a single O_APPEND `appendFile` call per batch — atomic for the * small line sizes involved — and are deliberately fail-soft: a ledger write * failure warns on stderr and never fails the underlying store transition * (losing a trail line is bad; losing the decision write is worse). Existing * entries are never rewritten or deleted. */ import type { DecisionStatus, DecisionStore } from '../../types/index.js'; export type LedgerActor = 'human' | 'autopilot' | 'agent' | 'sync'; export interface LedgerEntry { /** 8-char decision id. */ id: string; title: string; /** Prior status; null when the decision first entered the store. */ from: DecisionStatus | null; to: DecisionStatus; actor: LedgerActor; /** ISO timestamp of the transition. */ at: string; /** HEAD commit at transition time (best-effort; absent outside a git repo). */ commit?: string; } export declare function ledgerPath(rootPath: string): string; /** * HEAD commit (short) at transition time, best-effort. During a pre-commit hook * this is the parent of the commit being created — the closest honest anchor * available before the new commit exists. Undefined outside a git repo. */ export declare function currentHeadCommit(rootPath: string): Promise; /** * Diff two store snapshots into ledger entries: one per status change, plus a * creation entry (from: null) per decision present after but not before. Pure. */ export declare function diffStoreTransitions(before: DecisionStore, after: DecisionStore, actor: LedgerActor, at: string, commit?: string): LedgerEntry[]; /** * Append entries to the ledger. Fail-soft: warns on stderr, never throws — * the store transition this trails must not be broken by a trail write fault. */ export declare function appendLedgerEntries(rootPath: string, entries: LedgerEntry[]): Promise; /** * Read the full ledger, oldest-first. Malformed lines are skipped (a torn tail * line from a crashed writer must not poison the readable history). */ export declare function readLedger(rootPath: string): Promise; //# sourceMappingURL=ledger.d.ts.map