diff --git a/apps/sandbox-executor/src/sandbox_executor/calibration/generate.py b/apps/sandbox-executor/src/sandbox_executor/calibration/generate.py index d81fcac3b..ce7ff7598 100644 --- a/apps/sandbox-executor/src/sandbox_executor/calibration/generate.py +++ b/apps/sandbox-executor/src/sandbox_executor/calibration/generate.py @@ -121,6 +121,17 @@ def _attribution(exec_meta: dict[str, Any], plan_meta: dict[str, Any]) -> tuple[ return agent_id, agent_version, model_name +def _evaluator( + attribution: tuple[str, str, str], evaluating_agent: str | None, evaluating_model: str | None +) -> tuple[str, str]: + agent_id, _agent_version, model_name = attribution + return evaluating_agent or agent_id, evaluating_model or model_name + + +def _plan_attribution(plan_meta: dict[str, Any]) -> tuple[str, str]: + return plan_meta.get("agent") or "N/A", plan_meta.get("model") or "N/A" + + def _entropy_factors(actual: ActualMetrics, exec_meta: dict[str, Any]) -> EntropyFactors: """Predicted versus observed entropy factors; the observed SSA is the measured one, else a file-count fallback.""" ssa_fallback = 0.0 if actual.files_changed == 0 else max(0.2, actual.files_changed * 0.1) @@ -132,6 +143,9 @@ def generate_calibration( execution_branch: str, target_worktree: str = ".", review_accounting: dict[str, Any] | None = None, + *, + evaluating_agent: str | None = None, + evaluating_model: str | None = None, ) -> CalibrationReport: """Run calibration calculation and return a complete CalibrationReport. @@ -159,7 +173,10 @@ def generate_calibration( execution_id, resolved_plan_ref, predicted, execution_branch=resolved_exec_ref, target_worktree=target_worktree ) deltas, ratings, biases = compute_calibration_deltas(predicted, actual) - agent_id, agent_version, model_name = _attribution(exec_meta, plan_meta) + attribution = _attribution(exec_meta, plan_meta) + _, agent_version, _ = attribution + agent_id, model_name = _evaluator(attribution, evaluating_agent, evaluating_model) + plan_agent, plan_model = _plan_attribution(plan_meta) timestamp_str = datetime.now(UTC).strftime("%Y-%m-%dT%H:%M:%S.000Z") lambda_val, mu_val = load_metrics_physics(target_worktree) ef = _entropy_factors(actual, exec_meta) @@ -174,6 +191,8 @@ def generate_calibration( "agent_id": agent_id, "agent_version": agent_version, "model_name": model_name, + "plan_agent": plan_agent, + "plan_model": plan_model, "timestamp": timestamp_str, "predicted": predicted.to_dict(), "actual": actual.to_dict(), diff --git a/apps/sandbox-executor/src/sandbox_executor/calibration/report.py b/apps/sandbox-executor/src/sandbox_executor/calibration/report.py index 9feb3bd9e..7d4f15a2a 100644 --- a/apps/sandbox-executor/src/sandbox_executor/calibration/report.py +++ b/apps/sandbox-executor/src/sandbox_executor/calibration/report.py @@ -74,6 +74,8 @@ class CalibrationReport: touch_set: dict[str, Any] | None = None diff_base: str | None = None review_accounting: dict[str, Any] | None = None + plan_agent: str | None = None + plan_model: str | None = None # Self-check inputs, not serialised: the counted (non-metadata) paths and the ledger summary rows read. changed_paths: list[str] | None = None summary_records: list[dict[str, Any]] = dataclasses.field(default_factory=list) @@ -102,6 +104,10 @@ def _header_lines(report_data: dict[str, Any]) -> list[str]: f"- **Execution Branch:** `{report_data.get('execution_branch') or 'N/A'}`", f"- **Intent Branch:** `{report_data['intent_branch']}`", f"- **Evaluating Agent:** `{report_data['agent_id']}/{report_data['model_name']}`", + ] + if "plan_agent" in report_data: + lines.append(f"- **Plan Agent:** `{report_data['plan_agent']}/{report_data.get('plan_model') or 'N/A'}`") + lines += [ f"- **Evaluation Timestamp:** `{report_data['timestamp']}`", f"- **Evaluated Commit SHA:** {sha_display}", ] diff --git a/apps/sandbox-executor/src/sandbox_executor/calibration/run.py b/apps/sandbox-executor/src/sandbox_executor/calibration/run.py index dbadace6d..08e17891b 100644 --- a/apps/sandbox-executor/src/sandbox_executor/calibration/run.py +++ b/apps/sandbox-executor/src/sandbox_executor/calibration/run.py @@ -140,8 +140,13 @@ def run_calibrate( log_fn: Callable[[str], None] | None = None, **review: Unpack[CalibrateReview], ) -> CalibrationReport: - accounting = review.get("review_accounting") - report = generate_calibration(execution_branch, target_worktree=target_worktree, review_accounting=accounting) + report = generate_calibration( + execution_branch, + target_worktree=target_worktree, + review_accounting=review.get("review_accounting"), + evaluating_agent=review.get("evaluating_agent"), + evaluating_model=review.get("evaluating_model"), + ) # why: the self-check fails closed before any branch, file or commit is touched enforce_report_self_check(report, target_worktree, review.get("approved_head"), log_fn) report.committed = not skip_commit diff --git a/apps/sandbox-executor/src/sandbox_executor/calibration_predicted.py b/apps/sandbox-executor/src/sandbox_executor/calibration_predicted.py index fa9f7a183..c930ed127 100644 --- a/apps/sandbox-executor/src/sandbox_executor/calibration_predicted.py +++ b/apps/sandbox-executor/src/sandbox_executor/calibration_predicted.py @@ -20,6 +20,18 @@ _METRIC_ROW = re.compile(r"\|\s*([a-zA-Z_0-9]+)\s*\|\s*([0-9\.\-]+)\s*\|") +class PlanEvMismatchError(RuntimeError): + def __init__(self, plan_file: str, ledger_ev: float, plan_file_ev: float) -> None: + self.plan_file = plan_file + self.ledger_ev = ledger_ev + self.plan_file_ev = plan_file_ev + super().__init__( + f"Predicted EV mismatch: plans.jsonl row ev={ledger_ev:g} vs plan file {plan_file} Overall Plan Metrics " + f"ev={plan_file_ev:g}; calibration refused; append a plans correction row (ledger_revision >= 2) or " + "correct the plan file so both carry one EV" + ) + + class PredictedMismatch(NamedTuple): source: str field: str @@ -111,7 +123,7 @@ def execution_predicted_metrics(executions_path: str, execution_id: str, plan_br return _float_fields(latest["predicted_metrics"]) if latest else {} -# why: the warning is advisory; calibration still uses the selected plans row, and ledgers are only ever read here. +# why: advisory, only the plan file EV fails closed; calibration uses the selected plans row and only reads ledgers def cross_check_predicted( selected: dict[str, Any], sources: list[tuple[str, dict[str, float]]] ) -> list[PredictedMismatch]: @@ -140,20 +152,39 @@ def cross_check_predicted( return mismatches +def plan_ev_mismatch( + selected: dict[str, Any], plan_file: str, plan_metrics: dict[str, float] +) -> PlanEvMismatchError | None: + ledger_ev = metrics_from_row(selected).get("ev") + plan_file_ev = plan_metrics.get("ev") + if ledger_ev is None or plan_file_ev is None or abs(ledger_ev - plan_file_ev) <= MISMATCH_TOLERANCE: + return None + return PlanEvMismatchError(plan_file, ledger_ev, plan_file_ev) + + def cross_check_selected_row( selected: dict[str, Any], plan_branch: str, target_worktree: str, execution_id: str = "" ) -> list[PredictedMismatch]: + ev_mismatch: PlanEvMismatchError | None = None + mismatches: list[PredictedMismatch] = [] try: plan_file, plan_metrics = plan_file_overall_metrics(selected, plan_branch, target_worktree) + ev_mismatch = plan_ev_mismatch(selected, plan_file, plan_metrics) executions_path = os.path.join(target_worktree, EXECUTIONS_JSONL_REL) sources = [ - (f"plan file {plan_file} Overall Plan Metrics", plan_metrics), + ( + f"plan file {plan_file} Overall Plan Metrics", + {field: value for field, value in plan_metrics.items() if field != "ev"}, + ), ( f"execution {execution_id} predicted_metrics", execution_predicted_metrics(executions_path, execution_id, plan_branch), ), ] - return cross_check_predicted(selected, [(label, metrics) for label, metrics in sources if metrics]) + mismatches = cross_check_predicted(selected, [(label, metrics) for label, metrics in sources if metrics]) except Exception as e: logger.debug("Predicted-metric cross-check skipped: %s", e) - return [] + # why: raised outside the try so the broad except above cannot turn the fail-closed EV check back into a warning + if ev_mismatch is not None: + raise ev_mismatch + return mismatches diff --git a/apps/sandbox-executor/src/sandbox_executor/calibration_record.py b/apps/sandbox-executor/src/sandbox_executor/calibration_record.py index cd444c0cd..628e233b2 100644 --- a/apps/sandbox-executor/src/sandbox_executor/calibration_record.py +++ b/apps/sandbox-executor/src/sandbox_executor/calibration_record.py @@ -50,4 +50,8 @@ def calibration_action_row( "calibration_report_path": report_rel, "created_at": utc_now_z(), "touch_set_accuracy": data.get("touch_set"), + "calibration_agent": data.get("agent_id"), + "calibration_model": data.get("model_name"), + "plan_agent": data.get("plan_agent"), + "plan_model": data.get("plan_model"), } diff --git a/apps/sandbox-executor/src/sandbox_executor/calibration_self_check.py b/apps/sandbox-executor/src/sandbox_executor/calibration_self_check.py index 80a321b80..0533dc745 100644 --- a/apps/sandbox-executor/src/sandbox_executor/calibration_self_check.py +++ b/apps/sandbox-executor/src/sandbox_executor/calibration_self_check.py @@ -24,6 +24,8 @@ class CalibrateReview(TypedDict, total=False): approved_head: str | None review_accounting: dict[str, Any] | None + evaluating_agent: str | None + evaluating_model: str | None class CalibrationSelfCheckError(RuntimeError): diff --git a/apps/sandbox-executor/src/sandbox_executor/entrypoint/planner.py b/apps/sandbox-executor/src/sandbox_executor/entrypoint/planner.py index 983defc87..ec1145f85 100644 --- a/apps/sandbox-executor/src/sandbox_executor/entrypoint/planner.py +++ b/apps/sandbox-executor/src/sandbox_executor/entrypoint/planner.py @@ -36,6 +36,16 @@ from sandbox_executor.module_budget_guard import module_budget_change_authorised, refusal_message, without_budget_config from sandbox_executor.plan_artifact_format import format_plan_artifact from sandbox_executor.plan_attempt import clear_failure_detail, discard_untracked_plan_file, write_failure_detail +from sandbox_executor.plan_ev_sync import ( + PlanEvSyncError, + PlanMetrics, + check_plan_ev, + plans_ledger_files, + restore_files, + rounded_plan_ev, + snapshot_files, + write_plan_ev, +) from sandbox_executor.plan_paths import plan_file_rel from sandbox_executor.redaction import redact_agent_secrets, redact_command, redact_command_args from sandbox_executor.touch_set import parse_touch_set_section @@ -511,7 +521,7 @@ def build_agent_cmd(prompt_text: str) -> list[str]: impact = metrics["impact"] cost = metrics["cost"] learning_value = metrics["learning_value"] - ev = p_success * impact + ev_mu * learning_value - ev_lambda * entropy - cost + ev = rounded_plan_ev(PlanMetrics(p_success, impact, learning_value, entropy, cost), ev_lambda, ev_mu) metrics["ev"] = ev timestamp_str = datetime.now(UTC).strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z" @@ -533,6 +543,7 @@ def build_agent_cmd(prompt_text: str) -> list[str]: "entropy_budget": entropy_budget, } + write_plan_ev(plan_md_path, ev) # why: format before the ledger append so the recorded decision is parsed from the committed file try: converge_prettier([plan_md_rel], repo_dir=repo_dir) @@ -545,9 +556,16 @@ def build_agent_cmd(prompt_text: str) -> list[str]: plans_ledger_dir = os.path.join(repo_dir, "holon-knowledge/ledger") os.makedirs(plans_ledger_dir, exist_ok=True) plans_ledger_path = os.path.join(plans_ledger_dir, "plans.jsonl") + ledger_before = snapshot_files(plans_ledger_files(plans_ledger_path)) with atomic_ledger_append(plans_ledger_path) as lf: lf.write(json.dumps(plan_entry) + "\n") validate_ledger_file_unique_ids(plans_ledger_path, id_key="plan_id", parent_key="intent_branch") + try: + check_plan_ev(plan_md_path, plans_ledger_path, plan_id, intent_branch) + except PlanEvSyncError as e: + # why: a refused attempt must not leave its plans row for the next attempt's ledger add to commit + restore_files(ledger_before, plans_ledger_files(plans_ledger_path)) + _fail_plan_attempt(repo_dir, plan_md_rel, str(e)) # why: no push here, the host pushes the branch after this container returns run_cmd(["git", "add", plan_md_rel, *ledger_commit_paths(repo_dir, "plans.jsonl")], cwd=repo_dir) diff --git a/apps/sandbox-executor/src/sandbox_executor/flow/stage5.py b/apps/sandbox-executor/src/sandbox_executor/flow/stage5.py index 31c36bcc2..8c94fb1b5 100644 --- a/apps/sandbox-executor/src/sandbox_executor/flow/stage5.py +++ b/apps/sandbox-executor/src/sandbox_executor/flow/stage5.py @@ -219,6 +219,8 @@ def run_stage5( log_fn=context.log, approved_head=approved_head_of(context), review_accounting=accounting_of(context), + evaluating_agent=context.agent, + evaluating_model=context.model, ) context.calibrated_branch = report.calibrated_branch outcome.report_dict = report.to_dict() diff --git a/apps/sandbox-executor/src/sandbox_executor/plan_ev_sync.py b/apps/sandbox-executor/src/sandbox_executor/plan_ev_sync.py new file mode 100644 index 000000000..6381a3cb5 --- /dev/null +++ b/apps/sandbox-executor/src/sandbox_executor/plan_ev_sync.py @@ -0,0 +1,134 @@ +from __future__ import annotations + +import os +import re +from dataclasses import dataclass + +from sandbox_executor.calibration_predicted import MISMATCH_TOLERANCE, OVERALL_HEADING, overall_plan_metrics +from sandbox_executor.ledger import read_merged_rows +from sandbox_executor.ledger.fragments import iter_fragment_files + +EV_ROW = re.compile(r"^(\|\s*ev(?:_pred)?\s*\|)([^|]*)(\|.*)$") + + +class PlanEvSyncError(RuntimeError): + pass + + +@dataclass(frozen=True) +class PlanMetrics: + p_success: float + impact: float + learning_value: float + entropy: float + cost: float + + +def rounded_plan_ev(metrics: PlanMetrics, ev_lambda: float, ev_mu: float) -> float: + reward = metrics.p_success * metrics.impact + ev_mu * metrics.learning_value + return round(reward - ev_lambda * metrics.entropy - metrics.cost, 4) + + +def ev_cell_text(ev: float) -> str: + return repr(float(ev)) + + +def _overall_section_bounds(lines: list[str]) -> tuple[int, int] | None: + start = next((index for index, line in enumerate(lines) if line.startswith(OVERALL_HEADING)), None) + if start is None: + return None + end = next((index for index in range(start + 1, len(lines)) if lines[index].startswith("## ")), len(lines)) + return start, end + + +def _ev_row_with_value(match: re.Match[str], text: str) -> str: + cell = f" {text} " + return f"{match.group(1)}{cell.ljust(len(match.group(2)))}{match.group(3)}" + + +def _aligned_ev_row(previous_row: str, text: str) -> str: + widths = [len(cell) for cell in previous_row.split("|")[1:-1]] + if len(widths) != 2: + return f"| ev_pred | {text} |" + return f"|{' ev_pred '.ljust(widths[0])}|{f' {text} '.ljust(widths[1])}|" + + +def _synced_section(section: list[str], text: str) -> list[str]: + for index, line in enumerate(section): + if match := EV_ROW.match(line): + if match.group(2).strip() == text: + return section + return [*section[:index], _ev_row_with_value(match, text), *section[index + 1 :]] + table_rows = [index for index, line in enumerate(section) if line.startswith("|")] + if not table_rows: + return [*section, f"| ev_pred | {text} |"] + insert_at = table_rows[-1] + 1 + return [*section[:insert_at], _aligned_ev_row(section[insert_at - 1], text), *section[insert_at:]] + + +def write_plan_ev(plan_md_path: str, ev: float) -> bool: + with open(plan_md_path, encoding="utf-8") as f: + content = f.read() + lines = content.split("\n") + bounds = _overall_section_bounds(lines) + if bounds is None: + return False + start, end = bounds + synced = [*lines[: start + 1], *_synced_section(lines[start + 1 : end], ev_cell_text(ev)), *lines[end:]] + if synced == lines: + return False + with open(plan_md_path, "w", encoding="utf-8") as f: + f.write("\n".join(synced)) + return True + + +def _plans_row_ev(plans_ledger_path: str, plan_id: str, intent_branch: str) -> float | None: + rows = [ + row + for row in read_merged_rows(plans_ledger_path) + if row.get("plan_id") == plan_id and row.get("intent_branch") == intent_branch + ] + try: + return float(rows[-1]["ev"]) if rows else None + except (KeyError, TypeError, ValueError): + return None + + +def _plan_file_ev(plan_md_path: str) -> float | None: + with open(plan_md_path, encoding="utf-8") as f: + return overall_plan_metrics(f.read()).get("ev") + + +def check_plan_ev(plan_md_path: str, plans_ledger_path: str, plan_id: str, intent_branch: str) -> None: + markdown_ev = _plan_file_ev(plan_md_path) + ledger_ev = _plans_row_ev(plans_ledger_path, plan_id, intent_branch) + if markdown_ev is None or ledger_ev is None or abs(markdown_ev - ledger_ev) > MISMATCH_TOLERANCE: + raise PlanEvSyncError( + f"Plan {plan_id}: predicted EV differs between plans.jsonl (ev={ledger_ev}) and {plan_md_path} " + f"Overall Plan Metrics (ev_pred={markdown_ev}); the plan attempt is refused" + ) + + +def plans_ledger_files(plans_ledger_path: str) -> list[str]: + return [plans_ledger_path, *iter_fragment_files(plans_ledger_path)] + + +def snapshot_files(paths: list[str]) -> dict[str, bytes | None]: + snapshot: dict[str, bytes | None] = {} + for path in paths: + try: + with open(path, "rb") as f: + snapshot[path] = f.read() + except FileNotFoundError: + snapshot[path] = None + return snapshot + + +def restore_files(snapshot: dict[str, bytes | None], current_paths: list[str]) -> None: + for path in current_paths: + if snapshot.get(path) is None and os.path.exists(path): + os.remove(path) + for path, data in snapshot.items(): + if data is not None: + with open(path, "wb") as f: + f.write(data) diff --git a/apps/sandbox-executor/tests/fixtures/calibration_merge_main_expected.md b/apps/sandbox-executor/tests/fixtures/calibration_merge_main_expected.md index 3d88807dc..381c6e83c 100644 --- a/apps/sandbox-executor/tests/fixtures/calibration_merge_main_expected.md +++ b/apps/sandbox-executor/tests/fixtures/calibration_merge_main_expected.md @@ -5,6 +5,7 @@ - **Execution Branch:** `I-1795409225-regress/P-1795409242-REG/E-1795409573-REG/_` - **Intent Branch:** `I-1795409225-regress/_` - **Evaluating Agent:** `claude-agent/claude-opus-5-5` +- **Plan Agent:** `claude-agent/claude-opus-5-5` - **Evaluation Timestamp:** `2026-11-23T05:45:26.000Z` - **Evaluated Commit SHA:** `` - **Base SHA:** `` diff --git a/apps/sandbox-executor/tests/fixtures/calibration_report_golden.txt b/apps/sandbox-executor/tests/fixtures/calibration_report_golden.txt index 5f4172a15..b69cf8ec5 100644 --- a/apps/sandbox-executor/tests/fixtures/calibration_report_golden.txt +++ b/apps/sandbox-executor/tests/fixtures/calibration_report_golden.txt @@ -5,6 +5,7 @@ - **Execution Branch:** `I-1795000000-golden/P-1795000001-CLA-CO5.5/E-1795000002-CLA-CO5.5/_` - **Intent Branch:** `I-1795000000-golden/_` - **Evaluating Agent:** `claude-agent/claude-opus-5-5` +- **Plan Agent:** `codex-agent/gpt-5.5` - **Evaluation Timestamp:** `2026-11-26T05:30:00.000Z` - **Evaluated Commit SHA:** `0123456789abcdef0123456789abcdef01234567` - **Base SHA:** `1111111111111111111111111111111111111111` diff --git a/apps/sandbox-executor/tests/test_calibration_commit.py b/apps/sandbox-executor/tests/test_calibration_commit.py index 5b15fc04b..ce7308f07 100644 --- a/apps/sandbox-executor/tests/test_calibration_commit.py +++ b/apps/sandbox-executor/tests/test_calibration_commit.py @@ -267,6 +267,10 @@ def test_run_calibrate_appends_and_commits_act_cal(calibrated_committed): "calibration_report_path", "created_at", "touch_set_accuracy", + "calibration_agent", + "calibration_model", + "plan_agent", + "plan_model", ] assert (row["entry_type"], row["action_origin"]) == ("action", "calibration") assert row["outcome"] == "success" diff --git a/apps/sandbox-executor/tests/test_calibration_ev_fail_closed.py b/apps/sandbox-executor/tests/test_calibration_ev_fail_closed.py new file mode 100644 index 000000000..7c8f71b74 --- /dev/null +++ b/apps/sandbox-executor/tests/test_calibration_ev_fail_closed.py @@ -0,0 +1,84 @@ +from __future__ import annotations + +import logging +from pathlib import Path +from unittest.mock import patch + +import pytest +from sandbox_executor.calibration import generate_calibration, run_calibrate +from sandbox_executor.calibration_predicted import PlanEvMismatchError +from sandbox_executor.flow import FlowContext, StageStatus +from sandbox_executor.flow.stages.calibrate import _calibrate_execution_branch +from sandbox_executor.ledger import read_merged_rows + +from tests.test_calibration_evaluating_agent import EXEC_BRANCH, PLAN_FILE, PLAN_METRICS, build_planned_repo + +PREDICTED_LOGGER = "sandbox_executor.calibration_predicted" +REPORT_REL = "plans/I-1-cal/P-2_calibration.md" +LEDGER_REL = "holon-knowledge/ledger/executions.jsonl" +LEDGER_EV, PLAN_FILE_EV = 7.38, 52.26 + + +def calibration_success_rows(repo: Path) -> list[dict]: + rows = read_merged_rows(str(repo / LEDGER_REL)) + return [row for row in rows if row.get("action_origin") == "calibration" and row.get("outcome") == "success"] + + +@pytest.fixture +def mismatched_repo(tmp_path: Path) -> Path: + return build_planned_repo(tmp_path, LEDGER_EV, PLAN_FILE_EV) + + +def test_generate_calibration_raises_naming_both_values_and_the_plan_file(mismatched_repo: Path) -> None: + with pytest.raises(PlanEvMismatchError) as raised: + generate_calibration(EXEC_BRANCH, target_worktree=str(mismatched_repo)) + + assert all(text in str(raised.value) for text in ("7.38", "52.26", PLAN_FILE)) + + +def test_run_calibrate_writes_no_report_and_no_act_cal_row_on_a_mismatch(mismatched_repo: Path) -> None: + with ( + patch("sandbox_executor.calibration.run.format_calibration_report"), + pytest.raises(PlanEvMismatchError), + ): + run_calibrate(EXEC_BRANCH, target_worktree=str(mismatched_repo), skip_commit=False) + + assert not (mismatched_repo / REPORT_REL).exists() + assert calibration_success_rows(mismatched_repo) == [] + + +def test_the_calibrate_stage_fails_closed_with_both_values_and_no_report(mismatched_repo: Path) -> None: + context = FlowContext( + target_worktree=str(mismatched_repo), execution_branch=EXEC_BRANCH, dry_run=True, token_reduce=False + ) + with patch("sandbox_executor.calibration.run.format_calibration_report"): + result = _calibrate_execution_branch(context) + + assert result.status == StageStatus.FAILED + assert all(text in str(result.error) for text in ("7.38", "52.26", PLAN_FILE)) + assert not (mismatched_repo / REPORT_REL).exists() + assert calibration_success_rows(mismatched_repo) == [] + + +def test_a_non_ev_mismatch_only_warns_and_calibrates(tmp_path: Path, caplog: pytest.LogCaptureFixture) -> None: + caplog.set_level(logging.WARNING, logger=PREDICTED_LOGGER) + repo = build_planned_repo(tmp_path, PLAN_METRICS["ev"], PLAN_METRICS["ev"]) + plan = repo / PLAN_FILE + plan.write_text(plan.read_text(encoding="utf-8") + "| cost_pred | 9.0 |\n", encoding="utf-8") + + report = generate_calibration(EXEC_BRANCH, target_worktree=str(repo)) + + assert (report.predicted.ev, report.predicted.cost) == (PLAN_METRICS["ev"], PLAN_METRICS["cost"]) + warnings = [r.getMessage() for r in caplog.records if r.name == PREDICTED_LOGGER] + assert len(warnings) == 1 + assert "cost=5 vs cost=9" in warnings[0] and "ev=" not in warnings[0] + + +def test_values_within_the_tolerance_calibrate_unchanged(tmp_path: Path) -> None: + exact = generate_calibration(EXEC_BRANCH, target_worktree=str(build_planned_repo(tmp_path / "exact", 27.4, 27.4))) + noisy_repo = build_planned_repo(tmp_path / "noisy", 27.400000000000002, 27.405) + + noisy = generate_calibration(EXEC_BRANCH, target_worktree=str(noisy_repo)) + + assert noisy.predicted.to_dict() == exact.predicted.to_dict() | {"ev": 27.400000000000002} + assert noisy.actual.to_dict() == exact.actual.to_dict() diff --git a/apps/sandbox-executor/tests/test_calibration_evaluating_agent.py b/apps/sandbox-executor/tests/test_calibration_evaluating_agent.py new file mode 100644 index 000000000..d53716b3b --- /dev/null +++ b/apps/sandbox-executor/tests/test_calibration_evaluating_agent.py @@ -0,0 +1,141 @@ +from __future__ import annotations + +import json +from pathlib import Path +from unittest.mock import patch + +import pytest +from sandbox_executor.calibration import run_calibrate +from sandbox_executor.calibration_record import calibration_action_row +from sandbox_executor.flow import FlowContext +from sandbox_executor.flow.stage5 import run_stage5 +from sandbox_executor.flow.stages.calibrate import stage5_steps + +from tests.calibrate_scenarios import run_sync_git + +INTENT_BRANCH = "I-1-cal/_" +PLAN_BRANCH = "I-1-cal/P-2/_" +EXEC_BRANCH = "I-1-cal/P-2/E-3/_" +PLAN_FILE = "plans/I-1-cal/P-2.md" +PLAN_AGENT, PLAN_MODEL = "claude-agent", "claude-opus-5-5" +RESUMED_AGENT, RESUMED_MODEL = "codex-agent", "gpt-5.5" +PLAN_METRICS = {"p_success": 0.8, "entropy": 2.0, "impact": 40.0, "cost": 5.0, "learning_value": 2.0, "ev": 27.4} + + +def plan_markdown(ev: float) -> str: + return f"# Plan\n\n## Overall Plan Metrics\n\n| metric | value |\n| ------ | ----- |\n| ev_pred | {ev} |\n" + + +def build_planned_repo(root: Path, plan_row_ev: float, plan_file_ev: float) -> Path: + repo = root / "repo" + repo.mkdir(parents=True) + run_sync_git(repo, "init", "-q", "-b", "main") + summary = { + "execution_id": "E-3", + "plan_branch": PLAN_BRANCH, + "agent": PLAN_AGENT, + "model": PLAN_MODEL, + "status": "success", + "entry_type": "summary", + "created_at": "2026-01-01T00:00:00.000Z", + "exit_code": 0, + } + plan_row = { + "plan_id": "P-2", + "intent_branch": INTENT_BRANCH, + "plan_file": PLAN_FILE, + "agent": PLAN_AGENT, + "model": PLAN_MODEL, + **PLAN_METRICS, + "ev": plan_row_ev, + } + files = { + "holon-knowledge/ledger/executions.jsonl": json.dumps(summary) + "\n", + "holon-knowledge/ledger/plans.jsonl": json.dumps(plan_row) + "\n", + PLAN_FILE: plan_markdown(plan_file_ev), + } + for rel, text in files.items(): + (repo / rel).parent.mkdir(parents=True, exist_ok=True) + (repo / rel).write_text(text, encoding="utf-8") + run_sync_git(repo, "add", "--", *files) + run_sync_git(repo, "commit", "-qm", "plan") + run_sync_git(repo, "checkout", "-q", "-b", PLAN_BRANCH) + run_sync_git(repo, "checkout", "-q", "-b", EXEC_BRANCH) + (repo / "feature.py").write_text("print('hello')\n", encoding="utf-8") + run_sync_git(repo, "add", "feature.py") + run_sync_git(repo, "commit", "-qm", "feature") + return repo + + +def header_value(markdown: str, label: str) -> str: + prefix = f"- **{label}:** " + return next(line.removeprefix(prefix) for line in markdown.splitlines() if line.startswith(prefix)) + + +@pytest.fixture +def planned_repo(tmp_path: Path) -> Path: + return build_planned_repo(tmp_path, PLAN_METRICS["ev"], PLAN_METRICS["ev"]) + + +def test_a_resumed_stage5_names_the_resumed_runner_and_shows_the_plan_agent_apart(planned_repo: Path) -> None: + context = FlowContext( + target_worktree=str(planned_repo), + execution_branch=EXEC_BRANCH, + dry_run=True, + token_reduce=False, + agent=RESUMED_AGENT, + model=RESUMED_MODEL, + ) + with patch("sandbox_executor.calibration.run.format_calibration_report"): + outcome = run_stage5(context, stage5_steps(), None, report_only=True) + + report = outcome.report_dict + assert (report["agent_id"], report["model_name"]) == (RESUMED_AGENT, RESUMED_MODEL) + assert (report["plan_agent"], report["plan_model"]) == (PLAN_AGENT, PLAN_MODEL) + written = (planned_repo / "plans/I-1-cal/P-2_calibration.md").read_text(encoding="utf-8") + assert header_value(written, "Evaluating Agent") == f"`{RESUMED_AGENT}/{RESUMED_MODEL}`" + assert header_value(written, "Plan Agent") == f"`{PLAN_AGENT}/{PLAN_MODEL}`" + + +def test_standalone_calibrate_without_an_evaluator_keeps_the_execution_row_attribution(planned_repo: Path) -> None: + with patch("sandbox_executor.calibration.run.format_calibration_report"): + report = run_calibrate(EXEC_BRANCH, target_worktree=str(planned_repo), skip_commit=True) + + assert header_value(report.markdown_content, "Evaluating Agent") == f"`{PLAN_AGENT}/{PLAN_MODEL}`" + assert header_value(report.markdown_content, "Plan Agent") == f"`{PLAN_AGENT}/{PLAN_MODEL}`" + + +def test_act_cal_row_adds_the_evaluator_and_plan_keys_and_keeps_every_existing_value() -> None: + report = { + "plan_id": "P-2", + "plan_branch": PLAN_BRANCH, + "execution_branch": EXEC_BRANCH, + "calibrated_branch": "I-1-cal/P-2/E-3/calibrated", + "evaluated_commit_sha": "0" * 40, + "predicted": PLAN_METRICS, + "touch_set": {"precision": 1.0}, + } + evaluated = { + **report, + "agent_id": RESUMED_AGENT, + "model_name": RESUMED_MODEL, + "plan_agent": PLAN_AGENT, + "plan_model": PLAN_MODEL, + } + with patch("sandbox_executor.calibration_record.time.time", return_value=1794446836.0): + before = calibration_action_row(report, "plans/I-1-cal/P-2_calibration.md", "success", None) + after = calibration_action_row(evaluated, "plans/I-1-cal/P-2_calibration.md", "success", None) + + added = {key: after.pop(key) for key in ("calibration_agent", "calibration_model", "plan_agent", "plan_model")} + assert added == { + "calibration_agent": RESUMED_AGENT, + "calibration_model": RESUMED_MODEL, + "plan_agent": PLAN_AGENT, + "plan_model": PLAN_MODEL, + } + volatile = ("action_id", "created_at", "execution_id") + assert list(after) == [key for key in before if key not in added] + assert {k: v for k, v in after.items() if k not in volatile} == { + k: v for k, v in before.items() if k not in volatile and k not in added + } + assert "agent" not in after and "model" not in after diff --git a/apps/sandbox-executor/tests/test_calibration_plan_keys.py b/apps/sandbox-executor/tests/test_calibration_plan_keys.py index c40b3916b..448c18169 100644 --- a/apps/sandbox-executor/tests/test_calibration_plan_keys.py +++ b/apps/sandbox-executor/tests/test_calibration_plan_keys.py @@ -8,7 +8,11 @@ from sandbox_executor.calibration import PredictedMetrics, extract_branch_components, parse_predicted_metrics from sandbox_executor.calibration_ev import is_matching_record from sandbox_executor.calibration_execution_owner import unique_plan_branch_of_execution -from sandbox_executor.calibration_predicted import cross_check_selected_row, overall_plan_metrics +from sandbox_executor.calibration_predicted import ( + PlanEvMismatchError, + cross_check_selected_row, + overall_plan_metrics, +) PREDICTED_LOGGER = "sandbox_executor.calibration_predicted" INTENT = "I-1795184210-fix" @@ -127,10 +131,7 @@ def test_a_revision_tie_goes_to_the_later_created_at_and_an_unparseable_one_lose assert parse_predicted_metrics(PLAN_BRANCH, str(tmp_path))[0].ev == 2.0 -def test_a_plans_row_disagreeing_with_the_overall_table_logs_both_values( - tmp_path: Path, caplog: pytest.LogCaptureFixture -) -> None: - caplog.set_level(logging.WARNING, logger=PREDICTED_LOGGER) +def test_a_plans_row_disagreeing_with_the_overall_table_ev_raises_naming_both_values(tmp_path: Path) -> None: _write_ledger(tmp_path, "plans.jsonl", [_plans_row(7.38)]) plan = tmp_path / PLAN_FILE plan.parent.mkdir(parents=True) @@ -139,11 +140,10 @@ def test_a_plans_row_disagreeing_with_the_overall_table_logs_both_values( "## Overall Plan Metrics\n\n| metric | value |\n| cost_pred | 10.0 |\n| ev_pred | 52.26 |\n\n## Notes\n", encoding="utf-8", ) - predicted, _ = parse_predicted_metrics(PLAN_BRANCH, str(tmp_path)) - assert predicted.ev == 7.38 - warnings = [r.getMessage() for r in caplog.records if r.name == PREDICTED_LOGGER] - assert len(warnings) == 1 - assert all(text in warnings[0] for text in ("7.38", "52.26", "Overall", PLAN_FILE)) + with pytest.raises(PlanEvMismatchError) as raised: + parse_predicted_metrics(PLAN_BRANCH, str(tmp_path)) + assert all(text in str(raised.value) for text in ("7.38", "52.26", "Overall", PLAN_FILE)) + assert (raised.value.ledger_ev, raised.value.plan_file_ev, raised.value.plan_file) == (7.38, 52.26, PLAN_FILE) def test_float_noise_within_tolerance_logs_no_warning(tmp_path: Path, caplog: pytest.LogCaptureFixture) -> None: diff --git a/apps/sandbox-executor/tests/test_calibration_report.py b/apps/sandbox-executor/tests/test_calibration_report.py index 23b3a0203..efd6eb5e9 100644 --- a/apps/sandbox-executor/tests/test_calibration_report.py +++ b/apps/sandbox-executor/tests/test_calibration_report.py @@ -95,6 +95,8 @@ def _golden_report_dict() -> dict[str, Any]: "agent_id": "claude-agent", "agent_version": "2.1.302", "model_name": "claude-opus-5-5", + "plan_agent": "codex-agent", + "plan_model": "gpt-5.5", "timestamp": "2026-11-26T05:30:00.000Z", "predicted": pred.to_dict(), "actual": act.to_dict(), @@ -163,6 +165,8 @@ def test_every_pre_split_public_name_is_still_importable() -> None: "touch_set", "diff_base", "review_accounting", + "plan_agent", + "plan_model", ) diff --git a/apps/sandbox-executor/tests/test_plan_ev_sync.py b/apps/sandbox-executor/tests/test_plan_ev_sync.py new file mode 100644 index 000000000..de2fcedf0 --- /dev/null +++ b/apps/sandbox-executor/tests/test_plan_ev_sync.py @@ -0,0 +1,165 @@ +from __future__ import annotations + +import json +import pathlib +import unittest +from collections.abc import Iterator +from unittest.mock import patch + +import pytest +from sandbox_executor.calibration_predicted import overall_plan_metrics +from sandbox_executor.entrypoint import planner +from sandbox_executor.plan_attempt import PLAN_FAILURE_DETAIL_REL +from sandbox_executor.plan_ev_sync import ( + PlanEvSyncError, + PlanMetrics, + check_plan_ev, + ev_cell_text, + rounded_plan_ev, + write_plan_ev, +) + +from tests.test_planner import VALID_PLAN, _PlannerHarness, write_file + +PLAN_ID = "P-1-CLA-CO5.5" +INTENT_BRANCH = "I-1-ev/_" +COMPUTED_EV = 7.0 +PLAN_WITHOUT_EV_ROW = VALID_PLAN.replace("| ev_pred | 6.0 |\n", "", 1) +PLAN_WITH_MATCHING_EV = VALID_PLAN.replace("| ev_pred | 6.0 |", "| ev_pred | 7.0 |", 1) + + +def write_plan(tmp_path: pathlib.Path, content: str) -> pathlib.Path: + path = tmp_path / "plans" / "I-1-ev" / f"{PLAN_ID}.md" + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(content, encoding="utf-8") + return path + + +def write_plans_row(tmp_path: pathlib.Path, ev: float) -> pathlib.Path: + path = tmp_path / "holon-knowledge" / "ledger" / "plans.jsonl" + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(json.dumps({"plan_id": PLAN_ID, "intent_branch": INTENT_BRANCH, "ev": ev}) + "\n", encoding="utf-8") + return path + + +def overall_ev(path: pathlib.Path) -> float | None: + return overall_plan_metrics(path.read_text(encoding="utf-8")).get("ev") + + +def test_the_ev_is_computed_once_and_rounded_once() -> None: + metrics = PlanMetrics(p_success=0.8, impact=10.0, learning_value=0.5, entropy=2.5, cost=0.5) + assert rounded_plan_ev(metrics, ev_lambda=0.3, ev_mu=0.5) == COMPUTED_EV + third = PlanMetrics(p_success=1 / 3, impact=1.0, learning_value=0.0, entropy=0.0, cost=0.0) + assert rounded_plan_ev(third, ev_lambda=0.3, ev_mu=0.5) == 0.3333 + + +def test_the_markdown_value_uses_the_plans_row_number_form() -> None: + assert ev_cell_text(7.0) == "7.0" == json.dumps(7.0) + assert ev_cell_text(43.9) == json.dumps(43.9) + assert ev_cell_text(-2.125) == json.dumps(-2.125) + + +def test_an_agent_written_ev_that_differs_is_rewritten_to_the_computed_value(tmp_path: pathlib.Path) -> None: + plan = write_plan(tmp_path, VALID_PLAN) + + assert write_plan_ev(str(plan), COMPUTED_EV) is True + + content = plan.read_text(encoding="utf-8") + assert overall_ev(plan) == COMPUTED_EV + assert "| ev_pred | 7.0 |" in content + assert content == PLAN_WITH_MATCHING_EV + + +def test_a_plan_without_an_ev_row_gets_one_in_the_overall_table(tmp_path: pathlib.Path) -> None: + plan = write_plan(tmp_path, PLAN_WITHOUT_EV_ROW) + + assert write_plan_ev(str(plan), COMPUTED_EV) is True + + content = plan.read_text(encoding="utf-8") + assert overall_ev(plan) == COMPUTED_EV + assert "| learning_value_pred | 0.5 |\n| ev_pred | 7.0 |\n\n### Strategy Rationale" in content + assert content.count("ev_pred") == 1 + + +def test_an_agent_written_bare_ev_row_is_rewritten_in_place(tmp_path: pathlib.Path) -> None: + bare_ev_plan = VALID_PLAN.replace("| ev_pred | 6.0 |", "| ev | 6.0 |", 1) + plan = write_plan(tmp_path, bare_ev_plan) + + assert write_plan_ev(str(plan), COMPUTED_EV) is True + + content = plan.read_text(encoding="utf-8") + assert overall_ev(plan) == COMPUTED_EV + assert "| ev | 7.0 |" in content + assert "ev_pred" not in content.split("### Strategy Rationale")[0] + + +def test_a_plan_whose_ev_already_matches_is_unchanged_byte_for_byte(tmp_path: pathlib.Path) -> None: + plan = write_plan(tmp_path, PLAN_WITH_MATCHING_EV) + before = plan.read_bytes() + + assert write_plan_ev(str(plan), COMPUTED_EV) is False + assert plan.read_bytes() == before + + +def test_only_the_overall_table_is_touched(tmp_path: pathlib.Path) -> None: + step_table = "\n## Step 3: Measure\n\n| metric | value |\n| ------ | ----- |\n| ev_pred | 1.5 |\n" + plan = write_plan(tmp_path, VALID_PLAN + step_table) + + write_plan_ev(str(plan), COMPUTED_EV) + + assert plan.read_text(encoding="utf-8").endswith(step_table) + + +def test_an_inserted_row_wider_than_the_table_still_parses_and_checks(tmp_path: pathlib.Path) -> None: + plan = write_plan(tmp_path, PLAN_WITHOUT_EV_ROW) + write_plan_ev(str(plan), 1234.5678) + + assert overall_ev(plan) == 1234.5678 + check_plan_ev(str(plan), str(write_plans_row(tmp_path, 1234.5678)), PLAN_ID, INTENT_BRANCH) + + +def test_check_plan_ev_passes_when_both_values_are_equal(tmp_path: pathlib.Path) -> None: + plan = write_plan(tmp_path, PLAN_WITH_MATCHING_EV) + check_plan_ev(str(plan), str(write_plans_row(tmp_path, COMPUTED_EV)), PLAN_ID, INTENT_BRANCH) + + +@pytest.mark.parametrize( + ("markdown", "row_ev"), + [(PLAN_WITH_MATCHING_EV, 8.5), (VALID_PLAN, COMPUTED_EV), (PLAN_WITHOUT_EV_ROW, COMPUTED_EV)], +) +def test_check_plan_ev_raises_on_a_tampered_or_missing_value( + tmp_path: pathlib.Path, markdown: str, row_ev: float +) -> None: + plan = write_plan(tmp_path, markdown) + with pytest.raises(PlanEvSyncError, match=PLAN_ID): + check_plan_ev(str(plan), str(write_plans_row(tmp_path, row_ev)), PLAN_ID, INTENT_BRANCH) + + +@pytest.fixture +def planner_run() -> Iterator[_PlannerHarness]: + harness = _PlannerHarness(unittest.TestCase(), [write_file(VALID_PLAN)]) + yield harness + harness.cleanup() + + +def test_stage2_writes_the_same_ev_to_the_plans_row_and_the_plan_markdown(planner_run: _PlannerHarness) -> None: + planner_run.run() + + assert planner_run.exit_code == 0 + row = planner_run.ledger_lines("plans.jsonl")[0] + plan = pathlib.Path(planner_run.repo_dir) / row["plan_file"] + assert row["ev"] == COMPUTED_EV + assert overall_ev(plan) == row["ev"] + assert f"| ev_pred | {json.dumps(row['ev'])} |" in plan.read_text(encoding="utf-8") + + +def test_stage2_fails_the_attempt_when_the_reread_values_differ(planner_run: _PlannerHarness) -> None: + refusal = PlanEvSyncError("predicted EV differs between plans.jsonl (ev=7.0) and the plan (ev_pred=6.0)") + with patch.object(planner, "check_plan_ev", side_effect=refusal): + planner_run.run() + + assert planner_run.exit_code == 1 + assert not planner_run.committed() + assert planner_run.ledger_lines("plans.jsonl") == [] + detail = pathlib.Path(planner_run.repo_dir) / PLAN_FAILURE_DETAIL_REL + assert "ev=7.0" in detail.read_text(encoding="utf-8") diff --git a/apps/sandbox-executor/tests/test_unique_stage_ids.py b/apps/sandbox-executor/tests/test_unique_stage_ids.py index f1304bb9d..b88313eae 100644 --- a/apps/sandbox-executor/tests/test_unique_stage_ids.py +++ b/apps/sandbox-executor/tests/test_unique_stage_ids.py @@ -121,6 +121,10 @@ def test_calibration_action_row_ids_differ_within_one_second_across_flows(self): "calibration_report_path", "created_at", "touch_set_accuracy", + "calibration_agent", + "calibration_model", + "plan_agent", + "plan_model", ] first_data = { "plan_id": plan_id, diff --git a/docs/ledger_schema.md b/docs/ledger_schema.md index b175a1d66..1c05ca5ec 100644 --- a/docs/ledger_schema.md +++ b/docs/ledger_schema.md @@ -240,16 +240,24 @@ Stage 4 and Stage 5 action rows keep their historical field order and identifier the superseding row. Readers take the matching plans row with the highest `ledger_revision`, ties going to the later `created_at` instant and a full tie to the last line; this also selects the flow's `decision_recorded_by: "flow"` row. Stage 5 calibration (`sandbox_executor/calibration_predicted.py`) cross-checks the selected row against the plan - file's `## Overall Plan Metrics` table and the execution summary's `predicted_metrics` and logs a warning naming both - values on any difference above `0.01`; it still uses the selected row. Historic plans rows were written from a + file's `## Overall Plan Metrics` table and the execution summary's `predicted_metrics`. An `ev` difference above + `0.01` between the selected row and the plan file fails Stage 5 closed with `PlanEvMismatchError`, naming both values + and the plan file, and writes no report. Every other field, and the execution summary, stays advisory: a difference + above `0.01` logs a warning naming both values and calibration still uses the selected row. Stage 2 + (`sandbox_executor/plan_ev_sync.py`) computes the EV once, rounds it once to 4 decimals and writes that one value to + both the plans row `ev` and the plan file's `ev_pred` row (replacing the planner agent's number or inserting the row); + it re-reads both after the append and fails the plan attempt when they differ. Historic plans rows were written from a per-step metrics table by an old parser bug (for example `ev` `7.38` instead of `52.26`), which motivates this row. - `ACT-CAL` uses `execution_id` `CAL-{plan_id}-{ts}`, `category: "doc"` and labels `["calibration", "stage-5", plan_id]`. Beyond the common action fields it carries `plan_branch`, `execution_branch`, `evaluated_commit_sha`, `predicted_metrics`, `actual_metrics`, `calibration_deltas` and `calibration_report_path` (new - rows add `touch_set_accuracy`, see [touch_set.md](touch_set.md)). Each committed run appends a new `ACT-CAL` row. A - failed Stage 5 run (after its bounded retries) appends one uncommitted `failure` row, writes no report and commits and - pushes nothing; a `--from-stage calibrate` resume commits the row with its next reconciliation commit. The failure - row's `calibration_report_path` is the path the report would have had. + rows add `touch_set_accuracy`, see [touch_set.md](touch_set.md), then `calibration_agent` and `calibration_model`, the + runner and model that ran Stage 5 (after a checkpoint resume with a changed `--agent` or `--model`, the resumed ones; + for a standalone `holon calibrate`, the execution row's attribution), and `plan_agent` and `plan_model`, from the + selected plans row; the report shows them as `Evaluating Agent` and `Plan Agent`). Each committed run appends a new + `ACT-CAL` row. A failed Stage 5 run (after its bounded retries) appends one uncommitted `failure` row, writes no + report and commits and pushes nothing; a `--from-stage calibrate` resume commits the row with its next reconciliation + commit. The failure row's `calibration_report_path` is the path the report would have had. - Failure `error_context` values that can carry external output (the `ACT-POST` posting error and the failure `ACT-CAL` calibration error) are redacted, then truncated to 2000 characters. diff --git a/executions/E-1796100754-CLA-CO5.5.md b/executions/E-1796100754-CLA-CO5.5.md new file mode 100644 index 000000000..72efb316f --- /dev/null +++ b/executions/E-1796100754-CLA-CO5.5.md @@ -0,0 +1,122 @@ +# Execution Record: E-1796100754-CLA-CO5.5 + +## Summary + +Implements plan `P-1796100517-CLA-CO5.5` for intent `I-1796100493-stage5-evaluator-plan-ev-sync`: Stage 5 names the +evaluator that ran calibration, and Stage 2 writes one predicted EV to both plan sources, with Stage 5 failing closed on +a mismatch. + +## Actual Metrics + +| metric | value | +| --------------------- | ----- | +| success_actual | 0.95 | +| entropy_actual | 6.5 | +| impact_actual | 70.0 | +| cost_actual | 11.0 | +| learning_value_actual | 3.5 | + +## Steps Executed + +### Step 1: Baseline and scope-overlap check + +- Baseline over 25 in-scope test files (`uv run pytest -n auto --dist worksteal`): 568 passed, 2 skipped, 25 subtests + passed in 16.15s. +- `python scripts/check_module_budgets.py`: passed (435 modules). `python scripts/check_self_explaining.py`: passed. +- Headroom: `planner.py` 563 of 655; generate 219, report 280, run 163, predicted 89, self_check 137, record 53, + calibration_predicted 159, stage5 245, cli calibrate 105 (default budget 350). +- Open PRs 465, 466, 467: no file in the touch set. + +### Step 2: Evaluating agent and model plumbing + +- `CalibrateReview` gains optional `evaluating_agent` / `evaluating_model`; `run_calibrate` forwards them to + `generate_calibration` (new keyword-only parameters), which uses them for `agent_id` / `model_name` when given and + otherwise keeps `_attribution`. +- The report gains `plan_agent` / `plan_model` (plans row) and a `Plan Agent` header line after `Evaluating Agent`. +- ACT-CAL rows append `calibration_agent`, `calibration_model`, `plan_agent`, `plan_model` after `touch_set_accuracy`. +- Stage 5 passes `context.agent` / `context.model`; the standalone CLI wrapper already forwards no evaluator keys, so + `cli/commands/calibrate.py` is unchanged. +- Targeted run: 4 failed (pinned key lists and the merge-main fixture, fixed in Step 3), 301 passed. + +### Step 3: Evaluator attribution tests and fixtures + +- New `tests/test_calibration_evaluating_agent.py`: a resumed Stage 5 (`FlowContext` with a different agent/model than + the plans row) names the resumed runner as `Evaluating Agent` and the plan row's agent/model as `Plan Agent`; the + standalone `run_calibrate` path keeps the execution row attribution; the ACT-CAL row gains exactly the four keys and + keeps every existing key and value. +- Golden fixtures each gain one `Plan Agent` line; `test_calibration_report.py` golden dict and key tuple, and the + pinned ACT-CAL key lists in `test_calibration_commit.py` and `test_unique_stage_ids.py`, are extended. +- Targeted run over 15 files: 308 passed, 12 subtests passed. + +### Step 4: Stage 5 fails closed on a plans row versus plan file EV mismatch + +- `calibration_predicted.py` gains `PlanEvMismatchError` (plan file, ledger EV, plan file EV, remedy) and + `plan_ev_mismatch`; `cross_check_selected_row` computes it inside the read `try` and raises it after the `try`, so the + broad `except` cannot swallow it. The plan file `ev` is no longer also warned; other fields and the execution summary + stay warnings. `calibration/predicted.py` needed no change (the ledger path has no `suppress`). +- `test_calibration_plan_keys.py`: the warning-only EV test now asserts `PlanEvMismatchError` with `7.38`, `52.26` and + the plan file. +- New `tests/test_calibration_ev_fail_closed.py`: `generate_calibration` raises; `run_calibrate` leaves no report and no + ACT-CAL success row; the calibrate stage ends `FAILED` naming both values with no report; a non-EV mismatch only + warns; values within `0.01` calibrate unchanged. +- Targeted run over 10 files: 219 passed, 12 subtests passed. + +### Step 5: One computed EV in Stage 2 + +- New `src/sandbox_executor/plan_ev_sync.py` (under 110 lines): `rounded_plan_ev` (the formula, rounded once with + `round(value, 4)`; inputs grouped in a `PlanMetrics` dataclass to stay within `PLR0913`), `ev_cell_text` + (`repr(float)`, the same text `json.dumps` writes, so `7.0` stays `7.0`), `write_plan_ev` (rewrites the `ev_pred` + value cell in `## Overall Plan Metrics` keeping the cell width, or inserts a row aligned to the table; leaves other + sections untouched; returns whether the file changed) and `check_plan_ev` / `PlanEvSyncError` (re-reads the markdown + with `calibration_predicted.overall_plan_metrics` and the last plans row; fails on a missing value or a difference + above `MISMATCH_TOLERANCE`). +- `entrypoint/planner.py` (563 to 569 lines, budget 655): EV computed once via `rounded_plan_ev`, written to the + markdown before `converge_prettier`, and checked after the plans.jsonl append; `PlanEvSyncError` goes through + `_fail_plan_attempt` before `git add`/commit. +- New `tests/test_plan_ev_sync.py`: rewrite, insert, unchanged byte-for-byte, other sections untouched, number form, + check raises/passes, Stage 2 harness equality between the plans row and the formatted markdown, and a refused attempt + (exit 1, failure detail written, no commit). A real-Prettier convergence test was dropped: `converge_prettier` runs + `npx --yes prettier@3.8.4`, which needs a network download in this sandbox (the attempt timed out with the file left + unformatted); inserted rows are aligned to the table widths instead, so Prettier has nothing to re-pad. +- `tests/test_planner_plan_fence_format.py` passes unchanged (A12 held). +- Targeted run over 7 files: 117 passed, 2 skipped, 13 subtests passed; `check_module_budgets.py` passed. + +### Step 6: Ledger schema documentation + +- `docs/ledger_schema.md`: the ACT-CAL entry lists `calibration_agent`, `calibration_model` (the Stage 5 evaluator; the + execution row attribution for standalone `holon calibrate`) and `plan_agent`, `plan_model` (selected plans row); the + cross-check paragraph says an `ev` difference above `0.01` between the plans row and the plan file fails Stage 5 with + no report, other fields and the execution summary stay advisory, and Stage 2 writes one rounded EV to both. +- `npx --no-install prettier --write` applied; `prettier --check` clean. + +### Step 7: Lint, module budgets and the full suite + +- `uv run task lint` first found an `E501` in `plan_ev_sync.py` and a second, non-`# why:` comment line in + `calibration_predicted.py`; both fixed, then lint passed (ruff, ruff format, module budgets 436 modules, + self-explaining 23 changed files). +- The first `uv run task test` failed only + `test_ledger_merged_reader.py::test_no_new_direct_ledger_reader_appears_outside_the_ledger_package`: `check_plan_ev` + opened the plan markdown in a function that also names the plans ledger. The markdown read moved into `_plan_file_ev` + (source change only; the out-of-scope guard test is untouched). Re-run passed. +- `git diff --name-only origin/main...HEAD` holds only touch-set files plus the flow's intent, plan and execution + records; `holon-config/hygiene/module_budgets.json` and `uv.lock` are unchanged. `cli/commands/calibrate.py`, + `calibration/predicted.py` and the optional test files needed no change. +- `planner.py` 569 of 655 lines; `plan_ev_sync.py` 107, `calibration_predicted.py` 190, `generate.py` 237, `report.py` + 286, `run.py` 168 (default 350). + +## Tests Run + +| command | result | pytest time | +| ----------------------------------------------------------------------------- | ------------------------------------------------------ | ----------- | +| Step 1 baseline, 25 in-scope files, `uv run pytest -n auto --dist worksteal` | 568 passed, 2 skipped, 25 subtests | `16.15s` | +| Step 2, 14 calibration files | 4 failed (expected pinned lists / fixture), 301 passed | `10.15s` | +| Step 3, 15 calibration files incl. new evaluator test | 308 passed, 12 subtests | `10.60s` | +| Step 4, 10 files incl. `test_calibration_ev_fail_closed.py` | 219 passed, 12 subtests | `5.70s` | +| Step 5, `test_plan_ev_sync.py` + 6 planner/artefact files | 117 passed, 2 skipped, 13 subtests | `8.63s` | +| Step 7, `test_ledger_merged_reader.py` + `test_plan_ev_sync.py` after the fix | 39 passed | `4.91s` | +| `uv run task test` (full suite, first run) | 1 failed, 11068 passed, 7 skipped | `75.45s` | +| `uv run task test` (full suite, after the fix) | 11069 passed, 7 skipped | `101.33s` | +| `uv run task lint` | passed | n/a | +| `npx --no-install prettier --check docs/ledger_schema.md` | passed | n/a | + +No timing target applies, so each command ran once (the full suite twice only because the first run found a defect). diff --git a/holon-knowledge/kb/failure_modes/KB-failure-d67238f28c64325b.json b/holon-knowledge/kb/failure_modes/KB-failure-d67238f28c64325b.json index 49018c133..1379bebcb 100644 --- a/holon-knowledge/kb/failure_modes/KB-failure-d67238f28c64325b.json +++ b/holon-knowledge/kb/failure_modes/KB-failure-d67238f28c64325b.json @@ -23,7 +23,8 @@ ], "classification": "flaky", "stages": [ - "stage_3" + "stage_3", + "stage_4" ], "symptoms": [ "FAILED apps/sandbox-executor/tests/test_ledger_lock.py::test_concurrent_process_appends_do_not_interleave\n______________ test_concurrent_process_appends_do_not_interleave _______________\n[gw10] linux -- Python 3.13.14 /home/holon/.cache/holon-venv/bin/python\ntmp_path = PosixPath('/tmp/pytest-of-holon/pytest-6/popen-gw10/test_concurrent_process_append0')\n def test_concurrent_process_appends_do_not_interleave(tmp_path: Path) -> None:\n ledger_file = str(tmp_path / \"executions.jsonl\")\n # why: fresh interpreters importing only sandbox_executor; forking a threaded xdist worker can h" diff --git a/holon-knowledge/ledger/pending/executions/I-1796100493-stage5-evaluator-plan-ev-sync.jsonl b/holon-knowledge/ledger/pending/executions/I-1796100493-stage5-evaluator-plan-ev-sync.jsonl new file mode 100644 index 000000000..7a8e461e8 --- /dev/null +++ b/holon-knowledge/ledger/pending/executions/I-1796100493-stage5-evaluator-plan-ev-sync.jsonl @@ -0,0 +1,45 @@ +{"action_id": "ACT-1796101466-3f9ea9d8", "execution_id": "E-1796100754-CLA-CO5.5", "action": "Executed agent claude-agent with model claude-opus-5-5", "category": "code", "target": "claude-agent:claude-opus-5-5", "outcome": "success", "entry_type": "action", "parent_action_id": null, "event_type": "command_execution", "labels": ["agent", "claude-agent", "execution"], "error_context": null, "mistake_category": null, "action_origin": "initial_implementation", "review_severity": null, "review_iteration": null, "review_finding_ids": null, "review_disposition": null, "rejection_reason": null, "introduced_by_action_id": null, "created_at": "2026-12-01T05:04:26.629575Z"} +{"entry_type": "summary", "execution_id": "E-1796100754-CLA-CO5.5", "plan_branch": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/_", "agent": "claude-agent", "agent_version": "2.1.302", "model": "claude-opus-5-5", "status": "success", "summary": "Plan executed successfully", "created_at": "2026-12-01T04:52:35.464137Z", "agent_output_truncated": false, "agent_output_bytes": 287, "ledger_revision": 1, "execution_notes": "executions/E-1796100754-CLA-CO5.5.md", "execution_notes_valid": true, "elapsed_seconds": 816.0, "budget_seconds": 604717.0, "test_pass_rate": 1.0, "tests_passed": 11069, "tests_failed": 0, "tests_errored": 0, "test_exit_code": 0, "test_source": "stage_3"} +{"action_id": "ACT-1796101571-5bccaca6", "execution_id": "E-1796100754-CLA-CO5.5", "action": "Committed execution changes: execute: E-1796100754-CLA-CO5.5 completed for plan I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/_", "category": "code", "target": "HEAD", "outcome": "success", "entry_type": "action", "parent_action_id": null, "event_type": "git_mutation", "labels": ["commit", "git"], "error_context": null, "mistake_category": null, "action_origin": "initial_implementation", "review_severity": null, "review_iteration": null, "review_finding_ids": null, "review_disposition": null, "rejection_reason": null, "introduced_by_action_id": null, "created_at": "2026-12-01T05:06:11.456897Z"} +{"execution_id": "E-1796100754-CLA-CO5.5", "action": "test_failure", "category": "test", "target": "stage_4", "outcome": "failure", "action_origin": "ci_fix", "event_type": "test_run", "stage": "stage_4", "branch": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "run_id": "3a7795b9e4c5", "head_sha": "65ee022998f25a2c314457b4e30cbdf0a1e2cfa7", "failing_test_ids": ["apps/sandbox-executor/tests/test_ledger_lock.py::test_concurrent_process_appends_do_not_interleave"], "test_excerpts": {"apps/sandbox-executor/tests/test_ledger_lock.py::test_concurrent_process_appends_do_not_interleave": "FAILED apps/sandbox-executor/tests/test_ledger_lock.py::test_concurrent_process_appends_do_not_interleave\n______________ test_concurrent_process_appends_do_not_interleave _______________\n[gw6] linux -- Python 3.13.14 /home/holon/.cache/holon-venv/bin/python\ntmp_path = PosixPath('/tmp/pytest-of-holon/pytest-1/popen-gw6/test_concurrent_process_append0')\n def test_concurrent_process_appends_do_not_interleave(tmp_path: Path) -> None:\n ledger_file = str(tmp_path / \"executions.jsonl\")\n # why: fresh interpreters importing only sandbox_executor; forking a threaded xdist worker can han"}, "environment": {"variables": ["HOLON_AGENT_ID", "HOLON_AGENT_SETTINGS", "HOLON_CONFIG_RESOLVED", "HOLON_ROLE", "HOLON_SKIP_PREFLIGHT", "HOLON_STAGE_BUDGET_EXECUTE_MINUTES", "HOLON_TARGET_WORKTREE", "HOLON_TOKEN_REDUCE", "PYTHONPATH", "PYTHON_SHA256", "PYTHON_VERSION", "UV_FROZEN", "UV_PROJECT_ENVIRONMENT"], "values": {"UV_FROZEN": "1"}, "identity_overrides": [], "HOME_set": true, "TMPDIR_set": false}, "classification": "flaky", "failure_signature": "d67238f28c64325b", "iteration": 0, "model_tier": null, "base_check": "not_run", "error_context": "FAILED apps/sandbox-executor/tests/test_ledger_lock.py::test_concurrent_process_appends_do_not_interleave\n______________ test_concurrent_process_appends_do_not_interleave _______________\n[gw6] linux -- Python 3.13.14 /home/holon/.cache/holon-venv/bin/python\ntmp_path = PosixPath('/tmp/pytest-of-holon/pytest-1/popen-gw6/test_concurrent_process_append0')\n def test_concurrent_process_appends_do_not_interleave(tmp_path: Path) -> None:\n ledger_file = str(tmp_path / \"executions.jsonl\")\n # why: fresh interpreters importing only sandbox_executor; forking a threaded xdist worker can han", "entry_type": "action", "action_id": "ACT-1796102008-81df31f6", "created_at": "2026-12-01T05:13:28.968030Z"} +{"execution_id": "E-1796100754-CLA-CO5.5", "action": "test_failure", "category": "test", "target": "stage_4", "outcome": "success", "action_origin": "ci_fix", "event_type": "test_run", "stage": "stage_4", "branch": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "run_id": "3a7795b9e4c5", "head_sha": "65ee022998f25a2c314457b4e30cbdf0a1e2cfa7", "failing_test_ids": ["apps/sandbox-executor/tests/test_ledger_lock.py::test_concurrent_process_appends_do_not_interleave"], "test_excerpts": {"apps/sandbox-executor/tests/test_ledger_lock.py::test_concurrent_process_appends_do_not_interleave": "FAILED apps/sandbox-executor/tests/test_ledger_lock.py::test_concurrent_process_appends_do_not_interleave\n______________ test_concurrent_process_appends_do_not_interleave _______________\n[gw6] linux -- Python 3.13.14 /home/holon/.cache/holon-venv/bin/python\ntmp_path = PosixPath('/tmp/pytest-of-holon/pytest-1/popen-gw6/test_concurrent_process_append0')\n def test_concurrent_process_appends_do_not_interleave(tmp_path: Path) -> None:\n ledger_file = str(tmp_path / \"executions.jsonl\")\n # why: fresh interpreters importing only sandbox_executor; forking a threaded xdist worker can han"}, "environment": {"variables": ["HOLON_AGENT_ID", "HOLON_AGENT_SETTINGS", "HOLON_CONFIG_RESOLVED", "HOLON_ROLE", "HOLON_SKIP_PREFLIGHT", "HOLON_STAGE_BUDGET_EXECUTE_MINUTES", "HOLON_TARGET_WORKTREE", "HOLON_TOKEN_REDUCE", "PYTHONPATH", "PYTHON_SHA256", "PYTHON_VERSION", "UV_FROZEN", "UV_PROJECT_ENVIRONMENT"], "values": {"UV_FROZEN": "1"}, "identity_overrides": [], "HOME_set": true, "TMPDIR_set": false}, "classification": "flaky", "failure_signature": "d67238f28c64325b", "iteration": 0, "model_tier": null, "base_check": "not_run", "error_context": "FAILED apps/sandbox-executor/tests/test_ledger_lock.py::test_concurrent_process_appends_do_not_interleave\n______________ test_concurrent_process_appends_do_not_interleave _______________\n[gw6] linux -- Python 3.13.14 /home/holon/.cache/holon-venv/bin/python\ntmp_path = PosixPath('/tmp/pytest-of-holon/pytest-1/popen-gw6/test_concurrent_process_append0')\n def test_concurrent_process_appends_do_not_interleave(tmp_path: Path) -> None:\n ledger_file = str(tmp_path / \"executions.jsonl\")\n # why: fresh interpreters importing only sandbox_executor; forking a threaded xdist worker can han", "entry_type": "action", "action_id": "ACT-1796102014-4d8f6024", "created_at": "2026-12-01T05:13:34.002892Z"} +{"execution_id": "E-1796100754-CLA-CO5.5", "action": "test_failure", "category": "test", "target": "stage_4", "outcome": "success", "action_origin": "ci_fix", "event_type": "test_run", "stage": "stage_4", "branch": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "run_id": "3a7795b9e4c5", "head_sha": "65ee022998f25a2c314457b4e30cbdf0a1e2cfa7", "failing_test_ids": ["apps/sandbox-executor/tests/test_ledger_lock.py::test_concurrent_process_appends_do_not_interleave"], "test_excerpts": {"apps/sandbox-executor/tests/test_ledger_lock.py::test_concurrent_process_appends_do_not_interleave": "FAILED apps/sandbox-executor/tests/test_ledger_lock.py::test_concurrent_process_appends_do_not_interleave\n______________ test_concurrent_process_appends_do_not_interleave _______________\n[gw6] linux -- Python 3.13.14 /home/holon/.cache/holon-venv/bin/python\ntmp_path = PosixPath('/tmp/pytest-of-holon/pytest-1/popen-gw6/test_concurrent_process_append0')\n def test_concurrent_process_appends_do_not_interleave(tmp_path: Path) -> None:\n ledger_file = str(tmp_path / \"executions.jsonl\")\n # why: fresh interpreters importing only sandbox_executor; forking a threaded xdist worker can han"}, "environment": {"variables": ["HOLON_AGENT_ID", "HOLON_AGENT_SETTINGS", "HOLON_CONFIG_RESOLVED", "HOLON_ROLE", "HOLON_SKIP_PREFLIGHT", "HOLON_STAGE_BUDGET_EXECUTE_MINUTES", "HOLON_TARGET_WORKTREE", "HOLON_TOKEN_REDUCE", "PYTHONPATH", "PYTHON_SHA256", "PYTHON_VERSION", "UV_FROZEN", "UV_PROJECT_ENVIRONMENT"], "values": {"UV_FROZEN": "1"}, "identity_overrides": [], "HOME_set": true, "TMPDIR_set": false}, "classification": "flaky", "failure_signature": "d67238f28c64325b", "iteration": 0, "model_tier": null, "base_check": "not_run", "error_context": "FAILED apps/sandbox-executor/tests/test_ledger_lock.py::test_concurrent_process_appends_do_not_interleave\n______________ test_concurrent_process_appends_do_not_interleave _______________\n[gw6] linux -- Python 3.13.14 /home/holon/.cache/holon-venv/bin/python\ntmp_path = PosixPath('/tmp/pytest-of-holon/pytest-1/popen-gw6/test_concurrent_process_append0')\n def test_concurrent_process_appends_do_not_interleave(tmp_path: Path) -> None:\n ledger_file = str(tmp_path / \"executions.jsonl\")\n # why: fresh interpreters importing only sandbox_executor; forking a threaded xdist worker can han", "entry_type": "action", "action_id": "ACT-1796102018-df3c002c", "created_at": "2026-12-01T05:13:38.420317Z"} +{"action_id": "ACT-REV-1796102111-d61ce53f", "execution_id": "REV-ITR-1-1796102111", "action": "Review Loop iteration 1 reviewer 1 completed", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "important", "review_iteration": 1, "review_finding_ids": ["FIND-R1-001-01", "FIND-R1-001-02"], "labels": ["review", "reviewer", "iteration-1"], "error_context": null, "review_reviewer_index": 1, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "CHANGES_REQUESTED", "review_counts": {"critical": 0, "important": 1, "nit": 1}, "created_at": "2026-12-01T05:15:11.240301Z"} +{"action_id": "ACT-FIND-1796102111-cd5562d0", "execution_id": "REV-FIND-1-1796102111", "action": "Review Loop iteration 1 finding detected: FIND-R1-001-01", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "important", "review_iteration": 1, "review_finding_ids": ["FIND-R1-001-01"], "labels": ["review", "finding", "iteration-1"], "error_context": "check_plan_ev refusal runs after the plans row is flushed to the pending ledger fragment; _fail_plan_attempt removes only the plan markdown, so an orphan plans row for the refused plan remains and is committed by the next attempt's ledger_commit_paths add.", "review_reviewer_index": 1, "review_file": "apps/sandbox-executor/src/sandbox_executor/entrypoint/planner.py", "review_line": 553, "created_at": "2026-12-01T05:15:11.242880Z"} +{"action_id": "ACT-FIND-1796102111-1b762dd1", "execution_id": "REV-FIND-1-1796102111", "action": "Review Loop iteration 1 finding detected: FIND-R1-001-02", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["FIND-R1-001-02"], "labels": ["review", "finding", "iteration-1"], "error_context": "Plan Agent header renders 'None' when plan_model is absent; fall back to 'N/A' like the other header fields.", "review_reviewer_index": 1, "review_file": "apps/sandbox-executor/src/sandbox_executor/calibration/report.py", "review_line": 109, "created_at": "2026-12-01T05:15:11.244504Z"} +{"action_id": "ACT-REV-1796102111-d1302cc0", "execution_id": "REV-ITR-1-1796102111", "action": "Review Loop iteration 1 reviewer 2 completed", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "important", "review_iteration": 1, "review_finding_ids": ["FIND-R2-001-01"], "labels": ["review", "reviewer", "iteration-1"], "error_context": null, "review_reviewer_index": 2, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "CHANGES_REQUESTED", "review_counts": {"critical": 0, "important": 1, "nit": 0}, "created_at": "2026-12-01T05:15:11.246663Z"} +{"action_id": "ACT-FIND-1796102111-1c4ba3df", "execution_id": "REV-FIND-1-1796102111", "action": "Review Loop iteration 1 finding detected: FIND-R2-001-01", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "important", "review_iteration": 1, "review_finding_ids": ["FIND-R2-001-01"], "labels": ["review", "finding", "iteration-1"], "error_context": "check_plan_ev runs after the plans row is appended; on PlanEvSyncError _fail_plan_attempt and settle_failed_plan_attempt remove only the plan file, so the refused plan's row stays in the ledger fragment and is committed by the next successful attempt. Roll the row back on refusal and test that the ledger is unchanged.", "review_reviewer_index": 2, "review_file": "apps/sandbox-executor/src/sandbox_executor/entrypoint/planner.py", "review_line": 553, "created_at": "2026-12-01T05:15:11.248872Z"} +{"action_id": "ACT-REV-1796102111-1daf158b", "execution_id": "REV-ITR-1-1796102111", "action": "Review Loop iteration 1 reviewer 3 completed", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["FIND-R3-001-01", "FIND-R3-001-02", "FIND-R3-001-03"], "labels": ["review", "reviewer", "iteration-1"], "error_context": null, "review_reviewer_index": 3, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "CHANGES_REQUESTED", "review_counts": {"critical": 0, "important": 0, "nit": 3}, "created_at": "2026-12-01T05:15:11.251558Z"} +{"action_id": "ACT-FIND-1796102111-65a87e31", "execution_id": "REV-FIND-1-1796102111", "action": "Review Loop iteration 1 finding detected: FIND-R3-001-01", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["FIND-R3-001-01"], "labels": ["review", "finding", "iteration-1"], "error_context": "check_plan_ev runs after the plans row is appended, and the failure path removes only the plan markdown, so a refused attempt leaves an orphan plans row in the worktree.", "review_reviewer_index": 3, "review_file": "apps/sandbox-executor/src/sandbox_executor/entrypoint/planner.py", "review_line": 553, "created_at": "2026-12-01T05:15:11.253971Z"} +{"action_id": "ACT-FIND-1796102111-d706a07e", "execution_id": "REV-FIND-1-1796102111", "action": "Review Loop iteration 1 finding detected: FIND-R3-001-02", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["FIND-R3-001-02"], "labels": ["review", "finding", "iteration-1"], "error_context": "EV_ROW matches only ev_pred, so an agent-written bare `ev` row (also parsed as EV) is left beside the inserted ev_pred row.", "review_reviewer_index": 3, "review_file": "apps/sandbox-executor/src/sandbox_executor/plan_ev_sync.py", "review_line": 9, "created_at": "2026-12-01T05:15:11.255546Z"} +{"action_id": "ACT-FIND-1796102111-740997db", "execution_id": "REV-FIND-1-1796102111", "action": "Review Loop iteration 1 finding detected: FIND-R3-001-03", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["FIND-R3-001-03"], "labels": ["review", "finding", "iteration-1"], "error_context": "agent_version is read as attribution[1] instead of unpacking _attribution into named locals.", "review_reviewer_index": 3, "review_file": "apps/sandbox-executor/src/sandbox_executor/calibration/generate.py", "review_line": 191, "created_at": "2026-12-01T05:15:11.256902Z"} +{"action_id": "ACT-REV-1796102119-c0652711", "execution_id": "REV-ITR-1-1796102119", "action": "Review Loop iteration 1 evaluation for I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "important", "review_iteration": 1, "review_finding_ids": ["FIND-R1-001-01", "FIND-R1-001-02", "FIND-R2-001-01", "FIND-R3-001-01", "FIND-R3-001-02", "FIND-R3-001-03"], "labels": ["review", "review-loop", "iteration-1"], "error_context": "Findings detected: ['FIND-R1-001-01', 'FIND-R1-001-02', 'FIND-R2-001-01', 'FIND-R3-001-01', 'FIND-R3-001-02', 'FIND-R3-001-03']", "created_at": "2026-12-01T05:15:19.328446Z"} +{"action_id": "ACT-REV-1796102119-ff776a98", "execution_id": "REV-ITR-1-1796102119", "action": "Review Loop iteration 1 reviewer 1 completed", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "important", "review_iteration": 1, "review_finding_ids": ["FIND-R1-001-01", "FIND-R1-001-02"], "labels": ["review", "reviewer", "iteration-1"], "error_context": null, "review_reviewer_index": 1, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "CHANGES_REQUESTED", "review_counts": {"critical": 0, "important": 1, "nit": 1}, "created_at": "2026-12-01T05:15:19.331837Z"} +{"action_id": "ACT-FIND-1796102119-a2bed065", "execution_id": "REV-FIND-1-1796102119", "action": "Review Loop iteration 1 finding detected: FIND-R1-001-01", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "important", "review_iteration": 1, "review_finding_ids": ["FIND-R1-001-01"], "labels": ["review", "finding", "iteration-1"], "error_context": "check_plan_ev refusal runs after the plans row is flushed to the pending ledger fragment; _fail_plan_attempt removes only the plan markdown, so an orphan plans row for the refused plan remains and is committed by the next attempt's ledger_commit_paths add.", "review_reviewer_index": 1, "review_file": "apps/sandbox-executor/src/sandbox_executor/entrypoint/planner.py", "review_line": 553, "created_at": "2026-12-01T05:15:19.334605Z"} +{"action_id": "ACT-FIND-1796102119-24698603", "execution_id": "REV-FIND-1-1796102119", "action": "Review Loop iteration 1 finding detected: FIND-R1-001-02", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["FIND-R1-001-02"], "labels": ["review", "finding", "iteration-1"], "error_context": "Plan Agent header renders 'None' when plan_model is absent; fall back to 'N/A' like the other header fields.", "review_reviewer_index": 1, "review_file": "apps/sandbox-executor/src/sandbox_executor/calibration/report.py", "review_line": 109, "created_at": "2026-12-01T05:15:19.335975Z"} +{"action_id": "ACT-REV-1796102119-c8e1db77", "execution_id": "REV-ITR-1-1796102119", "action": "Review Loop iteration 1 reviewer 2 completed", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "important", "review_iteration": 1, "review_finding_ids": ["FIND-R2-001-01"], "labels": ["review", "reviewer", "iteration-1"], "error_context": null, "review_reviewer_index": 2, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "CHANGES_REQUESTED", "review_counts": {"critical": 0, "important": 1, "nit": 0}, "created_at": "2026-12-01T05:15:19.338556Z"} +{"action_id": "ACT-FIND-1796102119-47458a7e", "execution_id": "REV-FIND-1-1796102119", "action": "Review Loop iteration 1 finding detected: FIND-R2-001-01", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "important", "review_iteration": 1, "review_finding_ids": ["FIND-R2-001-01"], "labels": ["review", "finding", "iteration-1"], "error_context": "check_plan_ev runs after the plans row is appended; on PlanEvSyncError _fail_plan_attempt and settle_failed_plan_attempt remove only the plan file, so the refused plan's row stays in the ledger fragment and is committed by the next successful attempt. Roll the row back on refusal and test that the ledger is unchanged.", "review_reviewer_index": 2, "review_file": "apps/sandbox-executor/src/sandbox_executor/entrypoint/planner.py", "review_line": 553, "created_at": "2026-12-01T05:15:19.340651Z"} +{"action_id": "ACT-REV-1796102119-2444c36e", "execution_id": "REV-ITR-1-1796102119", "action": "Review Loop iteration 1 reviewer 3 completed", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["FIND-R3-001-01", "FIND-R3-001-02", "FIND-R3-001-03"], "labels": ["review", "reviewer", "iteration-1"], "error_context": null, "review_reviewer_index": 3, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "CHANGES_REQUESTED", "review_counts": {"critical": 0, "important": 0, "nit": 3}, "created_at": "2026-12-01T05:15:19.343246Z"} +{"action_id": "ACT-FIND-1796102119-d1bf46ea", "execution_id": "REV-FIND-1-1796102119", "action": "Review Loop iteration 1 finding detected: FIND-R3-001-01", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["FIND-R3-001-01"], "labels": ["review", "finding", "iteration-1"], "error_context": "check_plan_ev runs after the plans row is appended, and the failure path removes only the plan markdown, so a refused attempt leaves an orphan plans row in the worktree.", "review_reviewer_index": 3, "review_file": "apps/sandbox-executor/src/sandbox_executor/entrypoint/planner.py", "review_line": 553, "created_at": "2026-12-01T05:15:19.345168Z"} +{"action_id": "ACT-FIND-1796102119-00b36ec9", "execution_id": "REV-FIND-1-1796102119", "action": "Review Loop iteration 1 finding detected: FIND-R3-001-02", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["FIND-R3-001-02"], "labels": ["review", "finding", "iteration-1"], "error_context": "EV_ROW matches only ev_pred, so an agent-written bare `ev` row (also parsed as EV) is left beside the inserted ev_pred row.", "review_reviewer_index": 3, "review_file": "apps/sandbox-executor/src/sandbox_executor/plan_ev_sync.py", "review_line": 9, "created_at": "2026-12-01T05:15:19.346153Z"} +{"action_id": "ACT-FIND-1796102119-1fa016c0", "execution_id": "REV-FIND-1-1796102119", "action": "Review Loop iteration 1 finding detected: FIND-R3-001-03", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["FIND-R3-001-03"], "labels": ["review", "finding", "iteration-1"], "error_context": "agent_version is read as attribution[1] instead of unpacking _attribution into named locals.", "review_reviewer_index": 3, "review_file": "apps/sandbox-executor/src/sandbox_executor/calibration/generate.py", "review_line": 191, "created_at": "2026-12-01T05:15:19.347119Z"} +{"action_id": "ACT-RES-1796102559-d81e96d7", "execution_id": "REV-RES-1-1796102559", "action": "Review Loop iteration 1 finding R1-F1 adjudicated: applied", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": "important", "review_iteration": 1, "review_finding_ids": ["R1-F1"], "review_disposition": "applied", "rejection_reason": null, "introduced_by_action_id": "ACT-FIND-1796102119-a2bed065", "labels": ["review", "resolver", "iteration-1"], "error_context": null, "created_at": "2026-12-01T05:22:39.934413Z"} +{"action_id": "ACT-RES-1796102559-18f7be28", "execution_id": "REV-RES-1-1796102559", "action": "Review Loop iteration 1 finding R1-F2 adjudicated: applied", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["R1-F2"], "review_disposition": "applied", "rejection_reason": null, "introduced_by_action_id": "ACT-FIND-1796102119-24698603", "labels": ["review", "resolver", "iteration-1"], "error_context": null, "created_at": "2026-12-01T05:22:39.935416Z"} +{"action_id": "ACT-RES-1796102559-3c4d3b5f", "execution_id": "REV-RES-1-1796102559", "action": "Review Loop iteration 1 finding R2-F1 adjudicated: applied", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": "important", "review_iteration": 1, "review_finding_ids": ["R2-F1"], "review_disposition": "applied", "rejection_reason": null, "introduced_by_action_id": "ACT-FIND-1796102119-47458a7e", "labels": ["review", "resolver", "iteration-1"], "error_context": null, "created_at": "2026-12-01T05:22:39.936191Z"} +{"action_id": "ACT-RES-1796102559-76e8e943", "execution_id": "REV-RES-1-1796102559", "action": "Review Loop iteration 1 finding R3-F1 adjudicated: applied", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["R3-F1"], "review_disposition": "applied", "rejection_reason": null, "introduced_by_action_id": "ACT-FIND-1796102119-d1bf46ea", "labels": ["review", "resolver", "iteration-1"], "error_context": null, "created_at": "2026-12-01T05:22:39.936831Z"} +{"action_id": "ACT-RES-1796102559-20a6ceed", "execution_id": "REV-RES-1-1796102559", "action": "Review Loop iteration 1 finding R3-F2 adjudicated: applied", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["R3-F2"], "review_disposition": "applied", "rejection_reason": null, "introduced_by_action_id": "ACT-FIND-1796102119-00b36ec9", "labels": ["review", "resolver", "iteration-1"], "error_context": null, "created_at": "2026-12-01T05:22:39.937466Z"} +{"action_id": "ACT-RES-1796102559-98c5619c", "execution_id": "REV-RES-1-1796102559", "action": "Review Loop iteration 1 finding R3-F3 adjudicated: applied", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["R3-F3"], "review_disposition": "applied", "rejection_reason": null, "introduced_by_action_id": "ACT-FIND-1796102119-1fa016c0", "labels": ["review", "resolver", "iteration-1"], "error_context": null, "created_at": "2026-12-01T05:22:39.938033Z"} +{"action_id": "ACT-REV-1796102948-0dc9e582", "execution_id": "REV-ITR-2-1796102948", "action": "Review Loop iteration 2 reviewer 1 completed", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": null, "review_iteration": 2, "review_finding_ids": null, "labels": ["review", "reviewer", "iteration-2"], "error_context": null, "review_reviewer_index": 1, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "APPROVED", "review_counts": {"critical": 0, "important": 0, "nit": 0}, "created_at": "2026-12-01T05:29:08.429382Z"} +{"action_id": "ACT-REV-1796102948-2f9a66ed", "execution_id": "REV-ITR-2-1796102948", "action": "Review Loop iteration 2 reviewer 2 completed", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": null, "review_iteration": 2, "review_finding_ids": null, "labels": ["review", "reviewer", "iteration-2"], "error_context": null, "review_reviewer_index": 2, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "APPROVED", "review_counts": {"critical": 0, "important": 0, "nit": 0}, "created_at": "2026-12-01T05:29:08.432012Z"} +{"action_id": "ACT-REV-1796102948-a999a322", "execution_id": "REV-ITR-2-1796102948", "action": "Review Loop iteration 2 reviewer 3 completed", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": null, "review_iteration": 2, "review_finding_ids": null, "labels": ["review", "reviewer", "iteration-2"], "error_context": null, "review_reviewer_index": 3, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "APPROVED", "review_counts": {"critical": 0, "important": 0, "nit": 0}, "created_at": "2026-12-01T05:29:08.434044Z"} +{"action_id": "ACT-REV-1796102951-e78d2086", "execution_id": "REV-ITR-2-1796102951", "action": "Review Loop iteration 2 evaluation for I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": null, "review_iteration": 2, "review_finding_ids": null, "labels": ["review", "review-loop", "iteration-2"], "error_context": null, "created_at": "2026-12-01T05:29:11.868098Z"} +{"action_id": "ACT-REV-1796102951-0800c580", "execution_id": "REV-ITR-2-1796102951", "action": "Review Loop iteration 2 reviewer 1 completed", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": null, "review_iteration": 2, "review_finding_ids": null, "labels": ["review", "reviewer", "iteration-2"], "error_context": null, "review_reviewer_index": 1, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "APPROVED", "review_counts": {"critical": 0, "important": 0, "nit": 0}, "created_at": "2026-12-01T05:29:11.869181Z"} +{"action_id": "ACT-REV-1796102951-10487a14", "execution_id": "REV-ITR-2-1796102951", "action": "Review Loop iteration 2 reviewer 2 completed", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": null, "review_iteration": 2, "review_finding_ids": null, "labels": ["review", "reviewer", "iteration-2"], "error_context": null, "review_reviewer_index": 2, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "APPROVED", "review_counts": {"critical": 0, "important": 0, "nit": 0}, "created_at": "2026-12-01T05:29:11.870373Z"} +{"action_id": "ACT-REV-1796102951-4ec516d0", "execution_id": "REV-ITR-2-1796102951", "action": "Review Loop iteration 2 reviewer 3 completed", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": null, "review_iteration": 2, "review_finding_ids": null, "labels": ["review", "reviewer", "iteration-2"], "error_context": null, "review_reviewer_index": 3, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "APPROVED", "review_counts": {"critical": 0, "important": 0, "nit": 0}, "created_at": "2026-12-01T05:29:11.871411Z"} +{"action_id": "ACT-POST-1796102956-ea409da1", "execution_id": "REV-POST-1796102956", "action": "Review consensus dual-posted to GitHub for I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "category": "code", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_iteration": 2, "labels": ["review", "github", "dual-post"], "created_at": "2026-12-01T05:29:16.244617Z"} +{"execution_id": "REV-1796102959-95ca200c-claude-agent", "plan_branch": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/_", "execution_branch": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "agent": "claude-agent", "agent_version": "1.4.0", "model": "claude-opus-5-5", "status": "approved", "entry_type": "summary", "summary": "Review Loop reached consensus approval after 2 iteration(s); PR ready for maintainer merge; final verdicts: Reviewer 1 APPROVED (0/0/0); Reviewer 2 APPROVED (0/0/0); Reviewer 3 APPROVED (0/0/0)", "created_at": "2026-12-01T05:29:19.190Z", "total_iterations": 2, "max_iterations": 25, "ci_checks_summary": {"source": "github_cli", "total": 16, "passed": 16, "failed": 0, "pending": 0, "skipped": 0, "all_passed": true, "checks": [{"bucket": "pass", "event": "", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/runs/142420539461", "name": "CodeQL", "state": "SUCCESS", "workflow": ""}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/46582516357/job/142420387677", "name": "build", "state": "SUCCESS", "workflow": "Docker Build"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/46582516444/job/142420352423", "name": "build (macos-latest)", "state": "SUCCESS", "workflow": "Run Make"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/46582516444/job/142420352110", "name": "build (ubuntu-latest)", "state": "SUCCESS", "workflow": "Run Make"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/46582516337/job/142420346999", "name": "unit (macos-latest, shard 1 of 2)", "state": "SUCCESS", "workflow": "Test - Unit"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/46582516422/job/142420346127", "name": "hygiene (ubuntu-latest)", "state": "SUCCESS", "workflow": "Test - Hygiene"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/46582516424/job/142420343671", "name": "ledger-invariants", "state": "SUCCESS", "workflow": "Test - Ledger Invariants"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/46582516259/job/142420344742", "name": "self-doc-behavior", "state": "SUCCESS", "workflow": "Test - Self-Doc Behavior"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/46582516280/job/142420341561", "name": "Workspace survival (ubuntu-latest)", "state": "SUCCESS", "workflow": "Test - Stress"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/46582516337/job/142420347249", "name": "unit (ubuntu-latest)", "state": "SUCCESS", "workflow": "Test - Unit"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/46582516337/job/142420346698", "name": "unit (macos-latest, shard 2 of 2)", "state": "SUCCESS", "workflow": "Test - Unit"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/46582516267/job/142420347769", "name": "commit-trailers", "state": "SUCCESS", "workflow": "Test - Commit Trailers"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/46582516336/job/142420343614", "name": "integration (ubuntu-latest)", "state": "SUCCESS", "workflow": "Test - Integration"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/46582516302/job/142420325404", "name": "scan", "state": "SUCCESS", "workflow": "Test - No Harness References"}, {"bucket": "pass", "event": "dynamic", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/46582511988/job/142420318218", "name": "Analyze (python)", "state": "SUCCESS", "workflow": "CodeQL"}, {"bucket": "pass", "event": "dynamic", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/46582511988/job/142420318655", "name": "Analyze (actions)", "state": "SUCCESS", "workflow": "CodeQL"}], "test_source": "ci_head", "test_head_sha": "6cf9b5d92b31df1fb5073dff2fcf7e77b86e1b42"}, "trailers": {"action_origin": "pr_review", "review_severity": null, "review_iteration": 2, "review_finding_ids": ["none"], "review_disposition": null, "rejection_reason": null, "introduced_by_action_id": null, "consulted_knowledge_ids": null}, "review_post_withheld": null} +{"execution_id": "REV-1796102959-95ca200c-claude-agent", "action": "Review Loop executed for I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "category": "test", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "verdict": "success", "outcome": "success", "entry_type": "action", "context_fingerprint": "f9c165a0535f65d2", "labels": ["review", "review-loop", "claude-agent"], "error_context": null, "action_id": "ACT-1796102959-aeee8f83", "created_at": "2026-12-01T05:29:19.191141Z"} +{"action_id": "ACT-CAL-1796103128-5633ea54", "execution_id": "CAL-P-1796100517-CLA-CO5.5-1796103128-fcf0d620", "action": "Calibration report generated for plan P-1796100517-CLA-CO5.5", "category": "doc", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/calibrated", "outcome": "success", "entry_type": "action", "action_origin": "calibration", "labels": ["calibration", "stage-5", "P-1796100517-CLA-CO5.5"], "error_context": null, "plan_branch": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/_", "execution_branch": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "evaluated_commit_sha": "243f809daf6c43e1060121b27637fe40ea9177a7", "predicted_metrics": {"p_success": 0.8, "entropy": 7.0, "impact": 70.0, "cost": 12.0, "learning_value": 4.0, "ev": 43.9}, "actual_metrics": {"p_success": 1.0, "entropy": 2.2, "impact": 70.0, "cost": 10.2, "learning_value": 4.0, "ev": 61.14, "duration_seconds": null, "tokens": null, "exit_code": 0, "test_pass_rate": 1.0, "files_changed": 19, "insertions": 657, "deletions": 24, "ev_clean": 61.14, "ev_with_bugs": 61.14, "p_success_clean": 1.0, "p_success_with_bugs": 1.0, "impact_clean": 70.0, "impact_with_bugs": 70.0, "bug_ev_drag": 0.0}, "calibration_deltas": {"p_success_error": 0.2, "entropy_error": 4.8, "impact_error": 0.0, "cost_error": 1.8, "learning_value_error": 0.0, "ev_error": 17.24, "delta_ev": 17.24, "delta_ev_clean": 17.24, "delta_ev_with_bugs": 17.24, "bug_ev_drag": 0.0}, "calibration_report_path": "plans/I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5_calibration.md", "created_at": "2026-12-01T05:32:08.689653Z", "touch_set_accuracy": {"precision": 0.59375, "recall": 1.0, "unpredicted_paths": [], "unused_entries": ["apps/sandbox-executor/src/sandbox_executor/calibration/predicted.py", "apps/sandbox-executor/src/sandbox_executor/cli/commands/calibrate.py", "apps/sandbox-executor/tests/test_calibration_regression_merge_main.py", "apps/sandbox-executor/tests/flow/stages/test_calibrate.py", "apps/sandbox-executor/tests/test_calibrate_full_stage5.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_ledger_merged_parity.py", "apps/sandbox-executor/tests/test_planner_plan_fence_format.py", "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", "apps/sandbox-executor/tests/test_calibration_metrics.py"]}} +{"action_id": "ACT-1796103129-6f5be2b2", "parent_action_id": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "event_type": "reconciliation", "verdict": "success", "outcome": "success", "reason": "Stage 5 calibration reconciled execution outcome to success", "created_at": "2026-12-01T05:32:09.100053Z"} +{"action_id": "SYNC-1796108390-d19613d4", "execution_id": "E-1796100754-CLA-CO5.5", "action": "target_sync", "category": "code", "target": "main", "outcome": "success", "event_type": "target_sync", "labels": ["target_sync", "flow_start"], "stage": "calibrate", "boundary": "flow_start", "branch": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "target_sha": "3e9960ade4064cc474cafa614500ee51b00a085b", "head_before": "69250dc78049e0374e3f9591b01b28160eb950cf", "conflicted_paths": [], "resolutions": [], "code_paths": [], "resolver_tier": "", "attempts": 0, "test_result": "", "supersedes": "", "entry_type": "action", "action_origin": "initial_implementation", "created_at": "2026-12-01T06:59:50.641009Z"} +{"action_id": "ACT-CAL-1796108899-83661fd1", "execution_id": "CAL-P-1796100517-CLA-CO5.5-1796108899-fcc1261c", "action": "Calibration report generated for plan P-1796100517-CLA-CO5.5", "category": "doc", "target": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/calibrated", "outcome": "success", "entry_type": "action", "action_origin": "calibration", "labels": ["calibration", "stage-5", "P-1796100517-CLA-CO5.5"], "error_context": null, "plan_branch": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/_", "execution_branch": "I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_", "evaluated_commit_sha": "86ff48e1793b29f49bdcc8cb2090f6bd5c51f357", "predicted_metrics": {"p_success": 0.8, "entropy": 7.0, "impact": 70.0, "cost": 12.0, "learning_value": 4.0, "ev": 43.9}, "actual_metrics": {"p_success": 1.0, "entropy": 2.2, "impact": 70.0, "cost": 10.2, "learning_value": 4.0, "ev": 61.14, "duration_seconds": null, "tokens": null, "exit_code": 0, "test_pass_rate": 1.0, "files_changed": 19, "insertions": 657, "deletions": 24, "ev_clean": 61.14, "ev_with_bugs": 61.14, "p_success_clean": 1.0, "p_success_with_bugs": 1.0, "impact_clean": 70.0, "impact_with_bugs": 70.0, "bug_ev_drag": 0.0}, "calibration_deltas": {"p_success_error": 0.2, "entropy_error": 4.8, "impact_error": 0.0, "cost_error": 1.8, "learning_value_error": 0.0, "ev_error": 17.24, "delta_ev": 17.24, "delta_ev_clean": 17.24, "delta_ev_with_bugs": 17.24, "bug_ev_drag": 0.0}, "calibration_report_path": "plans/I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5_calibration.md", "created_at": "2026-12-01T07:08:19.048426Z", "touch_set_accuracy": {"precision": 0.59375, "recall": 1.0, "unpredicted_paths": [], "unused_entries": ["apps/sandbox-executor/src/sandbox_executor/calibration/predicted.py", "apps/sandbox-executor/src/sandbox_executor/cli/commands/calibrate.py", "apps/sandbox-executor/tests/test_calibration_regression_merge_main.py", "apps/sandbox-executor/tests/flow/stages/test_calibrate.py", "apps/sandbox-executor/tests/test_calibrate_full_stage5.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_ledger_merged_parity.py", "apps/sandbox-executor/tests/test_planner_plan_fence_format.py", "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", "apps/sandbox-executor/tests/test_calibration_metrics.py"]}} diff --git a/holon-knowledge/ledger/pending/intents/I-1796100493-stage5-evaluator-plan-ev-sync.jsonl b/holon-knowledge/ledger/pending/intents/I-1796100493-stage5-evaluator-plan-ev-sync.jsonl new file mode 100644 index 000000000..31a9b778c --- /dev/null +++ b/holon-knowledge/ledger/pending/intents/I-1796100493-stage5-evaluator-plan-ev-sync.jsonl @@ -0,0 +1 @@ +{"slug": "stage5-evaluator-plan-ev-sync", "target_branch": "main", "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.", "rationale": "The calibration ledger is only comparable across runners when each report names the agent that ran it, and a predicted EV that differs between the plan document and the ledger makes every reported delta unverifiable; one value written once and checked fails closed.", "scope": ["apps/sandbox-executor/src/sandbox_executor/calibration/generate.py", "apps/sandbox-executor/src/sandbox_executor/calibration/report.py", "apps/sandbox-executor/src/sandbox_executor/calibration/run.py", "apps/sandbox-executor/src/sandbox_executor/calibration_self_check.py", "apps/sandbox-executor/src/sandbox_executor/calibration_record.py", "apps/sandbox-executor/src/sandbox_executor/calibration_predicted.py", "apps/sandbox-executor/src/sandbox_executor/flow/stage5.py", "apps/sandbox-executor/src/sandbox_executor/cli/commands/calibrate.py", "apps/sandbox-executor/src/sandbox_executor/entrypoint/planner.py", "apps/sandbox-executor/src/sandbox_executor/plan_ev_sync.py (new)", "docs/ledger_schema.md", "apps/sandbox-executor/tests/test_calibration_report.py", "apps/sandbox-executor/tests/test_calibration_regression_merge_main.py", "apps/sandbox-executor/tests/fixtures/calibration_report_golden.txt", "apps/sandbox-executor/tests/fixtures/calibration_merge_main_expected.md", "apps/sandbox-executor/tests/test_calibration_plan_keys.py", "apps/sandbox-executor/tests/test_calibration_evaluating_agent.py (new)", "apps/sandbox-executor/tests/test_calibration_ev_fail_closed.py (new)", "apps/sandbox-executor/tests/test_plan_ev_sync.py (new)", "apps/sandbox-executor/tests/flow/stages/test_calibrate.py", "apps/sandbox-executor/tests/test_calibrate_full_stage5.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", "apps/sandbox-executor/tests/test_ledger_merged_parity.py", "apps/sandbox-executor/tests/test_planner_plan_fence_format.py", "apps/sandbox-executor/tests/test_calibration_commit.py", "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", "apps/sandbox-executor/tests/test_calibration_metrics.py", "apps/sandbox-executor/src/sandbox_executor/calibration/predicted.py"], "acceptance_criteria": ["A resumed run that changes runner or model produces a calibration report whose evaluating agent equals the runner and model that executed Stage 5; the plan's original agent is shown separately.", "A test covers a checkpoint resume with a different agent/model and asserts both labels in the report, in apps/sandbox-executor/tests/test_calibration_evaluating_agent.py (new).", "No report names an evaluating agent that did not run the calibration step: the standalone calibrate command passes no evaluator and the report keeps the execution row's attribution, asserted in a test.", "The ACT-CAL ledger row records calibration_agent, calibration_model, plan_agent and plan_model as new keys and every existing key keeps its value, asserted in a test.", "A Stage 2 run writes the same predicted EV to the plans ledger row and the plan markdown (test asserts equality), in apps/sandbox-executor/tests/test_plan_ev_sync.py (new); a plan whose agent-written ev_pred differs from the computed EV is rewritten to the computed value, and a plan with no ev_pred row gets one.", "Stage 2 re-reads both written values after writing and fails the plan attempt when they differ, asserted in a test.", "Stage 5 with a ledger/markdown EV mismatch stops with a failure naming both values; it writes no calibration report, asserted in apps/sandbox-executor/tests/test_calibration_ev_fail_closed.py (new).", "Existing plans with matching values still calibrate unchanged: predicted, actual and delta metrics are identical and only the report header gains the plan-agent line; the existing calibration tests pass with only the golden fixtures and the warning-only mismatch test updated.", "apps/sandbox-executor/src/sandbox_executor/entrypoint/planner.py stays within its 655-line budget, every other changed module stays within the default 350 lines, holon-config/hygiene/module_budgets.json is untouched, and `uv run task lint` and `uv run pytest` pass.", "apps/sandbox-executor/tests/test_calibration_commit.py::test_run_calibrate_appends_and_commits_act_cal passes with its exact ACT-CAL key list extended by calibration_agent, calibration_model, plan_agent and plan_model, and every other consumer of the ACT-CAL row or the predicted EV (test_calibrate_no_fallback.py, test_calibrate_rerun.py, flow/test_pipeline.py, test_calibration_metrics.py, calibration/predicted.py) still passes.", "Changes are confined to these files and no others: apps/sandbox-executor/src/sandbox_executor/calibration/generate.py, apps/sandbox-executor/src/sandbox_executor/calibration/report.py, apps/sandbox-executor/src/sandbox_executor/calibration/run.py, apps/sandbox-executor/src/sandbox_executor/calibration_self_check.py, apps/sandbox-executor/src/sandbox_executor/calibration_record.py, apps/sandbox-executor/src/sandbox_executor/calibration_predicted.py, apps/sandbox-executor/src/sandbox_executor/flow/stage5.py, apps/sandbox-executor/src/sandbox_executor/cli/commands/calibrate.py, apps/sandbox-executor/src/sandbox_executor/entrypoint/planner.py, apps/sandbox-executor/src/sandbox_executor/plan_ev_sync.py, docs/ledger_schema.md, apps/sandbox-executor/tests/test_calibration_report.py, apps/sandbox-executor/tests/test_calibration_regression_merge_main.py, apps/sandbox-executor/tests/fixtures/calibration_report_golden.txt, apps/sandbox-executor/tests/fixtures/calibration_merge_main_expected.md, apps/sandbox-executor/tests/test_calibration_plan_keys.py, apps/sandbox-executor/tests/test_calibration_evaluating_agent.py, apps/sandbox-executor/tests/test_calibration_ev_fail_closed.py, apps/sandbox-executor/tests/test_plan_ev_sync.py, apps/sandbox-executor/tests/flow/stages/test_calibrate.py, apps/sandbox-executor/tests/test_calibrate_full_stage5.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, apps/sandbox-executor/tests/test_ledger_merged_parity.py, apps/sandbox-executor/tests/test_planner_plan_fence_format.py, apps/sandbox-executor/tests/test_calibration_commit.py, 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, apps/sandbox-executor/tests/test_calibration_metrics.py, apps/sandbox-executor/src/sandbox_executor/calibration/predicted.py.", "Code is self-explaining: no docstrings and no comments except '# why:' comments."], "assumptions": [{"id": "A1", "statement": "Only one existing test depends on a plans row versus plan file EV mismatch being warning-only (test_calibration_plan_keys.py). TESTED NOW: in a scratch detached worktree of origin/main 769b4d154 the cross-check was patched to raise on an ev difference and the 20 calibration, planner, plan-support and artefact test files were run with `uv run pytest -n 8`: 386 passed, 1 failed, the failure being test_a_plans_row_disagreeing_with_the_overall_table_logs_both_values. Re-tested in Stage 3 by the full test run.", "impact": "medium"}, {"id": "A2", "statement": "After a resume with a changed --agent or --model, the flow context agent and model at Stage 5 equal the resumed values. TESTED NOW by reading cli/commands/_flow_context.py lines 54 and 105-106 (resolve_resumed_runner result assigned to context.agent and context.model before any stage runs). Re-tested in Stage 3 by the new test that sets a context with a different agent and model than the plan row and asserts the report header.", "impact": "medium"}, {"id": "A3", "statement": "The resume log of a runner or model change already exists (resolve_resumed_runner logs 'Agent runner ... overrides' and 'Model ... overrides' at INFO), so no resume-path file needs a change. TESTED NOW by reading cli/commands/_flow_resume.py lines 91-121; checked again at Stage 4 by confirming the diff does not touch that file.", "impact": "low"}, {"id": "A4", "statement": "The plans row EV is computed by planner.py from the other metrics with the configured lambda and mu, while the markdown ev_pred row is optional and written by the planner agent; no other module writes either value. TESTED NOW by grep of src, entrypoint, holon-config and scripts for ev_pred, Overall Plan Metrics and metrics['ev'] writers (only planner.py and the prompt template). plan_decision.py copies the existing row's ev unchanged (read now).", "impact": "low"}, {"id": "A5", "statement": "All readers of the changed data keep working: calibration/predicted.py and calibration_predicted.py read the markdown EV, plan_support.py and pr_metadata.py read the row EV, ledger append of ACT-CAL uses preserve_shape=True so new keys are kept and ledger/query.py reads only agent/agent_name. TESTED NOW by grep for every reader of ev_pred, Overall Plan Metrics, calibration_report_path, predicted_metrics and Evaluating Agent in src, scripts, docs and tests, and by reading ledger/rows.py append_action_record. Re-tested in Stage 3 by the 20-file baseline command below.", "impact": "medium"}, {"id": "A6", "statement": "The existing tests of every in-scope module pass on origin/main 769b4d154 before the change. TESTED NOW from the repository root of a scratch detached worktree: `uv run pytest -n 4 -p no:cacheprovider` over tests/test_calibration_plan_keys.py, test_calibration_report.py, test_calibration.py, test_calibration_commit.py, test_unique_stage_ids.py, flow/stages/test_calibrate.py, test_calibrate_full_stage5.py, test_calibration_metrics.py, test_calibration_regression_merge_main.py, test_calibration_dual_ev.py, test_calibration_self_check.py, flow/test_calibrate_nested_refs.py, flow/test_stage5_fail_closed.py, test_planner_integration.py, test_planner_touch_set.py, test_planner_plan_fence_format.py, test_artefacts.py, flow/stages/test_plan_support.py, test_calibration_touch_set.py, test_calibration_review_churn.py and test_pr_body_real_agent_model.py (all under apps/sandbox-executor/tests): 387 passed, 17 subtests passed. `python scripts/check_module_budgets.py` (434 modules) and `python scripts/check_self_explaining.py` also pass on that commit.", "impact": "low"}, {"id": "A7", "statement": "The standalone `holon calibrate` command has no flow runner, so it passes no evaluator and keeps the execution row's attribution. TESTED NOW by reading cli/commands/calibrate.py (the wrapper forwards only execution_branch, target_worktree, json_output and skip_commit); re-tested in Stage 3 by the standalone-path assertion in the new test and by test_calibrate_full_stage5.py.", "impact": "low"}, {"id": "A8", "statement": "The scope is disjoint from open pull requests 457, 460 and 462 and from the running stage4-main-baseline-guard flow (its changed files and plan scope are flow/review/* and calibrate_target_sync.py with their tests). TESTED NOW by a script comparing this scope with `gh pr diff --name-only` of each PR and with the worktree diff against origin/main: zero common files. Pull request 463 (flow_guard.py, flow/pipeline.py) is already merged on origin/main. Re-tested at launch by repeating the comparison.", "impact": "medium"}, {"id": "A9", "statement": "planner.py (563 lines, budget 655) has room for the call and the failure handling, while all other changed modules are far under 350 lines (generate.py 219, report.py 280, run.py 163, stage5.py 245, calibration_predicted.py 159). TESTED NOW by wc -l on origin/main 769b4d154; re-tested in Stage 3 and Stage 4 by `python scripts/check_module_budgets.py`.", "impact": "low"}, {"id": "A10", "statement": "Stage 5 failure handling already converts any exception raised by generate_calibration into a failed Stage 5 with no report (run_stage5 comment: calibration exceptions propagate uncaught; _fail_calibration writes only an uncommitted failure row). TESTED NOW by reading flow/stage5.py lines 213-222 and flow/stages/calibrate.py _calibrate_execution_branch; re-tested in Stage 3 by the new fail-closed test asserting no report file exists.", "impact": "low"}, {"id": "A11", "statement": "Rewriting the markdown ev_pred row before Prettier convergence is safe because Prettier only re-aligns table columns and the recorded decision is parsed from the committed file. TESTED NOW by reading planner.py (the 'format before the ledger append' ordering) and plan_artifact_format.py; re-tested in Stage 3 by the new test comparing the committed markdown value with the committed row after formatting.", "impact": "medium"}, {"id": "A12", "statement": "Rewriting the markdown ev_pred row from the computed EV breaks no existing planner test except a formatting-sensitive byte comparison. TESTED NOW: in the scratch worktree planner.py was temporarily patched to rewrite the ev_pred row with the computed value (4 decimals) and tests/test_planner.py, test_planner_plan_fence_format.py, test_planner_integration.py, test_planner_touch_set.py and test_artefacts.py were run: 94 passed, 1 failed (test_missing_ruff_does_not_abort_the_planner, because '7.0' became '7.0000'); the patch was then reverted. Hence the intent requires the same minimal number form in both places, and test_planner.py stays out of scope. Re-tested in Stage 3 by running the same five files.", "impact": "medium"}, {"id": "A13", "statement": "test_calibration_commit.py is the only test outside the earlier scope that fails once the four ACT-CAL keys are added. TESTED NOW: the full `uv run pytest apps/sandbox-executor/tests -n 8` run on the halted previous attempt of this change (ACT-CAL keys and the EV fail-closed error already implemented) failed only test_run_calibrate_appends_and_commits_act_cal plus the two stress canaries that re-run the suite and one Docker bind-mount review-workspace integration test unrelated to calibration; the integration_test-marked calibration and planner tests passed. A grep of origin/main for ACT-CAL, Evaluating Agent, ev_pred, Overall Plan Metrics and predicted_metrics found the other readers now in scope. Re-tested in Stage 3 by the full test run.", "impact": "medium"}], "assumption_validation": [{"assumption_id": "A1", "method": "Already run before launch with the result recorded in the assumption statement; re-run in Stage 3 with the pytest, module budget and self-explaining commands named there, and checked again by the Stage 4 reviewers against the diff."}, {"assumption_id": "A2", "method": "Already run before launch with the result recorded in the assumption statement; re-run in Stage 3 with the pytest, module budget and self-explaining commands named there, and checked again by the Stage 4 reviewers against the diff."}, {"assumption_id": "A3", "method": "Already run before launch with the result recorded in the assumption statement; re-run in Stage 3 with the pytest, module budget and self-explaining commands named there, and checked again by the Stage 4 reviewers against the diff."}, {"assumption_id": "A4", "method": "Already run before launch with the result recorded in the assumption statement; re-run in Stage 3 with the pytest, module budget and self-explaining commands named there, and checked again by the Stage 4 reviewers against the diff."}, {"assumption_id": "A5", "method": "Already run before launch with the result recorded in the assumption statement; re-run in Stage 3 with the pytest, module budget and self-explaining commands named there, and checked again by the Stage 4 reviewers against the diff."}, {"assumption_id": "A6", "method": "Already run before launch with the result recorded in the assumption statement; re-run in Stage 3 with the pytest, module budget and self-explaining commands named there, and checked again by the Stage 4 reviewers against the diff."}, {"assumption_id": "A7", "method": "Already run before launch with the result recorded in the assumption statement; re-run in Stage 3 with the pytest, module budget and self-explaining commands named there, and checked again by the Stage 4 reviewers against the diff."}, {"assumption_id": "A8", "method": "Already run before launch with the result recorded in the assumption statement; re-run in Stage 3 with the pytest, module budget and self-explaining commands named there, and checked again by the Stage 4 reviewers against the diff."}, {"assumption_id": "A9", "method": "Already run before launch with the result recorded in the assumption statement; re-run in Stage 3 with the pytest, module budget and self-explaining commands named there, and checked again by the Stage 4 reviewers against the diff."}, {"assumption_id": "A10", "method": "Already run before launch with the result recorded in the assumption statement; re-run in Stage 3 with the pytest, module budget and self-explaining commands named there, and checked again by the Stage 4 reviewers against the diff."}, {"assumption_id": "A11", "method": "Already run before launch with the result recorded in the assumption statement; re-run in Stage 3 with the pytest, module budget and self-explaining commands named there, and checked again by the Stage 4 reviewers against the diff."}, {"assumption_id": "A12", "method": "Already run before launch with the result recorded in the assumption statement; re-run in Stage 3 with the pytest, module budget and self-explaining commands named there, and checked again by the Stage 4 reviewers against the diff."}, {"assumption_id": "A13", "method": "Already run before launch with the result recorded in the assumption statement; re-run in Stage 3 by the full `uv run pytest` and checked again by the Stage 4 pre-push test gate."}], "assumption_risk": [{"assumption_id": "A1", "likelihood": "low", "testability": "testable", "score": 1, "response": "fail fast in the named Stage 3 test; park and re-scope before Stage 4 if the check shows an out-of-scope file"}, {"assumption_id": "A2", "likelihood": "low", "testability": "testable", "score": 1, "response": "fail fast in the named Stage 3 test; park and re-scope before Stage 4 if the check shows an out-of-scope file"}, {"assumption_id": "A3", "likelihood": "low", "testability": "testable", "score": 1, "response": "fail fast in the named Stage 3 test; park and re-scope before Stage 4 if the check shows an out-of-scope file"}, {"assumption_id": "A4", "likelihood": "low", "testability": "testable", "score": 1, "response": "fail fast in the named Stage 3 test; park and re-scope before Stage 4 if the check shows an out-of-scope file"}, {"assumption_id": "A5", "likelihood": "medium", "testability": "testable", "score": 2, "response": "fail fast in the named Stage 3 test; park and re-scope before Stage 4 if the check shows an out-of-scope file"}, {"assumption_id": "A6", "likelihood": "low", "testability": "testable", "score": 1, "response": "fail fast in the named Stage 3 test; park and re-scope before Stage 4 if the check shows an out-of-scope file"}, {"assumption_id": "A7", "likelihood": "low", "testability": "testable", "score": 1, "response": "fail fast in the named Stage 3 test; park and re-scope before Stage 4 if the check shows an out-of-scope file"}, {"assumption_id": "A8", "likelihood": "medium", "testability": "testable", "score": 2, "response": "fail fast in the named Stage 3 test; park and re-scope before Stage 4 if the check shows an out-of-scope file"}, {"assumption_id": "A9", "likelihood": "low", "testability": "testable", "score": 1, "response": "fail fast in the named Stage 3 test; park and re-scope before Stage 4 if the check shows an out-of-scope file"}, {"assumption_id": "A10", "likelihood": "low", "testability": "testable", "score": 1, "response": "fail fast in the named Stage 3 test; park and re-scope before Stage 4 if the check shows an out-of-scope file"}, {"assumption_id": "A11", "likelihood": "medium", "testability": "testable", "score": 2, "response": "fail fast in the named Stage 3 test; park and re-scope before Stage 4 if the check shows an out-of-scope file"}, {"assumption_id": "A12", "likelihood": "medium", "testability": "testable", "score": 2, "response": "fail fast in the named Stage 3 test; park and re-scope before Stage 4 if the check shows an out-of-scope file"}, {"assumption_id": "A13", "likelihood": "low", "testability": "testable", "score": 1, "response": "fail fast in the Stage 3 full test run; park and re-scope before Stage 4 if a further out-of-scope test fails"}], "branch": "I-1796100493-stage5-evaluator-plan-ev-sync", "status": "proposed", "created_at": "2026-12-01T04:48:20.892Z"} diff --git a/holon-knowledge/ledger/pending/plans/I-1796100493-stage5-evaluator-plan-ev-sync.jsonl b/holon-knowledge/ledger/pending/plans/I-1796100493-stage5-evaluator-plan-ev-sync.jsonl new file mode 100644 index 000000000..536a0f755 --- /dev/null +++ b/holon-knowledge/ledger/pending/plans/I-1796100493-stage5-evaluator-plan-ev-sync.jsonl @@ -0,0 +1 @@ +{"plan_id": "P-1796100517-CLA-CO5.5", "intent_branch": "I-1796100493-stage5-evaluator-plan-ev-sync/_", "agent": "claude-agent", "agent_version": "2.1.302", "model": "claude-opus-5-5", "p_success": 0.8, "entropy": 7.0, "impact": 70.0, "cost": 12.0, "learning_value": 4.0, "ev": 43.9, "created_at": "2026-12-01T04:51:29.838Z", "plan_file": "plans/I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5.md", "status": "proposed", "entropy_budget": 15.0, "decomposition_decision": "execute", "touch_set": [{"path": "apps/sandbox-executor/src/sandbox_executor/calibration/generate.py"}, {"path": "apps/sandbox-executor/src/sandbox_executor/calibration/report.py"}, {"path": "apps/sandbox-executor/src/sandbox_executor/calibration/run.py"}, {"path": "apps/sandbox-executor/src/sandbox_executor/calibration/predicted.py"}, {"path": "apps/sandbox-executor/src/sandbox_executor/calibration_self_check.py"}, {"path": "apps/sandbox-executor/src/sandbox_executor/calibration_record.py"}, {"path": "apps/sandbox-executor/src/sandbox_executor/calibration_predicted.py"}, {"path": "apps/sandbox-executor/src/sandbox_executor/flow/stage5.py"}, {"path": "apps/sandbox-executor/src/sandbox_executor/cli/commands/calibrate.py"}, {"path": "apps/sandbox-executor/src/sandbox_executor/entrypoint/planner.py"}, {"path": "apps/sandbox-executor/src/sandbox_executor/plan_ev_sync.py"}, {"path": "docs/ledger_schema.md"}, {"path": "apps/sandbox-executor/tests/test_calibration_report.py"}, {"path": "apps/sandbox-executor/tests/test_calibration_regression_merge_main.py"}, {"path": "apps/sandbox-executor/tests/fixtures/calibration_report_golden.txt"}, {"path": "apps/sandbox-executor/tests/fixtures/calibration_merge_main_expected.md"}, {"path": "apps/sandbox-executor/tests/test_calibration_plan_keys.py"}, {"path": "apps/sandbox-executor/tests/test_calibration_evaluating_agent.py"}, {"path": "apps/sandbox-executor/tests/test_calibration_ev_fail_closed.py"}, {"path": "apps/sandbox-executor/tests/test_plan_ev_sync.py"}, {"path": "apps/sandbox-executor/tests/flow/stages/test_calibrate.py"}, {"path": "apps/sandbox-executor/tests/test_calibrate_full_stage5.py"}, {"path": "apps/sandbox-executor/tests/test_calibration_self_check.py"}, {"path": "apps/sandbox-executor/tests/test_calibration_report_self_explaining_counts.py"}, {"path": "apps/sandbox-executor/tests/test_unique_stage_ids.py"}, {"path": "apps/sandbox-executor/tests/test_ledger_merged_parity.py"}, {"path": "apps/sandbox-executor/tests/test_planner_plan_fence_format.py"}, {"path": "apps/sandbox-executor/tests/test_calibration_commit.py"}, {"path": "apps/sandbox-executor/tests/test_calibrate_no_fallback.py"}, {"path": "apps/sandbox-executor/tests/test_calibrate_rerun.py"}, {"path": "apps/sandbox-executor/tests/flow/test_pipeline.py"}, {"path": "apps/sandbox-executor/tests/test_calibration_metrics.py"}]} diff --git a/plans/I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5.md b/plans/I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5.md new file mode 100644 index 000000000..d670a6324 --- /dev/null +++ b/plans/I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5.md @@ -0,0 +1,657 @@ +# Plan for I-1796100493-stage5-evaluator-plan-ev-sync + +- **Plan ID:** P-1796100517-CLA-CO5.5 +- **Parent Intent ID:** NONE +- **Agent:** claude-agent/claude-opus-5-5 (version: 2.1.302) +- **Created At:** 2026-12-01T04:48:38.336Z + +## Planner Autonomy Summary + +- **Intent handling:** ACCEPT_AS_IS +- **Reframed intent (if applicable):** N/A +- **Exploration stance:** conservative with a fail-fast baseline. The intent is fully specified (files, keys, error + semantics, test files) and its assumptions were already tested on origin/main, so the plan exploits that knowledge and + spends exploration only on a cheap baseline re-run that confirms the assumptions still hold on the current tip. +- **Safety priority level:** elevated +- **Priority Justification:** The change touches the calibration ledger row (ACT-CAL, `world/constraints.md` section 3 + append-only ledgers) and introduces a new fail-closed path in Stage 5 and Stage 2. Ledger rows are only ever appended + (new keys, no rewrites of history), and a wrong fail-closed check could block every flow, so both new failure paths + get dedicated positive and negative tests. + +## Exploration + +- **Proportion of steps that are exploratory:** 0.14 +- **Justification:** One of seven steps (the baseline) is a cheap information-gathering step; everything else is + specified implementation work whose risk is in details (signatures of test fakes, number formatting), not in unknowns. + +## Overall Plan Metrics + +| metric | value | +| ------------------- | ----- | +| p_success_pred | 0.8 | +| entropy_pred | 7.0 | +| impact_pred | 70.0 | +| cost_pred | 12.0 | +| learning_value_pred | 4.0 | +| ev_pred | 43.9 | + +### Strategy Rationale + +The intent bundles two independent defects that share one reader (the Stage 5 calibration report): the wrong evaluating +agent after a resumed run, and two different predicted EV values for one plan. Both are small, well-located changes in +modules far below their line budgets except `entrypoint/planner.py` (563 of 655 lines), so all new Stage 2 EV logic goes +into the new `plan_ev_sync.py` module and planner.py only gains a call and one failure branch. + +Order of work: (1) baseline, (2) evaluator plumbing and ACT-CAL keys, (3) evaluator tests and fixtures, (4) Stage 5 EV +fail-closed error, (5) Stage 2 single-EV writer and check, (6) docs, (7) full lint and test gate. The EV fail-closed +change in Stage 5 is safe only because Stage 2 now writes one value; existing committed plans with matching values are +unaffected (A1 shows only one existing test depends on warning-only behaviour). + +Aggregation: overall `p_success` is the product-like judgement over the bottleneck steps 2, 4 and 5 (each about 0.92 to +0.95) and the final gate step 7 (0.9, since it re-runs the full suite and the self-explaining and module-budget gates), +rounded to 0.8. Entropy is the sum of step entropies (`0.3 + 1.4 + 1.0 + 1.2 + 1.6 + 0.3 + 1.2 = 7.0`). Cost is the sum +of step costs (`0.5 + 2.5 + 2.0 + 2.0 + 2.5 + 0.5 + 2.0 = 12.0`). Impact is a qualitative 70: it removes an unverifiable +calibration delta and wrong attribution across every future run, but changes no user-facing feature. Learning value 4.0 +is the max-plus-small-sum of the steps (mostly confirming the resume context and Prettier interaction). + +`EV = P(success) * Impact + mu * LearningValue - lambda * Delta_S_intent - Cost` + +`EV = 0.8 * 70.0 + 0.5 * 4.0 - 0.3 * 7.0 - 12.0 = 56.0 + 2.0 - 2.1 - 12.0 = 43.9` + +Strong assumptions: A2 (flow context agent/model equal the resumed values at Stage 5), A11 (Prettier only re-aligns the +metrics table, so a value written before convergence survives), A12 (the minimal float form keeps the byte comparison in +`test_planner_plan_fence_format.py` passing). + +## Safety & Constraint Alignment + +- **Key world ruleset constraints that affect this plan:** + - `holon-config/world/constraints.md` section 3: ledgers are append-only; the plan only adds keys to newly appended + ACT-CAL rows and never rewrites existing plans or executions rows. + - `holon-config/world/constraints.md` section 1: work stays on the intent/plan/execution branch prefix; no commits to + `main`. + - `holon-config/world/ruleset.md` section 3: every test change is declared here (the intent lists each test file). + - `docs/safety.md` entropy budget 15.0 and module-budget freeze: `holon-config/hygiene/module_budgets.json` is never + touched. + - Repository self-explaining rule: no new docstrings or comments except `# why:` lines; existing docstrings in + `calibration/generate.py` and `calibration/report.py` are not edited (editing one counts as adding one), so new + parameters are added without touching docstring text. +- **Potential violations or edge cases:** + - Editing the `generate_calibration` docstring to describe the new parameters would trip `check_self_explaining.py`. + - A raised EV error swallowed by the broad `except Exception` in `cross_check_selected_row` would silently keep + warning-only behaviour. + - A plan row and markdown value formatted differently (`7.0` vs `7.0000`) would break the byte comparison test. + - `planner.py` crossing 655 lines. + - Test fakes for `steps.calibrate` with fixed keyword signatures rejecting the new keyword inputs. +- **Mitigations built into the plan:** + - The mismatch is computed inside the try block but raised after it; a dedicated test asserts propagation through + `generate_calibration`. + - EV is rounded once to 4 decimals and written to the markdown with `repr(float)` (the same text `json.dumps` writes), + so `7.0` stays `7.0`. + - planner.py gains at most about 10 lines; `scripts/check_module_budgets.py` runs in Steps 5 and 7. + - New keyword inputs are optional in the `CalibrateReview` TypedDict (`total=False`), so callers that do not pass them + keep working; only fakes with closed signatures are updated. +- **Residual risk accepted (and why):** A plan already on disk whose markdown ev_pred differs from its plans row by more + than 0.01 will now fail Stage 5 instead of warning. This is the intent's explicit goal (fail closed); the error + message names both values and the plan file, and the existing remedy (append a plans correction row with + ledger_revision >= 2) still applies. +- **Allocated Entropy Budget:** 15.0 +- **Predicted Plan Entropy:** 7.0 +- **Budget Compliance:** The strategy fits within budget; no sub-intent list is needed. + +## Plan Description & Strategy + +Two coupled fixes, executed as one plan on one execution branch: + +1. **Evaluator attribution.** `CalibrateReview` gains optional `evaluating_agent` and `evaluating_model` keys. + `run_calibrate` forwards them to `generate_calibration`, which uses them for the report's `agent_id` / `model_name` + when given, otherwise keeps today's `_attribution` fallback (execution row, then plan row, then legacy defaults). The + plans row's own `agent` / `model` become `plan_agent` / `plan_model` on the report and render as a separate header + line. Stage 5 passes `context.agent` / `context.model` (already the resumed values per A2). The ACT-CAL row gains + `calibration_agent`, `calibration_model`, `plan_agent`, `plan_model` appended after the existing keys. +2. **One predicted EV.** A new `plan_ev_sync.py` owns rewriting/inserting the `ev_pred` row of the plan markdown's + Overall Plan Metrics table and re-reading both stored values. planner.py computes and rounds EV once, writes it to + the markdown before Prettier convergence, then after the plans.jsonl append re-reads both values and fails the + attempt via `_fail_plan_attempt` on a difference. Stage 5's cross-check raises a dedicated `PlanEvMismatchError` for + an `ev` difference above 0.01 between the selected plans row and the plan file; all other mismatches stay warnings. + +## Touch Set + +- `apps/sandbox-executor/src/sandbox_executor/calibration/generate.py` +- `apps/sandbox-executor/src/sandbox_executor/calibration/report.py` +- `apps/sandbox-executor/src/sandbox_executor/calibration/run.py` +- `apps/sandbox-executor/src/sandbox_executor/calibration/predicted.py` +- `apps/sandbox-executor/src/sandbox_executor/calibration_self_check.py` +- `apps/sandbox-executor/src/sandbox_executor/calibration_record.py` +- `apps/sandbox-executor/src/sandbox_executor/calibration_predicted.py` +- `apps/sandbox-executor/src/sandbox_executor/flow/stage5.py` +- `apps/sandbox-executor/src/sandbox_executor/cli/commands/calibrate.py` +- `apps/sandbox-executor/src/sandbox_executor/entrypoint/planner.py` +- `apps/sandbox-executor/src/sandbox_executor/plan_ev_sync.py` +- `docs/ledger_schema.md` +- `apps/sandbox-executor/tests/test_calibration_report.py` +- `apps/sandbox-executor/tests/test_calibration_regression_merge_main.py` +- `apps/sandbox-executor/tests/fixtures/calibration_report_golden.txt` +- `apps/sandbox-executor/tests/fixtures/calibration_merge_main_expected.md` +- `apps/sandbox-executor/tests/test_calibration_plan_keys.py` +- `apps/sandbox-executor/tests/test_calibration_evaluating_agent.py` +- `apps/sandbox-executor/tests/test_calibration_ev_fail_closed.py` +- `apps/sandbox-executor/tests/test_plan_ev_sync.py` +- `apps/sandbox-executor/tests/flow/stages/test_calibrate.py` +- `apps/sandbox-executor/tests/test_calibrate_full_stage5.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` +- `apps/sandbox-executor/tests/test_ledger_merged_parity.py` +- `apps/sandbox-executor/tests/test_planner_plan_fence_format.py` +- `apps/sandbox-executor/tests/test_calibration_commit.py` +- `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` +- `apps/sandbox-executor/tests/test_calibration_metrics.py` + +--- + +## Step 1: Re-run the baseline and the scope-overlap check on the current tip + +- **Sub‑intent recommendation:** NO +- **Reasoning:** Read-only, minutes of cost; it only confirms A6 and A8 still hold on the branch base. +- **Step Type:** INFO_GATHERING +- **Exploration level:** BALANCED + +- **Hypothesis being tested:** The in-scope tests, module budgets and self-explaining gate pass on the branch base, and + no open PR touches a file in the touch set. +- **Learning target:** Whether any pre-existing failure or new overlapping PR must be separated from this change. +- **Maximum acceptable cost for this learning:** 0.5 cost units (one foreground pytest run plus `gh pr list`). + +### Intent & Git Integration + +- **Step Intent:** Establish a clean, attributable baseline before any code change. +- **Git branch:** `I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-.../_` (execution branch) +- **Sub‑intent:** NONE + +### Implementation Details (No code blocks, only logic/steps) + +1. From the repository root, run in the foreground `uv run pytest -n auto --dist worksteal` over the 21 test files named + in A6 plus `tests/test_calibration_commit.py`, `tests/test_calibrate_no_fallback.py`, + `tests/test_calibrate_rerun.py`, `tests/flow/test_pipeline.py` and `tests/test_planner.py` (all under + `apps/sandbox-executor/`); record pass/fail counts. +2. Run `python scripts/check_module_budgets.py` and `python scripts/check_self_explaining.py`. +3. Run `wc -l` on the ten in-scope source modules and record the headroom (planner.py 563 of 655). +4. List open PRs with `gh pr list` and compare each `gh pr diff --name-only` with the touch set; record any overlap. + +### Dependencies & Criticality + +- **Depends on:** NONE +- **Is Bottleneck:** NO + +### Safety & Constraint Considerations + +- **Relevant rules:** `docs/safety.md` (git is the safety boundary), test-run discipline (foreground, once). +- **Potential failure modes for this step:** a pre-existing flaky failure is mistaken for a regression later. +- **Guardrails and early‑abort checks:** a pre-existing failure in an in-scope file is recorded and re-checked after + Step 7; an overlapping open PR on an in-scope file parks the flow before Step 2. + +### Success & Discard Criteria + +- **Success:** Baseline counts recorded; zero touch-set overlap with open PRs. +- **Discard:** Overlap found on a source file in scope: stop and re-scope. + +### Metrics + +| metric | value | +| ------------------- | ----- | +| p_success_pred | 0.97 | +| entropy_pred | 0.3 | +| impact_pred | 5.0 | +| cost_pred | 0.5 | +| learning_value_pred | 1.0 | +| ev_pred | 4.8 | + +### Step Metrics Rationale + +`EV = 0.97 * 5.0 + 0.5 * 1.0 - 0.3 * 0.3 - 0.5 = 4.85 + 0.5 - 0.09 - 0.5 = 4.76` (rounded 4.8). Cheap and nearly +certain; its value is protecting attribution of later failures. + +--- + +## Step 2: Plumb the evaluating agent and model into the report and the ACT-CAL row + +- **Sub‑intent recommendation:** NO +- **Reasoning:** Six small, mechanical edits along one call chain; reversible and covered by Step 3 tests. +- **Step Type:** IMPLEMENTATION +- **Exploration level:** EXPLOIT + +### Intent & Git Integration + +- **Step Intent:** Make the report and ACT-CAL row name the runner and model that ran Stage 5, and show the plan's own + agent and model separately. +- **Git branch:** same execution branch +- **Sub‑intent:** NONE + +### Implementation Details (No code blocks, only logic/steps) + +1. `calibration_self_check.py`: add `evaluating_agent: str | None` and `evaluating_model: str | None` to the + `CalibrateReview` TypedDict (`total=False`, so both stay optional). +2. `calibration/run.py` `run_calibrate`: read both keys from `review` and pass them as keyword arguments to + `generate_calibration`. +3. `calibration/generate.py`: + - add keyword-only parameters `evaluating_agent: str | None = None` and `evaluating_model: str | None = None` to + `generate_calibration`; do not edit the existing docstring text. + - add a small function, e.g. `_evaluator(fallback_agent, fallback_model, evaluating_agent, evaluating_model)`, that + returns the given evaluator when present, else the `_attribution` result (the standalone path keeps today's + attribution unchanged). + - add `_plan_attribution(plan_meta)` returning `(plan_meta.get("agent") or "N/A", plan_meta.get("model") or "N/A")`. + - add `plan_agent` and `plan_model` to `report_dict`, set `agent_id` / `model_name` from the evaluator. + - `agent_version` stays the execution/plan row value (the header does not render it). +4. `calibration/report.py`: add dataclass fields `plan_agent: str | None = None` and `plan_model: str | None = None` + (defaults, so existing direct constructions stay valid); in `_header_lines` keep the `Evaluating Agent` line and + insert directly after it + `- **Plan Agent:** \`{plan_agent}/{plan_model}\``(rendered only when`plan_agent`is in`report_data`, so callers that + build report dicts without it keep their output). +5. `calibration_record.py` `calibration_action_row`: append, after `touch_set_accuracy`, in this order: + `calibration_agent` (from `data["agent_id"]`), `calibration_model` (from `data["model_name"]`), `plan_agent`, + `plan_model`. No existing key changes; none is named `agent` or `model`, so `ledger/query.py` attribution is + unaffected. +6. `flow/stage5.py`: in the `steps.calibrate(...)` call pass `evaluating_agent=context.agent` and + `evaluating_model=context.model`. +7. `cli/commands/calibrate.py`: keep the call without evaluator keys; only touch it if a type check needs an explicit + `None` (preferably not touched at all). +8. Run `uv run pytest` on `tests/test_calibration_report.py`, `tests/test_calibration_commit.py`, + `tests/flow/stages/test_calibrate.py`, `tests/test_calibrate_full_stage5.py`, `tests/test_unique_stage_ids.py` + (expected failures are only golden fixtures, the exact key list and closed-signature fakes, fixed in Step 3). + +### Dependencies & Criticality + +- **Depends on:** Step 1 +- **Is Bottleneck:** YES + +### Safety & Constraint Considerations + +- **Relevant rules:** `world/constraints.md` section 3 (append-only; new keys only on newly appended rows); + self-explaining gate (no docstring edits). +- **Potential failure modes for this step:** a fake `calibrate` step with a closed signature rejects the new keywords; + `CalibrationReport` field ordering breaks a positional construction; `to_dict()` key list asserted exactly somewhere. +- **Guardrails and early‑abort checks:** new dataclass fields go after the existing defaulted fields; grep tests for + `to_dict()` equality before editing; abort and re-scope if an out-of-scope test needs changing. + +### Success & Discard Criteria + +- **Success:** A report generated with evaluator inputs shows them as `Evaluating Agent`, the plan row agent/model on + `Plan Agent`, and the ACT-CAL row carries the four new keys; without evaluator inputs the header agent is unchanged. +- **Discard:** More than one out-of-scope test file needs editing; cost above 1.5x. + +### Metrics + +| metric | value | +| ------------------- | ----- | +| p_success_pred | 0.94 | +| entropy_pred | 1.4 | +| impact_pred | 25.0 | +| cost_pred | 2.5 | +| learning_value_pred | 0.8 | +| ev_pred | 20.7 | + +### Step Metrics Rationale + +`EV = 0.94 * 25.0 + 0.5 * 0.8 - 0.3 * 1.4 - 2.5 = 23.5 + 0.4 - 0.42 - 2.5 = 20.98` (rounded down to 20.7 for the risk of +closed-signature fakes). Well-located, single call chain; entropy from six files and one ledger shape change. + +--- + +## Step 3: Test the evaluator attribution and update fixtures and pinned key lists + +- **Sub‑intent recommendation:** NO +- **Reasoning:** Test-only work in files the intent names; small and directly tied to Step 2. +- **Step Type:** TEST +- **Exploration level:** EXPLOIT + +### Intent & Git Integration + +- **Step Intent:** Prove the resumed evaluator is named, the standalone path keeps its attribution, and ACT-CAL gained + exactly the four keys. +- **Git branch:** same execution branch +- **Sub‑intent:** NONE + +### Implementation Details (No code blocks, only logic/steps) + +1. New `tests/test_calibration_evaluating_agent.py`: + - resume case: build a plan row with agent `claude-agent` / model `claude-opus-5-5` and an execution row with the + same, build a FlowContext whose `agent` / `model` are a different runner and model (as `_flow_context` sets after a + resume with changed `--agent` / `--model`), run Stage 5's calibrate call with a recording or real `run_calibrate`, + and assert the report header `Evaluating Agent` names the context runner/model and `Plan Agent` names the plan + row's agent/model. + - standalone case: call `run_calibrate` (as `cli/commands/calibrate.py` does) without evaluator keys and assert the + `Evaluating Agent` equals the execution row's attribution. + - ACT-CAL case: assert `calibration_agent`, `calibration_model`, `plan_agent`, `plan_model` values and that every + pre-existing key is present with the value it had before (compare against a row built without the new fields). + - reuse existing fixtures (`calibrate_scenarios.py`, `worktree_fixtures.py`) to stay hermetic; no network. +2. `tests/fixtures/calibration_report_golden.txt` and `tests/fixtures/calibration_merge_main_expected.md`: add only the + `Plan Agent` header line; predicted/actual/delta sections stay byte-identical (acceptance: metrics unchanged). +3. `tests/test_calibration_commit.py::test_run_calibrate_appends_and_commits_act_cal`: extend the exact key list with + the four keys in the order `calibration_record.py` writes them; other assertions unchanged. +4. Update `tests/test_calibration_report.py`, `tests/test_calibration_regression_merge_main.py`, + `tests/flow/stages/test_calibrate.py`, `tests/test_calibrate_full_stage5.py`, `tests/test_unique_stage_ids.py`, + `tests/test_calibration_self_check.py`, `tests/test_calibration_report_self_explaining_counts.py`, + `tests/test_ledger_merged_parity.py`, `tests/test_calibrate_no_fallback.py`, `tests/test_calibrate_rerun.py`, + `tests/flow/test_pipeline.py` only where a fake signature, header line or key list requires it. +5. Run `uv run pytest` over those files plus the new file, foreground. + +### Dependencies & Criticality + +- **Depends on:** Step 2 +- **Is Bottleneck:** NO + +### Safety & Constraint Considerations + +- **Relevant rules:** `world/ruleset.md` section 3 (declared test changes only); hermetic test fixtures (no real + worktree or network). +- **Potential failure modes for this step:** golden fixture drift beyond the header line hides a metrics change. +- **Guardrails and early‑abort checks:** `git diff` of each fixture must show exactly one added line; any other diff + line means Step 2 changed metrics and is reworked. + +### Success & Discard Criteria + +- **Success:** New test passes; fixture diffs are one added line each; all listed files pass. +- **Discard:** A fixture needs more than the header line changed. + +### Metrics + +| metric | value | +| ------------------- | ----- | +| p_success_pred | 0.93 | +| entropy_pred | 1.0 | +| impact_pred | 12.0 | +| cost_pred | 2.0 | +| learning_value_pred | 0.8 | +| ev_pred | 8.9 | + +### Step Metrics Rationale + +`EV = 0.93 * 12.0 + 0.5 * 0.8 - 0.3 * 1.0 - 2.0 = 11.16 + 0.4 - 0.3 - 2.0 = 9.26` (rounded down to 8.9 for building a +realistic resume context). Verifies A2 directly. + +--- + +## Step 4: Fail Stage 5 closed on a plans row versus plan file EV mismatch + +- **Sub‑intent recommendation:** NO +- **Reasoning:** One new exception and a raise moved out of a broad try; high value, low size, fully testable. +- **Step Type:** IMPLEMENTATION +- **Exploration level:** EXPLOIT + +### Intent & Git Integration + +- **Step Intent:** Turn the silent EV disagreement into a named failure that stops calibration before any report is + written. +- **Git branch:** same execution branch +- **Sub‑intent:** NONE + +### Implementation Details (No code blocks, only logic/steps) + +1. `calibration_predicted.py`: + - add `class PlanEvMismatchError(RuntimeError)` holding `plan_file`, `ledger_ev`, `plan_file_ev`, with a message + naming both values (`:g`) and the plan file, plus the existing remedy (append a plans correction row with + ledger_revision >= 2). + - in `cross_check_selected_row`, keep the existing broad `try` for reading sources and warnings, but compute the plan + file EV comparison and raise `PlanEvMismatchError` after the `try` block (so the `except Exception` cannot swallow + it) when `abs(selected ev - plan file ev) > MISMATCH_TOLERANCE`. + - the `ev` mismatch against the plan file is no longer also logged as a warning; mismatches of other fields and every + execution-summary mismatch stay warnings; update the `# why:` comment above `cross_check_predicted` to say only the + plan file EV fails closed. +2. `calibration/predicted.py`: confirm `_parse_predicted_from_plans_ledger` and `PredictedMetrics.from_plan` let the + error propagate (they do today; no `suppress` wraps the ledger path); change only if needed. +3. `calibration/generate.py`: no catch added, so the error leaves `generate_calibration`; Stage 5 already fails closed + (A10) and writes only the uncommitted failure row. +4. `tests/test_calibration_plan_keys.py`: convert `test_a_plans_row_disagreeing_with_the_overall_table_logs_both_values` + into a test asserting `PlanEvMismatchError` with `7.38`, `52.26` and the plan file in the message; keep the tolerance + and execution-mismatch tests as they are. +5. New `tests/test_calibration_ev_fail_closed.py`: (a) `generate_calibration` on a worktree whose plans row EV and plan + markdown EV differ raises `PlanEvMismatchError` naming both; (b) Stage 5 via `run_calibrate` / the calibrate stage + ends failed and no calibration report file exists under `plans/` and no ACT-CAL success row was appended; (c) a + non-EV field mismatch still only warns and calibrates; (d) values within 0.01 calibrate unchanged. +6. Run + `uv run pytest tests/test_calibration_plan_keys.py tests/test_calibration_ev_fail_closed.py tests/test_calibration_metrics.py tests/test_calibration.py tests/flow/test_stage5_fail_closed.py`, + foreground. + +### Dependencies & Criticality + +- **Depends on:** Step 1 +- **Is Bottleneck:** YES + +### Safety & Constraint Considerations + +- **Relevant rules:** fail-closed calibration (`calibration_self_check.py` precedent); ledgers read-only here. +- **Potential failure modes for this step:** the raise ends up inside the broad `except` and is swallowed; an existing + fixture plan has a stale ev_pred and now fails. +- **Guardrails and early‑abort checks:** test (a) asserts propagation; a broad pre-change run of calibration tests + (Step 1) identifies fixtures with mismatching EV (A1 found only one). + +### Success & Discard Criteria + +- **Success:** Mismatch raises and leaves no report; matching plans calibrate byte-identically. +- **Discard:** More than one out-of-scope test depends on warning-only behaviour (A1 falsified): park and re-scope. + +### Metrics + +| metric | value | +| ------------------- | ----- | +| p_success_pred | 0.94 | +| entropy_pred | 1.2 | +| impact_pred | 20.0 | +| cost_pred | 2.0 | +| learning_value_pred | 0.6 | +| ev_pred | 16.7 | + +### Step Metrics Rationale + +`EV = 0.94 * 20.0 + 0.5 * 0.6 - 0.3 * 1.2 - 2.0 = 18.8 + 0.3 - 0.36 - 2.0 = 16.74`. A1 was measured, so the risk is +mainly the try/except placement, which test (a) pins. + +--- + +## Step 5: Write one computed EV to the plan markdown and plans row in Stage 2 + +- **Sub‑intent recommendation:** NO +- **Reasoning:** New focused module plus a few lines in planner.py; the riskiest step (number format, Prettier, module + budget) but small and fully testable without an agent. +- **Step Type:** IMPLEMENTATION +- **Exploration level:** EXPLOIT + +### Intent & Git Integration + +- **Step Intent:** Make Stage 2 write a single rounded EV to both plan sources and fail the attempt when the re-read + values differ. +- **Git branch:** same execution branch +- **Sub‑intent:** NONE + +### Implementation Details (No code blocks, only logic/steps) + +1. New `src/sandbox_executor/plan_ev_sync.py` (target under 120 lines, no docstrings): + - `rounded_plan_ev(p_success, impact, learning_value, entropy, cost, ev_lambda, ev_mu) -> float`: the existing + formula rounded once with `round(value, 4)`. + - `ev_cell_text(ev) -> str`: `repr(ev)` (identical to `json.dumps` of the float, so `7.0` stays `7.0`). + - `write_plan_ev(plan_md_path, ev)`: within the `## Overall Plan Metrics` section (stop at the next `## ` heading), + replace the value cell of an existing `ev_pred` row, or insert a `| ev_pred | |` row after the last metric + row of that table when absent; leave text outside the table untouched; return whether the file changed. + - `class PlanEvSyncError(RuntimeError)` and `check_plan_ev(plan_md_path, plans_ledger_path, plan_id, intent_branch)`: + re-read the markdown value with `calibration_predicted.overall_plan_metrics` (the Stage 5 reader, so both stages + parse identically) and the last plans.jsonl row for the plan, raise `PlanEvSyncError` naming both values when + either is missing or `abs(a - b) > MISMATCH_TOLERANCE` (reuse the 0.01 constant from `calibration_predicted`). +2. `entrypoint/planner.py`: + - replace the inline formula with `ev = rounded_plan_ev(...)`; use `ev` for `metrics["ev"]` and `plan_entry["ev"]`. + - call `write_plan_ev(plan_md_path, ev)` immediately before `converge_prettier`. + - after the plans.jsonl append and `validate_ledger_file_unique_ids`, call `check_plan_ev(...)`; on + `PlanEvSyncError`, call `_fail_plan_attempt(repo_dir, plan_md_rel, str(error))` (before `git add`/commit, so + nothing is committed). + - net growth at most about 10 lines; confirm with `wc -l` (must stay at or below 655). + - ordering note: `_plan_decision_fields` parses the committed (formatted) file, so it sees the synced value. +3. `tests/test_plan_ev_sync.py` (new): + - agent-written ev_pred differing from the computed EV is rewritten; a plan without an ev_pred row gets one; a plan + whose value already matches is unchanged byte-for-byte. + - after `converge_prettier` (or `format_plan_artifact` with Prettier skipped when unavailable, mirroring existing + planner tests), the markdown value parsed by `overall_plan_metrics` equals the plans row `ev` (Stage 2 equality). + - `check_plan_ev` raises on a tampered markdown or row and passes when equal; the planner path calls + `_fail_plan_attempt` (drive `planner.main` with the same stubbed runner the existing planner tests use, or + monkeypatch `check_plan_ev` to raise, and assert `SystemExit` plus the failure detail file and no plans row + commit). + - `7.0` is written as `7.0`. +4. `tests/test_planner_plan_fence_format.py`: change only if the byte comparison needs its expected EV text aligned; by + design it should pass unchanged (A12). +5. Run + `uv run pytest tests/test_plan_ev_sync.py tests/test_planner.py tests/test_planner_plan_fence_format.py tests/test_planner_integration.py tests/test_planner_touch_set.py tests/test_artefacts.py tests/flow/stages/test_plan_support.py`, + then `python scripts/check_module_budgets.py`, foreground. + +### Dependencies & Criticality + +- **Depends on:** Step 1 +- **Is Bottleneck:** YES + +### Safety & Constraint Considerations + +- **Relevant rules:** module budget freeze (planner.py 655); append-only plans ledger (the check only reads); no new + imports from entrypoints into the host flow engine (the new module is imported by the entrypoint, not the other way). +- **Potential failure modes for this step:** Prettier rewrites the number (it does not reformat numbers, only pads + cells, A11); `repr` of a rounded float such as `42.1235` vs JSON identical (both use shortest repr); the inserted row + breaks table alignment until Prettier runs (accepted, Prettier re-aligns); planner exceeds 655 lines. +- **Guardrails and early‑abort checks:** module budget check after editing; equality test after formatting; abort if + planner.py needs more than 15 extra lines (move more into the new module instead). + +### Success & Discard Criteria + +- **Success:** Both stored EV values equal after formatting in tests; mismatch fails the attempt; existing planner tests + pass unchanged; planner.py at or below 655 lines. +- **Discard:** `test_planner.py` would need a change (out of scope): re-design the number form rather than editing it. + +### Metrics + +| metric | value | +| ------------------- | ----- | +| p_success_pred | 0.92 | +| entropy_pred | 1.6 | +| impact_pred | 22.0 | +| cost_pred | 2.5 | +| learning_value_pred | 1.2 | +| ev_pred | 17.3 | + +### Step Metrics Rationale + +`EV = 0.92 * 22.0 + 0.5 * 1.2 - 0.3 * 1.6 - 2.5 = 20.24 + 0.6 - 0.48 - 2.5 = 17.86` (rounded down to 17.3 for the +Prettier interaction risk). Highest entropy because it changes Stage 2 output for every future plan. + +--- + +## Step 6: Update ACT-CAL and cross-check wording in docs/ledger_schema.md + +- **Sub‑intent recommendation:** NO +- **Reasoning:** Documentation only; small. +- **Step Type:** DOCUMENTATION +- **Exploration level:** EXPLOIT + +### Intent & Git Integration + +- **Step Intent:** Keep the ledger schema doc truthful about the new keys and the fail-closed EV check. +- **Git branch:** same execution branch +- **Sub‑intent:** NONE + +### Implementation Details (No code blocks, only logic/steps) + +1. In the ACT-CAL section list `calibration_agent`, `calibration_model` (the evaluator that ran Stage 5; the execution + row attribution for standalone `holon calibrate`) and `plan_agent`, `plan_model` (from the selected plans row). +2. In the predicted-metrics cross-check wording, state that an `ev` difference above 0.01 between the plans row and the + plan file's Overall Plan Metrics fails Stage 5 with no report, other fields and the execution summary stay advisory + warnings, and Stage 2 writes the same rounded EV to both. +3. Run `npx prettier --check docs/ledger_schema.md` via the repository lint task in Step 7 (self-explaining markdown + gate applies). + +### Dependencies & Criticality + +- **Depends on:** Steps 2, 4, 5 +- **Is Bottleneck:** NO + +### Safety & Constraint Considerations + +- **Relevant rules:** self-explaining markdown gate; Australian spelling convention in docs. +- **Potential failure modes for this step:** Prettier reflow failure in the docs check. +- **Guardrails and early‑abort checks:** formatter run in Step 7. + +### Success & Discard Criteria + +- **Success:** Doc names all four keys and the fail-closed rule; lint passes. +- **Discard:** N/A (cheap to redo). + +### Metrics + +| metric | value | +| ------------------- | ----- | +| p_success_pred | 0.98 | +| entropy_pred | 0.3 | +| impact_pred | 4.0 | +| cost_pred | 0.5 | +| learning_value_pred | 0.2 | +| ev_pred | 3.4 | + +### Step Metrics Rationale + +`EV = 0.98 * 4.0 + 0.5 * 0.2 - 0.3 * 0.3 - 0.5 = 3.92 + 0.1 - 0.09 - 0.5 = 3.43`. + +--- + +## Step 7: Run lint, module budgets and the full suite once + +- **Sub‑intent recommendation:** NO +- **Reasoning:** Final gate required by the acceptance criteria; no repetition needed (no timing target). +- **Step Type:** TEST +- **Exploration level:** EXPLOIT + +### Intent & Git Integration + +- **Step Intent:** Prove the whole change passes `uv run task lint` and the full test suite with every module in budget. +- **Git branch:** same execution branch +- **Sub‑intent:** NONE + +### Implementation Details (No code blocks, only logic/steps) + +1. `uv run task lint` in the foreground (ruff, complexity limits, `check_module_budgets.py`, `check_self_explaining.py`, + Prettier); fix findings in touched files only. +2. `uv run task test` once in the foreground; compare failures with the Step 1 baseline and A13 (known unrelated stress + canaries / Docker bind-mount integration test are reported, not "fixed" out of scope). +3. `git diff --name-only origin/main...HEAD` must be a subset of the touch set; + `holon-config/hygiene/module_budgets.json` absent from the diff. +4. `git diff` review for added docstrings or comments other than `# why:`. + +### Dependencies & Criticality + +- **Depends on:** Steps 2 to 6 +- **Is Bottleneck:** YES + +### Safety & Constraint Considerations + +- **Relevant rules:** test-run discipline (foreground, full suite once); module budget freeze; intent scope check. +- **Potential failure modes for this step:** an out-of-scope test reads ACT-CAL keys exactly or the plan EV (A13 + falsified); ruff complexity on `generate_calibration` (already long) after adding parameters. +- **Guardrails and early‑abort checks:** keep `generate_calibration` additions to helper calls; park and re-scope if an + out-of-scope file must change. + +### Success & Discard Criteria + +- **Success:** Lint clean; full suite passes except failures already present in the baseline and unrelated to + calibration; diff confined to the touch set. +- **Discard:** An out-of-scope file must change: stop and re-scope the intent. + +### Metrics + +| metric | value | +| ------------------- | ----- | +| p_success_pred | 0.9 | +| entropy_pred | 1.2 | +| impact_pred | 10.0 | +| cost_pred | 2.0 | +| learning_value_pred | 0.6 | +| ev_pred | 6.9 | + +### Step Metrics Rationale + +`EV = 0.9 * 10.0 + 0.5 * 0.6 - 0.3 * 1.2 - 2.0 = 9.0 + 0.3 - 0.36 - 2.0 = 6.94`. Probability limited by full-suite +surprises outside the measured scope. + +--- diff --git a/plans/I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5_calibration.md b/plans/I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5_calibration.md new file mode 100644 index 000000000..958d2654a --- /dev/null +++ b/plans/I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5_calibration.md @@ -0,0 +1,115 @@ +# Plan Calibration Report: P-1796100517-CLA-CO5.5 + +- **Plan Reference:** + [`plans/I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5.md`](P-1796100517-CLA-CO5.5.md) +- **Execution ID:** `E-1796100754-CLA-CO5.5` +- **Execution Branch:** `I-1796100493-stage5-evaluator-plan-ev-sync/P-1796100517-CLA-CO5.5/E-1796100754-CLA-CO5.5/_` +- **Intent Branch:** `I-1796100493-stage5-evaluator-plan-ev-sync/_` +- **Evaluating Agent:** `claude-agent/claude-opus-5-5` +- **Evaluation Timestamp:** `2026-12-01T07:08:17.000Z` +- **Evaluated Commit SHA:** `86ff48e1793b29f49bdcc8cb2090f6bd5c51f357` +- **Base SHA:** `3e9960ade4064cc474cafa614500ee51b00a085b` +- **Merge-Base SHA:** `3e9960ade4064cc474cafa614500ee51b00a085b` +- **Merged Commits:** `2` +- **Patch Size Base:** `target_merge_base` (merge-base `3e9960ade4064cc474cafa614500ee51b00a085b` with the target + branch) + +--- + +## 1. Executive Calibration Summary + +| Metric | Predicted (`pred`) | Actual (`actual`) | Absolute Error (`abs(pred - actual)`) | Accuracy Rating | Bias Direction | +| :------------------------------------------------- | :----------------- | :---------------- | :------------------------------------ | :-------------- | :------------------------- | +| **$P(\text{success})$** | `0.80` | `1.00` | `0.20` | Moderate | Slight Underconfidence | +| **Entropy ($\Delta S$)** | `7.00` | `2.20` | `4.80` | Moderate | Overestimated Risk | +| **Impact** | `70.00` | `70.00` | `0.00` | Exact | Perfectly Calibrated | +| **Cost** | `12.00` | `10.20` | `1.80` | Moderate | Conservative Cost Estimate | +| **Learning Value** | `4.00` | `4.00` | `0.00` | Exact | Perfectly Calibrated | +| **Expected Value — Clean (without bugs)** | `43.90` | `61.14` | `17.24` | Moderate | Conservative Underestimate | +| **Expected Value — Observed (with bugs included)** | `43.90` | `61.14` | `17.24` | Moderate | Conservative Underestimate | +| **Bug EV Drag** | `0.00` | `0.00` | `0.00` | - | Drag Penalty | + +--- + +## 2. Mathematical Derivations & Calibration Errors + +- **Success Probability Error:** $|0.80 - 1.00| = 0.20$ +- **Entropy Error:** $|7.00 - 2.20| = 4.80$ +- **Impact Error:** $|70.00 - 70.00| = 0.00$ +- **Cost Error:** $|12.00 - 10.20| = 1.80$ +- **Learning Value Error:** $|4.00 - 4.00| = 0.00$ +- **Expected Value Realization:** + $$EV_{\text{pred}} = 0.80 \times 70.0 + 0.5 \times 4.0 - 0.3 \times 7.00 - 12.00 = 43.90$$ + $$EV_{\text{actual}} = EV_{\text{clean}} = 1.00 \times 70.0 + 0.5 \times 4.0 - 0.3 \times 2.20 - 10.20 = 61.14$$ + $$EV_{\text{with\_bugs}} = 1.00 \times 70.0 + 0.5 \times 4.0 - 0.3 \times 2.20 - 10.20 = 61.14$$ + $$\text{Bug EV Drag} = round(EV_{\text{clean}} - EV_{\text{with\_bugs}}, 2) = 0.00$$ $$\Delta EV = +17.24$$ + +--- + +## 3. Entropy Factor Breakdown + +- **State Surface Area (SSA):** Predicted `0.6` vs Observed `7.2` (19 files modified). +- **Irreversibility (IRR):** Predicted `0.0` vs Observed `0.0` (Zero destructive or stateful changes). +- **Conflict Likelihood (CL):** Predicted `0.1` vs Observed `0.0` (Clean sequential branch merges). +- **Sandbox Escape Risk (SER):** Predicted `0.0` vs Observed `0.0` (Zero security exceptions). +- **Novelty (NOV):** Predicted `0.4` vs Observed `0.4` (Standard calibration reporting schema). + +--- + +## 4. Calibration Assessment + +Plan `P-1796100517-CLA-CO5.5` executed with minimal error ($p\_success\_error = 0.20$, $cost\_error = 1.80$). The +calibration step successfully completed the execution lifecycle and delivered verified post-execution analysis. + +--- + +## 5. Touch Set Accuracy + +- **Precision (declared entries the diff touched):** `59.4%` +- **Recall (changed files the touch set covered):** `100.0%` + +Changed files outside the touch set: + +- none + +Declared entries the diff did not touch: + +- `apps/sandbox-executor/src/sandbox_executor/calibration/predicted.py` +- `apps/sandbox-executor/src/sandbox_executor/cli/commands/calibrate.py` +- `apps/sandbox-executor/tests/test_calibration_regression_merge_main.py` +- `apps/sandbox-executor/tests/flow/stages/test_calibrate.py` +- `apps/sandbox-executor/tests/test_calibrate_full_stage5.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_ledger_merged_parity.py` +- `apps/sandbox-executor/tests/test_planner_plan_fence_format.py` +- `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` +- `apps/sandbox-executor/tests/test_calibration_metrics.py` + +--- + +## 6. Review Churn + +- **Full reviews:** `1` +- **Scoped reviews:** `1` +- **Approval carry-overs:** `1` +- **Pipeline runs:** `2` +- **Pipeline reruns:** `0` +- **Non-defect churn (target merge):** `1` +- **Non-defect churn (bookkeeping):** `0` +- **Non-defect churn (CI noise):** `0` + +--- + +## 7. Self-Explaining Code Counts + +Against the merge base with origin/main: added 0 docstring(s), added 0 comment(s), removed 0 docstring(s) and removed 0 +comment(s) across 26 changed file(s). + +- Changed files checked: 26 +- Added docstrings: 0 +- Added comments (not '# why:'): 0 +- Removed docstrings: 0 +- Removed comments (not '# why:'): 0