Skip to content

feat(parse): support non-strict choices - #1127

Merged
jdx merged 1 commit into
agent/combination-coveragefrom
agent/non-strict-choices
Aug 21, 2026
Merged

feat(parse): support non-strict choices#1127
jdx merged 1 commit into
agent/combination-coveragefrom
agent/non-strict-choices

Conversation

@jdx

@jdx jdx commented Aug 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • add choices strict=#false and typed choices_strict = false declarations
  • retain known values in help, completion, KDL, and generated metadata while accepting other values
  • carry the policy through usage-lib, usage-argv tables/derive, JSON-to-Go lowering, and generated Go
  • reject non-strict ValueEnum declarations because an unknown word cannot construct an enum variant
  • document the feature, update the clap matrix, and close the PLAN gap

Verification

  • mise run ci
  • focused Rust and Go conformance tests

Note

Medium Risk
Changes post-parse choice validation across Rust and Go parsers. Default remains strict, so existing CLIs are unaffected unless they opt in.

Overview
Adds non-strict choices: declared values remain suggestions for help and completion, while values outside the list are accepted. Strict validation stays the default.

KDL uses choices strict=#false …; the derive uses choices_strict = false on a string-like field with choices(...). The policy is carried through usage-lib, argv metadata, generated Go tables, and KDL emission. Combining it with value_enum is a compile error, since an unknown word cannot construct an enum variant.

Docs and the clap matrix record this as usage-only (clap#5885).

Reviewed by Cursor Bugbot for commit 434930e. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: df86c7dd-6394-4a3d-b434-f8aa274f309c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jdx
jdx force-pushed the agent/non-strict-choices branch from a0d294d to 26a9fe2 Compare August 20, 2026 12:51
@jdx
jdx force-pushed the agent/non-strict-choices branch from 26a9fe2 to a0c35ce Compare August 20, 2026 12:56
@jdx
jdx force-pushed the agent/non-strict-choices branch from a0c35ce to 8a4d8e5 Compare August 20, 2026 13:02
@jdx
jdx force-pushed the agent/non-strict-choices branch from 8a4d8e5 to a5852ac Compare August 20, 2026 13:06
@jdx
jdx force-pushed the agent/non-strict-choices branch 2 times, most recently from 91805ce to 0c409bd Compare August 20, 2026 13:31
@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Instruction counts

benchmark trend instructions Δ wall (min) Δ
markdown █▁▁▃ 199,315,003 → 201,371,612 +1.03% ⚠️ 19.00 → 18.75ms -1.31%
startup ▁▇▇█ 1,221,718 → 1,223,027 +0.11% 1.35 → 1.36ms +1.07%

1 benchmark(s) above the 1% gate: markdown +1.03%

Only instruction counts gate. Wall clock is shown for context — on identical hardware it moves 4-20% run to run.

Measured by tak — instruction-counted CLI benchmarks, stored in this repository's git notes.

Shadow comparison

Parsing mise use -g node@20 against a shadow of mise's committed spec.
Reported, not gated: the shadow grows as the derive learns to express more, so
what to watch is the ratio rather than either column.

framework instructions, cold parse vs usage
usage 4353
argh 6292 1.4x
clap 5893640 1353x
bpaf 21917948 5035x
                                              min       p01       p10    median
usage-rs: argv -> struct                      188       190       192       196  ns
argh: argv -> struct                          266       270       274       283  ns
clap: build tree + parse -> struct         472537    473456    477256    483644  ns
bpaf: build parser + parse -> struct      1588358   1588358   1601092   1646566  ns

usage: argv -> struct                             202 ns      0.20 µs
clap: build tree + parse -> struct             489659 ns    489.66 µs
clap: parse -> struct, tree reused              23054 ns     23.05 µs
clap: build tree only                          305124 ns    305.12 µs

434930e53568 vs c10d85cbe1b9 · measured on the runner, not pushed to the history.

@jdx
jdx force-pushed the agent/non-strict-choices branch from 0c409bd to 6f7ee6f Compare August 21, 2026 01:50
@jdx
jdx force-pushed the agent/non-strict-choices branch from 6f7ee6f to 8439fec Compare August 21, 2026 03:15
@jdx
jdx force-pushed the agent/non-strict-choices branch 2 times, most recently from dc24d1e to 5226b58 Compare August 21, 2026 03:20
@jdx
jdx force-pushed the agent/non-strict-choices branch 2 times, most recently from 2b59c67 to f7d2009 Compare August 21, 2026 03:43
@jdx
jdx force-pushed the agent/non-strict-choices branch from f7d2009 to 2b59c67 Compare August 21, 2026 03:49
@jdx
jdx force-pushed the agent/non-strict-choices branch from 2b59c67 to 60f0908 Compare August 21, 2026 04:10
@jdx
jdx force-pushed the agent/non-strict-choices branch from 60f0908 to 016c904 Compare August 21, 2026 04:19
@jdx
jdx force-pushed the agent/non-strict-choices branch from 016c904 to b13e3b7 Compare August 21, 2026 04:40
@jdx
jdx force-pushed the agent/non-strict-choices branch 2 times, most recently from 016c904 to b13e3b7 Compare August 21, 2026 04:43
@jdx
jdx force-pushed the agent/non-strict-choices branch from b13e3b7 to a8d5eaf Compare August 21, 2026 05:02
@jdx
jdx force-pushed the agent/non-strict-choices branch from a8d5eaf to 434930e Compare August 21, 2026 05:36
@jdx
jdx merged commit 4ddee55 into main Aug 21, 2026
9 of 10 checks passed
@jdx
jdx deleted the agent/non-strict-choices branch August 21, 2026 09:18
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.

1 participant