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
4 changes: 3 additions & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ All code authored in or evaluated by DevOps CLI must strictly adhere to the foll

The `--url` option of the `devops valkey` commands is an accepted case. A person types it, and no model gives the URL. So `valkey.password` goes to the host that the person names. Those commands are not MCP tools.

12. **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 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.
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 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.

---

Expand Down
16 changes: 0 additions & 16 deletions docs/MCP_TOOLS.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ The `devops-cli` FastMCP server exposes DevOps automation and AI review capabili
| [`valkey_set`](#valkey-set) | `false` | Set string value of key with optional expiration TTL. |
| [`valkey_stats`](#valkey-stats) | `true` | Display quick diagnostic summary of server health, memory, and keys. |
| [`vault_get`](#vault-get) | `true` | Fetch a secret from Vault, or from the OS keyring when Vault cannot answer. The keyring answers only with no usable token, when Vault has no value at the path, or when Vault is unreachable; never after Vault rejects the token. The output names the source. |
| [`vault_set`](#vault-set) | `false` | Store secret key-value pairs in HashiCorp Vault KV-v2 engine. |
| [`vault_status`](#vault-status) | `true` | Inspect HashiCorp Vault cluster health and initialization status. The health endpoint needs no token, and none is sent. The Token row names where the token other commands would use comes from, and why a stored token is not used for this address. |
| [`vault_sync`](#vault-sync) | `false` | Synchronize secrets from Vault into OS Keyring for offline/local CLI operations. Reads Vault alone. A path with no secret fails, and a field named like the entry that holds the `devops vault login` token is never written. |

Expand Down Expand Up @@ -2420,21 +2419,6 @@ Vault is unreachable; never after Vault rejects the token. The output names the
|---|---|---|---|---|
| `path` | `string` | Yes | - | Vault secret path (e.g. secret/data/myapp or vault://secret/data/myapp#token) |
| `key` | `string` | No | - | Specific secret field key to extract |
| `show` | `boolean` | No | `False` | Display secret in plain text without masking |
| `dry_run` | `boolean` | No | `False` | Preview execution plan without mutating external state. |

### `vault_set`

Store secret key-value pairs in HashiCorp Vault KV-v2 engine.

**Annotations:** `readOnlyHint: false`

**Parameters:**

| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `path` | `string` | Yes | - | Vault secret path (e.g. secret/data/myapp) |
| `key_values` | `array[string]` | Yes | - | Key-value pairs to store (format: KEY=VALUE) |
| `dry_run` | `boolean` | No | `False` | Preview execution plan without mutating external state. |

### `vault_status`
Expand Down
2 changes: 1 addition & 1 deletion k8s/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ The Service is a NodePort that Kubernetes assigns; find it with `kubectl -n llm
KEY=$(kubectl -n llm get secret llm-gateway-secrets -o jsonpath='{.data.master-key}' | base64 -d)
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 12). 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. 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`.
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. 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`.

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`, which has the largest window, 262,144 tokens, so none of them could take a prompt that another of them refused. A prompt longer than the window of `devops-background` (128,000) or `devops-triage` (160,000) moves on along the plain fallbacks to `qwen3.8:27b`, which has a 262,144 deployment on `ollama-48gib-fast`. A prompt fails with a context-window error only when no group of the chain holds it.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-11-02
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Design

## Decisions

- **The guard reads the published schema, not the Click commands.** The schema is what a model sees. A hand-written tool, such as `security_intel_package`, has no Click command, and the sweep covers it too.
- **A name word list, and a type filter.** The issue lists the words. The list adds `passphrase` and `key_values`. A match counts only when the parameter can hold text (a string, or a list of strings), because a flag, a number and a fixed choice cannot hold a secret value. That leaves `max_tokens` (an integer) and `push_secrets` (a boolean) out without an allow-list entry.
- **The allow-list is `CONST_MCP_SECRET_PARAMETER_ALLOWLIST`, a constant in `constants.py` and not a column of the exposure table.** A table row is a command, and the entry is a parameter of a tool. Hand-written tools are not in the table. The key is `(tool, parameter)` and the value is the reason.
- **Three entries, each with a reason.** `docker_sign.oidc_token` takes only a `keyring:<name>` reference, and the generator refuses any other value. `k8s_create_tls_secret.secret_name` and `k8s_enable_tls.secret_name` name a Kubernetes Secret object. The test checks that every entry matches a live parameter, so a renamed or removed parameter does not leave a dead entry.
- **`vault_set` leaves the tool surface.** The tool exists to carry secret values from the model to Vault. The rule forbids it. A person keeps `devops vault set`.
- **`vault_get` loses `show`.** The rule says that a tool never returns a credential. The option is cut with `_PATH_PARAM_RESTRICTIONS`, as for other options that are for a person.
- **`docker_sign` keeps `oidc_token` as a reference.** The owner's decision on #3219 names an opaque reference that the server resolves from the secret store. `keyring:<name>` is that, and the command resolves it already. The check is a `ValidationError` in the tool function, as `_check_model_endpoints` does for the benchmark. Its message names the parameter and never the value.
- **The run trace masks by name first.** `mask_secret_named_values` replaces the value under a secret-suggesting key at any depth of dicts and lists, and `bounded_text` then masks by form. The name matcher is shared with the guard test, in `sanitizer.py`, next to the other masking code.
- **No new log code.** `ArgumentValueLogFilter` replaces whole argument mappings in the FastMCP log, which is stronger than a mask by name. The rule cites it.

## Rejected alternatives

- **Put `vault_set.key_values` on the allow-list.** It is a secret value by purpose. An entry for it would make the rule empty.
- **Give `vault_set` a `credential_ref` for each value.** The command stores a value that a person gives. A reference would need a new source of values and no consumer asks for it.
- **Drop `oidc_token` from the sign tool.** Keyless signing outside a CI job with ambient identity needs a token, and the reference form is the carrier that the owner named.
- **Refuse in `generate_mcp_tools` at start-up instead of in a test.** The server would fail to start for a developer's new option, and the hand-written tools would still need the test. A test fails in CI where the change is reviewed.
- **Match the whole word only.** `secret_name` and `oidc_token` need a substring match, and the allow-list with reasons is the place to excuse the safe ones.
Loading
Loading