1 """Regression tests for the Phase 3.1 counted performance matrix (P31-S11-E01).""" 3 from __future__
import annotations
5 from pathlib
import Path
8 REPO_ROOT = Path(__file__).resolve().parents[3]
9 if str(REPO_ROOT)
not in sys.path:
10 sys.path.insert(0, str(REPO_ROOT))
12 from benchmarks.density_matrix.performance_evidence.case_selection
import (
13 build_phase31_counted_performance_case_contexts,
14 build_phase31_counted_performance_inventory_cases,
16 from benchmarks.density_matrix.performance_evidence.common
import (
17 PERFORMANCE_EVIDENCE_PHASE31_CASE_SCHEMA_VERSION,
19 from benchmarks.density_matrix.performance_evidence.phase31_counted_matrix_validation
import (
20 build_artifact_bundle,
23 from benchmarks.density_matrix.performance_evidence.records
import (
24 build_phase31_decision_summary,
25 build_phase31_counted_performance_record,
31 assert len(inventory) == 26
32 assert sum(case[
"benchmark_slice"] ==
"phase31_structured_performance" for case
in inventory) == 24
33 assert sum(case[
"benchmark_slice"] ==
"phase31_control_performance" for case
in inventory) == 2
34 assert all(case[
"counted_phase31_case"]
is True for case
in inventory)
35 assert all(case[
"claim_surface_id"] ==
"phase31_bounded_mixed_motif_v1" for case
in inventory)
40 assert len(contexts) == 26
41 assert sum(ctx.metadata[
"benchmark_slice"] ==
"phase31_structured_performance" for ctx
in contexts) == 24
42 assert sum(ctx.metadata[
"benchmark_slice"] ==
"phase31_control_performance" for ctx
in contexts) == 2
49 assert record[
"record_schema_version"] == PERFORMANCE_EVIDENCE_PHASE31_CASE_SCHEMA_VERSION
50 assert record[
"artifact_kind"] ==
"phase31_counted_performance_matrix_row" 51 assert record[
"counted_phase31_case"]
is True 52 assert record[
"claim_surface_id"] ==
"phase31_bounded_mixed_motif_v1" 53 assert record[
"representation_primary"] ==
"kraus_bundle" 54 assert record[
"contains_noise"]
is True 55 assert record[
"runtime_class"] ==
"phase31_channel_native_hybrid" 56 assert record[
"build_policy_id"] ==
"phase31_scalar_only_v1" 57 assert record[
"build_flavor"] ==
"scalar" 58 assert record[
"simd_enabled"]
is False 59 assert record[
"tbb_enabled"]
is False 60 assert record[
"thread_count"] == 1
61 assert record[
"counted_claim_build"]
is True 62 assert record[
"timing_mode"] ==
"median_3" 63 assert record[
"decision_class"]
in {
66 "phase31_not_justified_yet",
68 assert isinstance(record[
"hybrid_partition_route_records"], list)
69 assert len(record[
"hybrid_partition_route_records"]) == (
70 record[
"channel_native_partition_count"] + record[
"phase3_routed_partition_count"]
73 "channel_native_partition_count",
74 "phase3_routed_partition_count",
75 "channel_native_member_count",
76 "phase3_routed_member_count",
79 assert record[key] >= 0
81 "sequential_runtime_ms_samples",
82 "phase3_fused_runtime_ms_samples",
83 "phase31_hybrid_runtime_ms_samples",
85 assert len(record[key]) == 3
91 assert bundle[
"status"] ==
"pass" 92 assert bundle[
"record_schema_version"] == PERFORMANCE_EVIDENCE_PHASE31_CASE_SCHEMA_VERSION
93 summary = bundle[
"summary"]
94 assert summary[
"total_cases"] == 26
95 assert summary[
"primary_rows"] == 24
96 assert summary[
"control_rows"] == 2
97 assert summary[
"baseline_trio_present"]
is True 98 assert summary[
"route_fields_present"]
is True 99 assert summary[
"build_metadata_present"]
is True 100 assert summary[
"inventory_match"]
is True 101 assert summary[
"decision_rows"] == 26
102 assert summary[
"decision_inventory_match"]
is True 103 assert summary[
"break_even_table_rows"] == 26
104 assert summary[
"justification_map_rows"] == 26
110 assert decision_summary[
"total_cases"] == 26
111 assert len(decision_summary[
"break_even_table"]) == 26
112 assert len(decision_summary[
"justification_map"]) == 26
113 assert decision_summary[
"decision_class_counts"][
"phase3_sufficient"] >= 0
114 assert decision_summary[
"decision_class_counts"][
"phase31_justified"] >= 0
115 assert decision_summary[
"decision_class_counts"][
"phase31_not_justified_yet"] >= 0
117 entry[
"case_name"]
for entry
in decision_summary[
"break_even_table"]
118 ) == sorted(case[
"case_name"]
for case
in cases)
119 assert set(decision_summary[
"justification_map"]) == {
120 case[
"case_name"]
for case
in cases
def build_phase31_counted_performance_case_contexts()
def test_phase31_counted_matrix_inventory_frozen()
def test_phase31_counted_matrix_decision_summary_machine_readable()
def build_artifact_bundle(results)
def build_phase31_counted_performance_record(case_context)
def test_phase31_counted_matrix_bundle_summary()
def test_phase31_counted_matrix_contexts_frozen()
def test_phase31_counted_matrix_record_fields()
def build_phase31_counted_performance_inventory_cases()
def build_phase31_decision_summary