a11oy / test /test_brainhealth_wiring.py
betterwithage's picture
Wire all brain honesty signals into health rollup (#4)
5eef998
Raw History Blame
1.83 kB
from __future__ import annotations
import unittest
import szl_brainhealth as health
class BrainHealthWiringTests(unittest.TestCase):
def test_real_sibling_entrypoints_and_call_styles_are_explicit(self) -> None:
specs = {row["key"]: row for row in health.COMPONENTS}
self.assertEqual(specs["freshness"]["funcs"], ("build_aggregate",))
self.assertEqual(specs["provenance"]["call_style"], "ns_q_k")
self.assertEqual(specs["contradiction"]["funcs"], ("run_detection",))
self.assertEqual(specs["uncertainty"]["funcs"], ("handle_uncertainty",))
def test_uncertainty_is_inverted_to_trust_direction(self) -> None:
payload = health._normalize_component_payload(
"uncertainty",
{"label": "MODELED", "verdict": "HIGHLY-UNCERTAIN", "uncertainty": 0.91, "abstain_recommended": True},
)
self.assertEqual(payload["trust_value"], 0.09)
self.assertTrue(payload["abstain"])
def test_descriptive_prose_does_not_create_a_false_adverse_signal(self) -> None:
payload = {
"label": "MODELED",
"verdict": "WEAK-GROUNDING",
"should_abstain": False,
"note": "the system abstains only when evidence is insufficient",
}
self.assertIsNone(health._detect_adverse(payload, ("ungrounded",)))
def test_freshness_uses_real_node_distribution(self) -> None:
payload = health._normalize_component_payload(
"freshness",
{"label": "MEASURED", "node_count": 100, "verdict_counts": {"FRESH": 5, "AGING": 15, "STALE": 80}},
)
self.assertEqual(payload["trust_value"], 0.2)
self.assertTrue(payload["stale_dominant"])
self.assertEqual(payload["verdict"], "STALE-DOMINANT")
if __name__ == "__main__":
unittest.main()