Skip to content

refactor(pixel-art): simplify the scripts without changing behavior - #15071

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14670

Summary

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

Applied behavior-preserving simplifications to 8 of the 9 listed pixel-art scripts. backends.py now routes its six native-fallback notices through one local fallback() helper, and the notice text is byte-identical. capture.py folds three copies of the WebSocket XOR mask into _masked(), drops a duplicate isfile/which lookup in find_browser, and builds the DevTools /json/new URL once. embed.py shares one path resolver between its JSON and WAV loaders. image_pipeline.palette_violations becomes a single membership count, which is equivalent because allowed holds exactly the palette colors at alpha 255 plus (0,0,0,0) and its only caller passes read_png tuples. kit.layout builds torso and legs with one box() helper, and _body computes the tunic and belt position once. palette.read_png, snap_rgba and snap_frame_rows use comprehensions in place of hand loops. render.render computes the GIF color table and each animation's durations once. aseprite_backend drops a redundant re-check in sheet_order and uses dict.update for durations. gallery.py has nothing worth simplifying without a behavior risk, so it is unchanged. A review caught that a cheaper lookup in Walker._chars would raise TypeError for unhashable ramp colors, so that change was reverted.

Not verified

  • The pixel-art Python unit tests (plugins/pixel-art/scripts/test_*.py) were not run: this lane allows no interpreter. Left to the PR's CI.
  • ci-status green is a PR check, left to the PR's CI.
  • Tidy did not run every pass. Passes 1 to 4 ran and made no further edits. Pass 5's deterministic detector (detect.sh) and its digest guard are not commands this lane may run, so only the rubric read ran on the fragment, with no findings.
  • gallery.py was left unchanged: no simplification there was worth a behavior risk.
  • Not edited because they would change behavior for some input: replacing kit.Walker._chars's palette.values() scan with a dict (raises on unhashable colors); folding capture.py's killpg/terminate branches into one helper (would reference signal.SIGKILL on Windows); nearest_index via min() (raises on…
  • typos is not installed here, so check-affected skipped it.

Fix

  • plugins/pixel-art/scripts/aseprite_backend.py: sheet_order drops a redundant fallback; export_plan fills durations with dict.update
  • plugins/pixel-art/scripts/backends.py: _native returns directly; _upscale_sheet uses a comprehension; _run_aseprite routes its six fallback notices through a local fallback(reason) helper with identical text
  • plugins/pixel-art/scripts/capture.py: find_browser drops a duplicate lookup; new private _masked() replaces three inline XOR-mask expressions; _open_page builds the endpoint URL once
  • plugins/pixel-art/scripts/embed.py: one target() resolver shared by load_json and load_wav; the out path is converted once
  • plugins/pixel-art/scripts/image_pipeline.py: palette_violations is one membership count over the allowed set
  • plugins/pixel-art/scripts/kit.py: layout uses a box() helper for torso and legs; _body names body_x and belt_h once; fixed spacing in src =
  • plugins/pixel-art/scripts/palette.py: read_png builds each row with one comprehension; snap_rgba clamps the three channels in one expression; snap_frame_rows is a list comprehension
  • plugins/pixel-art/scripts/render.py: GIF color table moved out of the per-animation loop; frame_durations called once per animation
  • .changes/pixel-art/work-resolve-issue-issue-14670-42795305293-1-41685b56.md: patch fragment, ### Changed, "Internal simplification, no behavior change."

Verification

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

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

The run reports:

  • check-changelog-fragments: all 1 fragment valid (run before and after tidy and review)
  • check-changed-skills: no changed skills, nothing to gate
  • check-affected: 13 passed, 6 skipped over 9 changed files
  • fresh-context review subagent: compared every hunk with HEAD for equivalence; found one non-equivalent hunk (kit.Walker._chars raises TypeError on unhashable ramp colors), which was reverted; all other files judged equivalent
  • grep of callers and tests: palette_violations is fed only read_png tuples; no test asserts _http_json's method argument or the find_browser call count; no listed script is wired as a hook
  • diff size: 9 files, about 160 changed lines, inside the issue's 400-line and 15-file limits
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42795305293

Left out: the items under Not verified.

Related

#14670

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

Security review: PR #15071, head 47950152

I found no security issues. I read every hunk of the 9 changed files in .claude-lane/pr.diff. None of them matches a trusted-path glob. The diff touches no trust control, workflow, plugin manifest or standing instruction, so the trust-control, manifest and instruction-surface checks had nothing to apply to.

I looked closely at the hunks that could reach a security-relevant surface. In each one the refactor keeps the old behavior:

  • capture.py find_browser: the old code returned override when isfile(override) was true, otherwise shutil.which(override), otherwise None. The new one-line version returns the same value in each case, because shutil.which already returns None when it finds nothing. The CAPTURE_BROWSER trust surface (a local environment variable that picks the executable) is the same as before.
  • capture.py _masked / _open_page: the WebSocket XOR masking is moved into a helper and works the same way. os.urandom(4) is still where the client mask comes from. The DevTools URL still targets 127.0.0.1, and the page URL is still escaped with quote(..., safe='').
  • embed.py: the shared target() resolver produces the same path as the two inline copies did. The "<" → < escaping that stops </script> from breaking out of the inline script is still there. Embed paths could already point outside the template's directory before this change, and the PR leaves that as it was.
  • backends.py _run_aseprite: only the text of the fallback notices is restructured. The subprocess.run argv, timeout and env are unchanged.
  • image_pipeline.palette_violations, palette.py, kit.py, render.py, aseprite_backend.py: these are internal data-shaping refactors with no trust boundary.

The PR context file has no embedded instructions aimed at this lane.

This was the first review of this PR (blocking only: no), and there were no prior findings to carry over.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: PR #15071, refactor(pixel-art): simplify the scripts without changing behavior

Result: no findings. I read every hunk of all 9 changed files. Every change does the same thing it did before.

How I checked each file

  • aseprite_backend.py: sheet_order dropped a second check that could never run. The or list(frames) already covers the empty case. durations.update(zip(...)) writes the same keys in the same order.
  • backends.py: _native now returns from inside the try, and the exceptions caught are the same. In _upscale_sheet, [expanded] * scale repeats one shared row object, which is what the old loop did too. The new fallback(reason) helper builds exactly the old text "<reason>; rendered with the native backend" for all six messages. That keeps the eval vf-spark-aseprite-fallback/samples/says-native-fallback.json accurate.
  • capture.py: find_browser gives the same result, because shutil.which already returns None on a miss. _open_page now calls _http_json(endpoint) for the fallback. That is still a GET, since method="GET" is the default at capture.py:261. _masked() is the same XOR in all three places.
  • embed.py: the target() resolver works out the same path. The function still returns the same count.
  • image_pipeline.py: pixel not in allowed counts the same pixels as the old three branches. The allowed set holds only palette colors at alpha 255 plus (0,0,0,0). Its one caller (backends.py:80) and the test pass in 4-tuples from read_png.
  • kit.py: box() gives the same (x, y+bob, w, h). Every preset's torso and legs entry has exactly 4 values, so unpacking them is safe. _body computes body_x, body_w and belt_h the same way as before.
  • palette.py: read_png only lets color type 2 or 6 through (palette.py:175), so bpp is always 3 or 4. That makes the new branch on bpp == 4 equivalent. Each row still has width pixels as int tuples. The clamp and the snap_frame_rows comprehension are equivalent too.
  • render.py: moving gif_colors out of the loop is safe. animations is never empty because it defaults to "all", rgba already calls hex_rgb on every key, and write_gif does not change colors. frame_durations returns a new list and zip does not change it, so reusing durations for the tag is safe.

Closing issue #14670: acceptance criteria

  • Behavior unchanged: met, by my reading of each hunk above. Existing tests such as test_backends.py:216 (palette_violations) exercise these paths. I did not run them because this lane has no shell.
  • Only listed files and fragments edited: met. The diff touches 8 of the 9 listed scripts plus one fragment. gallery.py is unchanged, and the PR body explains why.
  • Within 400 lines and 15 files: met (9 files, about 160 changed lines).
  • ci-status green: the PR's CI decides this; I did not check it.
  • Fragment: met. bump: patch, ### Changed, "Internal simplification, no behavior change."

The PR body's test and check results are the author's claims. I have not confirmed them.

No plugin manifest changed, so the manifest checks did not apply. No embedded instructions were found in the PR context.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 4795015

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-15071-47950152bc3bc25e80ffd0baf950dfcd07133e75, 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
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 10, 2026
@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 7f33aec Nov 10, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14670-42795305293-1 branch November 10, 2026 12:32
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

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

File Killed Survived Timeout No coverage Invalid Not run
plugins/pixel-art/scripts/aseprite_backend.py 1 0 0 0 0 0
plugins/pixel-art/scripts/backends.py 0 1 0 0 0 0
plugins/pixel-art/scripts/capture.py 0 1 0 0 0 0
plugins/pixel-art/scripts/image_pipeline.py 1 0 0 0 0 0
plugins/pixel-art/scripts/kit.py 0 1 0 0 0 0
plugins/pixel-art/scripts/palette.py 1 0 0 0 0 0
plugins/pixel-art/scripts/render.py 1 0 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/pixel-art/scripts/kit.py:122 AOR productive no-assertion
plugins/pixel-art/scripts/backends.py:74 AOR productive no-assertion
plugins/pixel-art/scripts/capture.py:111 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 pixel-art plugin code

0 participants