Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-11-01
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Design

## Decisions

- **Build each PlannedRequest from the same argument builder the real run uses**: The issue states the plan cannot drift from the run. Using the same builder guarantees the plan matches the real requests.
- **Remove echo-only previews with no shim**: The issue says 'with no shim' and the pre-1.0 policy in the repository deletes rather than keeps behind flags.
- **Group commands by family and work type (mark-only vs request-plan)**: Each group fits the 40000-token budget. A group of 2-5 commands in one file keeps the step small and focused.
- **Use the existing PlannedRequest and render_request_plan**: They exist in the repository (#741) and are the established pattern. Building new rendering would duplicate code.

## Rejected alternatives

- **Build a new dry-run rendering module for these commands**: render_request_plan and PlannedRequest already exist (#741, #885 in CHANGELOG.md). Building a new one duplicates code and diverges from the established pattern.
- **Keep echo-only previews as a fallback behind a flag**: The issue says 'with no shim'. The pre-1.0 policy in the repository (ADR 0005, CONTEXT.md) deletes rather than keeps behind flags.
- **Add a new dependency for dry-run planning**: The issue states 'No new dependency is necessary.' The repository already has the full dry-run infrastructure.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Proposal

## Why

Issue #2258 (part of #886) reports that 24 repos, branches, ssh and tls commands do not obey the dry-run rule (#412). Nine make an external request under --dry-run or have no request plan. Fifteen print a generic line or an argument echo instead of running safely. The owner's rule says a dry run makes no external request and returns the requests a real run would make.

## What Changes

- Add the request-plan class and a --dry-run that returns ordered PlannedRequest items to 9 commands (branches sync, branches update, repos clone, repos clone-org, repos sync, repos update, ssh register, ssh rotate, tls enable-k8s).
- Add the no-external-request class to 15 commands (branches clean, branches jira, branches list, repos list, repos worktrees prune, repos worktrees status, ssh audit, ssh generate, ssh list, ssh status, tls ca, tls cert, tls homelab, tls inspect, tls verify).
- Remove echo-only --dry-run previews (render_dry_run_result or @dry_run_command) from the 9 request-plan commands and from ssh list, with no shim.
- Remove all 24 command paths from tests/fixtures/dry_run_gaps.json so the ratchet test passes.
- Write tests that verify no external request is made, the plan matches the real run, and mark-only commands run normally under --dry-run.
- The change fits one pull request.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

- `command-dry-run-class`: request-plan-dry-run-returns-planned-requests, no-external-request-runs-normally, request-plan-matches-real-run

## Impact

- Code: `src/devops_cli/commands/branches.py`, `src/devops_cli/commands/repos.py`, `src/devops_cli/commands/ssh.py`, `src/devops_cli/commands/tls.py`
- Tests: `tests/fixtures/dry_run_gaps.json`, `tests/test_branches_dry_run.py`, `tests/test_repos_dry_run.py`, `tests/test_ssh_dry_run.py`, `tests/test_tls_dry_run.py`, `tests/test_roadmap_dry_runs.py`

## Feasibility

- The premise is confirmed by the #886 inventory (2026-10-25, commit 1bb164bd) and the fixture file tests/fixtures/dry_run_gaps.json, which lists all 24 commands.
- The dry-run infrastructure exists: devops_cli.dry_run.requests.PlannedRequest and render_request_plan are referenced in CHANGELOG.md (#741, #885).
- The test guards in tests/conftest.py (network guard, process guard, keyring deny) are in place and will catch any unfaked external reach.
- The dry-run class decorator and ratchet test come from sub-issue 00, a stated dependency.
- First checks the implementation runs: (1) uv run devops ci test tests/test_roadmap_dry_runs.py to confirm the ratchet test currently fails for these 24 commands; (2) uv run devops branches sync --dry-run to confirm the current generic output; (3) uv run devops ssh list --dry-run to confirm the echo-only preview.

## Existing Tool Considered

The repository already provides devops_cli.dry_run.requests.PlannedRequest, render_request_plan (#741), the dry-run class decorator, and the ratchet test from sub-issue 00. The test guards in tests/conftest.py and the pattern in tests/test_roadmap_dry_runs.py cover the verification. No new dependency is necessary.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## ADDED Requirements

### Requirement: request-plan-dry-run-returns-planned-requests
A command with the request-plan class SHALL make no external request under --dry-run and SHALL return its real result type marked as a dry run with the ordered PlannedRequest items.

#### Scenario: dry-run makes no external request
- **WHEN** a request-plan command is invoked with --dry-run and the process runner and HTTP clients are patched to raise
- **THEN** the command completes without raising and the output lists the ordered PlannedRequest items with argv, stdin, env, condition and repeat

#### Scenario: dry-run returns real result type as json
- **WHEN** a request-plan command is invoked with --dry-run and --format json
- **THEN** the JSON output has the dry-run mark and the planned requests array in order

### Requirement: no-external-request-runs-normally
A command with the no-external-request class SHALL run normally under devops --dry-run.

#### Scenario: dry-run runs the command
- **WHEN** a no-external-request command is invoked under devops --dry-run with the process runner and HTTP clients patched to raise
- **THEN** the command completes and returns its normal result without a dry-run mark

### Requirement: request-plan-matches-real-run
The PlannedRequest items of a request-plan dry run SHALL match the requests the real run makes, in the same order.

#### Scenario: plan matches recorded calls
- **WHEN** a test runs the real command against a fake runner or client that records each call and compares the calls with the plan
- **THEN** the recorded calls match the PlannedRequest items in order with the same argv, stdin and env
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Tasks

## 1. Mark-only branches: clean, jira, list

Reads: none. Changes: `src/devops_cli/commands/branches.py`, `tests/fixtures/dry_run_gaps.json`, `tests/test_branches_dry_run.py`.

- [ ] 1.1 Write a test that runs devops --dry-run branches clean, devops --dry-run branches jira, and devops --dry-run branches list with the process runner and HTTP clients patched to fail. Assert each command completes and returns its normal result. Assert the --dry-run option is not present on the command (no echo-only preview), and verify that `uv run devops ci test tests/test_branches_dry_run.py` fails on the base
- [ ] 1.2 Add the no-external-request class to branches clean, branches jira, and branches list. Remove any echo-only --dry-run option or render_dry_run_result call from these three commands. Remove the three entries (branches clean, branches jira, branches list) from tests/fixtures/dry_run_gaps.json, and verify that `uv run devops ci test tests/test_branches_dry_run.py` passes
- [ ] 1.3 Change no document, run `uv run devops docs generate --sync-readme`, and verify that `uv run devops ci docs` passes

## 2. Request-plan branches: sync, update

Reads: none. Changes: `src/devops_cli/commands/branches.py`, `tests/fixtures/dry_run_gaps.json`, `tests/test_branches_dry_run.py`.

- [ ] 2.1 Write a test that runs devops branches sync --dry-run and devops branches update --dry-run with GitPython's fetch and pull patched to raise. Assert no external request is made. Assert the output lists the ordered PlannedRequest items with argv, stdin, env, condition and repeat. Write a second test that runs the real command against a fake runner that records each call, and compares the recorded calls with the plan, and verify that `uv run devops ci test tests/test_branches_dry_run.py` fails on the base
- [ ] 2.2 Add --dry-run to branches sync and branches update. In the dry-run path, build each PlannedRequest from the same argument builder the real run uses (the fetch_all function in git/operations.py). Return the command's real result type marked as a dry run with the ordered PlannedRequest items. Print with render_request_plan. Give both commands the request-plan class. Remove any echo-only preview. Remove the two entries (branches sync, branches update) from tests/fixtures/dry_run_gaps.json, and verify that `uv run devops ci test tests/test_branches_dry_run.py` passes
- [ ] 2.3 Change no document, run `uv run devops docs generate --sync-readme`, and verify that `uv run devops ci docs` passes

## 3. Mark-only repos: list, worktrees prune, worktrees status

Reads: none. Changes: `src/devops_cli/commands/repos.py`, `tests/fixtures/dry_run_gaps.json`, `tests/test_repos_dry_run.py`.

- [ ] 3.1 Write a test that runs devops --dry-run repos list, devops --dry-run repos worktrees prune, and devops --dry-run repos worktrees status with the process runner and HTTP clients patched to fail. Assert each command completes and returns its normal result. Assert repos list has no echo-only --dry-run option, and verify that `uv run devops ci test tests/test_repos_dry_run.py` fails on the base
- [ ] 3.2 Add the no-external-request class to repos list, repos worktrees prune, and repos worktrees status. Remove the echo-only --dry-run option and render_dry_run_result call from repos list. Remove the three entries (repos list, repos worktrees prune, repos worktrees status) from tests/fixtures/dry_run_gaps.json, and verify that `uv run devops ci test tests/test_repos_dry_run.py` passes
- [ ] 3.3 Change no document, run `uv run devops docs generate --sync-readme`, and verify that `uv run devops ci docs` passes

## 4. Request-plan repos: clone, clone-org, sync, update

Reads: none. Changes: `src/devops_cli/commands/repos.py`, `tests/fixtures/dry_run_gaps.json`, `tests/test_repos_dry_run.py`.

- [ ] 4.1 Write a test that runs devops repos clone --dry-run, devops repos clone-org --dry-run, devops repos sync --dry-run, and devops repos update --dry-run with GitPython's clone_from, fetch and pull patched to raise, and the GitHub session patched to raise. Assert no external request is made. Assert the output lists the ordered PlannedRequest items. Write a second test that runs the real command against a fake runner that records each call, and compares the recorded calls with the plan, and verify that `uv run devops ci test tests/test_repos_dry_run.py` fails on the base
- [ ] 4.2 Add --dry-run to repos clone, repos clone-org, repos sync, and repos update. In the dry-run path, build each PlannedRequest from the same argument builder the real run uses (clone_repo and fetch_all in git/operations.py, and the GitHub org listing for clone-org). Return the command's real result type marked as a dry run with the ordered PlannedRequest items. Print with render_request_plan. Give all four commands the request-plan class. Remove the echo-only --dry-run options and render_dry_run_result calls. Remove the four entries (repos clone, repos clone-org, repos sync, repos update) from tests/fixtures/dry_run_gaps.json, and verify that `uv run devops ci test tests/test_repos_dry_run.py` passes
- [ ] 4.3 Change no document, run `uv run devops docs generate --sync-readme`, and verify that `uv run devops ci docs` passes

## 5. Mark-only ssh: audit, generate, list, status

Reads: none. Changes: `src/devops_cli/commands/ssh.py`, `tests/fixtures/dry_run_gaps.json`, `tests/test_ssh_dry_run.py`.

- [ ] 5.1 Write a test that runs devops --dry-run ssh audit, devops --dry-run ssh generate, devops --dry-run ssh list, and devops --dry-run ssh status with the process runner and HTTP clients patched to fail. Assert each command completes and returns its normal result. Assert ssh list has no echo-only --dry-run option, and verify that `uv run devops ci test tests/test_ssh_dry_run.py` fails on the base
- [ ] 5.2 Add the no-external-request class to ssh audit, ssh generate, ssh list, and ssh status. Remove the echo-only --dry-run option and render_dry_run_result call from ssh list (named in #886). Remove the four entries (ssh audit, ssh generate, ssh list, ssh status) from tests/fixtures/dry_run_gaps.json, and verify that `uv run devops ci test tests/test_ssh_dry_run.py` passes
- [ ] 5.3 Change no document, run `uv run devops docs generate --sync-readme`, and verify that `uv run devops ci docs` passes

## 6. Request-plan ssh: register, rotate

Reads: none. Changes: `src/devops_cli/commands/ssh.py`, `tests/fixtures/dry_run_gaps.json`, `tests/test_ssh_dry_run.py`.

- [ ] 6.1 Write a test that runs devops ssh register --dry-run and devops ssh rotate --dry-run with the HTTP client (httpx2.AsyncClient) patched to raise. Assert no external request is made. Assert the output lists the ordered PlannedRequest items with argv, stdin, env, condition and repeat. Write a second test that runs the real command against a fake HTTP client that records each call, and compares the recorded calls with the plan, and verify that `uv run devops ci test tests/test_ssh_dry_run.py` fails on the base
- [ ] 6.2 Add --dry-run to ssh register and ssh rotate. In the dry-run path, build each PlannedRequest from the same argument builder the real run uses (the GitHub session post for key registration and rotation). Return the command's real result type marked as a dry run with the ordered PlannedRequest items. Print with render_request_plan. Give both commands the request-plan class. Remove the echo-only --dry-run options and render_dry_run_result calls. Remove the two entries (ssh register, ssh rotate) from tests/fixtures/dry_run_gaps.json, and verify that `uv run devops ci test tests/test_ssh_dry_run.py` passes
- [ ] 6.3 Change no document, run `uv run devops docs generate --sync-readme`, and verify that `uv run devops ci docs` passes

## 7. Mark-only tls: ca, cert, homelab, inspect, verify

Reads: none. Changes: `src/devops_cli/commands/tls.py`, `tests/fixtures/dry_run_gaps.json`, `tests/test_tls_dry_run.py`.

- [ ] 7.1 Write a test that runs devops --dry-run tls ca, devops --dry-run tls cert, devops --dry-run tls homelab, devops --dry-run tls inspect, and devops --dry-run tls verify with the process runner and HTTP clients patched to fail. Assert each command completes and returns its normal result. Assert tls ca, tls cert, and tls homelab have no echo-only --dry-run option, and verify that `uv run devops ci test tests/test_tls_dry_run.py` fails on the base
- [ ] 7.2 Add the no-external-request class to tls ca, tls cert, tls homelab, tls inspect, and tls verify. Remove the echo-only --dry-run options and render_dry_run_result calls from tls ca, tls cert, and tls homelab. Remove the five entries (tls ca, tls cert, tls homelab, tls inspect, tls verify) from tests/fixtures/dry_run_gaps.json, and verify that `uv run devops ci test tests/test_tls_dry_run.py` passes
- [ ] 7.3 Change no document, run `uv run devops docs generate --sync-readme`, and verify that `uv run devops ci docs` passes

## 8. Request-plan tls: enable-k8s

Reads: none. Changes: `src/devops_cli/commands/tls.py`, `tests/fixtures/dry_run_gaps.json`, `tests/test_tls_dry_run.py`.

- [ ] 8.1 Write a test that runs devops tls enable-k8s --dry-run with kubectl patched to raise. Assert no external request is made. Assert the output lists the ordered PlannedRequest items with argv, stdin, env, condition and repeat. Write a second test that runs the real command against a fake process runner that records each call, and compares the recorded calls with the plan, and verify that `uv run devops ci test tests/test_tls_dry_run.py` fails on the base
- [ ] 8.2 Add --dry-run to tls enable-k8s. In the dry-run path, build each PlannedRequest from the same argument builder the real run uses (the kubectl create call at commands.tls:enable_k8s_cmd:508). Return the command's real result type marked as a dry run with the ordered PlannedRequest items. Print with render_request_plan. Give the command the request-plan class. Remove the echo-only --dry-run option and render_dry_run_result call. Remove the entry (tls enable-k8s) from tests/fixtures/dry_run_gaps.json, and verify that `uv run devops ci test tests/test_tls_dry_run.py` passes
- [ ] 8.3 Change no document, run `uv run devops docs generate --sync-readme`, and verify that `uv run devops ci docs` passes

## 9. Ratchet test and full CI verification

Reads: none. Changes: `tests/test_roadmap_dry_runs.py`.

- [ ] 9.1 Run the ratchet test from sub-issue 00 and confirm it passes with all 24 commands removed from tests/fixtures/dry_run_gaps.json. Run the full test suite for the four command families and confirm no test starts a process or opens a socket, and verify that `uv run devops ci` fails on the base
- [ ] 9.2 Verify that tests/fixtures/dry_run_gaps.json no longer contains any of the 24 commands. Confirm the ratchet test in tests/test_roadmap_dry_runs.py passes. If the ratchet test needs an update to reflect the new class assignments, add the assertion that each of the 24 commands carries the correct class (request-plan or no-external-request), and verify that `uv run devops ci` passes
- [ ] 9.3 Change no document, run `uv run devops docs generate --sync-readme`, and verify that `uv run devops ci docs` passes

## Workflow follow-up

- Pending a person: review the diff in tuicr (tuicr -r <base>..HEAD).
Loading