Repository navigation
Closed
Labels
priority/p2-mediumPriority P2: standard workscope/aiAI review pipeline, personas, prompts, LLM client, or RAGscope/ciGitHub Actions workflows, pre-commit hooks, CI gates, and runnerstype/bugType bug: the code does not do what it must
Milestone
Description
Problem
Lines cited at dcafadf.
At 132ecc5, the MESSAGES.ci labels cited at lang/en/messages.py:764-765 are at :773-774.
Nothing checks that [project].dependencies matches what src imports. Ruff does not look at dependencies. mypy resolves imports against the installed environment, where transitive packages are present too; uv check runs ty, which pyproject.toml:155 sets to unresolved-import = "ignore". uv lock --check only compares pyproject.toml with uv.lock. deptry 0.25.1, run with the project's installed packages, scans 504 files at dcafadf in 0.56–0.68 s and reports 31 findings. At the branch tip 132ecc5 it scans 505 files in 0.78–0.84 s and reports the same 31:
- Imported directly, declared nowhere (DEP003, present only through another package):
logfire:telemetry/logfire.py:136,159,203,246,257,322(configure,span,metric_counter,instrument_pydantic,instrument_pydantic_ai). It arrives through pydantic-ai-slim'slogfireextra (logfire[httpx]>=4.39.0).nacl(PyNaCl):github/secrets.py:9, which seals GitHub Actions secrets inencrypt_secret(:49-54). It arrives through PyGithub (pynacl>=1.4.0).openai:ai/models/ollama.py:9,AsyncOpenAIin the Ollama provider signatures (:128,:167,:175,:200). It arrives through pydantic-ai-slim'sopenaiextra (openai>=3.0.0).pydantic_graph:ai/run/__init__.py:24,34. It arrives through pydantic-ai-slim (pydantic-graph==2.35.0).secretstorage:commands/devcontainer.py:1390, the gnome-keyring lock check_keyring_is_locked(:1386-1396). It arrives through keyring, and only on Linux (SecretStorage>=3.2; sys_platform == "linux").httpx, encode's original package (0.28.1, last release 2024-12-06). uv.lock gets it from fastmcp (through fastmcp-slim'sclientandserverextras), mcp, google-genai and qdrant-client. pydantic-ai 2.35 imports it optionally (pydantic_ai/_http.py:32-35) and marks its remaining legacy supportTODO(v3): remove(:80). Three places in src import it:ai/settings/__init__.py:11from httpx import Timeoutis unguarded and runs at module import.ai/models/ollama.py:24imports the module, andTimeoutis re-exported fromai/__init__.py:354,934,ai/agents/__init__.py:523,989andai/agents/pydantic_agent.py:423,713. If those packages stop requiring httpx (for example by moving to httpx2),devops_cli.ai.settingsfails to import, and the Ollama model path and the agents package fail with it.http/broker.py:9-12andtelemetry/memory_profiler.py:247-250both usetry: import httpx2 as httpx / except ImportError: import httpx. httpx2 is declared, so the fallback branch never runs. It is dead code that names an undeclared package. Both files then call httpx2 through thehttpxalias (broker.py:38-39,:53,:66,:72,:80,:87,:91,:95,:113,:139; memory_profiler.py:266), so a search forhttpx2.misses those call sites.
- Imported directly, missed by deptry:
from opentelemetry import traceatai/run/__init__.py:62andtelemetry/tracer.py:1390comes from opentelemetry-api, which arrives through the declared OTLP exporter. deptry matches imports by top-level name, and the exporter also installs into theopentelemetrynamespace, so deptry counts the import as covered. - Declared, never imported (DEP002):
pydantic-handlebars==0.2.1is flagged, but deleting it would break template rendering. src uses pydantic-ai'sTemplateStr(ai/template/__init__.py:12,22, andai/agents/agent.py:614renders Handlebars-templated system prompts; covered bytests/test_pydantic_ai_template.py).TemplateStrimports pydantic-handlebars lazily (pydantic_ai/template.py:61,125-135). pydantic-ai-slim and logfire list pydantic-handlebars only under extras this project does not enable (spec,variables). In uv.lock, devops-cli is the only package that requires it.- The 13 tree-sitter packages are false positives.
ai/ast/engine.py:55-68maps languages to grammar modules, which:422-423loads by name withimportlib.
- Missing (DEP001):
temporalio,dbosandprefectinai/durable.py:272,283,294. refactor(ai): the durable resolver offers only the engines that work, and the unreadai.durablesettings are removed #1121 settles these three engines, and this item leaves them alone.
Acceptance criteria
[project].dependenciesdeclares the directly imported packages, exact-pinned at the versions uv.lock already resolves:logfire==5.1.0,pynacl==1.6.2,openai==3.13.0,pydantic-graph==2.35.0,opentelemetry-api==1.44.0andsecretstorage==3.5.0; sys_platform == 'linux'. No resolved version changes. Auv lock --dry-runof this change at dcafadf, deptry included, adds only deptry 0.25.1, requirements-parser 0.13.1 and tomli 2.4.1.pydantic-ai[spec]==2.35.0replacespydantic-handlebars==0.2.1. pydantic-handlebars stays in uv.lock, andtests/test_pydantic_ai_template.pypasses unchanged.- No module under
srcimportshttpxor aliases httpx2 ashttpx:rg -n -g '*.py' -e '^\s*(import|from) httpx\b' -e 'httpx2 as httpx' srcprints nothing. Today it printsai/settings/__init__.py:11,http/broker.py:10,12andtelemetry/memory_profiler.py:248,250. This item owns all three direct httpx imports in src:ai/settings/__init__.py:11,http/broker.py:12andtelemetry/memory_profiler.py:250. fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898 no longer deletes the broker.py shim, or the memory_profiler.py one.ai/settings/__init__.pyno longer imports httpx.create_model_settings(timeout=…)takesfloat | None.resolve_runtime_model_settings(:123-133), which today passes untyped**kwargsstraight intocreate_model_settings(:130), takestimeout: float | Noneas an explicit keyword and forwards it, andtests/test_pydantic_ai_settings.pykeeps passing.Timeoutis removed from that module's__all__and from the re-exports listed above. There is no deprecation shim (pre-1.0).- This item deletes both fallback shims,
http/broker.py:9-12andtelemetry/memory_profiler.py:247-250. Both files useimport httpx2with no alias, and their call sites are renamed tohttpx2., so later searches forhttpx2.find them. - In
tests/test_http_broker.py, the localimport httpxat:64and:99goes, and the mocks at:76and:110usespec=httpx2.Response, the type the broker returns. If fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898 has already removed those per-request override tests, nothing is left to change there.tests/test_rag_query_telemetry.py:18keepshttpx, because it builds qdrant-client's own transport. - The MCP example in the shipped knowledge-base page
ai/knowledge_base/devops_cli/libraries/pydantic_ai.md:81-85useshttpx2.AsyncClientandhttpx2.Timeout, so retrieval stops suggesting the import this gate rejects.MCPToolsetstoreshttp_clientbut never passes it on (ai/agents/tools.py:133,:180,:246-256), so the edit changes no behaviour.
- deptry is a gate step:
deptry==0.25.1is in thedevdependency group.- pyproject.toml gets a
[tool.deptry.per_rule_ignores]table with exactly two commented lists.DEP002liststree-sitterand the 12 grammar packages, with a comment that they are loaded by name inai/ast/engine.py.DEP001liststemporalio,dbosandprefectuntil refactor(ai): the durable resolver offers only the engines that work, and the unreadai.durablesettings are removed #1121 settles them; if refactor(ai): the durable resolver offers only the engines that work, and the unreadai.durablesettings are removed #1121 has already landed, the table has noDEP001list. A comment records that deptry matches top-level names, which is whyopentelemetry-apiwas declared by hand. - No other ignore or
package_module_name_mapentry is added.
uv run deptry srclands as onedepsrow of refactor(ci): github ci runs the gate throughdevops cifrom one check table #843's check table, whichdevops ciand GitHub CI both run, with refactor(ci): github ci runs the gate throughdevops cifrom one check table #843's parity test mapping the row (if this item lands before refactor(ci): github ci runs the gate throughdevops cifrom one check table #843, refactor(ci): github ci runs the gate throughdevops cifrom one check table #843 carries the row). There is no separate task entry incommands/ci.py, no separate subcommand and no separate step in.github/workflows/ci.yml. A local pre-commit hook (language: system,pass_filenames: false,files: ^(pyproject\.toml|src/.*\.py)$) runs it at commit time.- The step's supporting edits are in place:
MESSAGES.cigains the row's label next touv_lockanduv_outdated(lang/en/messages.py:764-765).uv run devops docs checkpasses.- The gate list at
AGENTS.md:60names the row. docs(agents): instruction surfaces state only what is true, anddevops ai agentsnever overwrites AGENTS.md #840 replaces the gate counts on that line and feat(ci): hand-rolled URL and address parsing failsdevops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107 adds its own row to the same list; whichever lands second rebases.
- After this change,
deptry srcreports no issue. Tests with a fake runner pin the step's argv. On a real tree, addingimport httpxto a module fails the step with DEP003, and removing the last import of a declared package fails it with DEP002. The task file records both results. - Gate cost is measured and recorded in the task file. deptry took 0.56–0.84 s wall (about 2 CPU-seconds) for 504–505 files at host load 18–21 on 16 CPUs. It runs alongside pytest, so the gate's wall time does not measurably grow. It reads only local package metadata and makes no network call.
changelog.d/<issue>.mdrecords the removedTimeoutre-export under### Removedand the deptry step under### Added.- Tests stay offline, and
uv run devops cipasses.
Key questions
- What timeout type does
ModelSettings.timeouttake: an httpx.Timeout, an httpx2.Timeout or a float? Proposed: a float. pydantic-ai 2.35 types it asint | float | Timeout, whereTimeoutis the legacyhttpx.Timeout(pydantic_ai/settings.py:8-15,209). Its docstring (:210-226) says numeric seconds work everywhere and a legacyhttpx.Timeoutis converted for SDKs that need one (_http.py:68-77). It also sayshttpx2.Timeoutis "deliberately not part of this contract, because some SDKs behind these settings still reject it", and that Google and Mistral take numbers only. openai 3.13 acceptsfloat | httpx2.Timeout | None(openai/_types.py:36,123). So swapping in an httpx2.Timeout is not safe, and keeping httpx.Timeout depends on a package pydantic-ai plans to drop. The only production caller,ai/models/ollama.py:212-218, passestimeout: float | None(:174). The publicresolve_runtime_model_settings(ai/settings/__init__.py:123-133, re-exported fromai/__init__.py:364,1123,ai/agents/__init__.py:533,1185andai/agents/pydantic_agent.py:433,903) forwards untyped**kwargsintocreate_model_settingsand is called only from tests (tests/test_pydantic_ai_settings.py:120). It gets the samefloat | Nonekeyword, so no untyped path bypasses the narrower type. A per-phase timeout belongs on the provider's own httpx2 client (http/client.py:27already builds anhttpx2.Timeout), not inModelSettings. - Who deletes the two fallback shims, this item or fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898? Proposed: this item deletes both fallback shims,
http/broker.py:9-12andtelemetry/memory_profiler.py:247-250, and fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898 no longer deletes either; both deletions are out of its scope. The deptry step cannot pass while either file imports httpx. The lines are dead code and do not depend on fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898's egress rewrite. fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898 is P1 in v0.2.29 and this item is in the backlog, so fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898 is likely to land first. Until this item lands, fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898 leaves those lines alone and keeps calling httpx2 through thehttpxalias. This item then makes the same deletion, and renames the alias's call sites, in whateverbroker.pyandmemory_profiler.pyfix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898 leaves behind. - Why deptry and not a hand-written test or another tool? Proposed: deptry. It reports exactly the four cases needed: DEP001 missing, DEP002 unused, DEP003 transitive and DEP004 a dev dependency imported in shipped code. It is MIT-licensed and lives at osprey-oss/deptry, formerly fpgmaas/deptry. It has two maintainers: fpgmaas, the author, and mkniewallner, who cut 0.25.1. Maintainer commits run through 2026-08 and weekly Renovate lock maintenance through 2026-09. The latest release is 0.25.1 (2026-03-18). It ships abi3 wheels with a Rust core, declares Python 3.14 and has tested against 3.15 since 2026-08. The alternative, FawltyDeps (Tweag), last released in 2025-06 and last pushed in 2025-07. A hand-written import-versus-pyproject test would re-implement deptry's module-to-distribution mapping. deptry's known limit is that it matches by top-level name, so imports inside a shared namespace (
opentelemetry) go unchecked. That is why opentelemetry-api is declared by hand. - How does deptry see the installed packages? Proposed:
uv run deptry srcfrom the dev group. deptry reads distribution metadata from the interpreter it runs in, and its documentation says to run it inside the project's virtual environment. Auvxrun or a hook environment managed by pre-commit would not contain the project's packages. deptry's own published hook islanguage: systemfor the same reason. Usingsrcas the root makes deptry treatdevops_clias first-party. Run from.withoutknown_first_party, it reports 3,157 findings, nearly all of them false DEP003 findings fordevops_cliitself. - Should deptry scan
tests/? Proposed: no. deptry treats every scanned file as shipped code, sotests/would raise 327 DEP004 findings for pytest and hypothesis. The contract is the package users install, and deptry excludestestsby default. - Does declaring packages that already arrive transitively make upgrades harder? Proposed: accept that cost. pydantic-graph moves in lockstep with pydantic-ai (pydantic-ai-slim requires
pydantic-graph==2.35.0), and opentelemetry-api moves with the OTLP exporter series.uv lockfails loudly if the pins drift apart.uv tree --outdated --depth=1, already a gate step, then lists these packages too. - Should pydantic-handlebars be a direct pin or come through the extra? Proposed: the extra. pydantic-ai names
specas the install route forTemplateStr(pydantic_ai/template.py:133-135), and thepydantic-aipackage exposes the same extra (pydantic-handlebars and PyYAML). With the extra, no DEP002 ignore is needed. The handlebars version follows pydantic-ai's requirement, and uv.lock pins it. - Should logfire come through an extra or be declared directly? Proposed: directly, as
logfire==5.1.0. src calls its core API itself, and thehttpxextra still arrives through pydantic-ai'slogfireextra. - What platform marker does secretstorage need? Proposed:
sys_platform == 'linux', the marker keyring itself uses. The import stays inside the gnome-keyring check, so behaviour on other platforms does not change.
Strategic alignment
- Milestone: none; the roadmap tooling places it. Nothing is broken today, and httpx will stay in the tree while fastmcp, mcp, google-genai and qdrant-client require it. The risk is a later dependency update that drops a transitive package and breaks an import at run time.
- Related:
- fix(github): supply-chain claims made true — live Dependabot, zizmor and workflow invocation contracts #861 (v0.2.28) also pins a tool in the dev group, adds a gate step, and flags the undeclared
pip-auditcall indevops ci maintain. - refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001 may remove the
openaiimport fromai/models/ollama.py. deptry would then require dropping the declaration in the same PR. - refactor(github): the github session owns transport, ledger, error classes and link pagination #983 (v0.2.28) deletes
run_gh_async, the only caller ofget_async_limiter(github/rate_limiter.py:775-780, called at:1963). If it also removes the last aiolimiter import (:30, used at:763and:779), the same PR dropsaiolimiter==1.3.0(DEP002) once this step exists. - docs(agents): instruction surfaces state only what is true, and
devops ai agentsnever overwrites AGENTS.md #840 (v0.2.27) rewrites the gate counts onAGENTS.md:60, the line this item adds the step to. - fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898 (v0.2.29) leaves both fallback shims to this item and no longer deletes the broker.py shim, as the key question above sets out. When fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898 starts importing httpcore2, it declares
httpcore2==2.13.0, which this step then enforces. If this item lands first,broker.pyreaches its two clients ashttpx2.call sites, so fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898'shttpx2\.(Async)?Client\(count includes them. - refactor(ci): github ci runs the gate through
devops cifrom one check table #843 (v0.2.26): the check table this item adds itsdepsrow to. - feat(ci): hand-rolled URL and address parsing fails
devops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107 adds its ownconstructsrow to the same table and the sameAGENTS.md:60gate list. - Dependency-hygiene group: this item, fix(github): gh calls no longer stall silently for up to a minute behind a fixed 60-call window, and the unmaintained
ratelimitpackage is removed #1118 (removesratelimit) and refactor(ai): the durable resolver offers only the engines that work, and the unreadai.durablesettings are removed #1121 (the durable engines) change the same[project].dependencies; whichever lands second re-runsuv lock. - refactor(ai): the durable resolver offers only the engines that work, and the unread
ai.durablesettings are removed #1121 settles temporalio, dbos and prefect and removes the DEP001 ignore. - fix(github): gh calls no longer stall silently for up to a minute behind a fixed 60-call window, and the unmaintained
ratelimitpackage is removed #1118 removesratelimit. If this step lands first, DEP002 fails fix(github): gh calls no longer stall silently for up to a minute behind a fixed 60-call window, and the unmaintainedratelimitpackage is removed #1118's PR should the pin outlive the last import.
- fix(github): supply-chain claims made true — live Dependabot, zizmor and workflow invocation contracts #861 (v0.2.28) also pins a tool in the dev group, adds a gate step, and flags the undeclared
- Library first: this item uses deptry and pydantic-ai's own
specextra rather than any hand-written import scanner or mapping.
Metadata
Metadata
Assignees
Labels
priority/p2-mediumPriority P2: standard workscope/aiAI review pipeline, personas, prompts, LLM client, or RAGscope/ciGitHub Actions workflows, pre-commit hooks, CI gates, and runnerstype/bugType bug: the code does not do what it must
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 8, 2026
Placed in v0.2.31 on 2026-10-08 at the owner's request ("Populate 10 security and ci issues into each v0.2.30, v0.2.31, and v0.2.32 milestone"). This is a person's placement. Release theme: finding identity v2, URL credential masking, tests that leave no state, the Docker endpoint check and the Argo CD/OTel perimeters. Position 8 of 10 in the release's planned merge order. Its board Status is set to Ready, so the release-start fill keeps it.
dan-petty commentedon Oct 8, 2026
Re-checked at 05e9388 by the 2026-10-08 client-library audit. These direct imports are still undeclared in
[project].dependencies:secretstorage:commands/devcontainer.py:1396, moved from:1390. It arrives through keyring on Linux only.openai:ai/models/ollama.py:9(AsyncOpenAI). It arrives through pydantic-ai-slim'sopenaiextra.anthropic: to be added here once the AI-slice item that adopts the Claude SDK lands.PyNaCl is already listed in this item.
The audit's telemetry item (
refactor(telemetry): spans are built and exported by the OpenTelemetry SDK, ...) also makesopentelemetry-sdkandopentelemetry-exporter-otlp-proto-commondirect imports. Both arrive today only through logfire and the grpc exporter.fix(deps): declare direct dependencies and add deptry gate step (#1120)…
dan-petty-bot commentedon Oct 9, 2026
What changed
#1480, merged into
release/v0.2.31as b22837d.19 file(s) changed.
How it was verified
Check runs at 2e93066:
Acceptance Criteria of
docs/agent/tasks/task-1120-deptry-dependencies.md:deptry srcpasses cleanly with zero findings on the codebase.logfire,pynacl,openai,pydantic-graph,opentelemetry-api,secretstorage) are declared inpyproject.toml.httpximports and fallback shims insrc/are removed;Timeoutre-export is eliminated fromdevops_cli.ai.settings.devops ci depsexecutesuv run deptry srcand is wired as a gate check indevops ci.AGENTS.mdand documentation matrices are synchronized with thedepsgate check.depscheck spec, CLI subcommand dispatch, and workflow parity.import httpxtriggers DEP003; removing a declared package triggers DEP002.uv run devops cipasses 100% locally.feat(release): v0.2.31 (#1490)