Repository navigation
Description
Problem or Motivation
docs/TESTING.md says that product code holds nothing for tests. On origin/main (2026-10-28) src/devops_cli has 9 test accommodations:
unittest.mockimports:security/base.py:18,ai/review/pipeline.py:657;- the string
PYTEST_CURRENT_TEST:commands/ci.py:418,:422,core/process.py:109; - a mock attribute probed by name:
sandbox/host.py:101(_mock_return_value); - a
__module__value compared with"subprocess":core/process.py:670,:1080,sandbox/host.py:99.
Nothing stops a new one. #1309 planned a per-file ratchet for them. It was closed as not planned, because newer owner decisions add no new ratchet and no baseline file (#1016 and the rigid-rules decision Q4, 2026-10-22; #423, 2026-10-24). With only 9 sites, the sites can be removed and the forms banned at zero, with no baseline.
Proposed Solution & Architectural Design
- Remove the 9 sites. Each one is replaced by the seam or fake that the test needs, as
docs/TESTING.mddescribes. A test that relied on a site doubles the process edge instead. - Ban
unittestandunittest.mockimports insrc/with Ruff'sbanned-api(TID251), whichpyproject.tomlalready configures, and a per-file ignore fortests/. - Ban the string
PYTEST_CURRENT_TEST, aNonCallableMockattribute name that starts withassert_or_mock_, and a comparison of a__module__value with a standard-library module name, insrc/, with ast-grep rules and their rule tests. - No ceiling table, no baseline file and no lowering command.
Target Subsystem
src/devops_cli (security/base.py, ai/review/pipeline.py, commands/ci.py, core/process.py, sandbox/host.py), pyproject.toml, the ast-grep rules, docs/TESTING.md.
Existing Tool Considered
Ruff banned-api (TID251) for imports, and ast-grep for the other forms. Both already run in devops ci and in the pre-commit hooks. Nothing new is built.
Acceptance criteria
src/devops_cliholds none of the 9 sites.- Ruff reports TID251 for a fixture
src/module that importsunittest.mock, and not for a module undertests/. - Each ast-grep rule has a rule test with one failing and one passing case, including the
getattr(..., "__module__")form and a__module__read that is not compared with a standard-library name. docs/TESTING.mdnames the bans and drops the ratchet for test accommodations from its target list.uv run devops cipasses.
Related
#1309 (closed as not planned), #1307, #1336, #1016, #423.
Source: #1309
Activity
dan-petty commentedon Oct 28, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
The change removes existing code and adds static-analysis bans without altering user-facing behaviour.It prevents a known class of test accommodation from growing but does not block a release or fix a defect.It enforces the TESTING.md rule that product code holds no test hooks, reducing future coupling.Nine sites to replace, one Ruff rule to activate, and three ast-grep rules with passing and failing tests to write.Both remove test accommodations from src/ and add a check to block new ones, but #2166 targets two specific F401 re-imports and a private alias while the candidate targets nine sites of mock imports, PYTEST_CURRENT_TEST, mock attributes, andan-petty commentedon Oct 28, 2026
This item cannot be built as written in one pull request. Each of its 9 sites and its bans is already in the acceptance criteria of an older open item. No code was written.
Evidence (origin/main 0137f23, 2026-10-28):
security/base.py:18(NonCallableMock), with_is_mocked, the three mock-aware wrappers and the 58 patch sites that rely on themai/review/pipeline.py:657(NonCallableMock)sandbox/host.py:99,:101(__module__,_mock_return_valuein_is_mock_subprocess)commands/ci.py:418,:422(PYTEST_CURRENT_TEST)PYTEST_CURRENT_TESTreads"core/process.py:109(PYTEST_CURRENT_TESTpass-through),:670,:1080(async reroute onsubprocess.run.__module__)src, of the four kinds #1309 counts"A site cannot go before the tests that rely on it move to the fakes. For example, removing the
security/base.pysite needs the rewrite of the 58 patch sites that #1332 owns. So this item, built as written, does the work of #1325, #1328, #1332, #1333 and #2149 in one pull request.One part of this item is new: the bans use Ruff
banned-api(TID251) forunittestimports and ast-grep rules with rule tests for the other three kinds, instead of hand-written invariant tests. That fits the rigid-rules decision Q4 (2026-10-22: a tool owns its configuration). It is a design choice for #1336, which adds the bans after #1321 to #1335 bring each count to zero.Proposed next step for a person: close this item as a duplicate of #1325, #1328, #1332, #1333, #2149 and #1336, and add the tool choice for the bans to #1336.
dan-petty commentedon Oct 28, 2026
Closing as duplicate.