Skip to content

refactor(source-control): simplify landed-work, reap and test-helper scripts - #14910

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14829-42724608651-1
Nov 10, 2026
Merged

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14829

Summary

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

Simplified four of the six listed source-control scripts without changing their outputs, exit codes, flags or function names. Repeated blocks became small private helpers: test-helpers.sh routes every FAIL line through one _fail_with, landed-work.sh gains add_reason, push_counts and push_unprobed_row and a table-driven inprogress_of, reap-orphaned-plugin-records.sh runs both helper steps through one run_helper, and both reap scripts compute the Windows-shell check once instead of forking uname per call. scope-resolve.sh is left unchanged because it is a registered byte-identical copy of plugins/repo-fleet-hygiene/scripts/scope-resolve.sh (scripts/cross-plugin-source-registry.txt), so editing it alone would fail the drift check and editing both would touch another plugin. resolve-version-bump-conflict.sh is left unchanged because its only candidate rewrite (sed in place of a read loop) trips shellcheck SC2001, and the file is already terse.

Not verified

  • scope-resolve.sh not simplified: it is a registered byte-identical shared copy whose canonical file lives in plugins/repo-fleet-hygiene, outside this issue's file list and the lane's one-area limit.
  • check-affected's output does not name which *.test.sh suites it ran, so whether landed-work.test.sh, the reap suites and the suites sourcing test-helpers.sh ran here is unconfirmed; left to the PR's CI.
  • Tidy pass 5 (ai-slop:audit fix) could not run detect.sh or digest-guard.sh, because the lane allows only named wrappers; the one-line fragment was read by hand against the catalog instead. Its text is fixed by the issue.
  • Untracked runner files at the checkout root (.bash_profile, .bashrc, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) are not part of this change and were left untouched; they should be excluded from the patch.
  • ci-status green is a PR CI check, not run here.

Fix

  • plugins/source-control/scripts/test-helpers.sh: new private fail_with <label> <detail> counts and prints each FAIL line; fail and every assert* failure branch use it with byte-identical text (printf -v for the %q forms); assert_silent tests ${output//[[:space:]]/} in place of the…
  • plugins/source-control/scripts/landed-work.sh: inprogress_of maps state files to labels with NAME:label pairs instead of a case; add_reason replaces seven copies of the L_REASON append in merged_pr_proof; push_counts and push_unprobed_row replace the repeated R_* appends for not-git, bare and…
  • plugins/source-control/scripts/reap-orphaned-plugin-records.sh: run_helper replaces the duplicated dry-run and real reap blocks; one_line replaces two copies of the tr line-joining pipeline; the Windows-shell check is computed once at start.
  • plugins/source-control/scripts/reap-project-plugin-records.sh: is_windows_shell (one uname fork per norm_path call) becomes a windows_shell variable computed once; refuse_main_tree replaces the two copies of the main-worktree refusal; a comment now points at list_ids instead of 'above'.
  • .changes/source-control/work-resolve-issue-issue-14829-42724608651-1-2f6e7766.md: patch fragment, ### Changed, 'Internal simplification, no behavior change.'

Verification

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

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

The run reports:

  • check-changelog-fragments: all 20 fragments valid (run before and after tidy).
  • check-changed-skills: no changed skills, nothing to gate.
  • check-affected: first run failed shellcheck SC2001 on a sed rewrite in resolve-version-bump-conflict.sh; reverted that edit; re-run reported 13 passed, 6 skipped over 5 changed files, shellcheck clean.
  • Fresh-context review subagent over the full diff: no behavior differences found (checked FAIL-line bytes, assert_silent equivalence, run_helper exit and argument order, refuse_main_tree under set -uo, one R_* entry per target with the same values, name collisions in callers).
  • Tidy (code-tidying:tidy-diff) over all 43 changed hunks: no edits needed; passes 1-4 found nothing, pass 5 ran as a manual rubric read.
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42724608651

Left out: the items under Not verified.

Related

#14829

Merge-Risk: unrated reason=no-rating

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

Copy link
Copy Markdown
Contributor

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

Security review: PR #14910 (head d8974ec)

I found no security issues. I read every hunk of all 5 changed files. None of them matches a trusted-path glob, and none touches a plugin manifest, a workflow, a trust control or a standing instruction surface.

Destructive and safety paths I checked:

  • reap-project-plugin-records.sh, main-worktree refusal. The two inline refusals became refuse_main_tree, and the first check is now the one-liner [[ -d "$arg_native/.git" ]] && refuse_main_tree .... The function always runs exit 2. The script runs under set -uo pipefail (line 67), not set -e, so the && form behaves the same as the old if block. arg_native is assigned before the function is called. A main checkout is still refused before the directory change, as before.
  • reap-project-plugin-records.sh, Windows check. windows_shell is set unconditionally at top level (line 127), before the first norm_path call (line 199), so the environment cannot preset it. Case folding of the comparison key is unchanged.
  • reap-orphaned-plugin-records.sh, run_helper. It keeps the argument order (--worktree-path "$path" [--dry-run]). It also keeps exit-on-failure: exit 1 inside a function called in the current shell still stops the script. So the dry-run gate still runs before the real reap and before rm -rf -- "$path/.claude". strip_trailing_separators still keeps a trailing backslash off Windows, and windows_shell is set before the path loop.
  • landed-work.sh. These are reporting-only refactors (add_reason, push_counts, push_unprobed_row, and a lookup table in inprogress_of). Each row still gets the same values, and no new input reaches a command.
  • test-helpers.sh. This is test output formatting. The %q forms still go through printf -v, and assert_silent gives the same pass/fail result. The file's mode changes from 644 to 755. That is not a security concern for a test helper that is sourced, not run.
  • Changelog fragment. Prose only.

Nothing in the PR description or context asks the lane to pass the PR, skip a check or drop a finding. This is a first review (earlier heads reviewed: 0), so the blocking-only rule did not apply.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: PR #14910 (refactor(source-control): simplify landed-work, reap and test-helper scripts)

I found nothing to block or flag. I read all five changed files in full in .claude-lane/pr.diff. I also read the unchanged code that the new helpers touch: reap-orphaned-plugin-records.sh at head, the list_ids and set lines in reap-project-plugin-records.sh, the L_REASON writers in landed-work.sh, and the reap-orphaned test suite.

Checks that each refactor behaves the same as before (I traced each one by reading. I ran nothing, so the test results below are what the author reports, not something I confirmed):

  • landed-work.sh inprogress_of. The NAME:label pairs give the same results as the old case: ${pair%%:*} and ${pair#*:} split the names correctly, including CHERRY_PICK_HEAD:cherry-pick.
  • landed-work.sh row pushes.
    • The not-git row from push_unprobed_row holds the same values as before: notgit=yes, bare=no, unpushed/landed=?, method=none, base empty, inprogress=?, every count ?, and the same reason.
    • The bare row is also the same. R_NOTGIT+=("no") now sits after the bare check, and nothing between the old and new spot reads R_NOTGIT or continues. Each target still adds exactly one entry to every R_* array.
  • landed-work.sh add_reason. It changes the caller's L_REASON the same way the inline appends did.
  • reap-orphaned-plugin-records.sh run_helper.
    • It calls the helper with the same arguments in the same order and prints the same <step>: ok line.
    • It fails at the same point: fail_path, then exit 1.
    • out and rc are now local, and nothing after the reap steps reads them.
    • An empty "$@" under set -u is safe, even on bash 3.2.
  • reap-orphaned-plugin-records.sh windows_shell. The variable is set before strip_trailing_separators is defined and before the loop runs.
  • reap-project-plugin-records.sh refuse_main_tree. It prints the same two lines and exits 2. The [[ … ]] && refuse_main_tree … form is safe under set -uo pipefail.
  • reap-project-plugin-records.sh is_windows_shell. No other file in plugins/source-control called it, so removing it breaks nothing. The comment now points at list_ids, which does contain the join("\t") it refers to.
  • test-helpers.sh _fail_with. Every FAIL line keeps its exact text, using printf -v for the %q forms. The new assert_silent check (${output//[[:space:]]/}) is equivalent to the old trim-then-check-empty.

Acceptance criteria from #14829:

  • Behavior unchanged: met by my reading. Existing suites cover the changed paths, including the reap-orphaned failure at the reap step (failed at reap, reap-orphaned-plugin-records.test.sh#L140) and the main-tree refusals in reap-project-plugin-records.test.sh.
  • Only listed files and fragments edited: met.
  • Size limits: met, at 5 files and about 200 changed lines.
  • Fragment: met. It is bump: patch with ### Changed and the required line.
  • ci-status green: not something this lane can check.

The author explains why scope-resolve.sh and resolve-version-bump-conflict.sh were left alone. I have not confirmed that explanation.

Note, not counted as a finding: plugins/source-control/scripts/test-helpers.sh changes mode from 100644 to 100755, but its header says "Sourced, not executed" and it has no #! line. The issue lane's patch step (CHECK_AFFECTED_SCRIPT_EXEC_BIT, which makes every changed .sh executable) appears to cause this. It has no effect at runtime, but the PR description doesn't mention it.

Other notes:

  • No plugin manifest changed, so the manifest checks did not apply. No paved-path or settled-thread inputs applied.
  • None of the changed files matches a trusted-path glob.
  • No text in the PR context tried to give instructions to this lane.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit dd6a916 Nov 10, 2026
66 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14829-42724608651-1 branch November 10, 2026 03:55
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 4, survived 2, timeout 0, no coverage 0, invalid 0, not run 1.
Covered-code score 67%; mutation score 67%.

File Killed Survived Timeout No coverage Invalid Not run
plugins/source-control/scripts/landed-work.sh 2 1 0 0 0 0
plugins/source-control/scripts/reap-orphaned-plugin-records.sh 1 0 0 0 0 0
plugins/source-control/scripts/reap-project-plugin-records.sh 1 1 0 0 0 0
plugins/source-control/scripts/test-helpers.sh 0 0 0 0 0 1

Surviving mutants

Location Operator Disposition Cause
plugins/source-control/scripts/landed-work.sh:744 other productive no-assertion
plugins/source-control/scripts/reap-project-plugin-records.sh:152 ROR productive input-gap

The run's summary has the full report.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit dd6a9164f5b84d2c088e41e134b1ae765f5ffdf1; 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 source-control plugin code (2 of 3)

0 participants