Repository navigation
Description
Problem
Counts come from one AST pass over tests/test_*.py at 5c45b1e, the head of release/v0.2.28, and [code: …] lines are at the same commit. A file belongs to the package it references most, as in the census.
#1952 deleted commands/release.py and test_release.py with the release code. The release counts and lines below are history, and this item does not change them.
-
Files (6; 7,413 lines, 297 tests [measured: AST pass at 5c45b1e]):
test_pr_cmd,test_pr_update,test_gh_cmd,test_github_milestones,test_reposandtest_release.test_pr_cmd.pyreferencesgithub/slightly more thancommands/(98 to 84). Its subject isdevops pr, so this item names it rather than test(github): github/ is tested through its public interface over the gh process and session fakes, with no internal patches or private imports #1321.
-
Coupling. These files hold 380 patch sites aimed at devops_cli internals and 53 private imports. Every file has some of both [measured]. The internal patches break down as:
- 96 replace
run_gh, 94 of them incommands/pr(58),commands/gh(18) andcommands/release(18). - 54 replace
core.repo.get_repo_origin_name, even though git runs for real (Q23). - 29 replace
run_subprocess. - 12 replace
commands.pr.check_binary. - 15 replace
commands.repos.load_settings.
A further 74 sites patch
shutil.whichdirectly.test_release.pyimports 34 private names. - 96 replace
-
Doubles.
- There are 54
CompletedProcess(and 118MagicMock(calls, and 4 module-levelrunner = CliRunner(). test_release.pydefines ten nestedmock_gh*routers, from:509to:2445.
- There are 54
-
Product code shaped for patching (Q27).
commands/release.py:56-85holds_LAZY_OBJECT_MAPPING(9 names), a module__getattr__and_get. Its 66_get(...)calls exist so that tests can patch a name on the command module. refactor(cli): one process runner owns execution, process groups and dry-run #775 plans to replace such blocks with function-local imports. -
Logic living in commands/ (Q19).
- Merge readiness [code: commands/pr.py:1209-1805] covers the mergeable state, thread and check-run blockers, perimeter changes, and the grounding rules: one closed issue and its task file.
- Branch-update planning [code: commands/pr.py:1885-2263].
- Release:
- release notes and their limits [code: commands/release.py:333-531];
- version bumps [code: commands/release.py:532-611];
- changelog compilation and fragment collection [code: commands/release.py:612-772];
- service image tags and Argo CD target revisions [code: commands/release.py:146-305];
- the cut [code: commands/release.py:1059-1200].
- Rate-limit reads and parsing [code: commands/gh.py:1246-1365].
- Clone destination parsing [code: commands/repos.py:101-113, :196-228].
-
Edges.
devops reposreaches PyGithub through the session's client [code: commands/repos.py:54-60, :174], and thedevops ghlabel commands reach it through_get_github_client[code: commands/gh.py:138-142, :162, :241]. PyGithub speaks HTTP throughrequests, so four tests patchGitHubClientto fake it. refactor(github): pull request, repository and ssh key calls move from pygithub onto the github session #891 moves these calls onto the GitHub session, where refactor(github): the github session owns transport, ledger, error classes and link pagination #983's session fake answers them.devops pr updatepolls withtime.sleep[code: commands/pr.py:1940].
-
Files and names.
test_release.pyhas 2,519 lines and 82 tests. It holds changelog compilation (:1312), fragments (:1471), notes limits (:1681) and the fail-closed cut (:1879).test_pr_cmd.pyhas 2,291 lines and 101 tests. It holds readiness (:1705-:2202) and a test of the pull request template, a committed file (:2211).test_repos.pyhas 1,031 lines.- Catch-alls:
test_release.py:666,:829,:909;test_repos.py:324,:767,:803,:910;test_github_milestones.py:190. - 28 test names end in
_success,_failure,_basicor_command.
Acceptance criteria
-
No internal patches or private imports. The test files this item owns under
tests/commands/have zero patch sites aimed at devops_cli internals and zero private imports. So do the tests it adds elsewhere. If test(cli): ratchets hold internal patches, private imports and test accommodations in src at today's counts and name each site that would raise one #1309 has landed, its two ceilings drop by the counts these files carry when the item starts (380 and 53 at 5c45b1e). -
Edges only through seams:
- gh,
shutil.whichand other processes go through refactor(cli): one process runner owns execution, process groups and dry-run #775's process fake; - GitHub REST goes through refactor(github): the github session owns transport, ledger, error classes and link pagination #983's session fake, including the
devops reposanddevops ghcalls that refactor(github): pull request, repository and ssh key calls move from pygithub onto the github session #891 has moved off PyGithub; - polling goes through refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320;
- settings go through test(cli): the hermetic floor fails a test that reaches an edge without a fake and resets all process-wide state after every test #1310's
configfixture; - git runs for real in a temporary repository whose origin names the repository, and no test patches
get_repo_origin_name.
- gh,
-
No interim markers. If test(cli): the hermetic floor fails a test that reaches an edge without a fake and resets all process-wide state after every test #1310 added its interim
unreachable(...)marker, none remains in this item's test files: each gives way to the fake of the edge it names, in the fake's refusing state where the test relies on the refusal. -
Logic out of commands/ (Q19). Each piece below moves behind a public function and is tested in its package's mirror directory:
- merge readiness and branch-update planning move into
github/; - rate-limit reads and parsing move into
github/; - clone destination parsing moves into
git/.
The commands become thin adapters. A move too big for this item gets its own item, and until then its logic is tested through the CLI with edge fakes.
- merge readiness and branch-update planning move into
-
CLI tests and test data.
- CLI tests use the shared
clifixture in place of the 4 module-level runners, and check only parsing, wiring, output and exit codes (Q14). - Command tables are syrupy snapshots (Q18; test(cli): tests find the repository root and fixtures from any depth, import no other test module and build test data with shared builders, and devops test maps a change to its mirror directory #1312 adds syrupy).
- Where a test builds an item, it uses the shared builder that test(cli): tests find the repository root and fixtures from any depth, import no other test module and build test data with shared builders, and devops test maps a change to its mirror directory #1312 puts in
tests/support/builders.py(make_item; Q20). This item adds no builder of its own. - Assertions compare whole values (Q7).
- CLI tests use the shared
-
The pull request template test moves to
tests/invariants/test_pull_request_template.py(Q13), named after its subject,.github/pull_request_template.md. This item adds that file to the subject files named indocs/TESTING.md, so test(cli): Convert ratchets to bans and merge invariant tests #1336's ban on unlisted names intests/invariants/accepts it. -
Files and names.
test_pr_cmd.pyandtest_repos.pyare deleted.- Their tests live in behaviour files, for example
tests/github/test_merge_readiness.py. - The catch-alls are dissolved.
- Test names state behaviour in CONTEXT.md terms (Q8).
-
Every line that no public behaviour reaches is deleted (Q22), and the 90% coverage gate passes.
-
uv run devops cipasses.
Key questions
- Which files belong to this item? Decided 2026-10-07: under Q17, each file goes to the package that owns most of what it tests, and test(cli): every test file sits in the directory mirroring the package it tests or in tests/invariants/, and the root conftest holds only the hermetic floor #1313 places it in that package's mirror directory. This item owns exactly the files named above;
tests/commands/is shared, and each file in it belongs to the one E item that names it. (proposed) test(cli): every test file sits in the directory mirroring the package it tests or in tests/invariants/, and the root conftest holds only the hermetic floor #1313 placestest_pr_cmd.pyundertests/commands/, since what it tests isdevops pr. - Which package owns merge readiness? (proposed)
github/, next tocheck_verdict.py, which already classifies check runs. - Which subject file takes the pull request template test? (proposed) A new one,
tests/invariants/test_pull_request_template.py, named after.github/pull_request_template.md: none of the Q13 subjects covers the template. A subject is added by adding it to the list indocs/TESTING.md(test(cli): Convert ratchets to bans and merge invariant tests #1336), so this item adds it there, and test(cli): Convert ratchets to bans and merge invariant tests #1336's mapping of subject files includes it. - Is this one pull request? Decided 2026-10-07: under Q33 and Q19, it is filed now as one item. Refinement applies
needs-splitif it proves too big, and a domain move too big for the item gets its own item.
Strategic alignment
- Depends on: test(cli): every test file sits in the directory mirroring the package it tests or in tests/invariants/, and the root conftest holds only the hermetic floor #1313, refactor(cli): one process runner owns execution, process groups and dry-run #775, refactor(github): pull request, repository and ssh key calls move from pygithub onto the github session #891, refactor(github): the github session owns transport, ledger, error classes and link pagination #983, refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320. Blocks: test(cli): Convert ratchets to bans and merge invariant tests #1336. Related: test(cli): ratchets hold internal patches, private imports and test accommodations in src at today's counts and name each site that would raise one #1309 (the ratchets this item lowers), test(github): github/ is tested through its public interface over the gh process and session fakes, with no internal patches or private imports #1321 (owns
github/, which receives readiness), test(infra): infrastructure tests run on edge fakes #1335 (the infrastructure and planning-package tests), refactor(review): the model verifier, the hallucination catalog and the model-claim guards are deleted, and person-recorded verdicts become suppressions #1150 (rewires the perimeter warning [code: commands/pr.py:1415]). - Parent: test(cli): tests double only process edges and mirror the source tree #1307 (phase E).
Proposed design
Problem statement
The test files for devops pr, devops gh and devops repos couple to devops-cli internals through 380 patch sites and 53 private imports. They hold domain logic in commands/ instead of in domain packages. They use ad-hoc doubles instead of the shared edge fakes. This item removes the internal coupling, moves the domain logic into its packages, and reorganizes the tests into behaviour-named files over the shared fakes.
Acceptance criteria
- Criterion 1: The test files this item owns under tests/commands/ have zero patch sites aimed at devops_cli internals and zero private imports. Tests added elsewhere also have zero of both.
Verification: Run a grep or AST scan over the owned test files for mock.patch calls targeting devops_cli names and for imports of names starting with an underscore from devops_cli. The count is zero. If test(cli): ratchets hold internal patches, private imports and test accommodations in src at today's counts and name each site that would raise one #1309 has landed, its two ratchet ceilings drop by 380 and 53. - Criterion 2: Every edge in the owned tests goes through a shared seam: gh and processes through refactor(cli): one process runner owns execution, process groups and dry-run #775's process fake, GitHub REST through refactor(github): the github session owns transport, ledger, error classes and link pagination #983's session fake, polling through refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320, settings through test(cli): the hermetic floor fails a test that reaches an edge without a fake and resets all process-wide state after every test #1310's config fixture, and git runs for real in a temporary repository.
Verification: No test in the owned files patches run_gh, run_subprocess, shutil.which, time.sleep, load_settings, get_repo_origin_name, or GitHubClient. Each edge is reached through its named fixture. A grep for those names in the owned test files returns zero hits. - Criterion 3: No interim unreachable(...) marker remains in this item's test files.
Verification: A grep for unreachable in the owned test files returns zero hits. - Criterion 4: Merge readiness and branch-update planning move into github/ behind a public function. Rate-limit reads and parsing move into github/. Clone destination parsing moves into git/. The commands become thin adapters.
Verification: The moved logic is reachable through a public function in its domain package. The command module imports and calls it. Tests of the moved logic live in the package's mirror directory under tests/. A move too big for this item gets its own item, and until then its logic is tested through the CLI with edge fakes. - Criterion 5: CLI tests use the shared cli fixture, check only parsing, wiring, output and exit codes, and use syrupy snapshots for command tables.
Verification: No module-level CliRunner() in the owned test files. Command output assertions use syrupy snapshots. Tests assert on exit code, parsed arguments, and output text only. - Criterion 6: Where a test builds a domain object, it uses the shared builder from tests/support/builders.py. This item adds no builder of its own.
Verification: A grep for make_item or equivalent builder calls in the owned test files shows they import from tests.support.builders. No new builder function is defined in the owned files. - Criterion 7: The pull request template test moves to tests/invariants/test_pull_request_template.py, named after .github/pull_request_template.md. The subject is added to the list in docs/TESTING.md.
Verification: The file tests/invariants/test_pull_request_template.py exists and tests the template. The list in docs/TESTING.md under tests/invariants/ includes test_pull_request_template.py. - Criterion 8: test_pr_cmd.py and test_repos.py are deleted. Their tests live in behaviour-named files in the mirror directories. The catch-alls are dissolved. Test names state behaviour in CONTEXT.md terms.
Verification: The two files no longer exist. New files are named after behaviours, such as tests/github/test_merge_readiness.py. No test name ends in _success, _failure, _basic or _command. No test is named after a helper, a private function or a double. - Criterion 9: Every line that no public behaviour reaches is deleted, and the 90% changed-line coverage gate passes.
Verification: Run uv run devops ci. The coverage report shows 90% or more of changed lines covered. No dead code remains in the moved or modified files. - Criterion 10: uv run devops ci passes.
Verification: Run uv run devops ci in a clean checkout. All checks pass with no failures.
Key questions
- Which files belong to this item?: Decided 2026-10-07: under Q17, each file goes to the package that owns most of what it tests, and test(cli): every test file sits in the directory mirroring the package it tests or in tests/invariants/, and the root conftest holds only the hermetic floor #1313 places it in that package's mirror directory. This item owns test_pr_cmd, test_pr_update, test_gh_cmd, test_github_milestones, test_repos and test_release. test(cli): every test file sits in the directory mirroring the package it tests or in tests/invariants/, and the root conftest holds only the hermetic floor #1313 places test_pr_cmd.py under tests/commands/ since what it tests is devops pr. (proposed)
- Which package owns merge readiness?: Proposed: github/, next to check_verdict.py, which already classifies check runs. The reply on refactor(github): pr readiness is one verdict module that the pr commands, the monitor and mcp consume #998 notes that it splits readiness into github/ (read and blockers) and roadmap/ (Item rules). Whichever lands second follows that split. (proposed)
- Which subject file takes the pull request template test?: Proposed: a new file, tests/invariants/test_pull_request_template.py, named after .github/pull_request_template.md. None of the existing Q13 subjects covers the template. The subject is added to the list in docs/TESTING.md so test(cli): Convert ratchets to bans and merge invariant tests #1336's ban accepts it. (proposed)
- Is this one pull request?: Decided 2026-10-07: under Q33 and Q19, it is filed now as one item. Refinement applies needs-split if it proves too big, and a domain move too big for the item gets its own item. Given 7,413 lines of test code, 380 patch sites, and four domain moves across two packages, this item does not fit one pull request. (proposed)
- How does refactor(github): pr readiness is one verdict module that the pr commands, the monitor and mcp consume #998 affect the merge readiness move?: refactor(github): pr readiness is one verdict module that the pr commands, the monitor and mcp consume #998 turns the readiness rules (commands/pr.py:1209-1805) into one verdict: read and blockers in github/, Item rules in roadmap/. Whichever lands second follows that split. This item's move of merge readiness into github/ must respect refactor(github): pr readiness is one verdict module that the pr commands, the monitor and mcp consume #998's split if refactor(github): pr readiness is one verdict module that the pr commands, the monitor and mcp consume #998 lands first. [sources: src/devops_cli/commands/pr.py:1209]
Fit
Needs splitting into 4 items:
- Remove 380 patch sites and 53 private imports from the owned test files; rewire every edge through its shared fake; reorganize tests into behaviour-named files in mirror directories; rename tests to CONTEXT.md terms; dissolve catch-alls; delete test_pr_cmd.py and test_repos.py.
- Move merge readiness, branch-update planning and rate-limit reads from commands/ into github/ behind public functions; test in tests/github/. Coordinate with refactor(github): pr readiness is one verdict module that the pr commands, the monitor and mcp consume #998's split of readiness into github/ and roadmap/.
- Move clone destination parsing from commands/repos.py into git/ behind a public function; test in tests/git/.
- Move the pull request template test to tests/invariants/test_pull_request_template.py and add the subject to the list in docs/TESTING.md.
Suspected block
None.
Dependencies
Alternatives check of 2026-10-30: not-applicable.
Tool: none found.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNew
- StatusShow more project fieldsNew
Activity
dan-petty commentedon Oct 8, 2026
Linked: #998, which turns the readiness rules (
commands/pr.py:1209-1805) into one verdict: read and blockers ingithub/, Item rules inroadmap/. Whichever lands second follows that split. Found by the 2026-10-08 backlog review.dan-petty-bot commentedon Oct 8, 2026
Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.
This is a maintainability improvement within a larger test refactoring effort, not a user-facing defect or security issue.Reducing 380 internal patch sites and 53 private imports makes the test suite more resilient to refactoring, but it does not add new user-facing capability.Six files totaling 7,413 lines and 297 tests must be rewritten to eliminate all internal patches and private imports, and logic must be relocated into packages.[-]test(cli): devops pr, gh, repos and release are thin adapters tested over edge fakes, and merge readiness and release rules are tested in their packages[/-][+]test(cli): devops pr, gh and repos are thin adapters tested over edge fakes, and merge readiness is tested in its package[/+]dan-petty commentedon Oct 26, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.
The change improves test quality and maintainability but does not affect core functionality or security.Improving test structure and reducing coupling benefits project stability and developer productivity.The work requires refactoring tests and may involve changing how internal patches are handled.Both items test CLI commands over edge fakes, but the candidate focuses on specific commands and their test structure while #1307 addresses general test practices for all CLI commands.dan-petty commentedon Oct 28, 2026
The proposal at 69636b6 needs splitting into 4 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.
devops-cli-service commentedon Oct 30, 2026
Alternatives check: not-applicable
Tool: none found
Checked on 2026-10-30. A person decides what this means for the item. The check changes no label and closes no issue.