Repository navigation
Description
Problem
The implement step shell cannot call devops ai rag-query or devops review, because the shell has no gateway key. A key in the shell would undo #2667: the job process holds the key and is not dumpable, so the shell cannot read it. #3563 proposed a Caddy broker, which cannot work: execve sets the dumpable flag to 1 again, and the shell has the same user as the broker, so it could read /proc/<pid>/environ.
Expected
A loopback proxy that runs inside the job process (already non-dumpable, already holds the key) forwards only an exact allowlist of method and path pairs to the gateway. A per-step token dies with the step. The shell receives the proxy address and the token, never the gateway key.
Acceptance criteria
- A test: a request with the step token to an allowed method and path reaches the recorded gateway.
- A test: a request to any other path or method, or with another token, is refused.
- A test: the token stops working when the step ends.
- A test: the environment and arguments of the shell hold no gateway key.
- The change names the allowed paths and says how a shell call counts against the step budget and tier accounting.
/chat/completionsand/embeddingsare the same endpoints as the model of the agent, so the decision is part of this item.
Existing tool considered
The project already depends on fastapi, uvicorn and httpx2 (pyproject.toml). Use them for the proxy. No new binary, no Caddy in the runner image.
Related
Split from #3563 (comment of 2026-11-06). Related: #3041, #2667. Items B and C of the same split give rag-query and devops review their other needs.
Proposed design
Problem statement
The implement step shell cannot call devops ai rag-query or devops review because it has no gateway key. A key in the shell would expose it, and a Caddy broker cannot protect it. The item adds a loopback broker inside the job process. The broker holds the key, forwards only two exact gateway endpoints, and gives each step a token that dies with the step.
Acceptance criteria
Requirement: Loopback-only broker
The broker MUST bind only to the loopback interface.
Scenario: Non-loopback address is refused
- WHEN The job process configures the broker with an address that is not a loopback address.
- THEN The broker refuses to start and reports the invalid address.
Requirement: Allowed request reaches gateway
The broker SHALL forward an allowed request from a step to the recorded gateway.
Scenario: Allowed request
- WHEN A step sends
POST /chat/completionswith its step token to the broker address. - THEN The broker sends the request to the recorded gateway with the gateway key and returns the gateway response to the step.
Requirement: Exact method and path allowlist
The broker MUST forward only the exact method and path pairs POST /chat/completions and POST /embeddings.
Scenario: Other path or method
- WHEN A step sends a request to another path, or sends a method other than POST to an allowed path, with a valid step token.
- THEN The broker returns a refusal and sends no request to the gateway.
Requirement: Step token required
The broker MUST refuse a request that does not carry the current step token.
Scenario: Wrong token
- WHEN A step sends a request to an allowed path with a token other than the current step token.
- THEN The broker returns a refusal and sends no request to the gateway.
Requirement: Token dies with the step
The broker MUST reject the step token after the step ends.
Scenario: Token after step end
- WHEN The step has ended and a request uses the token that the step held.
- THEN The broker returns a refusal and sends no request to the gateway.
Requirement: No gateway key in shell
The job process MUST NOT put the gateway key in the environment or arguments of the step shell.
Scenario: Shell environment and arguments
- WHEN The job process starts a step shell.
- THEN The environment and arguments of the shell hold the broker address and the step token, and hold no gateway key.
Requirement: Shell call accounting
A shell request through the broker SHALL count against the step budget and tier accounting as a model call of the agent.
Scenario: Budget and tier record
- WHEN A shell call through the broker returns a gateway response with usage.
- THEN The step budget and the tier accounting record the call with the same usage and tier as a model call of the agent.
Existing Tool Considered
No alternatives check has run. The project already depends on fastapi==0.142.2, uvicorn==0.53.0 and httpx2==2.13.1 (pyproject.toml). These open, maintained libraries cover the loopback server and the upstream client. They lack a per-step token and an exact method and path allowlist. The change adds a small broker module of about 150 lines and 7 tests. Its estimated build cost is 8,000 tokens and 2 hours. Keep cost is low because the libraries carry the HTTP work. No new binary and no Caddy.
Key questions
- Which exact method and path pairs does the broker allow?: Allow only
POST /chat/completionsandPOST /embeddings. These are the gateway endpoints thatdevops ai rag-queryanddevops reviewneed. (best practice) [sources: tests/ai/client/test_ai_client_providers_and_embeddings.py, tests/ai/rag/test_embedding_providers.py]- Chosen:
POST /chat/completionsandPOST /embeddings. The item names these two endpoints, and they are the model endpoints of the agent. - Rejected: A prefix such as
/v1/*. A prefix lets the shell reach unrelated gateway routes. - Rejected: Only
POST /chat/completions.devops ai rag-queryneeds embeddings.
- Chosen:
- How does a shell call count against the step budget and tier accounting?: Count it as a model call of the agent. Use the gateway response usage and the same tier as the agent's model call. (best practice) [sources: CONTEXT.md, tests/ai/client/test_ai_client_telemetry.py]
- Chosen: Same as an agent model call. The endpoints are the same, so one budget and one tier record avoid double counting or hidden spend.
- Rejected: A separate tool budget. It splits one cost across two records and hides spend from the step budget.
- Rejected: No accounting. It lets shell calls spend without a budget or tier record.
- How does the shell receive the broker address and the step token?: Set the broker URL and the per-step token as environment variables for the step shell. Keep the gateway key in job-process memory only. (best practice) [sources: CONTEXT.md, src/devops_cli/roadmap/implement/implement_shell_policy.py]
- Chosen: Environment variables. The shell can read them, and they die with the step process.
- Rejected: Command-line arguments. Arguments are visible in process listings and can leak the token.
- Rejected: A file in the worktree. The file can persist after the step and can be read by later steps.
- How does the broker revoke the step token?: Create a random token per step, keep it in job-process memory, and delete it when the step ends. The broker accepts only the live token. (best practice) [sources: src/devops_cli/roadmap/implement/implement_shell_policy.py, CONTEXT.md]
- Chosen: In-memory per-step token deleted at teardown. It dies with the step and leaves no file or process to read later.
- Rejected: A token in a file deleted at teardown. A crash can leave the file behind.
- Rejected: A long-lived token. It outlives the step and breaks the per-step limit.
- Which libraries run the loopback server and send the upstream request?: Use FastAPI and uvicorn for the loopback server and httpx2 for the upstream request. The project already depends on them. (best practice) [sources: pyproject.toml, src/devops_cli/server/app.py, src/devops_cli/ai/mcp/remote.py]
- Chosen: FastAPI, uvicorn and httpx2. The project already depends on them, and they cover the server and client.
- Rejected: A Caddy sidecar.
execvesets the dumpable flag, and the shell shares the user, so it can read/proc/<pid>/environ. - Rejected: A new socket server. It adds code and tests that the existing libraries already cover.
- Where does the broker listen?: Bind
127.0.0.1on an ephemeral port in the job process. Reject any bind on a non-loopback address. (best practice) [sources: CONTEXT.md, src/devops_cli/server/app.py]- Chosen: Loopback ephemeral port. Only the step on the same pod can reach it, and the port needs no fixed allocation.
- Rejected: A Unix domain socket. The item asks for a loopback proxy, and HTTP clients expect a URL.
- Rejected: A fixed port on the pod IP. Other pods can reach it, and the port can conflict.
- How does the broker authenticate to the gateway without exposing the key?: The job process reads the gateway key into memory. The broker adds it to the upstream request and never writes it to the shell. (best practice) [sources: CONTEXT.md, src/devops_cli/roadmap/implement/implement_shell_policy.py]
- Chosen: Job-process memory only. The job process is not dumpable, so the shell cannot read the key.
- Rejected: Pass the key to the shell. It undoes feat(k8s): the implement job runs as a cluster Job on a runner image with uv, the dev dependencies and the pinned tools, submitted by the Service #2667 and exposes the key to
/proc/<pid>/environ. - Rejected: Store the key in a file. The shell can read the file and the key outlives the step.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-08: in-use.
The item already names this tool.
Tool: fastapi/fastapi (https://github.com/fastapi/fastapi), MIT, last activity 2026-11-08, maintained.
Activity
dan-petty commentedon Nov 6, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(roadmap)scope of the title gives the scope.It is a planned feature that maintains a security property but is not a regression or active exploit.Without it the implement shell cannot call rag-query or devops review at all.It needs a proxy, an allowlist, a per-step token, and four tests, but reuses fastapi, uvicorn, and httpx already in the project.Both target the implement shell's gateway access; #3563 is the umbrella, and the candidate is the specific loopback-proxy part of that split.devops-cli-service commentedon Nov 7, 2026
Status set to Ready at 8436734 (see proposed design in issue body).
devops-cli-service commentedon Nov 8, 2026
Alternatives check: in-use
Reason: No search turned up a ready-made broker with per-step tokens: the proxy projects found (mitmproxy, proxy.py, LiteLLM proxy) run out of process and bring no step-scoped token, key isolation or budget accounting. The libraries the issue already depends on do cover the generic half of the need — FastAPI/uvicorn serve the loopback endpoint and enforce exact method/path routing, and httpx2 sends the upstream request — so they cover part of it, while the per-step token, its revocation at step end, the gateway-key handling and the budget/tier accounting stay project code.
The item already names this tool.
Tool: fastapi/fastapi (https://github.com/fastapi/fastapi)
Covers:
Lacks:
Tools considered:
Searches run:
Sources:
Checked on 2026-11-08. A person decides what this means for the item. The check changes no label and closes no issue.
45 remaining items
feat(roadmap): Give the shell of a step the broker address and its to…
feat(roadmap): Run the broker for the length of a step (#3820)
feat(roadmap): Count a shell call in the budget and the tier record (#…
feat(roadmap): Document the broker of a step (#3820)
docs(openspec): archive the change (#3820)
feat(roadmap): Make check Tests & Coverage (shard 4 of 4) pass (#3820)
feat(roadmap): Make check Static Analysis pass (#3820)
devops-cli-service commentedon Nov 17, 2026
The runner Job devops-cli-implement-devops-cli-3820-6bd3f1 ended: succeeded.
Image digest: sha256:47b191971ac0f40357ab821d8b13fa5ae022b11beccd42ea859f629c94751c51
The last lines of its log:
devops-cli-service commentedon Nov 18, 2026
Released in v0.175.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.175.0
devops-cli-service commentedon Nov 18, 2026
Live since 2026-11-18 06:26 UTC