Repository navigation
Description
Problem or Motivation
Phase E migration of the tests of ai/mcp/, ai/agents/, ai/harness/, ai/tools/ and ai/toolsets/. The goal: these tests double only edges, and src holds no test switch.
This text replaces the body of 2026-10-07. That body was written at v0.2.28 and is mostly stale. Refine ruled twice that one pull request cannot carry the work. This item is now a tracker. Six child items carry the work. Each child is one reviewable pull request.
Measured at origin/main 29309f0 (2026-11-06). The files named below are identical at 4a2d958, where the first count was made.
Already delivered. No work remains.
- The mock check in
ai/mcp/server.pyis gone. PlaywrightBrowseris gone.ai/harness/holds onlyskills.pyandslots.py. It has no process spawn and no process-group signal.- No
LLMClient(construction remains inai/agents/,ai/harness/,ai/mcp/orai/tools/. - These test files do not exist:
test_harness.py,test_synthesis_protocol.py,test_runtime_security_and_ssrf_hardening.py, and the fivetest_ai_agent_*files for guardrails, media, prompt, spend and step persistence. - The scanner tools in
tests/security/test_builtin_tools.pyalready run onscanner_fake.tests/ai/review/test_review_security_tools.pyhas no patch and no private import.
Dropped as stale.
- All ratchet and ceiling criteria. 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 is closed as not planned. The owner direction is a ban at zero, with no ceiling table and no baseline. test(cli): Convert ratchets to bans and merge invariant tests #1336 turns the counts into bans after this item. Each child still removes the sites in its files.
- The separate coverage criterion. Each child passes
uv run devops ci, which holds the coverage gate. - The criterion about 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 interim
unreachable(...)markers. No file of this item uses one that hides a missing fake.
Handed to other open items. Two parts of the old text have an owner now.
- refactor(ai): Replace PydanticAgent with pydantic-ai Agent #2489 deletes the hand-rolled loop:
PydanticAgent,runner.py,MultiAgentPipelineandAgentMemory, with their tests. This item builds no test, rename or split for that code. The files aretest_pydantic_agent.py,test_agent.py,test_agent_invariants.py,test_ai_agent_deferred_tools.py,test_pydantic_ai_exceptions.py,test_pydantic_ai_native_capabilities.pyandtests/ai/rag/test_pipeline_context_budget.py. The tests in them that survive move to edge fakes in the refactor(ai): Replace PydanticAgent with pydantic-ai Agent #2489 pull request that rewrites them. A comment on refactor(ai): Replace PydanticAgent with pydantic-ai Agent #2489 says this. - test(ai): Wire rag once in ai/rag, test with edge fakes #1329 criterion 4 makes the RAG investigator get its client and embedder from
resolve_qdrant_clientandcreate_embedder. This item does not touch the investigator.
Still open, one child each.
| Child | Work | Size at 29309f0 |
|---|---|---|
| A | ALLOW_MODEL_REQUESTS, ModelNotAllowedError, _RUN_MESSAGES_CAPTURE and ai/agents/testing.py in src |
4 source files, 1 doc, 11 test files |
| B | The MCP tool tests patch _run_mcp_cmd by name 20 times and run_subprocess 4 times |
3 files, 2,837 lines, 35 string patches, 7 more patch targets, 12 private imports |
| C | test_builtin_tools.py: 23 patches on processes, RAG, keys, the clock and the OSV, Shodan and Radar clients |
1 file, 938 lines |
| D | Outbound MCP code that no command, setting or tool reaches | 5 source files, 2 KB pages, 1 doc, 2 test files |
| E | test_harness_slots.py: 1 internal patch, 2 private imports, and one misplaced client test |
2 files |
| F | File names and file size of the MCP tests, the toolset and tool tests, and the tool-listing snapshot | 5 files and 1 new snapshot |
Proposed Solution & Architectural Design
Close this item when all six children are closed. Open the children in this order.
| Child | Blocked by | Why |
|---|---|---|
| A | none | First. It removes switches and the tests that use them. |
| B | none | Adds one seam, install_mcp_dispatcher, and deletes the dead process branch of the MCP server. |
| C | none | The process, Qdrant, embedder, HTTP and clock fakes exist at 29309f0. C wires rag_search to the RAG seam and adds one method to the embedder fake. |
| D | none | Deletion after a caller search. It edits two tests that A also edits. The second to land rebases. |
| E | none | A small change in the harness tests. |
| F | B | F moves and renames the files that B edits. F goes last to avoid conflicts. |
Issue numbers of the children are added to this table after the children exist.
Decisions made in this plan.
- Outbound MCP is deleted (child D). The caller search found no command, setting, tool or entry point that reaches it. The class
MCPToolsetinai/agents/tools.pydoes not even connect. Itsclosedoes nothing and itsget_toolsreturns the list it was given. A seam for code with no caller would be zombie code. Open feat(roadmap): let a job call the tools of the MCP server #3221 plans a job-side MCP client. It uses pydantic-ai's ownMCPToolset, not the deleted wrapper, so the deletion does not block it. - The MCP seam is the dispatcher, not the process runner (child B). The 2026-10-07 text said that
uv run devopscalls go through the process fake. That is false at 29309f0.InProcessDispatcher._dispatch_typerruns the Typer app in the same process, sofake.requestsnever sees these calls. Every call site inai/mcp/server.pyand the one ingenerator.pypasses auv run devopsargv. So the subprocess branches run only in tests. Child B deletes them and adds a hook to install a dispatcher fake. - The dispatcher seam is a deliberate step beyond "edges only".
docs/TESTING.mdlists "uv run devopscalling itself" as a faked process edge. That is wrong for the MCP layer, because nothing starts a process. The dispatcher is the one place where an MCP tool hands adevopsargv to the CLI app. A test can assert the argv of a tool only there. Child B correctsdocs/TESTING.mdand adds a contract suite that holds the fake to the real dispatcher. - The OSV, Shodan and Radar tests need no wait on refactor(cli): Unify HTTP and DNS seams with shared fakes #1314 (child C).
security/vulnerability_lookup.pyalready builds its clients throughnew_http_client, and thestub_webfixture answers them. refactor(cli): Unify HTTP and DNS seams with shared fakes #1314 lists this item as blocked by it. That block is not needed. A person may drop the line from refactor(cli): Unify HTTP and DNS seams with shared fakes #1314. - The ratchet criteria fold into nothing. Each child removes the sites in its own files. test(cli): Convert ratchets to bans and merge invariant tests #1336 bans the forms for the whole suite.
- Files outside the list are not touched. 16 sites in 10 test files outside
tests/ai/mcp/patchai.mcp.server._run_mcp_cmd. They are in the argo, roadmap, commands, docs, telemetry, tf and ai tests. Four more sites are in 3 files oftests/ai/mcp/that this item does not name:test_path_confinement.py,test_mcp_tool_secrets.pyandtest_ai_gateway.py. Each belongs to the item that owns its package. The dispatcher fake of child B is the replacement. test(cli): Convert ratchets to bans and merge invariant tests #1336 finds what remains.
Exit check for this item. All commands run at the commit that closes the last child.
git grep -nE 'ALLOW_MODEL_REQUESTS|ModelNotAllowedError|MODEL_REQUESTS_DISABLED|_RUN_MESSAGES_CAPTURE|_is_testing_mode_active|agents\.testing' -- src tests docs ':!docs/agent/archive'returns no line.git grep -nE 'devops_cli\.ai\.agents\.tools import .*MCPToolset|ai\.mcp\.toolset|create_mcp_toolset|create_devops_mcp_toolset|load_devops_mcp_toolsets|get_devops_mcp_toolset|set_mcp_sampling_model' -- src tests docs ':!docs/agent/archive'returns no line. Pydantic-ai's ownMCPToolsetstays in the knowledge base.git grep -nE 'run_subprocess|import subprocess' -- src/devops_cli/ai/mcpreturns no line.- The files that the children name hold no patch of a
devops_cliname:patch("devops_cli.,monkeypatch.setattr("devops_cli.andpatch.objecton adevops_cliobject all return no line. They also import no_-name fromdevops_cli. Each child states the final file names. The files handed to refactor(ai): Replace PydanticAgent with pydantic-ai Agent #2489 are not in this check. ls tests/ai/mcp/test_fastmcp_*.py tests/ai/mcp/test_mcp.py tests/ai/agents/test_pydantic_ai_toolsets.py tests/ai/tools/test_pydantic_ai_tools.pylists no file, and no test name intests/ai/mcp/ends in_and_error_branches.uv run devops cipasses.
This tracker blocks #1336.
Target Subsystem
src/devops_cli/ai/mcp/, ai/agents/, ai/harness/, ai/tools/, ai/toolsets/, ai/pydantic_ai_bridge.py, commands/mcp.py, and their test directories under tests/ai/ and tests/security/test_builtin_tools.py.
Existing Tool Considered
The alternatives check of 2026-10-31 recorded not-applicable. The children reuse open tools. These are pytest, syrupy for the tool listing, pydantic-ai TestModel and FunctionModel, and FastMCP Client(server) over its in-memory transport. They also reuse the project fakes in tests/support/fakes/: model_fake, process_fake, scanner_fake, qdrant, embedder, keyring_store and clock, and the stub_web fixture. The only new own code is the dispatcher fake and its hook in child B. Its cost is written in child B. Nothing else is built in this item.
Alternatives check of 2026-10-31: not-applicable.
Tool: none found.
Proposed design
Problem statement
The tests of ai/mcp/, ai/agents/, ai/harness/, ai/tools/ and ai/toolsets/ patch devops-cli names and import private ones, and src holds test switches. This item is the tracker of that migration and delivers no code. Six child items carry the work, and each child is one reviewable pull request. A person closes this item when all six children are closed.
Acceptance criteria
Requirement: No model-request switch in the tree
The tree SHALL hold no ALLOW_MODEL_REQUESTS, ModelNotAllowedError, MODEL_REQUESTS_DISABLED, _RUN_MESSAGES_CAPTURE, _is_testing_mode_active or agents.testing name outside docs/agent/archive.
Scenario: The exit check finds no switch
- WHEN The last child merges into the default branch
- THEN
git grep -nE 'ALLOW_MODEL_REQUESTS|ModelNotAllowedError|MODEL_REQUESTS_DISABLED|_RUN_MESSAGES_CAPTURE|_is_testing_mode_active|agents\.testing' -- src tests docs ':!docs/agent/archive'exits 1 and prints no line.
Requirement: No outbound MCP wrapper in the tree
The tree SHALL hold no MCPToolset wrapper, create_mcp_toolset, create_devops_mcp_toolset, load_devops_mcp_toolsets, get_devops_mcp_toolset or set_mcp_sampling_model name.
Scenario: The exit check finds no wrapper
- WHEN The last child merges into the default branch
- THEN
git grep -nE 'devops_cli\.ai\.agents\.tools import .*MCPToolset|ai\.mcp\.toolset|create_mcp_toolset|create_devops_mcp_toolset|load_devops_mcp_toolsets|get_devops_mcp_toolset|set_mcp_sampling_model' -- src tests docs ':!docs/agent/archive'exits 1 and prints no line.
Requirement: The MCP server starts no process
src/devops_cli/ai/mcp/ SHALL hold no run_subprocess name and no import subprocess.
Scenario: The MCP package holds no process call
- WHEN The last child merges into the default branch
- THEN
git grep -nE 'run_subprocess|import subprocess' -- src/devops_cli/ai/mcpexits 1 and prints no line.
Requirement: The named test files patch no devops-cli name
Each test file that a child names SHALL hold no patch of a devops_cli name and SHALL import no private devops_cli name.
Scenario: A named test file holds no devops-cli patch
- WHEN The exit grep runs over the test files that the children name
- THEN
git grep -nE 'patch\("devops_cli\.|monkeypatch\.setattr\("devops_cli\.'exits 1 on those files, and nofrom devops_cliimport line names a name that starts with_.
Requirement: The old MCP test file names are gone
The MCP, toolset and tool test files SHALL carry behaviour names, and no test name in tests/ai/mcp/ SHALL end in _and_error_branches.
Scenario: The old file names are gone
- WHEN A person lists the six old paths at the default branch
- THEN
ls tests/ai/mcp/test_fastmcp_*.py tests/ai/mcp/test_mcp.py tests/ai/agents/test_pydantic_ai_toolsets.py tests/ai/tools/test_pydantic_ai_tools.pylists no file, andgit grep -n 'def test_.*_and_error_branches' -- tests/ai/mcpexits 1.
Requirement: The gate passes at the last child
The default branch MUST pass uv run devops ci at the commit that closes the last child.
Scenario: The gate is green
- WHEN The last child merges into the default branch
- THEN
uv run devops ciexits 0.
Existing Tool Considered
The alternatives check of 2026-10-31 recorded not-applicable for this test item, and named no tool. The work reuses open, maintained tools. These are pytest, syrupy for the tool-listing snapshot, pydantic-ai TestModel and FunctionModel, and FastMCP Client(server) over its in-memory transport. The project fakes in tests/support/fakes/ cover the process, scanner, Qdrant, embedder, keyring and clock edges. None of these covers the MCP layer's own seam. pytest can patch a name, and a patch of devops_cli is what this item removes. So child B adds a dispatcher fake and its install_mcp_dispatcher hook. Cost of that own code: about 400 lines of test support code and one contract suite. Build cost: about 80,000 tokens. Keep and fix cost until the last child merges: about 30,000 tokens. Elapsed time: about 2 person-days.
Key questions
- Does one pull request carry the work of this item?: No. This item is a tracker and delivers no code. Six child items carry the work, and each child is one reviewable pull request. F lands last, after B. (proposed)
- Rejected: One pull request. Refine ruled twice that one pull request cannot carry the work of five packages.
- Chosen: Six child items, one pull request each. Each child is one reviewable pull request with its own exit check.
- Which source names hold the model-request switch that child A removes?:
ALLOW_MODEL_REQUESTSis atsrc/devops_cli/ai/agents/agent.py:91, and its check is at line 877 of the same file.docs/ERRORS.md:83namesModelNotAllowedErrorwith the codeMODEL_REQUESTS_DISABLED, andai/agents/testing.pyholds the test module. [sources: src/devops_cli/ai/agents/agent.py:91, src/devops_cli/ai/agents/agent.py:877, src/devops_cli/ai/agents/testing.py, docs/ERRORS.md:83] - Which seam replaces the
_run_mcp_cmdandrun_subprocesspatches of the MCP tool tests?: The in-process dispatcher. Every call site passes auv run devopsargv, andInProcessDispatcher._dispatch_typerruns the Typer app in the same process. So no process starts, and a process fake sees nothing. Child B addsinstall_mcp_dispatcherand deletes the subprocess branch. (best practice) [sources: src/devops_cli/ai/mcp/server.py, tests/ai/mcp/test_mcp.py, docs/TESTING.md]- Chosen: Dispatcher fake and install hook. It is the one place where an MCP tool hands a
devopsargv to the CLI app, so a test can assert the argv there. - Rejected: Process fake through
run_subprocess. No process starts, so the subprocess branch runs only in tests. - Rejected: Keep the patches of
_run_mcp_cmd. It patches a devops-cli name and imports a private one, which the testing conventions forbid.
- Chosen: Dispatcher fake and install hook. It is the one place where an MCP tool hands a
- Does the dispatcher seam go beyond the edge-only rule?: Yes, on purpose.
docs/TESTING.mdlistsuv run devopscalling itself as a faked process edge, and that is wrong for the MCP layer because nothing starts a process. Child B correctsdocs/TESTING.mdand adds a contract suite that holds the fake to the real dispatcher. (best practice) [sources: docs/TESTING.md]- Chosen: Add the dispatcher seam and correct
docs/TESTING.md. The document names a process edge that the MCP layer does not have. - Rejected: Keep the process fake as the only seam. The process fake never sees a call that runs in the same process.
- Chosen: Add the dispatcher seam and correct
- What happens to the outbound MCP wrapper
MCPToolsetand its factories?: Child D deletes them. No command, setting, tool or entry point reaches them. The wrapper does not connect, itsclosedoes nothing and itsget_toolsreturns the list it was given. Open feat(roadmap): let a job call the tools of the MCP server #3221 uses pydantic-ai's ownMCPToolset, so the deletion blocks it in no way. (best practice) [sources: src/devops_cli/ai/agents/tools.py:120, src/devops_cli/ai/agents/tools.py:211, docs/MCP_TOOLS.md]- Chosen: Delete the wrapper and its factories. A seam for code with no caller is zombie code.
- Rejected: Add a seam and keep the wrapper. No caller reaches it, so the seam would have no test.
- Rejected: Wire it to a real client. feat(roadmap): let a job call the tools of the MCP server #3221 builds its client on pydantic-ai's own
MCPToolsetinstead.
- Does the OSV, Shodan and Radar test wait on refactor(cli): Unify HTTP and DNS seams with shared fakes #1314?: No.
security/vulnerability_lookup.pyalready builds its clients throughnew_http_client, and thestub_webfixture answers them. Child C needs no wait, and a person may drop the line from refactor(cli): Unify HTTP and DNS seams with shared fakes #1314. [sources: tests/security/test_builtin_tools.py, src/devops_cli/security/vulnerability_lookup.py] - What replaces the ratchet and ceiling criteria of the old body?: Nothing in this item. Each child removes the sites in its own files, and test(cli): Convert ratchets to bans and merge invariant tests #1336 turns the counts into bans at zero. The project keeps no ceiling table and no baseline. (best practice) [sources: docs/TESTING.md]
- Chosen: Each child removes its sites, and test(cli): Convert ratchets to bans and merge invariant tests #1336 bans the forms. The testing rules make a ratchet at zero a ban, so no ceiling table is needed.
- Rejected: Keep a ceiling table and a baseline. 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 is closed as not planned, and the owner direction is a ban at zero.
- Does this item keep a separate coverage criterion?: No. Each child runs
uv run devops ci, which holds the floor of 85% ofsrc/and the 90% changed-line step. (best practice) [sources: docs/TESTING.md]- Chosen: Let the gate hold coverage. The gate already fails a child below the floor and the changed-line step.
- Rejected: Add a coverage criterion to each child. It repeats what the gate checks.
- Does this item replace every patch of
_run_mcp_cmdin the suite?: No. 16 sites in 10 test files outsidetests/ai/mcp/, and 4 sites in 3 unnamed files oftests/ai/mcp/, stay with the item that owns their package. The dispatcher fake of child B is their replacement, and test(cli): Convert ratchets to bans and merge invariant tests #1336 finds what remains. (best practice) [sources: tests/ai/mcp/test_mcp.py, docs/TESTING.md]- Chosen: Each package's item replaces its own sites. A test of another package belongs to the item that owns that package.
- Rejected: This item replaces every site. It would edit 10 test files of other packages in one pull request.
- Does this item rename or split the tests of
PydanticAgent,MultiAgentPipelineandAgentMemory?: No. refactor(ai): Replace PydanticAgent with pydantic-ai Agent #2489 deletes that code and moves the surviving tests to edge fakes in its own pull request. test(ai): Wire rag once in ai/rag, test with edge fakes #1329 criterion 4 wires the RAG investigator, and this item does not touch it. [sources: tests/ai/rag/test_pipeline_context_budget.py, src/devops_cli/ai/agents/agent.py:237]
Fit
Needs splitting into 6 items:
- A: remove
ALLOW_MODEL_REQUESTS,ModelNotAllowedError,_RUN_MESSAGES_CAPTUREandai/agents/testing.pyfromsrc, with the 11 test files that use them (4 source files, 1 doc). - B: add
install_mcp_dispatcher, delete the dead subprocess branch of the MCP server, and move the MCP tool tests off_run_mcp_cmdandrun_subprocess(3 files). - C: move
tests/security/test_builtin_tools.pyoff its 23 patches on processes, RAG, keys, the clock and the OSV, Shodan and Radar clients (1 file). - D: delete the outbound MCP code that no command, setting or tool reaches (5 source files, 2 KB pages, 1 doc, 2 test files).
- E: remove the internal patch and the private imports of the harness slot tests, and move the misplaced client test (2 files).
- F: rename and split the MCP, toolset and tool test files and add the tool-listing snapshot (5 files, 1 snapshot). It lands last, after B.
Suspected block
None.
Dependencies
None.
Sub-issues
Collapse Sub-issuesSub-issues
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 large but non-urgent Phase E migration that improves test robustness and removes production test switches, with no security or blocking defect driving it.Removing 110 internal patch sites, duplicate test-mode flags, and mock-branching from production code makes the test suite and the shipped code significantly more maintainable and trustworthy.26 test files (12,025 lines, 389 tests) must be rewritten against edge fakes, and production code in ai/mcp, ai/agents, ai/harness, ai/tools, and ai/toolsets must be refactored to drop test switches and inline constructions.12 remaining items
devops-cli-service commentedon Nov 5, 2026
The proposal at f6d57ec needs splitting into 5 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.
ALLOW_MODEL_REQUESTS,ModelNotAllowedError,_RUN_MESSAGES_CAPTUREandai/agents/testing.pyfromsrc, move the test users to pydantic-ai'sTestModel/FunctionModelor the refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001 fake, and add the no-model-fake test._run_mcp_cmdpatches intests/ai/mcp/with the real dispatcher and the refactor(cli): one process runner owns execution, process groups and dry-run #775 process fake, splittest_fastmcp_contracts.pyandtest_mcp.pyby behaviour, and add the one tool-listing syrupy snapshot.test_builtin_tools.pyandtest_review_security_tools.pyonto the refactor(cli): Unify HTTP and DNS seams with shared fakes #1314, refactor(ai): Valkey, Qdrant and the embedder each have one seam, with shared fakes and contract suites #1317 and refactor(security): one keyring seam owns the keyring and the Secret Service lock check, with a shared keyring fake and its contract suite #1318 seams and the feat(review): review tools run through one injectable executor in a network-less sandbox with CPU, memory and time limits #772 executor fake; start it after refactor(cli): Unify HTTP and DNS seams with shared fakes #1314 closes.test_pydantic_ai_{exceptions,native_capabilities,tools,toolsets}andtest_agent_invariants.pyby behaviour, splittest_pydantic_agent.py, dissolve its web-search catch-all, move the chat-turn cases to the public CLI or agent entry, and remove the redundant asyncio markers.fix(roadmap): a rejected plan leaves its evidence on the issue (#3713)
[-]test(mcp): mcp, agent, harness and tool tests run on edge fakes, and the mcp server and agents stop branching on mocks and test-mode flags[/-][+]test(mcp): mcp, agent and tool tests run on edge fakes[/+]devops-cli-service commentedon Nov 6, 2026
The proposal at dc9815e 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.
ALLOW_MODEL_REQUESTS,ModelNotAllowedError,_RUN_MESSAGES_CAPTUREandai/agents/testing.pyfromsrc, with the 11 test files that use them (4 source files, 1 doc).install_mcp_dispatcher, delete the dead subprocess branch of the MCP server, and move the MCP tool tests off_run_mcp_cmdandrun_subprocess(3 files).tests/security/test_builtin_tools.pyoff its 23 patches on processes, RAG, keys, the clock and the OSV, Shodan and Radar clients (1 file).refactor(ai): test-only model request hooks leave src (#3768)
dan-petty commentedon Nov 10, 2026
All six child items of this tracker are completed and merged into
main:All exit checks pass on
main.