/** * CatalogRepo — SQLite-backed graph catalog at parity with v1's * single-JSON-file shape. * * v1 stored the catalog as `/cache/graph/catalog.json`. v2 * stores it in `graph_catalog` row 1, lifting the cache-validity * fields (language, cacheKey, filesFingerprint) into typed columns so * the orchestrator can fingerprint-mismatch without parsing the full * payload. The catalog perf follow-up plan normalizes the payload * into per-function/occurrence/edge tables and pushes dashboard view * derivations into SQL. */ import type { ShardBuildResult } from '../cli/orchestrate/shard-model.js'; import type { Catalog } from '../types.js'; import type { GraphCatalog } from '@opensip-cli/contracts'; import type { DataStore } from '@opensip-cli/datastore'; /** * SQLite/Drizzle-backed repository for the graph catalog and its per-shard * fragments. Owns the `graph_catalog` row plus the `graph_shard_fragment` * table; all reads/writes are synchronous (better-sqlite3). The orchestrator * uses it to persist whole catalogs and incremental shard fragments, and to * fingerprint-match for cache validity without parsing the full payload. */ export declare class CatalogRepo { private readonly datastore; constructor(datastore: DataStore); /** * True when a full container walk already validated this lifted identity * for this datastore in this process. Content-keyed validation-fact cache * (idempotent, never run state); keyed by the datastore handle via WeakMap * so it cannot outlive the store. */ private hasValidatedIdentity; private markValidatedIdentity; /** * Read only lifted identity columns for the single catalog row (id = 1). * Never selects/parses payload. Returns null when no row exists. */ readIdentity(): { language: string; cacheKey: string; filesFingerprint: string; builtAt: string; } | null; /** * Replace the catalog with a fresh value. Mirrors v1's atomic * tmp-file + rename write — the upsert is a single statement, and * SQLite's transaction semantics guarantee no torn reads. */ replaceAll(catalog: Catalog): void; /** * Load the full catalog. Returns `null` on cache miss (no row). * Reconstructs the legacy `Catalog` shape from the JSON payload at * parity — view derivations under * `packages/contracts/src/persistence/dashboard/code-paths/` consume * the same shape they always have. */ loadFullCatalog(): Catalog | null; /** * Read the catalog as the cross-tool {@link GraphCatalog} contract — * the shape the report renderer and graph contribution depend on. * This is the supported cross-tool read path: it lets fitness drop its * raw-SQL `SELECT … FROM graph_catalog` (audit 2026-05-29, H1). The * internal `Catalog` is structurally assignable to the GraphCatalog * contract, so this is a plain widening — no cast — verified by the * compiler at this boundary, where graph owns both types. */ loadCatalogContract(): GraphCatalog | null; /** * True iff a catalog row exists. Used by the orchestrator to short- * circuit fingerprint mismatch checks when nothing is cached. */ hasAnyCatalog(): boolean; /** * Persist one shard's `ShardBuildResult`, replacing any prior row for * the same shard id. The validity keys (`cache_key`, `shard_fingerprint`) * are lifted from the result so a reuse check needs no payload parse. */ upsertShardFragment(result: ShardBuildResult): void; /** * Load a shard fragment ONLY if it is still valid — both the shard's * cache key (tsconfig/version/mode) and its files fingerprint must match * the current run. Returns `null` on miss or staleness, signalling the * orchestrator to re-run that shard's worker. No parse happens here * beyond the JSON payload of a single valid shard. */ loadValidShardFragment(shardId: string, expectedCacheKey: string, expectedFingerprint: string): ShardBuildResult | null; /** * Drop fragment rows for shards no longer present in the current build * (e.g. a package was removed). Keeps the per-shard cache from * accumulating stale rows. No-op when `keepShardIds` is empty. */ pruneShardFragmentsExcept(keepShardIds: readonly string[]): void; } //# sourceMappingURL=catalog-repo.d.ts.map