Skip to content

feat(skill-coverage): --dry-run prices the two calls before any spend (Part of #94) - #1419

Merged
napetrov merged 12 commits into
intel:mainfrom
napetrov:feat/cli-paid-guards-2
Dec 2, 2026
Merged

napetrov merged 12 commits into
intel:mainfrom
napetrov:feat/cli-paid-guards-2

Conversation

@napetrov

@napetrov napetrov commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Part of #94 (F1b, spend: paid-guards slice 2, the dry-run on the skill-coverage leaf).

Summary

eval skill-coverage now prices its two model calls before any spend, as eval personas discover does in #1198:

  • --dry-run prints the list-price estimate and exits 0. It builds no client, calls no model and writes no --out file. Inputs and --out are still checked, so a refusal reads the same as on a real run.
  • --max-usd X refuses a real run before its first call (exit 3, no client built) when the estimate is over X, or when the model has no list price. The message names the estimate and the cap. Behaviour change: an unpriced model with --max-usd used to make one call and then stop (exit 1); it now refuses up front.
  • A run that goes over the cap mid-run still stops with exit 1.

Leaf table

Leaf Flags before Flags after
eval skill-coverage --max-usd (mid-run stop, exit 1) --dry-run added (estimate, exit 0, no client). --max-usd gains a pre-call refusal (exit 3) when the estimate is over the cap or the model is unpriced; mid-run stop stays exit 1

Kept rows: none. --json is not added (F2).

Evidence

  • tests/test_skill_coverage_dry_run.py: 11 tests. Red first: the dry-run tests failed on the missing flag; then 3 failed against the pre-call gate (two new gate tests and the reworded cap test: exit 0, client built). The within-cap test passes before and after, as a guard. Green: 11 passed; with test_cli_flags.py, 57 passed after the last doc-only edits. The full ci-local run is the gate.
  • The dry-run and gate tests replace _client, LLMClient.__init__ and LLMClient.json_object with functions that fail the test, so any client construction or model call is caught.
  • Pricing is stubbed in the tests; no provider is reached. cli-interface.json regenerated (make cli-snapshot, no diff needed for the help text change).

Not in this PR

Remaining unguarded paid leaves on intel/main e260503bb plus this change (41 paid leaves in the check):

  1. Fully guarded, or only --json missing (F2): skill routing, repo hits judge (guarded); catalog routing, skill novelty analyze, eval personas discover, tools preference, eval skill-coverage (--json only).
  2. --dry-run present, no --max-usd: repo reach, repo skill-reach (per-cell caps only; a batch cap needs a Spend total across cells), tasks run, eval questions refine.
  3. --max-usd present, no --dry-run, no estimator of its own: catalog novelty, skill novelty atoms, skill novelty probe, skill shorten, eval graph, repo run. The novelty estimator covers only the whole analyze pipeline.
  4. Neither flag, no estimator or spend total: answers generate, arms run, arms matrix-run, benchmark run, benchmark batch, catalog trigger-probe, delivery scan, eval judge agreement|validate|wording, eval questions analyze|generate|review, eval redteam, eval score checklist|pairwise|panel|pointwise|ragas|reference, eval triggers generate, evaluate, explore run, subjects run.

Label: cli-interface-change.

🤖 Generated with Claude Code

@napetrov
napetrov requested a review from a team as a code owner November 29, 2026 23:36
@napetrov napetrov added the cli-interface-change Changes dokimi's user-facing CLI surface label Nov 29, 2026
@github-actions

Copy link
Copy Markdown

CLI interface change detected

This PR changes dokimi's user-facing CLI surface (commands and/or options):

~ `dokimi eval skill-coverage` parameters changed:
    + added option `--dry-run`

Updated on every push; the cli-interface-change label is on while the diff is non-empty.

… (Part of intel#94)

eval skill-coverage --dry-run prices its two model calls at list prices and prints the estimate. It builds no client, calls no model and writes no --out file; inputs and --out are still checked. The second prompt is counted at the skill's length, since the requirement list is not known until the first call returns. --max-usd already existed and is unchanged.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@napetrov
napetrov force-pushed the feat/cli-paid-guards-2 branch from 844d419 to f8ba451 Compare November 29, 2026 23:40
@exai-bot

exai-bot commented Nov 29, 2026 •

Copy link
Copy Markdown

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

CI at 333a2b1: 21 passing, 4 skipped.

Review details
  • Commit reviewed: 333a2b1 against merge base 57a3155
  • Coverage: 6 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 127k tokens (61k from cache), 19s
  • Tool calls: 10 (6 file_read, 1 ci_status, 1 code_search, 1 local_check_results, 1 pr_threads)
  • Skill coverage dry-run and paid-operation CLI guards: 6 files

@codecov-commenter

codecov-commenter commented Nov 29, 2026 •

Copy link
Copy Markdown

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

Codecov Report

❌ Patch coverage is 96.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.31%. Comparing base (3ab27d8) to head (333a2b1).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
dokimi/dokimi/commands/skill_coverage.py 95.83% 1 Missing and 1 partial ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1419      +/-   ##
==========================================
- Coverage   96.34%   96.31%   -0.03%     
==========================================
  Files         517      521       +4     
  Lines       69116    69859     +743     
  Branches    11971    12084     +113     
==========================================
+ Hits        66587    67287     +700     
- Misses       1557     1589      +32     
- Partials      972      983      +11     
Files with missing lines Coverage Δ
dokimi/dokimi/skill_coverage.py 96.89% <100.00%> (+0.15%) ⬆️
dokimi/dokimi/commands/skill_coverage.py 96.24% <95.83%> (-0.50%) ⬇️

... and 15 files with indirect coverage changes

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

@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Mutation of changed lines

⚠️ Tests miss 2 of 65 small breaks of the lines this PR changes

At 333a2b1: 63 caught · 2 missed

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 # mutation-ok[<operator>]: <reason> at the end of the line or alone on the line above.

Where Operator Change no test notices Tests reaching the line
dokimi/dokimi/commands/skill_coverage.py:125 return-none False → None 7
dokimi/dokimi/commands/skill_coverage.py:139 return-none False → None 3

Not checked:

  • 5 changed lines were not mutated

Warning only: a missed break does not fail the job. Updated on every push; the full report is in the ci run summary.

@vlad-perevezentsev vlad-perevezentsev 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.

🟡 Changes needed · reviewed f8ba451

To fix: the user docs still describe the old --max-usd (exit 1 for an unpriced model) and do not mention --dry-run (line comments). The smaller estimate and output points there are optional.

✅ make ci-local --offline: 31,404 passed, 116 skipped · ✅ changed tests pass with 20 random seeds · ✅ changed-line coverage 98% · ✅ mypy, ruff, schema_compat

Pricing the two calls before any client is built matches personas discover and is well tested.

Comment thread dokimi/dokimi/skill_coverage.py Resolved
Comment thread dokimi/dokimi/skill_coverage.py Resolved
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g869hX1f PRRT_kwDOVBg7g869hX1m PRRT_kwDOVBg7g869hX1x PRRT_kwDOVBg7g869hX10 PRRT_kwDOVBg7g869hX19 PRRT_kwDOVBg7g869hX2D PRR_kwDOVBg7g88AAAABbFh75w
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@napetrov

Copy link
Copy Markdown
Contributor Author

Re: review by vlad-perevezentsev

The user docs still describe the old --max-usd.

Updated the guide and addressed the optional points. 43574e7

@vchamarthi vchamarthi 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.

@napetrov, could you fix the small thing I've marked fix before merge (in the line comments) and answer my question below? I'll approve once that's done.
I'll approve once that's done.

My question before I approve:

  • A run whose two replies are already in the response cache (DOKIMI_RESPONSE_CACHE) costs nothing, but --max-usd still refuses it before any client is built when the estimate is over the cap. Decide whether a fully cached run should go through.
Optional, non-blocking (1)
  • dokimi/dokimi/skill_coverage.py:380: An estimate a hair over the cap gets through: $0.0400004 against --max-usd 0.04 is allowed, because line 380 rounds it to six places first.

What I checked on d6eefce: the 13 changed tests pass, and fail on main as expected; the full test suite passes with main merged in (32,398 tests), apart from failures main has too; it merges cleanly onto main; when I changed the code on purpose, the tests caught all 12 changes.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g869_FGw
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRR_kwDOVBg7g88AAAABbVPFqw.b
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Copilot AI balanced review requested due to automatic review settings December 1, 2026 16:32
@napetrov

napetrov commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Re: review by vchamarthi

Decide whether a fully cached run should go through.
Waiting on a decision before I change this: should two cache hits bypass --max-usd? I recommend keeping preflight until both hits can be guaranteed without a paid call. 6c86a71 fixes the separate rounding case; $0.0400004 now exceeds a $0.04 cap.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open issues
What changed in this PR

Adds preflight pricing to eval skill-coverage so runs can be refused (or dry-run’d) before any model spend, aligning behavior with other guarded paid leaves.

Changes:

  • Add --dry-run to print a list-price estimate for the two model calls and exit 0 without building a client, calling a model, or writing --out.
  • Add a pre-call --max-usd refusal path (exit 3) when the estimate exceeds the cap or when the model is unpriced; keep mid-run cap stop behavior (exit 1).
  • Introduce token/cost estimation logic and targeted tests + docs/changelog updates for the new CLI behavior.
File Description
dokimi/​tests/​test_skill_coverage_dry_run.py Adds coverage for dry-run behavior and pre-call --max-usd refusal semantics.
dokimi/​dokimi/​skill_coverage.py Introduces estimate_coverage() and an assumed reply-token budget for list-price estimation.
dokimi/​dokimi/​commands/​skill_coverage.py Wires --dry-run and pre-call pricing/cap refusal into the CLI command, including messaging.
dokimi/​docs/​reference/​cli-interface.json Updates CLI snapshot to include the new --dry-run flag.
dokimi/​docs/​evaluating-treatments.md Documents the new dry-run estimate and pre-call cap refusal behavior for skill coverage evals.
dokimi/​changelog.d/​20261129_120000_cli-paid-guards-2.md Adds changelog entries describing the new pricing and cap refusal behavior.

Review effort: Lite

Comment on lines +375 to +379
extract = _EXTRACT_SYSTEM + _EXTRACT_PROMPT.format(skill=skill.text)
listing = skill.text[:MAX_REQUIREMENTS * 200]
mapping = _MAP_SYSTEM + _MAP_PROMPT.format(requirements=listing, checks=catalogue_text(checks))
prompt_tokens = [len(extract) // 4 + 1, len(mapping) // 4 + 1]
prices = [list_cost_usd(model, provider, tokens, ESTIMATE_REPLY_TOKENS) for tokens in prompt_tokens]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Keeping it. check_budget builds the same catalogue first and caps it at 120,000 chars; the listing is capped at 16,000. The strings are bounded and cost no spend, and pricing the real prompt text keeps the estimate from drifting from the prompt.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g86-LMsT
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g86-LMqb
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g86-LMrq
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@napetrov

napetrov commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Re: review by vchamarthi

Decide whether a fully cached run should go through.
Decided: keep the preflight. A cache hit is not known before the call, and a miss is paid over the cap.
$0.0400004 against --max-usd 0.04 is allowed
Fixed in 6c86a71: full precision, so it is refused.

@vlad-perevezentsev vlad-perevezentsev 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.

🟢 LGTM · re-checked 333a2b1 · nothing required from @napetrov

🔀 Merge: safe now · merges cleanly into current main, 13 commits behind; its tests and the CLI snapshot test pass on the merge (144 passed) · after it, #1190 and #1416 need a rebase (commands/skill_coverage.py)

✅ make ci-local --offline: 32,499 passed, 125 skipped · ✅ test_skill_coverage_dry_run.py passes with 20 random seeds · ✅ changed-line coverage 98%

The earlier points are fixed; the docs, changelog and refusal output now match what the cap does.

On @vchamarthi's cached-run question I agree with keeping the preflight: the second prompt depends on the first reply, so a cache hit cannot be known before a paid miss.

@napetrov
napetrov merged commit c83e473 into intel:main Dec 2, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli-interface-change Changes dokimi's user-facing CLI surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants