Repository navigation
Description
Problem
id --new is declared with an optional value (num_args = 0..=1), and clap greedily consumes the next token as that value — including when the next token is the subcommand. The documented random-name example therefore does the opposite of what it says:
pkgs/id/src/cli.rs:170-171—#[arg(long, global = true, num_args = 0..=1, default_missing_value = "", value_name = "NAME", conflicts_with = "data_dir")] pub new: Option<String>pkgs/id/src/cli.rs:162-168— the doc examples:id --new my-dev serve --port 0,id --new serve("Random name (auto-generated)"),id --new my-dev list.pkgs/id/src/cli.rs:189-191—command: Option<Command>; "IfNone, the REPL is started."main.rs:147dispatchesNone => run_repl(None).pkgs/id/src/main.rs:88-112— a non-empty--newname creates.iroh/<name>/and bails if it already exists.
So id --new serve creates an instance literally named serve under .iroh/serve/ and starts the interactive REPL — it does not start a server, and it does not use a random name. A second run of the same documented command then fails outright: "instance directory already exists: .iroh/serve (use --data-dir to reuse an existing directory)". The same swallowing hits every bare subcommand: id --new list, id --new id, id --new repl, … all become instance names with no subcommand.
Evidence (verified this run)
Laptop probe (~/git/fleet/probe-2026-10-31-laneA-clap-new/): a minimal clap 4.6.7 derive struct replicating the exact Cli shape (global --data-dir with conflicts_with = "new", global --new with num_args = 0..=1 + default_missing_value = "", and an optional subcommand enum), run against the pinned clap version in pkgs/id/Cargo.lock (clap 4.6.7):
--new serve => new=Some("serve") command=None BUG (documented as random-name serve)
--new my-dev serve => new=Some("my-dev") command=Some(Serve) control, works
--new list => new=Some("list") command=None BUG (any bare subcommand is swallowed)
--new => new=Some("") command=None random name, as intended
--new=serve => new=Some("serve") command=None explicit name via =, expected
serve --new => new=Some("") command=Some(Serve) trailing form works
Coverage gap that let this ship: every --new integration test uses the = form (pkgs/id/tests/cli_integration.rs:3696ff — --new=, --new=test-instance, --new=dup, --new=../escape); no test exercises a space-form --new followed by a subcommand.
Why it matters
--new is the documented way to spin up a throwaway instance, and its own help text gives the broken command as the example. A user following the docs gets an interactive REPL in a directory named after their subcommand instead of a running server, and the leftover .iroh/serve/ directory then makes the same command fail on retry. The failure is silent about the real cause — nothing says the subcommand was eaten as a name.
Acceptance criteria
id --new servebehaves as documented: a randomly-named instance directory is created and theservesubcommand runs. More generally, a bare token that names a subcommand is never consumed as the--newvalue (e.g.--new list,--new idlikewise).- The forms that work today keep working:
--newalone (random name),--new=<name> <cmd>,--new <name> <cmd>(named instance), and a trailing--newafter the subcommand. - Help text / doc examples and the actual parsing agree for every form shown at
cli.rs:152-168. - New integration tests in
pkgs/id/tests/cli_integration.rscover the space forms — at minimum--new serve-style subcommand non-consumption (using a fast subcommand such asid) and--new <name> <cmd>— alongside the existing=-form tests.
Activity
dezren39 commentedon Oct 31, 2026
🤖 Agent note · filed
id --newswallows the following subcommand as the instance name (cli.rs:170-171,num_args = 0..=1), so the documentedid --new serve(cli.rs:165) creates.iroh/serve/and starts the REPL (main.rs:147) instead of serving under a random name, and a repeat run then fails with "instance directory already exists". Verified this run with a minimal clap 4.6.7 probe on the laptop replicating the exact Cli shape (--new serve→ new=Some("serve"), command=None;--new listlikewise;--new my-dev serve, bare--new, and trailingserve --newall correct). Enqueued as a triage packet in queue repo-health-code-pilot.--newvalue) and add space-form integration tests; every existing--newtest uses the=form.dezren39 commentedon Nov 1, 2026
🤖 Agent note · picked up
--newspace-form parser bug and route an implementation packet.--newswallows the subcommand as the instance name — the documentedid --new servecreates .iroh/serve/ and starts the REPL instead of serving under a random name #3144 id(cli): space-form--newswallows the subcommand as the instance name — the documentedid --new servecreates .iroh/serve/ and starts the REPL instead of serving under a random name #31445 remaining items
dezren39 commentedon Nov 1, 2026
🤖 Agent note · handed off
--newswallows the subcommand as the instance name — the documentedid --new servecreates .iroh/serve/ and starts the REPL instead of serving under a random name #3144 completed; implementation follow-up task 5655 is queued inrepo-health-code-pilot.--newsubcommand disambiguation and add integration regressions while preserving existing named/equals forms.--newswallows the subcommand as the instance name — the documentedid --new servecreates .iroh/serve/ and starts the REPL instead of serving under a random name #3144 id(cli): space-form--newswallows the subcommand as the instance name — the documentedid --new servecreates .iroh/serve/ and starts the REPL instead of serving under a random name #3144 · follow-up task 5655dezren39 commentedon Nov 2, 2026
🤖 Agent note · picked up
--newswallows the subcommand as the instance name — the documentedid --new servecreates .iroh/serve/ and starts the REPL instead of serving under a random name #3144: space-form--newswallows the subcommand as the instance name. Make--newdistinguish subcommands from names in pkgs/id/src/cli.rs, with CLI integration regressions in pkgs/id/tests/cli_integration.rs.id --new serve-form tests passing, named/equals forms preserved.fix(id): keep space-form --new from swallowing the subcommand (#3144) (…
dezren39 commentedon Nov 2, 2026
🤖 Agent note · done
--newswallows the subcommand as the instance name — the documentedid --new servecreates .iroh/serve/ and starts the REPL instead of serving under a random name #3144 — space-form--newno longer swallows the subcommand.Cli::normalize_args(pkgs/id/src/cli.rs) rewrites a bare--newfollowed by a top-level subcommand name to--new=before clap parses; subcommand names come from the clap definition itself. main.rs parses through it. Named/equals/bare/trailing forms preserved;--data-diruntouched.--newswallows the subcommand as the instance name — the documentedid --new servecreates .iroh/serve/ and starts the REPL instead of serving under a random name #3144 auto-closed by the PR. Verified on the laptop at head 7fc37e8: 3 new lib parse/normalize tests pass; integrationtest_new_flag*6/6 pass including the 2 new space-form tests. Codex review on PR fix(id): keep space-form --new from swallowing the subcommand (#3144) #4326 completed with no findings. One pre-existing local failure noted on the PR: lib testtest_cli_parse_world_new_and_statsstack-overflows in this laptop's libtest setup on unmodified branch state too.