Skip to content

refactor(retro-audio): simplify the audio scripts without changing behavior - #15183

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14721

Summary

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

Simplified the five retro-audio scripts, aiming to leave behavior unchanged. mml.py drops a noise flag that _voice could never see set, since its only caller cleared it before the call. The parser's continue chain is now an if/elif chain, a table maps the t/o/l/v/ settings to their state keys, and a rest fills its silence in one step instead of sample by sample. presets.py builds the three chip entries from one helper, sfx.py flattens a nested conditional and drops an envelope argument that always equaled local, tone.py uses in tests, and wav.py packs and unpacks all frames in one struct call. Design choice: every edit stays inside its own file, because the issue puts cross-file dedupe out of scope.

Not verified

  • test_audio.py (python unittest) and audio.test.sh were not run: this lane allows no interpreter, so the suites are left to the PR's CI
  • Known residual difference: read_wav on a corrupt WAV with an odd data-byte count still raises struct.error, but its message text now comes from struct.unpack instead of struct.unpack_from. No CLI calls read_wav and nothing catches it; only the tests use it, on well-formed files.
  • tidy: passes 4-5 (docs-hygiene and ai-slop on markdown) were skipped because the only markdown is the changelog fragment, whose wording the issue fixes word for word
  • Lint and type checks for the Python files were not run (no interpreter or linter available in this lane); left to CI
  • ci-status green on the PR: a PR check, left to the PR's CI
  • The working tree has untracked files this run did not create (.bash_profile, .bashrc, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc), probably left by the sandbox; they are not part of this change

Fix

  • plugins/retro-audio/scripts/mml.py: removed the dead noise flag from the parse state and the save/restore around _voice. _voice now takes the program number. The parser's continue chain became an if/elif chain. A new SETTINGS table maps t/o/l/v/ to state keys. Repeat expansion is now one slice…
  • plugins/retro-audio/scripts/presets.py: the three CHIPS entries are built by a private _chip(bass_wave) helper with the same keys, values and order.
  • plugins/retro-audio/scripts/sfx.py: the nested ternary for freq_limit became an if/elif, and the envelope gets local, which already equals time when repeat is off.
  • plugins/retro-audio/scripts/tone.py: x == a or x == b became x in (a, b), and redundant parentheses were dropped.
  • plugins/retro-audio/scripts/wav.py: write_wav packs every sample in one struct.pack call, and read_wav unpacks every frame in one struct.unpack call.
  • .changes/retro-audio/work-resolve-issue-issue-14721-42885941364-1-5100e956.md: new patch fragment, made with new-changelog-fragment and holding ### Changed and "Internal simplification, no behavior change."

Verification

The runner ran each check from the base copy against 353bb6d:

  • 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 (run before and after the review fix)
  • check-changed-skills: no changed skills, nothing to gate
  • check-affected: 13 passed, 6 skipped (typos not installed, plus checks that run checked-tree code), others CI-only; run before and after the review fix
  • fresh-context review subagent, given the diff and the original files: found no behavior change in mml.py, presets.py, sfx.py or tone.py, and found no test in test_audio.py that the change breaks. It found two wav.py edge cases. The first, write_wav given a generator raising before the file is…
  • tidy-diff passes 1-3 on the changed code lines: no further edit; the changed lines hold no comments
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42885941364

Left out: the items under Not verified.

Related

#14721

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

Security review: PR #15183 (head 353bb6d)

I found no security issues.

I read every hunk of all 6 changed files. None of them matches a trusted-path glob, none is a plugin manifest, and none is an instruction surface.

  • plugins/retro-audio/scripts/mml.py: refactors the MML parser.
    • The dead noise state flag is gone, and _voice now takes the program number.
    • The chain of continue statements is now an if/elif chain, and a SETTINGS table maps the t/o/l/v/@ commands to state keys.
    • Repeat expansion is now a slice assignment, and a rest fills its silence in one step.
    • Input validation is unchanged: an unclosed repeat, a repeat count below 1, a missing number, and a tempo, length or note length of zero or less still raise.
    • The repeat expansion is the same as before, so there is no new resource-exhaustion path.
  • plugins/retro-audio/scripts/presets.py: a _chip() helper builds the same data.
  • plugins/retro-audio/scripts/sfx.py: one conditional is flattened, and the envelope now gets local, which equals time when repeat is off.
  • plugins/retro-audio/scripts/tone.py: x == a or x == b became x in (a, b).
  • plugins/retro-audio/scripts/wav.py: frames are packed and unpacked in one struct call each.
    • The write path is still the caller-supplied path, so path handling is unchanged.
    • A WAV with an odd byte count still raises struct.error, and only the error message changes.
  • .changes/retro-audio/...md: a changelog fragment only.

No change touches tokens, secrets, credentials, subprocess or shell calls, network access, workflows, or any trust control or merge hold. The PR context file contains no embedded directives aimed at the review lane.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: no findings

I read every hunk in all 6 changed files. None of them match a trusted-path glob. I checked each edit against the base code to see whether behavior can change. I ran nothing myself, because this lane has no interpreter. The PR's test results are the author's claim and I have not checked them.

plugins/retro-audio/scripts/mml.py

  • Dropping noise from the parse state is safe. The flag was set by n and cleared by @. Its only reader, _voice, was always called inside a save, clear and restore, so it never saw the flag set. The new _voice(program, chip) returns the same values.
  • The note-length rewrite is the same. length, index = _number(text, index) behaves like the old next_index handling, because _number returns (None, index) when there is no number (mml.py:26-32).
  • The settings table is the same. SETTINGS keeps int() for o and @ and the raw float for t, l and v. The error checks run in the same order with the same messages.
  • Repeats are the same. The slice assignment notes[start:] = notes[start:] * k gives the same list, holding the same shared dicts, as the old del-and-extend.
  • Rests are the same. _render_notes used to append 0.0 one sample at a time for a rest and now does it in one step. Rests never call noise.sample() and the per-note state resets at each note, so the noise sequence and the samples come out the same.

plugins/retro-audio/scripts/sfx.py

  • The freq_limit branch is the same. When slide == 0, the old code still never evaluated float(limit), and the new code doesn't either.
  • The envelope argument is the same. local already equals time when repeat <= 0 (sfx.py:61), so passing local changes nothing.

plugins/retro-audio/scripts/wav.py

  • Writing and reading give the same values. Each sample is clipped and converted the same way as before.
  • Empty input still works. A "<0h" format handles zero samples.
  • Odd byte counts still fail the same way. A WAV with an odd number of data bytes still raises struct.error; only the message text differs, as the PR says.
  • Errors still come before the file. All the frames are still built before the file is opened, so an input that fails still fails before anything is written.

plugins/retro-audio/scripts/presets.py and plugins/retro-audio/scripts/tone.py

  • presets.py: _chip() builds the same keys, values and order for each chip.
  • tone.py: the edits only switch to in tests and drop redundant parentheses.

Closing issue #14721

  • Behavior unchanged: met, by my reading. The only new module-level names are SETTINGS and _chip, and no exported name is removed or renamed. scripts/test_audio.py covers repeats, tempo and length errors, dotted notes, wave period and preset rendering, so a regression in those areas would fail a test.
  • Diff touches only the listed files plus a fragment: met.
  • Size: met (about 290 diff lines, 5 hand-edited files).
  • Fragment: met. It is bump: patch, with ### Changed and "Internal simplification, no behavior change."
  • ci-status green: a CI check that this review cannot see. Not judged here.

No plugin manifest changed. The PR context file had no embedded directives.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 353bb6d

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-15183-353bb6dca5a3b3cfc750f4299e574bcde7695d73, 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 b137f13 Nov 10, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14721-42885941364-1 branch November 10, 2026 23:03
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

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

File Killed Survived Timeout No coverage Invalid Not run
plugins/retro-audio/scripts/mml.py 2 1 0 0 0 0
plugins/retro-audio/scripts/sfx.py 0 2 0 0 0 0
plugins/retro-audio/scripts/tone.py 1 0 0 0 0 0
plugins/retro-audio/scripts/wav.py 0 1 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/retro-audio/scripts/mml.py:158 SBR productive input-gap
plugins/retro-audio/scripts/sfx.py:63 LCR productive no-assertion
plugins/retro-audio/scripts/sfx.py:81 other productive input-gap
plugins/retro-audio/scripts/wav.py:26 AOR productive no-assertion

The run's summary has the full report.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit b137f136b2a7ed6265d2db9c23f055dc4bceda2c; 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 retro-audio plugin code

0 participants