Repository navigation
Description
Problem Description
The dry-run plans of the devops ai commands in src/devops_cli/ai/ai_plans.py give service URLs that no setting gives. The rule of #1165 allows no such URL: the code reads the setting, or it names the setting.
- Nine sites fall back to
["http://localhost:11434"]whenai.ollama_urlsis empty: lines 33, 57, 110, 231, 248, 269, 308 and 327 onorigin/mainat release 0.127.0, and line 337 in_get_llm_embedding_target. _resolve_gateway_basefalls back toDEFAULT_AI_GATEWAY_URL(http://localhost:4000/v1) whenai.gateway_urlis not set._get_qdrant_targetfalls back toDEFAULT_QDRANT_URL(http://localhost:6333) whenqdrant.urlis not set._get_llm_chat_targethas no gateway branch, so a gateway provider gets the OpenAI default URL.
The guard of #1165, the ast-grep rule net-localhost-fallback, reads these files but does not find the sites: it matches or "http://localhost..." and not or ["http://localhost..."] or a fallback to a constant.
#5345 fixed the same problem in src/devops_cli/review/review_plans.py: the plan builders call resolve_ai_endpoint and show an unset setting as a placeholder, such as <ai.ollama_urls>.
Reproduction Steps
- Use a config file that holds only
ai.provider: ollama. - Run
uv run devops ai test --dry-runanduv run devops ai chat --dry-run. - Read the target of the planned model request.
Expected vs Actual Behavior
- Expected: the plan target names
ai.ollama_urlsas a placeholder, as the review plans do after fix(review): drop the fixed gateway URL of the review dry run #5345. - Actual: the plan target is
http://localhost:11434/api/chat.
Environment Diagnostics
origin/main at release 0.127.0. git grep -n 'or \["https\?://localhost' src finds 9 sites in src/devops_cli/ai/ai_plans.py after #5345.
Logs, Traces, or Terminal Output
None.
Proposed Fix
Get each AI target in ai_plans.py from resolve_ai_endpoint, as review_plans.py does, and show an unset setting as a placeholder. Give the gateway and Qdrant plans the same rule. Extend .ast-grep/rules/net-localhost-fallback.yml (and its rule test) to match a fallback list, such as or ["http://localhost:11434"], so the guard fails if the problem returns.
Alternatives check of 2026-11-28: none.
Tool: none found.
Reason: Searches surfaced no library that resolves AI plan endpoints from settings or renders an unset setting as a placeholder; the fix stays in the project's own resolver code, and ast-grep only needs a new rule branch.
Lacks:
- No tool resolves ai_plans targets from ai.ollama_urls, ai.gateway_url or qdrant.url
- No tool renders an unset setting as a
<key>placeholder in a dry-run plan - No tool adds the gateway branch to _get_llm_chat_target
- No tool drops the DEFAULT_AI_GATEWAY_URL and DEFAULT_QDRANT_URL imports
Proposed design
Problem statement
The AI dry-run plans show service URLs that no setting gives: http://localhost:11434 for Ollama, http://localhost:4000/v1 for the gateway and http://localhost:6333 for Qdrant. The guard net-localhost-fallback misses a list fallback such as or ["http://localhost:11434"]. The change resolves each AI target from the settings through resolve_ai_endpoint and shows an unset setting as a placeholder, as review_plans.py does after #5345.
Acceptance criteria
Requirement: Chat plan names the unset Ollama setting
The chat plan SHALL resolve the Ollama endpoint from the settings and SHALL show an unset ai.ollama_urls as <ai.ollama_urls>.
Scenario: Chat plan with no Ollama URLs
- WHEN
plan_ai_chatruns withai.providerset toollamaand noai.ollama_urls - THEN the target of the planned request is
<ai.ollama_urls>/api/chat
Requirement: Every Ollama plan names the unset setting
The agents, models, test, preload, prewarm and benchmark plans MUST use the same resolved Ollama endpoint or its placeholder.
Scenario: Ollama plan builders with no URLs
- WHEN
plan_ai_agents,plan_ai_models,plan_ai_test,plan_ai_preload,plan_ai_prewarmandplan_ai_benchmarkrun with noai.ollama_urls - THEN each planned target starts with
<ai.ollama_urls>
Requirement: Embedding plan names the unset setting
The embedding plan target SHALL resolve the configured endpoint and SHALL show an unset setting as a placeholder.
Scenario: Analyze plan with no Ollama URLs
- WHEN
plan_ai_analyze_pathruns withai.providerset toollamaand noai.ollama_urls - THEN the target of the planned request is
<ai.ollama_urls>/api/embeddings
Requirement: Gateway chat plan uses the gateway setting
_get_llm_chat_target MUST return the base of ai.gateway_url plus /chat/completions for a gateway provider.
Scenario: Chat target with a gateway provider
- WHEN
_get_llm_chat_targetruns withai.providerset togatewayandai.gateway_urlset tohttp://gw:4000/v1 - THEN the target is
http://gw:4000/v1/chat/completions
Requirement: Gateway plans name the unset setting
The gateway route, status, tune and ask plans MUST use ai.gateway_url, and an unset setting MUST show as <ai.gateway_url>.
Scenario: Gateway status plan with no gateway URL
- WHEN
plan_ai_gateway_statusruns with noai.gateway_url - THEN the target of the planned request is
<ai.gateway_url>/health
Requirement: Qdrant plans name the unset setting
Each Qdrant plan target MUST use qdrant.url, and an unset setting MUST show as <qdrant.url>.
Scenario: RAG status plan with no Qdrant URL
- WHEN
plan_ai_rag_statusruns with noqdrant.url - THEN the target of the planned request is
<qdrant.url>/collections
Requirement: The localhost guard catches a list fallback
The net-localhost-fallback rule SHALL report a fallback list that holds a localhost URL.
Scenario: Rule test for a list fallback
- WHEN
uv run ast-grep testruns the rule test that holdsx = urls or ["http://localhost:11434"] - THEN the command exits 0 and its output shows the
net-localhost-fallbackrule test passing
Requirement: The AI plans import no default URL constant
src/devops_cli/ai/ai_plans.py MUST NOT import DEFAULT_AI_GATEWAY_URL or DEFAULT_QDRANT_URL.
Scenario: Source test over the AI plans module
- WHEN a test inspects the imports of
src/devops_cli/ai/ai_plans.py - THEN the module imports neither
DEFAULT_AI_GATEWAY_URLnorDEFAULT_QDRANT_URL
Existing Tool Considered
The alternatives check of 2026-11-17 records the verdict none (see the alternatives block in the issue body). No external tool covers the need. The plan reuses the project's own resolve_ai_endpoint helper in src/devops_cli/ai/endpoints.py, as review_plans.py does after #5345. It extends the project's own ast-grep rule net-localhost-fallback to match a fallback list. The only new code is the rule branch and its test: about 10k tokens and under one hour to write, keep and fix.
Key questions
- How does a dry-run plan show a setting that is not set?: Catch
ConfigurationErrorfromresolve_ai_endpointand use<key>fromexc.key, asreview_plans.pydoes after fix(review): drop the fixed gateway URL of the review dry run #5345. (best practice) [sources: src/devops_cli/review/review_plans.py, src/devops_cli/ai/endpoints.py]- Chosen: Placeholder from the resolver. fix(review): drop the fixed gateway URL of the review dry run #5345 set this rule and the review plans use it.
- Rejected: Keep the localhost default. It shows a URL that no setting gives and breaks the rule of fix(config): service clients use only configured urls and never fall back to an unconfigured localhost default #1165.
- Rejected: Stop the dry run. A dry run must show the plan, and the review plans show a placeholder.
- Where does the shared plan resolver live?: Add
resolve_ai_plan_basetosrc/devops_cli/ai/endpoints.py. Both plan modules call it. (best practice) [sources: src/devops_cli/ai/endpoints.py, src/devops_cli/review/review_plans.py, src/devops_cli/ai/ai_plans.py]- Chosen: Shared helper in
ai/endpoints.py. One copy stays next toresolve_ai_endpointand serves both plan modules. - Rejected: Copy
_resolved_baseintoai_plans.py. Two copies of the placeholder rule drift. - Rejected: Import the private
_resolved_base. A module must not import a private helper of another module.
- Chosen: Shared helper in
- How do the preload, prewarm and benchmark plans list the Ollama servers?: Read
settings.ai.get_ollama_urls. When it is empty, use['<ai.ollama_urls>']. These plans target every server, andresolve_ai_endpointreturns one primary URL. (best practice) [sources: src/devops_cli/ai/ai_plans.py]- Chosen: List the setting with a placeholder. It keeps every server in the plan and names the setting when it is empty.
- Rejected: Use one primary from
resolve_ai_endpoint. It drops the other servers from the plan.
- How does
_get_qdrant_targetshow an unsetqdrant.url?: Readsettings.qdrant.url. When it is empty, return<qdrant.url>plus the path. (best practice) [sources: src/devops_cli/ai/ai_plans.py, src/devops_cli/ai/rag/indexer.py]- Chosen: Placeholder
<qdrant.url>. It matches the review plan rule and makes no request. - Rejected: Use
resolve_qdrant_client. It builds a client, and the plan needs only the URL. - Rejected: Keep
DEFAULT_QDRANT_URL. It shows a URL that no setting gives.
- Chosen: Placeholder
- What path does a gateway chat target use?: Return the gateway base plus
/chat/completions. The gateway serves the OpenAI chat path. (best practice) [sources: src/devops_cli/ai/ai_plans.py, src/devops_cli/review/review_plans.py, src/devops_cli/config/defaults.py]- Chosen: Gateway base plus
/chat/completions. The gateway serves the OpenAI chat path at that base. - Rejected: Keep the OpenAI default URL. It ignores
ai.gateway_url. - Rejected: Use the gateway root plus
/v1/chat/completions.primary_urlalready holds the version suffix.
- Chosen: Gateway base plus
- Which ast-grep pattern catches a fallback list?: Allow an optional
[before the localhost string in the boolean-operator regex. (best practice) [sources: .ast-grep/rules/net-localhost-fallback.yml]- Chosen: Optional
[in the existing regex. One branch catches both the string and the list form. - Rejected: New
listkind branch. It reports a localhost list even when it is not a fallback. - Rejected: Match
or DEFAULT_*_URL. The rule cannot tell a localhost constant from another URL constant, so it gives false positives.
- Chosen: Optional
- Does an open tool or library cover the need?: No. The alternatives check of 2026-11-17 records
none. The plan reuses the internal resolver and extends the project's ast-grep rule. [sources: src/devops_cli/ai/endpoints.py, .ast-grep/rules/net-localhost-fallback.yml]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 13, 2026
Both remove localhost fallback URLs from dry-run plans and replace them with setting-name placeholders; the candidate targets ai_plans.py while #5345 targets review_plans.py.fix(review): drop the fixed gateway URL of the review dry run (#5399)
devops-cli-service commentedon Nov 17, 2026
Alternatives check: none
Reason: The searches found only general linters (Semgrep) and unrelated documentation; no open tool or library resolves a configured AI endpoint or replaces an unset setting with a placeholder. The need is a change inside this project's own code:
src/devops_cli/ai/ai_plans.pyshould use the existing internalresolve_ai_endpointhelper, asreview_plans.pydoes after #5345, and the project's own ast-grep rulenet-localhost-fallbackshould be extended, so nothing external covers it.Tool: none found
Lacks:
resolve_ai_endpointhelper<ai.ollama_urls>instead of a default service URL_get_llm_chat_targetor ["http://localhost:11434"]Searches run:
Sources:
Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 17, 2026
Status set to Ready at 2620fae (see proposed design in issue body).
devops-cli-service commentedon Nov 29, 2026
Released in v0.247.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.247.0
devops-cli-service commentedon Nov 29, 2026
Live since 2026-11-29 16:17 UTC