/** * Freshness-aware trust — read dbt run artifacts (READ-ONLY) and fold data * health into the effective trust of certified blocks. * * "Certified" means the *logic* was reviewed. It says nothing about whether the * *data* behind a block is fresh: an upstream dbt model may have failed its last * run, or be past its freshness window. This module reads dbt's own artifacts — * `run_results.json` (last-run status/time per model) and, when present, the * source-freshness output — and derives a {@link DbtDataState} per dbt node. It * then rolls those up to each certified block's transitive dbt upstreams so a * surface can render "Certified · stale data" / "Certified · upstream failed". * * We never run dbt or query the warehouse — we only parse files dbt produced. * Everything degrades to `unknown` (which surfaces as the plain "Certified" * label) when an artifact is missing or unparseable, so this is fully additive. * * Kept in a dedicated module so `manifest/builder.ts` only needs a couple of * call sites, keeping its diff minimal and merge-clean with the sibling * `outputContract`/`drift` change. */ import type { DbtDataState, DbtRunState, ManifestBlock, ManifestSource } from './types.js'; /** Return the worse (higher-severity) of two data states. */ export declare function worseDataState(a: DbtDataState, b: DbtDataState): DbtDataState; /** * Parsed run-state keyed by dbt `unique_id`, plus the artifact path that was * read (for provenance). Empty `byUniqueId` means no artifact was found. */ export interface DbtRunStateIndex { byUniqueId: Map; runResultsPath?: string; } /** * Resolve and read dbt's `run_results.json` (and source-freshness output, when * a separate `sources.json` sits beside it) from the directory holding the dbt * `manifest.json`. Returns an empty index — never throws — when nothing is * found or the file cannot be parsed. * * dbt writes both `manifest.json` and `run_results.json` into the same * `target/` directory, so we look beside `manifestPath`. */ export declare function loadDbtRunState(manifestPath: string): DbtRunStateIndex; /** * Compute each certified block's effective `dataState` from the health of its * transitive dbt upstreams, mutating blocks additively in place. * * Resolution: a block's `tableDependencies` name dbt models/sources; we resolve * each to a `sources[...]` entry that carries a `dbtModel.uniqueId`, then walk * upstream through the dbt DAG (`edges`: source → target uniqueId) collecting * every reachable node's run state. The block's `dataState` is the worst state * among them. Blocks with no resolvable dbt upstream are left untouched. * * Only acts when a run-results artifact was actually read — without it every * node is `unknown` and we leave blocks alone so nothing regresses to a noisy * "· data freshness unknown" qualifier. */ export declare function applyBlockDataState(blocks: Record, sources: Record, dbtDag: { models: Array<{ uniqueId: string; }>; edges: Array<{ source: string; target: string; }>; } | undefined, runState: DbtRunStateIndex): void; //# sourceMappingURL=dbt-freshness.d.ts.map