Add Shadbala oracle closure audit chain

This commit is contained in:
732642856
2026-06-29 10:38:17 +08:00
parent 0f9b06d9d4
commit a824588d90
14 changed files with 1051 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env python3
"""Regression tests for D3 branch-level audit."""
from __future__ import annotations
from scripts.shadbala_d3_branch_audit import build_report
def test_shadbala_d3_branch_audit_points_to_calc_sthana_bala_d3_branch() -> None:
report = build_report("references/oracle/dasha_shadbala_oracle_cases.json")
assert report["scope"] == "shadbala_d3_branch_audit"
assert report["summary"]["row_count"] >= 4
assert report["summary"]["global_closure_blocked"] is True
assert report["branch_counts"]
assert "direct_exaltation_branch" in report["branch_counts"] or "direct_own_sign_branch" in report["branch_counts"]
assert all(row["suspected_function"] == "calc_sthana_bala" for row in report["rows"])
def test_shadbala_d3_branch_audit_splits_exaltation_vs_own_drift() -> None:
report = build_report("references/oracle/dasha_shadbala_oracle_cases.json")
assert report["branch_hotspots"]["direct_exaltation_branch"]["row_count"] >= 1
assert report["branch_hotspots"]["direct_own_sign_branch"]["row_count"] >= 1
assert report["branch_hotspots"]["direct_exaltation_branch"]["avg_abs_component_diff_rupa"] is not None
assert report["branch_hotspots"]["direct_own_sign_branch"]["avg_abs_component_diff_rupa"] is not None
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env python3
"""Regression tests for D3 mapping vs Shadbala dignity audit."""
from __future__ import annotations
from scripts.shadbala_d3_mapping_audit import build_report
def test_shadbala_d3_mapping_audit_distinguishes_mapping_vs_dignity_path() -> None:
report = build_report("references/oracle/dasha_shadbala_oracle_cases.json")
assert report["scope"] == "shadbala_d3_mapping_audit"
assert report["summary"]["case_count"] >= 3
assert report["summary"]["global_closure_blocked"] is True
assert report["rows"]
assert any(row["mapping_matches_engine_sign"] is True for row in report["rows"])
assert any(row["d3_dignity_bucket"] in {"exalted", "own"} for row in report["rows"])
assert report["suspected_fault_split"]
@@ -0,0 +1,18 @@
#!/usr/bin/env python3
"""Regression tests for batched Shadbala oracle summary."""
from __future__ import annotations
from scripts.shadbala_oracle_batch_summary import build_report
def test_shadbala_oracle_batch_summary_reuses_all_external_verified_cases() -> None:
report = build_report("references/oracle/dasha_shadbala_oracle_cases.json")
assert report["scope"] == "shadbala_oracle_batch_summary"
assert report["summary"]["case_count"] >= 4
assert report["summary"]["external_verified_case_count"] >= 4
assert report["summary"]["fully_within_tolerance_case_count"] <= report["summary"]["external_verified_case_count"]
assert any(row["case_id"] == "template_steve_jobs_dasha_lahiri" for row in report["rows"])
assert any(row["case_id"] == "template_redacted_place_shadbala_raman" for row in report["rows"])
assert report["summary"]["global_closure_blocked"] is True
@@ -0,0 +1,19 @@
#!/usr/bin/env python3
"""Regression tests for Shadbala component hotspot clustering."""
from __future__ import annotations
from scripts.shadbala_oracle_component_cluster_summary import build_report
def test_shadbala_component_cluster_summary_reuses_external_verified_cases() -> None:
report = build_report("references/oracle/dasha_shadbala_oracle_cases.json")
assert report["scope"] == "shadbala_oracle_component_cluster_summary"
assert report["summary"]["case_count"] >= 4
assert report["summary"]["planet_count"] >= 7
assert report["summary"]["global_closure_blocked"] is True
assert report["component_hotspots"]
assert any(row["component"] == "sthana" for row in report["component_hotspots"])
assert any(row["planet"] == "Sun" for row in report["planet_hotspots"])
assert "targeted_fix_recommendation" in report["summary"]
@@ -0,0 +1,18 @@
#!/usr/bin/env python3
"""Regression tests for Sapta dignity whitelist audit."""
from __future__ import annotations
from scripts.shadbala_sapta_dignity_whitelist import build_report
def test_shadbala_sapta_dignity_whitelist_surfaces_d7_d12_d3_d4_exalted_own_flags() -> None:
report = build_report("references/oracle/dasha_shadbala_oracle_cases.json")
assert report["scope"] == "shadbala_sapta_dignity_whitelist"
assert report["summary"]["case_count"] >= 4
assert report["summary"]["global_closure_blocked"] is True
assert report["whitelist_rows"]
assert any(row["layer"] in {"D7", "D12", "D3", "D4"} for row in report["whitelist_rows"])
assert any(row["dignity_type"] in {"exalted", "own"} for row in report["whitelist_rows"])
assert report["layer_counts"]
@@ -0,0 +1,21 @@
#!/usr/bin/env python3
"""Regression tests for Sapta Varga hotspot audit."""
from __future__ import annotations
from scripts.shadbala_sapta_layer_hotspots import build_report
def test_shadbala_sapta_layer_hotspots_surfaces_layer_ranking_and_driver_mix() -> None:
report = build_report("references/oracle/dasha_shadbala_oracle_cases.json")
assert report["scope"] == "shadbala_sapta_layer_hotspots"
assert report["summary"]["case_count"] >= 4
assert report["summary"]["row_count"] >= 20
assert report["summary"]["global_closure_blocked"] is True
assert report["layer_hotspots"]
assert any(row["layer"] == "D1" for row in report["layer_hotspots"])
assert any(row["layer"] == "D9" for row in report["layer_hotspots"])
assert report["driver_mix"]
assert any(key.startswith("friend_enemy") for key in report["driver_mix"])
assert any(key.startswith("dignity") for key in report["driver_mix"])
@@ -0,0 +1,19 @@
#!/usr/bin/env python3
"""Regression tests for targeted Sthana Bala oracle audit."""
from __future__ import annotations
from scripts.shadbala_sthana_targeted_audit import build_report
def test_shadbala_sthana_targeted_audit_identifies_sapta_and_dignity_signals() -> None:
report = build_report("references/oracle/dasha_shadbala_oracle_cases.json")
assert report["scope"] == "shadbala_sthana_targeted_audit"
assert report["summary"]["case_count"] >= 4
assert report["summary"]["row_count"] >= 20
assert report["summary"]["global_closure_blocked"] is True
assert report["rows"]
assert any("sapta" in row["suspected_driver"] for row in report["rows"])
assert any(row["d1_dignity_bucket"] in {"own", "exalted", "debilitated", "friend", "enemy", "neutral"} for row in report["rows"])
assert report["driver_counts"]