Update app.py
Browse files
app.py
CHANGED
|
@@ -727,30 +727,21 @@ def transform_arf_output_for_ui(raw_result: dict, scenario_name: str) -> dict:
|
|
| 727 |
# STEP 3: BUILD UI ANALYSIS (DERIVED, NOT INFERRED)
|
| 728 |
# ===================================================
|
| 729 |
|
| 730 |
-
#
|
| 731 |
-
# REAL ARF OSS USES "anomaly_detected": true key
|
| 732 |
detected = False
|
| 733 |
if isinstance(detection_data, dict):
|
| 734 |
-
|
| 735 |
-
# FIX: Added "anomaly_detected" to the list
|
| 736 |
-
detection_signals = ["signal", "anomaly", "finding", "detected", "alert", "indicator", "anomaly_detected"]
|
| 737 |
-
|
| 738 |
-
# Check for any detection signals in keys or values
|
| 739 |
-
for signal in detection_signals:
|
| 740 |
-
if signal in str(detection_data).lower():
|
| 741 |
-
detected = True
|
| 742 |
-
break
|
| 743 |
-
|
| 744 |
-
# ADDITIONAL DEFENSIVE CHECK: Direct boolean check for anomaly_detected
|
| 745 |
-
if not detected and "anomaly_detected" in detection_data:
|
| 746 |
detected = bool(detection_data["anomaly_detected"])
|
|
|
|
|
|
|
| 747 |
|
| 748 |
# CORRECTED: confidence = 0 if not in source (visibly conservative)
|
| 749 |
confidence = 0 # VISIBLY CONSERVATIVE DEFAULT
|
| 750 |
-
|
| 751 |
-
|
| 752 |
-
elif "confidence" in detection_data:
|
| 753 |
confidence = detection_data["confidence"]
|
|
|
|
|
|
|
| 754 |
|
| 755 |
# CORRECTED: similar_incidents = 0 if not in source (visibly conservative)
|
| 756 |
similar_incidents = 0 # VISIBLY CONSERVATIVE DEFAULT
|
|
@@ -760,10 +751,11 @@ def transform_arf_output_for_ui(raw_result: dict, scenario_name: str) -> dict:
|
|
| 760 |
elif "similar_incidents" in recall_data:
|
| 761 |
similar_incidents = recall_data["similar_incidents"]
|
| 762 |
|
| 763 |
-
#
|
| 764 |
healing_intent_created = False
|
| 765 |
if isinstance(decision_data, dict):
|
| 766 |
-
|
|
|
|
| 767 |
|
| 768 |
# Rule: recommended_action = pass through existing decision action text
|
| 769 |
recommended_action = "No actionable intelligence found" # VISIBLY CONSERVATIVE
|
|
|
|
| 727 |
# STEP 3: BUILD UI ANALYSIS (DERIVED, NOT INFERRED)
|
| 728 |
# ===================================================
|
| 729 |
|
| 730 |
+
# DOCTRINALLY PURE: detection only when OSS explicitly signals it
|
|
|
|
| 731 |
detected = False
|
| 732 |
if isinstance(detection_data, dict):
|
| 733 |
+
if "anomaly_detected" in detection_data:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 734 |
detected = bool(detection_data["anomaly_detected"])
|
| 735 |
+
elif "detected" in detection_data:
|
| 736 |
+
detected = bool(detection_data["detected"])
|
| 737 |
|
| 738 |
# CORRECTED: confidence = 0 if not in source (visibly conservative)
|
| 739 |
confidence = 0 # VISIBLY CONSERVATIVE DEFAULT
|
| 740 |
+
# Confidence must come from detection if anomaly detected
|
| 741 |
+
if detected and isinstance(detection_data, dict) and "confidence" in detection_data:
|
|
|
|
| 742 |
confidence = detection_data["confidence"]
|
| 743 |
+
elif isinstance(decision_data, dict) and "confidence" in decision_data:
|
| 744 |
+
confidence = decision_data["confidence"]
|
| 745 |
|
| 746 |
# CORRECTED: similar_incidents = 0 if not in source (visibly conservative)
|
| 747 |
similar_incidents = 0 # VISIBLY CONSERVATIVE DEFAULT
|
|
|
|
| 751 |
elif "similar_incidents" in recall_data:
|
| 752 |
similar_incidents = recall_data["similar_incidents"]
|
| 753 |
|
| 754 |
+
# DOCTRINALLY PURE: healing intent only when explicitly true in OSS output
|
| 755 |
healing_intent_created = False
|
| 756 |
if isinstance(decision_data, dict):
|
| 757 |
+
# Must be explicitly true in decision output
|
| 758 |
+
healing_intent_created = bool(decision_data.get("healing_intent_created", False))
|
| 759 |
|
| 760 |
# Rule: recommended_action = pass through existing decision action text
|
| 761 |
recommended_action = "No actionable intelligence found" # VISIBLY CONSERVATIVE
|