Repository navigation
Description
Problem or Motivation
The roadmap stage planner reads files and runs no command. ADR 0018 (docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md, #3242) designs a sandboxed read-only run tool to stop false-premise plan defects. Issues #4003, #4004, #4006, and #4007 add the Job manifest, allow-list, sanitizer, and proof tests. No issue connects this tool to the stage planner toolbox in src/devops_cli/roadmap/stage/stage_tools.py or to the planner prompt in src/devops_cli/ai/tasks/roadmap_stage_change.md.
Proposed Solution & Architectural Design
Add the run_command tool to the stage planner toolbox and prompt:
- Expose
run_commandinsrc/devops_cli/roadmap/stage/stage_tools.pywhentoolsetisextended. - Validate the command path against
check_commandfromstage_run_allowlist.py(feat(roadmap): allow-list builder for planner read-only commands #4004). Return the refusal reason as plain text when the command is not permitted. - Launch the command inside the isolated Job via
src/devops_cli/k8s/cluster_job_api.pyusing the template from feat(k8s): manifest and admission policy for planner sandboxed run job #4003. - Mask and truncate the output via
mask_and_truncate_outputfrom feat(roadmap): output truncation and secret masking for planner run tool #4006. - Update
src/devops_cli/ai/tasks/roadmap_stage_change.mdto instruct the model to callrun_commandwhen verifying premises or set counts, and quote the result in## Feasibility.
Depends on: #3242, #4003, #4004, #4006, #4007.
Target Subsystem
AI & Agentic Review Pipeline
Existing Tool Considered
The tool builds on Kubernetes Job execution in src/devops_cli/k8s/cluster_job_api.py and the existing stage toolbox. Cost: 8,000 tokens and 0.5 elapsed days.
Dependencies
- chore(roadmap): hold incremental stage and implement work #6521 (hold: incremental work on the stage, implement and fix-checks jobs waits for the re-architecture)
Alternatives check of 2026-11-25: rejected.
Rejected by ADR 0018. A newer fact can change an ADR.
Tool: containers/bubblewrap (https://github.com/containers/bubblewrap), NOASSERTION, last activity 2026-11-24, maintained.
Reason: Searches found only generic sandbox runners (bubblewrap, nsjail, gVisor, agent-sandbox); bubblewrap wraps one command read-only, but ADR 0018 rejects it, and none wire a run tool into the stage toolbox or prompt.
Covers:
- Read-only bind of the repository with a private /tmp
- Cleared environment and process-group kill at the cap
- One command wrapped, with no shell
Lacks:
- No Job isolation; the pod profile refuses user namespaces
- No allow-list check before a command runs
- No secret masking or 8 KiB output truncation
- No stage toolbox or planner prompt wiring
Proposed design
Problem statement
The stage planner reads files and runs no command. A plan can rest on a premise that only a run shows. This change wires the ADR 0018 sandboxed run tool into the stage toolbox and prompt.
Acceptance criteria
Requirement: The stage toolbox exposes the run tool
The stage toolbox SHALL expose run_command in the extended and research toolsets and MUST omit it from the base toolset.
Scenario: The three toolsets differ by the run tool
- WHEN A test builds
StageToolsfor each ofbase,extendedandresearchand reads its tool names. - THEN The
extendedandresearchnames holdrun_command, and thebasenames do not.
Requirement: The registry names the stage holders
The run_command entry of TOOLS in src/devops_cli/roadmap/tools.py SHALL name the holders stage-extended and stage-research and MUST keep read_only false.
Scenario: The registry gives the run tool to the stage holders
- WHEN A test reads
tool_namesforstage,stage-extendedandstage-research. - THEN The
stage-extendedandstage-researchlists holdrun_command, thestagelist does not, and therun_commandentry holdsread_only=False.
Requirement: The allow-list refuses a command
The run tool MUST call check_command of stage_run_allowlist.py with the command path and options before it creates a Job, and SHALL return a refusal as text.
Scenario: The allow-list refuses a command
- WHEN A test calls
run_commandwithdevops scan sastand a double ofcheck_commandreturns a refusal. - THEN The answer holds the refusal text and
scan sast, and the test observes no call toClusterJobs.create.
Requirement: A permitted command runs in one Job
The run tool SHALL create one Job from PLANNER_TEMPLATE through ClusterJobs.create for a permitted command, and MUST wait until the Job leaves RUNNING within 120 s.
Scenario: A read-only devops command reaches Complete
- WHEN A test calls
run_commandwithdevops gh labels list --repo owner/name, a double ofcheck_commandpermits it, and a double ofClusterJobs.list_jobsreturnsRUNNINGand thenComplete. - THEN
ClusterJobs.createis called once withPLANNER_TEMPLATEand the argsgh labels list --repo owner/name,list_jobsis called until the Job leavesRUNNING, and the tool reads the pod log.
Requirement: The answer holds the command line and the exit code
The run tool SHALL return the command line, the exit code and the capped text of the run.
Scenario: A command fails
- WHEN A test sets the terminated container of the Job pod to exit code 1.
- THEN The answer holds
devops gh labels list --repo owner/name,exit 1and the text thatcap_run_outputreturns.
Requirement: A signal names the signal
The run tool SHALL name the signal in place of the exit code when a signal ends the run.
Scenario: A signal ends the run
- WHEN A test sets the terminated container of the Job pod to signal 9.
- THEN The answer holds
SIGKILLand no exit code.
Requirement: The output is masked and cut
The run tool SHALL pass the log text through cap_run_output of run_output.py before it answers.
Scenario: The log holds a secret and more than 8 KiB
- WHEN A test gives the tool a log that holds a token and more than 8192 bytes of text.
- THEN The answer holds the masked text, a trailer that names the omitted bytes and lines, and no token.
Requirement: A run that the Job cannot hold fails closed
The run tool MUST return the cause as text and run no command when it cannot create the Job.
Scenario: The API refuses the create call
- WHEN A test makes
ClusterJobs.createraiseClusterJobError. - THEN The answer holds the cause and no command runs in the Service process.
Requirement: The prompt asks for a run and a quote
The stage prompt and the extended tool instructions SHALL tell the planner to call run_command and MUST require the quote under ## Feasibility.
Scenario: The prompts name the run tool
- WHEN A test reads
src/devops_cli/ai/tasks/roadmap_stage_change.mdandsrc/devops_cli/ai/tasks/roadmap_stage_tools_extended.md. - THEN Each names
run_command, the stage prompt names the refusal text, and both require the quote under## Feasibility.
Requirement: The documentation lists the run tool
The documentation SHALL name run_command among the tools that extended adds in docs/ENV_VARS.md, docs/roadmap/stage.md, CONTEXT.md and the stage row of docs/CLUSTER.md, and the stage row SHALL state that a plan run creates the run Job.
Scenario: The four documents list the run tool
- WHEN A test reads the environment row, the tool list, the Staging entry and the stage row.
- THEN Each names
run_commandamong the tools thatextendedadds, and the stage row states that a plan run creates the run Job.
Existing Tool Considered
The alternatives block in the issue body gives containers/bubblewrap the verdict rejected by ADR 0018. The block lists what the tool covers and lacks. This change adds the stage toolbox and prompt wiring, the check_command gate, the PLANNER_TEMPLATE Job launch, the exit and signal report, and the cap_run_output mask and cut that the block says the tool lacks. Cost: about 8,000 tokens and 0.5 elapsed days.
Key questions
- Which toolsets expose
run_command?: Theextendedandresearchtoolsets exposerun_command;baseomits it.researchaddssearch_webto the tools ofextended, so one registry row serves both. (best practice) [sources: src/devops_cli/roadmap/stage/stage_tools.py, src/devops_cli/roadmap/tools.py, docs/ENV_VARS.md]- Chosen: extended and research. The issue asks for extended, and research holds the tools of extended plus search_web.
- Rejected: extended only. research would diverge from extended and the model would lose the run tool in research.
- Rejected: new sandboxed toolset. It adds a setting, a default, a document row and a test, and the allow-list and Job caps already guard the tool.
- Where does
run_commandjoin the tool registry?: Therun_commandentry ofTOOLSinsrc/devops_cli/roadmap/tools.pynames the holdersstage-extendedandstage-research. It keepsread_onlyfalse. (best practice) [sources: src/devops_cli/roadmap/tools.py, src/devops_cli/roadmap/stage/stage_tools.py, tests/roadmap/test_roadmap_tools.py]- Chosen: Add stage-extended and stage-research holders. StageTools reads tool_names of the holder, and the two toolsets need the tool.
- Rejected: Add only stage-extended. research would diverge from extended.
- Rejected: Mark run_command read-only. The tool runs a program, so the registry must not mark it read-only.
- Which gate decides whether a command may run?:
check_commandofsrc/devops_cli/roadmap/stage/stage_run_allowlist.pydecides. It builds its entries from the read-only rows ofCONST_MCP_EXPOSURE_TABLEand refuses a command that the table does not name. [sources: src/devops_cli/roadmap/stage/stage_run_allowlist.py, src/devops_cli/config/constants.py:306, docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md, tests/roadmap/stage/test_stage_run_allowlist.py] - Where does a run happen?: A run happens in one Job that
ClusterJobs.createmakes fromPLANNER_TEMPLATE. The tool fails closed with the cause when the create fails. (best practice) [sources: src/devops_cli/k8s/cluster_job.py:75, src/devops_cli/k8s/cluster_job_api.py:187, k8s/devops/roadmap-service/cronjob-planner-run.yaml, docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md]- Chosen: One Job from PLANNER_TEMPLATE through ClusterJobs. ADR 0018 places the seven controls in the Job pod, and the template and admission rules already exist.
- Rejected: The Service process. That process holds the token, home, network and credentials that the seven controls close.
- Rejected: The planner process. The planner is a model loop with read-only tools and has no process of its own.
- What form does the command line take?: One string. The tool splits it with
shlex.split, drops a leadingdevopsword, and gives the rest as the command path and its options tocheck_commandand as the container args toClusterJobs.create. No shell runs. (best practice) [sources: docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md, src/devops_cli/config/constants.py:306, tests/k8s/test_k8s_cluster_job_api.py]- Chosen: One string split by shlex.split, with a leading devops dropped. The model writes one line, the exposure rows are command paths without devops, and the container args are the words after the image entrypoint.
- Rejected: A list of strings. The model can send a malformed list, and a plan quotes the string form.
- Rejected: A string that runs in a shell. A shell adds a second grammar that the allow-list does not check.
- How does the tool wait for the Job and read its result?: It polls
ClusterJobs.list_jobsby the Job label until the Job leavesRUNNING, within the 120 sactiveDeadlineSecondsof the template. It then reads the pod log and the terminated container state. (best practice) [sources: src/devops_cli/k8s/cluster_job_api.py:187, k8s/devops/roadmap-service/cronjob-planner-run.yaml, docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md]- Chosen: Poll list_jobs by label. The API lists Jobs by label, and the deadline of the template bounds the wait.
- Rejected: Read the log until it ends. An ended log does not show that the Job ended.
- Rejected: Watch the Job. A watch adds a second client and a reconnect path for one capped wait.
- How does the tool report the exit code and the signal?: It reads the terminated container state of the Job pod, as
ClusterJobs.exit_statusdoes. A run that a signal ends names the signal and gives no exit code. (best practice) [sources: src/devops_cli/k8s/cluster_job_api.py:187, docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md]- Chosen: Read the terminated container state. The API holds the exact exit code and the signal.
- Rejected: Parse the log for a marker. A command controls its own output, so a marker can lie.
- Rejected: Write the exit code to a file. The clone is read-only, and a second volume adds a handoff.
- Which function caps and masks the output?:
cap_run_outputofsrc/devops_cli/roadmap/run_output.pymasks withmask_secretsand cuts to 8192 bytes and 120 lines with a counted trailer. No function namedmask_and_truncate_outputexists in the tree. [sources: src/devops_cli/roadmap/run_output.py, openspec/specs/roadmap-run-output/spec.md, src/devops_cli/security/sanitizer.py] - Which files carry the prompt and documentation changes?: The stage prompt
src/devops_cli/ai/tasks/roadmap_stage_change.mdand the extended tool instructionssrc/devops_cli/ai/tasks/roadmap_stage_tools_extended.mdcarry the prompt change.docs/ENV_VARS.md,docs/roadmap/stage.md,CONTEXT.mdand the stage row ofdocs/CLUSTER.mdcarry the documentation change. [sources: src/devops_cli/ai/tasks/roadmap_stage_change.md, src/devops_cli/ai/tasks/roadmap_stage_tools_extended.md, docs/ENV_VARS.md, docs/roadmap/stage.md, CONTEXT.md, docs/CLUSTER.md] - Does this change edit
SECURITY.mdrule 6?: No. ADR 0018 gives the rule edit to feat(roadmap): run the implement agent shell in a real sandbox #2695. The change leavesSECURITY.mdunchanged. (best practice) [sources: docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md, SECURITY.md]- Chosen: Wait for feat(roadmap): run the implement agent shell in a real sandbox #2695. ADR 0018 names feat(roadmap): run the implement agent shell in a real sandbox #2695 as the owner of the rule edit, and two items must not change one rule.
- Rejected: Edit rule 6 here. It takes the edit from the item that the ADR names.
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 8, 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 an integration step that depends on four open issues and stops false-premise plan defects, but it is not a project blocker.Wiring the run tool into the planner stops the largest class of plan defects, which caused 8 of 48 findings.The body states a cost of 8,000 tokens and 0.5 elapsed days, which is a small wiring task.Both add tools to the stage planner toolbox, but #3037 delivers read-only file and grep tools while the candidate delivers the sandboxed run_command tool and its prompt instruction.devops-cli-service commentedon Nov 8, 2026
Refine cannot set this item to Ready at c56f784 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.
The next refine round also looks at the item again when a commit on the default branch changes one of these files:
SECURITY.md.devops-cli-service commentedon Nov 9, 2026
Refine cannot set this item to Ready at 681529b while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.
devops-cli-service commentedon Nov 10, 2026
Alternatives check: rejected
Reason: The searches surfaced no ready-made planner run tool; the closest existing sandbox is bubblewrap, which the repository already wraps in
HostSandboxand which covers read-only command execution with a private/tmp, a cleared environment and an output cap, so it covers part of the need. ADR 0018, however, rejects it for this use (owner decision of 2026-10-30, no user namespace under the pod'sseccompProfile: RuntimeDefault, nobwrapbinary in the runner image), and the allow-list check, exit-code/signal reporting, masking/truncation and the stage toolbox and prompt wiring stay repository work.Rejected by ADR 0018. A newer fact can change an ADR.
Tool: containers/bubblewrap (https://github.com/containers/bubblewrap)
Covers:
/tmpand a cleared environmentLacks:
stage_tools.py, so the stage planner never sees arun_commandtoolcheck_command, and no refusal reason returned as text## Feasibilitybwrapbinary in the runner image, and a run must happen in an isolated Job rather than in the Service processTools considered:
Searches run:
Sources:
Checked on 2026-11-10. A person decides what this means for the item. The check changes no label and closes no issue.
dan-petty commentedon Nov 12, 2026
The command gate plan (tracker #5199) changes the scope of this item.
stage_run_allowlist.pyhas no caller, and this item plans its own check. The shared gate replaces that check.New scope:
gate.judgewith the profilestage_run(the shared gate of feat(roadmap): check shell commands with a parser and configured lists #5201).CONST_MCP_EXPOSURE_TABLE, and the floor block entries apply.stage.run_gate, starts in shadow after its own eval (the pattern of feat(roadmap): score the command gate on labelled commands and fit its cut #5207). The planner process calls Jev, because the run Job has no egress.environment_facts.json, profilestage_run(feat(roadmap): build the command gate facts from the manifests and a probe #5203).Acceptance to add: the tests assert that a read-only devops command runs and that a path option is refused with source
block.Dependencies: #5206.
devops-cli-service commentedon Nov 14, 2026
Refine cannot set this item to Ready at 9de03b4 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.
dan-petty commentedon Nov 15, 2026
Returned: the item stays blocked. #4003 and #4006 are merged, but #4007 is still a draft pull request (#5871), and #2695 (a real sandbox for the implement agent shell) and #5206 (ask Jev if a command off the lists is dangerous) are open with no branch. The refined design sets
gate.judgewith the profilestage_runand leavesSECURITY.mdrule 6 to #2695, so the tool cannot ship before the gate and the rule edit exist. Wire it after #2695 and #5206 merge.devops-cli-service commentedon Nov 15, 2026
Refine cannot set this item to Ready at ca62d6a while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.
The next refine round also looks at the item again when a commit on the default branch changes one of these files:
SECURITY.md.devops-cli-service commentedon Nov 16, 2026
Refine cannot set this item to Ready at fccb781 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.
dan-petty commentedon Nov 20, 2026
Frozen on 2026-11-20. The stage, implement and fix-checks jobs grade under 60%, so the owner rule asks for a re-architecture before more fixes inside the current design (tracker #6519). This item is incremental work on those jobs, so its Dependencies section now names #6521 first. Stage and implement leave this item while #6521 is open. When the experiments of #6519 decide, a person closes #6521 (this item can then continue) or closes this item as not planned.
devops-cli-service commentedon Nov 20, 2026
Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.
dan-petty commentedon Nov 30, 2026
Triage under #6519 (owner instruction of 2026-11-30), before the hold #6521 closes. This item adds or extends a gate, refusal, screen, cap, limit, retry, result line, shell allowlist, tool catalog or plan-shape rule of the stage, implement or fix-checks job. #6519 found that 263 of about 900 issues in four weeks added such rules and none replaced the engine. Stage now runs on stock Coder (grade 60 on 30 graded attempts), where the agent reads the repository, runs the checks in its loop and has a real shell; implement follows (#6527). The code paths that this item names have also moved. If the failure class still shows in graded attempts, file a new item from that evidence. Closed as not planned; a person may reopen it.