Skip to content

feat(roadmap): track the shared command gate #5199

Not planned
8 of 8 issues completed
Not planned

Description

@dan-petty

Problem or Motivation

The implement Job checks each shell command that a model writes. The check reads only the first word against a program allowlist and finds operators as plain text. In 7 days (Loki, namespace devops, container runner, 2026-11-05..12), it refused 175 of 2,526 shell calls (6.9 %). 78 % of these refusals were of allowlisted programs. 127 of the 175 refusals come from syntax only: a quoted ;, && chains and pipes into cat or sort. All 13 halts on 3 refusals in a row came from two of these shapes. The check also lets dangerous commands through, because uv and git take any arguments. All lists are code constants. No setting changes them, and no repository has its own list.

The owner asked for a configured allowlist and blocklist, with a one-line reason for each entry, and for Jev to judge the commands that no list decides.

Proposed Solution & Architectural Design

One shared gate in the new package src/devops_cli/roadmap/command_gate/ decides each command that a model writes. Three tiers run in a fixed order, and the strictest result wins (the Codex rules design: "the most restrictive decision wins").

  1. Parse. This tier is deterministic and fails closed. tree-sitter-bash splits the text into simple commands. The tier refuses each form that tree-sitter and dash can read differently: comments, a backslash-newline outside a quoted heredoc, substitutions, a background &, bash-only forms, invisible Unicode characters, and non-ASCII text outside quoted text. It normalizes path words, expands globs, and refuses a write redirect to a target outside the checkout, /tmp and the scratch HOME.
  2. Lists. This tier is deterministic. Argument models for git, uv run, env prefixes, sed and awk make a canonical argv. The blocklist and then the allowlist match it. Each entry has an id, a pattern, a one-line reason, an optional instead text, and match and not_match examples that the load checks. The defaults are package data. Settings add entries, globally and for each repository. The gate never reads a list from the target repository. An indirect executor (make, npm, tox, python <file> and similar) with no allow entry is refused.
  3. Jev, for the rest. One fixed question: "Is this command dangerous, given ?". Jev gets facts only: the canonical argv with typed placeholders, path classes, hosts, the environment facts, and the nearest entries of both lists. The default is allow. Jev refuses only at or above a cut that the eval fits on labelled cases. The tier starts in mode shadow.

The gate is a filter for accidents and for usability. It is not a security boundary. The pod and the egress limits carry the security weight. ADR 0026 and SECURITY.md say this.

Gate flow, in short:

  1. Remove the exact prefix cd <checkout> &&, and force the tool timeout.
  2. Refuse text over 2,000 characters, invisible characters, and non-ASCII words.
  3. Parse. Refuse a parse error, a comment and a line continuation.
  4. Grammar check. Refuse substitutions, background forms, compound forms, bash-only forms, a program word with /, env names off the allowlist, opaque executors, interactive programs, more than 8 simple commands, and opaque blobs.
  5. Normalize words and paths. Give each path a class: checkout, tmp, scratch_home, git_internal, secret or outside. Refuse a write redirect to a target outside.
  6. Unwrap the known wrappers: uv run, env, timeout, nice, and sh -c '<literal>'.
  7. The argument models make the canonical argv.
  8. Blocklist: one match refuses the command. The text gives the entry reason and the instead text.
  9. Allowlist: when every simple command matches an allow entry, the command runs. In mode shadow, 5 % of these commands also go to Jev under a separate audit point. The verdict does not change.
  10. An indirect executor with no allow entry is refused. It never goes to Jev.
  11. Rest, mode off: refuse, and name the 3 nearest allowed forms.
  12. Rest, modes shadow and on: sticky refusals, a budget of 5 Jev refusals for each Job, a breaker, and a cache for the run. Then one Jev request for each rest part, at most 3.
  13. Mode shadow records the band and refuses as mode off does. Mode on runs the command when every part is in band continue. Each failure falls back to mode off.
  14. The harness Shell runs the command with its own lists empty.
  15. Each decision adds one count and writes one log line with no argument word.
  16. A person labels a sample of the commands that ran on a Jev verdict.

Owner decisions (2026-11-12)

  1. The owner's model. A configured allowlist and blocklist decide first. Jev judges the rest with a default of allow, and it reads the blocklist entries as the examples of dangerous. When Jev cannot answer, the command falls back to today's behavior: the gate refuses it, and the text says "not judged".
  2. Accepted: the list decisions. Inline Python (uv run python -c and quoted heredocs) goes on the allowlist, because it has the same power as an allowed script file. This removes 77 of the 175 refusals and all 13 halts. These are floor block entries, and only the owner can remove one: git push, git config writes, git remote changes, git options that start a program or write a file, secret paths, and writes outside the checkout.
  3. Accepted: kept command text. Runner Jobs keep the masked text of the commands that the gate refuses or sends to Jev. The limits are 300 characters for each command, 20 commands for each Job, and 14 days. The text goes through mask_secrets and mask_private_hosts first.

Child items, in order

New items:

  1. feat(roadmap): check shell commands with a parser and configured lists #5201 feat(roadmap): check shell commands with a parser and configured lists
  2. feat(roadmap): build the command gate facts from the manifests and a probe #5203 feat(roadmap): build the command gate facts from the manifests and a probe
  3. refactor(roadmap): judge plan verify commands with the shared command gate #5204 refactor(roadmap): judge plan verify commands with the shared command gate
  4. feat(roadmap): ask Jev if a command off the lists is dangerous, in shadow #5206 feat(roadmap): ask Jev if a command off the lists is dangerous, in shadow
  5. feat(roadmap): score the command gate on labelled commands and fit its cut #5207 feat(roadmap): score the command gate on labelled commands and fit its cut
  6. feat(roadmap): report the live shadow bar of the command gate from Loki #5208 feat(roadmap): report the live shadow bar of the command gate from Loki

Updates of existing items (a comment on each item gives the new scope):

  1. feat(roadmap): count tool call errors by class for each workflow #5179: count the command gate refusals by source. After feat(roadmap): ask Jev if a command off the lists is dangerous, in shadow #5206.
  2. feat(roadmap): rank refused tool calls and propose safe tool changes #5180: rank gate refusals and Jev answers into list proposals. After feat(roadmap): count tool call errors by class for each workflow #5179 and feat(roadmap): ask Jev if a command off the lists is dangerous, in shadow #5206.
  3. feat(roadmap): an implement refusal halt gets one repair turn #4859: measure refusal halts again 7 days after feat(roadmap): check shell commands with a parser and configured lists #5201 deploys, then close or narrow it.
  4. feat(roadmap): wire sandboxed run tool into stage toolbox and prompt #4098: run the stage run tool through the shared gate with profile stage_run. After feat(roadmap): ask Jev if a command off the lists is dangerous, in shadow #5206.
  5. feat(roadmap): track job grades for each agentic workflow #5164: add the gate refusal rate and the over-blocking cost to the job grades. After feat(roadmap): count tool call errors by class for each workflow #5179.
  6. feat(roadmap): run the implement agent shell in a real sandbox #2695: limit the public HTTPS egress of the runner Job to named hosts. This waits for open question 3.

Fixes that the design found:

  1. fix(ai): set the Jev context window from the model data #5209 fix(ai): set the Jev context window from the model data
  2. fix(telemetry): runner Job counters keep their first count in increase() #5210 fix(telemetry): runner Job counters keep their first count in increase()

The first item waits for a private security fix (owner).

Open questions for the owner

  1. The bar for mode on. The proposed bar: 0 critical misses; 0 misses on at least 100 held-out dangerous rest cases, which bounds the miss rate below 3 % with 95 % confidence; no phrasing of any dangerous act runs; false refusal on held-out safe rest cases at most 0.10; and at least 30 would-run shadow commands with 0 dangerous. A 2 % bound needs about 150 held-out cases (about 300 dangerous cases in the set). The bar is a threshold, so only the owner can set or lower it.
  2. Labels. Who labels the eval cases and the shadow sample? Option 1: an agent proposes each label, and a person confirms it in the pull request review. Option 2: a person labels each case.
  3. Egress. Does the owner accept the host allowlist for the public HTTPS egress of the runner, through an Envoy forward proxy (the update of feat(roadmap): run the implement agent shell in a real sandbox #2695)? It changes the network of every runner Job. A host that is missing from the list makes a Job fail until the list gets that host.

Target Subsystem

SDLC, Git & PR Governance (src/devops_cli/roadmap/, the implement runner) and Security & Vulnerability Scanners (the command gate lists).

Existing Tool Considered

  • tree-sitter-bash 0.25.1 (a dependency, pyproject.toml:66) for the parse.
  • The Codex rules design (https://learn.chatgpt.com/docs/agent-configuration/rules) for the entry shape: match and not_match examples that the load checks.
  • The project's DecisionPoint, ResolverChain and decision_fit (ADR 0020) for the modes, the records and the fitted cut, and pybreaker (a dependency) for the breaker.
  • Not used: ToolCallJudge can only block. The pydantic-ai-harness ApprovalReviewer approves on an argmax 'no' with no fitted cut, no shadow mode and no record. sh-guard and bashlex are GPLv3, AgentTrust is AGPL, and SecureShell is unmaintained.
  • The build covers only the matcher, the parse walker, the word normalization, the argument models, the nearest-entry selection and the facts builder: about 930 lines in total. Each child item gives its cost.

Acceptance Criteria

  1. Each new child item is closed.
  2. Each updated item states the new scope, or it is closed with the evidence.
  3. The mode of implement.command_gate is on only after the owner accepts the bar and the measurement meets it.

Related

Source: #5164

Dependencies

Alternatives check of 2026-11-28: in-use.
The repository already uses this tool.
Tool: tree-sitter/tree-sitter-bash (https://github.com/tree-sitter/tree-sitter-bash), MIT, last activity 2026-09-13, maintained.
Reason: Searches found no open, maintained library that parses shell commands and applies configured allow and block lists with a fitted judge. tree-sitter-bash, already a project dependency, covers only the deterministic parse tier of the gate.

Covers:

  • Parses bash text into a syntax tree of simple commands
  • Reports parse errors and the shape of chains, pipes and redirects
  • MIT grammar with Python bindings, usable as package data input

Lacks:

  • No allowlist or blocklist with reasons and match examples
  • No canonical argv, path classes or redirect target checks
  • No model judge, shadow mode, fitted cut or decision record
  • No settings for global or per-repository list entries

Sub-issues

Sub-issues

8 of 8 Issues completed
Loading 8 sub-issues

Activity

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

    @dan-petty
    OwnerAuthor
  4. added
    priority/p2-medium
    on Nov 12, 2026
  5. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (10)

    Tools considered:

    Searches run:

    • open source shell command allowlist blocklist policy gate for AI agent shell calls, results: 5
    • library parse bash command and decide allow or deny with reasons policy, results: 5
    • github "shell command" guard allowlist deny deny deny tool for LLM agents, results: 5
    • bashlex shell command parser allowlist deny list python tool, results: 5
    • sh-guard bash command allowlist GitHub project, results: 5
    • sandbox-runtime anthropic command filtering deny list, results: 5
    • policy engine to allow or block shell commands with reasons YAML config, results: 5
    • bashlex, results: 5
    • shellharden github, results: 5
    • sh-guard github, results: 5

    Sources:

  6. 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.

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

  8. 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/highpriority/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