// storage/hash-snapshot-store.ts — Persistence for spec hash snapshots
// Stores snapshots in data/projects/{hash}/spec-hashes/{specId}.json
// Append-only: old snapshots are archived, not deleted.
import { projectDataDir, readJson, writeJson } from './base-store.js';
/**
 * Get the file path for a spec's hash snapshot.
 */
function snapshotPath(projectId, specId) {
    return `${projectDataDir(projectId)}/spec-hashes/${specId}.json`;
}
/**
 * Get the file path for a spec's reconcile log.
 */
function reconcileLogPath(projectId, specId) {
    return `${projectDataDir(projectId)}/spec-hashes/${specId}-reconcile-log.json`;
}
/**
 * Load a spec's hash snapshot. Returns null if not found.
 */
export async function getSnapshot(projectId, specId) {
    return readJson(snapshotPath(projectId, specId), null);
}
/**
 * Save a spec's hash snapshot.
 */
export async function saveSnapshot(projectId, specId, snapshot) {
    await writeJson(snapshotPath(projectId, specId), snapshot);
}
/**
 * Load reconcile log entries for a spec.
 */
export async function getReconcileLog(projectId, specId) {
    return readJson(reconcileLogPath(projectId, specId), []);
}
/**
 * Append entries to the reconcile log for a spec.
 */
export async function appendReconcileLog(projectId, specId, entries) {
    const existing = await getReconcileLog(projectId, specId);
    existing.push(...entries);
    await writeJson(reconcileLogPath(projectId, specId), existing);
}
//# sourceMappingURL=hash-snapshot-store.js.map