Description
Problem
config/constants.py and config/defaults.py declare 138 names (57 constants, 81 defaults) that only one package of the AI runtime uses. Counted at 38517a8 (the release/v0.2.25 tip) by AST, with the method described in #1016: from-imports and attribute reads count, and re-exports do not. The counts are approximate (an independent count differs by up to about ten per item, mostly in how function-local imports and names that only build another config/ name are attributed); the baseline is the exact list.
- By package: modules directly in
ai/83,ai/client/26,ai/mcp/13,ai/tools/8,ai/providers/6,ai/cache/1 andai/retries/1 (CONST_RETRYABLE_HTTP_STATUS_CODES, read byai/retries/__init__.py). 39 modules read them. The largest readers areai/format_prompt.py(13),ai/gateway.py(10),ai/client/unified.py(9),ai/common_tools.py(9),ai/review_schema.py(8),ai/tools/builtin_tools.py(8) andai/pydantic_ai_bridge.py(7). - Eight are read by two or more modules of one package. For example,
CONST_URL_ANTHROPIC_API_BASE(constants.py:366) is read byai/client/claude.pyandai/client/unified.py. - Seven test files import them from
config/:test_ai_client_finish_reasons.py,test_ai_gateway.py,test_ai_gateway_portkey.py,test_fastmcp_contracts.py,test_ollama_dynamic_leasing.py,test_pydantic_ai_workflows.pyandtest_structural_positional_oracles.py.
The placement rule (#1016) puts each of these names next to the code that reads it. That item's baseline lists them under ai, ai.client, ai.mcp, ai.tools, ai.providers, ai.cache and ai.retries, and its invariant fails once a listed name is moved and its entry is left behind, so this PR deletes those blocks.
Acceptance criteria
- Each name listed under
ai,ai.client,ai.mcp,ai.tools,ai.providers,ai.cacheandai.retriesintests/fixtures/config_placement_baseline.jsonis declared in the one module that reads it, or in its package'sconstants.pywhen two or more modules of the package read it. Its name, value and comment are unchanged, and it is annotatedFinal.config/constants.pyandconfig/defaults.pyno longer declare it, and its block is gone from the baseline. - Every importer imports the name from its new module, including the test files named above. Nothing in
config/re-exports it. - A name that only code deleted by an earlier item read is deleted, not moved.
- The two invariant tests from docs(agents): a matching table lives beside its one owner, and moves to config/ only when a second package imports it #1016 pass.
- Apart from the
Finalannotation added where a name lacked it, the PR only moves code:git diff --color-moved=zebrashows every other declaration line as moved. The diff touches onlyconfig/constants.py,config/defaults.py, the baseline,ai/(outsideai/review/and the packages of refactor(ai): the agent, rag, benchmark and spend tables move out of config/ next to their owners #1028) and the tests that import the moved names. -
uv run devops cipasses.
Key questions
- Does a name go into the module that reads it, or into the package's
constants.py? (proposed) Into the module, when one module reads it. Into the package'sconstants.pywhen two or more do, as the rule says. That applies to eight names here, for exampleCONST_URL_ANTHROPIC_API_BASE,CONST_URL_OPENAI_API_BASEandCONST_URL_GITHUB_COPILOT_API_BASE. - When does it land? (proposed) After the filed items that delete or rewrite these modules: refactor(ai): one agent runtime behind one construction point, with no silent fallback #1005 (deletes the bridge factories and, per its proposed scope,
ai/providers/andai/direct.py), refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001 (rewritesai/client/), refactor(mcp): the mcp tool bridge is generated from the typer app instead of 147 hand-written argv lists #997 (generates the MCP tools, so most ofai/mcp/server.pygoes) and refactor(ai): one structured-output path for validate, repair, reflect and retry #1003 (ai/client/structured.py). Names their deleted code read are deleted with it. - Can the move add an import cycle? (proposed) No. A moved table imports nothing new, and a package's
constants.pyimports nothing from its package.test_no_circular_imports_in_decoupled_subsystems(tests/test_architectural_invariants.py:308) is the check.
Depends on: #1016, #776.
Order: after #1005, #1001 and #997 when those are scheduled first. #1002 deletes ai/__init__.py's re-exports, so the move does not edit them if #1002 has landed.
Related: #1001, #1002, #1003, #1005, #997, #776.
Update 2026-10-08: refinement
The owner's #1001 decision keeps the pydantic-ai route, so a name that code reads is moved, not deleted, unless #1001 removed its last reader (ai/pydantic_ai_bridge.py:25-41). The legacy classes still go with #1331; if it lands first, names only they read are deleted, such as DEFAULT_OLLAMA_HOST (config/defaults.py:387).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsReady
- StatusShow more project fieldsReady
Activity
dan-petty commentedon Oct 3, 2026
Lines cited at dcafadf.
At 132ecc5,
ai/mcp/server.py:2050is:2073; the other cited lines are unchanged.Two of this item's names have readers that other items delete. Leave them in
config/, with their baseline entries:CONST_MODEL_ENDPOINT_MARKERS(config/constants.py:269, underai.mcp; read only atai/mcp/server.py:2050). fix(security): URL and host:port reads use the sending client's parser, so key trust, crawls, probes and settings act on the host actually dialled #1112 deletes it. Model specs then go through one parser, and endpoints are compared byhttpx2.URL(...).origininstead of the("@", "://")substring test.DEFAULT_AI_CACHE_TTL_SECONDS(config/defaults.py:645), this item's oneai.cachename. Its only reader isai/cache/valkey_cache.py(imported at:12). fix(valkey): one validated URL names every Valkey endpoint, valkey-py dials an address that one check vetted, and the unused cache layer goes #1113's first PR deletesai/cache/,ValkeyCacheProviderand its export, because only tests build that provider, and it deletes this default with them.Moving either name first only adds a diff that those items undo. If #1112 has landed, the marker table is already gone; if #1113's first PR has landed, so is the TTL default. For any other name, this item's "deleted, not moved" criterion applies: if an earlier item deleted its only reader, delete the name instead of moving it.
dan-petty commentedon Oct 28, 2026
Closed as not planned. The item conflicts with a more recent project direction. No code was written.
This item is a bulk move of single-owner tables out of
config/. Its acceptance criteria use the placement baseline and the invariant tests that #1016 planned.The owner decision of 2026-10-22 on #1016 replaced that plan:
core/config_placement.py, the baseline filetests/fixtures/config_placement_baseline.jsonand the two invariants are not built.#2492 (merged 2026-10-28) put the rule in
CONTRIBUTING.md: "When you change the owner of a table inconfig/that only one package reads, move the table to its owner in the same pull request."On origin/main (2026-10-28) the baseline file,
core/config_placement.pyand the placement tests do not exist, so the criteria of this item that use them cannot be met. A bulk move also conflicts with each open pull request that changesconfig/constants.pyorconfig/defaults.py. #1026, the sibling item, is closed with the same evidence.A table in
config/that only one package reads now moves to its owner in the pull request that next changes that owner.