Skip to content

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

Merged
jdx merged 8 commits into
feat/spec-clause-interpreterfrom
feat/compiled-clauses
Aug 28, 2026
Merged

feat(argv,derive): add compiled clause support#1320
jdx merged 8 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
Changes core positional parsing and completion cursor rules across Rust and Go; spec clause changes are intentionally breaking, but behavior is covered by new corpus and conformance tests.

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

The argv parser gains Command.clause, a ClauseSeparator event, and positional binding through the clause’s inner args (including after restart tokens and when automatic -- stops flags). Completions, help/usage, and spec emission now treat clause positionals like ordinary args, with usage showing a repeatable [separator …]… pattern.

Derive supports #[usage(clause, separator = "…")] on Vec<T> (T: Args) with partial/build/apply wiring; Go mirrors the same parser, help, spec lowering, and generated Parse structs. Conformance and a new corpus section expect a clauses map of per-instance arg bindings; usage diff marks clause add/remove/separator changes as breaking.

Reviewed by Cursor Bugbot for commit 8703b56. 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: ceac0ba9-7b9f-4070-a957-e38bc3ad91da

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,669,288 → 341,722,706 +0.02% 28.58 → 28.92ms +1.19%
startup █▁ 908,601 → 908,017 -0.06% 0.90 → 0.86ms -4.06%

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                      429       434       439       447  ns
clap: build tree + parse -> struct         515041    516240    519114    524091  ns
bpaf: build parser + parse -> struct      1571372   1571372   1576426   1593168  ns

usage: argv -> struct                             481 ns      0.48 µs
clap: build tree + parse -> struct             529092 ns    529.09 µs
clap: parse -> struct, tree reused              23275 ns     23.27 µs
clap: build tree only                          323494 ns    323.49 µs

8703b562b08a vs af6ee72adaaa · 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 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
Comment thread lib/src/go/structs.rs
@jdx
jdx force-pushed the feat/compiled-clauses branch from 8b8f0ff to 32a77b0 Compare August 28, 2026 12:35
@jdx
jdx force-pushed the feat/compiled-clauses branch 2 times, most recently from d2a6d4b to ecc3ce3 Compare August 28, 2026 13:19

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

Comment thread argv/src/complete.rs
@jdx
jdx force-pushed the feat/compiled-clauses branch from ecc3ce3 to 8703b56 Compare August 28, 2026 13:45
@jdx
jdx merged commit eb52253 into main Aug 28, 2026
12 checks passed
@jdx
jdx deleted the feat/compiled-clauses branch August 28, 2026 14:14
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