petter2025 commited on
Commit
b28d6b4
·
verified ·
1 Parent(s): f516920

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -19
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
- # SURGICAL FIX: Add "anomaly_detected" to detection_signals list
731
- # REAL ARF OSS USES "anomaly_detected": true key
732
  detected = False
733
  if isinstance(detection_data, dict):
734
- # Look for explicit detection signals that OSS should provide
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
- if "confidence" in decision_data:
751
- confidence = decision_data["confidence"]
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
- # CORRECTED: healing_intent_created requires explicit action in decision data
764
  healing_intent_created = False
765
  if isinstance(decision_data, dict):
766
- healing_intent_created = "action" in decision_data or "recommended_action" in decision_data
 
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