@@ -54,14 +54,18 @@ type AppConfig struct {
5454 CSVExportAppend bool `yaml:"csv_export_append"`
5555 CSVExportPath string `yaml:"csv_export_path"`
5656
57- InsightsEnabled bool `yaml:"insights_enabled"`
58- InsightsSamplingRate float64 `yaml:"insights_sampling_rate"`
59- InsightsSlowThresholdMs int `yaml:"insights_slow_threshold_ms"`
60- InsightsMaxEvents int `yaml:"insights_max_events"`
61- InsightsMaxGroups int `yaml:"insights_max_groups"`
62- InsightsExplainEnabled bool `yaml:"insights_explain_enabled"`
63- InsightsExplainTopN int `yaml:"insights_explain_top_n"`
64- InsightsExplainMaxTimeMS int `yaml:"insights_explain_max_time_ms"`
57+ InsightsEnabled bool `yaml:"insights_enabled"`
58+ InsightsSamplingRate float64 `yaml:"insights_sampling_rate"`
59+ InsightsSlowThresholdMs int `yaml:"insights_slow_threshold_ms"`
60+ InsightsMaxEvents int `yaml:"insights_max_events"`
61+ InsightsMaxGroups int `yaml:"insights_max_groups"`
62+ InsightsExplainEnabled bool `yaml:"insights_explain_enabled"`
63+ InsightsExplainTopN int `yaml:"insights_explain_top_n"`
64+ InsightsExplainMaxTimeMS int `yaml:"insights_explain_max_time_ms"`
65+ InsightsExplainSeverityMode string `yaml:"insights_explain_severity_mode"`
66+ InsightsExplainWorkers int `yaml:"insights_explain_workers"`
67+ InsightsExplainRetries int `yaml:"insights_explain_retries"`
68+ InsightsExplainBackoffMS int `yaml:"insights_explain_backoff_ms"`
6569}
6670
6771type WebUIConfig struct {
@@ -169,6 +173,10 @@ func applyUIDefaults(cfg *AppConfig) {
169173 cfg .InsightsExplainEnabled = false
170174 cfg .InsightsExplainTopN = 5
171175 cfg .InsightsExplainMaxTimeMS = 1000
176+ cfg .InsightsExplainSeverityMode = "high_only"
177+ cfg .InsightsExplainWorkers = 1
178+ cfg .InsightsExplainRetries = 1
179+ cfg .InsightsExplainBackoffMS = 150
172180}
173181
174182// applyBaseDefaults sets low-level engine safety limits & remaining UI limits
@@ -204,6 +212,20 @@ func applyBaseDefaults(cfg *AppConfig) {
204212 if cfg .InsightsExplainMaxTimeMS <= 0 {
205213 cfg .InsightsExplainMaxTimeMS = 1000
206214 }
215+ switch cfg .InsightsExplainSeverityMode {
216+ case "high_and_low" , "medium_only" , "critical_only" , "high_only" :
217+ default :
218+ cfg .InsightsExplainSeverityMode = "high_only"
219+ }
220+ if cfg .InsightsExplainWorkers <= 0 {
221+ cfg .InsightsExplainWorkers = 1
222+ }
223+ if cfg .InsightsExplainRetries < 0 {
224+ cfg .InsightsExplainRetries = 0
225+ }
226+ if cfg .InsightsExplainBackoffMS < 0 {
227+ cfg .InsightsExplainBackoffMS = 0
228+ }
207229
208230 // Web UI Port
209231 if cfg .WebUI .Port <= 0 {
@@ -567,6 +589,24 @@ func applyEnvOverrides(cfg *AppConfig) map[string]bool {
567589 cfg .InsightsExplainMaxTimeMS = n
568590 }
569591 }
592+ if v := os .Getenv ("PLGM_INSIGHTS_EXPLAIN_SEVERITY_MODE" ); v != "" {
593+ cfg .InsightsExplainSeverityMode = v
594+ }
595+ if v := os .Getenv ("PLGM_INSIGHTS_EXPLAIN_WORKERS" ); v != "" {
596+ if n , err := strconv .Atoi (v ); err == nil && n > 0 {
597+ cfg .InsightsExplainWorkers = n
598+ }
599+ }
600+ if v := os .Getenv ("PLGM_INSIGHTS_EXPLAIN_RETRIES" ); v != "" {
601+ if n , err := strconv .Atoi (v ); err == nil && n >= 0 {
602+ cfg .InsightsExplainRetries = n
603+ }
604+ }
605+ if v := os .Getenv ("PLGM_INSIGHTS_EXPLAIN_BACKOFF_MS" ); v != "" {
606+ if n , err := strconv .Atoi (v ); err == nil && n >= 0 {
607+ cfg .InsightsExplainBackoffMS = n
608+ }
609+ }
570610
571611 return overrides
572612}
0 commit comments