Repository navigation
Conversation
…s next step (intel#94) Test-narrowed: the tools preference post-call refusal now names its --help step (the intel#1581 nit), so the old next == [] expectation is replaced by the help-step asserts; that test now has four asserts where it had three. Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
CLI interface change detectedThis PR changes dokimi's user-facing CLI surface (commands and/or options): ~ `dokimi catalog routing` parameters changed:
+ added option `--json`
~ `dokimi eval questions analyze` parameters changed:
+ added option `--json`
~ `dokimi eval questions review` parameters changed:
+ added option `--json`
~ `dokimi skill novelty analyze` parameters changed:
+ added option `--json`
~ `dokimi skill sensitivity` parameters changed:
+ added option `--json`Updated on every push; the |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1668 +/- ##
==========================================
- Coverage 96.44% 96.39% -0.05%
==========================================
Files 585 585
Lines 76600 76817 +217
Branches 13175 13209 +34
==========================================
+ Hits 73876 74047 +171
- Misses 1671 1701 +30
- Partials 1053 1069 +16
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
Cost reporting loses known spend for mixed priced/unpriced calls and reports zero calls and spend when skill-sensitivity result saving fails.
2 open issues
What changed in this PR
2 new findings. This advances #94 by extending dokimi’s structured CLI output to five more paid commands and addressing the follow-up from #1581.
Changes:
- Adds
--jsonoutput for novelty analysis, catalog routing, sensitivity, and question analysis/review. - Adds estimate, stop, and failure documents; supplies help steps for input errors.
- Updates regression tests, the CLI snapshot, and release notes.
| File | Description |
|---|---|
dokimi/tests/test_cli_output.py |
Registers the five commands’ next-step expectations. |
dokimi/tests/test_cli_json_paid.py |
Requires help after preference output errors. |
dokimi/tests/test_cli_json_novelty.py |
Tests JSON estimates, stops, costs, and failures. |
dokimi/dokimi/spend_preview.py |
Exposes estimates and refusals to wrappers. |
dokimi/dokimi/commands/tools.py |
Adds help steps after output-path refusals. |
dokimi/dokimi/commands/skill.py |
Registers novelty analysis JSON output. |
dokimi/dokimi/commands/skill_sensitivity.py |
Emits sensitivity result and estimate documents. |
dokimi/dokimi/commands/routing_parser.py |
Registers routing and sensitivity JSON flags. |
dokimi/dokimi/commands/questions.py |
Wraps question analysis and review output. |
dokimi/dokimi/commands/novelty.py |
Emits novelty documents with run costs. |
dokimi/dokimi/commands/novelty_routing.py |
Adds catalog documents and shared routing emission. |
dokimi/dokimi/commands/novelty_routing_report.py |
Returns routing estimates for JSON output. |
dokimi/dokimi/commands/novelty_budget.py |
Returns novelty dry-run estimates. |
dokimi/dokimi/cli.py |
Adds fallback help and prevents duplicate crash documents. |
dokimi/dokimi/cli_output.py |
Adds stop and write-failure document helpers. |
dokimi/docs/reference/cli-interface.json |
Records the five new flags. |
dokimi/changelog.d/20261205_120000_napetrov_cli-json-paid-2.md |
Documents expanded JSON support and preference help. |
Review effort: Balanced
| rolled = roll_up_cost(state["clients"]) | ||
| return cli_output.cost_of(spent_usd=rolled.get("usd"), calls=rolled.get("llm_calls", 0), cap_usd=args.max_usd) |
| except SystemExit as stop: | ||
| _emit(args, state, stop) | ||
| raise |
|
🔍 OpenCodeReview found 1 issue(s) in this PR. CI at `976c1ee`: 3 failing, 15 passing, 9 skippedNot fully read: log of Test Linux Python 3.14: longer than 8000000 bytes, only the start was read; log of Test Linux Wheels Python 3.14: longer than 8000000 bytes, only the start was read
By label: 1 should fix
Test notes (2)
Review details
|
| "cost": roll_up_cost([selector]), | ||
| } | ||
| out = save_result(payload, out, result) | ||
| state.update(payload=payload, out=out) |
There was a problem hiding this comment.
Impact: a post-call write failure produces a JSON document claiming zero calls and zero spend, losing the paid run's accounting.
Trigger: skill sensitivity ... --json completes selector calls but save_result() raises an OSError (for example, disk full).
Evidence: state is populated only after saving, the wrapper catches only SystemExit, and cli.main's exception fallback builds a document with the default zero cost. Capture the selector/accounting before saving and handle write exceptions with write_failure_document, as the catalog-routing wrapper does; do not advertise an artifact that was not saved.
Fix: Add a regression test forcing the save to fail after mocked paid calls.
Workaround: use a writable destination with sufficient space; there is no accounting recovery in this response once the write fails.
Should fix: A run shows it; it was not judged to be met in ordinary use.
This proof replaces part of the code with stand-ins (monkeypatch): it shows the code path, not the real dependency or platform.
Shown by running: exit 1 (at the head) · exit 1 (at the merge base, which cannot run it) · exit 0 (at the head with the fix)
python -m pytest -q -p no:randomly -p no:cacheprovider tests/test_verify_sensitivity_write_accounting.py
What the proof does: Calls the real sensitivity CLI with a transport supplying priced replies and a simulated disk-full write, and checks that its failure document retains both calls and their cost.
The problem shows as the output sensitivity write failure lost paid accounting.
Script: dokimi/tests/test_verify_sensitivity_write_accounting.py (55 lines).
assert stopped.value.code == 5
assert doc['status'] == 'failed' and doc['error']['code'] == 'infra'
> assert doc['cost']['calls'] == 2 and doc['cost']['spent_usd'] == pytest.approx(0.02), 'sensitivity write failure lost paid accounting'
E AssertionError: sensitivity write failure lost paid accounting
E assert (0 == 2)
tests/test_verify_sensitivity_write_accounting.py:53: AssertionError
=========================== short test summary info ============================
FAILED tests/test_verify_sensitivity_write_accounting.py::test_write_failure_retains_paid_accounting
1 failed in 1.15s
Mutation of changed linesAt 976c1ee: 58 caught · 6 missed · 16 inconclusive Each row is a small deliberate break (a mutant) of a line this PR changes that every test reaching that line still passes. Add a test that fails on it or, if it cannot change behaviour, put
Not the whole picture:
Warning only: a missed break does not fail the job. Updated on every push; the full report is in the ci run summary. |
| cli_output.emit(cli_output.stop_document(kind, payload, stopped, limit_code=cli_output.limit_code_of(payload), | ||
| **fields)) |
There was a problem hiding this comment.
CI check Tests (py3.14) fails: The new _emit_saved path calls stop_document without a reason override, replacing the prior partial['message'] with the human-readable exit message, including call counts and the output path. This breaks the existing capped-routing JSON reason assertion; overriding the reason only for budget exits preserves the new failed-call status behavior. Proposed fix, not run by the bot.
| cli_output.emit(cli_output.stop_document(kind, payload, stopped, limit_code=cli_output.limit_code_of(payload), | |
| **fields)) | |
| reason = (payload.get("partial") or {}).get("message") if stopped.code == 3 else None | |
| cli_output.emit(cli_output.stop_document(kind, payload, stopped, limit_code=cli_output.limit_code_of(payload), | |
| reason=reason, **fields)) |

Part of #94 (F2
--jsonslice 2). #94 stays open.Summary
Adds
--json(thecli_output.v1document) to five paid leaves, and closes the #1581 nit where a refusedtools preferencepath after the model calls exited 2 with an emptynext.--dry-run)nextskill novelty analyzecompletebudget_stopped, partial record kept (artifactsnull); exit 1 after a failed call:partial, file kept--helpcatalog routingcompletebudget_stoppedorpartial--helpskill sensitivitycompletebudget_stoppedorpartial--helpeval questions analyzecompletebudget_stopped. Cap reached mid-run:failed, no report, cost kept--helpeval questions reviewcompletebudget_stopped. Cap reached with reviews saved:budget_stoppedwith the saved reviews. None saved:failed--helptools preference(nit)--out/--items-outafter the calls: exit 2, now names--help--helpKept rows: a success prints no
next(the five are inLEAVES_WITHOUT_NEXT_BY_DESIGN).--jsonis a newflag on five leaves:
docs/reference/cli-interface.jsonregenerated (make cli-snapshot).stop_documenttakes an explicitreason: an int-coded stop (SystemExit(3)) reads "the run stopped (exit 3)"instead of "3", and a stop with no kept result is
failed, notpartial.Evidence
tests/test_cli_json_novelty.py(new): dry-run document and no file written; input error names--help;budget stop keeps cost and exits 3; finished run with a failed call is
partial; spend cap inside the runis documented as the stop it is; questions analyze dry run, CLI-login refusal, and a cap reached mid-run
(
failed, cost kept); sensitivity dry run; int-coded stop reason; stop with no result isfailed; a writefailing after the calls keeps their cost (wrapper and through
cli.main: one document, exit 5); a finishedrun's cost includes the
--judge2regrade's calls; a skill sensitivity with afailedsaved result.tests/test_cli_json_paid.py: thetools preferencepost-call path assertion now requires the help step(was
next == []).tests/test_cli_output.py: five leaves added to the next-step sets.catalog routing/skill routingdocuments: unit test of_emit_saved(exit 3 budget, exit 1 partial viaPartialStop(msg, 1)).eval questions review --jsonorcatalog routing --json; the surface andnext-step sets cover them.
API environment variables unset and clients mocked.
Merge Danger
_emit_analyzeand the other wrappers run the command underquiet_stdout(): human output moves to stderronly with
--json. Without the flag the path is unchanged.cli.pyexit-2 fallback: a leaf markedinput_help_nextnow gets the--helpstep on every exit-2 inputerror, not only the five leaves in this PR (the
--jsonleaves already had it; this makes it general).print_estimate_onlynow returns its estimate dict (wasNone); only the analyze wrapper reads it.skill routing --jsondry run now emits an estimate document (wasdata: null). Its stop documents now takethe status from the exit code (exit 3
budget_stopped, exit 1partial), andreasonis the full stop message;before, a
no_pricestop (exit 3) readpartial.skill novelty analyze,catalog routing) now prints one documentthat keeps the calls' cost (
failed, orinputwith the help step for exit 2), then exits as before.cli.pycrash handler (exit 5): it no longer prints a second document when the leaf already printed its own(
cli_output.printed()), so stdout keeps onecli_output.v1document.skill sensitivitywith a saved result ofstatus: failed(every selector call failed) prints afaileddocument.eval questions analyzeexit 2 after its calls (unwritable output) is aninputdocument with the help step.catalog routing --jsonandeval questions review --jsonhave no CLI-level test yet (see Evidence).🤖 Generated with Claude Code