Skip to content

Commit d6798b6

Browse files
committed
Add comprehensive tests for Phase 3 features and fix risk assessment
Tests: - 13 new tests for executive summary, risk assessment, action items - All 36 reporting tests passing (23 existing + 13 new) Fix: - Adjusted risk assessment sensitivity - Moved 'anomaly' keyword from CRITICAL to MEDIUM severity - More granular keyword classification (critical/high/medium) Test coverage: - Executive summary with top insights and priority actions - Risk level assessment for all severity levels - Action item extraction from insights and recommendations - Metadata includes risk_level and action_items
1 parent 1c3d94d commit d6798b6

2 files changed

Lines changed: 389 additions & 4 deletions

File tree

graph_analytics_ai/ai/reporting/generator.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,27 +508,34 @@ def _assess_risk_level(self, insights: List[Insight]) -> str:
508508
if not insights:
509509
return "LOW"
510510

511-
# Check for critical keywords in titles/descriptions
512-
critical_keywords = ["fraud", "botnet", "breach", "attack", "critical", "failure"]
513-
high_keywords = ["risk", "anomaly", "suspicious", "over-aggregation", "false positive"]
511+
# Check for critical keywords in titles/descriptions (very specific, high-severity terms)
512+
critical_keywords = ["fraud", "botnet", "breach", "attack", "failure", "malicious"]
513+
high_keywords = ["risk", "suspicious", "over-aggregation", "false positive"]
514+
medium_keywords = ["anomaly", "unusual", "inconsisten"] # Moved anomaly to medium
514515

515516
critical_count = 0
516517
high_count = 0
518+
medium_count = 0
517519

518520
for insight in insights:
519521
text = (insight.title + " " + insight.description).lower()
520522

523+
# Check in priority order
521524
if any(kw in text for kw in critical_keywords):
522525
critical_count += 1
523526
elif any(kw in text for kw in high_keywords):
524527
high_count += 1
528+
elif any(kw in text for kw in medium_keywords):
529+
medium_count += 1
525530

526531
# Assess based on counts and confidence
527532
if critical_count > 0:
528533
return "CRITICAL"
529534
elif high_count >= 2 or (high_count >= 1 and any(i.confidence > 0.8 for i in insights)):
530535
return "HIGH"
531-
elif high_count >= 1:
536+
elif high_count >= 1 or medium_count >= 2:
537+
return "MEDIUM"
538+
elif medium_count >= 1:
532539
return "MEDIUM"
533540
else:
534541
return "LOW"

0 commit comments

Comments
 (0)