Skip to content

feat(argv,derive): add compiled clause support - #1320

Open
jdx wants to merge 6 commits into
feat/spec-clause-interpreterfrom
feat/compiled-clauses
Open

feat(argv,derive): add compiled clause support#1320
jdx wants to merge 6 commits into
feat/spec-clause-interpreterfrom
feat/compiled-clauses

Conversation

@jdx

@jdx jdx commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • add clause tables and boundary events to the zero-allocation argv parser
  • support typed Vec clause fields through usage derive
  • add equivalent Go parser, spec-lowering, and generated-table support
  • extend the shared corpus so interpreted Rust, compiled Rust, and Go agree
  • report clause addition, removal, and separator changes as breaking in usage diff

Stack

Test plan

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

AI-assisted — Tool: Codex; model: OpenAI/GPT-5; version: unavailable.


Note

Medium Risk
Touches core positional parsing, derive codegen, and Go-generated binders; mistakes could mis-split repeated positionals or break compatibility detection, though coverage is broad.

Overview
Adds repeatable clause parsing: a command can own one separator-delimited positional group (e.g. :::) whose inner arguments reset on each boundary instead of overwriting the previous instance.

The Rust argv parser gains Command::clause, Event::ClauseSeparator, and positional routing through clause args; separators stay syntax after double_dash="automatic" unless protected by --. Help, completions, and KDL emission treat clause positionals like ordinary args for listings and usage (including the repeatable [separator …]… pattern).

usage derive supports #[usage(clause, separator = "…")] on Vec<T> (T: Args) with partial state, separator handling in apply, and per-instance build. Go mirrors the same behavior in argv, help, spec lowering, and generated Parse (per-instance validation and []Clause fields). Conformance and a new corpus section assert matching clauses maps across interpreted Rust, compiled Rust, and Go.

usage diff flags adding, removing, or changing a clause separator as breaking.

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

@coderabbitai

coderabbitai Bot commented Aug 25, 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: 091cb5ec-7fdb-4abc-8ead-d8db685d2e5d

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.

Comment thread argv/src/lib.rs
Comment thread derive/src/codegen.rs
Comment thread cli/src/cli/diff.rs
Comment thread derive/src/model.rs
Comment thread argv/src/complete.rs
@jdx
jdx force-pushed the feat/compiled-clauses branch from 24d040a to 911cc4c Compare August 25, 2026 17:41
@jdx
jdx force-pushed the feat/compiled-clauses branch from 911cc4c to 20207e5 Compare August 25, 2026 17:54
Comment thread go/argv/parser.go
@jdx
jdx force-pushed the feat/compiled-clauses branch from 20207e5 to e3f365e Compare August 25, 2026 18:00
@jdx
jdx force-pushed the feat/compiled-clauses branch from e3f365e to b79b9c2 Compare August 25, 2026 18:15
@jdx
jdx force-pushed the feat/compiled-clauses branch from b79b9c2 to eb1cdf8 Compare August 25, 2026 18:17
@jdx
jdx force-pushed the feat/compiled-clauses branch from eb1cdf8 to a86bd3f Compare August 25, 2026 18:27
Comment thread derive/src/model.rs
@jdx
jdx force-pushed the feat/compiled-clauses branch from a86bd3f to ca197ee Compare August 25, 2026 18:32
Comment thread argv/src/complete.rs
@jdx
jdx force-pushed the feat/compiled-clauses branch from ca197ee to f2ed8d7 Compare August 25, 2026 18:45
@jdx
jdx force-pushed the feat/compiled-clauses branch 2 times, most recently from 1304064 to 64a99e6 Compare August 25, 2026 19:00
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Instruction counts

benchmark trend instructions Δ wall (min) Δ
markdown ▁█ 341,631,291 → 341,678,724 +0.01% 31.73 → 28.91ms -8.89%
startup █▁ 910,819 → 908,110 -0.30% 0.98 → 0.89ms -9.26%

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 stripped binary, bytes
usage 1340672
bpaf 2493280
clap 3101832
framework instructions, cold parse vs usage
usage 8523
clap 6315248 740x
bpaf 21909169 2570x
                                              min       p01       p10    median
usage-rs: argv -> struct                      428       431       434       446  ns
clap: build tree + parse -> struct         514148    515132    518519    525164  ns
bpaf: build parser + parse -> struct      1590042   1590042   1596910   1608187  ns

usage: argv -> struct                             435 ns      0.44 µs
clap: build tree + parse -> struct             532922 ns    532.92 µs
clap: parse -> struct, tree reused              24004 ns     24.00 µs
clap: build tree only                          325144 ns    325.14 µs

8b8f0ff4ffeb vs 7db6c6c30649 · measured on the runner, not pushed to the history.

@jdx
jdx force-pushed the feat/compiled-clauses branch from 64a99e6 to e173603 Compare August 25, 2026 20:21
@jdx
jdx force-pushed the feat/compiled-clauses branch from e173603 to 22683bd Compare August 25, 2026 20:41
@jdx
jdx force-pushed the feat/compiled-clauses branch from 22683bd to 1e0e644 Compare August 25, 2026 20:48
@jdx
jdx force-pushed the feat/compiled-clauses branch from 1e0e644 to 80ff8a9 Compare August 25, 2026 20:59
@jdx
jdx force-pushed the feat/compiled-clauses branch 2 times, most recently from b3c69b6 to bf7076a Compare August 25, 2026 21:26
Comment thread lib/src/go/mod.rs
@jdx
jdx force-pushed the feat/compiled-clauses branch 2 times, most recently from 80a14ec to 679b346 Compare August 27, 2026 12:59
@jdx
jdx force-pushed the feat/compiled-clauses branch from 679b346 to cb0c4b8 Compare August 27, 2026 13:04
Comment thread go/argv/argv.go
Comment thread lib/src/go/mod.rs

@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 4451efa. Configure here.

Comment thread lib/src/go/structs.rs
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