Skip to content

refactor(lib): simplify setup-apply.mjs, spawn_noise.py and state-key.sh - #14374

Merged
melodic-automation-lanes[bot] merged 2 commits into
mainfrom
work-resolve-issue/issue-14340-42569078237-1
Nov 9, 2026
Merged

melodic-automation-lanes[bot] merged 2 commits into
mainfrom
work-resolve-issue/issue-14340-42569078237-1

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14340

Summary

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

Simplified the three shared lib sources without changing behavior. setup-apply.mjs now has one META_KEYS set in place of three copies, a topScalars helper for four repeated top-level scalar maps, reuses isNull and eolOf where it repeated their regexes, parses the file once in --check instead of once per object key, and shares the WARN and PASS line writers between the two exported reports. spawn_noise.py names the spread ratio once, picks the no-op command with one lookup, and drops a docstring that repeated the module header plus two history notes (the repo standard rules out origin or history notes in code). state-key.sh replaces hash12 and hash8 with one hash_prefix helper. The regenerated shared copies and one patch changelog fragment per carrier plugin are included.

Not verified

  • Test suites for the changed files (lib/setup-apply.test.sh, state-key.test.sh, plugins/harness-ops/lib/test_spawn_noise.py and spawn_noise.test.sh) were not run: this lane's Bash runs only the named wrappers. Left to the PR's CI.
  • Build and lint of the touched files (node --check, ruff, shellcheck) not run here for the same reason; left to the PR's CI.
  • ci-status green on the PR: a PR CI check, left to the PR's CI.
  • Tidy not run: the change touches lib/, a listed shared path, and spans 60 files (over the 10-file cutoff; most are generated copies and fragments).

Fix

  • lib/setup-apply.mjs: META_KEYS set, topScalars helper, isNull and eolOf reuse, single flatten in --check, warnLines/passLine shared by perKeyReport and wholeFileReport (exports unchanged)
  • lib/spawn_noise.py: local ratio variable, single NOOP_SPAWN lookup, trimmed the duplicated summarize_spawn_samples docstring and the history notes in is_measurable and percentile_floor docstrings
  • lib/state-key.sh: hash12/hash8 merged into hash_prefix <length> <text>
  • plugins/{discipline,discovery,docs-hygiene,education,planning,review,session-flow,verification}/lib/setup-apply.mjs: regenerated by scripts/sync-shared-copies.sh
  • plugins/{harness-ops,performance}/lib/spawn_noise.py: regenerated by scripts/sync-shared-copies.sh
  • plugins/*/lib/state-key.sh (22 carrier plugins): regenerated by scripts/sync-shared-copies.sh
  • .changes/<plugin>/work-resolve-issue-issue-14340-*.md (25 plugins): patch fragments, 'Simplified the shared ... library copies; behavior is unchanged.'

Verification

The runner ran each check from the base copy against 01a67de:

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

The run reports:

  • sync-shared-copies: regenerated 32 copies, exit 0 (re-run after the review fix: 8 setup-apply.mjs copies, exit 0)
  • check-changelog-fragments: all 29 fragments valid
  • check-changed-skills: no changed skills, nothing to gate
  • check-affected: 14 passed, 5 skipped (typos not installed; three validate-plugins steps that run code from the checked tree; changed-skills with no skill file), over 60 changed files
  • fresh-context review subagent over the lib/ diff: no behavior differences found in any hunk (checked CRLF/LF equivalence of the eolOf rewrite, TDZ/shadowing of the new consts, hash_prefix argument order, ratio None handling); one style nit (missing space after && in setup-apply.mjs readOld)…
  • git-read diff --numstat HEAD -- lib/: 41 added, 55 removed across the 3 hand-edited files
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42569078237

Left out: the items under Not verified.

Related

#14340

Merge-Risk: max=MEDIUM demote=false head=871738ec582e166cb23c4da49453c270b1a7b06d rubric=8.1.2 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 needs no new review of 871738ec582e166cb23c4da49453c270b1a7b06d: no file of this pull request changed since the review of 01a67de.

Security review: PR #14374 (refactor(lib): simplify setup-apply.mjs, spawn_noise.py and state-key.sh)

No security issues found.

critical-findings: 0

Scope read

I read every hunk of lib/setup-apply.mjs, lib/spawn_noise.py and lib/state-key.sh. I also read the first path of each identical-copy group: plugins/adhd/lib/state-key.sh, plugins/discipline/lib/setup-apply.mjs, plugins/harness-ops/lib/spawn_noise.py and the .changes/adhd/... fragment. All copies sit at plugin lib/ paths and do the same job as the root lib/ sources; no hook, workflow, settings or manifest path is among them. None of the 60 changed files matches a trusted-path glob. No plugin manifest changed.

What I checked

  • setup-apply.mjs
    • META_KEYS holds the same three keys as the inline checks and the local meta set it replaces, so the known-key and skip-key filters are unchanged.
    • isNull (lib/setup-apply.mjs:288) matches the same null|Null|NULL|~ set as the regex it replaces.
    • eolOf (lib/setup-apply.mjs:1122) returns CRLF only when every line break is CRLF. The new refusal fires when it returns \n and the text still contains \r\n. That is the same mixed-line-ending refusal as before, so no file with mixed endings now gets past it.
    • topScalars and the single flatten in --check produce the same maps as the inline code they replace. The read-back check before a write is unchanged.
  • state-key.sh: hash_prefix is only called with the literal lengths 12 and 8. The text argument is still printed with printf '%s' as data, so no new injection point exists. The state key and discriminator values come out the same.
  • spawn_noise.py: the ratio local and the single NOOP_SPAWN lookup choose the same command and give the same results. The docstrings and comments that were removed are explanation, not standing instructions or guardrails.
  • Changelog fragments: patch-bump text only.

Trust controls and instruction surface

The diff doesn't touch the trusted-trigger check, the lane token request or broker, the kill switch, any merge hold, or any action under .github/. It deletes no standing instruction: only code comments and docstrings were trimmed. No embedded directives turned up in the PR context.

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

claude-review needs no new review of 871738ec582e166cb23c4da49453c270b1a7b06d: no file of this pull request changed since the review of 01a67de.

Code review: PR #14374, a simplification of setup-apply.mjs, spawn_noise.py and state-key.sh

Result: no findings. I read every hunk of the three hand-edited sources under lib/. For each group of identical files I read the first one: plugins/adhd/lib/state-key.sh, plugins/discipline/lib/setup-apply.mjs, plugins/harness-ops/lib/spawn_noise.py and the adhd changelog fragment. The other copies match these line for line, apart from the hunk offsets. All copies sit under plugins/*/lib/ or .changes/<plugin>/, the same kind of path as the file they copy, so the location changes nothing about what they do. No changed file matches a trusted-path glob.

Behaviour checks (my own reading of the code; I ran nothing)

  • lib/setup-apply.mjs
    • META_KEYS holds the same three keys as the old inline checks in known, keys, and the meta set in readOld.
    • isNull (L288) is the same null|Null|NULL|~ regex as before, only reordered.
    • topScalars gives the same result as the four expressions it replaces. inNew keeps the existing === null guard.
    • The mixed-line-ending refusal now uses eolOf (L1122, declared in main before the write branch uses it). It gives the same result in every case: all LF, all CRLF, and mixed CRLF/LF, which still refuses.
    • In --check, moving the flatten(existing) call up changes nothing. existing is already non-null there, and the old scalars line already parsed the file eagerly.
    • warnLines and passLine write the same bytes as before.
    • Module-level consts are initialised before run() calls main, so there is no temporal-dead-zone problem.
    • The exported names are unchanged.
  • lib/spawn_noise.py
    • ratio holds the same value that is stored in spread_ratio, and the bimodal check is unchanged.
    • The single NOOP_SPAWN lookup is equivalent to the old two-branch form.
    • The new comment points to the module docstring (L13-18), which does describe the two-part signature.
    • Only docstrings were trimmed, and nothing prints this module's function __doc__.
  • lib/state-key.sh
    • hash_prefix 12 and hash_prefix 8 produce the same output as the old hash12 and hash8.
    • The script runs as a subprocess and is not sourced (for example findings-state.sh L337), so the removed function names were never exported.

Closing issue #14340 acceptance criteria

  • Behaviour unchanged: met, on my reading above. The existing suites (setup-apply.test.sh, state-key.test.sh, test_spawn_noise.py) would catch a regression. The PR body says it did not run them; that is unverified.
  • Edits only the listed files, regenerated copies and fragments: met. There are 25 fragments, one per carrier plugin: the 22 state-key.sh carriers plus discipline, docs-hygiene and verification for setup-apply.mjs. harness-ops and performance also carry spawn_noise.py.
  • Within 400 lines and 15 hand-edited files: met, with 3 hand-edited files and about 96 changed lines under lib/.
  • ci-status green: not something this lane can check; left to CI.
  • sync-shared-copies.sh run and copies committed: the copies in the diff match the sources. That the script was run is the author's claim, unverified.

No plugin manifests changed. No embedded instructions were found in the PR context. No settled threads were named, and there are no prior findings from this lane. The change adds no spend.

@melodic-automation-lanes melodic-automation-lanes Bot added the needs-session A pr-unblock stop a session builder takes: a change the lane cannot make. Not an owner stop. label Nov 9, 2026
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The pr-unblock lane stopped fix-ci on this pull request: the lane could not fix every failing check, after one retry a model rung up, so a session builder takes it; its run log names each one and why. The lane labels it needs-session for a session builder, who makes the change this lane cannot, and the run ends in a failing pr-unblock/fix-ci status on the head the lane gated.

When a retry on this head can change the outcome, the lane runs one on its own, up to its per-head cap, and edits this comment if it stops again; a run that does not stop clears the status. When no retry can (a review thread the lane does not take or settle, or a failing check after the retries are spent), a person resolves the threads or gets the checks green, then dispatches the workflow below: that run finds the cause gone and clears the status. On a pull request the lanes App opened, the dispatchers start that run once per stop; on any other, a person does. A new commit to the branch starts clean.

To run it again on this head now, dispatch the pr-unblock workflow:

gh workflow run pr-unblock.yml -R melodic-software/claude-code-plugins -f pr-number=14374 -f activity=fix-ci

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

a pr-unblock lane stopped its head (pr-unblock/fix-ci is failure), which clears when the lane runs
  again

@melodic-automation-lanes melodic-automation-lanes Bot removed the needs-session A pr-unblock stop a session builder takes: a change the lane cannot make. Not an owner stop. label Nov 9, 2026
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 871738e

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-14374-871738ec582e166cb23c4da49453c270b1a7b06d, 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 dccd6ba Nov 9, 2026
83 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14340-42569078237-1 branch November 9, 2026 07:16
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit dccd6bae061930c6f9c278723309d1789fe265aa; 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 setup-apply.mjs, spawn_noise.py and state-key.sh shared lib sources

1 participant