Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ All code authored in or evaluated by DevOps CLI must strictly adhere to the foll

12. **MCP Tool Secrets**: A model writes the arguments of an MCP tool call. A secret in an argument passes through the model context, the provider, the LLM cache and the run trace, and the model can send it to another tool. So a tool publishes no parameter that takes a secret value (a password, a token, an API key or a private key). A credential for a call is carried on the connection, as a header that the harness sets, or the server reads it from its configuration, or it is an opaque reference that the server resolves from the secret store, such as `keyring:<name>` for the OIDC token of `docker_sign`. A tool never returns or logs a credential, so `vault_get` publishes no `show` option, and `vault_set` is not a tool. `CONST_MCP_SECRET_PARAMETER_WORDS` in `src/devops_cli/config/constants.py` lists the words that make a parameter name suggest a secret. `tests/ai/mcp/test_mcp_tool_secrets.py` reads the published schema of every tool and fails on a text parameter whose name holds one of them. `CONST_MCP_SECRET_PARAMETER_ALLOWLIST` names the parameters that hold no secret value, such as the name of a Kubernetes Secret. A new entry needs a reason, and the test fails on an entry that matches no parameter. `RunTrace` hides the value of an argument under such a name, and `mask_secrets` is the second guard. `ArgumentValueLogFilter` keeps all arguments out of the FastMCP log.

13. **Hosted Models**: The LiteLLM gateway serves four groups that call a provider outside the cluster: `gemini-3.8-flash`, `claude-sonnet-5-5`, `claude-haiku-5-5` and `deepseek-v4.1-flash-1017` (through OpenRouter, which picks a third-party provider and is asked to skip providers that store or train on prompts). A prompt sent to one of them leaves the cluster, and the provider bills each token. So no pool names a hosted group, no fallback sends a group that is not hosted to a hosted group, and a request reaches a provider only when its caller names a hosted group. The Service config names `deepseek-v4.1-flash-1017` for every chat slot but one: `ai.model` and the tasks `implement`, `verification`, `chat` and `triage` (`k8s/devops/configmap.example.yaml`, owner decision of 2026-11-07, #3874). So the code of the repositories of the Service, which can be private, leaves the cluster to OpenRouter in the prompts of a step, and so do the titles and bodies of the issues in the prompts of intake and chat. The one exception is the task `analysis` (the stage job, refine and the alternatives check), which names `claude-sonnet-5-5` as a trial (owner decision of 2026-11-09, #4204): its prompts, which hold the issue and the repository text that the planner reads, leave the cluster to Anthropic. Only the embedding slot stays in the cluster. The one fallback, `claude-sonnet-5-5` to `deepseek-v4.1-flash-1017` (#3152), sends the prompt of a failed Claude call to OpenRouter, not to Anthropic. The keys are optional keys of the Secret `llm/llm-gateway-secrets` (keyring: `gemini.api_key`, `anthropic.api_key`, `openrouter.api_key`). The gateway NetworkPolicy admits TCP 443 to public addresses and to no private or metadata range. A Claude group sets its prices, drops the sampling parameters that its API refuses, and sets `supports_native_structured_output` and `supports_response_schema`, or a structured call becomes a forced tool call that Sonnet 5.5 refuses (#3140). `tests/ai/benchmark/test_k8s_llm_gateway.py` fails when any of this breaks.
13. **Hosted Models**: The LiteLLM gateway serves four groups that call a provider outside the cluster: `gemini-3.8-flash`, `claude-sonnet-5-5`, `claude-haiku-5-5` and `deepseek-v4.1-flash-1017` (through OpenRouter, which picks a third-party provider and is asked to skip providers that store or train on prompts). A prompt sent to one of them leaves the cluster, and the provider bills each token. So no pool names a hosted group, no fallback sends a group that is not hosted to a hosted group, and a request reaches a provider only when its caller names a hosted group. The Service config names `deepseek-v4.1-flash-1017` for every chat slot but one: `ai.model` and the tasks `implement`, `verification`, `chat` and `triage` (`k8s/devops/configmap.example.yaml`, owner decision of 2026-11-07, #3874). So the code of the repositories of the Service, which can be private, leaves the cluster to OpenRouter in the prompts of a step, and so do the titles and bodies of the issues in the prompts of intake and chat. The one exception is the task `analysis` (the stage job, refine and the alternatives check), which names `claude-sonnet-5-5` as a trial (owner decision of 2026-11-09, #4204): its prompts, which hold the issue and the repository text that the planner reads, leave the cluster to Anthropic. Only the embedding slot stays in the cluster. The one fallback, `claude-sonnet-5-5` to `deepseek-v4.1-flash-1017` (#3152), sends the prompt of a failed Claude call to OpenRouter, not to Anthropic. The keys are optional keys of the Secret `llm/llm-gateway-secrets` (keyring: `gemini.api_key`, `anthropic.api_key`, `openrouter.api_key`). The gateway NetworkPolicy admits TCP 443 to public addresses and to no private or metadata range. A Claude group sets its prices, drops the sampling parameters that its API refuses, and sets `supports_native_structured_output` and `supports_response_schema`, or a structured call becomes a forced tool call that Sonnet 5.5 refuses (#3140). TypeSafe Jev (`typesafe/jev-1.14`) is no group: the gateway passes `POST /v1/systemone` to the System One endpoint of OpenRouter with the OpenRouter key of the gateway, for a caller that holds a valid gateway key (#4289). A prompt sent to it leaves the cluster, and the pass-through cannot set `data_collection`, so the privacy setting of the OpenRouter account applies. `tests/ai/benchmark/test_k8s_llm_gateway.py` fails when any of this breaks. `tests/ai/test_jev_gateway_route.py` fails when the client path and the pass-through differ.

14. **Roadmap Item Authors**: The repository is public, and a roadmap job gives the text of an item to a model. The model writes into the roadmap and, through Ready items, steers the agents that build.
- **The authors.** A job takes an item only when its author is a person with write access. For such a person, `author_association` is OWNER, MEMBER or COLLABORATOR (#2478). A job also takes an item of two bots. Their login is exactly `service.github_app.bot_login` or `github-actions[bot]` (#3502).
Expand Down
2 changes: 2 additions & 0 deletions k8s/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ curl -H "Authorization: Bearer $KEY" http://<node>:<node-port>/v1/models
```
Four groups call a hosted provider: `gemini-3.8-flash` (Google), `claude-sonnet-5-5` and `claude-haiku-5-5` (Anthropic), and `deepseek-v4.1-flash-1017` (DeepSeek, through OpenRouter). A prompt sent to one of them leaves the cluster, and the provider bills each token. No pool names them, and the one fallback links a hosted group to a hosted group (`claude-sonnet-5-5` to `deepseek-v4.1-flash-1017`, #3152), so a request reaches a provider only when its caller names a hosted group. A call to `claude-sonnet-5-5` that fails (an Anthropic error, a rate limit, a spend limit) then goes to OpenRouter and not to Anthropic: in the review of 12 golden plans that model found 38% of the known defects against 56% for Sonnet 5.5, and the Gemini Flash Lite, Gemma and older Gemini models found 7 to 25%, so only it is a fallback. A person stores each key in the keyring with `devops config set gemini.api_key`, `devops config set anthropic.api_key` or `devops config set openrouter.api_key`. Then `devops k8s push-secrets --only llm/llm-gateway-secrets` writes it to the Secret as `gemini-api-key`, `anthropic-api-key` or `openrouter-api-key` and restarts the gateway. The gateway starts without a key, and a call to a group with no key fails with an error that names the missing key; the other groups work. The gateway NetworkPolicy admits TCP 443 to public addresses for these calls, and to no private range (SECURITY.md rule 13). OpenRouter picks the provider of a `deepseek-v4.1-flash-1017` call. The group asks for the cheapest provider (the OpenRouter `floor` route) with fp8 weights that does not store or train on prompts (`data_collection: deny`); a provider that fails a filter is skipped, so the price can be above the cheapest one, and a call fails when no provider passes. A caller sets the reasoning effort. The implement job of the Service and its runner Jobs call this group (item 19 of the Roadmap service). Both Claude models refuse `temperature`, `top_p` and `top_k` with a 400, and the cost map of the pinned LiteLLM image does not list them, so their groups drop the three and set their own prices. Sonnet 5.5 also refuses a forced tool call, so a caller of the group sends `tool_choice` `auto`. LiteLLM turns a `response_format` into a forced tool call unless its model map says the model supports native structured output, so each Claude group sets `supports_native_structured_output` and `supports_response_schema` and a structured reply works (#3140). Above 100,000 prompt tokens Haiku 5.5 costs 0.50 USD for input and 2.50 USD for output per million tokens, and LiteLLM has no price tier at that size: the spend of such a call reads low. To check a key after the rollout, run `curl -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" -d '{"model":"gemini-3.8-flash","messages":[{"role":"user","content":"Say ok"}],"max_tokens":16}' http://<node>:<node-port>/v1/chat/completions`.

TypeSafe Jev (`typesafe/jev-1.14`) is a decision model, not a group. OpenRouter refuses it on chat completions with HTTP 400, so `model_list` has no entry for it. The gateway serves it as the pass-through `POST /v1/systemone` (`general_settings.pass_through_endpoints`), which forwards the request body unchanged to `https://openrouter.ai/api/v1/systemone` (#4289). The client `SystemOneModel` posts to `{ai.gateway_url}/systemone`, so a Jev call needs no setting beyond `ai.gateway_url` and the gateway key. The pass-through checks the gateway key of the caller, sends the OpenRouter key from the Secret key `openrouter-api-key` (keyring `openrouter.api_key`) and forwards no header of the caller. It cannot set provider preferences such as `data_collection` in the body, so the privacy setting of the OpenRouter account applies to Jev calls. A prompt sent to Jev leaves the cluster (SECURITY.md rule 13). OpenRouter bills 0.042 USD per million input tokens and nothing for output; the spend ledger of the gateway does not see these calls, because the pass-through has no cost entry. To check the route after a rollout, run `curl -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" -d '{"model":"typesafe/jev-1.14","state":"The page is blank after Pay.","questions":{"is_bug":{"type":"noul","instructions":"Is this a software defect?"}}}' http://<node>:<node-port>/v1/systemone`.

Each `ollama_chat` deployment sets `max_input_tokens` in its own top-level `model_info`, equal to the `OLLAMA_CONTEXT_LENGTH` of its tier, and `devops ai gateway render` keeps the two equal. LiteLLM reads the window only from that place: a `model_info` under `litellm_params` has no effect. A deployment that sets no window reads the cost-map entry of its backend model, which the last deployment registered wrote. Thus each deployment sets its own window, and a test holds this (#2825). Ollama cuts a prompt that is longer than its window and returns no error, so the check is the only guard. The gateway sets no `context_window_fallbacks`: `devops-chat`, `devops-coder` and `devops-reasoning` run on `ollama-48gib-fast`, and `devops-background` and `devops-triage` run on `ollama-64gib-standard`. Both tiers have the same window, 262,144 tokens, so none of these groups could take a prompt that another of them refused. A prompt fails with a context-window error only when no group of the chain holds it.

These groups route reviews, embeddings and background work:
Expand Down
32 changes: 18 additions & 14 deletions k8s/llm/gateway/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,6 @@ model_list:
output_cost_per_token: 1.92e-07
cache_read_input_token_cost: 8.0e-09
supports_response_schema: true
# TypeSafe Jev 1.14 System One decision model on OpenRouter. Answers typed Choice, Noul and
# Score questions with calibrated probabilities for model routing, tool-call gating and evals.
- model_name: typesafe/jev-1.14
litellm_params:
model: openrouter/typesafe/jev-1.14
api_key: os.environ/OPENROUTER_API_KEY
extra_body:
provider:
data_collection: deny
model_info:
max_input_tokens: 262144
input_cost_per_token: 4.2e-08
output_cost_per_token: 0.0
supports_response_schema: true
litellm_settings:
# Per-deployment requests, failures and latency at /metrics/, scraped by Prometheus. The
# Ollama nodes export no metrics of their own, so this is how their load is seen.
Expand Down Expand Up @@ -286,3 +272,21 @@ general_settings:
# allow_requests_on_db_unavailable stays unset (false): the gateway is reachable from outside
# the cluster, so a key that it cannot check while the database is down is refused.
proxy_batch_write_at: 10
# TypeSafe Jev 1.14 is a decision model. OpenRouter refuses it on chat completions (HTTP 400),
# so it has no model_list entry. The client (src/devops_cli/ai/jev.py) posts the System One
# protocol to {ai.gateway_url}/systemone, and this pass-through forwards that body unchanged to
# the System One endpoint of OpenRouter (https://openrouter.ai/docs/guides/community/jev). The
# gateway checks the key of the caller (auth), sends the OpenRouter key from its own
# environment, and forwards no header of the caller. It cannot set provider preferences such as
# data_collection in the body, so the privacy setting of the OpenRouter account applies.
# tests/ai/test_jev_gateway_route.py fails when this path and the client path differ.
pass_through_endpoints:
- path: /v1/systemone
target: https://openrouter.ai/api/v1/systemone
methods: [POST]
auth: true
forward_headers: false
include_subpath: false
headers:
Authorization: bearer os.environ/OPENROUTER_API_KEY
content-type: application/json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-11-09
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Design

## Decisions
- One route serves the client and the Service: `POST {ai.gateway_url}/systemone`, a LiteLLM pass-through to `https://openrouter.ai/api/v1/systemone`. The path is the path that `SystemOneModel` already uses, so the client code does not change.
- The pass-through sets `auth: true`. The gateway is reachable from outside the cluster, and an open pass-through would let anyone spend the OpenRouter key. LiteLLM 1.103.0 needs no license for it.
- `forward_headers: false` and a fixed `Authorization` header from `os.environ/OPENROUTER_API_KEY`. The gateway key of the caller never reaches OpenRouter.
- `methods: [POST]` and `include_subpath: false`: the route serves one call and nothing else.
- Jev is removed from `model_list` and from `CONST_AI_GATEWAY_HOSTED_MODELS`. It is no chat group; a chat call always fails, and a ladder tier named `typesafe/jev-1.14` would fail the same way.
- The check is `tests/ai/test_jev_gateway_route.py`. It builds the model as the bridge builds it, records the path of the request on the HTTP fake, and compares that path with the pass-through of the real gateway config (target, auth, headers, methods). It also fails when `model_list` lists the model again.

## Rejected alternatives
- Pass-through to `/api/alpha/decisions`: the wire format also matches, but OpenRouter marks it alpha and the shape may change. The pydantic-ai issue 8552 only verified that rewrite offline. The System One path is documented for this client.
- Direct call to `api.typesafe.ai` (`CONST_URL_TYPESAFE_API_BASE`): it needs a new key and an egress decision. A person decides both, and the pass-through needs neither.
- Keep the `model_list` entry next to the pass-through: it serves chat calls, which OpenRouter answers with HTTP 400 (evidence of #4289), so it only makes the model look healthy.
- Drop Jev: it removes the planned uses of #4282 and #4284, and the route works with documented, existing tools.
Loading
Loading