import type { AcceptanceCriterion, Anchor, Finding, GateProvenance, Task } from '@manehorizons/cadence-types'; /** * Phase 235 (T4) — criteria-gap detection. Sits directly on top of the pure * §7.1 anchor resolver (`resolveAnchor`, T2): for every file a code-review * finding was reported against, this module works out which criterion (if * any) that file is anchored to and tags each finding with the result. A * finding whose best anchor resolves to `{ kind: 'none', tier: 'undeclared' * }` is, by definition, a criteria gap — diff work no acceptance criterion * and no boundary covers (AC-4). No new refusal machinery lives here: the * caller (`gates/code-review.ts`) keeps feeding the tagged findings through * the SAME `highs`/`pass` computation it always has, so a HIGH-severity gap * finding refuses through the pre-existing path (`dec-20260729-005`, D2). * * Pure and dependency-injected — no fs, no clock, no I/O — matching the house * pure-core/impure-shell split used throughout `gates/*` and `verify/*`. */ /** Structural shape of a code-review finding. As of Phase 236 (T5, D9) there * is only one `Finding` type — `verify/code-review.ts` now imports the * shared, persisted `@manehorizons/cadence-types` `Finding` directly rather * than declaring its own — but this module still declares its own narrow * structural shape rather than importing `Finding` from `verify/code-review.ts`: * it has no reason to depend on that file's shape beyond what it * structurally needs (severity/message/line), and a structural type here * stays satisfied by any caller carrying a superset (extra `id`/`target`/ * `disposition`/`waiver`/`anchor` fields included). `severity` is derived as * `Finding['severity']` (not restated as a hand-picked subset) so that the * post-T5 convergence — `verify/code-review.ts`'s `CodeReviewResult.findings` * now carries the full `critical|high|medium|low` union — keeps flowing * through `anchorFindings` without a widening mismatch at its call site in * `gates/code-review.ts`. `line` is likewise derived as `Finding['line']` * (`number | undefined`, not a hand-restated `number`) — under this repo's * `exactOptionalPropertyTypes`, the shared schema's optional `line` is a * distinct type from a bare `line?: number`, and only the derived form * accepts a real `Finding` object (which may carry `line: undefined` * explicitly) without a second mismatch. */ export interface GapCandidateFinding { readonly severity: Finding['severity']; readonly message: string; readonly line?: Finding['line']; } /** A finding tagged with its resolved §7.1 anchor. `anchor.tier === * 'undeclared'` (equivalently `anchor.kind === 'none'`) is the criteria-gap * signal — the property that makes a gap finding distinguishable from an * ordinary anchored finding in the result. */ export interface AnchoredFinding extends GapCandidateFinding { readonly anchor: Anchor; } /** Phase 235 (T4, D3) — declared unconditionally by the caller regardless of * whether the evidence floor stops the settle; config decides what stops * you, never what is visible. `severityDistribution` tallies only the gap * (undeclared-tier) findings — the population relevant to reasoning about * whether the pre-existing HIGH-finding floor will refuse. Keyed by the full * `Finding['severity']` union (Phase 236, T5) so tallying a gap finding of * any severity — including `critical` — can never fall outside the Record's * declared keys; `critical` is not currently reachable through code-review's * own verifiers (they only ever emit `high|medium|low`), but the type must * stay sound for the full converged `Finding` shape regardless. */ export interface CriteriaGapSummary { readonly gapCount: number; readonly severityDistribution: Readonly>; } export interface CriteriaGapResult { /** Every input finding, unchanged except for the added `anchor`. */ readonly findings: Record; readonly summary: CriteriaGapSummary; } /** * Tag every finding with its resolved anchor and unconditionally declare the * gap count + severity distribution (D3). `gateProvenance` is threaded * through to `resolveAnchor` unchanged — pass `[]` when the caller has no * corroborating provenance available (as of Phase 241, this settle's * `code-review` gate does have provenance available and passes the real * in-flight snapshot; `[]` remains the correct fallback for any other caller * with none), which conservatively can never inflate a tier to `executable`. */ export declare function anchorFindings(findings: Readonly>, acceptanceCriteria: readonly AcceptanceCriterion[], boundaries: readonly string[], tasks: readonly Task[], gateProvenance: readonly GateProvenance[]): CriteriaGapResult; //# sourceMappingURL=criteria-gap.d.ts.map