mindnet_obsidian/src/analysis/severityPolicy.ts
Lars 86c88bc275
Some checks are pending
Node.js build / build (20.x) (push) Waiting to run
Node.js build / build (22.x) (push) Waiting to run
Enhance Mindnet settings and chain inspection features
- Added new settings for analysis policies path, chain inspector include candidates, and max template matches.
- Updated MindnetSettingTab to allow user configuration of new settings with validation.
- Enhanced chain inspection logic to respect includeCandidates option consistently across findings.
- Improved template matching to apply slot type defaults for known templates, ensuring better handling of allowed node types.
- Refactored tests to validate new functionality and ensure consistent behavior in edge case scenarios.
2026-01-19 15:47:23 +01:00

52 lines
1.3 KiB
TypeScript

/**
* 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;
}