Refactor crash recovery diagnostics and remove unused curvature calculations

- Simplified diagnostic output by renaming "Probabilistic Root Cause Analysis" to "Root Cause Analysis".
- Removed unused methods and calculations related to manifold curvature.
- Updated tests to reflect changes in diagnostic output and removed obsolete assertions.
This commit is contained in:
Sudo-Ivan
2026-03-06 12:16:56 -06:00
parent 7e44b60052
commit 1653553518
3 changed files with 8 additions and 120 deletions

View File

@@ -120,7 +120,7 @@ class TestCrashRecovery(unittest.TestCase):
self.assertIn("!!! APPLICATION CRASH DETECTED !!!", report)
self.assertIn("Type: ValueError", report)
self.assertIn("Message: Simulated error for testing", report)
self.assertIn("Probabilistic Root Cause Analysis:", report)
self.assertIn("Root Cause Analysis:", report)
self.assertIn("Recovery Suggestions:", report)
def test_heuristic_analysis_sqlite(self):
@@ -164,10 +164,6 @@ class TestCrashRecovery(unittest.TestCase):
causes = self.recovery._analyze_cause(exc_type, exc_value, diagnosis)
self.assertEqual(causes[0]["description"], "Missing Reticulum Configuration")
self.assertEqual(causes[0]["probability"], 99)
self.assertIn(
"deterministic manifold constraints",
causes[0]["reasoning"].lower(),
)
def test_entropy_calculation_levels(self):
"""Test how entropy reflects system disorder."""
@@ -201,27 +197,6 @@ class TestCrashRecovery(unittest.TestCase):
# Actually for a "disorder" metric, we might want it to peak when things are most uncertain.
# But in our context, we are showing entropy of the "State Predictability".
def test_confidence_grounding_text(self):
"""Verify that reasoning text reflects grounding logic."""
# High confidence scenario
exc_type = RuntimeError
exc_value = RuntimeError("no current event loop")
diagnosis = {} # probability 88% -> heuristic matching
causes_low = self.recovery._analyze_cause(exc_type, exc_value, diagnosis)
self.assertIn(
"probabilistic heuristic matching",
causes_low[0]["reasoning"].lower(),
)
# Near-certainty scenario
diagnosis_certain = {"config_missing": True}
causes_high = self.recovery._analyze_cause(
exc_type,
exc_value,
diagnosis_certain,
)
self.assertIn("high-confidence threshold", causes_high[0]["reasoning"].lower())
def test_heuristic_analysis_lxmf_storage(self):
"""Test LXMF storage failure detection."""
exc_type = RuntimeError
@@ -280,8 +255,7 @@ class TestCrashRecovery(unittest.TestCase):
report = output.getvalue()
self.assertIn("[System Entropy:", report)
self.assertIn("[Deterministic Manifold Constraints:", report)
self.assertIn("deterministic manifold constraints", report.lower())
self.assertIn("[KL-Divergence:", report)
def test_heuristic_analysis_unsupported_python(self):
"""Test detection of unsupported Python versions."""
@@ -344,38 +318,6 @@ class TestCrashRecovery(unittest.TestCase):
finally:
sys.excepthook = original
# ==================================================================
# _calculate_manifold_curvature
# ==================================================================
def test_curvature_empty_causes(self):
"""Empty causes list should return 0.0 curvature."""
self.assertEqual(self.recovery._calculate_manifold_curvature([]), 0.0)
def test_curvature_single_cause(self):
"""Single cause should return probability * 10."""
causes = [{"probability": 95}]
self.assertAlmostEqual(self.recovery._calculate_manifold_curvature(causes), 9.5)
def test_curvature_two_causes_gradient(self):
"""Curvature should be 10 * (top - second)."""
causes = [{"probability": 90}, {"probability": 40}]
self.assertAlmostEqual(self.recovery._calculate_manifold_curvature(causes), 5.0)
def test_curvature_equal_causes(self):
"""Equal probabilities should give curvature = 0."""
causes = [{"probability": 50}, {"probability": 50}]
self.assertAlmostEqual(self.recovery._calculate_manifold_curvature(causes), 0.0)
def test_curvature_many_causes(self):
"""Only top 2 probabilities matter for curvature."""
causes = [
{"probability": 80},
{"probability": 30},
{"probability": 10},
]
self.assertAlmostEqual(self.recovery._calculate_manifold_curvature(causes), 5.0)
# ==================================================================
# _calculate_system_entropy edge cases
# ==================================================================

View File

@@ -998,22 +998,6 @@ class TestCrashRecoveryMathProperties:
assert entropy >= 0, f"Negative entropy: {entropy}"
assert divergence >= 0, f"Negative divergence: {divergence}"
@given(
probs=st.lists(
st.integers(min_value=0, max_value=100), min_size=0, max_size=10
),
)
@settings(derandomize=True, deadline=None)
def test_manifold_curvature_bounded(self, probs):
"""Manifold curvature must always be a non-negative finite float."""
import math as m
recovery = self._make_recovery()
causes = [{"probability": p} for p in probs]
curvature = recovery._calculate_manifold_curvature(causes)
assert m.isfinite(curvature), f"Non-finite curvature: {curvature}"
assert curvature >= 0 or len(probs) >= 2, f"Unexpected negative: {curvature}"
@given(
exc_msg=st.text(min_size=0, max_size=200),
exc_type_name=st.sampled_from(