Skip to content

feat(roadmap): wire sandboxed run tool into stage toolbox and prompt #4098

Not planned

Description

@dan-petty

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:

  1. Expose run_command in src/devops_cli/roadmap/stage/stage_tools.py when toolset is extended.
  2. Validate the command path against check_command from stage_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.
  3. Launch the command inside the isolated Job via src/devops_cli/k8s/cluster_job_api.py using the template from feat(k8s): manifest and admission policy for planner sandboxed run job #4003.
  4. Mask and truncate the output via mask_and_truncate_output from feat(roadmap): output truncation and secret masking for planner run tool #4006.
  5. Update src/devops_cli/ai/tasks/roadmap_stage_change.md to instruct the model to call run_command when 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

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 StageTools for each of base, extended and research and reads its tool names.
  • THEN The extended and research names hold run_command, and the base names 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_names for stage, stage-extended and stage-research.
  • THEN The stage-extended and stage-research lists hold run_command, the stage list does not, and the run_command entry holds read_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_command with devops scan sast and a double of check_command returns a refusal.
  • THEN The answer holds the refusal text and scan sast, and the test observes no call to ClusterJobs.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_command with devops gh labels list --repo owner/name, a double of check_command permits it, and a double of ClusterJobs.list_jobs returns RUNNING and then Complete.
  • THEN ClusterJobs.create is called once with PLANNER_TEMPLATE and the args gh labels list --repo owner/name, list_jobs is called until the Job leaves RUNNING, 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 1 and the text that cap_run_output returns.

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 SIGKILL and 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.create raise ClusterJobError.
  • 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.md and src/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_command among the tools that extended adds, 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?: The extended and research toolsets expose run_command; base omits it. research adds search_web to the tools of extended, 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_command join the tool registry?: The run_command entry of TOOLS in src/devops_cli/roadmap/tools.py names the holders stage-extended and stage-research. It keeps read_only false. (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_command of src/devops_cli/roadmap/stage/stage_run_allowlist.py decides. It builds its entries from the read-only rows of CONST_MCP_EXPOSURE_TABLE and 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.create makes from PLANNER_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 leading devops word, and gives the rest as the command path and its options to check_command and as the container args to ClusterJobs.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_jobs by the Job label until the Job leaves RUNNING, within the 120 s activeDeadlineSeconds of 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_status does. 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_output of src/devops_cli/roadmap/run_output.py masks with mask_secrets and cuts to 8192 bytes and 120 lines with a counted trailer. No function named mask_and_truncate_output exists 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.md and the extended tool instructions src/devops_cli/ai/tasks/roadmap_stage_tools_extended.md carry the prompt change. docs/ENV_VARS.md, docs/roadmap/stage.md, CONTEXT.md and the stage row of docs/CLUSTER.md carry 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.md rule 6?: No. ADR 0018 gives the rule edit to feat(roadmap): run the implement agent shell in a real sandbox #2695. The change leaves SECURITY.md unchanged. (best practice) [sources: docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md, SECURITY.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#3242, #4003, #4004, #4006, #4007, #6521

Activity

  1. added
    source/agent
    type/feature
    scope/roadmap
    status/new
    value/high
    effort/low
    on Nov 8, 2026
  2. dan-petty commented on Nov 8, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. It is an integration step that depends on four open issues and stops false-premise plan defects, but it is not a project blocker.
    • Value: High. Wiring the run tool into the planner stops the largest class of plan defects, which caused 8 of 48 findings.
    • Effort: Low. The body states a cost of 8,000 tokens and 0.5 elapsed days, which is a small wiring task.
    • Related: feat(roadmap): the stage job plans with a read-only investigation toolbox #3037, which asks for a different change. 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.
  3. added
    priority/p2-medium
    on Nov 8, 2026
  4. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    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.

  5. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

    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 HostSandbox and 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's seccompProfile: RuntimeDefault, no bwrap binary 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)

    • License: NOASSERTION
    • Last activity: 2026-10-14
    • Maintained: yes

    Covers:

    • Runs one command under a sandbox with a read-only bind of the repository
    • Gives the command a private /tmp and a cleared environment
    • Kills the process group when the output cap is reached
    • Is an open, actively maintained project

    Lacks:

    • Not wired into stage_tools.py, so the stage planner never sees a run_command tool
    • No allow-list check such as check_command, and no refusal reason returned as text
    • No report of the exit code or of the signal that ended a run
    • No masking and truncation of the output before it reaches the model
    • No stage-prompt instruction to run a command and quote the result under ## Feasibility
    • ADR 0018 rejected it for this use: no user namespace under the pod profile, no bwrap binary in the runner image, and a run must happen in an isolated Job rather than in the Service process

    Tools considered:

    Searches run:

    • kubernetes-sigs agent-sandbox sandboxed execution for AI agents, results: 5
    • sandboxed read-only command execution tool for LLM agent planner, results: 5
    • E2B code interpreter sandbox open source run commands in isolated sandbox, results: 5
    • "agent-sandbox" kubernetes SIGs Sandbox custom resource controller, results: 5
    • OpenSandbox Alibaba container sandbox for coding agents, results: 5
    • github kubernetes-sigs agent-sandbox repository, results: 5
    • kubernetes agent sandbox warm pool claims pod template, results: 5
    • bubblewrap bwrap sandbox, results: 5

    Sources:

    Checked on 2026-11-10. A person decides what this means for the item. The check changes no label and closes no issue.

  6. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    The command gate plan (tracker #5199) changes the scope of this item.

    stage_run_allowlist.py has no caller, and this item plans its own check. The shared gate replaces that check.

    New scope:

    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.

  7. dan-petty commented on Nov 15, 2026

    @dan-petty
    OwnerAuthor

    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.judge with the profile stage_run and leaves SECURITY.md rule 6 to #2695, so the tool cannot ship before the gate and the rule edit exist. Wire it after #2695 and #5206 merge.

  8. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    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.

  9. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    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.

  10. dan-petty commented on Nov 20, 2026

    @dan-petty
    OwnerAuthor

    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.

  11. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor

    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.

  12. dan-petty commented on Nov 30, 2026

    @dan-petty
    OwnerAuthor

    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.

  13. removed
    status/new
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/roadmapsource/agenttype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions