fix: reject unknown --flag in positional args#366
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…nknown-flag-guard # Conflicts: # ai.txt # skills/ilo/SKILL.md
The rerun8 personas typed `--engine tree` expecting it to be a flag (it had been clap-known but undocumented), then hit silent-consume traps when the value was misinterpreted. The canonical surface is the `--run-*` convenience flags; `--engine` should fall through to the unknown-flag guard. Replace #[arg(long, ...)] with #[arg(skip)] so the field still exists for internal construction sites but is no longer exposed on the CLI.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Six rerun8 personas (ab-tester, routing-tsp, content-mod, qa-tester, interactive-cli, security-researcher) independently burned minutes on the same trap:
ilo main.ilo --engine treesilently consumed--engineas a positional arg (becauseCli::argsandRunArgs::restusetrailing_var_arg = true, allow_hyphen_values = true), then surfaced misleadingILO-R012 no functions definedorILO-R004 main: expected N args, got N+1further down the line.This guard rejects any clean long-flag shape (
--wordor--word-with-dashes) in the positional tail with a clear, actionable error and exit code 1. The--separator escapes through hyphen-prefixed literal args.Repro
Before:
After:
What's in the diff
src/cli/args.rs—reject_unknown_flags+reject_unknown_flags_with_allowlisthelpers, with 10 unit tests covering every accept/reject path (clean flags, hyphenated,--separator,--key=val, trailing/doubled dashes, negative numbers).src/main.rs— guard at top ofdispatch_run(catchesCmd::Run(r).restand the bare-args path's final rest); guard at top ofdispatch_bare_argssource-slot detection (catchesilo --engine tree main.ilostyle mis-placements); first--separator stripped fromr.restso it doesn't reach the program as a positional arg.tests/regression_unknown_flag_guard.rs— 19 cross-engine integration tests covering bare path,runsubcommand path,--escape, recognised flags still working, all four engines respecting the guard, negative-number and--key=valdata shapes not flagged.examples/unknown-flag-guard.ilo— minimal example exercised by the engine harness.SPEC.md,ai.txt,skills/ilo/SKILL.md— CLI section gains the unknown-flag-guard rule +--escape doc.site/src/content/docs/docs/reference/cli.md(separate repo, already pushed) — mirrored.Test plan
--run-tree,--run-vm,--run-cranelift.--run-vm,--run-tree,--bench,--dense, etc.) still parse cleanly.--separator correctly strips and passes literal--foothrough as a program arg.-1,-3.14) and--key=valshapes still pass through as data.Follow-ups
None — single-purpose fix.