Skip to content

refactor(performance): simplify the scripts and climb plugin code - #15029

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14666

Summary

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

Behavior-preserving simplification of the performance plugin scripts. pathfix.py now builds its path spellings with a lazy generator, so cygpath runs only after the cheaper spellings fail, as the module's own docstrings already said. ratio.py and summarize.py type fail() as NoReturn, which removes the unreachable raise lines and the no-op value or "". ratchet.py dispatches subcommands through argparse set_defaults instead of a second name-to-handler table. The two census shell scripts drop a header usage block that repeated usage() word for word. Left unchanged: resolve-python.sh (already minimal), test-helpers.sh (a per-plugin copy kept on purpose under docs/contracts/shell-test-helpers), untracked-cache-probe.sh and climb_log.py (no simplification found that keeps behavior identical). A review rewrite of ratio.py's disagreement loop was reverted, because max() would pick a NaN spread differently than the original loop.

Not verified

  • The performance and toolchain *.test.sh suites (pathfix.test.sh, ratchet tests, run-spawn-census.test.sh, spawn-census.test.sh) and ruff were not run here, because this lane cannot run an interpreter or test runner. Left to the PR's CI.
  • ci-status green: left to the PR's CI.
  • Tidy not run: the change spans 2 areas (plugins/performance and plugins/toolchain via the regenerated shared copy), above the 1-area tidy cutoff.
  • Known edge cases from review, accepted as part of the efficiency fix. On native Windows, when the MSYS-to-native spelling exists, cygpath is no longer called, so a UnicodeDecodeError cygpath could raise on undecodable output no longer escapes. With an empty path and a deleted working directory on…
  • Untracked root dotfiles (.bashrc, .bash_profile, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) show in git status. This run did not create them; they look like sandbox mount points, so they were left alone and are not part of this change.

Fix

  • plugins/performance/scripts/pathfix.py: new spellings() generator; tried() is built from it, and resolve_existing() walks it lazily, so cygpath is not called when the MSYS-to-native spelling already exists
  • plugins/performance/scripts/ratio.py: fail() typed NoReturn; removed the two unreachable raise lines and value or "" in env()
  • plugins/performance/scripts/summarize.py: fail() typed NoReturn; removed the unreachable raise and value or "" in env()
  • plugins/performance/scripts/ratchet.py: subcommand handlers bound with set_defaults(handler=...) in the parser loop instead of a second lookup table; tighten_per_file names the over-ceiling test once
  • plugins/performance/scripts/run-spawn-census.sh: header usage block that repeated usage() replaced with a pointer to it
  • plugins/performance/scripts/spawn-census.sh: header usage/output/exit block that repeated usage() replaced with a pointer to it
  • plugins/toolchain/skills/ratchet/scripts/ratchet.py: regenerated shared copy of performance's ratchet.py (sync-shared-copies)
  • .changes/performance/work-resolve-issue-issue-14666-42778871893-1-e1b57950.md: patch fragment, ### Changed, Internal simplification, no behavior change.
  • .changes/toolchain/work-resolve-issue-issue-14666-42778871893-1-8116375c.md: patch fragment for the regenerated ratchet.py copy, same body

Verification

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

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

The run reports:

  • sync-shared-copies: regenerated plugins/toolchain/skills/ratchet/scripts/ratchet.py, then a second run after the last edit, exit 0
  • check-changelog-fragments: all 5 fragments valid
  • check-changed-skills: toolchain ratchet skill PASS, 0 errors (1 existing warning about SKILL.md body length, which this change did not touch)
  • check-affected: first run failed with MISSING FRAGMENT for plugins/toolchain; after adding the toolchain fragment, 14 passed, 5 skipped, 0 failed over 9 changed files
  • fresh-context review subagent over the full diff: found no change in normal use; two edge cases (NaN spread selection in ratio.py, a redundant second stat of the literal path in pathfix.py) were fixed, and the remaining edge cases are noted in not_done
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42778871893

Left out: the items under Not verified.

Related

#14666

Merge-Risk: max=MEDIUM demote=false head=df92c8db61afc46dc657192a22ee3b4ac0b3828c rubric=8.3.3 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 df92c8db61afc46dc657192a22ee3b4ac0b3828c: read 9 of 9 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15029 (head df92c8d)

No security issues found. This was a full first review, not blocking-only: the prior-findings file lists 0 earlier heads.

I read every hunk of every changed file. The toolchain changelog fragment is an exact copy of the performance fragment, so only the first one counts as read. Neither fragment's path is special: both sit under .changes/ as changelog data.

What I checked:

  • plugins/performance/scripts/pathfix.py: tried() now delegates to a lazy spellings() generator, and resolve_existing() walks it. Nothing new reaches cygpath_native's subprocess call: it still gets the same value as before and only runs later in the walk. No shell, and no new source of input.
  • ratchet.py (performance and its regenerated toolchain copy): each subcommand now picks its handler through set_defaults(handler=...). The handlers are a fixed table in the code, and argparse only accepts the three registered subcommands, so no user value can choose which function runs. The over variable is a pure refactor.
  • ratio.py / summarize.py: fail() is now typed NoReturn, and the unreachable raise lines and the value or "" fallbacks are gone. fail() still raises SystemExit(2), so the fail-closed paths behave the same.
  • run-spawn-census.sh / spawn-census.sh: only header comments are deleted, and they repeated usage(). These are script comments, not instructions an agent follows, and no rule or control is removed.

None of the changed files matches a trusted-path glob. There are no trust-control, token-scope, kill-switch, merge-hold or plugin-manifest changes. The PR context has no embedded instructions aimed at this lane.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: PR #15029, simplify the performance plugin scripts (closes #14666)

Findings: none. I read every hunk in the 8 distinct changed files. The toolchain changelog fragment is a byte-identical copy of the performance fragment, so I read it once.

What I checked

  • pathfix.py: the new spellings() generator yields the same candidates in the same order as the old tried(). The one difference is that cygpath now runs only when its spelling is actually needed, which is what the module's docstrings already said.
    • resolve_existing() replaces the old tried(value)[1:] with if candidate == value: continue, so it skips the literal spelling the same way.
    • Empty candidates still can't match: msys_to_native and native_to_msys return the input unchanged when it isn't converted, so a non-matching spelling equals value and is skipped.
    • A spelling repeated after the old de-duplication was removed only costs one extra exists() call.
    • The two Windows-only edge cases the PR body lists are real and are accepted there: a UnicodeDecodeError from cygpath no longer escapes when the MSYS spelling exists, and an empty path behaves differently when the working directory has been deleted. Neither reaches the POSIX path.
  • ratio.py / summarize.py: changing fail() to NoReturn is right, because it always raises SystemExit(2). So the removed raise lines were unreachable, and value or "" did nothing once the None branch had already called fail(). Outputs and exit codes stay the same.
  • Both copies of ratchet.py: set_defaults(handler=...) dispatches to the same three handlers. No argument uses handler as its name, and nothing reads vars(args). Using the over variable leaves the ABOVE and changed branches doing exactly what they did. The toolchain copy matches the performance one hunk for hunk, which fits its regeneration by sync-shared-copies.
  • run-spawn-census.sh / spawn-census.sh: the removed header blocks say the same as usage() (checked at head: options, output line and exit codes). The new pointer line follows the convention ab.sh already uses, and no test reads the header comments.
  • Changelog fragments: both are bump: patch with the body the issue requires (### Changed / "Internal simplification, no behavior change."). A patch bump fits a change that keeps behavior the same. No plugin manifest changed.

Closing issue #14666 acceptance criteria

  • Behavior unchanged: met on review, apart from the edge cases the PR lists. The existing pathfix.test.sh and ratchet/census *.test.sh suites cover it. I couldn't run them (no shell here). The PR body says they weren't run in the lane either, so that's left to CI.
  • The diff edits only the listed files, test lines and fragments: met. The only other file is the generated toolchain ratchet.py copy, which the issue asks for.
  • Within 400 changed lines and 15 hand-edited files: met.
  • ci-status green: depends on CI; I couldn't check it.
  • Fragments per touched plugin and sync-shared-copies.sh run: met as far as the diff shows. The PR body also reports running the checks, but I haven't verified that claim myself.

No instructions to the review lane appear in the PR body or the issue.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for df92c8d

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-15029-df92c8db61afc46dc657192a22ee3b4ac0b3828c, expires on 2026-12-10.

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 10, 2026
Merged via the queue into main with commit e83ef7f Nov 10, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14666-42778871893-1 branch November 10, 2026 08:54
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 2, survived 5, timeout 0, no coverage 0, invalid 0, not run 0.
Covered-code score 29%; mutation score 29%.

File Killed Survived Timeout No coverage Invalid Not run
plugins/performance/scripts/pathfix.py 0 2 0 0 0 0
plugins/performance/scripts/ratchet.py 1 1 0 0 0 0
plugins/performance/scripts/ratio.py 1 0 0 0 0 0
plugins/toolchain/skills/ratchet/scripts/ratchet.py 0 2 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/performance/scripts/pathfix.py:135 ROR productive input-gap
plugins/performance/scripts/pathfix.py:113 SBR productive no-assertion
plugins/performance/scripts/ratchet.py:347 ROR productive input-gap
plugins/toolchain/skills/ratchet/scripts/ratchet.py:350 LCR unclassified none
plugins/toolchain/skills/ratchet/scripts/ratchet.py:352 UOI productive input-gap

The run's summary has the full report.

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 and climb performance plugin code

0 participants