/** * Snapshot store with atomic writes and per-instance namespaces. * * All instance state lives under `.aidlc/state//`: * - `instance.yaml` — instance metadata * - `phase-.yaml` — per-phase state (one per applicable phase) * * Write semantics: * - Snapshot files use write-to-tmp + rename for atomicity (Req 23.5). * Readers never observe partial writes. * - Instance directories are fully isolated — edits to one instance * never touch another instance's files (Req 23.1, 23.3, 6.1). * * Requirements: 4.1, 6.1, 23.1, 23.3, 23.5 */ import type { SchemaValidator } from './yaml-helpers.js'; /** * Write content to a file atomically using tmp-file + rename. * * 1. Write to `.tmp.` — unique per process, avoids collisions. * 2. Rename the tmp file to the target path — atomic on POSIX filesystems. * * Parent directories are created if they don't exist. */ export declare function atomicWrite(filePath: string, content: string): void; /** * Compute the absolute directory path for an instance namespace. * * @param stateDir - Root state directory (e.g., `/project/.aidlc/state`). * @param instance - Instance name (URL-safe directory name). * @returns Absolute path: `//`. */ export declare function instancePath(stateDir: string, instance: string): string; /** * Create the namespace directory for a new lifecycle instance. * * @param stateDir - Root state directory. * @param name - Instance name. * @returns The absolute path to the created directory. */ export declare function createInstanceDir(stateDir: string, name: string): string; /** * List all instance namespace directories under the state root. * * Returns an array of instance names (directory basenames). * Only directories are included — stray files at the state root are ignored. * * @param stateDir - Root state directory. * @returns Array of instance names (directory names). */ export declare function listInstanceDirs(stateDir: string): string[]; /** * Save a snapshot file atomically within an instance namespace. * * Serializes `data` to deterministic YAML and writes it using * tmp-file + rename to guarantee atomic writes (Req 23.5). * * @param stateDir - Root state directory. * @param instance - Instance name. * @param fileName - File name within the instance directory (e.g., `instance.yaml`). * @param data - Data to serialize and persist. */ export declare function saveSnapshot(stateDir: string, instance: string, fileName: string, data: unknown): void; /** * Load and parse a snapshot file from an instance namespace. * * Optionally validates the parsed data using a schema validator. * Throws `YamlLoadError` on missing files, parse errors, or validation failures * — always naming the file in the error message (Req 4.7). * * @param stateDir - Root state directory. * @param instance - Instance name. * @param fileName - File name within the instance directory. * @param validate - Optional schema validator. * @returns The parsed (and validated) data cast to `T`. * @throws {YamlLoadError} If the file is missing, corrupt, or fails validation. */ export declare function loadSnapshot(stateDir: string, instance: string, fileName: string, validate?: SchemaValidator): T; //# sourceMappingURL=snapshot-store.d.ts.map