Skip to content

refactor(instruction-placement): simplify detect, glob-tools and precompute scripts without behavior change - #15229

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14590-42939071058-1
Nov 11, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14590-42939071058-1

Conversation

@melodic-automation-lanes

@melodic-automation-lanes melodic-automation-lanes Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #14590

Summary

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

Applied small behavior-preserving simplifications to the instruction-placement scripts: glob-tools.sh flattens the nested bracket/brace/budget status branch into one if/elif/else, drops an always-true array-length guard, iterates CLI globs by index instead of a hand-kept counter, and replaces a one-arm case with [[ ]]; detect.sh stops the identity section search at the first match (section starts are unique line numbers) and declares RULE_COUNT beside the loop that counts it; precompute.sh drops a no-op || true whose status was never read. quote-check.sh was reviewed and left unchanged: the only candidate ($(<file) for $(cat file)) changed stderr wording on an unreadable file, so it was reverted.

Not verified

  • The plugin's *.test.sh suites (detect.test.sh, glob-tools.test.sh, precompute.test.sh, quote-check.test.sh) were not executed: this lane cannot run bash or interpreters directly; left to the PR's CI
  • ci-status green is a PR check, left to the PR's CI
  • tidy: markdown passes (write-for-humans, ai-slop fix) skipped for the changelog fragment, whose single line is fixed verbatim by the issue's acceptance criteria
  • verify step (build/tests) not run locally for the reason above; checks step covered by check-affected

Fix

  • plugins/instruction-placement/scripts/glob-tools.sh: if/elif/else status branch, dropped redundant expansions-length guard, index loop over CLI_GLOBS, [[ ]] in place of a one-arm case, case "$1" after the argc guard
  • plugins/instruction-placement/scripts/detect.sh: emit_identity breaks on the first matching section start; RULE_COUNT=0 moved next to the rule-inventory loop
  • plugins/instruction-placement/scripts/precompute.sh: removed a no-op || true in branch()
  • .changes/instruction-placement/work-resolve-issue-issue-14590-42939071058-1-75321466.md: patch fragment, ### Changed, 'Internal simplification, no behavior change.'

Verification

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

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

The run reports:

  • check-changelog-fragments: all 10 fragments valid
  • check-changed-skills: no changed skills, nothing to gate
  • check-affected: 13 passed, 6 skipped (typos not installed; validate-plugins steps that run checked-tree code; ruff and changed-skills not applicable), rest CI-only
  • fresh-context review subagent over the whole diff: every hunk behavior-preserving under bash 3.2 and 5; its one low finding (stderr wording of $(<file) in quote-check.sh) was fixed by reverting that hunk
  • tidy-diff over the changed lines: no edits needed; comments in the touched glob-tools.sh lines state constraints and were kept
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42939071058

Left out: the items under Not verified.

Related

#14590

Merge-Risk: max=MEDIUM demote=false head=c895f3b3bed4b1b3ac1a41f25e4f1845aa075829 rubric=8.4.1 rater=claude-opus-5-5 checker=claude-opus-5-5

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

Copy link
Copy Markdown
Contributor

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

Security review: PR #15229, no security issues found

I read every hunk of all 4 changed files. None of them adds or widens a security surface.

  • plugins/instruction-placement/scripts/detect.sh: emit_identity now stops at the first matching section start, using ((starts[i] == want)) where it used [[ -eq ]]. RULE_COUNT=0 moves down next to the loop that counts rules. The arithmetic only sees values the script parsed itself (section start line numbers, and ID_START, which was already forced to base 10 with 10#). Nothing new reaches the shell from outside.

  • plugins/instruction-placement/scripts/glob-tools.sh: the changes are:

    • the nested status branch is flattened into one if/elif/else;
    • an array-length guard is dropped;
    • CLI globs are looped by index ("${!CLI_GLOBS[@]}");
    • a one-arm case becomes [[ == ]];
    • case "${1:-}" becomes case "$1".

    User-supplied glob patterns are still quoted everywhere and still go through brackets_valid and expand_braces. The expansion budget (MAX_EXPANDED) is still checked before any matching. The path prefix still reaches awk through ENVIRON rather than -v, so awk escape processing still can't touch it. No guard on untrusted input was removed.

  • plugins/instruction-placement/scripts/precompute.sh: removing || true from branch() changes only the exit status. It has no security effect.

  • .changes/...md: a changelog fragment, prose only.

There is no trust control, manifest, workflow, token, or instruction-surface change in this diff, and no changed file matches a trusted-path glob. The PR context contains no embedded directives aimed at the lane. There are no prior findings from this lane (blocking only: no), so this is a full review.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: no findings

I read every hunk of the 4 changed files. I found no correctness or maintainability problems. Every edit keeps behavior the same, which is what #14590 asks for.

What I checked, file by file (by reading the code; I did not run anything):

  • glob-tools.sh
    • case "$1" without :-: this is safe under set -u. The [[ $# -eq 0 ]] guard just before it at L298 exits first when there are no arguments.
    • Loop over "${!CLI_GLOBS[@]}": the array is never empty here, because validate dies earlier on zero --glob (L351). It is built only with +=, so the indices are 0..n-1, the same as the old hand-kept counter. That keeps the BUDGET_KEYS values unchanged.
    • Flattened if/elif/else: in the old code the match-count block was reached after a failed expand_braces only with status=over-budget, so it was skipped. The new code doesn't reach it at all in that case, which gives the same result.
    • Dropped ${#expansions[@]} -gt 0 guard: this check was always true. expansions is reset for each pattern (L416). A <<< here-string always gives read at least one line, so the array has at least one element whenever this branch runs. That also means "${expansions[@]}" cannot trip set -u on bash 3.2.
    • One-arm case replaced with [[ == */.claude/rules/* ]]: both use the same glob semantics.
  • detect.sh
    • ((starts[i] == want)) with break: section starts are line numbers taken from the file-facts sweep, so they are unique. Stopping at the first match picks the same index the old last-match loop did. Both forms evaluate the values arithmetically, including an empty value as 0.
    • Moving RULE_COUNT=0: nothing reads it before its new spot at L533. Its only uses are at L546 and L554, and the identity path exits at L519 without touching it.
  • precompute.sh
    • Removed || true in branch(): the script runs set -uo pipefail without -e. branch() is only called inside $(...) in printf arguments (L113, L127), and its exit status is never read. Output is unchanged.

Closing issue #14590, acceptance criteria:

  • Behavior unchanged: met, by the reasoning above. The plugin's existing *.test.sh suites cover these scripts. I did not run them, and the PR says they were not run either; they are left to CI.
  • Only the listed files and fragments are edited: met. quote-check.sh is listed but left untouched, and the PR body explains why.
  • Within 400 lines and 15 files: met.
  • ci-status green: not verifiable from here; it is a PR check.
  • Changelog fragment: met. It has bump: patch, a ### Changed heading, and the exact line "Internal simplification, no behavior change."

The verification results in the PR body come from the author's lane run, and I have not confirmed them myself. No plugin manifest changed, so the manifest checks don't apply. Nothing in the PR context was addressed to this lane.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head c895f3b3bed4b1b3ac1a41f25e4f1845aa075829, the head its arming checks judged.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for c895f3b

The verifier passed this head. The capture artifact holds the capture summary, which says whether the capture ran, and any screenshot or video that passed the mask check; this comment uploads no file.

Capture artifact: pr-capture-15229-c895f3b3bed4b1b3ac1a41f25e4f1845aa075829, expires on 2026-12-11.

One comment per pull request, updated in place for each new head.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit 5fb798f Nov 11, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14590-42939071058-1 branch November 11, 2026 03:05
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 5fb798f5d5fce5b783df0504417b579e9ae23645; later checks count it verified from this comment.

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.

Simplify the scripts instruction-placement plugin code

0 participants