/** * Append-only, content-addressed storage for run artifacts * (mmnto-ai/totem#2100). Layout: `/artifacts/runs/.json`, * where `` is the sha256 of the artifact's canonical serialization * EXCLUDING `createdAt` — identical runs dedup to one record regardless of * when they ran, and a rerun NEVER mutates a prior record (write-if-absent). * * The directory is machine-local state (gitignored alongside * `.totem/cache/`); growth is bounded per-run and pruning is a future verb, * deliberately not this slice. * * Reads go through `readJsonSafe` + `RunArtifactSchema` so a corrupted or * wrong-major artifact is a loud `TotemParseError`, never a silent partial * (Tenet 4). Version tolerance within the major + the migration-on-read * registry implement the F1 evolution policy from the #2100 design review. */ import type { InvocationFailureArtifact, RunArtifact } from './schema.js'; /** Absolute runs directory for a given absolute totem dir. */ export declare function runsDir(totemDirAbs: string): string; /** Absolute terminal-invocation failure directory for a given absolute totem dir. */ export declare function failureRunsDir(totemDirAbs: string): string; /** * Content address of an artifact: deterministic hash over everything EXCEPT * `createdAt` (observability, not identity — see schema docstring). */ export declare function computeRunArtifactContentHash(artifact: RunArtifact): string; export interface SaveRunArtifactResult { /** The content address (= filename stem). */ hash: string; /** Absolute path of the stored artifact. */ path: string; /** True when an identical logical run was already recorded (no write happened). */ existed: boolean; } /** Content address of a terminal failure artifact, excluding emission time. */ export declare function computeInvocationFailureArtifactContentHash(artifact: InvocationFailureArtifact): string; export interface SaveInvocationFailureArtifactResult { /** The content address (= filename stem). */ hash: string; /** Absolute path of the stored artifact. */ path: string; /** True when an identical logical failure was already recorded. */ existed: boolean; } /** * Persist an artifact at its content address, write-if-absent. An existing * file is NEVER rewritten: same hash ⇒ same logical content by construction, * and the original record (including its `createdAt`) is the durable one — * append-only means the FIRST write wins forever. */ export declare function saveRunArtifact(totemDirAbs: string, artifact: RunArtifact): SaveRunArtifactResult; /** * Persist a terminal invocation failure at its content address. As with * successful run artifacts, atomic create-exclusive makes the ledger * append-only and the first write (including its `createdAt`) wins. */ export declare function saveInvocationFailureArtifact(totemDirAbs: string, artifact: InvocationFailureArtifact): SaveInvocationFailureArtifactResult; /** * Load + validate an artifact by content address. Throws `TotemParseError` * on a missing file, corrupt JSON, or schema violation (including an unknown * major with no migration entry) — loud, never a silent partial. */ export declare function loadRunArtifact(totemDirAbs: string, hash: string): RunArtifact; /** Load and validate a terminal invocation failure by content address. */ export declare function loadInvocationFailureArtifact(totemDirAbs: string, hash: string): InvocationFailureArtifact; //# sourceMappingURL=storage.d.ts.map