Skip to content

refactor(scripts): simplify scripts lib helpers without changing behavior (1 of 2) - #14537

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14371-42595284589-1
Nov 9, 2026
Merged

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14371

Summary

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

I ran /simplify's four checks over the 15 listed scripts/lib files and edited the 8 that had something real to fix. The fixes are: merged duplicate case branches and shifts; dropped redundant locals and if/return scaffolding; replaced a tr subprocess with bash's ${var,,}; and stopped a git call from running when an early return makes it unneeded. Outputs, exit codes, stderr text, the GE_* result record and flags are unchanged. The other 7 files (awk-probe.sh, checkout-path.sh, dependabot-entry.sh, manifest-path-guard.sh, markdownlint-config-data.mjs, read-list.sh, report-first-difference.mjs) were already tight, and any further cut would have changed behavior or meant moving code between files, which the issue puts out of scope.

Not verified

  • Tidy pass not run: the change sits under scripts/, a listed shared path for the tidy cutoffs
  • Test suites (scripts/lib/*.test.sh, ci-GH -read.test.sh, changelog-fragments.test.sh, gate-entry.test.sh, fixture-tree.test.sh, generators' --check runs) not executed here: the lane allows only its wrappers; left to the PR's CI
  • ci-status green on the PR: left to the PR's CI
  • Not committed: the lane instructions say to leave changes uncommitted in the working tree for the runner's patch
  • Untracked dotfiles at the checkout root (.bash_profile, .bashrc, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) were already present and are not part of this change; leave them out of the patch

Fix

  • scripts/lib/changed-files.sh: changed_files::into option loop merges --no-renames/--find-renames into one branch (_cf_renames=("$1")) and does one shared shift after esac
  • scripts/lib/changelog-fragments.sh: bump_delivered drops the rc local and if-block; uses [[ == ]] || return 0 and in_mode || return (same 0/1/2 propagation)
  • scripts/lib/ci-GH -read.sh: ci_gh_read::reset removes both directories in one rm -rf
  • scripts/lib/fixture-tree.sh: build replaces the _ft_lib (0/1/auto) + _ft_lib_explicit pair with one _ft_lib state (auto|all|none); same lib-copy outcome for every flag order
  • scripts/lib/gate-entry.sh: fatal shares one exit 2; require_base uses ${2:-default message}; classify uses (($# == 1)) || return 2 style arity checks (GE_REF still set before the usage return); collect_changed is into || fatal; finish maps 0|1 in one branch
  • scripts/lib/marker-block.mjs: syncMarkerBlock checks existing === expected once and picks inSync or unchanged by check; drift path unchanged
  • scripts/lib/pytest-python.sh: resolve computes pwd and the main checkout only after the two early returns, and main_checkout only when SETUP_ENV_VENV is empty
  • scripts/lib/python-probe.sh: require_to lowercases the resolved path with ${var,,} instead of a printf|tr subprocess (file already needs bash 4.3 for local -n)

Verification

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

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

The run reports:

  • check-changelog-fragments: All 3 changelog fragment(s) under .changes/ are valid (no fragment needed: scripts/ is not a plugin in fragment mode)
  • check-changed-skills: no changed skills under plugins/*/skills/, nothing to gate
  • check-affected: 10 passed, 6 skipped over 8 changed files
  • fresh-context review subagent over the whole diff and the callers and *.test.sh suites: no behavior differences, no new ShellCheck warning-level or shfmt problems; it traced every fixture-tree flag order, the gate-entry GE_REF/usage paths, and the bump_delivered callers (all use || rc=$?)
  • git-read diff --numstat HEAD: 8 files, 30 added / 76 removed lines, all under scripts/lib/ (within the 400-line / 15-file limit)
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42595284589

Left out: the items under Not verified.

Related

#14371

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

Lane-Activity: work-resolve-issue/resolve-issue
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

pr-merge's gate refuses its verifier verdict (verify:missing)

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Security review: PR #14537 (refactor of the scripts/lib helpers)

I found no security issues. I read every hunk in all 8 changed files. None of them match a trusted-path glob, and none touches a trust control, the merge-hold scripts, a plugin manifest or a standing instruction.

I checked each refactor for a change in how it fails, because several of these helpers sit behind CI gates:

  • gate-entry.sh
    • fatal still ends in exit 2 on both the subshell and non-subshell paths.
    • require_base with ${2:-…} behaves the same as the old ${2-} plus a -n check. The message is still printed through printf '%s\n', so a ref name is never read as a format string.
    • In classify, (($# == 1)) without the shift checks the same arity as before, and GE_REF is still set before the usage return.
    • collect_changed with into || fatal still exits 2 when into fails.
    • In finish, 0 | 1) exit "$1" returns the same codes, and any other value still exits 2.
  • changelog-fragments.sh: in_mode || return passes on the same 1 or 2 status the old rc code returned.
  • changed-files.sh: the single shift after esac behaves the same for every option. The -- and unknown-option branches still break or return 2 before reaching it.
  • fixture-tree.sh: the three-state _ft_lib (auto, all, none) copies the same libs as the old flag pair for every order of --lib and --no-lib.
  • marker-block.mjs: same exit codes and messages, and it still uses the function replacer (no $-sequence injection).
  • pytest-python.sh: top is now set after the early returns. Only the setup call reads it (L79-L88); find_venv does not.
  • python-probe.sh: lowercasing with ${var,,} instead of printf | tr does not change the WindowsApps check.
  • ci-gh-read.sh: the two rm -rf calls on quoted paths are now one call.

The diff also changes 7 shell libraries from mode 100644 to 100755 (executable). The PR description does not mention this. It has no security impact, but the code-review lane may want to ask about it.

The PR context contains no embedded instructions aimed at this lane.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Code review: PR #14537 (simplify scripts/lib helpers, 1 of 2)

I read the whole diff for all 8 changed files and found no correctness or maintainability problems. I compared each refactor with the code around it at head:

  • changed-files.sh: The -- branch still shifts and then breaks, so it never reaches the new shift after esac. The *) branch returns before it. The merged --no-renames | --find-renames branch passes the same flag on to git.
  • changelog-fragments.sh: A bare return after in_mode ... || returns in_mode's own status, so 1 and 2 are passed on exactly as rc used to pass them.
  • ci-gh-read.sh: rm -rf with two arguments behaves the same as the two separate calls. Neither call's status was checked before.
  • fixture-tree.sh: I checked every flag order against the new auto|all|none state: --lib --no-lib copies no libs, --no-lib --lib copies all libs with no closure, and auto with or without --sut behaves as before. Each case matches the old _ft_lib / _ft_lib_explicit pair. No other line reads _ft_lib.
  • gate-entry.sh: fatal still exits 2 on both paths. ${2:-…} matches the old -n test, which picks the default message when the argument is empty or unset. The arity checks now compare $# before any shift, and nothing after the case reads $@, so the dropped shifts change nothing. collect_changed still returns 0 on success, and finish still maps 0, 1 and everything else as before.
  • marker-block.mjs: Hoisting the equality check gives the same message and exit code for both check values. The drift path is unchanged.
  • pytest-python.sh: top and main were only used after the two early returns. find_venv doesn't read either variable through dynamic scope, since it calls pwd -P and main_checkout itself. main_checkout only runs git rev-parse, so skipping it when SETUP_ENV_VENV is set has no side effect to lose.
  • python-probe.sh: ${var,,} needs bash 4, and the file already needs 4.3 for local -n.

Closing issue #14371, acceptance criteria:

  • Behavior unchanged: met by my reading. The existing scripts/lib/*.test.sh suites cover these helpers. I ran no tests myself: the author's Verification section reports the check-* runs, and those results are author-claimed and unverified.
  • Diff touches only listed files: met. All 8 files are on the issue's list.
  • Within 400 lines / 15 files: met (8 files, about 30 lines added and 76 removed).
  • ci-status green: left to CI; I couldn't observe it from this lane.

Note, not counted as a finding: the diff changes the mode of 7 .sh libs from 100644 to 100755. Several of these files describe themselves as "Sourced, never executed". The pipeline does this on purpose: apply-patch makes every changed .sh file executable (scripts/check-affected.sh#L241-L246). The executable bit does no harm on a sourced lib and is outside the issue's behavior criteria, but a reader of the diff may wonder why it changed.

No plugin manifests changed. The PR context contained no embedded instructions aimed at this lane.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for c70818a

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-14537-c70818aa34e4e52159b2a9485172caea020be76f, expires on 2026-12-09.

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 9, 2026
Merged via the queue into main with commit a41995c Nov 9, 2026
72 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14371-42595284589-1 branch November 9, 2026 11:04
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit a41995c078713d87e8dcb5c76dbef0510d39feab; 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 lib repository script (1 of 2)

0 participants