import type { Issue, IssueGroup } from '../types/analysis.types'; /** * Result of attempting to mechanically fix a single finding. * * - `applied`: the file was rewritten on disk (or would be, in dry-run). * - `skipped`: the finding matched the rule, but the props object already * contained the desired property (e.g. user already opted in) or the * construct couldn't be located unambiguously. * - `error`: something went wrong — bad source location, parse error, or * an explicit refusal because applying the fix would be unsafe. */ export type FixOutcome = { status: 'applied'; ruleId: string; filePath: string; summary: string; diff?: { before: string; after: string; }; } | { status: 'skipped'; ruleId: string; filePath: string; reason: string; } | { status: 'error'; ruleId: string; filePath?: string; reason: string; }; /** * A fixer takes a finding (with its resolved source location) plus the * resource group it belongs to, and returns either a side-effect description * or a refusal. Fixers are pure with respect to the in-memory file content * they receive — they do not read or write the disk themselves; the calling * orchestrator handles that so dry-run can compose multiple fixes for the * same file safely. */ export interface FixContext { /** Absolute path to the file that owns the construct. */ filePath: string; /** Current source content of the file (post any earlier fixes in this run). */ fileContent: string; /** 1-indexed line number reported by the source-location helpers. */ line: number; /** 1-indexed column number reported by the source-location helpers. */ column: number; issue: Issue; group: IssueGroup; } export interface FixResult { /** Updated file content. Same as input means no-op (skipped). */ content: string; /** Human-readable summary of what changed (or why nothing did). */ summary: string; /** Whether `content` differs from the input. */ changed: boolean; } export type Fixer = (ctx: FixContext) => FixResult; /** * Registry mapping rule IDs (e.g. `AwsSolutions-S10`, `AwsSolutions-DDB3`) to * their fixers. Adding a new mechanical fix is a one-line registration plus a * fixer module. */ export type FixerRegistry = Record;