import type { Finding, FindingGrounding } from "../types/finding.js"; /** Normalize text for content-matching: drop CR, collapse whitespace, trim. */ export declare function normalizeForMatch(text: string): string; /** * Repo-relative, separator- and case-normalized path for matching against a * known-paths set: trim, backslash→slash, strip a leading `./`, lowercase. * * The single path normalizer (drift-plan P7) shared by the conceptual-review * grounding and any other consumer that matches a cited `affected_files` path * against a repo manifest. (Quote-and-verify resolves a cited path against the * filesystem instead, so it does not lowercase — see `verifyFindingGrounding`.) * * INV-B3-1: strips a leading `./` ONLY — it must NEVER strip the leading dot of a * dotfile-directory segment (`.claude/…`, `.github/…`). The regex is anchored to * `./` (dot-SLASH); do not broaden it to `/^\.\/?/` or similar, or every * dotfile-dir citation silently un-grounds (it would no longer match its * `git ls-files` form by exact membership). */ export declare function normalizeRepoPath(p: string): string; /** * True when `p` is a bare basename — a single path segment with no separator * (`advance.ts`), as opposed to a nested repo-relative path (`src/x/advance.ts`) * or a dotfile-dir path (`.claude/hooks/x.mjs`). A bare basename is the one shape * that cannot be resolved by a naive `root/` join when the real file is * nested, so it is the shape {@link resolveBasenameToTrackedPath} rescues. */ export declare function isBareBasename(p: string): boolean; /** * INV-B3-2: resolve a bare basename (`advance.ts`) to its UNIQUE tracked full * path in the known-path corpus (`src/audit/orchestrator/advance.ts`). Returns * the single matching corpus entry when exactly one tracked path has that * basename; `undefined` when zero OR more-than-one path matches — an ambiguous * basename stays a checkable signal, never a silent false-pass. * * Corpus-agnostic and case-insensitive on the basename: it works whether the * caller's corpus is `normalizeRepoPath`-lowercased (the M-B3 gate) or * case-preserving (the fs-resolving remediate consumers), and returns the corpus * entry as-is so a case-preserving caller gets a real on-disk path back. Single * source (drift-plan convention) — the gate, both orchestrators, and * `groundDesignFinding` all resolve basenames through this one authority. */ export declare function resolveBasenameToTrackedPath(basename: string, knownPaths: ReadonlySet): string | undefined; /** * Case-preserving corpus of the tracked working-tree paths at `root`, via * `git ls-files -z` (forward-slashed). THE one git enumeration behind both * grounding corpora: the M-B3 gate's `enumerateRepoTreePaths` is a * `normalizeRepoPath`-lowercased draw over this set, while the remediate * consumers that resolve a basename and then read the file off disk (line * counting) need the REAL on-disk case, so this one does not lowercase. * * `-z` is load-bearing, not a flourish: plain `ls-files` renders any path git * considers unusual in C-quoted form (`core.quotePath` turns a non-ASCII byte * into `\303`, and a path containing a newline is quoted too), so a newline * split yielded an entry that no longer equals the real repo path — every * citation naming that file silently failed to ground while the file-disposition * rule, which already used `-z`, kept it in scope. NUL-delimited output is * unquoted and unambiguous, so entries are taken verbatim (no trim: with no line * terminator to strip, trimming could only damage a legitimately space-padded * POSIX path). * * Degrades to an empty set when git is missing / not a repo (callers then fall * back to their existing `existsSync` check — monotonic, never a regression). * OS-agnostic: `shell: false`, forward-slash output. */ export declare function enumerateTrackedFilePaths(root: string): Set; /** * True when the (normalized) quoted span appears anywhere in the (normalized) * file content. An empty quote never matches (an empty quote grounds nothing). */ export declare function quoteMatches(fileContent: string, quotedText: string): boolean; /** Reads a source file's text; injectable so the verifier is testable without fs. */ export type SourceReader = (absolutePath: string) => Promise; /** * A {@link SourceReader} memoized by absolute path, for ONE grounding pass: a * batch whose findings all cite the same file reads that file once rather than * once per finding. The promise is cached — including a rejecting one — so an * unreadable path is not retried per citation either. * * Scope it to a single pass and discard it: a reader that outlived the pass * would serve stale bytes after a later edit, which is exactly what quote-and- * verify exists to catch. */ export declare function createMemoizedSourceReader(): SourceReader; /** * Re-verify a finding's cited verbatim span(s) against disk. A finding is * `grounded` as soon as ONE of its `affected_files[].quoted_text` spans matches * its cited file; it is `ungrounded` when it carries no quote at all, or when no * cited quote can be found on disk (with a reason naming the failed spans). */ export declare function verifyFindingGrounding(repoRoot: string, finding: Finding, readSource?: SourceReader): Promise; /** * INV-GND-02 (total function): classify a finding's grounding as a verdict that * is ALWAYS defined. A finding whose `grounding` is undefined/absent is treated * as **ungrounded** — it was never re-verified, so it must be verified before a * fix is applied, never silently trusted. This is the single authority the * remediator consults on the structured-audit path so a missing verdict can * never be mistaken for a passing one. */ export declare function findingIsGrounded(finding: Pick): boolean; /** * True when a finding must be verified-before-fix because it was NOT positively * grounded: `ungrounded` (quote didn't re-verify), `refuted` (anchor disproved — * normally already quarantined-excluded upstream), or no verdict at all * (undefined → treated as ungrounded, INV-GND-02). The remediator uses this to * flag such findings for a verify-first pass rather than blindly applying the fix. */ export declare function findingNeedsVerificationBeforeFix(finding: Pick): boolean; //# sourceMappingURL=findingGrounding.d.ts.map