Skip to content

feat(stage5): After a checkpoint resume with a different runner or model the Stage 5 calibration... - #468

Merged
thomashan merged 19 commits into
mainfrom
I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_
Dec 1, 2026
Merged

thomashan merged 19 commits into
mainfrom
I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_

Conversation

@thomashan

Copy link
Copy Markdown
Collaborator

Summary

After a checkpoint resume with a different runner or model the Stage 5 calibration report still names the plan's original agent as its evaluating agent, and Stage 2 writes two different predicted EV values (a computed one to the plans ledger row and the planner agent's own number to the plan markdown) while Stage 5 silently calibrates against the ledger row.

Goal:
Make Stage 5 name the evaluator that actually ran calibration and make the predicted EV one value in both plan sources. (1) Evaluating agent: add optional evaluating-agent and evaluating-model inputs to the run_calibrate review keyword set in apps/sandbox-executor/src/sandbox_executor/calibration_self_check.py, pass them through apps/sandbox-executor/src/sandbox_executor/calibration/run.py into generate_calibration in apps/sandbox-executor/src/sandbox_executor/calibration/generate.py, and have apps/sandbox-executor/src/sandbox_executor/flow/stage5.py pass the flow context agent and model (the resumed runner and model after a checkpoint resume with a changed --agent or --model) when it calls the calibrate step; the standalone call in apps/sandbox-executor/src/sandbox_executor/cli/commands/calibrate.py passes none and keeps today's fallback attribution. The report header in apps/sandbox-executor/src/sandbox_executor/calibration/report.py labels 'Evaluating Agent' with the evaluator and adds a separate labelled line for the plan's own agent and model (from the plans row); apps/sandbox-executor/src/sandbox_executor/calibration_record.py adds calibration_agent, calibration_model, plan_agent and plan_model to the ACT-CAL row (new keys only; no existing key changes; none is named agent or model). (2) One predicted EV: add apps/sandbox-executor/src/sandbox_executor/plan_ev_sync.py (new) with a helper that writes the single computed EV value into the plan markdown's '## Overall Plan Metrics' table as the ev_pred row (replacing the planner agent's own number, or inserting the row when absent) and a check that re-reads both the markdown value and the plans.jsonl row; apps/sandbox-executor/src/sandbox_executor/entrypoint/planner.py computes EV once, rounds it once, uses that one variable for both the markdown row and the plans.jsonl row, runs the helper before the existing Prettier convergence and ledger append, and fails the plan attempt through the existing _fail_plan_attempt path when the re-read values differ; keep planner.py within its existing 655-line module budget by keeping the new logic in the new module. In apps/sandbox-executor/src/sandbox_executor/calibration_predicted.py a difference above the existing 0.01 tolerance between the selected plans row EV and the plan file's Overall Plan Metrics EV raises a dedicated error naming both values and the plan file instead of only logging a warning; other fields and the execution-summary source stay advisory warnings. That error propagates out of generate_calibration so Stage 5 fails closed through its existing failure path and writes no calibration report. Update the ACT-CAL and cross-check wording in docs/ledger_schema.md. Never modify holon-config/hygiene/module_budgets.json and keep every module within its existing budget. Update the golden report fixtures apps/sandbox-executor/tests/fixtures/calibration_report_golden.txt and apps/sandbox-executor/tests/fixtures/calibration_merge_main_expected.md and the tests apps/sandbox-executor/tests/test_calibration_report.py, apps/sandbox-executor/tests/test_calibration_regression_merge_main.py and apps/sandbox-executor/tests/test_calibration_plan_keys.py (its warning-only EV mismatch test becomes a raises test), and add new tests in apps/sandbox-executor/tests/test_calibration_evaluating_agent.py (new), apps/sandbox-executor/tests/test_calibration_ev_fail_closed.py (new) and apps/sandbox-executor/tests/test_plan_ev_sync.py (new); tests/test_planner.py is 934 lines so no test is added to it; the existing byte-for-byte comparison in apps/sandbox-executor/tests/test_planner_plan_fence_format.py is kept passing by writing the EV into the plan markdown in the same minimal number form the plans row uses (7.0 stays 7.0), and apps/sandbox-executor/tests/test_calibrate_full_stage5.py, apps/sandbox-executor/tests/flow/stages/test_calibrate.py, apps/sandbox-executor/tests/test_calibration_self_check.py, apps/sandbox-executor/tests/test_calibration_report_self_explaining_counts.py, apps/sandbox-executor/tests/test_unique_stage_ids.py and apps/sandbox-executor/tests/test_ledger_merged_parity.py are updated only where the new keyword inputs or the raised error require it. The exact ACT-CAL key list pinned by test_run_calibrate_appends_and_commits_act_cal in apps/sandbox-executor/tests/test_calibration_commit.py is extended with the four new keys in the order calibration_record.py writes them (its other assertions stay); apps/sandbox-executor/tests/test_calibrate_no_fallback.py, apps/sandbox-executor/tests/test_calibrate_rerun.py, apps/sandbox-executor/tests/flow/test_pipeline.py and apps/sandbox-executor/tests/test_calibration_metrics.py read ACT-CAL rows or the predicted EV and apps/sandbox-executor/src/sandbox_executor/calibration/predicted.py parses the plan markdown EV; they are changed only where the new keys or the raised error require it. Code is self-explaining: no docstrings and no comments except '# why:' comments that record a reason the code cannot show.

Key Changes

  • Implement After a checkpoint resume with a different runner or model the Stage 5 calibration report still names the plan's original agent as its evaluating agent, and Stage 2 writes two different predicted EV values (a computed one to the plans ledger row and the planner agent's own number to the plan markdown) while Stage 5 silently calibrates against the ledger row.

References

None

Plan & Validation Metadata

  • Plan ID: P-1796100517-CLA-CO5.5
  • Expected Value (EV): 43.90
  • Agent: claude-agent
  • Model: claude-opus-5-5

Holon Intent Agent and others added 12 commits December 1, 2026 04:48
Description:
After a checkpoint resume with a different runner or model the Stage 5 calibration report still names the plan's original agent as its evaluating agent, and Stage 2 writes two different predicted EV values (a computed one to the plans ledger row and the planner agent's own number to the plan markdown) while Stage 5 silently calibrates against the ledger row.

Goal:
Make Stage 5 name the evaluator that actually ran calibration and make the predicted EV one value in both plan sources. (1) Evaluating agent: add optional evaluating-agent and evaluating-model inputs to the run_calibrate review keyword set in apps/sandbox-executor/src/sandbox_executor/calibration_self_check.py, pass them through apps/sandbox-executor/src/sandbox_executor/calibration/run.py into generate_calibration in apps/sandbox-executor/src/sandbox_executor/calibration/generate.py, and have apps/sandbox-executor/src/sandbox_executor/flow/stage5.py pass the flow context agent and model (the resumed runner and model after a checkpoint resume with a changed --agent or --model) when it calls the calibrate step; the standalone call in apps/sandbox-executor/src/sandbox_executor/cli/commands/calibrate.py passes none and keeps today's fallback attribution. The report header in apps/sandbox-executor/src/sandbox_executor/calibration/report.py labels 'Evaluating Agent' with the evaluator and adds a separate labelled line for the plan's own agent and model (from the plans row); apps/sandbox-executor/src/sandbox_executor/calibration_record.py adds calibration_agent, calibration_model, plan_agent and plan_model to the ACT-CAL row (new keys only; no existing key changes; none is named agent or model). (2) One predicted EV: add apps/sandbox-executor/src/sandbox_executor/plan_ev_sync.py (new) with a helper that writes the single computed EV value into the plan markdown's '## Overall Plan Metrics' table as the ev_pred row (replacing the planner agent's own number, or inserting the row when absent) and a check that re-reads both the markdown value and the plans.jsonl row; apps/sandbox-executor/src/sandbox_executor/entrypoint/planner.py computes EV once, rounds it once, uses that one variable for both the markdown row and the plans.jsonl row, runs the helper before the existing Prettier convergence and ledger append, and fails the plan attempt through the existing _fail_plan_attempt path when the re-read values differ; keep planner.py within its existing 655-line module budget by keeping the new logic in the new module. In apps/sandbox-executor/src/sandbox_executor/calibration_predicted.py a difference above the existing 0.01 tolerance between the selected plans row EV and the plan file's Overall Plan Metrics EV raises a dedicated error naming both values and the plan file instead of only logging a warning; other fields and the execution-summary source stay advisory warnings. That error propagates out of generate_calibration so Stage 5 fails closed through its existing failure path and writes no calibration report. Update the ACT-CAL and cross-check wording in docs/ledger_schema.md. Never modify holon-config/hygiene/module_budgets.json and keep every module within its existing budget. Update the golden report fixtures apps/sandbox-executor/tests/fixtures/calibration_report_golden.txt and apps/sandbox-executor/tests/fixtures/calibration_merge_main_expected.md and the tests apps/sandbox-executor/tests/test_calibration_report.py, apps/sandbox-executor/tests/test_calibration_regression_merge_main.py and apps/sandbox-executor/tests/test_calibration_plan_keys.py (its warning-only EV mismatch test becomes a raises test), and add new tests in apps/sandbox-executor/tests/test_calibration_evaluating_agent.py (new), apps/sandbox-executor/tests/test_calibration_ev_fail_closed.py (new) and apps/sandbox-executor/tests/test_plan_ev_sync.py (new); tests/test_planner.py is 934 lines so no test is added to it; the existing byte-for-byte comparison in apps/sandbox-executor/tests/test_planner_plan_fence_format.py is kept passing by writing the EV into the plan markdown in the same minimal number form the plans row uses (7.0 stays 7.0), and apps/sandbox-executor/tests/test_calibrate_full_stage5.py, apps/sandbox-executor/tests/flow/stages/test_calibrate.py, apps/sandbox-executor/tests/test_calibration_self_check.py, apps/sandbox-executor/tests/test_calibration_report_self_explaining_counts.py, apps/sandbox-executor/tests/test_unique_stage_ids.py and apps/sandbox-executor/tests/test_ledger_merged_parity.py are updated only where the new keyword inputs or the raised error require it. The exact ACT-CAL key list pinned by test_run_calibrate_appends_and_commits_act_cal in apps/sandbox-executor/tests/test_calibration_commit.py is extended with the four new keys in the order calibration_record.py writes them (its other assertions stay); apps/sandbox-executor/tests/test_calibrate_no_fallback.py, apps/sandbox-executor/tests/test_calibrate_rerun.py, apps/sandbox-executor/tests/flow/test_pipeline.py and apps/sandbox-executor/tests/test_calibration_metrics.py read ACT-CAL rows or the predicted EV and apps/sandbox-executor/src/sandbox_executor/calibration/predicted.py parses the plan markdown EV; they are changed only where the new keys or the raised error require it. Code is self-explaining: no docstrings and no comments except '# why:' comments that record a reason the code cannot show.

Generated by Holon Intent Agent at 2026-12-01T04:48:20Z
…5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/_
…3 (iteration 1)

Action-Origin: pr_review
Review-Iteration: 1
Review-Finding-Ids: R1-F1, R1-F2, R2-F1, R3-F1, R3-F2, R3-F3
Review-Severity: important
Action-Origin: pr_review
Review-Iteration: 1

@thomashan thomashan left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Ensemble Consensus Review — APPROVED (3/3)

Reviewed stage5-evaluator-plan-ev-sync at 6cf9b5d9 against main: 0 critical, 0 important and 0 nit findings; CI passing; mergeability UNMEASURED.

Role reviews:

Role (activated) Verdict Review
Engineering PASS Ledger snapshot and restore rolls back the refused plans row, including new fragments; the bare ev row and the N/A fallback are fixed.
Testing PASS Ran the targeted suites (45 passed); the refusal test now asserts an empty plans ledger and the bare ev row test is added.

Verified:

  • A refused plan attempt leaves no plans.jsonl row — apps/sandbox-executor/tests/test_plan_ev_sync.py::test_stage2_fails_the_attempt_when_the_reread_values_differ
  • An agent-written bare ev row is rewritten in place — apps/sandbox-executor/tests/test_plan_ev_sync.py::test_an_agent_written_bare_ev_row_is_rewritten_in_place
  • Plan Agent header falls back to N/A for a missing model — apps/sandbox-executor/src/sandbox_executor/calibration/report.py
  • No added docstrings or explanatory comments — scripts/check_self_explaining.py
  • A refused plan attempt leaves no plans row in the canonical ledger or pending fragments — apps/sandbox-executor/tests/test_plan_ev_sync.py::test_stage2_fails_the_attempt_when_the_reread_values_differ
  • A bare 'ev' row in Overall Plan Metrics is rewritten in place — apps/sandbox-executor/tests/test_plan_ev_sync.py::test_an_agent_written_bare_ev_row_is_rewritten_in_place
  • A refused plan attempt leaves no plans.jsonl row behind — apps/sandbox-executor/tests/test_plan_ev_sync.py::test_stage2_fails_the_attempt_when_the_reread_values_differ
  • An agent-written bare ev row is rewritten in place without adding an ev_pred row — apps/sandbox-executor/tests/test_plan_ev_sync.py::test_an_agent_written_bare_ev_row_is_rewritten_in_place

Checks: Mergeability UNMEASURED · CI 16/16 passed, 0 failing, 0 pending (source: ci_head)

Covers head 6cf9b5d; change fingerprint pf2:76d4a6ea79cb; CI at that commit: 16 of 16 checks passed.

🗳️ Ensemble Review Breakdown

  • Reviewer 1 (claude-agent / claude-opus-5-5): APPROVED (critical: 0, important: 0, nit: 0)
  • Reviewer 2 (claude-agent / claude-opus-5-5): APPROVED (critical: 0, important: 0, nit: 0)
  • Reviewer 3 (claude-agent / claude-opus-5-5): APPROVED (critical: 0, important: 0, nit: 0)
  • Ensemble Consensus Verdict: APPROVED

Reviewed by claude-agent (3-Agent Ensemble) · Model claude-opus-5-5

Stage 5 calibration will be added to this PR before merge. Merging remains with the human maintainer.

@thomashan
thomashan added this pull request to the merge queue Dec 1, 2026
Merged via the queue into main with commit 1ecfcee Dec 1, 2026
16 checks passed
@thomashan
thomashan deleted the I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_ branch December 1, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant