Skip to content

feat(cli): commands with no dry-run preview: read-only ones run, mutators gain one #886

Closed
23 of 23 issues completed

Description

@dan-petty

Context & Rationale

Paths are under src/devops_cli/. Evidence was checked at ef21785.

  • 174 of the 361 distinct command callbacks declare no --dry-run and have no dry-run branch in their body. I counted them by walking typer.main.get_command for every _COMMAND_SPECS module.
  • After feat(cli): reachable --dry-run previews for delegated commands #412:
    • devops --dry-run <cmd> prints Would run delegated command: … and runs nothing;
    • devops <cmd> --dry-run fails with No such option: --dry-run.
  • Both outcomes are honest, but neither helps:
    • read-only commands such as config show and k8s pods do not show their output;
    • mutating commands give no preview. Examples are config set (commands/config.py:182-191), pr create, pr close, gh issues create, argo cd apps sync, ai cost reset and workspace remove.
  • Some read-only commands that feat(cli): reachable --dry-run previews for delegated commands #412 gives a --dry-run only echo their arguments, for example ssh list (commands/ssh.py:342-348).

Scope & Deliverables

  • Deliverable:
    • Classify every command as read-only or mutating.
    • Each mutating command declares --dry-run, with a preview that returns before acting.
    • Each read-only command declares that it is read-only, and the feat(cli): reachable --dry-run previews for delegated commands #412 proxy runs it normally under dry-run.
    • Remove the echo-only previews, and their option, from read-only commands, with no shim.
  • Acceptance criteria:
    • An invariant test: every command reachable from _COMMAND_SPECS either declares --dry-run or is marked read-only, never both. Verified by the test.
    • devops --dry-run config show prints the configuration, and devops --dry-run config set ai.provider ollama prints a preview and writes nothing. Verified by tests with save_settings patched to fail.
    • The new tests add at most 1 s to the test step, recorded in the task file.
    • uv run devops ci passes.
  • Key questions:
    • How does a command declare that it is read-only? With a read_only attribute set by a decorator in dry_run/decorator.py, which the proxy reads (proposed).
    • Should this agree with the MCP readOnlyHint annotations (feat(mcp): mcp tools declare ToolAnnotations, and mutating tools require approval in devops-cli's own agent loop #857)? Yes (proposed). Add a consistency test for MCP tools that wrap a devops command, rather than keeping one shared list.
    • Does this fit one PR? Decide when this item is refined (proposed). If more than about 40 mutating commands need a new preview, split by command group, starting with gh and pr.
  • Constraint: Tests start no process and touch no network, cluster or real scanner. No new dependency.

Strategic Alignment

Split off #412 during the v0.2.25/v0.2.26 readiness review (2026-10-01): This is the classification the first draft of #412 wanted before flipping the switch. #412 now routes per command and fails safe: a command with no preview keeps the generic line. So this audit no longer has to come first, and it splits off as its own item.

Amended 2026-10-04: the owner's dry-run rule replaces "read-only commands run"

The owner (2026-10-04): "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". #412 records the rule. "Read-only" is therefore no longer a reason to run under a dry run. The line between the two cases is whether a command makes an external request: GitHub, a cluster, a model, the network, or a child process that does any of these.

Update 2026-10-08: refinement

#885 delivered devops ci --dry-run running nothing (tests/test_ci_dry_run.py:89-105); drop that criterion. This class means 'makes no external request', while #857's readOnlyHint means 'changes no state' (gh issues list is the first only), so the consistency test checks one direction: a tool wrapping a no-request command has readOnlyHint: true. #997 can read both facts from one declaration.

Proposed design

Problem statement

226 of 483 commands in _COMMAND_SPECS declare no --dry-run option. Commands that make external requests execute those requests under --dry-run instead of returning a plan. Commands that make no external requests lack a read_only marker. No invariant test enforces that every command either runs safely under dry-run or returns a request plan.

Acceptance criteria

  • Criterion 1: Every command in _COMMAND_SPECS has a read_only marker or declares --dry-run with a request plan.
    Verification: The invariant test passes. It fails when a command makes an external request and lacks both markers.
  • Criterion 2: devops --dry-run k8s pods returns the kubectl request it would make and makes none.
    Verification: A test patches the subprocess runner to fail. The command exits 0 and the runner is not called.
  • Criterion 3: An MCP tool wrapping a no-request command has readOnlyHint: true.
    Verification: The consistency test in tests/test_fastmcp_contracts.py passes.
  • Criterion 4: Echo-only previews are removed from no-request commands with no shim.
    Verification: devops --dry-run ssh list prints the SSH list output. The --dry-run option is absent from the ssh list callback.
  • Criterion 5: uv run devops ci passes.
    Verification: Run uv run devops ci and confirm exit code 0.

Key questions

Fit

Needs splitting into 9 items:

  1. Infrastructure: add the read_only decorator in dry_run/decorator.py, the proxy logic in main.py, and the invariant test
  2. gh command group: add --dry-run request plans to external-request commands
  3. pr command group: add --dry-run request plans to external-request commands
  4. k8s command group: add --dry-run request plans to external-request commands
  5. config command group: classify commands and add read_only markers or --dry-run request plans
  6. argo cd command group: add --dry-run request plans to external-request commands
  7. ai command group: add --dry-run request plans to external-request commands
  8. workspace command group: add --dry-run request plans to external-request commands
  9. Remaining command groups (ssh and others): classify and add read_only markers or --dry-run request plans

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-10-29: not-applicable.
Tool: none found.

Sub-issues

Sub-issues

23 of 23 Issues completed
Loading 23 sub-issues

Activity

  1. added
    type/feature
    scope/cli
    priority/p3-low
    on Oct 1, 2026
  2. dan-petty commented on Oct 25, 2026

    @dan-petty
    OwnerAuthor

    This item cannot be built as written in one pull request. _COMMAND_SPECS has 483 commands. 226 commands declare no --dry-run. More than 230 commands make external requests and lack request plans with PlannedRequest. The issue asks for an invariant test that fails when any external-request command lacks a request plan. The issue also requires splitting by command group if more than 40 commands need changes.

    Refinement must split this work into bounded issues by command group, starting with gh and pr.

  3. 9 remaining items

  4. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    The proposal at bb46660 needs splitting into 9 items. A person splits the item into the items below, or replies in a comment or edits the body to keep one item, and the next refine round looks at the item again.

    1. Infrastructure: add the read_only decorator in dry_run/decorator.py, the proxy logic in main.py, and the invariant test
    2. gh command group: add --dry-run request plans to external-request commands
    3. pr command group: add --dry-run request plans to external-request commands
    4. k8s command group: add --dry-run request plans to external-request commands
    5. config command group: classify commands and add read_only markers or --dry-run request plans
    6. argo cd command group: add --dry-run request plans to external-request commands
    7. ai command group: add --dry-run request plans to external-request commands
    8. workspace command group: add --dry-run request plans to external-request commands
    9. Remaining command groups (ssh and others): classify and add read_only markers or --dry-run request plans
  5. added
    status/new
    value/medium
    effort/high
    on Oct 28, 2026
  6. devops-cli-service commented on Oct 29, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Tool: none found

    Checked on 2026-10-29. A person decides what this means for the item. The check changes no label and closes no issue.

  7. removed
    status/new
    on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/highpriority/p3-lowscope/clitype/featurevalue/medium

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions