/** * @fileoverview The enrichment consumption audit. * * The engine already performs every enrichment lookup during the generate * walk — the dispatch loops read each `[generatorId][...subject]` block to * enumerate variants, the projection statics read each subject leaf and * the run-constant scopes, and the Drivers read peer blocks for the * variant guard. `EnrichmentAudit` records those lookups (every read is * routed through `GenerateContext.readEnrichment`, the single choke * point) and, post-walk, diffs them against the paths actually present in * `settings.enrichments`. A configured path no lookup touched is dead * config — a typo'd generator id / path / method / model name, or an * entry orphaned by spec evolution — and becomes an * `UNCONSUMED_ENRICHMENT` warning on the manifest. * * Consumption is recorded prefix-closed: consuming * `[id, '/pets', 'post', 'main']` also marks `[id, '/pets', 'post']`, * `[id, '/pets']`, and `[id]`. The present-path enumeration walks each * generator's slice to the block depth its entry type dictates (model: * `[refName]`; operation / webhook / GQL: two segments), so the diff * compares like with like. Reserved keys (`_generator`, `_stack`) are * engine-owned constants and never flagged. * * Everything here is warn-level and fail-open — the audit can only add * warnings to the manifest, never change generation output. * * @module EnrichmentAudit */ import { type GeneratorEnrichments } from '../types/Enrichments.js'; import { type EnrichmentWarning } from './EnrichmentWarning.js'; /** * The slice of a generator entry the audit needs: its id and the entry * type that dictates its enrichment routing depth. */ export type AuditGenerator = { readonly id: string; readonly type: 'oasOperation' | 'gqlOperation' | 'model' | 'webhook'; }; type FinalizeArgs = { /** The consumer's `client.json#settings.enrichments` record. */ enrichments: GeneratorEnrichments | undefined; /** The generators configured for this run. */ generators: readonly AuditGenerator[]; /** * Generator ids the consumer skipped wholesale (string entries in * `settings.skip`). Their slices are reported as info, not warnings — * a temporary skip is legitimate, not dead config. */ skippedGeneratorIds: readonly string[]; }; export declare class EnrichmentAudit { #private; /** * Record one enrichment lookup. Every prefix of `segments` is marked * consumed, so block-level and leaf-level reads land in one namespace. */ consume(segments: readonly string[]): void; /** * Add a warning, deduplicated on `(type, path)` — the same lookup can * repeat many times per run (one per insert call) and must produce one * warning. */ report(warning: EnrichmentWarning): void; /** * Diff the configured enrichment paths against the consumed set and * return every warning gathered during the run plus the addressing * misses found here. Called once, after the generate walk. */ finalize({ enrichments, generators, skippedGeneratorIds }: FinalizeArgs): EnrichmentWarning[]; } /** * Whether an enrichment block declares the given variant — the presence * probe behind `SKIPPED_SUBJECT_ENRICHMENT` info lines. Exported for the * dispatch loops; a non-record block (absent or malformed) has no * variants. */ export declare const hasVariantEnrichment: (block: unknown, variant: string) => boolean; export {};