Skip to content

Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.

merge: main at v3.12.1 into the contract-strings branch; the Unreleased section sits above v3.12.1 and upgrades from it

Soohong Kimf40bcf7bd83a
diff --cc CHANGELOG.md
index 87b9264,5747f8f..deef564
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -2,21 -2,15 +2,30 @@@
All notable public changes to `sprite-gen` are recorded here. Versions track the `version:` field in `SKILL.md` and `pyproject.toml`.
+## Unreleased - Contract strings each written once and read by name
+
- **Upgrading from 3.12.0: every output, report, JSON body, JSON key order, CLI choice and order, `--help` text, refusal and warning text keeps its bytes. Nothing a user runs behaves differently. One visible effect: `frames/extract.py` and `frames/decontam.py` changed, so `engine_revision` changes. The curation view's heal re-extracts each existing run once when it is next opened; the frames it writes have the same pixels. One edge: `python -m sprite_gen.serve.serve_curation`, `scripts/serve_curation.py` and `scripts/interpolate_frames.py` now load the image providers (`sprite_gen.gen`) when they start, because their default provider is read from a declared name. A malformed `SPRITE_GEN_GEN_TIMEOUT_SECONDS` now stops them at start with its `ValueError`, instead of when a reroll or interpolate button is pressed. `sprite-gen curation` already loaded them, so it is unchanged. `python -m sprite_gen.video.loop` and `scripts/video_loop.py` read `gen.facing.FACINGS` when they run or build their arguments, so they load the image providers too, and a malformed `SPRITE_GEN_GEN_TIMEOUT_SECONDS` now stops them with its `ValueError`, even for `--help` (`sprite-gen video-loop` already did). Importing `sprite_gen.video.loop` still loads no provider code.**
++**Upgrading from 3.12.1: every output, report, JSON body, JSON key order, CLI choice and order, `--help` text, refusal and warning text keeps its bytes. Nothing a user runs behaves differently. One visible effect: `frames/extract.py` and `frames/decontam.py` changed, so `engine_revision` changes. The curation view's heal re-extracts each existing run once when it is next opened; the frames it writes have the same pixels. One edge: `python -m sprite_gen.serve.serve_curation`, `scripts/serve_curation.py` and `scripts/interpolate_frames.py` now load the image providers (`sprite_gen.gen`) when they start, because their default provider is read from a declared name. A malformed `SPRITE_GEN_GEN_TIMEOUT_SECONDS` now stops them at start with its `ValueError`, instead of when a reroll or interpolate button is pressed. `sprite-gen curation` already loaded them, so it is unchanged. `python -m sprite_gen.video.loop` and `scripts/video_loop.py` read `gen.facing.FACINGS` when they run or build their arguments, so they load the image providers too, and a malformed `SPRITE_GEN_GEN_TIMEOUT_SECONDS` now stops them with its `ValueError`, even for `--help` (`sprite-gen video-loop` already did). Importing `sprite_gen.video.loop` still loads no provider code.**
+
+- **Internal: one declaration per contract string**: a key, kind, mode, provider name or key colour that two or more places write, read or branch on was spelt again at each place, so a one-letter typo passed every test (for example the curation server's `extractOk` spelt `extractOK` made the curator warn on every row with the suite green). Each is now declared once and every use names it:
+ - curation and composer servers: every key of the JSON the curator and composer read, in `serve_curation.Wire` (112 keys and the `X-Filename` download header) and `serve_compose.Wire` (16 keys, plus `TYPE_DIR`, `TYPE_IMAGE`); the heal report and progress file keys in `frames/extract.py` (`HEAL_*`, `PROGRESS_*`, `PROGRESS_PHASE_COMPONENTS`); `curation.CURATION_KIND`, `REF_ANCHOR`, `REF_BASIS`, `REF_GUIDE`, `BREATHE_PIXEL`, `BREATHE_SMOOTH`.
+ - image provider names `PROVIDER_CODEX`, `PROVIDER_GROK`, `PROVIDER_OPENAI` in `gen/base.py`, with `gen.PROVIDERS` and the other provider sets written with them; the curator's two buttons gated by one set, `serve_curation.CURATOR_PROVIDERS`; the reroll default is `gen.HARD_DEFAULT_PROVIDER`; the interpolate default is `interpolate.DEFAULT_PROVIDER` (codex, its own documented choice from the three-way comparison); the HTTP host names `address.OPENAI`, `XAI`, `ANTHROPIC`, `ELEVENLABS`; `retry.ELEVENLABS_BUSY`; `audio.manifest.KIND`, `SFX`, `BGM`; the workflow guide's journey, field and access names in `workflow/catalog.py` and `workflow/access.py`; `video-prompt` takes `gen.video.DEFAULT_MODEL` instead of a second copy; the choice to stop and ask when codex cannot run is `gen.CODEX_UNAVAILABLE_ASK`, which `gen.CODEX_UNAVAILABLE_CHOICES`, `gen.CODEX_UNAVAILABLE_DEFAULT` and the workflow catalogue read; the guide reports that choice under `gen.CODEX_UNAVAILABLE_SETTING`, the name it is saved by; `xai.AUTH_SOURCE_API_KEY` is `xai.AUTH_ENV`; `claude_login.CHILD_DROP` reads `anthropic_api.AUTH_ENV`; the codex binary's name is `codex_provider.BINARY`; `pixel_draw.EFFORTS` is `anthropic_api.EFFORTS`, the copy removed.
+ - key colours and modes: `cutout.KEY_TARGETS` with `MAGENTA` and `GREEN` beside it is the one table of key colours (`gen.chroma.KEYS` is built from it, `logo_matte.KEYS` is it, `slice_sheet.CHROMA_KEYS` is removed, the hex values in `prepare`, `unpack-atlas` and the curation server are derived from it); `cutout.KEYS` is cutout's own `--key` set; `OFF, AUTO, PALETTE = DECONTAM_MODES` and `CHROMA_RGB, CHROMA_YCBCR = CHROMA_MODES` are declared in `frames/extract.py`, and `frames.decontam.DECONTAM_MODES` and `video.frames.DECONTAM_MODES` are that same tuple; every `--decontam`, `--chroma-mode` and `--key` choice reads its declaration; `logo_matte.LETTERING_BOX`, `UNMIX`; `prompt_parts.CONFLICT`, `REPEAT`; `gen.chroma.KEY_BACKGROUND_TEXT`, `gen.logo.KEY_COLOUR_WORDS` and a scene report's `key_like_pixels` are keyed by `cutout.GREEN` and `MAGENTA`; `prop_plate.RGB` reads `KEY_TARGETS[MAGENTA]`; `video.frames.DECONTAM_DEFAULT` is `extract.AUTO` and video-frames' decontam branches read `OFF`, `AUTO` and `PALETTE`; `video-frames --alpha-mode` reads `effect.ALPHA_MODES`; the `method` a `gen.chroma` report states reads `extract.CHROMA_YCBCR` and `base.TRANSPARENCY_NATIVE`.
+ - kinds: `loop.REPORT_KIND`, `loop.REPORT_PASSED`; `spec.assets.ASSET_KIND`, `SET_SHEET_KIND` (`set_sheet.KIND` names it); `qa.motion.REPORT_KIND`; `video.evidence.SOURCE_KIND`; `nonloop.GAIT_STATES` (the copies in `qa.handed` and `video.batch` removed); `body_plan.BIPED`, `QUADRUPED`, `LEGLESS`; `effect.STATE` read by `video-set` and `video-prompt`; `pixel_gates.SPRITE`, `ICON`, `TILE`, `EFFECT` (`pixel_draw.KINDS` is that tuple); new names `spec.runio.REQUEST_KIND`, `video.frames.REPORT_KIND`, `video.align.REPORT_KIND`, `unpack_atlas.UNPACK_SOURCE_KIND`; `video-canvas` writes `prop_plate.CANVAS_REPORT`, the name the report is read by; the `kind` of a pixel-draw effect strip is `pixel_gates.EFFECT`; a `video-cycle-align` same-foot refusal states `align.RETAKE_FEET_REASON`.
+ - other copies: `sprite-request.json` and `curation.json` are read as `runio.REQUEST_FILENAME` and `curation.CURATION_FILENAME` everywhere they are written, opened or checked; `pixel_grid.PNG_MAGIC` is `base.PNG_MAGIC`; `restoration.ARTIFACT_SUFFIXES` is the one table of a restoration's five files (`restoration.ARTIFACTS` is its keys, the demo script reads it); `game_pack.SIDES` is `ui_kit.SIDES`; `video-canvas --facing`, `video-loop --facing` and a lateral view's check in `gen.handedness` read `gen.facing.FACINGS`; `effects.breathe.SIDE_NAMES` is keyed by `extract.FRAME_SIDES`.
+ - Values that no test bound before and that now cannot drift: the legless anatomy sentence key, `effect` in `video-set`'s states pinned to their first frame, the pixel-draw pick sheet's tile branch, the loop report kind `video-cycle-align` reads (its typo passed the fast bundle).
+- Python callers: every name above is importable. Downstream imports keep the same objects: `sprite_gen.video.frames.DECONTAM_MODES`, `sprite_gen.frames.cutout.KEY_TARGETS`, `sprite_gen.gen.chroma.KEY_BACKGROUND_TEXT`, `set_sheet.KIND`, `pixel_draw.KINDS`, `batch.GAIT_STATES`. Removed: `slice_sheet.CHROMA_KEYS` (use `cutout.KEY_TARGETS`). `clip_prompt.DEFAULT_MODEL` is `gen.video.DEFAULT_MODEL`, imported (the same object). `qa.handed.GAIT_STATES` is now a frozenset (was a tuple); every use is a membership test. `sprite_gen.frames.cutout` now imports `frames.extract` when it loads (for the decontam defaults), so importing it loads more modules than before; `pixel_draw.EFFORTS`, `game_pack.SIDES` and `pixel_grid.PNG_MAGIC` stay importable as the same objects; `loop.FACINGS` is removed (use `sprite_gen.gen.facing.FACINGS`).
+- **Curator**: the JS mirror `BREATHE_MODES` moved from `store.js` to `breathe.js`, with `BREATHE_SMOOTH` beside it; `gen-trigger.js`'s provider select mirrors `serve_curation.CURATOR_PROVIDERS`. No screen changes; `BREATHE_ROUND_KEYS` moved from `store.js` to `breathe.js`, beside the refusal that spelt the two keys.
+- **Tests**: new `tests/serve/test_curator_wire_keys.py`: every key the curator and composer read is found in the scripts with the object it is read from, built from the declared value; every declared key is read or listed as unread, the unread ones spelt out in the test; the servers write no wire key, and send no header the curator reads, as text; every `Wire.X` the servers name exists. `tests/serve/test_curation_view_contract.py`: the reroll and interpolate buttons follow `CURATOR_PROVIDERS` and their declared defaults, and node runs `gen-trigger.js` to hold its select to `CURATOR_PROVIDERS` in order. `tests/effects/test_breathe_sidecar_roundtrip.py`: the curator's save payload kind is `CURATION_KIND`. `tests/frames/test_cutout.py` and `tests/frames/test_chroma_decontam.py`: every key table is the one table, every `--key`, `--decontam` and `--chroma-mode` flag reads its declaration, `cutout.KEYS` pinned as written. `tests/gen/test_codex_unavailable.py` (the codex-unavailable choices in order), `tests/gen/test_openai_provider.py` (adapter names equal `gen.PROVIDERS`), `tests/audio/test_sound.py` (the two ElevenLabs busy codes), `tests/workflow/test_capabilities.py` (the video model default), `tests/gen/test_prompt_assembly.py` (a repeat note's kind). The two absence guards that searched `serve_curation.py` for a key's spelling (`tests/serve/test_pixel_grid_always_available.py`, `tests/curate/test_logical_height_contract.py`) now search for its name; with the old spelling they would have passed while testing nothing. Red first: at 3.10.1 the new binding tests fail (for example the wire-key test finds 217 keys written as text in `serve_curation.py` and 55 in `serve_compose.py`; 8 `--decontam` parsers held their own copy; `video-set`'s `--key` was a copy). Mutation check: one character changed in a declared value fails a test in every family; before, 16 of 25 sampled curation key changes, the provider adapter name, either ElevenLabs busy code, the video model default and the loop report kind under the fast bundle left the suite green. `tests/frames/test_cutout.py` (no table in the package keys a key colour by its spelling (an AST scan of `sprite_gen`)), `tests/gen/test_codex_unavailable.py` (the guide reports the codex choice under the name it is saved by), `tests/gen/test_pixel_draw.py` (the effort order is the API's), `tests/compose/test_game_pack_v2.py` (a nine-slice's sides are `ui_kit`'s), `tests/gen/test_facing.py` (`video-loop --facing` takes the facings `gen.facing` declares), `tests/effects/test_breathe_reference_key.py` (the JS frame sides and border share equal `extract.FRAME_SIDES` and `BORDER_MIN_FRACTION`), `tests/spec/test_assets.py` (the kinds written to disk are pinned as written), `tests/gen/test_codex_login.py` (the codex binary pinned as written), `tests/video/test_source_restoration.py` (a restoration's five file suffixes pinned as written).
+
+ ## v3.12.1 - A one-shot cut where no pair returns names its closest return, ratio and moved, and the report gains cycle.closest_return
+
+ **Upgrading from 3.12.0: Thresholds, the search window, which clips are cut, and every cut's pictures and report values are the same as 3.12.0.** Only the refusal text changes where no pair of frames returns, and `--report` gains `cycle.closest_return`. The refusal now names the closest return, its frames, its ratio of departure, and that pair's moved instead of reporting `moved 0.00`. Where a pair returns but what lies between is not an action, or where no pair departs at all, the refusal line is the 3.12.0 line as before.
+
+ - **Fix: A one-shot cut where no pair of frames returns now names the closest return, its ratio and its moved instead of reporting `moved 0.00`.** In 3.12.0 and earlier, where no pair of frames returned, the refusal said `the clip never leaves its rest pose and returns with observed endpoints (moved 0.00, need 0.4)`. The moved it reported was the largest moved among pairs that had returned, and because none had, it always read 0.00; a body that jumps across the canvas therefore read as one that never moved. Where no pair returns, the refusal now names the closest return: the pair of frames whose return distance over departure is the least of every pair the search read, that ratio, and that pair's moved. After the fixed prefix, the line is `the clip does not come back to a pose it left: the closest return, frames A-B, is R of its departure away, over 0.25 (moved M, need 0.4)`. On a synthetic leap whose body lands 240 px along a 360 px canvas, the new line reads `frames 0-34, is 1.12 of its departure away, over 0.25 (moved 0.36, need 0.4)`. The report written with `--report` gains `cycle.closest_return` with keys `pair`, `ratio`, `seam`, `departure` and `moved`. Where a pair does return but what lies between is not an action (too little contrast or moved, fewer than four active frames, or a departure under three times the steps between its frames), or where no pair departs at all, the 3.12.0 line is printed as before.
+ - Python callers: `loop.ONE_SHOT_RETURN_MAX` names the return bound (0.25). The `CycleSelectionError` diagnostics of `detect_one_shot` carry `closest_return` where some pair departed.
+ - **Docs**: [video-pipeline.md](docs/video-pipeline.md) (section "One-shot actions") documents the return bound `ONE_SHOT_RETURN_MAX`, the refusal line, `cycle.closest_return`, and cutting canvas-crossing jumps with `--cycle once --start S --length L` from the closest return's frames. `SKILL.md` updates its single-play motion guidance with the same command and refusal quote.
+ - **Tests**: `tests/video/test_one_shot_refusal.py` adds five tests drawn with rectangles and no real footage: (1) a leap whose body crosses the canvas is refused on its closest return, naming the pair with the least return over departure in the searched window and matching `closest_return` in the report; (2) the same leap in place is cut from rest to rest; (3) in place, a take-off crouch and a landing crouch that are two different pictures, ending in the landing stance, is refused on its closest return; (4) a stand moved up to 3 px along and up or down every frame is refused across twelve seeds (the test runs one seed); (5) a clip that never departs is refused with the 3.12.0 line and no `closest_return`. Red first: on 3.12.0, 2 failed and 3 passed (tests 1 and 3 refused with `moved 0.00`); on 3.12.1, 5 passed.
+
## v3.12.0 - Prop plate painted on the canvas (video-canvas --prop-plate) and erased from keyed frames (video-frames --prop-plate <canvas report json>)
**Upgrading from 3.11.0: runs without the new options produce unchanged outputs: every canvas, frame, strip, GIF, WebP, and report keeps its exact bytes (with only the loop report's `producer.implementation_sha256` changing with source code changes).**