/** * Check-weakening findings (change: add-check-weakening-findings). * * A diff can make checks pass by weakening the checks instead of fixing the code: a test removed or * skipped, assertions dropped, an expected value edited, a suppression comment added, an error * caught and discarded, or a test/lint/coverage/CI config relaxed. This module reports each of those * shapes as a registered advisory finding, computed against a FIXED baseline: the merge-base of the * requested base (or of the default branch when none is given) with the new state. Never the agent's * own last commit, which would hide a weakening done in two steps. * * Every shape is a fact about the diff, worded neutrally: a legitimate test cleanup produces the same * fact, and the reader decides. Each test-shape finding names the production symbols the weakened * test file reaches in the index (its `tested_by` edges and their forward call closure), so the * receipt says what the test was guarding. A file in a language or framework outside the closed * tables is reported `not-assessed`, never as free of weakening. * * Detection reads syntax trees (tree-sitter) for test cases, assertions, comments and catch blocks, * and a parsed YAML document for CI workflows. No test is run and no LLM is used. */ import type { SerializedCallGraph } from '../analyzer/call-graph.js'; import type { GovernanceFinding } from './mcp-handlers/enforcement-policy.js'; export declare const CHECK_WEAKENING_CODES: readonly ["test-removed", "test-disabled", "assertions-reduced", "expected-value-changed", "suppression-added", "error-swallowed", "check-config-relaxed"]; export type CheckWeakeningCode = typeof CHECK_WEAKENING_CODES[number]; export declare const CHECK_WEAKENING_SOURCE = "check-weakening"; /** A finding plus the production symbols the affected test file reaches. */ export interface CheckWeakeningFinding extends GovernanceFinding { code: CheckWeakeningCode; /** Production symbols the test file reaches in the index (first {@link MAX_REACH_NAMES}). */ reaches?: string[]; /** The subset of `reaches` that this diff also changes. */ reachesChanged?: string[]; } export interface NotAssessed { file: string; shapes: CheckWeakeningCode[]; reason: string; } export interface CheckWeakeningResult { /** The fixed baseline the shapes were computed against. */ baseline: { ref: string; commit: string; }; findings: CheckWeakeningFinding[]; notAssessed: NotAssessed[]; boundaries: string[]; } /** One changed file: its text at the baseline and in the new state (`null` when absent there). */ export interface WeakeningFile { path: string; base: string | null; current: string | null; /** The file exceeds the read cap at one of the two revisions; it is reported not-assessed. */ tooLarge?: true; } /** Which production symbols a test file reaches, from the index. */ export interface ReachIndex { reachOf(testFile: string): { recorded: boolean; symbols: Array<{ id: string; name: string; }>; }; } type ConfigKind = 'ci' | 'lint' | 'test-runner' | 'coverage' | 'ignore-file' | 'sectioned'; /** The closed table of check config files. */ export declare function checkConfigKind(path: string): ConfigKind | null; /** Production symbols reached by a test file, from `tested_by` edges and their forward call closure. */ export declare function reachIndexFromGraph(cg: SerializedCallGraph): ReachIndex; /** * Detect every weakening shape over the changed files. Pure except for loading the tree-sitter * grammars; `reach` joins each test finding to what the test guarded, and `changedIds` is the set of * production symbols the diff changes (an expected value updated with its code is not reported). */ export declare function detectWeakeningShapes(files: readonly WeakeningFile[], reach: ReachIndex | undefined, changedIds: ReadonlySet | undefined): Promise<{ findings: CheckWeakeningFinding[]; notAssessed: NotAssessed[]; boundaries: string[]; }>; /** * The fixed baseline: the merge-base of `baseRef` with the new state. An omitted or `HEAD` base is * read as the default branch, so a weakening already committed on this branch is still compared. */ export declare function resolveWeakeningBaseline(root: string, baseRef: string | undefined, headRef?: string): Promise<{ ref: string; commit: string; note?: string; }>; /** * Compute the check-weakening facts for a change: the working tree (or `headRef`) against the fixed * baseline. `root` must be the repository root (git prints repository-relative paths). Never throws * on a git failure; a failure is returned as a boundary with no findings. */ export declare function checkWeakening(input: { root: string; baseRef?: string; headRef?: string; callGraph?: SerializedCallGraph; /** Restrict to these repository-relative paths. */ files?: readonly string[]; }): Promise; export {}; //# sourceMappingURL=check-weakening.d.ts.map