fix(cli): keep usage explain from running a spec's choices run= commands - #1503
Conversation
`usage explain` promises never to start another program: a spec file that arrived with a bug report should not run its commands on the machine of whoever explains a line against it. Mounts were already answered without running anything, but #1497's `choices run=` ran its command to check a value. Parser gains `without_running_commands()`, which explain now uses: a value the declared choices don't accept is bound unchecked, and help describes the command instead of listing its output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 4 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe parser now supports skipping ChangesChoice command execution
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant Parser
participant NoRunScope
participant run_choices
participant ChoiceValidation
Parser->>NoRunScope: Enter scope when command execution is disabled
Parser->>run_choices: Resolve run= choices
run_choices->>NoRunScope: Check whether runs are disabled
run_choices-->>ChoiceValidation: Return shell error without executing command
ChoiceValidation-->>Parser: Ignore choice-check failure for run= choices
Merge Risk: ⚪ Minimal · up to The reviewed change is mergeable after normal checks; no actionable risk remains identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
|
https://entire.io/gh/jdx/usage/trails/51
usage explainanswers "what would this command line bind to?" without running anything, and it promises that in the code: a spec file that arrived with a bug report shouldn't be able to run its commands on the machine of whoever explains a line against it. Mounts were already answered from injected outputs instead of being run. Butchoices run=(#1497) runs its command during parse-time validation, sousage explainran it too:Before:
usage explain -f spec.kdl m nopecreated/tmp/ran. After: nothing runs, and the report shows<svc> = "nope"bound from argv with no error. The value is let through unchecked, because only the command could say whether it's valid, and explaining must not ask it. Values the declared choices list are still checked as usual.Library:
Parser::without_running_commands()is new. With it set, achoices run=command never starts duringparse,explainorexplain_refused. A value outside the declared choices is accepted unchecked, and a help page reached through the parse describes the command instead of listing its output. Parsing without it is unchanged.usage explainnow uses it. Mounts are unaffected; they keep their existing injected-output handling. The MCP server only describes commands and never parses a command line, so it never ran these commands.Tests:
a_parser_told_not_to_run_commands_never_does(lib) anda_choices_command_is_never_run_to_answer_a_report(usage explain) check with a marker file that the command never ran. Both fail without the fix. Both are Unix-only, like the other command-running tests.cargo test --all --all-featuresandmise run lintpass.This was raised by Greptile's review of #1498, which is where the merged #1497 code showed up in its view.
🤖 Generated with Claude Code
Note
Medium Risk
Changes parse-time validation semantics for callers using
without_running_commands(); default parsing behavior is unchanged, but explain now may report values as bound that a real run would reject.Overview
usage explainno longer executeschoices run=shell commands when building a binding report. It now parses throughParser::without_running_commands(), matching the existing mount policy: inspect a line without side effects from untrusted specs.The library adds
Parser::without_running_commands()and a thread-localNoRunScope. While active,run_choicesrefuses to spawn processes; strict validation skips errors that would require command output, so argv values outside the static choice list are accepted unchecked (help text describes the command instead of listing its output). Declared static choices and mount injection behavior are unchanged when the flag is not set.Tests (Unix): marker-file checks in
explainandchoices_runassert therun=command never runs under explain / no-run parsing.Reviewed by Cursor Bugbot for commit eb0f6d1. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
explaincommand can now report choice values without runningchoices run=commands, avoiding their side effects during explanations.