Skip to content

refactor(kindle-dedrm): simplify manage scripts without behavior change - #15238

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14595-42939101283-1
Nov 11, 2026
Merged

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14595

Summary

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

Simplified six of the seven kindle-dedrm manage scripts without changing behavior. Repeated path literals now have named variables. lock-updates.sh routes its four icacls calls through one helper that builds the same command strings, cleanup.sh's two mode filters are merged into one case statement, and status.sh looks up the firewall rule once instead of twice. Two branches were flattened (verify_sha in check-drift.sh, the check action in firewall.ps1). sync-prep.sh was left as is because it holds only print statements and a dry-run guard, and none of the four checks found anything to change in it. pin(), firewall.ps1's $RuleName line and its $rule.Enabled guards were kept as they were because the tests pin their shape.

Not verified

  • Did not run the shell test suites (check-drift.test.sh, sync-prep.test.sh) or the Pester suite firewall.Tests.ps1, because this lane runs only the named wrappers. Left to the PR's CI.
  • Did not run the scripts themselves: they need Windows (LOCALAPPDATA, powershell.exe, icacls, NetSecurity). The no-behavior-change claim rests on reading the code and on the review subagent.
  • Tidy only partly ran. Passes 1-3 ran over the code lines and changed nothing. Passes 4-5 (docs-hygiene and ai-slop on markdown) were skipped because the only markdown is the changelog fragment, whose wording the issue sets word for word.
  • ci-status green is an acceptance criterion that only the PR's CI can show
  • The working tree has untracked dotfiles that this run did not create or change (.bash_profile, .bashrc, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc). They should not go into the patch.

Fix

  • plugins/kindle-dedrm/skills/manage/scripts/check-drift.sh: verify_sha returns early when the file is absent instead of nesting the comparison in an if/else
  • plugins/kindle-dedrm/skills/manage/scripts/cleanup.sh: ask_yn's two per-mode case blocks merged into one case on MODE:prompt; CACHED_INSTALLER, KFC_DOWNLOAD and DEDRM_JSON name paths that were spelled out 3-4 times each
  • plugins/kindle-dedrm/skills/manage/scripts/firewall.ps1: check action tests Show-State directly instead of through a temporary variable; comment updated to match
  • plugins/kindle-dedrm/skills/manage/scripts/lock-updates.sh: icacls_updates helper replaces four inline powershell.exe icacls calls (same command strings); CACHED_INSTALLER and TEST_WRITE name repeated paths; redundant return 0 and an else around exit removed
  • plugins/kindle-dedrm/skills/manage/scripts/status.sh: probe_firewall_rule makes one Get-NetFirewallRule lookup instead of two; probe_key_finder drops a -d check that the -f test already implies; probe_cached_installer names its path once
  • plugins/kindle-dedrm/skills/manage/scripts/sync-finalize.sh: CACHED_INSTALLER names the installer path used four times
  • .changes/kindle-dedrm/work-resolve-issue-issue-14595-42939101283-1-6371c63d.md: patch fragment, ### Changed, 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against 0d2beb9:

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

The run reports:

  • check-changelog-fragments: all 10 fragments valid (run before and after tidy)
  • check-changed-skills: CHECK-SKILL manage PASS, 0 errors, 3 warnings about the existing SKILL.md (description length, body length, no Gotchas), none from this change
  • check-affected: 13 passed, 6 skipped over 7 changed files (run before and after tidy)
  • fresh-context review subagent over the whole diff, read-only: no behavior change found in any hunk, including the icacls command strings built with ${1:+ $1}, the MODE:prompt case patterns, ensure_dir's return status and the Show-State condition. Its only note was a race in the old code: a rule…
  • manual read of the tests that pin these files: check-drift.test.sh extracts pin() unchanged; firewall.Tests.ps1 reads the enable/disable $rule.Enabled guards and the check output, all unchanged; sync-prep.test.sh greps firewall.ps1's RuleName line, unchanged
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42939101283

Left out: the items under Not verified.

Related

#14595

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

Security review: PR #15238 (kindle-dedrm manage scripts refactor)

No security issues found.

I read every hunk of all 7 changed files. None of them match a trusted-path glob. None is a plugin manifest, a workflow, a trust control or an instruction surface. The changes are limited to the user-local Windows helper scripts under plugins/kindle-dedrm/skills/manage/scripts/ and one changelog fragment.

What I checked:

  • lock-updates.sh: The new icacls_updates helper builds icacls '${UPDATES_DIR_WIN}'${1:+ $1}, which gives the same command strings as the four inline calls it replaces. Every call site passes a fixed literal or one built from the same TRUSTEE/LOCALAPPDATA environment values as before, so it adds no new interpolation or injection surface. CACHED_INSTALLER and TEST_WRITE are defined after UPDATES_DIR_BASH (head lines 15, 20 and 21), so rm -f still targets the same paths. ensure_dir no longer ends in an explicit return 0, but its status is unchanged: when the directory exists, the if returns 0. The deny check still fails closed: exit 1 when the test write succeeds, and the "verified" message is printed only after that check.
  • cleanup.sh: The merged case "${MODE}:${prompt}" keeps the same soft/full skip patterns, so the "Calibre Library is never deleted" guard in full mode still holds. The new path variables are defined after the directories they build on (lines 33–37), so the rm targets are unchanged.
  • status.sh: The firewall probe now makes one Get-NetFirewallRule lookup. $rule is escaped so bash does not expand it, and FIREWALL_RULE_NAME is interpolated exactly as before. Dropping the -d check is safe because the -f test on a file inside the directory already implies it.
  • check-drift.sh, firewall.ps1, sync-finalize.sh: These only reorder control flow or rename variables. The SHA verification, the exit codes and the delete-then-verify step behave as before.

The PR context contains no embedded instructions aimed at the review lane. Prior findings: none, and this is not a blocking-only review.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: PR #15238 (refactor(kindle-dedrm): simplify manage scripts)

I read every hunk of all 7 changed files. I also read the head versions of cleanup.sh, lock-updates.sh and status.sh, the relevant parts of check-drift.sh and firewall.ps1, and listed the plugin's test files. No blocking findings.

Behavior-equivalence check (my own reading; I did not run anything)

  • check-drift.sh verify_sha: a bare return after note keeps the status the function returned before. The script runs set -uo pipefail without -e, so declaring actual with local up front changes nothing.
  • cleanup.sh ask_yn: each soft:*"…"* and full:*"Calibre Library"* pattern on ${MODE}:${prompt} matches exactly when the old two-step check (mode test, then substring) did. MODE can only be confirm, soft or full, so it never holds a :. CACHED_INSTALLER, KFC_DOWNLOAD and DEDRM_JSON are set after the directories they use (cleanup.sh:38-40).
  • lock-updates.sh:
    • icacls_updates with ${1:+ $1} builds the same -Command strings for /deny and /remove:d, and plain icacls '<dir>' when given no argument.
    • 2>/dev/null on the function call still silences powershell's stderr.
    • Without return 0, ensure_dir still returns 0 when the directory exists, because the if it ends on returns 0 when its branch is not taken.
    • The flattened apply branch prints the same messages and gives the same exit codes.
  • firewall.ps1: if (Show-State) { exit 0 }; exit 1 is equivalent. Show-State writes only $true or $false to the success stream.
  • status.sh:
    • The single $rule lookup prints .Enabled the same way, including when several rules share the name, and \$ escapes correctly inside the double quotes.
    • Dropping the -d check is safe because -f on the file inside the directory already implies it.
  • sync-finalize.sh: a straight rename of a path that was spelled out four times.

Closing issue #14595 acceptance criteria

  • Diff edits only the listed files and changelog fragments: met.
  • Within 400 changed lines and 15 hand-edited files: met (about 120 lines).
  • Fragment with ### Changed and "Internal simplification, no behavior change.": met, with bump: patch.
  • ci-status is green: I can't see it from here; the PR's CI will show it.
  • "Behavior is unchanged: same outputs, exit codes, written files, printed text, command-line flags and exported names": met, as far as my reading shows (see above). But for most of the changed code, no test could fail if it broke (advisory):
    • The repository's tests cover only check-drift.sh's pin() (check-drift.test.sh), sync-prep.sh (sync-prep.test.sh) and firewall.ps1 (tests/firewall.Tests.ps1).
    • Nothing exercises cleanup.sh's ask_yn mode filter (cleanup.sh:44-48), which decides whether --soft skips the firewall, ICACLS, uninstall and Calibre plugin prompts.
    • Nothing exercises the command strings lock-updates.sh's icacls_updates builds (lock-updates.sh:33-35), or the status.sh and sync-finalize.sh probes. A regression in any of these would merge unnoticed.
    • The issue puts new tests out of scope, so this is not blocking. A shim-based test like sync-prep.test.sh (stub powershell.exe, record its argv) could be a follow-up.

Other notes

  • No plugin manifest changed, so there are no manifest lines.
  • No path-scoped rule or paved-path concerns came up within this review's scope.
  • No embedded instructions in the PR context or prior-findings files.
  • No earlier review heads and no prior findings, so this was a full review, not blocking-only.
  • The author's verification (fragment and skill checks, check-affected, the subagent review) is author-claimed and I did not verify it. The author says the shell, Pester and Windows runs were not done.
  • Cost: none. The change touches only local Windows helper scripts.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 0d2beb9

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-15238-0d2beb933be21b6c7698d3987cf769fc34c3358d, expires on 2026-12-11.

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 11, 2026
Merged via the queue into main with commit 431edf0 Nov 11, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14595-42939101283-1 branch November 11, 2026 03:10
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

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

File Killed Survived Timeout No coverage Invalid Not run
plugins/kindle-dedrm/skills/manage/scripts/check-drift.sh 0 1 0 0 0 0
plugins/kindle-dedrm/skills/manage/scripts/cleanup.sh 0 2 0 0 0 0
plugins/kindle-dedrm/skills/manage/scripts/lock-updates.sh 0 2 0 0 0 0
plugins/kindle-dedrm/skills/manage/scripts/status.sh 0 1 0 0 0 0
plugins/kindle-dedrm/skills/manage/scripts/sync-finalize.sh 0 1 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/kindle-dedrm/skills/manage/scripts/check-drift.sh:131 SBR productive input-gap
plugins/kindle-dedrm/skills/manage/scripts/cleanup.sh:45 SBR unclassified none
plugins/kindle-dedrm/skills/manage/scripts/cleanup.sh:185 LCR productive input-gap
plugins/kindle-dedrm/skills/manage/scripts/lock-updates.sh:34 other productive input-gap
plugins/kindle-dedrm/skills/manage/scripts/lock-updates.sh:56 SBR unclassified none
plugins/kindle-dedrm/skills/manage/scripts/status.sh:63 UOI productive input-gap
plugins/kindle-dedrm/skills/manage/scripts/sync-finalize.sh:38 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 431edf0d92fbed4f97a46bf5b2ae65fabb05c27e; 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 manage kindle-dedrm plugin code

0 participants