Skip to content

feat(criteria): opt-in match_on: simple_commands for command_executed - #270

Open
CarlesUIPath wants to merge 3 commits into
mainfrom
feat/match-on-simple-commands
Open

CarlesUIPath wants to merge 3 commits into
mainfrom
feat/match-on-simple-commands

Conversation

@CarlesUIPath

Copy link
Copy Markdown
Collaborator

command_executed / command_not_executed search the raw Bash text, so a grader cannot tell a command that ran from a mention of it (a heredoc body, an echo string, a comment). Suites compensate with long prefix lists and heredoc-skipping regexes (UiPath/skills #5069). This adds an opt-in per-criterion mode that matches each simple command the shell runs.

What it does (src/coder_eval/shell_commands.py, stdlib only, linear time)

  • Drops heredoc bodies and comments. A quoted-delimiter body is dropped whole; an unquoted body keeps its $(...)/backtick contents; a heredoc fed to sh/bash is parsed as a script.
  • Splits on ; && || | & ( ) and newlines with shlex (posix, punctuation_chars). It recurses into $(...), backticks, <(...), sh -c/bash -lc strings, eval and find -exec.
  • Strips leading timeout/sudo/nohup/nice/exec/command/builtin/xargs/stdbuf/time wrappers and shell keywords. Leading assignments and env options stay visible.
  • Each matching simple command counts towards min_count/max_count. exclude_pattern applies per simple command.
  • Falls back to raw matching for PowerShell/cmd calls and for text it cannot split, and says so in the criterion details.
  • Default match_on: command_text is unchanged.

Evidence (replay of 16,936 stored criterion evaluations, 18 nightlies 2026-11-18..25)

  • Default mode equals the current matcher on 16,936/16,936.
  • Opt-in on the voice guards (one-line ^(\S*/)?uip (maestro )?flow debug\b) and 7 other max_count: 0 guards: 0 pass→fail, 21 fail→pass (20 row verdicts). uip-timings.log confirms that no forbidden uip call ran in the flipped voice and insights rows.
  • No crashes on 146,745 stored shell calls. 30 (0.02%) cannot be split and fall back to raw.
  • Unit tests per construct, plus a linear-time test.

Docs: TASK_DEFINITION_GUIDE § command_executed (quotes are resolved, no spanning, python heredocs dropped, loop variables not expanded, counting). Rationale: .claude/notes/contracts.md § Matching on simple commands.

Reviewed with /coder-eval-code-review-wf (8 axes, verify on); its 🟠 and 🟡 findings are fixed in 3df13d2 (heredoc mark out of band, any splitter error falls back to raw, prefixed heredoc-to-shell parsed, one -c detector, linear wrapper stripping). Quality Gate green: 7149 passed, coverage 93.46%.

🤖 Generated with Claude Code

CarlesUIPath and others added 3 commits November 25, 2026 18:11
A pattern can now match each simple command the shell runs instead of the
raw Bash text, so a heredoc body, echo string or comment no longer counts
as running a command. Heredoc bodies dropped (unquoted: substitutions kept;
fed to a shell: parsed), $(...)/backticks/sh -c recursed, leading
timeout/sudo/nohup/nice/exec/command/xargs/find -exec/stdbuf/time wrappers
stripped; assignments and env stay visible. PowerShell/cmd calls and text
that cannot be split fall back to raw matching, noted in the details.
Matches count per simple command. Default behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…c, keeps quoted < > as words, treats unwrapped PowerShell as non-POSIX

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… error falls back to raw

- The heredoc mark is a private-use code point, not `__HEREDOC_<n>__`: a literal
  `__HEREDOC_0__` word in agent text raised IndexError (score 0.0, early stop disarmed)
  or fed a real heredoc body to the wrong command. A text that holds one of the
  splitter's own marks (U+E000-U+E007, U+E0FF) is not split; other private-use code
  points (Codex citation marks) are words.
- Any exception from the splitter falls back to raw matching, logged and named in the
  details (`splitter error <type>`), instead of failing the check.
- A heredoc fed to a shell behind assignments or `env` (`X=1 bash <<EOF`,
  `env -u Y sh -s <<EOF`) is parsed as a script.
- Wrapper and keyword stripping walks an index: it was quadratic in the run length.
- One `-c` detector: command_text normalization uses shell_commands.command_flag_index
  and looks_like_shell (same open `*sh` test as before); simple_commands' allowlist
  gains yash and fish. The non-POSIX name regex is built from NON_POSIX_SHELLS.
- command_pattern / exclude_pattern / match_on descriptions cover simple_commands;
  piped stdin into a shell is documented as not parsed. CE036 cases for simple_commands.

Replay of 16,936 stored evaluations: default match_on unchanged (0 diffs); opt-in set
0 P->F, 21 F->P (as before); crash scan of 146,745 calls: 0 exceptions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Claude finished @CarlesUIPath's task in 1m 14s —— View job


Code Review in Progress

Todo List:

  • Read .github/code_review.md for review standards
  • Read CLAUDE.md for project conventions
  • Review full PR diff (git diff origin/main...HEAD)
  • Read each changed file in full context
  • Perform cross-file consistency checks
  • Check for missing edge cases and documentation
  • Post comprehensive review findings

Starting code review for PR #270: opt-in match_on: simple_commands for command_executed criteria...

@uipreliga uipreliga left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: coder_eval — pr:270 (8 files) axis:1-8

Scope: pr:270 (8 files) axis:1-8 · branch feat/match-on-simple-commands (pr-270) · 3df13d2 · 2026-11-25T20:34Z · workflow variant

Change class: complex — adds a new shell tokenizer/parser (heredocs, substitutions, wrappers) and a new opt-in criterion matching mode that changes grading semantics

PR #270 is a well-contained opt-in feature (it is additive, the default command_text mode does not change, and type safety, architecture and security are strong), but match_on: simple_commands can still pass a max_count: 0 guard for a forbidden command when it falls back to raw text with an anchored pattern, or when it reads 1<<3 arithmetic as a heredoc, and the schema description and guide teach patterns that miss common forms, so fix these score-changing gaps before you merge.

Summary

Axis Score 🔴 🟠 🟡 🔵 Top Issue
1. Code Quality & Style 9.2 / 10 0 0 1 3 High cyclomatic complexity in _matching_commands and new shell lexer functions
2. Type Safety 9.9 / 10 0 0 0 1 Tri-state return (tuple
3. Test Health 9.4 / 10 0 0 1 1 The shell splitter's fail-safe and quoting branches have no tests: depth limit, unterminated heredoc and backtick, single-quoted ')' in $(...), stray backtick in a heredoc body, shlex error, bare bash -c
4. Security 9.8 / 10 0 0 0 2 Common shell forms (bash -euo pipefail -c, here-string to a shell, sh -c --, exec -a) are not unwrapped, and the guide does not list them
5. Architecture & Design 9.9 / 10 0 0 0 1 Public guide names internal systems (studio-web, internal tickets) and leaves out the built-in agents
6. Error Handling & Resilience 8.4 / 10 0 1 1 1 Raw-text fallback in match_on: simple_commands applies an anchored per-command pattern to the whole call, so max_count: 0 guards fail open
7. API Surface & Maintainability 9.5 / 10 0 0 1 0 match_on field description says echo strings are not commands, but an unanchored pattern still matches an echo or printf string, so a max_count: 0 guard fails on a mention
8. Evaluation Harness Quality 9 / 10 0 0 2 0 Unquoted arithmetic shift ((( x = 1<<3 ))) is read as a heredoc and swallows the rest of the script silently, with no fallback note

Overall Score: 9.4 / 10 · Weakest Axis: Error Handling & Resilience at 8.4 / 10
Totals: 🔴 0 · 🟠 1 · 🟡 6 · 🔵 9 across 8 axes.

Blockers

  1. [Axis 6] Raw-text fallback in match_on: simple_commands applies an anchored per-command pattern to the whole call, so max_count: 0 guards fail open (src/coder_eval/criteria/command_executed.py:171) — _simple_command_texts sends every call it cannot classify or split to raw command_text matching: if _NON_POSIX_PREFIX.match(cmd_text) or _POWERSHELL_ENV.search(cmd_text): return _NOT_POSIX (line 167) and except ShellSplitError: return _UNPARSEABLE (lines 171-172). The patterns written for simple_commands are anchored. The guide's own example (docs/TASK_DEFINITION_GUIDE.md:1075) is command_pattern: "^(\\S*/)?uip (maestro )?flow debug\\b" with max_count: 0. The pattern is compiled with re.DOTALL and without MULTILINE, so on the raw text ^ matches only at the start of the whole call. A forbidden command later in the call does not match, and the guard passes. I ran the real checker with that criterion on three inputs. All three gave score 1.0, and live_verdict gave 'undecided', so early stop did not fire. The inputs were: (1) echo 'On Windows run: $env:UIPATH_URL=x'; uip flow debug x, (2) cat <<'EOF' > README.md\nSet $env:UIPATH_URL first\nEOF\nuip flow debug x, (3) echo $'it\\'s' && uip flow debug x. Bash accepts the ANSI-C quote in (3), but the single-quote branch at shell_commands.py:140 raises 'unterminated quote'. The only notice is one line in the details of a passing criterion (1 call(s) matched on raw text (1 not POSIX shell)). This contradicts contracts.md:150, which says a parse failure "never turns a match into a miss without notice". Fix: when a call falls back, match the pattern per logical line or per ;/&&/| segment of the raw text (or with re.MULTILINE), so an anchored pattern still finds a command later in the call. Alternatively, have a call that falls back count as unresolved for a max_count guard. Add a fallback test that uses the documented anchored guard; the current fallback tests (tests/test_command_executed_simple_commands.py:308-356) use only unanchored patterns.

Non-blocking, but please consider before merge

  1. [Axis 1] High cyclomatic complexity in _matching_commands and new shell lexer functions (src/coder_eval/criteria/command_executed.py:310) — radon gives CommandExecutedChecker._matching_commands D(26) at line 280. On origin/main it is C(16), so this PR adds 10 branches. Most of them come from the inlined if criterion.match_on == "simple_commands": block (lines 310-322). That block repeats the pattern/exclude test that the command_text path does at lines 328-333: if pattern is not None and not any(pattern.search(w) for w in windows): continue / if exclude_re is not None and any(exclude_re.search(w) for w in windows): continue. The logic now exists in 2 places in one function, with different labeling and fallthrough rules (a continue that skips the raw path for a tuple, and a fallthrough with a raw_fallbacks increment for a str). Fix: factor out a per-call generator _match_units(cmd, criterion) -> Iterable[(label, haystacks)]. It yields one unit per simple command in simple_commands mode, and one unit (raw + normalized haystacks) otherwise. Then one loop applies pattern/exclude and appends the label. This removes the duplicate loop and brings CC back to about 16.
  2. [Axis 3] The shell splitter's fail-safe and quoting branches have no tests: depth limit, unterminated heredoc and backtick, single-quoted ')' in $(...), stray backtick in a heredoc body, shlex error, bare bash -c (src/coder_eval/shell_commands.py:84) — The routed coverage report lists these lines of the new module as missing: 84 (raise ShellSplitError("nested deeper than the limit")), 213->220 (heredoc with no closing delimiter), 228-229 and 233 (backslash inside backticks, raise ShellSplitError("unterminated backtick")), 244-249 (single-quote tracking in _closing_paren), 270-271 and 283-284 (except ShellSplitError: pass # prose with a stray backtick or $(), 296-297 (shlex ValueError wrapped), and 386->388 (bash -c with no script). Most of these decide whether a call is split or falls back to raw text, so they change the score. Example: echo $($($($($($($($(uip x)))))))) raises the depth error, and the whole call, heredoc mentions included, is matched raw (verified: details say '1 not splittable into simple commands'). No test trips that gate. Add direct _texts/ShellSplitError assertions for each branch. Verified outputs to pin: x=$(echo ')' ; uip a) gives {'x=SUBST','echo )','uip a'}; cat <<EOF\nuip flow debug\n (no terminator) gives {'cat'}; echo oopsraises ShellSplitError;cat > r.md <<EOF\nrun uip a and $(\nEOF gives {'cat'}; 7 nested $( raises ShellSplitError; bash -c gives []. Also add one checker test where the depth limit forces a raw fallback.
  3. [Axis 6] Whole-text $env: / non-POSIX heuristic disables splitting for a whole POSIX call that only mentions PowerShell in a heredoc or quoted string (src/coder_eval/criteria/command_executed.py:167) — if _NON_POSIX_PREFIX.match(cmd_text) or _POWERSHELL_ENV.search(cmd_text): return _NOT_POSIX runs _POWERSHELL_ENV = re.compile(r"\$env:\w") (line 47) on the text before it is split. The check therefore also hits heredoc bodies, single-quoted echo strings and comments, which are the mentions this feature exists to ignore. A README heredoc with Windows setup steps ($env:UIPATH_URL) is a plausible case for this Windows-centric product. I confirmed that the bash call cat <<'EOF' > README.md\nSet $env:UIPATH_URL first\nEOF\nuip flow debug x returns 'not POSIX shell', and the whole call is matched as raw text. The cmdlet check is already narrow: it runs after the split and only on argv[0] (line 176: _POWERSHELL_CMDLET.fullmatch(argv[0])). Fix: apply the $env: check the same way, after the split, on command words only (for example, any argv[0] that starts with $env:). Then a mention inside a string or heredoc no longer sends the call to the fallback. Add a test with a quoted or heredoc $env: mention next to a real command.
  4. [Axis 7] match_on field description says echo strings are not commands, but an unanchored pattern still matches an echo or printf string, so a max_count: 0 guard fails on a mention (src/coder_eval/models/criteria.py:950) — The match_on Field description is the source for the generated plugin reference (plugins/coder-eval/reference/criteria.md:114), which /coder-eval:task reads when it writes guards. Lines 950-951 say: "heredoc bodies, comments and " / "echo strings are not commands". This is not true without a qualifier. The splitter keeps echo as the program and the string as its argument, so only an ANCHORED pattern skips it. I ran this on PR head 3df13d2: _check(_turn('echo "never run uip flow debug here"'), command_pattern="uip flow debug", match_on="simple_commands", min_count=0, max_count=0) gives score 0.0 with Examples: ['echo never run uip flow debug here']. With ^uip flow debug it gives 1.0. The guide is correct at docs/TASK_DEFINITION_GUIDE.md:1083: "An echo/printf string is an argument of echo, so an anchored pattern (^uip ...) does not match it". The schema description is the copy that is wrong. A task author who trusts it writes an unanchored guard and gets a false fail on any echo, printf or git commit -m that names the command. Fix: change the clause to say that a simple command is matched as <program> <args>, so anchor the pattern (^prog ...) to skip echo strings and other arguments. Also state that a substitution shows as __SUBST__. The guide says this but the description does not. Then run make plugin-reference. Also remove the history wording at line 957, "Other tools' JSON params are matched as before." (CLAUDE.md: a docstring states the contract, not the history). Write "...are matched as with command_text" instead.
  5. [Axis 8] Unquoted arithmetic shift ((( x = 1<<3 ))) is read as a heredoc and swallows the rest of the script silently, with no fallback note (src/coder_eval/shell_commands.py:168) — elif text.startswith("<<", i) and not text.startswith("<<<", i) and (m := _HEREDOC.match(text, i)): together with _HEREDOC = re.compile(r"<<(-?)[ \t]*(?:...|(\\?)([A-Za-z0-9_.\-]+))") (line 41) accepts a digit delimiter. In (( mask = 1<<3 ))\nuip flow debug f.flow the <<3 opens a 'heredoc', and every following line is eaten as its body until a line that is exactly 3. Repro: simple_commands gives only ('mask = 1',), and a max_count: 0 guard on uip flow debug scored 1.0 with no 'matched on raw text' note. let y=1<<2 behaves the same way. This is the one silent-miss shape I found, because every other parse problem is either noted in the details or falls back. Fix: track ((...)) / let arithmetic context in _scan (skip it as one word, as $(( already is at line 197), or reject a delimiter that is all digits. A safer option is to raise ShellSplitError when a heredoc is still open at end of text in a call that has later lines, so the call falls back loudly. Add a regression test.
  6. [Axis 8] The guide's ^(env \\S+ )* prefix does not match its own env -u UIPATH_STUDIO_PID uip rpa build example, so a guard written from the guide misses it (docs/TASK_DEFINITION_GUIDE.md:1086) — Line 1086 says: '(env -u UIPATH_STUDIO_PID uip rpa build, ...). Wrapper stripping stops at the first assignment or env, so write ^(env \\S+ )* or ^(\\w+=\\S* )* before the program if those forms must also match.' I loaded ^(env \\S+ )*uip rpa build through yaml.safe_load and tested it with re.search: it gives False for 'env -u UIPATH_STUDIO_PID uip rpa build' and True for 'env X=1 uip rpa build' and 'env -i uip rpa build'. Each repeat of the group needs the word env again, so an option that takes an argument (-u NAME) breaks the chain. The notes cite 43 evaluations of exactly these env -u UIPATH_STUDIO_PID guards. An author who copies this advice into a max_count: 0 guard gets a false pass on the most common env form. Fix: give a prefix that is correct, for example ^(env( -u \\S+| -\\S+| \\w+=\\S*)* )?(\\w+=\\S* )*, and verify it with a test in tests/test_command_executed_simple_commands.py that compiles the documented string. The same text is in the model description, so no regeneration of plugins/coder-eval/reference/criteria.md is needed for this line.

Nits

  1. [Axis 1] Shell identification duplicated in shell_commands.py: two predicates with different basename rules, repeated POSIX-shell -c check, fish in _POSIX_SHELLS (src/coder_eval/shell_commands.py:336) — looks_like_shell (line 336: return arg0.rsplit("/", 1)[-1].endswith("sh")) splits only on / and does not lowercase or remove .exe. _is_posix_shell goes through program_name (line 68: re.split(r"[\\/]", arg0)[-1].lower() plus .removesuffix(".exe")). So C:\...\bash.exe -c unwraps in simple_commands mode but not in command_text mode. Make looks_like_shell use program_name(arg0).endswith("sh"). Also, _POSIX_SHELLS at line 47 lists "fish", but fish is not POSIX (it has no heredocs, and $(...)/&& work only in newer versions). Rename the set to _SH_COMPATIBLE_SHELLS, or remove fish.
  2. [Axis 1] match_on Literal re-spelled in several places without a named alias (tests/lint/live_verdict_contract.py:78) — match_on: Literal["command_text", "simple_commands"] = "command_text", copies the field type from CommandExecutedCriterion.match_on (models/criteria.py). Define a MatchOn = Literal[...] alias in models and import it here, so a third mode cannot be added in one place only.
  3. [Axis 1] New test file hand-rolls TurnRecord/CommandTelemetry builders and imports models from submodules (tests/test_command_executed_simple_commands.py:12) — Lines 12-13 from coder_eval.models.results import TurnRecord / from coder_eval.models.telemetry import CommandTelemetry go against the CLAUDE.md rule "All core models import from coder_eval.models" (both are re-exported there, and 38 test files already import them that way). _turn (line 21) and test_non_shell_tool_json_is_matched_as_before (line 365) each hand-build TurnRecord(...CommandTelemetry(... timestamp=datetime.now() ...)), although tests/_fixtures/live_criteria.py already has make_command/make_turn with a frozen timestamp. The contract cases in the same PR use those helpers. Also, line 396 has a function-local from coder_eval.models import SandboxConfig, TaskDefinition; move it to the top-level import.
  4. [Axis 2] Tri-state return (tuple | reason-str | None) dispatched by isinstance (src/coder_eval/criteria/command_executed.py:155) — def _simple_command_texts(cmd_text: str) -> tuple[str, ...] | str: (line 155) and _simple_commands_of(...) -> tuple[str, ...] | str | None (line 181) return a sentinel reason string (_NOT_POSIX = "not POSIX shell", _UNPARSEABLE = ..., f"splitter error {type(e).__name__}" at line 175) in the same union as the tuple of simple-command texts. A str is also an Iterable[str]. If a future caller writes for unit in units: without the isinstance(units, tuple) check at line 312, the code type-checks and loops over the characters of the reason: each character becomes a 'simple command' and can match a pattern. Today the only caller does the check, so the cost is only future risk. Fix: return a small typed result, for example class _RawFallback(NamedTuple): reason: str with return type tuple[str, ...] | _RawFallback | None, or a dataclass with commands: tuple[str, ...] | None and fallback_reason: str | None. Pyright then makes a caller narrow the result before it iterates, and the open-ended reason vocabulary (also the dict[str, int] key of _Matches.raw_fallbacks, line 265) is named in one place. Optional: the positional 3-tuples _scan -> tuple[str, list[str], list[tuple[bool, str]]] and _unwrap -> tuple[list[str], list[str], list[list[str]]] in shell_commands.py return two list[str] items (argv and scripts) that can be swapped with no type error. A NamedTuple would remove that risk too.
  5. [Axis 3] Checker branches added for simple_commands mode have no tests: per-unit counting without a command_pattern, windowing of long simple commands, and the empty or non-string command fallthrough (src/coder_eval/criteria/command_executed.py:315) — Line 315 is if pattern is not None and not any(pattern.search(w) for w in windows):. Its pattern is None side changes how pattern-less caps count. Verified: tool_name='Bash', max_count=1 on cd x && ls && pwd gives 0.0 with match_on=simple_commands (3 matches) and 1.0 with the default mode (1 match). No test pins this. Line 314, windows = _search_windows(unit), has no test with a simple command longer than _MAX_PATTERN_SEARCH_LEN. Line 193, return None (empty or non-string command in _simple_commands_of), is in the routed coverage-missing list. Add one test for each: a pattern-less max_count cap counted per simple command, a pattern found only past 2000 chars of one simple command, and a Bash call with command: "" or a non-string command in simple_commands mode.
  6. [Axis 4] Common shell forms (bash -euo pipefail -c, here-string to a shell, sh -c --, exec -a) are not unwrapped, and the guide does not list them (src/coder_eval/shell_commands.py:345) — The guide tells authors to anchor patterns in this mode. Several common forms leave the program out of first position, or drop the script entirely, so the evaluated agent can run a forbidden command without a match. Results from running _simple_command_texts: bash -euo pipefail -c 'uip flow debug x' -> ('bash -euo pipefail -c uip flow debug x',). The cause is command_flag_index at lines 345-349: if not tok.startswith("-"): return None treats the argument of -o (pipefail) as the first positional word. bash <<< 'uip flow debug x' -> ('bash',): _REDIRECT_OP at line 45 removes <<< and its target, and _feeds_a_script (line 119) handles only heredocs. The guide does not list this case; it lists only stdin piped from another command. sh -c -- 'uip flow debug x' -> ('-- uip flow debug x',). exec -a n uip flow debug x -> ('-a n uip flow debug x',). In each case ^(\S*/)?uip ... flow debug\b does not match. The equivalent bash -s <<'EOF' form is parsed correctly. Fix: in command_flag_index, skip the argument of -o/+o/-O and accept -- after -c. Treat a <<< target fed to a shell like a heredoc fed to a shell. Give exec its options in _FLAG_WRAPPERS (-a). Add these cases to the test file. Cross-axis: Axis 8. CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N
  7. [Axis 4] simple_commands runs shlex on the whole command without a size limit, against the HAZARD invariant at line 29; one long quoted word is quadratic (1 MB takes about 9 s) (src/coder_eval/criteria/command_executed.py:170) — Lines 29-30 say # HAZARD: bounds ReDoS on a large command string. Every search window is at most this long and normalization runs per window, so shlex needs no separate size guard. The new path calls argvs = simple_commands(cmd_text) (line 170) on the full text, which has no limit. It reaches lexer = shlex.shlex(top, posix=True, punctuation_chars=_SEP_CHARS) (shell_commands.py:290). shlex builds each token one character at a time, so cost is quadratic in the length of one word. Measured _split times for echo "<n chars>": 125k 0.29 s, 250k 0.84 s, 500k 2.43 s, 1M 9.10 s. A python3 -c '<512 KB script>' takes 4.8 s. The module docstring (shell_commands.py:10, "Linear in the length of the text") and contracts.md:162 ("The splitter is linear") are wrong for this input. TestLinearTime tests only units with many short words. live_verdict calls this path synchronously from the early-stop event callback (orchestration/early_stop.py:419), so a large call blocks the event loop once per distinct text. @lru_cache(maxsize=1024) on _simple_command_texts (line 153) also keeps up to 1024 full-size texts for the whole process. Model output limits keep the practical impact low. Fix: above a length limit (for example 64 KB), return a "too long to split" raw-text fallback reason. Or remove the long quoted spans before shlex sees them. Add a long single-word case to TestLinearTime, and correct the two "linear" statements. CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L
  8. [Axis 5] Public guide names internal systems (studio-web, internal tickets) and leaves out the built-in agents (docs/TASK_DEFINITION_GUIDE.md:1097) — Line 1097, - It reads the recorded command text only, so it works the same on every agent and driver (Claude Code, Codex bash -lc records, studio-web)., names studio-web as an agent/driver. No such agent or driver exists in src/coder_eval/ (the in-tree agents are Claude Code, Codex, Antigravity, OpenCode, Pi). .claude/notes/contracts.md:132-137 cites (UiPath/skills #5069) and lab ticket 526, which are internal trackers. Replace studio-web with the in-tree agents, or say "every agent and driver". Remove the internal ticket references from the notes, or make them generic ("a downstream suite").
  9. [Axis 6] Shell call with a non-string/malformed command element is matched on raw JSON with no fallback note in details (src/coder_eval/criteria/command_executed.py:192) — _simple_commands_of re-quotes only an all-string list (if isinstance(raw_command, list) and raw_command and all(isinstance(a, str) for a in raw_command):, line 190). Any other non-string value gets if not isinstance(raw_command, str) or not raw_command: return None (lines 192-193). None is the value for a non-shell call, so _matching_commands falls through to JSON matching and does not add the call to raw_fallbacks. I confirmed that a Bash call with command: ["bash", "-lc", "uip flow debug", 1] matches as Bash({"command": [...]}). The details say match_on=simple_commands but have no matched on raw text line, so this fallback is the one case that _raw_fallback_note does not report. Fix: return a reason string (for example 'command is not a string or string list') for a shell call with a non-empty, non-string command, so every fallback path is reported the same way.

What's Missing

Parallel paths:

  • 🟡 The Codex adapter loses the shell kind before the new matcher sees it, and the PR does not change the adapter. _record_command_text in src/coder_eval/agents/codex_agent.py:282-295, used by rollout recovery at :2474, removes a powershell -Command / cmd /c wrapper (detected by its own _SHELL_PROGRAM regex at :189) and records only the script, with tool_name "Bash". The live path at :2636 records the full wrapper text. So the same Windows call reaches _simple_commands_of in two shapes, and simple_commands mode has to guess from the text (_POWERSHELL_ENV over the whole text, Verb-Noun on argv[0]). That guess is the source of the false raw-text fallback. Codex's _SHELL_PROGRAM is also a fourth shell-identification predicate, next to looks_like_shell, _POSIX_SHELLS and NON_POSIX_SHELLS. Fix at record time: keep the wrapper for non-POSIX shells, or record a shell-kind param that _simple_commands_of reads, the same way it reads a tool_name that contains powershell. Add one test that sends a rollout-shaped Codex PowerShell record through match_on: simple_commands. (trigger: src/coder_eval/criteria/command_executed.py) (restates: Axis 6: Whole-text $env: / non-POSIX heuristic disables splitting for a whole POSIX call)
  • 🔵 Only the generated plugins/coder-eval/reference/criteria.md was updated for the new mode, and it has the echo claim that Axis 7 found to be wrong. The other guard-authoring surfaces were not updated. plugins/coder-eval/reference/task-rubric.md row 1 still says echo cmd can pass, and row 3 covers max_count: 0 negatives, but neither gives match_on: simple_commands plus an anchored pattern as the fix. The /coder-eval:task and /coder-eval:lint-tasks skills (plugins/coder-eval/skills/*/SKILL.md) do not suggest it for must-not-run guards and do not flag a max_count: 0 guard that trips on heredoc mentions. The /coder-eval:analyze skill cannot explain the new matched on raw text (...) details line. As a result, new guards written with the plugin keep the heredoc false-fail that this PR exists to remove. (trigger: src/coder_eval/models/criteria.py)

Tests:

  • 🔵 No test covers require_success: true together with match_on: simple_commands. result_status is set per call, so every simple command in a successful call counts as having succeeded. For example, uip flow pack x; true and uip flow pack x || echo skip both credit uip flow pack even when that command failed. The guide's simple-commands section does not say that the success status comes from the whole call. Add a test that pins this, and add one line to docs/TASK_DEFINITION_GUIDE.md § Matching simple commands. (trigger: src/coder_eval/criteria/command_executed.py)
  • 🔵 No test loads the guide's own simple-commands YAML example and prefix advice and runs them against the cases the guide names. A test that loads ^(\\S*/)?uip (maestro )?flow debug\\b from YAML, adds the ^(env \\S+ )* prefix, and runs them against env -u UIPATH_STUDIO_PID uip rpa build, a heredoc mention and a raw-text fallback call would have caught both the broken env prefix and the anchored-guard fail-open on fallback. Add a doc-example test in tests/test_command_executed_simple_commands.py. (trigger: docs/TASK_DEFINITION_GUIDE.md) (restates: Axis 8: The guide's ^(env \\S+ )* prefix does not match its own env -u example)
  • 🔵 The checker tests for simple_commands mode use only tool_name "Bash" and "ExecutePowershellCommand". _is_shell_call treats ANY call with a command param as shell, and the PR splits those calls as POSIX. That includes OpenCode, Antigravity and Pi shell tools after their command_line -> command normalization, and also an MCP or other tool that has an unrelated command param. No test runs a non-Bash shell tool name or a non-shell tool with a command key through the splitter. Add tests for one in-tree non-Claude shell tool record and for one non-shell tool that has a command key. (trigger: src/coder_eval/criteria/command_executed.py)

Nightly pipeline:

  • 🟡 The PR does not give the rollout order for the downstream nightly suites. Criterion models use extra="forbid" (models/criteria.py:103). So a task YAML that adds match_on: simple_commands fails validation with "Extra inputs are not permitted" on every coder-eval release before this one. evaluate <run_dir> from an older install also fails on such a run's recorded config. The PR body shows default-mode parity (16,936/16,936) and opt-in evidence (21 fail->pass, 20 row verdicts). It does not say that the nightly's coder-eval pin must be bumped before any suite opts in, or that the opt-in flips those rows. The flip shows as a step in the evalboard pass-rate trend, which nobody has been told to expect. State the pin-then-opt-in order and the expected trend shift in the PR, or in the contracts.md note. (trigger: src/coder_eval/models/criteria.py)

Harness & Lint Improvements

Static checks (lint / type):

  • [ce-lint] CE069 no-str-or-str-sequence-union (new BaseRule tests/lint/rules/ce069_no_str_or_str_sequence_union.py; add to ALL_RULES in tests/lint/runner.py and to [tool.ruff.lint] external in pyproject.toml). The rule forbids a return or parameter annotation in src/coder_eval/ that puts bare str in one union with tuple[str, ...], list[str], Sequence[str] or Iterable[str]. A str is itself an Iterable[str], so pyright does not make a caller narrow the value before a for loop. To check it on the AST, flatten the BitOr chain of FunctionDef.returns and arg.annotation. A grep of src/ finds exactly two hits, and both are in this PR: _simple_command_texts -> tuple[str, ...] | str (command_executed.py:155) and _simple_commands_of -> tuple[str, ...] | str | None (:181). So the rule starts with zero violations after the fix. The fix it forces: a typed _RawFallback(reason: FallbackReason) NamedTuple whose reasons are a closed Literal/enum. The fix also removes the | None arm. Each non-tuple path must then name a reason, so the silent JSON fallthrough for a malformed command element (command_executed.py:192) becomes a type error and cannot go unreported. Prevents: Tri-state tuple | reason-str | None return dispatched by isinstance (command_executed.py:155/181, A1/A2/A5/A7). Indirectly also the malformed-command-element fallback with no note in details (command_executed.py:192, A2/A6), because removing None from the union forces a reason on that path.
  • [ce-lint] CE070 literal-member-set-spelled-once (a whole-tree @pytest.mark.lint class in tests/test_custom_lint.py, because it reasons over the whole tree). Over src/coder_eval/ and tests/lint/, the same Literal[...] with 2 or more string members may appear in only one place. Every other site imports a named alias (for example MatchOn = Literal["command_text", "simple_commands"] in coder_eval.models). I ran an AST scan on the PR head and found 5 duplicated member sets: match_on (models/criteria.py:945 and tests/lint/live_verdict_contract.py:78), error/success/unknown (5 sites in agents/*, models/telemetry.py:398 and live_verdict_contract.py:96), argmax/expected (2), the error/failed/succeeded/ungraded set (4), and docker/tempdir (3). All are small enough to fix in the same change, so the rule can start at zero violations. Prevents: match_on Literal written again in tests/lint/live_verdict_contract.py:78 and models/criteria.py:945 with no shared alias (A1/A7). A third mode cannot then be added in one place only.
  • [ce-lint] CE072 cyclomatic-complexity ratchet (a whole-tree @pytest.mark.lint class that uses radon.complexity.cc_visit; radon is already a runtime dependency). Keep a checked-in baseline (tests/lint/cc_baseline.json) of every function in src/coder_eval/ with radon CC > 20, recorded at its current value. Fail when a function that is not in the baseline goes above 20, or when a baselined function's CC increases. A flat cap is not possible, because about 53 D-or-worse blocks exist today. Ruff's C901 is the wrong tool here: mccabe does not count boolean operators, so it scores _matching_commands at 14 and _scan at 13 (radon scores them 26 and 31). At any useful max-complexity it misses both functions and reports 20 old offenders. PLR0912 (max-branches=25) also passes both. The fix is a refactor (the _match_units generator, splitting _scan), not a # noqa. Per CLAUDE.md, a cap rule sets its limit below the current value, so the baseline only goes down. Prevents: CommandExecutedChecker._matching_commands going from C(16) to D(26) because of the inlined, duplicated simple_commands pattern/exclude loop, and the new _scan at E(31) in shell_commands.py:125 (A1 theme group).
  • [ce-lint] Widen CE001 (tests/lint/rules/no_submodule_model_imports.py) from src/ to tests/. Exempt tests/lint/** fixtures that build violating source on purpose, and keep the existing TYPE_CHECKING skip. Today 34 test files use from coder_eval.models.<sub> import. That is a mechanical fix, and this project has no backward-compatibility burden. Do not propose a rule against the hand-built TurnRecord/CommandTelemetry with datetime.now(): 34 test files build CommandTelemetry( directly, so a rule would be mostly noise. Leave the move to the shared tests/_fixtures/live_criteria.py builders to review. Prevents: tests/test_command_executed_simple_commands.py:12-13 importing TurnRecord/CommandTelemetry from coder_eval.models.results/.telemetry against the CLAUDE.md rule (A1).
  • [ce-lint] CE073 executable pattern examples in docs (extend tests/lint/doc_examples.py, the CE029 extractor). Add a fenced block type, for example ```pattern-example, with a pattern: line, a match_on: line, and match: / no-match: command lines. CE073 runs each block through the real CommandExecutedChecker and asserts the result, and it fails when the match_on section of docs/TASK_DEFINITION_GUIDE.md has an inline regex that is not in such a block. Use it for the wrapper-prefix advice (^(env \S+ )* must match env -u UIPATH_STUDIO_PID uip rpa build; today it does not) and for the echo-string claim (an unanchored uip flow debug DOES match echo "... uip flow debug ..."). The match_on Field description in models/criteria.py:950 is the source of plugins/coder-eval/reference/criteria.md, so make it point at the same verified examples instead of making its own unverified claim. Prevents: Guide prefix ^(env \S+ )* that does not match the guide's own env -u NAME example (TASK_DEFINITION_GUIDE.md:1086, A8). Field description saying echo strings are not commands although an unanchored guard matches them (models/criteria.py:950, A7).
  • [ce-lint] CE074 no internal tracker references on public surfaces (a doc-surface @pytest.mark.lint class). Over docs/**, plugins/**, .claude/notes/** and src/**, forbid cross-repo issue references of the form <Org>/<repo> #<n> for any repo other than this one, and \b(lab )?ticket \d+\b. Both are mechanical. Product names such as studio-web in an agent list are NOT generically detectable; leave those to the Axis 5 review litmus (grep -ri <internal-system>). Prevents: (UiPath/skills #5069) and lab ticket 526 in .claude/notes/contracts.md:132-137 (A5/A7). It does not catch studio-web at TASK_DEFINITION_GUIDE.md:1097.
  • [ci-gate] Changed-line branch-coverage gate in make verify and CI: pytest --cov-branch and then diff-cover coverage.xml --compare-branch origin/main --fail-under 95 (diff-cover is a new dev dependency, so run the license check first). The repo-wide 80% threshold passed while the new shell_commands.py had 11 uncovered branches. These include the depth-limit ShellSplitError (line 84), the unterminated-heredoc and backtick paths, the _closing_paren single-quote tracking, the except ShellSplitError: pass at 283-284, and the pattern is None per-unit counting side of command_executed.py:315. Most of these branches decide between split and raw fallback, so they change the score. Prevents: Untested splitter fail-safe and quoting branches (shell_commands.py:84 and others, A3). Untested checker branches in simple_commands mode: pattern-less per-unit max_count, windowing of long units, empty or non-string command (command_executed.py:315/314/193, A3).

Harness improvements (not statically reachable):

  • Bash-oracle differential test for shell_commands.simple_commands. Run each command of a corpus (authored, plus Hypothesis-generated from a small shell grammar) under a real bash in a tmp dir. Use a PATH of stub executables that only log their argv, or a trap DEBUG that logs BASH_COMMAND. Assert that every program bash runs is the first word of some unit that the splitter returns, or that the splitter raises ShellSplitError. A silent miss must fail the test. Seed the corpus with (( m = 1<<3 ))\nuip ..., let y=1<<2, bash -euo pipefail -c '...', sh -c -- '...', bash <<< '...', exec -a n uip ..., echo $'it\'s' && uip ..., 7-deep $(, and quoted ) in $(...). Why not static: The ground truth is what bash actually runs. Only a bash process can supply it, and a lint rule over the splitter source cannot predict how it parses a given input. Prevents: Arithmetic <<3 read as a heredoc that silently swallows later lines (shell_commands.py:168, A8). Wrapper forms not unwrapped (shell_commands.py:345, A4/A8). ANSI-C quote mis-split that forces a raw fallback (part of command_executed.py:171, A6).
  • A 'fallback fails closed' requirement in the CE036 live-verdict contract (tests/lint/live_verdict_contract.py). After the CE069 fix makes the fallback reasons a closed type, add a fallback_gaps check. For each reason (not POSIX, unparseable, splitter error, malformed command), it requires a ContractCase with the guide's anchored max_count: 0 guard (^(\S*/)?uip (maestro )?flow debug\b) and a forbidden command placed after the fallback trigger, with reaches: "fail". Today the fallback cases use only unanchored patterns, so they cannot expose an anchored pattern that is tested against the whole raw text. Seed it with the three reproduced inputs: $env: in an echo string, $env: in a heredoc body, and the ANSI-C quote. Why not static: Fail-open is a semantic property of how the checker applies an anchored regex to text that fell back. Only a replay through the real checker shows it; the AST shows nothing. Prevents: An anchored max_count: 0 guard that passes on a forbidden command after a raw-text fallback (command_executed.py:171, A6 high). The whole-text $env: heuristic that sends POSIX calls to the fallback (command_executed.py:167, A6).
  • Adversarial-shape performance budget in TestLinearTime. Add cases with one long word or one quoted span (echo "<256 KB>", python3 -c '<256 KB script>') and assert a wall-clock or op-count budget. Pair it with an explicit max input length that returns a too long to split fallback reason. Also correct the 'linear' claims in the shell_commands.py docstring and in contracts.md:162. Why not static: shlex is quadratic only for certain input shapes, and a cost that depends on input shape shows only at runtime. No lint rule can prove that a call site is bounded. Prevents: Unbounded shlex run on the whole command, which goes against the HAZARD invariant at command_executed.py:29 (about 9 s per 1 MB word and blocks the early-stop event loop) (command_executed.py:170, A4).
  • Delete before you guard, for shell identification. Collapse looks_like_shell and _is_posix_shell into one predicate built on program_name (lowercase, split on \ and /, remove .exe), and rename or trim _POSIX_SHELLS so it does not list fish. Add one Windows-path case (C:\...\bash.exe -c) that runs in both match modes. No lint rule is proposed: CLAUDE.md prefers removing the sharp edge to guarding it, and after the merge there is no second predicate left to guard. Why not static: This is a deliberate choice not to add a rule. A rule that forbids rsplit("/", 1)[-1] would guard a pattern the fix deletes, and deciding whether fish counts as POSIX is a semantic call. Prevents: Two shell predicates with different basename rules, and fish listed in _POSIX_SHELLS (shell_commands.py:336/47, A1/A5/A7).

Top 5 Priority Actions

  1. Stop anchored guards from failing open on fallback (src/coder_eval/criteria/command_executed.py:167-172): match the pattern on each line or each ;/&&/| segment of the raw text, or make a fallback call count as unresolved for a max_count guard; move the $env: check after the split so it runs only on argv[0]; and add a fallback test that uses the guide's anchored ^(\S*/)?uip (maestro )?flow debug\b guard on the three verified inputs ($env: in a quoted string, $env: in a heredoc, ANSI-C $'it\'s').
  2. Stop the silent heredoc swallow in src/coder_eval/shell_commands.py:168 (with _HEREDOC at line 41): skip ((...)) and let arithmetic as $(( already is at line 197, reject an all-digit delimiter, or raise ShellSplitError when a heredoc is still open at the end of the text; then add a regression test for (( mask = 1<<3 ))\nuip flow debug f.flow, which now passes a max_count: 0 guard with no fallback note.
  3. Correct the match_on Field description at src/coder_eval/models/criteria.py:950-957: say that a simple command is matched as <program> <args>, so only an anchored pattern skips echo/printf strings; state that a substitution shows as __SUBST__; replace the history wording 'matched as before'; then run make plugin-reference so plugins/coder-eval/reference/criteria.md:114 stops telling /coder-eval:task to write unanchored guards that fail on a mention.
  4. Replace the broken ^(env \S+ )* prefix advice at docs/TASK_DEFINITION_GUIDE.md:1086 with a prefix that matches the guide's own env -u UIPATH_STUDIO_PID uip rpa build example, and add a test in tests/test_command_executed_simple_commands.py that compiles the documented string and runs it on that example.
  5. Close the unwrapping and test gaps in src/coder_eval/shell_commands.py: in command_flag_index (line 345), skip the argument of -o/+o/-O and accept -- after -c; treat a <<< here-string fed to a shell like a heredoc; give exec -a its option; add tests for the fail-safe branches that have no tests (depth limit at line 84, unterminated heredoc/backtick, single-quoted ) in $(...), shlex error, bare bash -c), including one checker test where the depth limit forces a raw fallback.

Stats: 0 🔴 · 1 🟠 · 6 🟡 · 9 🔵 across 8 axes reviewed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants