Repository navigation
fix(novelty): a budget stop that kept its partial result exits 3 - #1374
Conversation
…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>
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 15 selected item(s). CI at Review details
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
napetrov
left a comment
There was a problem hiding this comment.
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.
|
Summary
docs/quickstart.mdgives 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", andtools preferencedoes that.skill novelty atoms,probe,analyze,skill routingandcatalog routingkeep their partial file on the same stop but exit 1, because they raiseSystemExit(<message>).On
main(52f9de6), with the offline test providers:mainexit_partial("--max-usd stopped the probes with 1 of 2 answers", Path("probes.partial.json"))stop_if_partial({"partial": {"reason": "spend_cap", ...}}, Path("routing.json"), ...)skill novelty atoms --max-usd 1over 200 spans--max-usd stopped extraction with 50 of 200 spans read; the partial result is in atoms.partial.jsonpermanent_error)The decision is one rule,
partial_exit_code(reason)incommands/novelty_routing_report.py:spend_capandno_priceexit 3 (EXIT_INCONCLUSIVE),permanent_errorand 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, andstop_if_partial(single and all-vs-all routing) reads it from thepartialblock. Both print the unchanged message to stderr and raisePartialStop, aSystemExitsubclass whosecodeis the int and whosestr()is the message, so every existingmatch=on the message still holds. This was chosen over printing andraise SystemExit(code)as intools.pybecause that would move the message off the exception and every test that pins it would have to readcapsys.These keep exit 1:
exit_partial_all_vs_all(failed model calls),stops_at_capandshorten's cap stop (they write nothing), andcatalog novelty(a batch).The same cause outside the issue:
repo run --max-usdandrepo hits judge --max-usdkeep 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,PartialStopandstop_partial(prints the message, raises with the code);stop_if_partialandexit_partial_all_vs_alluse it (the latter with a reason that exits 1).commands/novelty_budget.py:exit_partialtakesreason=;save_analyze_partial,save_probe_runandsave_atoms_runpass theirs.commands/novelty_routing.py:RoutingStoppedtakes thePartialStopand carries its code and message;skill routing --jsonstill prints its document (budget_stoppedforspend_cap,partialotherwise) and then exits with that code, andcli.mainprints no second document.spend_capandno_price, 1 forpermanent_errorand for failed model calls).test_novelty_partial_exit_code.pyis new: the rule, probe, analyze and atoms stopped on no price or a permanent error, and atoms throughcli.main()with the message once on stderr.test_novelty_routing_spend_cap_partial.pygains a permanent-error single routing stop (exit 1) andskill routing --jsonthroughcli.main()(one document, exit 3).test_report_summary.py::test_skill_routing_json_of_a_capped_run_keeps_its_document_and_its_exitpinnedcode == 1for a cappedskill routing --jsonand now pins 3;test_novelty_routing_repeat_failures.pyread the message throughexc.value.code, which is now the int, so it readsstr(exc.value)and gainscode == 1.skill-novelty.md(routing, atoms, probe and analyze exits), and one line ofskill-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'sanalyzebullet is left as it is onmain.Risk
A script that read exit 1 as "stopped by the budget" from
skill novelty atoms,probe,analyze,skill routingorcatalog routingnow sees 3; apermanent_errorstop and failed model calls still exit 1. The stderr text is unchanged.skill routing --jsonnow exits 3 with the same single document.Open PR #1325 rewrites the
analyzebullet ofdocs/skill-novelty-walkthrough.md, which still saysanalyzekeeps nothing although it has kept<out stem>.partial.jsonsince #633. This PR leaves that bullet asmainhas 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
mainindocs/quickstart.md(its row 3 predatesmain'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 inrun_estimate; it is not touched here. #1313, #1366 and #1371 change other lines ofquickstart.md,skill-novelty.md, the walkthrough and (#1371) a docstring innovelty_budget.py, and merge with this branch's changes cleanly.Testing
On Linux, at
b190b094(onmain52f9de6):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.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.py7 failed, 5 passed;test_novelty_routing_spend_cap_partial.py20 failed, 34 passed;test_novelty_cap_partial.py7 failed, 30 passed;test_novelty_analyze_cap_partial.py7 failed, 24 passed;test_novelty_routing_all_vs_all.py5 failed, 74 passed;test_novelty_spend_cap.py1 failed, 21 passed.no_priceleft out of the budget reasons,permanent_errorexiting 3, the message not printed, the message printed twice, failed all-vs-all calls exiting 3,stop_if_partial,exit_partialof probe, analyze and atoms ignoring the reason, andRoutingStoppedlosing its code or its message each fail a test.Open questions
None.
Revert
A plain revert restores exit 1 for these stops. Nothing is stored.
Checklist
pytestpassesruff,mypy, and schema checks passAGENTS.mdraise/exit and test names the doc, contract or issue it traces to.github/.licenserc.yaml)