Repository navigation
Description
Ready: implementation plan (refined 2026-10-17 at 3dd7fa6)
This section supersedes any text below that conflicts with it.
Decisions
- Whether this lands before or after refactor(ai): one agent runtime behind one construction point, with no silent fallback #1005: before. refactor(ai): one agent runtime behind one construction point, with no silent fallback #1005 deletes names that three files deleted here re-export (
src/devops_cli/ai/__init__.py:48and:66-75,src/devops_cli/ai/agents/__init__.py:294,src/devops_cli/ai/agents/pydantic_agent.py:227-236, which also re-exportspydantic_ai.agent.Agentat:14-30). Landing first, this item removes those re-exports wholesale and refactor(ai): one agent runtime behind one construction point, with no silent fallback #1005 edits no facade; landing after refactor(ai): one agent runtime behind one construction point, with no silent fallback #1005 would save this item only one import line (src/devops_cli/ai/pydantic_ai_bridge.py:19). The tests of refactor(ai): one agent runtime behind one construction point, with no silent fallback #1005's targets import fromai.pydantic_ai_bridgeandai.durabledirectly (tests/test_pydantic_ai_concurrency.py:29,tests/test_pydantic_ai_native_capabilities.py:36,tests/test_pydantic_ai_workflows.py:19), so they are unaffected. - What refactor(ai): one agent runtime behind one construction point, with no silent fallback #1005 drops once this lands: every facade edit, and the clause of its first criterion about
ai/agents/pydantic_agent.py:5-7re-exportingpydantic_ai.agent.Agent, because that file is deleted here. - Whether this lands before refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001: yes, PR 1 first. The facades re-export
ai.client,ai.directandai.providersnames (ai/__init__.py:16-44,pydantic_agent.py:212-225,:365-370) that refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001 rebuilds, so with PR 1 merged refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001 touches no facade. - Whether any MCP, plugin or documentation entry point relies on
devops_cli.ai.<name>attribute access: no. The only script isdevops_cli.entry:main(pyproject.toml:76), no configuration file in the repository names a facade attribute, and the three knowledge-base pages that teach facade imports change in PR 1. - Whether fix(cli): cli start-up imports no telemetry when the bridge is off, and timing tests stop asserting host speed #858 must land first: no, it has landed;
tests/test_cli_startup_imports.pyis its test, and PR 2 extends it. - Where a re-pointed import goes: to the module that defines the name (for example
PydanticAgentfromai/agents/agent.py,BaseCapabilityfromai/agents/capabilities.py:64,AgentToolfromai/agents/tools.py:28,list_mcp_toolsandrun_mcp_serverfromai/mcp/server.py:3085,:3104), or topydantic_aifor a pydantic-ai name. - How facade imports stay gone: a test pins that the four
__init__.pyfiles hold a docstring and nothing else, so Python itself rejects a non-submodule import from them; one AST test also walks the Python code blocks of the knowledge-base pages, which nothing imports. The wider rule "no__init__imports a sibling package" is not adopted, as the 2026-10-02 amendment says, andtest_no_circular_imports_in_decoupled_subsystemsno longer exists. - What happens to tests that assert a name is reachable through a facade: they lose the facade targets (
devops_cli.ai,devops_cli.ai.agents,devops_cli.ai.agents.pydantic_agent,devops_cli.ai.mcp) and keep any other target, such asdevops_cli.ai.tools; a test left with no target is deleted. They are the 11test_package_reexportsandtest_public_package_reexportstests intests/test_pydantic_ai_format_prompt.py:277,_profiles_and_providers.py:333,_run.py:116,_function_signature.py:207,_retries.py:191,_tools.py:243,_template.py:97,_result.py:140,_settings.py:130,_ollama.py:251and_mcp.py:208, and the facade modules intests/test_codebase_hygiene_and_shims.py:100-135, whose removed-class checks stay on the defining modules.test_ai_agents_and_providers_import_no_model_sdks(tests/test_cli_startup_imports.py:185) importsdevops_cli.ai.agents.agentinstead of the emptied package. - Whether the suppression ceilings move: yes, down by what PR 1 removes.
DEFAULT_C901_SUPPRESSION_CEILINGgoes from 51 to 49 (src/devops_cli/config/defaults.py:701; the markers atai/__init__.py:8andai/agents/__init__.py:290),src type: ignorefrom 91 to 90 (:708;pipeline/stage.py:49), and theai/pipeline_protocol.pyentry leavestests/fixtures/swallowed_failures_ceilings.json:46throughuv run python tests/test_swallowed_failures_ratchet.py --lower. Ceilings only go down. - Why the startup amendment is its own PR: measured at 3dd7fa6,
devops --versionanddevops --helpalready load none of the six packages and finish in 0.3 s, while 31 of 39 groups'--helpload pydantic-ai, fastmcp and opentelemetry in 2 to 3.5 s. Only one cause is a facade deleted here (commands/mcp.py:10throughai/mcp/__init__.py). The others: the module-levelpydantic_ai._ssrfimports atsrc/devops_cli/core/validation.py:17andsrc/devops_cli/http/egress.py:29, reached by most groups throughhttp/__init__.py;import pydantic_ai.exceptionsatsrc/devops_cli/exceptions/ai.py:8, reached byroadmapthroughroadmap/intake_model.py:27; and module-level AI imports in theai,reviewandscancommand modules (for examplecommands/ai_cost.py:11,ai/review/__init__.py:18). - How the private
pydantic_ai._ssrfimports stop loading pydantic-ai at startup: they move to first use, behaviour unchanged. Incore/validation.pythe module-level network tuples built from_PRIVATE_NETWORKS(:43-62) becomefunctools.cachefunctions, andhttp/egress.pyimportsis_cloud_metadata_ipinside_refusal(:80). refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001 keeps its criterion to replace the private API; this item only defers the import, so neither waits for the other. - How the exception module stops importing pydantic-ai: the 15 classes in
exceptions/ai.pythat subclasspydantic_ai.exceptions(:182-514) move tosrc/devops_cli/ai/exceptions.py, which already imports pydantic-ai, and the 11 aliases of pydantic-ai exceptions (exceptions/ai.py:724-734) are deleted, their users importing frompydantic_ai.exceptions.exceptions/ai.pykeeps only classes based onDevOpsCLIError. Sixsrcmodules and four test files import a moved name. - How the AI command groups stop loading pydantic-ai at
--help: their command modules import AI modules inside the command functions, and annotations that name AI types useTYPE_CHECKING. Typer reads only signatures and help text to render--help. - How the budget is enforced without a flaky test: each
--version,--helpand group--help(from_COMMAND_SPECS,src/devops_cli/main.py:34-78) runs in its own subprocess, which asserts that none of the six packages is insys.modulesand that the-X importtimecumulative time ofdevops_cli.mainand the group's command module is within the budget. A command over budget is measured twice more and fails only if all three runs are over, with the ten slowest imports listed. The budgets are constants inconfig/defaults.py: 0.5 s for--versionand--help, 1.0 s for a group's--help. - What "dry runs import only what their plan needs" means, testably:
k8s deploy-stack --dry-runloads none of pydantic-ai, fastmcp, qdrant-client and opentelemetry, andai benchmark --dry-runandreview path --dry-runload none of kubernetes, docker and qdrant-client. A dry run sends no request, so it needs no client for the services it would call. - Whether the priority changes to P1, as the amendment proposed: no change here. Priority belongs to the roadmap tooling, and this plan does not set it.
src/devops_cli/pipeline/, which test(infra): infrastructure tests run on edge fakes #1335 also lists: deleted here; test(infra): infrastructure tests run on edge fakes #1335 drops it.
Delivery
- PR 1 (M): the facades and the dead protocols.
ai/__init__.py,ai/agents/__init__.py,github/__init__.pyandai/mcp/__init__.pybecome docstrings;ai/agents/pydantic_agent.py,src/devops_cli/pipeline/andai/pipeline_protocol.pyare deleted withtests/test_pipeline_engine.pyandtests/test_pipeline_protocol.py; every importer names the defining module. Tests first: a test that the four__init__.pyfiles parse to a single docstring expression; an AST test that nofrom devops_cli.ai import,from devops_cli.ai.agents import,from devops_cli.ai.mcp importorfrom devops_cli.github importinsrc,testsor a knowledge-base Python block names anything but a submodule. Files: the four__init__.pyfiles; the 16srcimporters ofpydantic_agent(11 undersrc/devops_cli/ai/harness/,ai/pydantic_ai_bridge.py:19,ai/ext_langchain.py:8,ai/review/pipeline.py:33,ai/agents/pipeline.py:5, plusai/agents/__init__.pyitself);commands/ai.py:1058and:1240;commands/mcp.py:10;ai/knowledge_base/devops_cli/python_packages.md:126andai/knowledge_base/devops_cli/libraries/pydantic_ai.md:54,:82;config/defaults.py;tests/fixtures/swallowed_failures_ceilings.json; the 56 test files that import fromai.agents.pydantic_agentor through a facade (including the threepatch("devops_cli.ai.agents.PydanticAgent")targets intests/test_ai_cmd.py);changelog.d/1002.md. Refs refactor(ai): delete the pass-through package facades and the two stagepipeline protocols nothing implements #1002. - PR 2 (M):
--version,--helpand every group's--helpload none of pydantic-ai, kubernetes, docker, fastmcp, qdrant-client and opentelemetry, within the budget. Tests first: extendtest_cli_help_imports_no_telemetry(tests/test_cli_startup_imports.py:36-83) to the six packages,--versionand every_COMMAND_SPECSgroup, with the budget check; it fails today for 31 groups. Files:src/devops_cli/core/validation.py,src/devops_cli/http/egress.py,src/devops_cli/exceptions/ai.py,src/devops_cli/ai/exceptions.py, the sixsrcimporters of moved exceptions,src/devops_cli/commands/mcp.py,src/devops_cli/commands/ai*.py,src/devops_cli/commands/review.py,src/devops_cli/commands/scan.py,src/devops_cli/commands/roadmap.pyif still needed,src/devops_cli/config/defaults.py,tests/test_cli_startup_imports.py, the four test files importing moved exceptions. Refs refactor(ai): delete the pass-through package facades and the two stagepipeline protocols nothing implements #1002. - PR 3 (S): dry runs. Tests first: one parametrized subprocess test runs
k8s deploy-stack --dry-run,ai benchmark --dry-runandreview path --dry-runoffline, with the model edge faked, and asserts the module sets above. Files: the command modules and helpers the test points at,tests/test_cli_startup_imports.py. Closes refactor(ai): delete the pass-through package facades and the two stagepipeline protocols nothing implements #1002.
Acceptance criteria
-
src/devops_cli/ai/__init__.py,src/devops_cli/ai/agents/__init__.py,src/devops_cli/github/__init__.pyandsrc/devops_cli/ai/mcp/__init__.pyhold a docstring and nothing else, and a test pins it. -
src/devops_cli/ai/agents/pydantic_agent.py,src/devops_cli/pipeline/,src/devops_cli/ai/pipeline_protocol.py,tests/test_pipeline_engine.pyandtests/test_pipeline_protocol.pyare deleted. - The AST test finds no facade import of a non-submodule name in
src,testsor the knowledge-base pages. -
DEFAULT_C901_SUPPRESSION_CEILINGis 49, thesrc type: ignoreceiling is 90, andtests/fixtures/swallowed_failures_ceilings.jsonhas noai/pipeline_protocol.pyentry. -
devops --version,devops --helpand every group's--helpload none of pydantic-ai, kubernetes, docker, fastmcp, qdrant-client and opentelemetry, and stay within 0.5 s and 1.0 s of import time; the test lists the slowest imports when it fails. -
rg -n "^import pydantic_ai|^from pydantic_ai" src/devops_cli/exceptions src/devops_cli/core/validation.py src/devops_cli/http/egress.pyprints nothing. - The three dry runs load only what their plan needs, as decided above.
- Every new and changed test runs offline, with no model, network or cluster.
-
changelog.d/1002.mdlists the removed import paths under### Removed;CHANGELOG.mdis untouched. -
uv run devops cipasses. - Pending a person: the PR records
python -X importtime -c "import devops_cli.main"totals anddevops ai --helpwall time, before and after.
Current references
ai/__init__.py__getattr__with its C901 marker:src/devops_cli/ai/__init__.py:8ai/agents/__init__.pyeager imports and__getattr__:src/devops_cli/ai/agents/__init__.py:7-288,:290pydantic_agent.pyre-exports ofpydantic_ai.agent,ai.direct,ai.durable,ai.providers:src/devops_cli/ai/agents/pydantic_agent.py:14-30,:212-225,:227-236,:365-370ai/mcp/__init__.pyimports:src/devops_cli/ai/mcp/__init__.py:5-12,:109github/__init__.pyre-exports:src/devops_cli/github/__init__.py:27,:129StagePipeline:src/devops_cli/pipeline/pipeline.py:32,src/devops_cli/ai/pipeline_protocol.py:62PydanticAgentimporters through the package:src/devops_cli/commands/ai.py:1058,:1240commands/mcp.pyfacade import:src/devops_cli/commands/mcp.py:10- Knowledge-base facade imports:
src/devops_cli/ai/knowledge_base/devops_cli/python_packages.md:126,src/devops_cli/ai/knowledge_base/devops_cli/libraries/pydantic_ai.md:54,:82 - Ceilings:
src/devops_cli/config/defaults.py:701,:708;tests/fixtures/swallowed_failures_ceilings.json:46 - Private pydantic-ai imports:
src/devops_cli/core/validation.py:17-21,:43-62;src/devops_cli/http/egress.py:29,:80 - Exception subclasses and aliases of pydantic-ai:
src/devops_cli/exceptions/ai.py:8,:182-514,:724-734 - Command registry:
src/devops_cli/main.py:34-78 - Startup test:
tests/test_cli_startup_imports.py:36-83,:185
Dependencies and order
- refactor(ai): one agent runtime behind one construction point, with no silent fallback #1005 (open, Ready, no milestone): lands after PR 1 and then edits no facade; it drops the
pydantic_agent.py:5-7clause of its first criterion. refactor(ai): one agent runtime behind one construction point, with no silent fallback #1005 also should land before the refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001 PR that rebuildsresolve_pydantic_ai_model(ai/pydantic_ai_bridge.py:201), so refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001 does not carry the dead callersbuild_fallback_cascade_model(:420) andcreate_durable_pydantic_agent(ai/durable.py:630) through that change. - refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001 (v0.2.37): its PRs start after PR 1. refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001 does not depend on refactor(ai): one agent runtime behind one construction point, with no silent fallback #1005 (owner decision of 2026-10-08), and it keeps its criterion to remove the private
pydantic_ai._ssrfimports, which PR 2 only defers. PR 2 should merge before the refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001 PR that routes theLLMClient(...)constructions incommands/ai.pythrough the factory, because both edit that module's imports. - fix(ai): reasoning request parameters follow the model's declared capability, not its name #888 (v0.2.37, another agent): shares no file with this item, and only
ai/gateway.pywith refactor(ai): one agent runtime behind one construction point, with no silent fallback #1005, in a different function (fetch_model_infoat:254againstbuild_pydantic_cascade_modelat:488). It can land before refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001: it moves the reasoning decision onto the declared capability in the existing pydantic-aiModelProfile(ai/profiles/__init__.py:76,supports_thinkingat:141), changes the two name checks atai/client/openai.py:106andai/client/claude.py:47, and deletes the name lists (config/constants.py:2132-2148); refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001's pydantic-ai models then read the same profile. If refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001's adapter PR lands first, fix(ai): reasoning request parameters follow the model's declared capability, not its name #888 only sets the flag on that profile. - refactor(github): pull request, repository and ssh key calls move from pygithub onto the github session #891 (v0.2.37): keeps the names
github/__init__.pyre-exports, so the two do not wait on each other; whichever lands second rebases. - fix(cli): cli start-up imports no telemetry when the bridge is off, and timing tests stop asserting host speed #858 and docs: hand-written docs name only commands, options and components that exist #921: delivered.
- test(infra): infrastructure tests run on edge fakes #1335: drops
pipeline/from its list once PR 1 merges.
Context & Rationale
About 3,700 lines of re-export serve between 0 and 11 source importers, and the documented stage protocol has two copies and no implementer. Checked at 9c879ae.
ai/__init__.py(1,153 lines): a 663-line__getattr__with 33if name in {...}blocks and a 479-name__all__. Its first statement already doesimport_module(f"devops_cli.ai.{name}"), so the remaining ~650 lines serve no source importer; one source module (gateway_tune.py) and 11 test files import through it.ai/agents/__init__.py(1,213 lines) eagerly imports 8 submodules, includingpydantic_agent.py(931 lines, a 435-name re-export of pydantic_ai), then a 374-line__getattr__routes lazily to 16 sibling packages (ai.durable,ai.tools,ai.harness, ...): a child re-exporting its parent's siblings, the shapetest_no_circular_imports_in_decoupled_subsystemsexists to police. 35 source modules import something underai.agentsand each pays the eager pydantic_ai import; 2 use the package path (15 test files do).github/__init__.py: 107 names, 0 users.ai/mcp/__init__.py: 120 names, 3 users.StagePipelineexists twice (pipeline/pipeline.py:32,ai/pipeline_protocol.py:62) with zero implementers outside their own packages; onlytests/test_pipeline_engine.py(8 tests) andtests/test_pipeline_protocol.py(4) use them. The review usesMultiAgentPipelineandreview/stages/(2 files); Remove the review stage modules the pipeline never calls #530 removed the stage modules nothing called.exceptions/__init__.py(86 names, 21 used by 52 modules) hides 17 files behind a small interface and stays.- feat(cli): public re-export surface consolidation #424 consolidated the lists; refactor(config): the config barrel and the unused config names go, and the package inits stop re-exporting #776 covers
config/__init__.pyand is not repeated here.
Deletion test: pure pass-through. Two source import lines and about 26 test import lines re-point to the owning module; nothing else moves.
Scope & Deliverables
- Deliverable:
ai/__init__.py,ai/agents/__init__.py,github/__init__.pyandai/mcp/__init__.pybecome docstrings;ai/agents/pydantic_agent.pyand bothStagePipelineprotocols go, with their 12 tests. Importers name the module that implements the thing. The circular-import invariant simplifies to "no__init__imports a sibling package". - Tests: 11 + 15 + 12 test files change import lines;
test_pipeline_engine.pyandtest_pipeline_protocol.pyare deleted. - Key questions (open):
- Does any MCP, plugin or documentation entry point rely on
devops_cli.ai.<name>attribute access? - Should fix(cli): cli start-up imports no telemetry when the bridge is off, and timing tests stop asserting host speed #858 (start-up imports) land first, or does this item deliver most of its goal?
- Does any MCP, plugin or documentation entry point rely on
- Constraint: ARCHITECTURE.md's stage-protocol claim is corrected by docs: hand-written docs name only commands, options and components that exist #921; this item removes the code the claim pointed at.
Strategic Alignment
- Milestone: Backlog (no release)
- Design: none
- Depends on: none
- Related: refactor(config): the config barrel and the unused config names go, and the package inits stop re-exporting #776, feat(cli): public re-export surface consolidation #424, fix(cli): cli start-up imports no telemetry when the bridge is off, and timing tests stop asserting host speed #858, docs: hand-written docs name only commands, options and components that exist #921, feat(ai): sequential pipeline stages carry a budgeted context, with the scratchpad appended once #859 (uses
MultiAgentPipeline, unaffected) - Source: architecture review of 2026-10-02, config cross-cut and AI core
Scope added 2026-10-02: checked at 38517a8, with corrections. ai/agents/pydantic_agent.py is not mainly a re-export of pydantic_ai. Of its 435 names, 377 come from 27 devops_cli.ai modules and 58 from pydantic_ai. 17 source modules import it: 12 under ai/harness/, ai/pydantic_ai_bridge.py:18, ai/ext_langchain.py:8, ai/agents/pipeline.py:29, ai/review/pipeline.py:34 and ai/agents/__init__.py:45. So deleting it re-points about 17 source modules, not 2. commands/ai.py:1009 and :1172 import PydanticAgent through the package. The whole src/devops_cli/pipeline/ package (__init__.py, models.py, stage.py, pipeline.py, 280 lines) has no importer in src, not only its StagePipeline; with ai/pipeline_protocol.py (168 lines) only the two test files use them. Two knowledge-base pages teach the facade path: ai/knowledge_base/devops_cli/python_packages.md:137 and ai/knowledge_base/devops_cli/libraries/pydantic_ai.md:54,83. #921's key question leaves deleting the unused StagePipeline to a refactor item, and this is that item.
Acceptance criteria
-
ai/__init__.py,ai/agents/__init__.py,github/__init__.pyandai/mcp/__init__.pyhold a docstring and nothing else. -
ai/agents/pydantic_agent.pyis deleted. Its 17 source importers import from the module that defines each name, or frompydantic_ai. - The
src/devops_cli/pipeline/package andai/pipeline_protocol.pyare deleted, withtests/test_pipeline_engine.pyandtests/test_pipeline_protocol.py. - Every
from devops_cli.ai import,from devops_cli.ai.agents import,from devops_cli.ai.mcp importandfrom devops_cli.github importinsrc,testsand the knowledge-base pages names a submodule, asai/gateway_tune.py:28andai/tools/registry.py:161already do. An AST test checks it. At 38517a8, 88 such lines exist (6 insrc), most of them importing re-exported names. - A test pins that the four emptied
__init__.pyfiles import nothing. The wider rule in the deliverable ("no__init__imports a sibling package") is not adopted here: 13 other package__init__.pyfiles import outside their package at 38517a8 (for exampleai/personas,ai/review,ai/tools,core,models,commands/k8s). The PR lists them for a later item. -
ARCHITECTURE.mdno longer namesStagePipelineordevops_cli.pipeline. docs: hand-written docs name only commands, options and components that exist #921 (v0.2.28) rewritesARCHITECTURE.md:187to say the protocol exists but is unused; this item removes that text, or docs: hand-written docs name only commands, options and components that exist #921 drops it if this item lands first. - The new and changed tests run offline, with no model, network or cluster.
-
changelog.d/1002.mdlists the removed import paths under### Removed.CHANGELOG.mdis not edited. -
uv run devops cipasses. - (person-run) The PR records
python -X importtime -c "import devops_cli.main"totals before and after.
Key questions
- Does any MCP, plugin or documentation entry point rely on
devops_cli.ai.<name>attribute access? (proposed) No runtime entry point does. The only script isdevops_cli.entry:main(pyproject.toml:61). Of the three importers of theai.mcppackage,commands/mcp.py:10re-points toai.mcp.server;ai/tools/mcp_bridge.py:24andai/tools/registry.py:161already import theserversubmodule. The two knowledge-base pages change in this PR, because the RAG corpus would otherwise teach imports that fail. - Should fix(cli): cli start-up imports no telemetry when the bridge is off, and timing tests stop asserting host speed #858 (start-up imports) land first, or does this item deliver most of its goal? (proposed) No order is needed. fix(cli): cli start-up imports no telemetry when the bridge is off, and timing tests stop asserting host speed #858 is about telemetry imports when the bridge is off. This item removes the eager pydantic_ai import from
ai/agents/__init__.py, which helps start-up but does not overlap fix(cli): cli start-up imports no telemetry when the bridge is off, and timing tests stop asserting host speed #858's files. - Does it land before or after refactor(ai): one agent runtime behind one construction point, with no silent fallback #1005? (proposed) After. refactor(ai): one agent runtime behind one construction point, with no silent fallback #1005 deletes the bridge factories and
durable.create_durable_pydantic_agent, which leaves fewer modules for this item to re-point.
Amended 2026-10-04: a startup budget for help, version and dry runs
The owner (2026-10-04): help and dry-run commands are "way slower than they need to be", although the CPU is idle. Measured the same day, best of two:
-
devops --versiontakes 3.0 s, and so doesdevops --help.devops ai benchmark --helptakes 10.5 s. A bare interpreter starts in 0.03 s, and Typer, Rich and Click together import in 0.13 s (Textual alone in 0.32 s). -
python -X importtime -c 'import devops_cli.main'spends 2.3 s, 1.5 s of it importing pydantic-ai. The chain isdevops_cli.core.cli→devops_cli.exceptions→exceptions.ai→pydantic_ai.exceptions→pydantic_ai, then its agent, capabilities and MCP modules, then fastmcp's client. These facades and eager re-exports are what this item deletes. -
uv runadds about 1.5 s per call. It checks the environment and, withUV_COMPILE_BYTECODEset, prints "Bytecode compiled 12637 files" every time. -
devops --version,devops --helpand everydevops <group> [<command>] --helpimport no pydantic-ai, kubernetes, docker, fastmcp, qdrant-client or opentelemetry module. A test runs each in a subprocess and asserts the absence throughsys.modules. Exception modules define their classes without importing pydantic-ai. -
A startup budget, as a named constant and a test:
devops --helpanddevops --versionwithin 0.5 s of import time (-X importtimecumulative fordevops_cli.main), and any--helpwithin 1.0 s. The test fails with the slowest imports listed. -
--dry-runpaths import only what their plan needs. One test covers a dry run ofai benchmark,k8s deploy-stackandreview path. -
Priority? Proposed: raise to P1. Every command, every agent loop and every test subprocess pays the startup cost, and the gate budget (CI speed is P0) pays it too.
Update 2026-10-08: refinement
#921 removed StagePipeline from ARCHITECTURE.md; drop that criterion. src/devops_cli/pipeline/ and ai/pipeline_protocol.py:62 remain, unimported in src. Extend tests/test_cli_startup_imports.py (#858) to --version, every group's --help, and kubernetes, docker, fastmcp and qdrant-client. #1005 no longer deletes ai/direct.py. #1335 lists pipeline/; whichever lands second drops it there.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 17, 2026
Moved to v0.2.37: v0.2.37 started with fewer than its 16 items and was topped up to 16 from Ready items, critical fixes and P0 features first. (devops roadmap reprioritize)
dan-petty commentedon Oct 18, 2026
Amendment (2026-10-18), from the hook-speed investigation: PR 2 also covers running commands
PR 2 asserts that
--version,--helpand every group's--helpload no pydantic-ai. Every runningdevopscommand still imports the whole package, through two module-level imports of one SSRF helper:src/devops_cli/http/egress.py:29andsrc/devops_cli/core/validation.py:17-21importpydantic_ai._ssrfat module level, and importing a submodule runspydantic_ai/__init__(agents, MCP, fastmcp, logfire: about 1,000-1,300 extra modules).main.py:119->telemetry/__init__.py:53->telemetry/service_status.py:23-24->http/__init__.py:5->http/client.py:32-> egress. There is also a path throughtelemetry/__init__.py:79->waterfall.py:14-15, and throughget_tracerviatracer.py:819.import pydantic_aialone costs 1.65 s, and the command import chain 1.98 s. Every hook-leveldevops ci test, every pre-pushdevops ciand everydevops ghcall pays it.tests/test_http_egress.pyandtests/test_validation.py(155 passed), and cutdevops ci test --dry-runfrom 2,320 to 1,034 modules and from a median 10.36 to 5.15 CPU-s. Makingservice_statuslazy alone, or using a function-level import in egress alone, does not remove the load.Proposed additions to PR 2:
is_cloud_metadata_ipinside_refusalinhttp/egress.py.core/validation.py, build the network tables in afunctools.cached function that imports_PRIVATE_NETWORKSon first call, and importis_cloud_metadata_ipandis_private_ipat their use sites.#1622reworked this module, so recheck the line numbers.tests/test_cli_startup_imports.py: a subprocess importsdevops_cli.mainanddevops_cli.commands.ci, callsdevops_cli.telemetry.tracer.get_tracer(), importsdevops_cli.http, and asserts"pydantic_ai" not in sys.modules. The egress and validation tests keep their behaviour.This was drafted as a separate item. It is posted here instead, because it is the same import-budget work PR 2 already does and the agent filing quota is nearly spent.
refactor(ai): delete the pass-through package facades and the two sta…
refactor(ai): lazy pydantic_ai imports on command and help dispatch p…
refactor(ai): startup import budget invariants and dry-run isolation …
dan-petty commentedon Oct 18, 2026
What changed
#1680, merged into
release/v0.2.37as a17b56b.11 file(s) changed.
How it was verified
Check runs at 735af76:
Acceptance Criteria of
docs/agent/tasks/task-1002-delete-facades-and-stagepipeline-protocols.md:__init__.pyfiles fordevops_cli.ai,devops_cli.ai.agents,devops_cli.ai.mcp, anddevops_cli.githubhold only single module docstrings.test_no_non_submodule_imports_from_ai_and_github_facadesenforces zero non-submodule imports from these facades acrosssrc/,tests/, and knowledge base docs.src/devops_cli/ai/agents/pydantic_agent.py,src/devops_cli/ai/pipeline_protocol.py, and the entiresrc/devops_cli/pipeline/package are deleted along with their obsolete test suites.src/andtests/point directly to defining submodules.devops --version,devops --help, and alldevops <group> --helpcommands load zero heavy modules (pydantic_ai,kubernetes,docker,fastmcp,qdrant_client,opentelemetry).devops_cli.core.validationanddevops_cli.http.egresslazified to prevent running commands (devops ci, tracer, http client) from eagerly importingpydantic_ai.devops_cli.exceptions.ai_pydanticand lazily re-exported indevops_cli.exceptions.ai.devops_cli.ai.rag,devops_cli.ai.review, anddevops_cli.ai.benchmarkmade lazy via__getattr__.devops_cli.commands.mcpmade lazy inside command functions.tests/test_cli_startup_imports.py.uv run devops cipasses with 100% success.--version/--help(< 0.5s) and any command--help(< 1.0s), reporting slowest imports on failure.ai benchmark,k8s deploy-stack, andreview pathimport only what their plans need.changelog.d/1002.md.feat(release): v0.2.37 (#1720)