Skip to content

fix(evals): resolve same-command shell variables in run-validity's Bash paths - #12225

Closed
melodic-automation-lanes[bot] wants to merge 4 commits into
mainfrom
work-resolve-issue/issue-12156-41374150324-1
Closed

melodic-automation-lanes[bot] wants to merge 4 commits into
mainfrom
work-resolve-issue/issue-12156-41374150324-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #12156

Summary

Opened by the work-resolve-issue lane. The run's own summary:

run-validity.py's bash_paths now reads a Bash command with its own quote-aware tokenizer (shell_tokens/shell_words) in place of shlex.split. It resolves NAME=<literal> assignments made earlier in the same command, so $NAME and ${NAME} paths are judged like literal ones and a plugin-data denial reached through D=/PD=/R=$D/... is set aside under #12003's rule. An assignment counts only when it is a command of its own that always runs in the top-level shell: first, or after ;, a newline, or an && whose left side was such an assignment. It must come before any compound command, # comment, heredoc, backtick or IFS use, and its value must be one literal word (no expansion, glob, tilde, whitespace or redirect). A later mention of the name (read D, printf -vD, ((D=1)), export D=...), eval/source/., or a shell-managed name drops it. Anything else stays unresolved (None, so FAIL). One design choice beyond the issue's text: the first word of each simple command (after ;, &&, ||, |, newline or an opening parenthesis) now counts as a command name, like the command's first word already did. Without that, the issue's PD=...; ls ...; touch ... acceptance case could never be set aside, since the old parser added None for every later command name even with literal paths.

Not verified

  • run-validity.test.sh / test_run_validity.py were not executed: this lane runs no Python interpreter or test runner, and check-affected's output does not show whether it ran the suite. Every assertion was traced by hand, by me and by the review subagent. The suite is left to the PR's CI.
  • The issue's check that the new tests fail against the old parser was not run, for the same reason. By reading the old code: it added None for any word holding $, and for any later word that was neither rooted nor a flag. So every plugin-data WARN case and every exact-tuple case in BashPathsTest woul
  • The done-when run of run-validity.py on /home/kyle/worktrees/cc-plugins-11564b-evalrun/m-before.json needs the lane-1 host and was not run. From the commands quoted in the issue: the PD= ls -la ...; touch ... denial should now be set aside. The D=...; bash "$S" lease acquire ... denial still FAILs
  • Behavior change to note in review: any later command name is now excused, as the first word already was. So cat /proc/v; make no longer adds None, though make reads its working directory. Arguments and relative paths still add None.
  • tidy: the code passes (simplify, comment triage, generated-code residue) and docs-hygiene:write-for-agents ran. The ai-slop:audit deterministic detector (detect.sh) was skipped because this lane's Bash runs only the named wrappers. Its rubric was applied by reading and found nothing.
  • Untracked dotfiles in the checkout root (.bashrc, .bash_profile, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) are not part of this change and were left alone. They were left out of the tidy size measure.

Fix

  • plugins/evals/skills/plugin-eval/scripts/run-validity.py: new shell_tokens, assignment, expand and shell_words, plus constants for names, expansions and the values and names never recorded; bash_paths uses them in place of shlex.split and excuses the first word of each simple command and each assign
  • plugins/evals/skills/plugin-eval/scripts/test_run_validity.py: two end-to-end tests (D=, PD= and R=$D/... plugin-data shapes come out WARN; a variable outside plugin data, a climb-out, an unassigned name, $(...) and use-before-assignment come out FAIL), and a BashPathsTest class with exact path tupl
  • plugins/evals/skills/plugin-eval/reference/reading-results.md: the Bash-denial paths rule now names the command-name exemption and same-command variable resolution
  • .changes/evals/work-resolve-issue-issue-12156-41374150324-1-93154224.md: patch fragment for the evals plugin

Verification

The runner ran each check from the base copy against a5d7ce4:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-changelog-fragments: all 9 fragments valid (run after tidy and after the review fixes)
  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-changed-skills: CHECK-SKILL plugin-eval PASS, 0 errors, 5 warnings that predate this change (description length, body size)
  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-affected: 12 passed, 6 skipped, the rest CI-only, over 4 changed files (run after tidy and after the review fixes)
  • fresh-context review subagent: read the whole diff and traced by hand every existing Bash-command test, every new test and the exact tuples; found no regressions and five soundness gaps (a # comment hiding an assignment, a name set in ((...)) or by printf -vD not dropped, GROUPS/FUNCNAME/SHELLOPTS/M
  • ruff config (ruff.toml selects E4, E7, E9, F): read the changed code against it; the shlex import was removed with its last use, and no unused names remain
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/41374150324

Left out: the items under Not verified.

Related

#12156

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed e1cf5845d1e539c9cc9f188837b1dce9964e5e7a: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #12225, incremental (51ccaec..e1cf584)

I found no security issues.

Scope. I read every hunk of both files in the incremental diff:

  • plugins/evals/skills/plugin-eval/scripts/run-validity.py
  • plugins/evals/skills/plugin-eval/scripts/test_run_validity.py

Neither file matches a TRUSTED PATHS glob. Neither is a trust control, a merge hold, a plugin manifest or a standing instruction surface, so no manifest lines apply. The other two files of the PR have not changed since the last review.

What changed. The commit makes the fixes the owner asked for in the two settled threads. Both threads are marked lines changed since resolution: yes, and this diff is the change that answers them. Each change makes the parser stricter:

  • Bare-name values. UNRECORDED_VALUE now refuses to record a value that is only a variable name, such as X=D. A later read "$X" or declare "$X=..." therefore can no longer leave D holding an old value.
  • Writes inside assignment values. shell_words now also checks an assignment's value for mentions of a recorded name before it records anything. E="$((D=5))" and E=$[D=5] now drop D.
  • Commands with no rooted argument. bash_paths tracks each simple command. One that names no rooted argument outside a redirect, and does not read from a pipe, now adds None. So ls -la /proc; ls is FAIL again. Words after ) are the compound command's redirects and are left out, and the file named by a redirect is not counted as an argument.
  • Tests. New tests pin each of these cases.

Why there is no finding. run-validity.py is a quality check that runs after an eval run finishes:

  • It parses command strings and never runs them.
  • It grants or denies no tool call, holds no credential, mints no token and gates no merge.
  • Every change here moves results toward None, which fails closed.
  • The worst case is still a wrong eval verdict. That is not a leak, compromise or charge.

Prior findings. The lane's earlier post (a no-findings summary) has nothing to restate.

Embedded text. Neither the PR context nor the settled threads contain a directive aimed at this lane.

Spend. Nothing here spends credits or can cause a charge.

critical-findings: 0

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

claude-review: 1 inline finding(s) on a5d7ce4d234b1b25d189abf031c2c56d0f4aad69; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed e1cf5845d1e539c9cc9f188837b1dce9964e5e7a: read 2 of 2 changed file(s); 1 finding(s), 1 as inline comments.

Code review: PR #12225, incremental since 51ccaec

Scope. This round covers the change since 51ccaec in run-validity.py and test_run_validity.py. I read every hunk of .claude-lane/incremental.diff and checked it against the head file. The other two files of the PR have not changed since the last review.

Prior findings. Both earlier inline findings are addressed:

  • Bare later commands. A later bare command such as ls, make or cd - adds None again. ls -la /proc; ls is now pinned to FAIL in test_a_with_arm_bash_denial_with_no_rooted_path_is_a_fail, and new tuple tests cover it in test_a_later_command_naming_no_rooted_argument_adds_none.
  • Writes the name check missed. An assignment's value is now scanned for names it mentions, and a bare-name value is no longer recorded. The test cases the finding listed were added.

Findings (1)

  1. Inline on run-validity.py L1026-1033: an env-prefix assignment's rooted value counts as the command's rooted argument. So PYTHONPATH=/opt/lib pytest -q or TMPDIR=/tmp make returns ('/opt/lib',) with no None, even though the command works in the working directory. That is the same gap the last round's fix was meant to close.

A correction to this lane's earlier finding (not counted). The four added cases in test_a_variable_it_cannot_resolve_still_adds_none would also pass on the code from before this change:

  • E="$((D=5))" and E=$[D=5]: the E word already left a $ piece, which matches UNRESOLVED.
  • read "$X" and declare "$X=/e" with X=D: these already expanded to a bare D word, which adds None.

So my earlier claim that these commands came out as (<d>/a,) was wrong: the whole tuple already had None in it. The two fixes are safe and only make the result more conservative, but these cases do not pin them. No action needed.

Closing issue #12156 criteria. These are unchanged from the last round:

  • Resolution of NAME=<literal>: met and tested.
  • Plugin data set aside, outside paths and unresolved names still FAIL: met and tested. The acceptance shapes (D=…; R=$D/…; ls -la "$R", and PD=…; ls …; touch …) still name a rooted argument in every simple command, so the new rule keeps them WARN. I traced this by hand.
  • Done-when host run and the old-parser check: not verified. I have no shell, so I could not run the test suite either; CI will show whether it passes.

Other notes

  • No plugin.json or marketplace manifest changed.
  • Neither the PR context, the settled threads nor the prior-findings file holds text aimed at instructing this lane.
  • No hold. The change adds no spend.

@melodic-automation-lanes

melodic-automation-lanes Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head e1cf5845d1e539c9cc9f188837b1dce9964e5e7a. The lanes clear this reason on their own; the next scheduled run judges it again.

a pr-unblock lane stopped its head (pr-unblock/fix-ci is failure), which ci-status fails in the
  merge queue

Lane-Activity: pr-unblock/resolve-conflicts

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

claude-review: 1 inline finding(s) on 15e35316845fabdb41f807370ab5e36dbdee9b50; the summary is in this lane's pull request comment.

claude-lane: claude-review

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 15e35316845fabdb41f807370ab5e36dbdee9b50.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The pr-unblock lane stopped address-feedback on this pull request: the reply job failed before it decided anything (a lane token it could not get, or a script error), so no reply was posted. The lane sets no label: the run ends in a failing pr-unblock/address-feedback status on the head the lane gated.

When a retry on this head can change the outcome, the lane runs one on its own, up to its per-head cap, and edits this comment if it stops again; a run that does not stop clears the status. When no retry can (a review thread the lane does not take or settle, or a failing check after the retries are spent), a person resolves the threads or gets the checks green, then dispatches the workflow below: that run finds the cause gone and clears the status. On a pull request the lanes App opened, the dispatchers start that run once per stop; on any other, a person does. A new commit to the branch starts clean.

To run it again on this head now, dispatch the pr-unblock workflow:

gh workflow run pr-unblock.yml -R melodic-software/claude-code-plugins -f pr-number=12225 -f activity=address-feedback

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

A lane run on this pull request's head failed because the token broker refused it as workflow-modified: .github/workflows/pr-run-activity-write.yml changed on main after the run's event, and a rerun keeps the old file. pr-merge pushes an empty commit so the next pr-unblock run uses main's files. It does this once per version of that file, so if a run fails the same way again, a person looks at it. The push starts no run itself: the conflict-resolution run starts at the next push to main or half-hourly pr-unblock-dispatch tick, or when a listed person runs it by hand, and an address-feedback run can start after both review lanes review the new head, if an unresolved thread is left for it.

The token broker refused a lane run on the previous head as workflow-modified (.github/workflows/pr-run-activity-write.yml). This commit changes no file.
Lane-Activity: pr-unblock/address-feedback
Lane-Thread: PRRT_kwDOTCGFQM6yg83X
Lane-Thread: PRRT_kwDOTCGFQM6yhYgZ
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

pr-unblock / address-feedback finished round 1 of max 4 on e1cf584.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

claude-review: 1 inline finding(s) on e1cf5845d1e539c9cc9f188837b1dce9964e5e7a; the summary is in this lane's pull request comment.

claude-lane: claude-review

Comment on lines +1026 to +1033
# A redirect's file (>/x, or the word after a bare >) is no argument.
argument = not (target or REDIRECT.match(text))
target = REDIRECT.fullmatch(text) is not None
if simple is not None:
named[simple] = named.get(simple, False) or (
argument
and any(rooted(v) for k, v in enumerate(pieces) if k or not first)
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A prefix assignment's rooted value counts as the simple command's rooted argument, so PYTHONPATH=/opt/lib pytest still adds no None.

shell_words marks a prefix assignment lead and puts it in the same simple command as the command word after it. Here, its pieces after NAME count toward named[simple]. Trace for PYTHONPATH=/opt/lib pytest -q:

  • word 1: PYTHONPATH=/opt/lib, pieces ['PYTHONPATH', '/opt/lib']. argument is True and /opt/lib (k=1) is rooted, so named[0] = True.
  • pytest is lead and -q is a flag, so neither adds None.
  • Result: ('/opt/lib',). On the base code, the later word pytest added None.

TMPDIR=/tmp make, HOME=/tmp ls and LC_ALL=C ls /x; X=/y ls behave the same way. The command works in the working directory, which may be the plugin. Yet in the with-arm, same_as_clean sets the denial aside when /opt/lib lies outside the plugin. That is the case the new rule ("names no rooted argument … adds None") was added to catch.

A possible fix: skip assignment words when filling named. A simple command made only of assignments (D=<d>;) then gets no entry, so the acceptance cases still resolve:

        # A redirect's file (>/x, or the word after a bare >) is no argument,
        # nor is a prefix assignment's value (PYTHONPATH=/x pytest).
        assigned = lead and ASSIGNMENT.match(text)
        argument = not (target or REDIRECT.match(text))
        target = REDIRECT.fullmatch(text) is not None
        if simple is not None and not assigned:
            named[simple] = named.get(simple, False) or (
                argument
                and any(rooted(v) for k, v in enumerate(pieces) if k or not first)
            )

To pin it, add ("PYTHONPATH=/opt/lib pytest -q", ("/opt/lib", None)) and ("TMPDIR=/tmp make", ("/tmp", None)) to test_a_later_command_naming_no_rooted_argument_adds_none. The existing cases D=<d>; R=$D/runs; ls -la "$R" and R=$D/x S=$R/y should still return no None.

claude-lane: claude-review

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

pr-fix lane: please fix this finding. Confirmed at e1cf584: bash_paths (run-validity.py L1029-1033) fills named[simple] for every word, prefix assignments included, so PYTHONPATH=/opt/lib pytest -q gives (/opt/lib,) with no None. Apply the suggested fix (skip lead assignment words when filling named, so an assignment-only simple command gets no entry) and add ("PYTHONPATH=/opt/lib pytest -q", ("/opt/lib", None)) and ("TMPDIR=/tmp make", ("/tmp", None)) to test_a_later_command_naming_no_rooted_argument_adds_none; the D=; R=$D/runs; ls -la "$R" and R=$D/x S=$R/y cases must still return no None.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed in the replacement PR #12275, commit 89daf97: bash_paths skips lead NAME=value words when filling named, so an assignment-only command gets no entry. PYTHONPATH=/opt/lib pytest -q now gives ('/opt/lib', None) and TMPDIR=/tmp make gives ('/tmp', None). Both are pinned in test_a_later_command_naming_no_rooted_argument_adds_none, and the D=<d>; R=$D/runs; ls -la "$R" and R=$D/x S=$R/y cases still return no None. This thread stays open until this PR closes.

@kyle-sexton kyle-sexton added the do-not-merge Hard merge gate: do not merge while applied. label Nov 2, 2026
@kyle-sexton

Copy link
Copy Markdown
Member

Hold: replaced by #12275 (lanes could not take the shlex merge fix). Releases when: #12275 merges.

@kyle-sexton

Copy link
Copy Markdown
Member

Superseded by #12275, merged.

@kyle-sexton kyle-sexton closed this Nov 2, 2026
@github-actions
github-actions Bot deleted the work-resolve-issue/issue-12156-41374150324-1 branch November 4, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge Hard merge gate: do not merge while applied.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(evals): resolve same-command shell variables in run-validity's Bash paths

1 participant