/** * Effect ledger storage under the artifact store. * * effects// * segments/.jsonl one hash-chained segment per writer * segments/.pending a signed line awaiting append after its index claim * index/.json exclusive-create, one per effect ID (and one per outcome) * checkpoints/.json EffectCheckpoint.v1 * keyring.json EffectKeyring.v1 * index.key per-ledger key for index file names * locks/ same-host directory locks * * The root resolves only through `projectAiwgWritePath`, which fails closed when * a configured external artifact root is unavailable. Directories are 0700 and * files 0600. */ import { INDEX_SCHEMA_VERSION, type EffectPhase, type EffectScope, type EffectSubsystem } from './types.js'; export interface LedgerPaths { root: string; segments: string; index: string; checkpoints: string; locks: string; keyring: string; indexKey: string; } /** Resolve the ledger root for one subsystem. Throws exit 7 when the artifact root is unavailable. */ export declare function resolveLedgerPaths(projectDir: string, subsystem: EffectSubsystem): LedgerPaths; export declare function ensureLedgerDirectories(paths: LedgerPaths): Promise; export declare const segmentFile: (paths: LedgerPaths, writer: string) => string; /** Serialize work for one lock name across processes on this host. */ export declare function withLedgerLock(paths: LedgerPaths, name: string, timeoutMs: number, work: () => Promise): Promise; /** Writers with a segment file, sorted by writer ID. */ export declare function listWriters(paths: LedgerPaths): Promise; /** * Raw lines of one writer's segment, or null when the segment does not exist. * `torn` is true when the file does not end with a newline. */ export declare function readSegment(paths: LedgerPaths, writer: string): Promise<{ lines: string[]; torn: boolean; } | null>; /** Append one serialized line and fsync. The caller holds the writer lock. */ export declare function appendSegmentLine(paths: LedgerPaths, writer: string, line: unknown): Promise; /** Atomically replace a whole segment (purge only). The caller holds the writer lock. */ export declare function replaceSegment(paths: LedgerPaths, writer: string, lines: string[]): Promise; /** Write a 0600 file through a temporary name, fsync and rename. */ export declare function replaceFile(directory: string, file: string, contents: string): Promise; /** The per-ledger index-naming key, created once with an exclusive publish. */ export declare function loadIndexKey(paths: LedgerPaths): Promise; export type IndexRole = 'intent' | 'outcome'; /** Keyed file name, so plaintext effect IDs never appear in directory listings. */ export declare function indexName(key: Buffer, scope: EffectScope, effectId: string, role: IndexRole): string; export interface IndexEntry { schemaVersion: typeof INDEX_SCHEMA_VERSION; role: IndexRole; effectId: string; payloadDigest: string; phase: Exclude; writer: string; seq: number; recordHash: string; } export declare function readIndexEntry(paths: LedgerPaths, name: string): Promise; export declare function listIndexEntries(paths: LedgerPaths): Promise>; /** Exclusive create. Returns false when another writer already claimed the name. */ export declare function claimIndex(paths: LedgerPaths, name: string, entry: IndexEntry): Promise; export interface PendingAppend { indexName: string; line: unknown; } export declare function writePending(paths: LedgerPaths, writer: string, pending: PendingAppend): Promise; export declare function readPending(paths: LedgerPaths, writer: string): Promise; export declare function clearPending(paths: LedgerPaths, writer: string): Promise; //# sourceMappingURL=store.d.ts.map