Repository navigation
test(cli): the flag contract checks what a flag means, not only its spelling - #844
Conversation
…pelling The registry compared option strings only. Each use of a canonical spelling is now compared with its registry row: a switch or a value (kind), the metavar when one is set, choices (kind `choice`), and the type for the int, float and usd kinds. Known clashes are listed in MEANING_EXCEPTIONS with a reason; a row that stops clashing fails, as the allowlist does. --judge is a switch in arms run, arms matrix-run and subjects run and a PROVIDER/MODEL elsewhere: the clash issue intel#94 names (sec. 2.4, D10), allowlisted until F1b. --context-framing is declared as a choice, which its parsers already are. No parser, default or help text changes. Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
|
OpenCodeReview: Commit 24c091b was not reviewed. This PR has reached its review limit (6 reviews). CI at `24c091b`: 10 still running, 2 passing, 2 skipped
To review this commit: re-request review from exai-bot in the Reviewers list. <details><summary>Last review (e21e925): no findings</summary> Open threads from the bot: 0 </details> |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #844 +/- ##
==========================================
- Coverage 96.06% 96.05% -0.02%
==========================================
Files 475 475
Lines 62888 62888
Branches 10889 10889
==========================================
- Hits 60414 60407 -7
- Misses 1528 1531 +3
- Partials 946 950 +4
🚀 New features to boost your workflow:
|
vlad-perevezentsev
left a comment
There was a problem hiding this comment.
Review at 5f0fcf6. The meaning check works and runs on the real tree. Every clash it finds today is either fixed in the registry (--context-framing) or listed with a reason. The two gaps are in the line comments, and neither blocks the merge.
What I ran, at 5f0fcf6:
make ci-local --offline: 22,194 passed, 0 failed, 72 skipped; all checks pass.tests/test_cli_flags.pyon this branch merged into currentmainand then with each open PR that touchescli_flags.py(#489, #849, #838, #811, #783): 23 passed every time, so none of them adds a new clash.- I listed every use of a registry flag on the tree to see what each aspect checks.
Checked, no issues
- Exceptions: each one matches a real clash on the tree. A stale row, a row with no reason and a clash with no row each fail the test.
- Metavar: it is compared only when a leaf sets one, which avoids false clashes from argparse's default
DESTmetavar. The docstring says so. - Changelog: an internal-only change, under the right category; no CLI, default or help text changes.
vchamarthi
left a comment
There was a problem hiding this comment.
🟡 Not approved yet · reviewed 5f0fcf6
Next: @napetrov: settle 1 open question (below). 3 nits optional.
Blocking
- Open question for @napetrov:
--timeoutis declaredtextindokimi/dokimi/cli_flags.py:239, butrepo reach,repo runandrepo skill-reachparse it aspositive_intandcatalog trigger-probeasfloat. Give the row the kind the four leaves share, or keeptextand say in thetests/test_cli_flags.pydocstring thattextrows are not type-checked.
Nits
-
dokimi/CONTRIBUTING.md:275– The contributor guide says the ratchet compares spellings only; the test now compares switch or value, metavar, choices and int, float and usd types.Input: the sentence at line 275,
The ratchet compares spellings only: a reviewer checks that the option's type matches the kind of its concept.Head:meaning_clashesintests/test_cli_flags.pyalso compares switch or value, metavar, choices, and the types of int, float and usd rows. Expected: the sentence names what the ratchet compares now and what a reviewer still checks.Suggestion: Replace the sentence with: The ratchet compares spellings, switch or value, metavar, choices, and the int, float and usd types; a reviewer checks the other kinds.
Patch, run on
5f0fcf6: the quoted text is gone; tests are no worse.Patch
--- a/dokimi/CONTRIBUTING.md +++ b/dokimi/CONTRIBUTING.md @@ -272,8 +272,10 @@ - **Snapshot.** From `dokimi/`, after `make dev`, run `make cli-snapshot` and commit `docs/reference/cli-interface.json` with the change. CI's `typecheck` job and `tests/test_cli_flags.py` check it against the code, so a flag change without a - regenerated snapshot fails the PR. The ratchet compares spellings only: a reviewer checks - that the option's type matches the `kind` of its concept. + regenerated snapshot fails the PR. The ratchet compares spellings, and for each use of a + canonical spelling its switch or value, metavar, choices and, for `int`, `float` and `usd` + kinds, its type. A reviewer checks that the type of every other kind matches the `kind` of + its concept. - **Non-canonical spelling.** Only if the flag must keep it, add one row to `tests/data/cli_flags_allowlist.txt` with the reason after `#`, for example `--sample-size # the spelling the external runner already passes`. An allowlist row
Verified on 5f0fcf6: ✅ changed tests: 23 passed, fail on main · ✅ full suite with main merged in: 22223 passed · ✅ merges onto main · 6 mutations tried · 3 edge inputs tried
16 checks behind it, each with its evidence
| Area | What holds | How |
|---|---|---|
| Context-framing row | --context-framing is declared choice, which its parser matches (choices on dokimi/commands/novelty.py:637); declaring it text fails the tree check |
broke the code, tests caught it |
| Int type aspect | Narrowing the int kind to int alone fails the tree check on the positive_int rows |
broke the code, tests caught it |
| Switch aspect | A switch where the kind takes a value, and a value where it takes a switch, is reported; with that check removed the suite fails | broke the code, tests caught it |
| Stale exception row | A MEANING_EXCEPTIONS row that no longer clashes fails; with that check removed the suite fails |
broke the code, tests caught it |
| Empty exception reason | An exception row with a blank reason fails; with that check removed the suite fails | broke the code, tests caught it |
| Exception count | Eleven known clashes are listed in MEANING_EXCEPTIONS, as the description says |
ran it |
| Repeatability | Use has no repeatability field, so a flag's repeatability is not compared, as the description says |
ran it |
| Metavar text | A metavar is compared as exact text: "", " N", "N ", "N\r\n" and "n" each give one metavar clash against N, and "N" gives none |
ran it, edge input (text) |
| Unset metavar | A use with no metavar set (None) gives no metavar clash, so the registry value is not compared for it |
ran it, edge input (none) |
| Tuple metavar | A tuple metavar is joined with a space before the comparison, so ("PROVIDER", "MODEL") clashes with PROVIDER/MODEL |
ran it, edge input (tuple) |
| Banned spellings | A banned spelling is not in the canonical map, so --max-tokens gives no meaning clash, as the description says |
ran it |
| Evidence count | The three flag test files give 110 passed on the head, as the description says | ran it |
| Changed tests | The 23 tests of tests/test_cli_flags.py pass on the head, including the tree-wide meaning check, the leaf-scoped --judge case and the --context-framing row |
tests on the head |
| New tests on main | The tree-wide meaning check and the leaf-scoped --judge case fail on main |
same tests on main |
| Full check run | The full repository check run passes with the PR merged onto main, including the CLI snapshot and mypy, so no flag, default or help text changes | full suite, main merged in |
| Merge | The PR merges onto main with no conflict | merge onto main |
antonwolfy
left a comment
There was a problem hiding this comment.
Review at 5f0fcf6. I found no new problems in the diff. The merge waits for the author's answer to @vchamarthi's question on --timeout: the registry declares it text, four leaves parse it as positive_int or float, and the contract checks none of them.
@vlad-perevezentsev's point that choices is compared only for presence, not for the listed values, also waits for the author's choice between comparing the sets and documenting the gap.
I agree with @vchamarthi's points on the changelog wording, the missing usd/float type case, and the stale sentence at dokimi/CONTRIBUTING.md:275 (outside this diff), which still says the ratchet compares spellings only.
What I ran, on a Linux review host at 5f0fcf6:
make ci-local: 34 passed, 0 failed, 14 skipped; changed-line coverage measured 0 lines (registry data and tests only).tests/test_cli_flags.py: 23 passed. Withtest_cli_flag_moves.pyandtest_cli_skill_catalog_moves.py: 110 passed, as the description says.
Checked, no issues
- Commits: the one commit carries a
Signed-off-by. - Behaviour: the CLI surface dump reports no user-facing change;
--context-framingis declaredchoiceand its parser already passeschoices. - Exceptions: the tree check passes, so each of the eleven rows matches a real clash.
Main replaced usd_amount with cli_types.positive_usd on --max-usd (intel#872), so on the merged tree the flag-meaning check flags eight leaves. Accept positive_usd for the usd kind; usd_amount stays until this branch is on main. The new test fails when positive_usd is dropped or a bare float passes. Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
|
Adds a case where a float row with an int use reports a type clash, so skipping the type comparison for non-int kinds fails the suite. The changelog fragment and the cli_flags docstring say the type is compared for int, float and usd rows only. Signed-off-by: vchamarthi <venkata.sai.gireesh.chamarthi@intel.com>
|
🟡 Waiting on @napetrov · 1 commit on Next: @napetrov: answer the 2 questions below. Changes
Needs @napetrov
Threads and comments
Not this PR's
Verified on the new head: ✅ tests of the fix: 1 passed · What each test shows
|
|
Update at 7ae3cd5 (CI green):
|
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g864am1y Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRR_kwDOVBg7g88AAAABYksuvg.b Thread: PRR_kwDOVBg7g88AAAABYnuUlA.c Thread: IC_kwDOVBg7g88AAAABn5X8Nw.c Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: IC_kwDOVBg7g88AAAABn2Ru9A Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g864am1y Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g864am1y Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
|
Re: review by vlad-perevezentsev
|
|
|
|
|
|
vchamarthi
left a comment
There was a problem hiding this comment.
🔴 Changes needed: 1 must-fix (outside the diff), 1 earlier finding still fails, 1 nit · re-reviewed 9317cdd
Next: @napetrov: fix the 1 must-fix finding and the 1 earlier finding below and answer 1 open thread from vlad-perevezentsev; then push for a re-review. 1 nit optional.
Outside the diff (1): on lines this PR does not change, so GitHub takes no line comment there
-
🔴 Must fix
dokimi/CONTRIBUTING.md:273– A count from 0 declaredintwithnon_negative_int, the type this guide names, is reported as a type clash.Input:
--ndeclared kindintwith parsernon_negative_int, and--rdeclared kindfloatwith parserunit_interval, throughmeaning_clashes. Head: both give a type clash,kind int takes int or positive_intandkind float takes float. Expected: no clash, since this sentence says a count from 0 and a share take their type fromdokimi/cli_types.py. The_TYPES_BY_KINDrows (tests/test_cli_flags.py:156-157) list onlyint,positive_intandfloat, so the guide and the contract disagree.Also at:
dokimi/tests/test_cli_flags.py:156,dokimi/tests/test_cli_flags.py:157.Suggestion: Add
non_negative_intto theintrow andunit_intervalandpositive_fractionto thefloatrow of_TYPES_BY_KIND, or reword this sentence to name only the types the contract takes.Patch, run on
9317cdd: the failing case passes; tests and lint are no worse.Patch
--- a/dokimi/tests/test_cli_flags.py +++ b/dokimi/tests/test_cli_flags.py @@ -153,7 +153,7 @@ # Types a parser may use for each registry kind. A kind not listed takes any type. _TYPES_BY_KIND: Mapping[str, frozenset[str]] = { - "int": frozenset({"int", "positive_int"}), + "int": frozenset({"int", "positive_int", "non_negative_int"}), "float": frozenset({"float"}), "usd": frozenset({"positive_usd", "_usd"}), } @@ -327,7 +327,7 @@ text = [what for _leaf, _option, _aspect, what in meaning_clashes(found, concepts)] assert text == [ "has metavar `SEED`, the registry says `N`", - "has type `str`, kind `int` takes int or positive_int", + "has type `str`, kind `int` takes int or non_negative_int or positive_int", "is a value here, but the registry kind is `flag`", "has no choices, but the registry kind is `choice`", "has choices, but the registry kind is `text`",
Blocking
- Still fails: earlier finding –
--timeoutonrepo reachwith apositive_intparser still gives no type clash on the head, so the question on the--timeoutrow stays open. - Still holds on this head: thread by @vlad-perevezentsev –
--timeout(kindtext) with apositive_intparser onrepo reachgives no type clash on the head, so the four numeric leaves are not checked.
Verified on 9317cdd: ✅ changed tests: 32 passed, fail on main · ✅ full suite with main merged in: 23561 passed · ✅ merges onto main · 2 mutations tried · 1 edge input tried
9 checks behind it, each with its evidence
| Area | What holds | How |
|---|---|---|
| Changed tests on head | The 32 tests in tests/test_cli_flags.py pass on the head, including the tree-wide meaning check and the leaf-scoped --judge case |
tests on the head |
| Changed tests on main | On main, test_every_registered_flag_has_one_meaning_on_the_tree and test_a_new_use_that_clashes_fails_and_an_exception_is_leaf_scoped fail |
same tests on main |
| Merge | The PR merges onto main with no conflict | merge onto main |
| Full repository run | The full repository check run with main merged in passes: 23561 passed, 0 failed | full suite, main merged in |
| Context-framing choice set | Changing the registry value of --context-framing to reference|neutra fails 2 tests, so the tree check pins the choice set |
broke the code, tests caught it |
| Registry value parsing | _registered_choices gives an empty set for "" and " ", and the stripped sets for {ß, x} and native|none\r\n |
ran it, edge input (text) |
| Enumerated choice sets | --delegation registered as native|none, with an extra auto choice on the parser, is reported as a choices clash |
ran it |
| Known clashes | MEANING_EXCEPTIONS lists eleven known clashes |
ran it |
| Flag test files | tests/test_cli_flags.py, tests/test_cli_flag_moves.py and tests/test_cli_skill_catalog_moves.py pass together on the head |
ran it |
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g865L_rR Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRR_kwDOVBg7g88AAAABY4Xo7w.a Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRR_kwDOVBg7g88AAAABY4Xo7w.a Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
|
|
|
|
a397d8d recognizes the numeric converters for counts and shares. The choice regression covers whitespace. The existing author question concerns how to model the four numeric |
Thread: PRRT_kwDOVBg7g866bmqH PRR_kwDOVBg7g88AAAABY4Xo7w.a: Verified that the accepted numeric converter cases still pass, including the recorded float exceptions. The separate timeout question remains open. Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
vchamarthi
left a comment
There was a problem hiding this comment.
@napetrov: fix the 1 earlier finding that still fails, fix what vlad-perevezentsev's thread on dokimi/tests/test_cli_flags.py:159 still finds and settle 1 open question, then push for a re-review. 1 nit in line comments is optional.
- Still fails: earlier finding:
--timeoutonrepo reachwith apositive_intparser gives no type clash and no exception row on the head.
Open threads and questions:
- thread on
dokimi/tests/test_cli_flags.py:159by vlad-perevezentsev: still holds on this head.--timeout(kindtext) is not type-checked on any leaf:repo reachwithpositive_intgives no type clash and has no exception row on the head. - Open question for napetrov: A
choicerow whose value starts with{but does not end with}, such as{warn,fail, gives an empty set, so no choices are compared and no clash is reported (dokimi/tests/test_cli_flags.py:210). Make such a value aregistry_problemserror, or document in a docstring on_registered_choicesthat a value which is neither{...}nora|bis only checked for presence.
Also holding approval:
- The type check reports new errors in the changed files.
Re-reviewed at e21e925: changed tests: 41 passed, fail on main; full suite with main merged in: 24541 passed, its only failures are main's too; merges onto main; 2 mutations and 3 edge inputs tried.
…-844 Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g866c-K0 Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
PRR_kwDOVBg7g88AAAABZiMC4Q.a 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>
vlad-perevezentsev
left a comment
There was a problem hiding this comment.
🟡 Changes needed · re-checked e21e925
To fix: merged with current main the meaning test fails on flags added there since the base (line comment). Also settle --timeout: I answered your question in its thread.
✅ make ci-local --offline: 24,453 passed · schema_compat fails from main's schema changes, not from this PR · ❌ test_cli_flags.py on the merge with main: 6 failed, 153 passed · ✅ --timeout as kind int with one trigger-probe row: 134 passed
The earlier points are fixed; exceptions now pin the value they cover, so a changed choice set is caught.
Agreed with @vchamarthi: an unclosed {warn,fail value is checked only for presence; the native | none trim case.
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Three repo leaves parse positive integer seconds. The catalog probe accepts fractional seconds. Record that one exception so a changed converter on any of the four leaves fails. Thread: PRRT_kwDOVBg7g864am17 PRR_kwDOVBg7g88AAAABZiMC4Q PRR_kwDOVBg7g88AAAABZsl7Mg PRR_kwDOVBg7g88AAAABYnuUlA IC_kwDOVBg7g88AAAABn5X8Nw IC_kwDOVBg7g88AAAABn6pPIw Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
|
|
Re: review by vlad-perevezentsev
|
|
|
|
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
vlad-perevezentsev
left a comment
There was a problem hiding this comment.
🟢 LGTM · re-checked 24c091b · nothing required from @napetrov
🔀 Merge: safe now · merges cleanly into current main, 12 commits behind, and its tests pass on the merge · no open PR conflicts with it; with #1158, #1147 or #1132 on top the meaning test still passes
✅ make ci-local --offline: 27,097 passed · ✅ test_cli_flags.py, test_cli_flag_moves.py, test_docs_code_refs.py on the merge with main: 234 passed
The earlier points are fixed; each exception now pins the value it covers, --timeout included.
Summary
The flag contract (
tests/test_cli_flags.py) now compares what a canonical flag means on every leaf, not only its spelling:--judgeas a switch inarms run,arms matrix-runandsubjects run(CLI API: the evaluation loop at the top level, subject and eval groups below, one enforced flag vocabulary (proposal v2.1) #94 §2.4, D10; F1b moves it to--judge P/M).--context-framingis declaredchoice, since its parser already passeschoices=. The--timeoutcontract checks today’s integer-seconds converters and retains the planned[PHASE=]SECvocabulary from CLI API: the evaluation loop at the top level, subject and eval groups below, one enforced flag vocabulary (proposal v2.1) #94 §2.4. F1b will introduce parsing for the phase prefix.catalog trigger-proberetains its fractional-seconds parser through a leaf-specific exception.--max-tokens) are not meaning-checked here.Evidence
a9d73a27c2(230 tests). Replacing thecatalog trigger-probetimeout converter withstrescaped detection before the fix and now fails the contract. Ruff and mypy both pass on the changed test.run_idis normalised. No parser, default or help change.Merge Danger
Door: two-way. Registry data and a test; no runtime code path changes.
Blast Radius: contributors only. A new flag that clashes with its registry row now fails
test_every_registered_flag_has_one_meaning_on_the_treeuntil it is fixed or listed inMEANING_EXCEPTIONS.Follow-ups:
--judge P/M(#94 F1b); the other clash rows (--from,--format,--arm,--cache,--network,--questions) are F1b work; repeatability and banned-spelling meaning are not checked yet.🤖 Generated with Claude Code