Skip to content

feat(parse): preserve trailing delimiters - #1098

Merged
jdx merged 1 commit into
agent/token-boundary-controlsfrom
agent/trailing-delimiter-policy
Aug 20, 2026
Merged

jdx merged 1 commit into
agent/token-boundary-controlsfrom
agent/trailing-delimiter-policy

Conversation

@jdx

@jdx jdx commented Aug 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • add an inherited dont_delimit_trailing_values command policy to KDL and typed Rust metadata
  • preserve delimited values after -- and on automatic trailing positionals across usage-lib, usage-argv, and generated/direct Go
  • carry the clap setting without a fidelity loss and document the portable behavior
  • mark the PLAN gap complete and add shared corpus/conformance coverage

Validation

  • cargo test --all --all-features
  • cd go && go test ./...
  • mise run lint
  • mise run gen-shadow
  • mise run gen-go
  • mise run render

This PR was generated by Codex.


Note

Medium Risk
Changes core argv binding and delimiter handling in Rust and Go across derive, parsers, and generated code; behavior is well covered by tests but mistakes could affect many CLIs that use delimiters or trailing -- forwarding.

Overview
Implements clap's dont_delimit_trailing_values as an inherited, command-wide policy that round-trips through KDL, usage-lib, the typed derive, usage-argv, generated Go, and the clap bridge (no longer a fidelity loss).

Parsing behavior: After -- or once an automatic trailing positional starts, variadic positionals stop splitting on delimiter (e.g. a,b -- c,da, b, c,d). Ordinary tokens before that boundary still split. Subcommands inherit the policy from ancestors.

API shift: Event::Arg gains a delimit flag; Rust derive and Go binders honor it when expanding values (and drop the derive's old post-check delimiter split pass). Go also threads Delimiter on flags/args, counts delimited pieces for variadic flags, and uses SplitValue in conformance and generated parsers.

Docs, PLAN, corpus, and conformance tests cover inheritance and KDL round-trip.

Reviewed by Cursor Bugbot for commit 616fcfc. 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: 36f7e301-ddea-4092-b2b1-89187ed2ca98

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.

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 054db7f. Configure here.

Comment thread go/argv/parser.go
@jdx
jdx force-pushed the agent/trailing-delimiter-policy branch from 054db7f to 616fcfc Compare August 20, 2026 01:31
@jdx
jdx merged commit 1cfb2f5 into main Aug 20, 2026
9 checks passed
@jdx
jdx deleted the agent/trailing-delimiter-policy branch August 20, 2026 01:52
@github-actions

Copy link
Copy Markdown
Contributor

Instruction counts

benchmark trend instructions Δ wall (min) Δ
markdown ██▁ 198,671,176 → 195,983,569 -1.35% 18.71 → 18.86ms +0.80%
startup ▁▁█ 1,217,543 → 1,218,362 +0.07% 1.34 → 1.39ms +4.25%

No instruction-count regression above 1%.

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 4340
argh 6292 1.4x
clap 5893640 1357x
bpaf 21917948 5050x
                                              min       p01       p10    median
usage-rs: argv -> struct                      212       215       218       222  ns
argh: argv -> struct                          269       273       278       286  ns
clap: build tree + parse -> struct         480151    480502    482458    484822  ns
bpaf: build parser + parse -> struct      1573559   1573559   1583532   1606631  ns

usage: argv -> struct                             218 ns      0.22 µs
clap: build tree + parse -> struct             491489 ns    491.49 µs
clap: parse -> struct, tree reused              23413 ns     23.41 µs
clap: build tree only                          301668 ns    301.67 µs

616fcfc30619 vs 83ed87bb9e8f · measured on the runner, not pushed to the history.

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