Repository navigation
Description
Context & Rationale
Paths are under src/devops_cli/ unless they start with tests/ or docs/. Evidence was checked at ef21785.
How dry-run reaches a command today
- Every command group is registered lazily.
main.py:179-180passes each_COMMAND_SPECSentry (main.py:32-70) toOTelTyper.add_typeras amodule:appstring, and that branch registers a proxy command (core/cli.py:121-151). - Under dry-run, the proxy prints
Would run delegated command: devops <group> <args>(lang/en/messages.py:509-511). It then returns before importing the module (core/cli.py:129-134). - Two forms take that path:
devops --dry-run …, and an exportedDEVOPS_CLI_DRY_RUN(main.py:216-218;tests/test_main_dry_run.py:12-28,:44-66). - The trailing form
devops <group> <cmd> --dry-runbehaves differently:entry.py:36-37turns dry-run on;- the root callback turns it off again, because this process set it (
main.py:216-217,dry_run/state.py:28-35); - the proxy delegates, and the command parses
--dry-runas its own option (tests/test_main_dry_run.py:31-41).
- MCP tools use the trailing form (
ai/mcp/server.py:521-522and others).
What is reachable
I walked typer.main.get_command for every _COMMAND_SPECS module, leaving out the tui, format and lint aliases. That gives 418 leaf command paths and 361 distinct leaf callbacks.
- 112 declare their own
--dry-run.- The trailing form reaches them. The global form prints only the generic line.
- So
devops repos sync --dry-runpreviews, anddevops --dry-run repos syncdoes not. - Four group callbacks also declare it:
ci,scan,ai benchmarkanddashboard(aliastui). With them, 116 callbacks and 123 command paths declare--dry-run.
- 75 have a dry-run branch in their body but no
--dry-runoption. The branch is anis_dry_run()check,render_dry_run_resultor@dry_run_command.- No form reaches them. The global form short-circuits, and the trailing form fails with
No such option: --dry-run(exit 2). I confirmed this fork8s configure-urls,tf applyandrelease sync-notes. - They span 24 modules: tf has 12, argo 7, release 6 and ssh 5.
- They include
tf applyandtf destroy(apply's branch is atcommands/tf.py:205-211),k8s deploy-stack,k8s teardown-stack,release tag,release sync-notes,docker push,docker prune,ssh rotateandvault login. - I ran all 75 under
DEVOPS_CLI_DRY_RUN=1with process creation replaced by a recorder, sockets blocked and HOME isolated. 52 rendered their preview. 23 needed arguments or a repository and did not finish. None started a process.
- No form reaches them. The global form short-circuits, and the trailing form fails with
- 174 have neither, so they have no preview to reach. This check reads only the command's own source, so a command that handles dry-run only inside helpers counts here.
Unreachable previews go stale
k8s configure-urlsonce previewed eight hardcoded minikube NodePort URLs. v0.2.22 rewrote that preview (cb75261,commands/k8s/networking.py:559-576).- Its branch (
networking.py:870-876) is still unreachable from the CLI.
The short-circuit is load-bearing
- Under dry-run,
run_subprocessprintsWould run commandand then runs the command anyway (core/process.py:235-236, then:266; the async version is at:376-377, then:409). refactor(cli): one process runner owns execution, process groups and dry-run #775 tracks this. - Forwarding makes
devops --dry-run <cmd>do whateverdevops <cmd> --dry-rundoes. Some commands act under their own flag:- With
subprocess.runrecorded,devops ci lint --dry-runreachesuv … run ruff check . --fix(commands/ci.py:883-893,:172-185). 12cisubcommands reached their tool the same way, andci runreached the async runner. The split-off fix(ci):devops cichecks run for real under their own--dry-run#885 (devops cichecks run for real under their own--dry-run) fixes these. review path <file> --dry-runwrites a review session._execute_review_workflowbuildsReviewPipelineOrchestratorbefore any dry-run check (ai/review/runner.py:2142). Its constructor creates the session directory (ai/review/pipeline.py:1415-1420). The report step writesfindings.json,candidates.jsonandreview.md(pipeline.py:3600-3627). WithDEVOPS_CLI_DATA_DIRisolated, one run wrotereviews/<id>/with three "[DRY-RUN] Simulated" findings.runner.py:1268skips the session directory only in the persona loop.ai benchmark --dry-runsaves<id>-benchmark.jsonwith"is_dry_run": true(ai/benchmark/runner.py:566,:955-961).
- With
- The probes so far recorded process starts only, not file writes. They ran the declaring commands without arguments, so 40 of 120 paths did not finish, and they skipped
dashboard,serveandtui. devops --dry-run lintanddevops --dry-run review path .are safe today only because of the short-circuit.tests/test_main_dry_run.py:44-51records what a dry-run that ran costs. Async-notes --allmeant as a preview republished every release description.
Where the forwarded flag lands matters
- 26 call sites in 6 command modules run
set_dry_run(dry_run)with the command's own option, for examplecommands/sandbox.py:138andcommands/review.py:289. If the forwarded--dry-rundoes not reach the option, they turn dry-run off. - Click treats everything after
--as an argument. Forsandbox deploy(commands/sandbox.py:101-102),deploy -- sh -c true --dry-runparses asdry_run=False, with--dry-runinside the container command.deploy --dry-run -- sh -c trueparses asdry_run=True. - So appending the flag at the end would make
devops --dry-run sandbox deploy -- sh -c truedeploy for real.
The proxy also never resolves the command
- An unknown command passes under dry-run.
devops --dry-run repos statusexits 0 with the generic line, whiledevops repos statusexits 2 withNo such command 'status'. tests/test_all_commands_help_dryrun.py:23, 25, 28-29andtests/test_repos.py:1035-1037assert exit 0 forrepos status,argo listandargo status. None of these commands exists.--helpunder the global flag prints the generic line instead of the help.
Scope & Deliverables
- Deliverable:
- One rule: a command previews only if it declares
--dry-run. - Proxy routing under dry-run (
core/cli.py:126-139). The proxy resolves the target command and parses its arguments without invoking it. Then:- if the command declares
--dry-runand the parsed value is already true, the proxy delegates the arguments unchanged; - if it declares
--dry-runand the parsed value is false, the proxy inserts--dry-rundirectly after the command path, before any other argument, so a--separator cannot swallow it. The global flag stays on; - if it does not declare it, the proxy prints the generic line, as today;
- if the command does not resolve or its arguments do not parse, the proxy shows that usage error and exits with its code. It never delegates a command it could not resolve and parse;
-h/--helpgoes to_delegate's help fast path (main.py:90-97);- the
formatandlintaliases resolve toci formatandci lint(main.py:86).
- if the command declares
- Each of the 75 branch-only commands declares
dry_run: Annotated[bool, typer.Option("--dry-run", help=HELP.options.dry_run)] = False. This is the existing convention, for examplecommands/kustomize.py:56.- Its branch tests
dry_run or is_dry_run(). It never callsset_dry_run(dry_run). @dry_run_commandalready reads adry_runargument (dry_run/decorator.py:43-44), so commands that use it only gain the option.- Before adding the option, the builder checks that the branch returns before any write, mutating subprocess or mutating API call.
- Its branch tests
- An invariant test. It reuses the import walk in
tests/test_all_commands_help_dryrun.py:84-104and asserts two things:- every command reachable from
_COMMAND_SPECSwhose callback referencesis_dry_run,render_dry_run_resultordry_run_commanddeclares--dry-run; - every callback that declares
--dry-runreads itsdry_runparameter, or is wrapped by@dry_run_command. All 116 declaring callbacks do at ef21785.
- every command reachable from
- A one-off recorder sweep, outside the gate. Run every command that declares
--dry-runafter this change once, with valid arguments, process creation recorded, sockets blocked, and HOME andDEVOPS_CLI_DATA_DIRin a temp directory. Record the processes started and the files written in the task file. - Update every test that relied on the short-circuit:
tests/test_main_dry_run.py;tests/test_all_commands_help_dryrun.py:21-31and:57-58;tests/test_repos.py:1001-1004,:1014-1018and:1035-1037;tests/test_rag_cli.py:20-33;tests/test_grafana.py:36-40;tests/test_ai_subcommands_rag.py:37-43,tests/test_argo.py:206andtests/test_prometheus.py:107;- any other test that invokes
main.appwith a leading--dry-run.
- Docs and records:
HELP.main.dry_run(lang/en/help.py:12-15) states the rule;docs compact(commands/docs.py:279-280, option help at:337) stops reusing that string and usesHELP.options.dry_run;docs/SDLC.md:145states the rule instead of requiring@dry_run_command;- regenerate
docs/CLI_REFERENCE.mdanddocs/commands/; - add a CHANGELOG entry;
- rewrite the task file
docs/agent/tasks/task-412-reachable-dry-run-previews-for-delegated-commands.md, which still says v0.2.24 and Backlog.
- One rule: a command previews only if it declares
- Acceptance criteria:
devops --dry-run k8s configure-urlsanddevops k8s configure-urls --dry-runboth print the JSON preview with"command": "devops k8s configure-urls"and"action": "configure_monitoring_urls", and exit 0. Verified by a test that runs the real_delegatewithsave_settingsand process creation patched to fail.tf apply <tmp dir>,tf destroy <tmp dir>,k8s teardown-stackanddocker pruneexit 0, render their preview and start no process, in both the global form and the trailing form. Verified the same way, with the tf binary lookup and the Docker engine (commands/docker.py:196) also patched to fail.- For
repos sync,branches cleanand thelintalias,devops --dry-run <cmd>passes_delegatethe same arguments asdevops <cmd> --dry-run.devops --dry-run repos sync --dry-runpasses--dry-runonce. Verified with_delegatepatched, intests/test_main_dry_run.py. devops --dry-run sandbox deploy -- sh -c truepasses_delegate["deploy", "--dry-run", "--", "sh", "-c", "true"].devops --dry-run sandbox deploy -- tool --dry-runalso gets--dry-runbefore--. Verified with_delegatepatched. Both tests fail if the flag is appended at the end or if its presence is checked by searching the argument list.DEVOPS_CLI_DRY_RUN=1 devops repos syncdelegates the same way asdevops --dry-run repos sync. This test replaces thecalled == Falseassertion attests/test_main_dry_run.py:66.devops --dry-run config set ai.provider ollamaprintsWould run delegated command: devops config set ai.provider ollamaand exits 0, and_delegateis not called. Verified by a test.devops --dry-run repos statusexits 2 withNo such command 'status', anddevops --dry-run repos --unknown-optionexits 2. Verified by tests. The cases for the non-existent commandsrepos status,argo listandargo statusare replaced by commands that exist.devops --dry-run k8s --helpprints the k8s help and exits 0. Verified by a test.- The invariant test fails on ef21785, listing 75 callbacks, and passes after the change. A fixture callback that declares
--dry-runand never reads it also fails the test. - The task file has one row for each command that gained
--dry-run. Each row says what runs before the command's branch and gives the verdict. - The task file records the sweep. It shows no command that starts a mutating process, or writes outside its temp directories, under its own
--dry-run. The reviewer checks this in the PR. - The new and changed tests add at most 1 s to the test step. Measure with
pytest --durations=0on the touched test files, before and after, and record both figures in the task file. uv run devops docs checkanduv run devops cipass.
- Key questions:
- Should every command be classified first, and the switch flipped last, as the first draft planned? No (proposed). Route per command, and default to the generic line. Then a command the audit misses keeps printing a harmless line instead of running. Classifying the commands that have no preview is the split-off.
- Should a marker decorator or a declared
--dry-runoption say that a command previews? The option (proposed). 112 commands already follow that convention. It shows in--helpand indocs/CLI_REFERENCE.md, MCP can pass it, and the trailing form works too. With a marker,devops tf apply --dry-runwould still fail withNo such option. - Should the proxy clear the global flag when it forwards, so the result matches the trailing form exactly? No (proposed). If the flag stays on, helper-level guards such as
k8s/logs.py:28also apply. It does not protect a command that runsset_dry_run(dry_run), which is why the next answer matters. - Where does the forwarded flag go? Directly after the command path, and only when the parsed value is false (proposed). Appended at the end, it lands after a
--separator andsandbox deployruns for real. Reading the parsed value, not searching the argument list, also stops a--dry-runinside a passed-through command from counting as the command's own. - How does the proxy find the command? With fix(mcp): mcp tools and resources call commands and options that exist #836's resolver, not a second copy (proposed). That resolver walks
resolve_commandfrom_COMMAND_SPECSand callsmake_contexton the leaf, neverinvoke. If fix(mcp): mcp tools and resources call commands and options that exist #836 puts it undersrc/devops_cli/docs/, this item moves it tocore/, because the CLI entry path now calls it. - Group callbacks run before a forwarded command. Are they safe? Yes, at ef21785 (proposed):
ai,ai review/review,ai analyzeandai ragonly handle--explain(commands/ai.py:144-161,review.py:134-148,analyze.py:311-325,rag.py:38-55);ci,scan,ai cost(aliasai spend) andai benchmarkreturn when a subcommand is invoked (ci.py:704,scan.py:125,ai_cost.py:322,benchmark.py:353). Before it returns,ciresolves and prints the worktree root (ci.py:701-703), which only reads files;- groups used as commands:
install-toolsandservedeclare no--dry-run, so they keep the generic line.dashboard/tuiandai benchmarkdeclare it, so they are forwarded.dashboard --dry-runrenders the static summary (commands/dashboard.py:197-198).ai benchmark --dry-runwrites a report, which a dependency fixes.
- Some of the 75 are read-only, such as
ssh list, whose preview only echoes its arguments (commands/ssh.py:342-348). Add the option, or delete the branch? Add the option (proposed). One rule for all 75 keeps the review mechanical. Whether read-only commands should simply run under dry-run is the split-off's question. - What if a branch turns out to act before it returns? If the fix is local to the command, fix the order in this PR. Otherwise, leave that command without the option, list it in the task file and add it to the split-off (proposed).
- Does the feat(review): per-model review quality baseline for the devops-review pool #475 extension's ordering (
docs/ROADMAP.md:314, "PR 3, before Reachable--dry-runPreviews") still apply? Yes (proposed). A dry-run review still writes a session directory andfindings.jsonthrough the orchestrator path (ai/review/runner.py:2142,pipeline.py:1415-1420,:3600-3627). Forwarding would makedevops --dry-run review path .write them. The feat(review): per-model review quality baseline for the devops-review pool #475 refinement splits this off as "a dry-run review writes no session", and this item depends on it.
- Constraint:
devops --dry-run <cmd>starts no mutating process, writes no file outside a temp directory and makes no mutating API call. Today the short-circuit guarantees this. After this item, each forwarded command's own--dry-runmust.devops --dry-run <cmd>is never less careful thandevops <cmd> --dry-run.- The dependencies below land first.
- Typer 0.27.2 vendors Click (
typer._click). Its exceptions do not subclass theclick.ClickExceptionthatmain.py:144catches. The proxy's usage-error path catches the vendored classes. - Tests start no process and touch no network, cluster or real scanner. The preview tests patch process creation, settings writes and the Docker engine to fail.
- No new dependency, and no compatibility shim for the old generic-line behaviour.
- Cyclomatic complexity is 10 or less and nesting depth 5 or less. Tests use structural tuple assertions until test(cli): retire the tuple-assert mandate and detect opaque tuple asserts and presence-only tests #851 settles that.
Strategic Alignment
- Milestone: Backlog, ranked first. It left v0.2.26 when refactor(ci): ci installs nothing on the runner, and live bubblewrap tests skip where bwrap is missing #832 joined that release, because the two split-off dependencies below are not filed or placed, so it could not start there. The roadmap entry (
docs/ROADMAP.md:683-686) still sits under the v0.2.24 heading and has no issue number. After feat(github): github-sourced roadmap, migration and generated roadmap view (devops roadmap migrate,render) #739 (v0.2.25), this issue is the source. - Depends on:
- fix(mcp): mcp tools and resources call commands and options that exist #836, for the leaf resolver. It is in v0.2.24, an earlier release.
- The split-off fix(ci):
devops cichecks run for real under their own--dry-run#885 (devops cichecks run for real under their own--dry-run). It is not filed yet. Its sweep of the declaring commands also records file writes, with HOME andDEVOPS_CLI_DATA_DIRisolated, and includesdashboardandtui. Any item that sweep files, such asai benchmark --dry-runsaving its report, is also a dependency. - The split-off drafted from feat(review): per-model review quality baseline for the devops-review pool #475 for
docs/ROADMAP.md:314PR 3: a dry-run review writes no session directory and nofindings.json. It is not filed yet.
- Related:
- refactor(cli): one process runner owns execution, process groups and dry-run #775: the process runner still executes under dry-run.
- fix(test): the test network guard refuses loopback connects to services the test did not start #837: the loopback guard keeps the preview tests off port-forwarded services.
- feat(mcp): mcp tools declare ToolAnnotations, and mutating tools require approval in devops-cli's own agent loop #857: MCP ToolAnnotations, which classifies MCP tools while this item classifies CLI commands.
- fix(docs): generated reference docs fail closed and describe the real surface #854: it also regenerates
docs/CLI_REFERENCE.mdanddocs/commands/, so whichever lands second regenerates again. - The split-off feat(cli): commands with no dry-run preview: read-only ones run, mutators gain one #886 (commands with no dry-run preview: read-only ones run, mutators gain one).
- Split off (backlog): fix(ci):
devops cichecks run for real under their own--dry-run#885 (devops cichecks run for real under their own--dry-run); feat(cli): commands with no dry-run preview: read-only ones run, mutators gain one #886 (commands with no dry-run preview: read-only ones run, mutators gain one).
Amended 2026-10-04: a dry run makes no external request (owner's definition)
The owner (2026-10-04): a "dry run should just return the command or request that would be run and a dry run response that is the exact same type as the real return object, not run a thousand api requests as read only".
Measured the same day: devops roadmap reprioritize --dry-run read all 931 board items and spent 2,025 GraphQL points. That is the same read as a real run; only the writes were skipped.
- No external requests. With
--dry-run, no command makes any external request (GitHub, Kubernetes, the AI gateway, Docker, Vault or HTTP), reads included. A test runs every command that has--dry-runwith the network,gh,kubectland other subprocess runners replaced by fakes that fail on use, and asserts that none was called. - The plan of requests. A dry run returns the exact commands or requests the real run would make, in order, each with method, target and redacted parameters. Values that need a read to know are shown as named placeholders (for example
<items of board 2 matching is:open>), never fetched. - The same return type. A dry run returns an object of the same type as the real run, marked as a dry run (for example
dry_run: trueplus the request plan), so CLI rendering,--jsonoutput, MCP tools and tests handle both paths with one code path. Its typed fields hold empty or placeholder values, never fabricated data. - Commands that must read to decide (reprioritize, intake, migrate) still make no request in a dry run. A separate, explicitly named mode (for example
--plan) may read, and reports its request cost, so a read-only preview is a deliberate choice.
Update 2026-10-08: refinement
#836 and #885 (PR #1199) landed; #872 is open. ai benchmark --dry-run still saves its report (ai/benchmark/runner.py:604-607), so that folds here: a dry run saves no report. The resolver (docs/command_resolver.py:139-159) moves to core/. Lines: proxy core/cli.py:139-144, root callback main.py:242-250, entry.py:46-50. The no-request test takes its arguments from #986's table.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 1, 2026
Moved from v0.2.25 to v0.2.26 to make room for the seven P1 items left open in the shipped v0.2.23, which were committed earlier. The roadmap-job items placed in v0.2.25 stay, and this item is among the oldest of the rest.
dan-petty commentedon Oct 1, 2026
Moved from v0.2.26 to the backlog to keep v0.2.26 at 12 after #832 joined. Its two dependencies, #885 (devops ci checks run for real under their own --dry-run) and #872 (a dry-run review writes no session), are in the backlog, so it couldn't start in v0.2.26 anyway. It heads the P1 backlog, after those two.
dan-petty commentedon Oct 8, 2026
Another case for this item, from #1360 (2026-10-08):
devops roadmap run --dry-run, andrunwithout--confirm, read the changes and releases, now including the pull request and GitHub Release listings #1360 adds to the poll, although the help says they make no request. A dry run should return the would-be requests with the same-typed result and make none. Folded here instead of a new issue because the agent filing quota (#1153) is spent.dan-petty commentedon Oct 8, 2026
Linked: #886 and #775 apply this item's 2026-10-04 dry-run rule (#886 declares which commands make requests; #775's runner refuses them), and #794 and #809 had
--dry-runcriteria amended to make no request. Found by the 2026-10-08 backlog review.dan-petty commentedon Oct 9, 2026
Note from #1515 (2026-10-09):
devops roadmap run --dry-runhas promised since v0.2.26 to name why each job is due, but nothing returns a reason today (_Poll.is_duereturns a bool). Since this item reshapes the dry-run output, the reason line belongs here if it fits: aDueReasonper job printed under the unchangedDue:line, soparse_due_tupleand the MCP tool keep working. #1515 proves its own interval through the due tuple only.feat(cli): reachable --dry-run previews for delegated commands (#412) (…
dan-petty-bot commentedon Oct 9, 2026
What changed
#1530, merged into
release/v0.2.33as 1f91d98.64 file(s) changed.
How it was verified
Check runs at 29635b0:
Acceptance Criteria of
docs/agent/tasks/task-412-reachable-dry-run-previews-for-delegated-commands.md:No Acceptance Criteria section.
feat(release): v0.2.33 (#1537)
feat(gh): preview requests in dry run for api, status, secrets (#2832)
feat(review): preview requests in dry run for review commands (#2892)
docs(openspec): plan #2258 plan dry-run for repos branches ssh tls (#…
feat(repos): request plans for repos, branches, ssh and tls (#3129)
feat(ci): uv, test, serve and mcp dry runs list their requests (#3135)
fix(k8s): list helm repo and upgrade in deploy-stack dry-run (#4227)