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.
- Files. 12 test files, 6,037 lines, 246 tests [measured: AST pass at 5c45b1e]:
test_ci,test_ci_build_index,test_ci_dry_run,test_ci_maintain,test_test_selection,test_test_runner,test_load_and_pipeline,test_devcontainer,test_workspace,test_install_tools,test_uvandtest_branches.- No other item names
commands/pipeline.py(devops pipeline run). Its tests sharetest_load_and_pipeline.pywithdevops test load, so this item takes it (see Key questions).
- No other item names
- Coupling. All 12 files hold internal patch sites, 213 in total, and 6 of them hold the 76 private imports [measured]. Most of the private imports are in
test_devcontainer.py(37),test_ci.py(17) andtest_install_tools.py(17).- Most-patched internals:
ci._get_project_root22,devcontainer.run_subprocess21,ci._run18,install_tools._download12,ci.run_subprocess11,test_cmd.run_subprocess9,ci.cache.compute_worktree_blob_hashes8,devcontainer._keyring_is_locked7,workspace._PROJECT_ROOT6. - Another 57 sites patch
shutil.which(34),subprocess.run(20) orsubprocess.Popen(3) directly. - 11 of the files build a module-level
runner = CliRunner().
- Most-patched internals:
- Product code shaped for tests (Q27).
- Four command modules carry the
_LAZY_OBJECT_MAPPING/__getattr__/_getblock, with this many_getcalls:commands/ci.py:56-89(40),commands/uv.py:17-39(4),commands/workspace.py:24-56(25),commands/branches.py:18-51(20). refactor(cli): one process runner owns execution, process groups and dry-run #775 plans to replace these blocks with function-local imports. _clean_coverage_artifactsreturns early underPYTEST_CURRENT_TEST[code: commands/ci.py:253]. In that case it also compares the root against its own source tree [code: commands/ci.py:257-260].- The process runner passes
PYTEST_CURRENT_TESTthrough to children [code: core/process.py:93]; test(cli): Use edge fakes and real git; drop test rebind hooks #1333 owns that module.
- Four command modules carry the
- Edges outside a seam.
commands/devcontainer.py:- 15
shutil.whichcalls [code: commands/devcontainer.py:524-1523]; - a
subprocess.Popen[code: commands/devcontainer.py:1042]; - gh calls made outside
run_gh[code: commands/devcontainer.py:1461, :1466]; - a D-Bus socket [code: commands/devcontainer.py:1283] and
secretstorage[code: commands/devcontainer.py:1396]; - a TCP probe of the local git daemon [code: commands/devcontainer.py:1221];
SIGALRM[code: commands/devcontainer.py:1440];- a
time.sleeppoll [code: commands/devcontainer.py:946].
- 15
commands/install_tools.pybuilds httpx2 clients [code: commands/install_tools.py:84, :100, :190] and callsshutil.which[code: commands/install_tools.py:495].commands/test_cmd.pycallsshutil.which[code: commands/test_cmd.py:235].devops test sandboxruns through the Docker engine [code: commands/test_cmd.py:398].
- Logic living in commands/ (Q19).
commands/ci.py(1,765 lines) holds:- check specs and selection [code: commands/ci.py:398-612];
- the gate cache [code: commands/ci.py:888-993];
- result assembly [code: commands/ci.py:683, :1016];
- coverage-artifact cleanup [code: commands/ci.py:219-273];
- test-target selection [code: commands/ci.py:1131-1358], which imports private
core.coverage_indexnames [code: commands/ci.py:1174].
- Files and names.
test_devcontainer.py: 2,042 lines, 89 tests in one class.test_ci.py: 1,878 lines, 64 tests. Ten of its tests take a committed workflow or action file as their subject (:575,:598,:637,:670,:697,:749,:1031,:1056,:1836,:1846); the two at:1031and:1056run the workflow's image-change step in a temporary repository.- Catch-alls:
test_ci.py:318,:342,:383,:463;test_devcontainer.py:823,:939,:1020;test_install_tools.py:167;test_uv.py:46;test_workspace.py:109;test_branches.py:63.
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 any 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 (213 and 76 at 5c45b1e). - Accommodations are gone.
- refactor(cli): one process runner owns execution, process groups and dry-run #775 replaces the lazy-lookup blocks in
ci.py,uv.py,workspace.pyandbranches.pywith function-local imports and lands first. This item confirms they are gone and removes any part that remains (Q27). - This item deletes the two
PYTEST_CURRENT_TESTreads [code: commands/ci.py:253, :257]. rg -n "_LAZY_OBJECT_MAPPING|PYTEST_CURRENT_TEST" src/devops_cli/commands/{ci,uv,workspace,branches}.pyprints nothing.- If test(cli): Use edge fakes and real git; drop test rebind hooks #1333 has landed, this item also deletes the pass-through [code: core/process.py:93], so
rg -n PYTEST_CURRENT_TEST src/prints nothing. - 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 accommodation ceiling drops by the sites removed.
- refactor(cli): one process runner owns execution, process groups and dry-run #775 replaces the lazy-lookup blocks in
- Edges only through seams.
- Processes, including the
Popen, gh andshutil.which, go through refactor(cli): one process runner owns execution, process groups and dry-run #775's process fake. - Downloads go through refactor(cli): Unify HTTP and DNS seams with shared fakes #1314.
- The sandboxed test run goes through refactor(infra): DockerEngineService is the Docker engine seam, with a shared in-memory engine fake and its contract suite #1316's Docker engine fake.
- The keyring and session bus go through refactor(security): one keyring seam owns the keyring and the Secret Service lock check, with a shared keyring fake and its contract suite #1318.
- 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.
- No test patches
subprocess,shutil.which,run_subprocess,_run,_get_project_rootor_PROJECT_ROOT. Tests run inside a temporary repository, and the floor restores the working directory.
- Processes, including the
- 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 moves out of
commands/(Q19).- Check specs, the gate cache, result assembly and coverage cleanup move into
ci/as public functions, tested intests/ci/. - Test-target selection moves into
core/test_selection.pyand stops importing private names. commands/ci.pybecomes a thin adapter.
- Check specs, the gate cache, result assembly and coverage cleanup move into
- The ten workflow tests are added to the Q13 subject file
tests/invariants/test_workflows.py, which this item creates if no earlier item has. No second workflow file is added beside it; test(cli): Convert ratchets to bans and merge invariant tests #1336 mergestest_workflow_contracts.py, which 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 moved, into the same subject file. - Behaviour files (Q10).
test_devcontainer.pyandtest_ci.pyare deleted. Their tests live in behaviour files, for exampletests/ci/test_gate_cache.py,tests/ci/test_check_selection.pyandtests/commands/test_devcontainer_post_start.py.- The catch-alls are dissolved.
- Test names state behaviour (Q8), and assertions compare whole values (Q7).
- CLI tests use the shared
clifixture in place of the 11 module-level runners (Q14).
- Generated files, such as the devcontainer's Claude Code MCP configuration and the workspace file, are compared as 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).
- Every line that no public behaviour reaches is deleted (Q22). 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)commands/pipeline.pyjoins this item, although test(cli): tests double only process edges and mirror the source tree #1307's default sends a command no child names to the item of its domain package (test(infra): infrastructure tests run on edge fakes #1335 forpipeline/):devops pipeline runanddevops test loadshare one 72-line test file,test_load_and_pipeline.py. - Where does the devcontainer logic go? (proposed) It has no domain package, so it stays in
commands/devcontainer.pyand is tested through the CLI with edge fakes. Creating a package for it would be a separate item. - Does the CI logic move in this item? (proposed) Yes, into
ci/, tested intests/ci/; test(infra): infrastructure tests run on edge fakes #1335, which ownsci/, does not move it. If refinement finds the move too big, it gets its own item (Q19), and this item tests that logic through the CLI with edge fakes until then. - How does
devops workspacefind its root? (proposed) Today it resolves the root from__file__[code: commands/workspace.py:62]. Instead it resolves the current worktree root, ascommands/ci.py:95does, so tests run in a temporary repository. - Is this one pull request? Decided 2026-10-07: under Q33, it is filed now as one item. Refinement applies
needs-splitif it proves too big.
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(cli): Unify HTTP and DNS seams with shared fakes #1314, refactor(infra): DockerEngineService is the Docker engine seam, with a shared in-memory engine fake and its contract suite #1316, refactor(security): one keyring seam owns the keyring and the Secret Service lock check, with a shared keyring fake and its contract suite #1318, 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(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 (
devops testmaps changed files to mirror directories), test(k8s): k8s/ is tested through its public interface over the Kubernetes API, process, HTTP and keyring fakes, with no internal patches or private imports #1322 (moves_apply_configured_k8s_contextout ofdevcontainer.py), test(cli): Use edge fakes and real git; drop test rebind hooks #1333 (ownscore/test_selection.pyandcore/process.py; whichever of the two items lands second deletes thePYTEST_CURRENT_TESTpass-through), test(infra): infrastructure tests run on edge fakes #1335 (ownsci/; does not move the CI logic). - Parent: test(cli): tests double only process edges and mirror the source tree #1307 (phase E).
Proposed design
Problem statement
Twelve test files (6,037 lines, 246 tests) for devops ci, test, devcontainer, workspace, install-tools, uv, branches and pipeline use 213 internal patch sites and 76 private imports. Product code holds test accommodations: lazy patch targets in four command modules and PYTEST_CURRENT_TEST checks in ci.py and process.py. Domain logic (check specs, gate cache, result assembly, coverage cleanup, test-target selection) lives in commands/ci.py instead of its package. This item removes all accommodations, moves logic to its package, and rewrites the tests over edge fakes with behaviour-based naming.
Acceptance criteria
- Criterion 1: The 12 test files under tests/commands/ have zero patch sites aimed at devops_cli internals and zero private imports.
Verification: Runrg -n 'patch\(|from devops_cli.* import _' tests/commands/test_ci*.py tests/commands/test_test_*.py tests/commands/test_load_and_pipeline.py tests/commands/test_devcontainer.py tests/commands/test_workspace.py tests/commands/test_install_tools.py tests/commands/test_uv.py tests/commands/test_branches.pyand confirm no output. - Criterion 2: No _LAZY_OBJECT_MAPPING or PYTEST_CURRENT_TEST references remain in the four command modules or core/process.py.
Verification: Runrg -n '_LAZY_OBJECT_MAPPING|PYTEST_CURRENT_TEST' src/devops_cli/commands/ci.py src/devops_cli/commands/uv.py src/devops_cli/commands/workspace.py src/devops_cli/commands/branches.py src/devops_cli/core/process.pyand confirm no output. - Criterion 3: No test patches subprocess, shutil.which, run_subprocess, _run, _get_project_root or _PROJECT_ROOT. Tests run inside a temporary repository.
Verification: Runrg -n 'subprocess|shutil\.which|run_subprocess|_run\(|_get_project_root|_PROJECT_ROOT' tests/commands/test_ci*.py tests/commands/test_test_*.py tests/commands/test_load_and_pipeline.py tests/commands/test_devcontainer.py tests/commands/test_workspace.py tests/commands/test_install_tools.py tests/commands/test_uv.py tests/commands/test_branches.pyand confirm no patch targets remain. - Criterion 4: Check specs, gate cache, result assembly and coverage cleanup are public functions in ci/. Test-target selection is in core/test_selection.py. commands/ci.py is a thin adapter.
Verification: Runrg -n '^def ' src/devops_cli/ci/and confirm the functions exist. Runrg -n '^def ' src/devops_cli/core/test_selection.pyand confirm test-target selection is there. Confirm commands/ci.py contains no logic beyond CLI argument parsing and delegation. - Criterion 5: The 10 workflow tests live in tests/invariants/test_workflows.py. No second workflow file exists beside it.
Verification: Runls tests/invariants/test_workflows.pyand confirm it exists. Runrg -l 'workflow' tests/and confirm only test_workflows.py holds workflow tests. - Criterion 6: test_devcontainer.py and test_ci.py are deleted. Their tests live in behaviour files. Catch-alls are dissolved. Test names state behaviour.
Verification: Runls tests/commands/test_devcontainer.py tests/commands/test_ci.py 2>&1and confirm both report No such file. Runrg -n 'def test_' tests/ci/ tests/commands/and confirm test names state behaviour. - Criterion 7: The 90% coverage gate passes and
uv run devops ciexits with code 0.
Verification: Runuv run devops ciand confirm exit code 0.
Key questions
- Which files belong to this item?: The 12 files named in the body: test_ci, test_ci_build_index, test_ci_dry_run, test_ci_maintain, test_test_selection, test_test_runner, test_load_and_pipeline, test_devcontainer, test_workspace, test_install_tools, test_uv and test_branches. commands/pipeline.py joins this item. (proposed)
- Where does the devcontainer logic go?: It stays in commands/devcontainer.py and is tested through the CLI with edge fakes. Creating a package for it is a separate item. (proposed) [sources: src/devops_cli/commands/devcontainer.py]
- Does the CI logic move in this item?: Yes, into ci/, tested in tests/ci/. If the move is too big for one PR, it gets its own split and this item tests that logic through the CLI with edge fakes until then. (proposed) [sources: src/devops_cli/commands/ci.py]
- How does devops workspace find its root?: It resolves the current worktree root, as commands/ci.py:95 does, so tests run in a temporary repository. (proposed) [sources: src/devops_cli/commands/workspace.py:62, src/devops_cli/commands/ci.py:95]
- Is this one pull request?: No. The scope (6,037 lines of test code, 246 tests, moving 1,765 lines of product code, creating new packages) exceeds one PR. It splits into multiple items. (proposed) [sources: src/devops_cli/commands/ci.py]
Fit
Needs splitting into 6 items:
- Move CI logic (check specs, gate cache, result assembly, coverage cleanup) into ci/ package, tested in tests/ci/
- Move test-target selection into core/test_selection.py and stop importing private names
- Remove lazy patch targets and PYTEST_CURRENT_TEST accommodations from product code
- Refactor test files for ci, test, load_and_pipeline to use edge fakes; create behaviour files in tests/ci/
- Refactor test files for devcontainer, workspace, install-tools, uv, branches to use edge fakes; create behaviour files
- Move 10 workflow tests to tests/invariants/test_workflows.py and fix workspace root resolution
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-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.
It is a planned maintainability refactor within an existing epic, not a defect or security gap, so it is important but not urgent.Removing 213 internal patch sites and 76 private imports across 246 tests will make the suite resilient to refactoring and easier to maintain.Twelve test files totalling 6,037 lines and 246 tests must be rewritten, plus product-code test hooks (lazy mappings, PYTEST_CURRENT_TEST checks) must be removed.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.
This item improves test quality and maintainability but does not address a critical issue.Improving test coverage and reducing coupling benefits the overall project health.The effort involves refactoring tests and ensuring no lazy patch targets or PYTEST_CURRENT_TEST checks exist.Both items test CLI commands with edge fakes but the candidate focuses on CI-related tests while item 1327 covers infra commands.dan-petty commentedon Oct 28, 2026
The proposal at 69636b6 needs splitting into 6 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.
refactor(docker): DockerEngineService is the Docker engine seam, with…
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.