2 """Phase 3.1 counted performance matrix validation (P31-S11-E01). 4 Freezes the full bounded 26-row Phase 3.1 counted performance inventory and 5 one comparable row schema for every counted case. 8 python benchmarks/density_matrix/performance_evidence/phase31_counted_matrix_validation.py 11 from __future__
import annotations
14 from pathlib
import Path
16 REPO_ROOT = Path(__file__).resolve().parents[3]
17 if str(REPO_ROOT)
not in sys.path:
18 sys.path.insert(0, str(REPO_ROOT))
20 from benchmarks.density_matrix.performance_evidence.case_selection
import (
21 build_phase31_counted_performance_inventory_cases,
23 from benchmarks.density_matrix.performance_evidence.common
import (
24 PERFORMANCE_EVIDENCE_PHASE31_CASE_SCHEMA_VERSION,
25 performance_evidence_output_dir,
27 from benchmarks.density_matrix.performance_evidence.records
import (
28 build_phase31_decision_summary,
29 build_phase31_counted_performance_records,
31 from benchmarks.density_matrix.performance_evidence.validation_support
import (
32 assemble_record_schema_case_bundle,
34 from benchmarks.density_matrix.validation_scaffold
import (
35 require_bundle_fields,
39 SUITE_NAME =
"performance_evidence_phase31_counted_matrix" 40 ARTIFACT_FILENAME =
"phase31_counted_matrix_bundle.json" 42 ARTIFACT_CORE_FIELDS = (
45 "record_schema_version",
59 case_ids = [case[
"case_name"]
for case
in cases]
60 inventory_ids = [case[
"case_name"]
for case
in inventory]
62 primary_rows = sum(case[
"benchmark_slice"] ==
"phase31_structured_performance" for case
in cases)
63 control_rows = sum(case[
"benchmark_slice"] ==
"phase31_control_performance" for case
in cases)
64 route_fields_present = all(
68 "channel_native_partition_count",
69 "phase3_routed_partition_count",
70 "channel_native_member_count",
71 "phase3_routed_member_count",
72 "hybrid_partition_route_records",
75 baseline_trio_present = all(
79 "sequential_median_runtime_ms",
80 "phase3_fused_median_runtime_ms",
81 "phase31_hybrid_median_runtime_ms",
82 "sequential_median_peak_rss_kb",
83 "phase3_fused_median_peak_rss_kb",
84 "phase31_hybrid_median_peak_rss_kb",
87 build_metadata_present = all(
96 "counted_claim_build",
102 and case_ids == inventory_ids
103 and len(set(case_ids)) == len(case_ids)
104 and primary_rows == 24
105 and control_rows == 2
106 and route_fields_present
107 and baseline_trio_present
108 and build_metadata_present
109 and decision_summary[
"inventory_match"]
110 and len(decision_summary[
"break_even_table"]) == 26
111 and len(decision_summary[
"justification_map"]) == 26
115 "total_cases": len(cases),
116 "primary_rows": primary_rows,
117 "control_rows": control_rows,
118 "route_fields_present": route_fields_present,
119 "baseline_trio_present": baseline_trio_present,
120 "build_metadata_present": build_metadata_present,
121 "inventory_match": case_ids == inventory_ids,
122 "decision_rows": decision_summary[
"total_cases"],
123 "decision_inventory_match": decision_summary[
"inventory_match"],
124 "phase3_sufficient_rows": decision_summary[
"phase3_sufficient_rows"],
125 "phase31_justified_rows": decision_summary[
"phase31_justified_rows"],
126 "phase31_not_justified_yet_rows": decision_summary[
"phase31_not_justified_yet_rows"],
127 "break_even_table_rows": len(decision_summary[
"break_even_table"]),
128 "justification_map_rows": len(decision_summary[
"justification_map"]),
136 bundle[
"record_schema_version"] = PERFORMANCE_EVIDENCE_PHASE31_CASE_SCHEMA_VERSION
137 bundle[
"decision_summary"] = decision_summary
142 def main(argv: list[str] |
None =
None) -> int:
145 build_cases=build_cases,
146 build_artifact_bundle=build_artifact_bundle,
147 artifact_filename=ARTIFACT_FILENAME,
148 default_output_dir=DEFAULT_OUTPUT_DIR,
149 description=__doc__
or "",
150 output_dir_help=
"Directory to write the Phase 3.1 counted matrix bundle into.",
151 quiet_report=
lambda b: print(
152 "total_cases={total_cases}, primary_rows={primary_rows}, control_rows={control_rows}, status={status}".format(
160 if __name__ ==
"__main__":
161 raise SystemExit(
main())
def build_artifact_bundle
def build_phase31_counted_performance_records()
def performance_evidence_output_dir
def assemble_record_schema_case_bundle
def build_phase31_counted_performance_inventory_cases()
def build_phase31_decision_summary
def require_bundle_fields