Repository navigation
Description
Problem Statement
Split off #885 on 2026-10-02 by owner decision Q3: #885 keeps the two dry-run guards in the ci.py runners and the guard around the coverage cleanup, and its task file records the 80-path recorder result already measured and names this candidate. The survey of the remaining 40 argument-taking paths changes no code in #885, cannot be verified by that pull request's checks (docs/agent/tasks/README.md:11, rule 3: verification is the PR's passing checks), and its only output is zero or more candidates for other command modules. So it is its own candidate for intake (backlog, no milestone), not a step of #885.
Paths are under src/devops_cli/; evidence checked at 9c879ae (tip of release/v0.2.25). lang/en/help.py and config/constants.py changed since #885's 8271385, but the lines cited below hold.
- A command's own
--dry-runonly callsset_dry_run(True)(dry_run/state.py:18-25), which setsDEVOPS_CLI_DRY_RUN; nothing below the command refuses to run. The core runners printWould run commandand then start the process anyway (core/process.py:235-236thensubprocess.runat:266;:376-377thenasyncio.create_subprocess_execat:409). Whether a command is safe under its own--dry-runtherefore depends on each command checkingis_dry_run()(dry_run/state.py:38-41) itself. - fix(ci):
devops cichecks run for real under their own--dry-run#885 found that 14devops cicommands do not, and fixes them. For the other commands, the issue's recorder run (withsubprocess.runreplaced, astests/test_ci.py:28-36does) covered 120 command paths: 80 that run without arguments finished, and apart fromcithe only processes started were read-only (git worktree list,git rev-parse,gh api rate_limit,kubectl apply -k . --dry-run=client). The 40 paths that need arguments were not run, so nobody knows whetherdevops <group> <cmd> <args> --dry-runruns for real in any of them. - At
9c879ae, at least 96 command functions across 30 modules undercommands/declare--dry-run(an AST count of decorated typer commands whose signature contains the literal"--dry-run"): 15 inci.pyand 81 elsewhere (scan.py10,ai.py8,docker.py6,sandbox.py6,devcontainer.py5,gh.py5, and 24 modules with 1-4 each). That count misses commands registered after definition withapp.command()(func)(commands/k8s/__init__.py:98-120; for examplek8s lint,commands/k8s/security_audit.py:99-106), so it is a floor. The issue's 120-path count also includes root aliases (devops lintanddevops formatarecisubcommands,main.py:70-71,config/constants.py:183) and group callbacks; the survey re-derives the list from the Click tree rather than from any AST count. - The option's help promises "Preview execution plan without mutating external state." (
lang/en/help.py:25). Every command that declares it makes that promise. tests/test_all_commands_help_dryrun.py:22-73runs--dry-runon 14 entries (12 distinct paths) and asserts only exit 0 (:86). Ten of those paths use the globaldevops --dry-run <cmd>form, which never reaches the command: the lazy proxy prints a delegated line and stops (core/cli.py:128-135). Only two (repos sync,branches clean) pass the command's own flag, both argument-free. The test records no process and covers none of the 40 argument-taking paths.
Proposed Solution
The method, reusing what #885 established:
- Enumerate every command path that declares
--dry-runfrom the Click tree (typer.main.get_command(app)over_COMMAND_SPECS,main.py:33), including theformatandlintroot aliases, and split it into argument-free paths (already recorded in fix(ci):devops cichecks run for real under their own--dry-run#885's task file) and argument-taking paths (the 40). - For each argument-taking path, invoke it once through
CliRunnerwith its own--dry-runand syntactically valid placeholder arguments (atmp_pathfile or directory, a name such asexample, a loopback URL), withsubprocess.runreplaced by a recorder returning rc 0 (tests/test_ci.py:31-35). The recorder also catches the async runner, which falls back to the sync runner in a thread wheneversubprocess.runis patched (core/process.py:361-362). No live cluster, tunnel or repository is needed: every process is intercepted, as it was for the 80 paths. The survey runs under the session network guard (tests/conftest.py:98-112): a connect to a non-loopback host raisesRuntimeError, and a loopback port this process does not listen on is refused, so a path that reaches the network fails loudly rather than silently. - Record per path: exit code, every argv recorded, and whether each argv is read-only (the
_QUIET_SUBPROCESS_ARGSset,core/process.py:23-25, is the existing list of such git subcommands) or mutating. - For each command outside
commands/ci.pywhose recorder shows a mutating process, or whose code path writes files or calls a remote API under--dry-run, file one candidate. A path that only starts read-only processes is recorded, not filed.
What a resulting item looks like (the shape #885 has): title fix(<scope>): \devops ` runs for real under its own --dry-run; a problem statement citing the command's --dry-rundeclaration and the runner call it reaches; the fix placed in that command's runner or helper, printing the command withprint_dry_run_command (output/console.py:728) and returning a pass; a test that records subprocess.run, asserts zero calls and the Would run commandlines, and fails before the fix; the no-flag control; One command per item; a module with several offenders may group them when they share one runner function, asci.py` does.
Scope
- The survey record: the list of argument-taking
--dry-runpaths, the placeholder arguments used, and the recorder result per path, kept in this item's task file (docs/agent/tasks/task-<issue>-dry-run-survey.md). - Zero or more filed candidates, one per offending command outside
commands/ci.py, each named in the task file. - No change under
src/ortests/. The enumeration and recorder snippet is reproduced in the task file so the survey can be re-run; it is not committed as a script (AGENTS.md:97-102: scratch scripts live only in the gitignored scratch directory and are deleted before the session ends).
Key Questions
This item is born from decisions already taken; nothing is open.
- Does the survey stay in fix(ci):
devops cichecks run for real under their own--dry-run#885? No (owner decision Q3,decisions.jsonitem 885: "Move it out as its own candidate; this PR's task file keeps the recorded 80-path result and names the candidate filed"). - Does the survey need live arguments (a cluster, a tunnel, a repository)? No. The recorder intercepts every process and returns rc 0, so placeholder arguments that pass each command's own validation are enough; that is how the 80 argument-free paths ran. A command that validates its argument before any process (an existing path, a reachable host) gets a
tmp_pathor loopback placeholder; the network guard refuses the loopback connect, which is itself a recorded result. - Does an offender get fixed in this item? No. This item changes no code. Each offender becomes its own candidate with the shape above, and intake places it. This keeps the item a survey that one task file delivers.
- Is a read-only process under dry-run a finding? No. Many callers rely on read-only processes under dry-run (
git rev-parseinreview branch;_QUIET_SUBPROCESS_ARGS,core/process.py:23-25). The runner-level decision is refactor(cli): one process runner owns execution, process groups and dry-run #775. Only a mutating process, a file write or a remote write is a finding. - Should the survey become a permanent test? Not here.
tests/test_all_commands_help_dryrun.pyalready asserts exit 0 for a hand-kept list; turning it into a tree-walking recorder test with per-path placeholder arguments is a follow-up the survey can propose once it knows how many paths need bespoke arguments.
Acceptance Criteria
- The task file lists every argument-taking command path that declares
--dry-runat the surveyed commit, derived from the Click tree, one table row per path with the placeholder arguments used; the file states the counts (argument-taking, and argument-free as recorded in fix(ci):devops cichecks run for real under their own--dry-run#885's task file), reconciles their sum against the issue's 120-path figure and explains any difference. Observable: the table and the reconciliation paragraph indocs/agent/tasks/task-<issue>-dry-run-survey.md. - Every row records the exit code and every argv the recorder saw, each marked read-only or mutating, and names any file or remote write the code path performs under
--dry-run; a row with no process saysnone. Observable: no row of the table has an empty result cell. - For every command outside
commands/ci.pyrecorded as mutating, the task file names the candidate filed for it, in the shape described above; a survey with no offender says so in one sentence. Observable: the "Candidates filed" section of the task file. - The task file reproduces the enumeration and recorder snippet and states that the survey ran with
subprocess.runrecorded and under thetests/conftest.pynetwork guard, with no live cluster, tunnel, repository or network; no script is added to the tree (git diff --stat main...HEADlists only the task file and the changelog fragment). -
uv run devops cipasses.
Out of Scope
- Fixing any command found to run for real: each is its own candidate.
- The 14
devops cicommands, their runner guards and the coverage-cleanup guard (fix(ci):devops cichecks run for real under their own--dry-run#885), and the 80 argument-free paths already recorded there. - Making
run_subprocess/run_subprocess_asyncrefuse to run under dry-run (refactor(cli): one process runner owns execution, process groups and dry-run #775), and forwarding the globaldevops --dry-runto a command's own--dry-run(feat(cli): reachable--dry-runpreviews for delegated commands #412). - A permanent tree-walking dry-run test (a follow-up this survey may propose).
Dependencies
- Depends on: none. fix(ci):
devops cichecks run for real under their own--dry-run#885 names this candidate in its task file; the two can proceed in any order, since this item reads the code and fix(ci):devops cichecks run for real under their own--dry-run#885 changes onlycommands/ci.py, which this survey excludes. - Related: feat(cli): reachable
--dry-runpreviews for delegated commands #412 (global--dry-runforwarding) gains from every offender found here, since after itdevops --dry-run <cmd>reaches the command's own flag; refactor(cli): one process runner owns execution, process groups and dry-run #775 (runner-level dry-run intent). Neither is in the refined item set, so neither is a dependency entry.
Update 2026-10-08: refinement
Under #412's rule, a row is a finding when its --dry-run contacts a server, writes outside its temp directories or changes local state; a local read is not. #885's survey lists gh api rate_limit and kubectl apply -k . --dry-run=client, both findings now. The table gives #412's test its arguments.
- Every argv is marked local read, local write or external, and every finding has a candidate.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNew
Activity
fix(ci): devops ci checks run for real under the gate (#885) (#1199)
feat(release): v0.2.27 (#1257)
chore(cli): survey argument-taking --dry-run command paths (#2316)