Repository navigation
Closed
Labels
effort/highEffort High: much work, in one pull requestpriority/p1-highPriority P1: high-impact work for the next planned milestonescope/ciGitHub Actions workflows, pre-commit hooks, CI gates, and runnersscope/cliCore CLI framework, Typer subcommands, options, and tablestype/testType test: a new or changed testvalue/highValue High: the delivery of the item matters much
Description
Problem
- The suite is flat. All 447 test files sit directly in
tests/; its only subdirectories aretests/fixtures/andtests/golden/[measured: find at 5c45b1e]. AGENTS.md already asks for tests organised by submodule, mirroringsrc/devops_cli/, and allowstests/<submodule>/test_<feature>.py[code: AGENTS.md:159], but nothing checks it. The owner ranks findability second among the suite's problems (Q1). - Where a file belongs needs a rule. 146 of the 447 files have under 60% of their devops_cli references in one package directory (93 after discounting config, lang, exceptions, output, models and dry_run), and 9 reference no devops_cli module. The census groups proposed different directories for 23 files and claimed none for 16 [measured: census of 2026-10-07]. File names mislead:
tests/test_agent_invariants.pytests the pinned invariants ofPydanticAgent, not a committed file [code: tests/test_agent_invariants.py:1, :9], andtests/test_k8s_argocd_overrides.py, new with fix(k8s): argo cd takes homelab values from deploy-time overrides, and the repository holds no private or placeholder config #1290, testsk8s/argocd_overrides.pyalthough it also reads committed manifests [code: tests/test_k8s_argocd_overrides.py:15, :24]. - One conftest serves every package.
tests/conftest.pyhas 917 lines and 33 fixtures, 17 of them autouse [measured: grep at 5c45b1e]. Beside the isolation every test needs, it holds domain fixtures: the roadmap store (github_roadmap_factory:380,roadmap_store:408,unreadable_github_roadmap:430), git repositories (git:554,nested_worktree:580,symbol_removal_repo:600), review sessions (write_review_session:614,review_history:657),mock_keyring:710,mock_settings:719,docker_engine:744 withreset_docker_engine_singleton:750,public_dns:173,stub_web:204,register_test_mock_provider:59 andguard_live_rag_data:480.tmp_ssh_dir:696 andtmp_repos_dir:703 have no user [code: tests/conftest.py]. - Moving files today would break them. 48 files find the repo root through
__file__depth and 7 findtests/fixturesortests/goldenrelative to themselves [measured: grep at 5c45b1e]; 3 importtests.conftest; tests/test_roadmap_dry_runs.py:47 imports from another test file; anddevops testglobstests/non-recursively [code: src/devops_cli/commands/test_cmd.py:72]. 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 removes all of these first, so the move edits no test module. - One hook names test files by path.
detect-private-keyexcludestests/test_review_prompt_guardrails.pyandtests/test_security_gitleaks.py[code: .pre-commit-config.yaml:26]; moved without an update, both fail the hook.
Acceptance criteria
The move
- Every
tests/test_*.pykeeps its file name and moves into the directory mirroring thesrc/devops_clipackage that owns most of what it tests, at full depth (src/devops_cli/ai/review/*->tests/ai/review/). Ownership counts the devops_cli modules a file imports and the targets it patches, ignoring config, lang, exceptions, output, models and dry_run unless nothing else is referenced. A file whose tests mostly drive adevopscommand goes undertests/commands/with that command's module. Cross-package behaviour files (*_hardening.py,test_subprocess_env_boundary.py) go to the package that owns the behaviour. - The placement agrees with the phase E file lists: a file that an E item names lands in a directory that item covers, and no file is named by two E items. Where the ownership rule and a list disagree, the task file records the choice and the list is corrected before this PR merges. A name does not decide the directory:
test_agent_invariants.pygoes totests/ai/agents/,test_otel_command_coverage.py, which checks the spans and metrics every command emits, totests/telemetry/, andtest_k8s_argocd_overrides.pytotests/k8s/. - Invariant tests, whose subject is a committed repo file, move to
tests/invariants/under their current names, for exampletest_architectural_invariants.py,test_workflow_contracts.py,test_agent_task_files.py,test_agents_md_claims.pyand thetest_k8s_*files whose subject is the YAML underk8s/(such astest_k8s_argocd_apps.py). - Each new directory has an empty
__init__.py, so modules import astests.<dirs>.<name>and later behaviour-named files may share a base name across packages. - The task file lists every move (old path, new directory). For each file whose top package holds under 60% of its references, or whose directory the census disputed, it names the runner-up and why the chosen directory won. It also holds the commands that regenerate the move from that table.
Proof that the move is rename-only
-
git diff --name-status -M100% <merge-base>...HEAD -- tests/shows anR100line for every moved test file, and otherwise onlyM tests/conftest.py, addedconftest.pyfiles, added empty__init__.pyfiles, added or modified files undertests/support/that receive moved fixtures, the layout ratchet intests/invariants/test_source_tree.py, and, 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 ceiling table re-keyed as below.git diff -M --statshows 0 changed lines for every rename. - The test IDs from
pytest --collect-only -qat the merge base and at HEAD are the same set once the directory part of each path is dropped, and the full run passes, skips and xfails the same numbers of tests. Both comparisons are recorded in the task file.
The conftest split
- The root
tests/conftest.pyholds only the hermetic floor as 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 leaves it (network block; isolation of env, data dir, config, kubeconfig, gh config and D-Bus; process-wide resets; the workspace tripwire) and onepytest_pluginsentry that registers the shared fixtures intests/support/, 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'scliandconfigfixtures among them (Q14, Q16, Q25; pytest readspytest_pluginsonly from the top-level conftest). - Every other fixture moves with its body unchanged. One used only under one directory goes to that directory's
conftest.py; one used across directories goes totests/support/, beside its fake if it has one. A directory gets aconftest.pyonly when it has fixtures of its own. The task file lists each fixture and its destination. Fixtures with no user (tmp_ssh_dir,tmp_repos_dir, if still present) are deleted.
The layout ratchet
- A ratchet in
tests/invariants/test_source_tree.py, the Q13 subject file for source-tree invariants (created here, or extended 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 created it first), counts thetest_*.pyfiles that are neither in a directory mirroring asrc/devops_clipackage nor undertests/invariants/;tests/itself mirrors the top-level modules__init__.py,entry.pyandmain.py. Its ceiling is the count after this PR and may only go down. A second ceiling holds the number of test files directly intests/. - On fixture trees the ratchet fails and names the path for: a test file in a directory with no matching package, a test file under
tests/support/, and a mirror directory whose package has leftsrc/. - 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 ceiling table is re-keyed from the move table: paths change, counts do not. Rows for fixtures that leave the root conftest follow them to their destinations, so each ratchet's total stays the same.
Landing
- The
detect-private-keyexclusion (.pre-commit-config.yaml:26) names the two files' new paths. - (person-run) The PR merges into
mainat a quiet point, when few open PRs changetests/. If another PR changestests/first, the move is regenerated from the task file's table rather than rebased. -
uv run devops cipasses.
Key questions
- One move, or one per package? Decided 2026-10-07: one mechanical move PR at a quiet point on
main; design fixes land per package as separate items (Q4). - Rename or edit files while moving? Decided 2026-10-07: no. Pure
git mvof whole files plus the conftest split, so git records each move as a rename andgit log --followkeeps the history. Behaviour-named files come with the package items (Q10, Q17, Q29). - Where does a file that tests several packages go? Decided 2026-10-07: to the package owning most of what it tests; its package item splits it (Q17).
- Which directories may hold tests outside the mirror? Decided 2026-10-07: only
tests/invariants/, for tests whose subject is a committed repo file (Q13). - Do invariant files take their subject names (
test_source_tree.py,test_agents_md.py,test_task_files.py, ...) here? Decided 2026-10-07: no; the move renames nothing (Q17, Q29), and Q13 fixes the subject names. (proposed) test(cli): Convert ratchets to bans and merge invariant tests #1336 merges each moved invariant file into its subject file and bans any other name intests/invariants/; 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, test(k8s): devops k8s commands are thin adapters tested over edge fakes, and the _K8sModule patch forwarding is gone #1323 and test(ci): devops ci, test, devcontainer, workspace, install-tools, uv, branches and pipeline are tested over edge fakes, with no lazy patch targets or PYTEST_CURRENT_TEST checks #1325 add their invariant tests to the subject files, not to new parallel files. - Where do shared fixtures go? Decided 2026-10-07:
tests/support/, registered once from the root conftest; domain fixtures go to package conftests or beside their fake (Q15, Q25). - What about paths to moved files cited outside
tests/? (proposed) Live docs, comments and strings that cite a moved file (AGENTS.md, CONTRIBUTING.md,docs/,k8s/README.md, comments and strings insrc/, and.github/workflows/ci.yml) get path-only substitutions in a separate commit of this PR.CHANGELOG.md, task files, the archive and dated logs keep the paths they had. Mentions inside test modules wait for their package items, since this PR edits no test module.
Strategic alignment
- Depends on: 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, 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. Blocks: test(github): github/ is tested through its public interface over the gh process and session fakes, with no internal patches or private imports #1321, 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, test(k8s): devops k8s commands are thin adapters tested over edge fakes, and the _K8sModule patch forwarding is gone #1323, test(cli): devops pr, gh and repos are thin adapters tested over edge fakes, and merge readiness is tested in its package #1324, test(ci): devops ci, test, devcontainer, workspace, install-tools, uv, branches and pipeline are tested over edge fakes, with no lazy patch targets or PYTEST_CURRENT_TEST checks #1325, test(ai): devops review, devops analyze and the devops ai commands are thin adapters tested over the model seam and edge fakes #1326, test(cli): the infra commands are thin adapters tested over edge fakes, with no internal patches or private imports #1327, test(review): ai/review and review/ are tested through one public interface over the model, tool-executor and process fakes, with no mock detection in src #1328, test(ai): Wire rag once in ai/rag, test with edge fakes #1329, test(mcp): mcp, agent and tool tests run on edge fakes #1330, test(ai): the remaining ai modules are tested through their public interfaces on edge fakes, and the legacy provider layer leaves src #1331, test(security): scanner, secret and crypto tests run on the executor, process, http and keyring fakes, and scanners stop looking for mocks #1332, test(cli): Use edge fakes and real git; drop test rebind hooks #1333, test(telemetry): telemetry, server, ui, output and docs tests run on edge fakes, and the dashboard suite splits by behaviour #1334, test(infra): infrastructure tests run on edge fakes #1335. Related: docs(cli): docs/TESTING.md holds the test conventions, ADR 0005 records that tests double only process edges, and AGENTS.md and the contributor docs point to them #1308 (TESTING.md documents the layout), 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 other ratchets, in the same subject file; this PR re-keys their ceiling table), fix(ci): tests touch no state outside their temporary directories #1311 (also edits the root conftest), test(cli): Convert ratchets to bans and merge invariant tests #1336 (merges the moved invariant files into the Q13 subject files and turns the layout ratchet into a ban).
- Parent: test(cli): tests double only process edges and mirror the source tree #1307 (phase C).
Proposed design
Problem statement
The test suite is flat with 447 files in tests/ directory. Files are not in directories mirroring the source package structure. The root conftest.py holds many fixtures that should be isolated.
Acceptance criteria
- Criterion 1: Every test file moves to a directory that mirrors its main devops_cli package
Verification: Files like tests/test_agent_invariants.py move to tests/ai/agents/ and tests/test_k8s_argocd_overrides.py to tests/k8s/ - Criterion 2: Invariant test files go to tests/invariants/ directory with their current names
Verification: Files such as test_architectural_invariants.py, test_workflow_contracts.py move to tests/invariants/ directory - Criterion 3: Each new directory has an empty init.py file
Verification: New directories like tests/ai/agents/init.py exist and are empty - Criterion 4: Root conftest.py holds only hermetic floor fixtures
Verification: Root tests/conftest.py contains only network block, isolation and workspace tripwire fixtures - Criterion 5: All moved test files are recognized as renames by git
Verification: git diff --name-status -M100% shows R100 lines for all moved files
Key questions
- One move, or one per package?: One mechanical move PR at a quiet point on main (proposed)
- Rename or edit files while moving?: No. Pure git mv of whole files plus the conftest split (proposed)
- Where does a file that tests several packages go?: To the package owning most of what it tests (proposed)
- Which directories may hold tests outside the mirror?: Only tests/invariants/ for tests whose subject is a committed repo file (proposed)
- Do invariant files take their subject names here?: No. The move renames nothing (proposed)
- Where do shared fixtures go?: tests/support/ registered once from the root conftest (proposed)
- What about paths to moved files cited outside tests/?: Live docs, comments and strings that cite a moved file get path-only substitutions in a separate commit of this PR (proposed)
Open questions
- Do invariant files take their subject names (
test_source_tree.py,test_agents_md.py,test_task_files.py, ...) here? Decided 2026-10-07: no; the move renames nothing (Q17, Q29), and Q13 fixes the subject names. (proposed) test(cli): Convert ratchets to bans and merge invariant tests #1336 merges each moved invariant file into its subject file and bans any other name intests/invariants/; 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, test(k8s): devops k8s commands are thin adapters tested over edge fakes, and the _K8sModule patch forwarding is gone #1323 and test(ci): devops ci, test, devcontainer, workspace, install-tools, uv, branches and pipeline are tested over edge fakes, with no lazy patch targets or PYTEST_CURRENT_TEST checks #1325 add their invariant tests to the subject files, not to new parallel files.
Fit
Needs splitting into 3 items:
- Split the root conftest.py into package-specific conftest.py files
- Move test files to their mirrored package directories
- Update layout ratchet in tests/invariants/test_source_tree.py
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-10-29: not-applicable.
Tool: none found.
Metadata
Metadata
Assignees
Labels
effort/highEffort High: much work, in one pull requestpriority/p1-highPriority P1: high-impact work for the next planned milestonescope/ciGitHub Actions workflows, pre-commit hooks, CI gates, and runnersscope/cliCore CLI framework, Typer subcommands, options, and tablestype/testType test: a new or changed testvalue/highValue High: the delivery of the item matters much
Type
Projects
- StatusShow more project fieldsNew
- StatusShow more project fieldsNew
Activity
9 remaining items
feat(release): v0.2.37 (#1720)
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.
Improving test organization and infrastructure is critical for maintainability and developer experience.Better organized tests improve findability, reduce confusion, and make refactoring easier for developers.Moving 447 files and restructuring the conftest requires significant coordination and testing.Both items aim to reorganize tests but #1307 focuses on mirroring the source tree and using edge fakes, while this candidate focuses on directory placement and conftest cleanup.dan-petty commentedon Oct 26, 2026
Refine cannot set this item to Ready at 48c78ca until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.
test_source_tree.py,test_agents_md.py,test_task_files.py, ...) here? Decided 2026-10-07: no; the move renames nothing (Q17, Q29), and Q13 fixes the subject names. (proposed) test(cli): Convert ratchets to bans and merge invariant tests #1336 merges each moved invariant file into its subject file and bans any other name intests/invariants/; 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, test(k8s): devops k8s commands are thin adapters tested over edge fakes, and the _K8sModule patch forwarding is gone #1323 and test(ci): devops ci, test, devcontainer, workspace, install-tools, uv, branches and pipeline are tested over edge fakes, with no lazy patch targets or PYTEST_CURRENT_TEST checks #1325 add their invariant tests to the subject files, not to new parallel files.devops-cli-service commentedon Oct 29, 2026
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.