/** * Centralized severity policy for Chain Inspector findings. * Applies profile-aware severity rules. */ export type Severity = "info" | "warn" | "error"; export type ProfileName = "discovery" | "decisioning"; /** * Apply severity policy based on profile and finding code. * * Policy rules: * - missing_link_constraints: * - discovery => INFO * - decisioning => WARN * - missing_slot_*: * - discovery => INFO * - decisioning => WARN * - weak_chain_roles: * - discovery => INFO * - decisioning => INFO * - All other findings: keep base severity (no change) */ export function applySeverityPolicy( profileName: ProfileName | undefined, findingCode: string, baseSeverity: Severity ): Severity { // If no profile specified, use base severity if (!profileName) { return baseSeverity; } // missing_link_constraints if (findingCode === "missing_link_constraints") { return profileName === "decisioning" ? "warn" : "info"; } // missing_slot_* if (findingCode.startsWith("missing_slot_")) { return profileName === "decisioning" ? "warn" : "info"; } // weak_chain_roles if (findingCode === "weak_chain_roles") { return "info"; // Always INFO for both profiles } // All other findings: keep base severity return baseSeverity; }