/** * Docs Inconsistency Detector — checks that all docs stores and ledgers * agree on the canonical SHA for published documents. * * The doc storage landscape: * 1. tasks.db `attachments` table — slug, sha256, type, lifecycle_status, * supersedes/supersededBy lineage edges. * 2. tasks.db `attachment_refs` table — links attachments to owner entities * (tasks, sessions, observations, decisions, learnings, patterns). * 3. manifest.db `blob_attachments` table (CleoBlobStore / BlobFsAdapter) — * content-addressed blob store with (doc_slug, blob_name, hash) per row. * 4. Filesystem blobs at `.cleo/attachments/sha256//` (legacy) * and `.cleo/blobs/blobs/` (new via llmtxt). * * Inconsistencies detected: * - SHA mismatch between tasks.db attachments.sha256 and manifest.db * blob_attachments.hash for the same document. * - Missing filesystem blob for a SHA that should be on disk. * - Orphaned attachment_refs (refs pointing to non-existent attachment rows). * - Zero-ref attachments (attachments with no corresponding refs). * - Slug collision between different SHA rows (two rows with same slug * but different SHA — slug column UNIQUE prevents this at DB level, * but the detector double-checks). * * @task T11051 (Epic T10519 / Saga T10516 — docs storage/query consolidation) */ /** * Severity of an inconsistency finding. */ export type InconsistencySeverity = 'error' | 'warning'; /** * Category of inconsistency. */ export type InconsistencyKind = 'sha-mismatch' | 'missing-blob-filesystem' | 'missing-blob-manifest' | 'orphaned-ref' | 'zero-ref-attachment' | 'slug-disagreement' | 'blob-corrupt'; /** * A single inconsistency finding. */ export interface InconsistencyFinding { /** What kind of inconsistency was detected. */ readonly kind: InconsistencyKind; /** Severity — 'error' stops publishing, 'warning' is advisory. */ readonly severity: InconsistencySeverity; /** Human-readable description of the problem. */ readonly message: string; /** Slug of the affected document, when applicable. */ readonly slug?: string; /** Attachment ID affected, when applicable. */ readonly attachmentId?: string; /** SHA-256 hash expected by one store, when applicable. */ readonly expectedSha?: string; /** SHA-256 hash found by another store, when applicable. */ readonly actualSha?: string; /** Additional diagnostic details. */ readonly detail?: Record; } /** * Result of a full consistency check. */ export interface InconsistencyCheckResult { /** Whether the stores are fully consistent (no errors). */ readonly consistent: boolean; /** Total number of published documents checked. */ readonly docsChecked: number; /** Total number of attachments examined. */ readonly attachmentsExamined: number; /** Findings grouped by kind. */ readonly findings: InconsistencyFinding[]; /** Summary of findings by severity. */ readonly summary: { readonly errors: number; readonly warnings: number; }; } /** * Run a full consistency check across all docs stores. * * Checks: * 1. SHA agreement between attachments table and blob_attachments manifest. * 2. Filesystem blobs exist for every claimed SHA (legacy + new paths). * 3. No orphaned attachment_refs (refs to deleted attachments). * 4. No zero-ref attachments (attachments with no owner refs). * 5. No two published attachments with the same slug but different SHA. * * @param projectRoot - Absolute path to the CLEO project root. * @returns Full inconsistency check result. */ export declare function checkDocsConsistency(projectRoot?: string): Promise; /** * Synchronous, best-effort version of the consistency check. * Only checks filesystem blob existence (no DB access). * * Intended for fast pre-flight checks where opening both DBs * would be too expensive. * * @param projectRoot - Absolute path to the CLEO project root. * @param shas - Set of SHA-256 hashes to verify. * @returns List of SHAs missing from the filesystem. */ export declare function checkBlobFilesystem(projectRoot: string, shas: ReadonlySet): { missing: string[]; legacy: string[]; new: string[]; }; //# sourceMappingURL=docs-inconsistency-detector.d.ts.map