export declare const RECORD_FORMAT: 1; export declare const RECORD_KINDS: readonly ["binding", "capability", "lifecycle", "approval", "lease", "check", "fact", "work", "control", "experiment", "activity", "advice"]; export type RecordKind = (typeof RECORD_KINDS)[number]; export declare const LEDGER_DAMAGED: "LEDGER_DAMAGED"; export interface RecordEnvelope { v: typeof RECORD_FORMAT; seq: number; prev: string | null; at: string; kind: RecordKind; id: string; body: B; /** Present when the record was copied from a pre-format store; the original is left untouched. */ imported?: { path: string; line: number; }; digest: string; } export interface RecordDamage { line: number; reason: string; } export interface ReadRecords { records: RecordEnvelope[]; damage: RecordDamage | null; } /** Deterministic JSON: sorted object keys at every level, arrays in order. No `undefined` survives. */ export declare function canonicalJson(value: unknown): string; export declare function recordDigest(record: object): string; /** Damage reasons that mean "this is not a record file at all" rather than "a record file with a torn tail". */ export declare const PRE_FORMAT_REASONS: ReadonlySet; /** Read every intact record before the first damaged line. Never throws on content; damage is data. */ export declare function readRecords(text: string): ReadRecords; export declare function readRecordsFile(path: string): Promise>; export interface AppendOptions { id?: string; at?: string; imported?: { path: string; line: number; }; } /** Append one record under the file lock. Refuses LEDGER_DAMAGED when the tail is torn or invalid. */ export declare function appendRecord(path: string, kind: RecordKind, body: B, options?: AppendOptions): Promise>; export interface RepairResult { /** The raw lines that were (or would be) dropped, in file order. */ dropped: string[]; /** Where the intact prefix ends, 1-based line count. */ keptLines: number; /** How many dropped lines still parse as JSON objects: a tampered middle, not a torn tail. */ droppedParseable: number; /** True when the file is not a record file at all (a pre-format ledger); nothing is ever truncated then. */ preFormat: boolean; /** True when there was no file. */ missing: boolean; } /** * Drop everything from the first damaged line on. `apply: false` previews. The repair never rewrites an * intact record and never invents one; it only truncates, and only after the caller decided to. */ export declare function repairLedger(path: string, options: { apply: boolean; }): Promise; //# sourceMappingURL=record.d.ts.map