Skip to content

fix(novelty): a budget stop that kept its partial result exits 3 - #1374

Merged
napetrov merged 2 commits into
intel:mainfrom
antonwolfy:fix/partial-stop-exit-3
Nov 29, 2026
Merged

napetrov merged 2 commits into
intel:mainfrom
antonwolfy:fix/partial-stop-exit-3

Conversation

@antonwolfy

Copy link
Copy Markdown
Contributor

Summary

docs/quickstart.md gives exit 3 to a run that "stopped short because a budget ran out (--max-usd, or a call with no price) and kept the partial output", and tools preference does that. skill novelty atoms, probe, analyze, skill routing and catalog routing keep their partial file on the same stop but exit 1, because they raise SystemExit(<message>).

On main (52f9de6), with the offline test providers:

Run Output Exit on main Exit now
exit_partial("--max-usd stopped the probes with 1 of 2 answers", Path("probes.partial.json")) message on stderr 1 3
stop_if_partial({"partial": {"reason": "spend_cap", ...}}, Path("routing.json"), ...) message on stderr 1 3
skill novelty atoms --max-usd 1 over 200 spans --max-usd stopped extraction with 50 of 200 spans read; the partial result is in atoms.partial.json 1 3
a stop on a provider error every call would meet (permanent_error) its message 1 1

The decision is one rule, partial_exit_code(reason) in commands/novelty_routing_report.py: spend_cap and no_price exit 3 (EXIT_INCONCLUSIVE), permanent_error and any other reason exit 1 (EXIT_FAILURE), since a provider error is a runtime failure (quickstart row 1) and not a budget stop. exit_partial (atoms, probe, analyze) takes the stop's reason, and stop_if_partial (single and all-vs-all routing) reads it from the partial block. Both print the unchanged message to stderr and raise PartialStop, a SystemExit subclass whose code is the int and whose str() is the message, so every existing match= on the message still holds. This was chosen over printing and raise SystemExit(code) as in tools.py because that would move the message off the exception and every test that pins it would have to read capsys.

These keep exit 1: exit_partial_all_vs_all (failed model calls), stops_at_cap and shorten's cap stop (they write nothing), and catalog novelty (a batch).

The same cause outside the issue: repo run --max-usd and repo hits judge --max-usd keep their output on a budget stop and exit 1, tracked in #1372 and #1373.

Closes #632

Changes

  • commands/novelty_routing_report.py: partial_exit_code, PartialStop and stop_partial (prints the message, raises with the code); stop_if_partial and exit_partial_all_vs_all use it (the latter with a reason that exits 1).
  • commands/novelty_budget.py: exit_partial takes reason=; save_analyze_partial, save_probe_run and save_atoms_run pass theirs.
  • commands/novelty_routing.py: RoutingStopped takes the PartialStop and carries its code and message; skill routing --json still prints its document (budget_stopped for spend_cap, partial otherwise) and then exits with that code, and cli.main prints no second document.
  • Tests: every test that pins one of these stops by message also asserts the code (3 for spend_cap and no_price, 1 for permanent_error and for failed model calls). test_novelty_partial_exit_code.py is new: the rule, probe, analyze and atoms stopped on no price or a permanent error, and atoms through cli.main() with the message once on stderr. test_novelty_routing_spend_cap_partial.py gains a permanent-error single routing stop (exit 1) and skill routing --json through cli.main() (one document, exit 3).
  • Two existing tests changed: test_report_summary.py::test_skill_routing_json_of_a_capped_run_keeps_its_document_and_its_exit pinned code == 1 for a capped skill routing --json and now pins 3; test_novelty_routing_repeat_failures.py read the message through exc.value.code, which is now the int, so it reads str(exc.value) and gains code == 1.
  • Docs: quickstart row 3 and the prose after the table, skill-novelty.md (routing, atoms, probe and analyze exits), and one line of skill-novelty-walkthrough.md: the bullet that lists how the stopped steps exit now says "Each exits 3 (1 when a permanent provider error stopped it)". The walkthrough's analyze bullet is left as it is on main.
  • Changelog fragment (Changed).

Risk

A script that read exit 1 as "stopped by the budget" from skill novelty atoms, probe, analyze, skill routing or catalog routing now sees 3; a permanent_error stop and failed model calls still exit 1. The stderr text is unchanged. skill routing --json now exits 3 with the same single document.

Open PR #1325 rewrites the analyze bullet of docs/skill-novelty-walkthrough.md, which still says analyze keeps nothing although it has kept <out stem>.partial.json since #633. This PR leaves that bullet as main has it so as to stay apart from #1325, which fixes it; the exit line this PR changes is three unchanged lines away from #1325's change.

Open PR #1184 already conflicts with main in docs/quickstart.md (its row 3 predates main's), so its rebase meets this PR's row 3 as well; it also changes row 4, the line after row 3. #1197 rewrites the line after the prose this PR edits and merges with this PR's doc changes cleanly. #1190 and #1247 change one import in run_estimate; it is not touched here. #1313, #1366 and #1371 change other lines of quickstart.md, skill-novelty.md, the walkthrough and (#1371) a docstring in novelty_budget.py, and merge with this branch's changes cleanly.

Testing

On Linux, at b190b094 (on main 52f9de6):

  • make ci-local: 38 passed, 0 failed, 16 skipped. Changed-line coverage 100% of 21 lines; the mutation step: 17 of 17 mutants killed. Skipped steps are the ones that need another job, Docker, micromamba, semgrep or a PR event.
  • On main's code the new and changed tests fail on the code assertion (the exit code is the message string, not the int): test_novelty_partial_exit_code.py 7 failed, 5 passed; test_novelty_routing_spend_cap_partial.py 20 failed, 34 passed; test_novelty_cap_partial.py 7 failed, 30 passed; test_novelty_analyze_cap_partial.py 7 failed, 24 passed; test_novelty_routing_all_vs_all.py 5 failed, 74 passed; test_novelty_spend_cap.py 1 failed, 21 passed.
  • Mutants, each one break: no_price left out of the budget reasons, permanent_error exiting 3, the message not printed, the message printed twice, failed all-vs-all calls exiting 3, stop_if_partial, exit_partial of probe, analyze and atoms ignoring the reason, and RoutingStopped losing its code or its message each fail a test.
  • Not run: the other Python versions (3.11, 3.12, 3.14) and a real model provider.

Open questions

None.

Revert

A plain revert restores exit 1 for these stops. Nothing is stored.

Checklist

  • Tests added/updated and pytest passes
  • ruff, mypy, and schema checks pass
  • Docs updated (or N/A) — see the docs-drift checklist in CONTRIBUTING.md
  • Self-reviewed per "Before opening a PR" in AGENTS.md
  • Each new raise/exit and test names the doc, contract or issue it traces to
  • No ad-hoc run artifacts committed
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml)

…el#632)

`skill novelty atoms`, `probe`, `analyze`, `skill routing` and `catalog routing` stopped by `--max-usd` or a call with no price kept their partial file and exited 1 through `SystemExit(<message>)`, while the exit-code table in docs/quickstart.md gives 3 to a run that stopped short on a budget and kept its partial output, as `tools preference` does.

`partial_exit_code(reason)` in `novelty_routing_report.py` is now the one rule: `spend_cap` and `no_price` exit 3, `permanent_error` (a runtime failure) and any other reason exit 1. `exit_partial` takes the stop's reason and `stop_if_partial` reads it from the partial block; both print the same message to stderr and raise `PartialStop`, a `SystemExit` whose `code` is the int and whose `str()` is the message, so the existing message checks hold. `RoutingStopped` carries that code too, and `cli.main` prints no second document for `skill routing --json`. `exit_partial_all_vs_all` (failed model calls) and the stops that keep nothing stay exit 1.

The tests that pin these stops also assert the code, and new ones cover the rule, a permanent-error stop, `skill routing --json` and a stop through `cli.main`. quickstart.md, skill-novelty.md and the walkthrough name the new exit, and the walkthrough no longer says `analyze` keeps nothing.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
The first commit rewrote the walkthrough's `analyze` bullet to say what analyze keeps in its partial file since intel#633. An open PR rewrites the same bullet, so this branch puts it back to main's text and changes only the walkthrough line that says how the stopped steps exit.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@exai-bot

exai-bot commented Nov 28, 2026 •

Copy link
Copy Markdown

✅ OpenCodeReview: Review complete: 0 finding(s) across 15 selected item(s).

CI at b190b09: 21 passing, 4 skipped.

Review details
  • Commit reviewed: b190b09 against merge base 52f9de6
  • Coverage: 15 files in 3 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 277k tokens (159k from cache), 18s
  • Tool calls: 28 (17 file_read, 7 code_search, 2 ci_status, 1 file_read_diff, 1 local_check_results)
  • Partial-stop exit behavior documentation: 4 files
  • Novelty budget caps and partial exit codes: 5 files
  • Novelty routing partial results and reporting: 6 files

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.21%. Comparing base (52f9de6) to head (b190b09).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1374      +/-   ##
==========================================
- Coverage   96.22%   96.21%   -0.02%     
==========================================
  Files         509      509              
  Lines       67762    67773      +11     
  Branches    11766    11766              
==========================================
+ Hits        65203    65205       +2     
- Misses       1576     1580       +4     
- Partials      983      988       +5     
Files with missing lines Coverage Δ
dokimi/dokimi/commands/novelty_budget.py 97.03% <100.00%> (ø)
dokimi/dokimi/commands/novelty_routing.py 97.70% <100.00%> (+0.01%) ⬆️
dokimi/dokimi/commands/novelty_routing_report.py 99.43% <100.00%> (+0.01%) ⬆️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@napetrov napetrov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Change class: CONTRACT (head b190b09)

  • Contract: changed. defaults dokimi/dokimi/commands/novelty_budget.py:66; errors dokimi/dokimi/commands/novelty_routing.py:165
  • Responsibility: none
  • Dependency: none
  • Review depth: check the changed surface: callers, docs, tests pin new behaviour
  • Coverage gaps: none

The changed CLI paths preserve the partial output, return 3 for budget stops, and keep exit 1 for permanent model errors. The structured output and single stderr message are covered.

Coverage: 289 passed in 9.99s. Hosted checks on the reviewed head passed or skipped. The combined #1371 and #1374 tree also passed 86 targeted tests.

@napetrov
napetrov merged commit 9be7756 into intel:main Nov 29, 2026
25 checks passed
@antonwolfy
antonwolfy deleted the fix/partial-stop-exit-3 branch November 29, 2026 10:27
@xaleryb

xaleryb commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A budget stop that kept its partial output exits 1 in atoms, probe, routing and analyze; tools preference exits 3

5 participants