2 """Summary-consistency guardrails for performance evidence. 4 Interprets the shared benchmark package and verifies that downstream rollups, 5 limitation carry-forward, and claim-closure flags stay consistent with the 6 underlying per-case evidence. 9 python benchmarks/density_matrix/performance_evidence/summary_consistency_validation.py 12 from __future__
import annotations
16 from pathlib
import Path
18 REPO_ROOT = Path(__file__).resolve().parents[3]
19 if str(REPO_ROOT)
not in sys.path:
20 sys.path.insert(0, str(REPO_ROOT))
22 from benchmarks.density_matrix.performance_evidence.benchmark_bundle_validation
import (
23 build_performance_evidence_benchmark_package,
25 from benchmarks.density_matrix.performance_evidence.common
import (
26 PERFORMANCE_EVIDENCE_SUMMARY_SCHEMA_VERSION,
27 build_package_software_metadata,
28 performance_evidence_output_dir,
29 write_artifact_bundle,
31 from benchmarks.density_matrix.validation_scaffold
import require_bundle_fields
33 SUITE_NAME =
"performance_evidence_summary_consistency" 34 ARTIFACT_FILENAME =
"summary_consistency_bundle.json" 36 ARTIFACT_CORE_FIELDS = (
50 cases = benchmark_package[
"cases"]
51 negative_cases = benchmark_package[
"negative_cases"]
52 counted_supported_cases = sum(case[
"counted_supported_benchmark_case"]
for case
in cases)
53 positive_threshold_pass_cases = sum(case[
"positive_threshold_pass"]
for case
in cases)
54 diagnosis_only_cases = sum(case[
"diagnosis_only_case"]
for case
in cases)
55 excluded_cases = sum(case[
"benchmark_status"] ==
"excluded" for case
in cases)
56 representative_review_cases = sum(case[
"representative_review_case"]
for case
in cases)
58 summary_consistency_pass = (
59 benchmark_package[
"summary"][
"total_cases"] == len(cases)
60 and benchmark_package[
"summary"][
"counted_supported_cases"] == counted_supported_cases
61 and benchmark_package[
"summary"][
"positive_threshold_pass_cases"]
62 == positive_threshold_pass_cases
63 and benchmark_package[
"summary"][
"diagnosis_only_cases"] == diagnosis_only_cases
64 and benchmark_package[
"summary"][
"excluded_cases"] == excluded_cases
65 and benchmark_package[
"summary"][
"representative_review_cases"]
66 == representative_review_cases
67 and benchmark_package[
"summary"][
"correctness_evidence_boundary_cases"] == len(negative_cases)
70 positive_benchmark_claim_completed = positive_threshold_pass_cases >= 1
71 diagnosis_grounded_closure_completed = (
72 positive_threshold_pass_cases == 0
73 and diagnosis_only_cases >= 1
74 and all(case[
"diagnosis_reasons"]
for case
in cases
if case[
"diagnosis_only_case"])
75 and len(negative_cases) > 0
77 main_benchmark_claim_completed = (
78 positive_benchmark_claim_completed
or diagnosis_grounded_closure_completed
82 "suite_name": SUITE_NAME,
83 "status":
"pass" if summary_consistency_pass
and main_benchmark_claim_completed
else "fail",
84 "schema_version": PERFORMANCE_EVIDENCE_SUMMARY_SCHEMA_VERSION,
86 "selected_candidate": benchmark_package[
"selected_candidate"],
88 "positive_claim_rule": (
89 "Only counted representative performance-evidence cases may close a " 90 "positive benchmark claim." 93 "If no representative case meets the positive threshold, diagnosis-" 94 "only cases must remain benchmark-grounded and visible as explicit " 95 "limitation evidence." 97 "boundary_visibility_rule": (
98 "Excluded, unsupported, or deferred evidence must remain visible " 99 "as claim-boundary evidence in downstream summaries." 103 "summary_consistency_pass": summary_consistency_pass,
104 "positive_benchmark_claim_completed": positive_benchmark_claim_completed,
105 "diagnosis_grounded_closure_completed": diagnosis_grounded_closure_completed,
106 "main_benchmark_claim_completed": main_benchmark_claim_completed,
107 "counted_supported_cases": counted_supported_cases,
108 "positive_threshold_pass_cases": positive_threshold_pass_cases,
109 "diagnosis_only_cases": diagnosis_only_cases,
110 "excluded_cases": excluded_cases,
111 "representative_review_cases": representative_review_cases,
112 "correctness_evidence_boundary_cases": len(negative_cases),
114 "required_artifacts": [
116 "artifact_id":
"benchmark_package",
117 "suite_name": benchmark_package[
"suite_name"],
118 "status": benchmark_package[
"status"],
119 "schema_version": benchmark_package[
"schema_version"],
127 def main(argv: list[str] |
None =
None) -> int:
128 parser = argparse.ArgumentParser(description=__doc__)
132 default=DEFAULT_OUTPUT_DIR,
133 help=
"Directory to write the summary consistency bundle into.",
138 help=
"Suppress console output.",
140 args = parser.parse_args(argv)
147 "summary_consistency_pass={summary_consistency_pass}, main_benchmark_claim_completed={main_benchmark_claim_completed}".format(
151 print(
"Wrote {}".format(output_path))
153 return 0
if bundle[
"status"] ==
"pass" else 1
156 if __name__ ==
"__main__":
157 raise SystemExit(
main())
def build_package_software_metadata()
def performance_evidence_output_dir
def build_summary_consistency_bundle()
def build_performance_evidence_benchmark_package()
def write_artifact_bundle
def require_bundle_fields