Skip to content

refactor(rate-limit-guard): simplify hook code without behavior change - #14800

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14706

Summary

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

Simplified two of the three listed rate-limit-guard files without changing behavior. register.tsx gets one resetsMsOf helper in place of four copies of the reset-time parse, reuses DATA_ITEMS as DEFAULT_DATA (the two arrays were identical), computes the toast's short window name once, and fixes two formatting slips. record-rate-limit-stop.sh's rotate_events now cleans up through one if-block instead of an early return followed by a fall-through. check-mod-load.sh is left unchanged: it is already short and direct, and every candidate edit (inlining ROOT, merging the version reads) would have made it less clear or changed its behavior when BASH_SOURCE is a bare filename.

Not verified

  • Test suites (rate-limit-guard.test.ts, record-rate-limit-stop.test.sh, check-mod-load.test.sh) and TypeScript type-checking were not run: this lane's Bash runs only the named wrappers. Left to the PR's CI.
  • Tidy: the code passes ran (simplify, comment triage, residue; no further edits). The markdown passes did not fully run on the changelog fragment. The ai-slop detector could not run because this lane's Bash runs only the named wrappers, and write-for-humans was not invoked because the fragment's one…
  • ci-status green on the PR: left to the PR's CI.

Fix

  • plugins/rate-limit-guard/hooks/register.tsx: added resetsMsOf(limit) and used it in liveWindows, recordCrossings, snapshotBody and statusJson; DEFAULT_DATA = DATA_ITEMS; toastBody computes the short window name once; formatting fixes in sameAccount and writeSnapshot's else
  • plugins/rate-limit-guard/hooks/record-rate-limit-stop.sh: rotate_events cleanup collapsed into one if ! tail ... || ! mv ...; then rm; fi with the same outcomes in every case
  • .changes/rate-limit-guard/work-resolve-issue-issue-14706-42645458919-1-73761b48.md: patch fragment, ### Changed, "Internal simplification, no behavior change."

Verification

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

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

The run reports:

  • check-changelog-fragments: all 6 fragments valid
  • check-changed-skills: no changed skills, nothing to gate
  • check-affected: first run failed shellcheck SC2015 on an a && b || c form in rotate_events; rewrote it as an if-block; re-run 13 passed, 6 skipped, 0 failed
  • fresh-context review subagent: confirmed every change keeps behavior (truth table for rotate_events, type-checking of DEFAULT_DATA and resetsMsOf, toast strings) and found no source-text assertions in rate-limit-guard.test.ts or record-rate-limit-stop.test.sh; its one note (an unconverted…
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42645458919

Left out: the items under Not verified.

Related

#14706

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

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 c59e611cb0568fb3aa77daa520fe7c6bd3e53c04: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #14800 (head c59e611)

I found no security issues in this change.

I read every hunk of all 3 changed files. None of them matches a trusted-path glob, and the diff touches no plugin manifest, workflow, trust control, merge hold or standing instruction.

  • plugins/rate-limit-guard/hooks/record-rate-limit-stop.sh: rotate_events now cleans up through if ! tail … || ! mv …; then rm -f "$tmp"; fi. This has the same outcomes as the base's "return on success, else rm" form in all three cases (tail fails, mv fails, both succeed). The variables are still quoted and the temp-file handling is unchanged, so no new path or injection surface appears.
  • plugins/rate-limit-guard/hooks/register.tsx: four copies of the reset-time parse become one resetsMsOf helper. statusJson went from Date.parse(l.resetsAt ?? '') to resetsMsOf(l), and both give NaN for a missing resetsAt, so the <= now filter behaves the same. The other edits are formatting and computing the toast's short window name once. DEFAULT_DATA now aliases DATA_ITEMS; that matters only if one of them were mutated, which is a correctness question for the code-review lane, not a security one. No data reaches a new sink.
  • .changes/…-73761b48.md: a changelog fragment only.

The PR context holds no embedded directives.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Code review: PR #14800, refactor(rate-limit-guard): simplify hook code without behavior change

No findings. I read every hunk of all 3 changed files and checked each edit for a change in behavior.

plugins/rate-limit-guard/hooks/record-rate-limit-stop.sh (rotate_events)

  • Old flow: if tail && mv; then return 0; fi; rm; return 0.
  • New flow: if ! tail || ! mv; then rm; fi; return 0.
  • The two match in every case:
    • If tail fails, or the redirect can't create the temp file, mv is skipped and the temp is removed.
    • If tail succeeds and mv fails, the temp is removed.
    • If both succeed, nothing is removed.
  • The function returns 0 every time, as before.

plugins/rate-limit-guard/hooks/register.tsx

  • resetsMsOf gives NaN when resetsAt is undefined, and otherwise Date.parse(resetsAt). That is the same as the three inline copies it replaces. The fourth copy, in statusJson, used Date.parse(l.resetsAt ?? ''). Date.parse('') is also NaN, so !(resetsMsOf(l) <= now) gives the same result there too.
  • DEFAULT_DATA = DATA_ITEMS makes the two names share one array, which only matters if something changes the array in place. Nothing does: the only uses are at lines 113, 117 and 119, and they call .includes, .join and new Set(...), which only read it.
  • toastBody now works out the short window name once. The strings it builds are the same as before.
  • Other edits: the spacing fix in sameAccount and the } else fix in writeSnapshot only change formatting.

Closing issue #14706, acceptance criteria

  • Behavior unchanged: met, by my reading of the code above. I didn't run anything. The PR says the tests and type-check were not run in its own lane and leaves them to CI.
  • Only the listed files and changelog fragments edited: met. check-mod-load.sh was left alone, and the PR body says why.
  • Under 400 lines and 15 files: met.
  • Patch fragment with ### Changed and "Internal simplification, no behavior change.": met.
  • ci-status green: I can't check this from the lane. The PR's verification results are the author's own claims, and I did not confirm them.
  • Tests: the current suites (rate-limit-guard.test.ts, record-rate-limit-stop.test.sh) already cover the behavior these refactors must keep, so a regression would show up in CI. No new test is needed for a change that keeps behavior the same.

Path-scoped rules

  • .claude/rules/mod-authoring.md applies to plugins/*/hooks/**. This PR adds no new mod API use and no change to how hooks.json loads modules, so the rule raises nothing.

Other notes

  • No plugin manifest changed, so there are no manifest lines.
  • There were no prior findings and no settled threads.
  • I found no embedded instructions in the PR context.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for c59e611

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-14800-c59e611cb0568fb3aa77daa520fe7c6bd3e53c04, 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 c7554d0 Nov 9, 2026
56 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14706-42645458919-1 branch November 9, 2026 19:00
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

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

File Killed Survived Timeout No coverage Invalid Not run
plugins/rate-limit-guard/hooks/record-rate-limit-stop.sh 1 1 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/rate-limit-guard/hooks/record-rate-limit-stop.sh:111 SBR 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 c7554d0bd61359bae10e37f3375bd166494c248f; 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 hooks and scripts rate-limit-guard plugin code

0 participants