2 """Validation: Phase 3 planner-calibration supported-claim selection surface. 4 Selects one supported planner claim from the correctness-gated calibration 5 matrix using an explicit benchmark-grounded rule and keeps the other candidate 6 settings visible as comparison baselines. 9 python benchmarks/density_matrix/planner_calibration/calibrated_claim_selection_validation.py 12 from __future__
import annotations
17 from pathlib
import Path
19 REPO_ROOT = Path(__file__).resolve().parents[3]
20 if str(REPO_ROOT)
not in sys.path:
21 sys.path.insert(0, str(REPO_ROOT))
23 from benchmarks.density_matrix.planner_calibration.claim_selection
import (
24 PLANNER_CALIBRATION_CLAIM_SELECTION_SCHEMA_VERSION,
25 PLANNER_CALIBRATION_CLAIM_SELECTION_RULE,
26 PLANNER_CALIBRATION_CLAIM_STATUS_COMPARISON,
27 PLANNER_CALIBRATION_CLAIM_STATUS_SUPPORTED,
28 build_planner_calibration_claim_selection_payload,
30 from benchmarks.density_matrix.planner_surface.common
import build_software_metadata
32 SUITE_NAME =
"phase3_planner_calibration_claim_selection" 33 ARTIFACT_FILENAME =
"claim_selection_bundle.json" 34 DEFAULT_OUTPUT_DIR = (
39 /
"planner_calibration" 42 ARTIFACT_CORE_FIELDS = (
45 "claim_selection_schema_version",
48 "candidate_summaries",
59 cases = payload[
"cases"]
60 candidate_summaries = payload[
"candidate_summaries"]
61 selected_candidate = payload[
"selected_candidate"]
62 supported_claim_cases = sum(
63 case[
"claim_status"] == PLANNER_CALIBRATION_CLAIM_STATUS_SUPPORTED
for case
in cases
65 comparison_cases = sum(
66 case[
"claim_status"] == PLANNER_CALIBRATION_CLAIM_STATUS_COMPARISON
for case
in cases
69 "suite_name": SUITE_NAME,
71 if supported_claim_cases > 0
72 and comparison_cases > 0
73 and len(candidate_summaries) == 3
75 "claim_selection_schema_version": PLANNER_CALIBRATION_CLAIM_SELECTION_SCHEMA_VERSION,
78 "total_cases": len(cases),
79 "supported_claim_cases": supported_claim_cases,
80 "comparison_cases": comparison_cases,
81 "selected_candidate_id": selected_candidate[
"candidate_id"],
82 "claim_selection_rule": PLANNER_CALIBRATION_CLAIM_SELECTION_RULE,
84 "selected_candidate": selected_candidate,
85 "candidate_summaries": candidate_summaries,
88 missing = [field
for field
in ARTIFACT_CORE_FIELDS
if field
not in bundle]
91 "Calibrated claim-selection bundle missing required fields: {}".format(
99 output_dir.mkdir(parents=
True, exist_ok=
True)
100 output_path = output_dir / ARTIFACT_FILENAME
101 output_path.write_text(json.dumps(bundle, indent=2, sort_keys=
True) +
"\n")
105 def main(argv: list[str] |
None =
None) -> int:
106 parser = argparse.ArgumentParser(description=__doc__)
110 default=DEFAULT_OUTPUT_DIR,
111 help=
"Directory to write the calibrated claim-selection bundle into.",
116 help=
"Suppress per-case console output.",
118 args = parser.parse_args(argv)
125 "selected_candidate={selected_candidate_id}, rule={claim_selection_rule}".format(
129 print(
"Wrote {}".format(output_path))
131 return 0
if bundle[
"status"] ==
"pass" else 1
134 if __name__ ==
"__main__":
135 raise SystemExit(
main())
def write_artifact_bundle
def build_software_metadata()
def build_planner_calibration_claim_selection_payload()
def build_artifact_bundle()