From 201e72ea5d570a61323591d15558e7debd548805 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Tue, 1 Dec 2026 00:39:07 +0000 Subject: [PATCH 1/4] fix(repo): repo run exits 3 when the batch budget is the only reason cells were not started (#1372) `repo run --max-usd` counted the cells its batch budget left unstarted in `budget_stopped` and kept the finished cells' results, but `_exit_of_batch` exited 1 for it, while the exit-code table gives exit 3 to a run that stopped short on a budget and kept its partial output. `_exit_of_batch` now orders the reasons: a cell that crashed of the machinery is 5, then an error or a failed probe is 1, then a budget stop alone is 3 (`EXIT_INCONCLUSIVE`). A batch with a budget stop and an error exits 1: a defect outranks an inconclusive result. The no-result case stays 1. The quickstart exit-code table, the text after it and the repo evaluation contract say so, and `test_timed_out_cell_counts_toward_batch_budget` pins 3. New `tests/test_repo_run_batch_exit.py` covers the order from summaries. Signed-off-by: Anton Volkov --- ...1201_120000_repo-run-budget-stop-exit-3.md | 8 ++++ dokimi/docs/quickstart.md | 7 ++-- dokimi/docs/repo-evaluation-contract.md | 5 ++- dokimi/dokimi/commands/repo_run.py | 11 ++++-- dokimi/tests/test_repo_run.py | 2 +- dokimi/tests/test_repo_run_batch_exit.py | 38 +++++++++++++++++++ 6 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 dokimi/changelog.d/20261201_120000_repo-run-budget-stop-exit-3.md create mode 100644 dokimi/tests/test_repo_run_batch_exit.py diff --git a/dokimi/changelog.d/20261201_120000_repo-run-budget-stop-exit-3.md b/dokimi/changelog.d/20261201_120000_repo-run-budget-stop-exit-3.md new file mode 100644 index 000000000..f8e0374c7 --- /dev/null +++ b/dokimi/changelog.d/20261201_120000_repo-run-budget-stop-exit-3.md @@ -0,0 +1,8 @@ + + +### Fixed + +- **`repo run --max-usd` exits 3 (inconclusive) when the batch budget is the only reason a cell was not started** — the finished cells keep their `result.json`, as the other spend-capped commands keep a partial output; it exited 1. A batch with a budget stop and also an error or a failed probe still exits 1, and a cell that crashed of the machinery still exits 5. diff --git a/dokimi/docs/quickstart.md b/dokimi/docs/quickstart.md index 1e5a7b98a..8c4506c2b 100644 --- a/dokimi/docs/quickstart.md +++ b/dokimi/docs/quickstart.md @@ -262,7 +262,7 @@ failed check. | 0 | The command ran and, if it checks something, the check passed. | | | 1 | A verdict or a gate that ran and failed, or a runtime failure the command reports (a model call, a run, a clone or fetch); a crash that escapes is 5. `eval judge validate --strict` and `eval leak`/`eval redteam` that fail as blocked. | `baseline compare --max-context-drop 0` over a regression, `repo reach` with a harness binary that cannot run, `eval triggers generate --fail-on warn` over a lint finding | | 2 | A bad invocation: a missing, unreadable or malformed input file, a configuration the agent's CLI rejects (`repo run --tools all` with a `.mcp.json` the CLI does not accept: refused before any cell runs), a device given as one (` : not a file`), a flag combination the command refuses, an output file that cannot be written, a missing provider credential, a source string that is malformed, unpinned or not a repository root. | `baseline save` on a bad eval file, `evaluate --questions` on an empty or non-JSON file (`--questions : `), `benchmark preflight` with no golden set, `repo scan --manifest ../x.yaml` | -| 3 | Inconclusive: the run stopped short because a budget ran out (`--max-usd`, or a call with no price) and kept the partial output (`tools preference`, `skill novelty atoms`, `probe` and `analyze`, `skill routing` and `catalog routing`; a stop on a permanent provider error exits 1; `eval personas discover` refuses its one call before it runs, so nothing is written; other spend-capped commands such as `repo run` and `repo hits judge` still exit 1 on a budget stop), or the result is undecided (`eval judge validate`: a pass whose interval straddles the gate, or a variant no pair was built for, with `--strict` making it 1; `eval leak`: an item that could not be checked, or none could; `eval redteam`: a graded question not measured, or nothing graded; `eval judge agreement --strict`: an arm NOT MEASURED, or no arm to compare; `repo security --fail-on`: an unfinished cell or an arm with no measured cell, when no arm failed and every model has a baseline cell). | `tools preference --max-usd 5` with calls not run; `eval judge validate` with too few bases | +| 3 | Inconclusive: the run stopped short because a budget ran out (`--max-usd`, or a call with no price) and kept the partial output (`tools preference`, `skill novelty atoms`, `probe` and `analyze`, `skill routing` and `catalog routing`, and `repo run` when the batch budget is the only reason a cell was not started: a batch with a crashed cell or a failed probe too exits 1; a stop on a permanent provider error exits 1; `eval personas discover` refuses its one call before it runs, so nothing is written; other spend-capped commands such as `repo hits judge` still exit 1 on a budget stop), or the result is undecided (`eval judge validate`: a pass whose interval straddles the gate, or a variant no pair was built for, with `--strict` making it 1; `eval leak`: an item that could not be checked, or none could; `eval redteam`: a graded question not measured, or nothing graded; `eval judge agreement --strict`: an arm NOT MEASURED, or no arm to compare; `repo security --fail-on`: an unfinished cell or an arm with no measured cell, when no arm failed and every model has a baseline cell). | `tools preference --max-usd 5` with calls not run; `eval judge validate` with too few bases | | 4 | Invalid: the result is not comparable or not trustworthy: a model that differs from the baseline's, or one that cannot be verified, under `baseline compare --strict` or the regression gate (`--max-context-drop` or `--max-lift-drop`); under `repo security --fail-on`, a model with no baseline cell when no arm failed; under `eval judge agreement --strict`, an arm JUDGE-DEPENDENT. | `baseline compare --strict` over a baseline scored with another judge | | 5 | Infrastructure failure: a crash (an uncaught exception) in any command, with its traceback on stderr. For a command that emits the cli_output document, `--json` prints its `infra` document on stdout first. Also a `repo run` cell that crashes (a harness that exits nonzero before its first trace line, unless the cap killed it, a docker daemon or CLI failure that stops the agent, a scratch directory that vanished): the batch keeps the other cells and exits 5. | `backends --json` when `detect` raises; `repo run` with the docker daemon down | @@ -273,8 +273,9 @@ but still exit 1 for other input refusals (a missing or malformed manifest, a ba a `.mcp.json` the CLI rejects under `--tools all` is exit 2 before any cell; a `--manifest` path that leaves the source tree as typed is exit 2, pinned or not, as a source refusal; a link in the tree that leads out of it is exit 1), and `tools preference` exits 1 when every call failed and 3 when `--max-usd` -or an unpriced model stopped it short, and `eval personas discover` exits 3 when its `--max-usd` refuses the one call. `repo run --max-usd`, -`repo hits judge --max-usd` still exit 1 when the budget or an unpriced call stops them. +or an unpriced model stopped it short, and `eval personas discover` exits 3 when its `--max-usd` refuses the one call. `repo run --max-usd` exits 3 when the batch budget stops cells and nothing else went wrong +(with a crashed cell or a failed probe too it exits 1), and +`repo hits judge --max-usd` still exits 1 when the budget or an unpriced call stops it. `skill novelty atoms`, `probe` and `analyze` and `skill routing` and `catalog routing` exit 3 when the budget or an unpriced call stops them and they keep a partial file, and 1 when they keep nothing (`skill shorten`, and a stop that leaves no partial file: "nothing was written") or a permanent provider error diff --git a/dokimi/docs/repo-evaluation-contract.md b/dokimi/docs/repo-evaluation-contract.md index ab24e4183..e0271856e 100644 --- a/dokimi/docs/repo-evaluation-contract.md +++ b/dokimi/docs/repo-evaluation-contract.md @@ -2617,7 +2617,10 @@ python cli.py repo compare repo-runs/authoring --baseline guidance:none --metric then the CLI's process group is killed, the container is killed by name, and the cell is still graded. `--max-usd` starts no new cell once the batch has spent that much, earlier invocations included (kept in - `_eval/spend.json`), counting the budget of each cell in flight. + `_eval/spend.json`), counting the budget of each cell in flight. When the + batch budget is the only reason a cell was not started, the finished cells + keep their `result.json` and the command exits 3 (inconclusive); with a crashed + cell or a failed probe too it exits 1 (5 for a cell that crashed of the machinery). - Every container runs with `--security-opt no-new-privileges`, `--cap-drop ALL` and a `--pids-limit`, as the caller's uid and gid. - `--agent-network` is required while the egress proxy is missing: it gives the diff --git a/dokimi/dokimi/commands/repo_run.py b/dokimi/dokimi/commands/repo_run.py index dd7ba924c..eb1035f96 100644 --- a/dokimi/dokimi/commands/repo_run.py +++ b/dokimi/dokimi/commands/repo_run.py @@ -22,7 +22,7 @@ from dokimi.atomic_write import write_text_atomic from dokimi import cli_flags from dokimi import docker_cmd -from dokimi.exit_codes import EXIT_INFRA +from dokimi.exit_codes import EXIT_INCONCLUSIVE, EXIT_INFRA from dokimi.repos.harness_profile import DELEGATION_MODES from dokimi.repos.source import SourceArgumentError, tree_path from dokimi.utils import tree_digest @@ -500,12 +500,15 @@ def _refuse_before_any_cell(ctx, tasks, option) -> None: def _exit_of_batch(summary: dict) -> None: - """A cell that crashed of the machinery is infrastructure (exit 5, §2.6), never a verdict; a refused cell, a budget - stop, a failed probe or a batch with no result is exit 1.""" + """A cell that crashed of the machinery is infrastructure (exit 5, §2.6), never a verdict; a refused cell, a failed + probe or a batch with no result is exit 1. A budget stop alone is inconclusive (exit 3: the finished cells keep + their results); with an error or a failed probe too it is exit 1, a defect outranks an inconclusive result.""" if any(err.get("infra") for err in summary["errors"]): sys.exit(EXIT_INFRA) - if summary["errors"] or summary["budget_stopped"] or summary["probe_failed"]: + if summary["errors"] or summary["probe_failed"]: sys.exit(1) + if summary["budget_stopped"]: + sys.exit(EXIT_INCONCLUSIVE) if not summary["ran"] and not summary["skipped"]: # every cell unsupported: the batch holds no result print(f"✗ incomplete: no cell has a result ({summary['cells']} cells, {summary['unsupported']} unsupported)", file=sys.stderr) diff --git a/dokimi/tests/test_repo_run.py b/dokimi/tests/test_repo_run.py index 87f2d184f..7235849a6 100644 --- a/dokimi/tests/test_repo_run.py +++ b/dokimi/tests/test_repo_run.py @@ -503,7 +503,7 @@ def test_timed_out_cell_counts_toward_batch_budget(setup, monkeypatch, capsys): with pytest.raises(SystemExit) as exc: _run(setup, "--arm", "guidance:raw", "--task", "fix_add", "--reps", "2", "--timeout", "2", "--max-usd-per-cell", "0.5", "--max-usd", "0.01") - assert exc.value.code == 1 + assert exc.value.code == 3 assert "1 ran" in (out := capsys.readouterr().out) and "1 not started (batch budget), 0 unsupported; $0.5000" in out rec = json.loads((setup["out"] / "b1/fix_add__guidance-raw__m-1__r1/result.json").read_text()) assert rec["agent"]["cost_usd"] is None and rec["agent"]["charged_usd"] == 0.5 diff --git a/dokimi/tests/test_repo_run_batch_exit.py b/dokimi/tests/test_repo_run_batch_exit.py new file mode 100644 index 000000000..ba42e1fd6 --- /dev/null +++ b/dokimi/tests/test_repo_run_batch_exit.py @@ -0,0 +1,38 @@ +# Copyright (C) 2026 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +"""The exit code of a `repo run` batch, from its summary (docs/quickstart.md, exit-code table rows 1, 3 and 5).""" + +from __future__ import annotations + +import pytest + +from dokimi.commands.repo_run import _exit_of_batch + + +def _summary(**over): + base = {"ran": 1, "skipped": 0, "errors": [], "budget_stopped": 0, "probe_failed": [], "unsupported": 0, "cells": 2} + return {**base, **over} + + +def _code(summary) -> int | None: + try: + _exit_of_batch(summary) + except SystemExit as exc: + return exc.code + return None + + +@pytest.mark.parametrize(("over", "code"), [ + ({}, None), + ({"budget_stopped": 1}, 3), # the finished cells keep their results: inconclusive + ({"budget_stopped": 1, "errors": [{"infra": False}]}, 1), # a defect outranks an inconclusive result + ({"budget_stopped": 1, "probe_failed": ["t1"]}, 1), + ({"budget_stopped": 1, "errors": [{"infra": True}]}, 5), # an infrastructure crash outranks both + ({"budget_stopped": 1, "errors": [{"infra": False}, {"infra": True}]}, 5), + ({"errors": [{"infra": False}]}, 1), + ({"probe_failed": ["t1"]}, 1), + ({"ran": 0, "unsupported": 2}, 1), # no cell has a result +]) +def test_exit_of_a_batch(over, code): + assert _code(_summary(**over)) == code From fe97824f764b2a488b06f1bd3bc0a612e794b7eb Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Tue, 1 Dec 2026 00:40:09 +0000 Subject: [PATCH 2/4] fix(repo): repo hits judge exits 3 when --max-usd or an unpriced call stops it (#1373) `repo hits judge --max-usd` stopped by the cap or by a call with no price writes the cells it judged and emits status `budget_stopped`, but exited 1, while the exit-code table gives exit 3 to a run that stopped short on a budget and kept its partial output. A `done.stopped` run now exits 3 (`EXIT_INCONCLUSIVE`); a failed judge call (`JudgeFailing`, an input or infrastructure error) keeps its exit code. The quickstart exit-code table, the text after it and the repo evaluation contract say so, and the four tests that pinned exit 1 on a budget stop pin 3. Signed-off-by: Anton Volkov --- .../20261201_120100_repo-hits-judge-budget-stop-exit-3.md | 8 ++++++++ dokimi/docs/quickstart.md | 4 ++-- dokimi/docs/repo-evaluation-contract.md | 4 ++-- dokimi/dokimi/commands/repo_hits.py | 6 +++--- dokimi/tests/test_repo_hits_judge.py | 6 +++--- dokimi/tests/test_repo_hits_judge_cost.py | 2 +- 6 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 dokimi/changelog.d/20261201_120100_repo-hits-judge-budget-stop-exit-3.md diff --git a/dokimi/changelog.d/20261201_120100_repo-hits-judge-budget-stop-exit-3.md b/dokimi/changelog.d/20261201_120100_repo-hits-judge-budget-stop-exit-3.md new file mode 100644 index 000000000..d9511c6e2 --- /dev/null +++ b/dokimi/changelog.d/20261201_120100_repo-hits-judge-budget-stop-exit-3.md @@ -0,0 +1,8 @@ + + +### Fixed + +- **`repo hits judge --max-usd` exits 3 (inconclusive) when the cap or a call with no price stops it** — the cells judged before the stop keep their `hits_judged.json` and `--json` prints status `budget_stopped`, as before; the exit was 1. A failed judge call still exits 1. diff --git a/dokimi/docs/quickstart.md b/dokimi/docs/quickstart.md index 8c4506c2b..f9e7627df 100644 --- a/dokimi/docs/quickstart.md +++ b/dokimi/docs/quickstart.md @@ -262,7 +262,7 @@ failed check. | 0 | The command ran and, if it checks something, the check passed. | | | 1 | A verdict or a gate that ran and failed, or a runtime failure the command reports (a model call, a run, a clone or fetch); a crash that escapes is 5. `eval judge validate --strict` and `eval leak`/`eval redteam` that fail as blocked. | `baseline compare --max-context-drop 0` over a regression, `repo reach` with a harness binary that cannot run, `eval triggers generate --fail-on warn` over a lint finding | | 2 | A bad invocation: a missing, unreadable or malformed input file, a configuration the agent's CLI rejects (`repo run --tools all` with a `.mcp.json` the CLI does not accept: refused before any cell runs), a device given as one (` : not a file`), a flag combination the command refuses, an output file that cannot be written, a missing provider credential, a source string that is malformed, unpinned or not a repository root. | `baseline save` on a bad eval file, `evaluate --questions` on an empty or non-JSON file (`--questions : `), `benchmark preflight` with no golden set, `repo scan --manifest ../x.yaml` | -| 3 | Inconclusive: the run stopped short because a budget ran out (`--max-usd`, or a call with no price) and kept the partial output (`tools preference`, `skill novelty atoms`, `probe` and `analyze`, `skill routing` and `catalog routing`, and `repo run` when the batch budget is the only reason a cell was not started: a batch with a crashed cell or a failed probe too exits 1; a stop on a permanent provider error exits 1; `eval personas discover` refuses its one call before it runs, so nothing is written; other spend-capped commands such as `repo hits judge` still exit 1 on a budget stop), or the result is undecided (`eval judge validate`: a pass whose interval straddles the gate, or a variant no pair was built for, with `--strict` making it 1; `eval leak`: an item that could not be checked, or none could; `eval redteam`: a graded question not measured, or nothing graded; `eval judge agreement --strict`: an arm NOT MEASURED, or no arm to compare; `repo security --fail-on`: an unfinished cell or an arm with no measured cell, when no arm failed and every model has a baseline cell). | `tools preference --max-usd 5` with calls not run; `eval judge validate` with too few bases | +| 3 | Inconclusive: the run stopped short because a budget ran out (`--max-usd`, or a call with no price) and kept the partial output (`tools preference`, `skill novelty atoms`, `probe` and `analyze`, `skill routing` and `catalog routing`, `repo run` when the batch budget is the only reason a cell was not started (a batch with a crashed cell or a failed probe too exits 1), and `repo hits judge`; a stop on a permanent provider error or a failed judge call exits 1; `eval personas discover` refuses its one call before it runs, so nothing is written), or the result is undecided (`eval judge validate`: a pass whose interval straddles the gate, or a variant no pair was built for, with `--strict` making it 1; `eval leak`: an item that could not be checked, or none could; `eval redteam`: a graded question not measured, or nothing graded; `eval judge agreement --strict`: an arm NOT MEASURED, or no arm to compare; `repo security --fail-on`: an unfinished cell or an arm with no measured cell, when no arm failed and every model has a baseline cell). | `tools preference --max-usd 5` with calls not run; `eval judge validate` with too few bases | | 4 | Invalid: the result is not comparable or not trustworthy: a model that differs from the baseline's, or one that cannot be verified, under `baseline compare --strict` or the regression gate (`--max-context-drop` or `--max-lift-drop`); under `repo security --fail-on`, a model with no baseline cell when no arm failed; under `eval judge agreement --strict`, an arm JUDGE-DEPENDENT. | `baseline compare --strict` over a baseline scored with another judge | | 5 | Infrastructure failure: a crash (an uncaught exception) in any command, with its traceback on stderr. For a command that emits the cli_output document, `--json` prints its `infra` document on stdout first. Also a `repo run` cell that crashes (a harness that exits nonzero before its first trace line, unless the cap killed it, a docker daemon or CLI failure that stops the agent, a scratch directory that vanished): the batch keeps the other cells and exits 5. | `backends --json` when `detect` raises; `repo run` with the docker daemon down | @@ -275,7 +275,7 @@ a `--manifest` path that leaves the source tree as typed is exit 2, pinned or no `tools preference` exits 1 when every call failed and 3 when `--max-usd` or an unpriced model stopped it short, and `eval personas discover` exits 3 when its `--max-usd` refuses the one call. `repo run --max-usd` exits 3 when the batch budget stops cells and nothing else went wrong (with a crashed cell or a failed probe too it exits 1), and -`repo hits judge --max-usd` still exits 1 when the budget or an unpriced call stops it. +`repo hits judge --max-usd` exits 3 when the budget or an unpriced call stops it, and 1 when a judge call failed. `skill novelty atoms`, `probe` and `analyze` and `skill routing` and `catalog routing` exit 3 when the budget or an unpriced call stops them and they keep a partial file, and 1 when they keep nothing (`skill shorten`, and a stop that leaves no partial file: "nothing was written") or a permanent provider error diff --git a/dokimi/docs/repo-evaluation-contract.md b/dokimi/docs/repo-evaluation-contract.md index e0271856e..c63cfbe24 100644 --- a/dokimi/docs/repo-evaluation-contract.md +++ b/dokimi/docs/repo-evaluation-contract.md @@ -2715,14 +2715,14 @@ python cli.py repo compare repo-runs/authoring --baseline guidance:none --metric call. `--dry-run` writes nothing and takes no lock. `--max-usd X` starts no new call once X is spent: a cell not fully judged gets no `hits_judged.json` (one an earlier run wrote is removed), and the - command exits 1. After a live judge reply with no known price, such a run + command exits 3 (inconclusive; the cells judged keep their files). After a live judge reply with no known price, such a run starts no further live call, as `novelty`'s spend cap does: the cap cannot be enforced on spend it cannot see. That reply still labels its pair when it parses (a redraw would be a further call), and pairs replayed from the response cache still finish; when pairs are left, the cells they are in get no file, the line naming those cells says why (`--json`, under `data`: `budget_stop`; drop `--max-usd` to run - unmetered), and the command exits 1. When none is left, the run ends as + unmetered), and the command exits 3. When none is left, the run ends as one with no cap does (exit 0, `budget_stop` null). Without `--max-usd` an unpriced call counts as 0, and the spend line says how many calls had no price and that the spend is not known (`--json`, under `data`: diff --git a/dokimi/dokimi/commands/repo_hits.py b/dokimi/dokimi/commands/repo_hits.py index c8fab7629..581fdacd7 100644 --- a/dokimi/dokimi/commands/repo_hits.py +++ b/dokimi/dokimi/commands/repo_hits.py @@ -16,7 +16,7 @@ from pathlib import Path from typing import Any, Callable, NoReturn -from dokimi.exit_codes import EXIT_FAILURE, EXIT_USAGE +from dokimi.exit_codes import EXIT_FAILURE, EXIT_INCONCLUSIVE, EXIT_USAGE from dokimi.utils import InputError from ._output import exit_on_unwritable @@ -160,8 +160,8 @@ def _judge(batch_dir: Path, args: argparse.Namespace) -> None: cost=_cost(done.meter, args.max_usd)) else: print(format_summary(result)) - if done.stopped: # as repo run: a cap that left work undone is not a finished run - sys.exit(EXIT_FAILURE) + if done.stopped: # a cap that left work undone: inconclusive, the judged cells keep their files + sys.exit(EXIT_INCONCLUSIVE) def cmd_repo_hits_sheet(args: argparse.Namespace) -> None: diff --git a/dokimi/tests/test_repo_hits_judge.py b/dokimi/tests/test_repo_hits_judge.py index 3a460ebfc..65d07c595 100644 --- a/dokimi/tests/test_repo_hits_judge.py +++ b/dokimi/tests/test_repo_hits_judge.py @@ -396,7 +396,7 @@ def test_max_usd_starts_no_call_once_spent_and_a_cell_left_gets_no_file(tmp_path stale = _judged(batch, "guidance:raw", 1) stale.write_text("{}") # an earlier run's file is not left to read as this run's code, out, _ = _run(capsys, "judge", str(batch), "--judge", JUDGE, "--max-usd", "1") - assert code == 1 + assert code == 3 assert len(judge_llm.requests) == 3 # $0.40 each: the third starts at $0.80, the fourth would at $1.20 assert _judged(batch, "guidance:none", 1).is_file() and not stale.exists() assert (f"1 cell(s) not fully judged (--max-usd spent), no {HITS_JUDGED}: " @@ -429,7 +429,7 @@ def test_an_unpriced_judge_under_max_usd_stops_the_run_and_says_why(tmp_path, ca batch = _batch(tmp_path) with llm.use_adapter(llm.FakeAdapter(respond=_reply)) as fake: # no cost_usd: the judge has no known price code, out, _ = _run(capsys, "judge", str(batch), "--judge", JUDGE, "--max-usd", "0.5") - assert (code, len(fake.requests)) == (1, 1) + assert (code, len(fake.requests)) == (3, 1) lines = out.splitlines() assert (f"2 cell(s) not fully judged ({UNPRICED_STOP}), no {HITS_JUDGED}: {TASK}__guidance-none__{MODEL}__r1, " f"{TASK}__guidance-raw__{MODEL}__r1") in lines @@ -453,7 +453,7 @@ def test_pairs_in_the_response_cache_still_finish_after_an_unpriced_stop(tmp_pat with llm.use_adapter(llm.FakeAdapter(respond=_reply)) as fake: # no cost_usd: the judge has no known price code, out, _ = _run(capsys, "judge", str(batch), "--judge", JUDGE, "--max-usd", "5", "--json") result = json.loads(out)["data"] - assert (code, len(fake.requests), result["calls"]) == (1, 1, 1) # none's first pair live, then the stop + assert (code, len(fake.requests), result["calls"]) == (3, 1, 1) # none's first pair live, then the stop assert result["budget_stopped"] == [f"{TASK}__guidance-none__{MODEL}__r1"] and result["budget_stop"] == UNPRICED_STOP document = json.loads(out) assert (document["status"], document["cost"]["calls"], document["cost"]["cap_usd"]) == ("budget_stopped", 1, 5.0) diff --git a/dokimi/tests/test_repo_hits_judge_cost.py b/dokimi/tests/test_repo_hits_judge_cost.py index 1d1cdda07..29c7a4bdb 100644 --- a/dokimi/tests/test_repo_hits_judge_cost.py +++ b/dokimi/tests/test_repo_hits_judge_cost.py @@ -19,6 +19,6 @@ def test_an_unpriced_judge_under_max_usd_json_has_no_remaining_budget_and_gives_ with llm.use_adapter(llm.FakeAdapter(respond=_reply)): # no cost_usd: the judge has no known price code, out, _ = _run(capsys, "judge", str(batch), "--judge", JUDGE, "--max-usd", "0.5", "--json") doc = json.loads(out) - assert code == 1 and (doc["status"], doc["reason"]) == ("budget_stopped", UNPRICED_STOP) + assert code == 3 and (doc["status"], doc["reason"]) == ("budget_stopped", UNPRICED_STOP) assert (doc["cost"]["remaining_usd"], doc["cost"]["priced"]) == (None, False) # not "the full budget left" assert schema_errors("cli_output.v1", doc) == [] From 84e2dfcbc53d9e771f7f7231fc6895cacd6c43bd Mon Sep 17 00:00:00 2001 From: Alexander Rybkin Date: Mon, 30 Nov 2026 23:14:44 -0800 Subject: [PATCH 3/4] fix(repo): repo run whose batch budget starts no cell exits 1, not 3 A rerun after earlier invocations spent --max-usd starts no cell and keeps nothing, so it is the no-result exit 1 (docs/quickstart.md exit 3 needs a kept partial output); it exited 3. Suggested in review. Signed-off-by: Alexander Rybkin --- ...1201_120000_repo-run-budget-stop-exit-3.md | 2 +- dokimi/dokimi/commands/repo_run.py | 4 +-- dokimi/tests/test_repo_run_batch_exit.py | 32 +++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/dokimi/changelog.d/20261201_120000_repo-run-budget-stop-exit-3.md b/dokimi/changelog.d/20261201_120000_repo-run-budget-stop-exit-3.md index f8e0374c7..98fe99399 100644 --- a/dokimi/changelog.d/20261201_120000_repo-run-budget-stop-exit-3.md +++ b/dokimi/changelog.d/20261201_120000_repo-run-budget-stop-exit-3.md @@ -5,4 +5,4 @@ SPDX-License-Identifier: Apache-2.0 ### Fixed -- **`repo run --max-usd` exits 3 (inconclusive) when the batch budget is the only reason a cell was not started** — the finished cells keep their `result.json`, as the other spend-capped commands keep a partial output; it exited 1. A batch with a budget stop and also an error or a failed probe still exits 1, and a cell that crashed of the machinery still exits 5. +- **`repo run --max-usd` exits 3 (inconclusive) when the batch budget is the only reason a cell was not started** — the finished cells keep their `result.json`, as the other spend-capped commands keep a partial output; it exited 1. A batch with a budget stop and also an error or a failed probe still exits 1, and a cell that crashed of the machinery still exits 5. A batch whose budget starts no cell keeps nothing and still exits 1. diff --git a/dokimi/dokimi/commands/repo_run.py b/dokimi/dokimi/commands/repo_run.py index eb1035f96..3a7731a52 100644 --- a/dokimi/dokimi/commands/repo_run.py +++ b/dokimi/dokimi/commands/repo_run.py @@ -507,9 +507,9 @@ def _exit_of_batch(summary: dict) -> None: sys.exit(EXIT_INFRA) if summary["errors"] or summary["probe_failed"]: sys.exit(1) - if summary["budget_stopped"]: + if summary["budget_stopped"] and (summary["ran"] or summary["skipped"]): sys.exit(EXIT_INCONCLUSIVE) - if not summary["ran"] and not summary["skipped"]: # every cell unsupported: the batch holds no result + if not summary["ran"] and not summary["skipped"]: # every cell unsupported or not started: the batch holds no result print(f"✗ incomplete: no cell has a result ({summary['cells']} cells, {summary['unsupported']} unsupported)", file=sys.stderr) sys.exit(1) diff --git a/dokimi/tests/test_repo_run_batch_exit.py b/dokimi/tests/test_repo_run_batch_exit.py index ba42e1fd6..18c321f9c 100644 --- a/dokimi/tests/test_repo_run_batch_exit.py +++ b/dokimi/tests/test_repo_run_batch_exit.py @@ -7,7 +7,9 @@ import pytest +from dokimi.cli import build_parser from dokimi.commands.repo_run import _exit_of_batch +from repo_eval_fixture import FakeRunner, fake_harness, make_repo def _summary(**over): @@ -33,6 +35,36 @@ def _code(summary) -> int | None: ({"errors": [{"infra": False}]}, 1), ({"probe_failed": ["t1"]}, 1), ({"ran": 0, "unsupported": 2}, 1), # no cell has a result + ({"ran": 0, "budget_stopped": 2}, 1), # every cell not started: nothing kept, not inconclusive + ({"ran": 0, "skipped": 1, "budget_stopped": 1}, 3), # a rerun: the cells done before keep their results ]) def test_exit_of_a_batch(over, code): assert _code(_summary(**over)) == code + + +def test_a_rerun_whose_spent_budget_starts_no_cell_exits_1(tmp_path, monkeypatch, capsys): + root, _ = make_repo(tmp_path) + exe, profile = fake_harness(tmp_path) + monkeypatch.setattr("dokimi.repos.container.DockerRunner", lambda *a, **k: FakeRunner()) + monkeypatch.setenv("FAKE_ACTION", "sleep") + out = tmp_path / "runs" + + def run(arm): + argv = ["repo", "run", f"{root}@HEAD", "--manifest", ".agent-eval/repo-eval.yaml", "--harness", str(profile), + "--bin", str(exe), "--model", "m-1", "--name", "b1", "--out", str(out), "--cache-root", + str(out / "caches"), "--agent-network", "host", "--arm", arm, "--task", "fix_add", "--timeout", "2", + "--max-usd-per-cell", "0.5", "--max-usd", "0.01"] + args = build_parser().parse_args(argv) + return _exit(args) + + assert run("guidance:raw") is None # the one cell runs and spends the cap + assert run("guidance:none") == 1 + assert "0 ran, 0 already done, 0 crashed, 1 not started (batch budget)" in capsys.readouterr().out + + +def _exit(args) -> int | None: + try: + args.func(args) + except SystemExit as exc: + return exc.code + return None From 4d2bfc1d84ae410d51e9472d1facb259e64919be Mon Sep 17 00:00:00 2001 From: Alexander Rybkin Date: Mon, 30 Nov 2026 23:16:02 -0800 Subject: [PATCH 4/4] docs(repo): help and docs give the exit codes repo run and hits judge return repo run --help and repo hits judge --max-usd help still said exit 1 for a budget stop; the quickstart said a crashed cell exits 1 (an infrastructure crash exits 5) and that any failed judge call exits 1 (only 3 in a row with one error stop the run; a single one leaves its pair unjudged). Signed-off-by: Alexander Rybkin --- .../20261201_120100_repo-hits-judge-budget-stop-exit-3.md | 2 +- dokimi/docs/quickstart.md | 6 +++--- dokimi/docs/repo-evaluation-contract.md | 4 ++-- dokimi/dokimi/commands/repo_hits.py | 2 +- dokimi/dokimi/commands/repo_run.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dokimi/changelog.d/20261201_120100_repo-hits-judge-budget-stop-exit-3.md b/dokimi/changelog.d/20261201_120100_repo-hits-judge-budget-stop-exit-3.md index d9511c6e2..0524ca744 100644 --- a/dokimi/changelog.d/20261201_120100_repo-hits-judge-budget-stop-exit-3.md +++ b/dokimi/changelog.d/20261201_120100_repo-hits-judge-budget-stop-exit-3.md @@ -5,4 +5,4 @@ SPDX-License-Identifier: Apache-2.0 ### Fixed -- **`repo hits judge --max-usd` exits 3 (inconclusive) when the cap or a call with no price stops it** — the cells judged before the stop keep their `hits_judged.json` and `--json` prints status `budget_stopped`, as before; the exit was 1. A failed judge call still exits 1. +- **`repo hits judge --max-usd` exits 3 (inconclusive) when the cap or a call with no price stops it** — the cells judged before the stop keep their `hits_judged.json` and `--json` prints status `budget_stopped`, as before; the exit was 1. A run stopped by 3 judge calls in a row failing with one error still exits 1. diff --git a/dokimi/docs/quickstart.md b/dokimi/docs/quickstart.md index f9e7627df..c18e9abf6 100644 --- a/dokimi/docs/quickstart.md +++ b/dokimi/docs/quickstart.md @@ -262,7 +262,7 @@ failed check. | 0 | The command ran and, if it checks something, the check passed. | | | 1 | A verdict or a gate that ran and failed, or a runtime failure the command reports (a model call, a run, a clone or fetch); a crash that escapes is 5. `eval judge validate --strict` and `eval leak`/`eval redteam` that fail as blocked. | `baseline compare --max-context-drop 0` over a regression, `repo reach` with a harness binary that cannot run, `eval triggers generate --fail-on warn` over a lint finding | | 2 | A bad invocation: a missing, unreadable or malformed input file, a configuration the agent's CLI rejects (`repo run --tools all` with a `.mcp.json` the CLI does not accept: refused before any cell runs), a device given as one (` : not a file`), a flag combination the command refuses, an output file that cannot be written, a missing provider credential, a source string that is malformed, unpinned or not a repository root. | `baseline save` on a bad eval file, `evaluate --questions` on an empty or non-JSON file (`--questions : `), `benchmark preflight` with no golden set, `repo scan --manifest ../x.yaml` | -| 3 | Inconclusive: the run stopped short because a budget ran out (`--max-usd`, or a call with no price) and kept the partial output (`tools preference`, `skill novelty atoms`, `probe` and `analyze`, `skill routing` and `catalog routing`, `repo run` when the batch budget is the only reason a cell was not started (a batch with a crashed cell or a failed probe too exits 1), and `repo hits judge`; a stop on a permanent provider error or a failed judge call exits 1; `eval personas discover` refuses its one call before it runs, so nothing is written), or the result is undecided (`eval judge validate`: a pass whose interval straddles the gate, or a variant no pair was built for, with `--strict` making it 1; `eval leak`: an item that could not be checked, or none could; `eval redteam`: a graded question not measured, or nothing graded; `eval judge agreement --strict`: an arm NOT MEASURED, or no arm to compare; `repo security --fail-on`: an unfinished cell or an arm with no measured cell, when no arm failed and every model has a baseline cell). | `tools preference --max-usd 5` with calls not run; `eval judge validate` with too few bases | +| 3 | Inconclusive: the run stopped short because a budget ran out (`--max-usd`, or a call with no price) and kept the partial output (`tools preference`, `skill novelty atoms`, `probe` and `analyze`, `skill routing` and `catalog routing`, `repo run` when the batch budget is the only reason a cell was not started (with a cell error or a failed probe too it exits 1, 5 for a cell that crashed of the machinery; a batch that started no cell exits 1), and `repo hits judge`; a stop on a permanent provider error, or on 3 judge calls in a row failing with one error, exits 1; `eval personas discover` refuses its one call before it runs, so nothing is written), or the result is undecided (`eval judge validate`: a pass whose interval straddles the gate, or a variant no pair was built for, with `--strict` making it 1; `eval leak`: an item that could not be checked, or none could; `eval redteam`: a graded question not measured, or nothing graded; `eval judge agreement --strict`: an arm NOT MEASURED, or no arm to compare; `repo security --fail-on`: an unfinished cell or an arm with no measured cell, when no arm failed and every model has a baseline cell). | `tools preference --max-usd 5` with calls not run; `eval judge validate` with too few bases | | 4 | Invalid: the result is not comparable or not trustworthy: a model that differs from the baseline's, or one that cannot be verified, under `baseline compare --strict` or the regression gate (`--max-context-drop` or `--max-lift-drop`); under `repo security --fail-on`, a model with no baseline cell when no arm failed; under `eval judge agreement --strict`, an arm JUDGE-DEPENDENT. | `baseline compare --strict` over a baseline scored with another judge | | 5 | Infrastructure failure: a crash (an uncaught exception) in any command, with its traceback on stderr. For a command that emits the cli_output document, `--json` prints its `infra` document on stdout first. Also a `repo run` cell that crashes (a harness that exits nonzero before its first trace line, unless the cap killed it, a docker daemon or CLI failure that stops the agent, a scratch directory that vanished): the batch keeps the other cells and exits 5. | `backends --json` when `detect` raises; `repo run` with the docker daemon down | @@ -274,8 +274,8 @@ a `.mcp.json` the CLI rejects under `--tools all` is exit 2 before any cell; a `--manifest` path that leaves the source tree as typed is exit 2, pinned or not, as a source refusal; a link in the tree that leads out of it is exit 1), and `tools preference` exits 1 when every call failed and 3 when `--max-usd` or an unpriced model stopped it short, and `eval personas discover` exits 3 when its `--max-usd` refuses the one call. `repo run --max-usd` exits 3 when the batch budget stops cells and nothing else went wrong -(with a crashed cell or a failed probe too it exits 1), and -`repo hits judge --max-usd` exits 3 when the budget or an unpriced call stops it, and 1 when a judge call failed. +(with a cell error or a failed probe too it exits 1, and 5 for a cell that crashed of the machinery), and +`repo hits judge --max-usd` exits 3 when the budget or an unpriced call stops it, and 1 when 3 judge calls in a row failed with one error. `skill novelty atoms`, `probe` and `analyze` and `skill routing` and `catalog routing` exit 3 when the budget or an unpriced call stops them and they keep a partial file, and 1 when they keep nothing (`skill shorten`, and a stop that leaves no partial file: "nothing was written") or a permanent provider error diff --git a/dokimi/docs/repo-evaluation-contract.md b/dokimi/docs/repo-evaluation-contract.md index c63cfbe24..567e4343d 100644 --- a/dokimi/docs/repo-evaluation-contract.md +++ b/dokimi/docs/repo-evaluation-contract.md @@ -2619,8 +2619,8 @@ python cli.py repo compare repo-runs/authoring --baseline guidance:none --metric once the batch has spent that much, earlier invocations included (kept in `_eval/spend.json`), counting the budget of each cell in flight. When the batch budget is the only reason a cell was not started, the finished cells - keep their `result.json` and the command exits 3 (inconclusive); with a crashed - cell or a failed probe too it exits 1 (5 for a cell that crashed of the machinery). + keep their `result.json` and the command exits 3 (inconclusive); with a cell + error or a failed probe too it exits 1 (5 for a cell that crashed of the machinery). - Every container runs with `--security-opt no-new-privileges`, `--cap-drop ALL` and a `--pids-limit`, as the caller's uid and gid. - `--agent-network` is required while the egress proxy is missing: it gives the diff --git a/dokimi/dokimi/commands/repo_hits.py b/dokimi/dokimi/commands/repo_hits.py index 581fdacd7..51f5a2322 100644 --- a/dokimi/dokimi/commands/repo_hits.py +++ b/dokimi/dokimi/commands/repo_hits.py @@ -209,7 +209,7 @@ def register(repo_sub, positive_int, usd: Callable[[str], float]) -> None: help="A `repo hits sheet` file with `label` filled in: report agreement and Cohen's kappa " "per arm and answer model between the person and the judge") judge_p.add_argument("--max-usd", type=usd, default=None, dest="max_usd", metavar="X", - help="Start no new judge call once this much has been spent (exit 1 if a cell was left); " + help="Start no new judge call once this much has been spent (exit 3 if a cell was left); " "after a judge reply with no known price no further call starts, since the cap cannot " "be enforced (drop --max-usd to run unmetered)") judge_p.add_argument("--dry-run", action="store_true", dest="dry_run", diff --git a/dokimi/dokimi/commands/repo_run.py b/dokimi/dokimi/commands/repo_run.py index 3a7731a52..e7f48444e 100644 --- a/dokimi/dokimi/commands/repo_run.py +++ b/dokimi/dokimi/commands/repo_run.py @@ -669,7 +669,7 @@ def _common(p: argparse.ArgumentParser, source_help: str, cache_help: str, posit "(clone, fetch, revision) and " ) CHECK_EXIT = _SOURCE_EXIT + "for a task that fails the check, or when no task was checked (every one a suite gap)." -RUN_EXIT = _SOURCE_EXIT + "for a cell that crashed, a batch budget stop or an incomplete batch." +RUN_EXIT = _SOURCE_EXIT + "for a cell that crashed or an incomplete batch; exit 3 when the batch budget alone left cells not started." def register(repo_sub, eval_sub, positive_int, source_help: str, cache_help: str) -> None: