Skip to content

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

fix(gen): remove the retired generate_image shim that shadowed the generate_image() function

Soohong Kima84ce9516cc1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4bad17e..3cdb3eb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ All notable public changes to `sprite-gen` are recorded here. Versions track the
- New `video-extend` (`POST /v1/videos/extensions`) continues a 2–15 s clip by 2–10 s and new `video-edit` (`POST /v1/videos/edits`) changes a clip of at most 8.7 s with a prompt. Both force the classic `grok-imagine-video` model (the 1.5 model refuses both endpoints), take no resolution / aspect / model flags because the output inherits the input's, check the input with ffprobe before uploading, and `video-extend` refuses a result shorter than its input.
- Local pre-checks refuse, before any call: no input at all, more than 7 references, `<IMAGE_n>` tags outside the given references (or with none), 1080p with references, and `last_frame` / `image`+`reference` on the classic model.
- The `sprite-gen-video-report` carries `mode` (`image-to-video`, `first-last`, `last-frame`, `reference`, `extend`, `edit`), `inputs` (local paths by role) and, for extend / edit, `input_duration`; every existing field stays.
+- Removed the retired `sprite_gen/gen/generate_image.py` shim. It shared its name with the `generate_image()` function that `sprite_gen.gen` exports, so `import sprite_gen.gen.generate_image` replaced the function with the shim module for the rest of the process and the next `sprite_gen.gen.run()` died with `TypeError: 'module' object is not callable` — at runtime, not only under pytest. Nothing routed to the shim (no CLI verb, no `-m` step, no MCP entry), so the fix is deletion: the old module path now fails with `ModuleNotFoundError`, and the only image-generation entry point remains `sprite_gen.gen` / `sprite-gen gen`. `sprite_gen._modules.MODULE_DOMAIN` and the packaging import-surface list drop the row; the `import_probe` fixture stays as a general isolation device.
- Test isolation: the packaging import-surface probe now restores the parent package attribute and `sys.modules` entry it touched, so importing the retired `sprite_gen.gen.generate_image` shim no longer replaces the `generate_image()` function for later `tests/gen` runs. `pytest tests/packaging tests/gen` is green in any order.
- Test isolation: `tests/curate` imports its shared helper from `tests/frames` through the `tests/` root instead of by bare module name, so `pytest tests/curate` passes on its own instead of depending on `tests/frames` having been collected first.
- The expired-login prescription for Grok video and images no longer names a bare prompt (`grok -p ok`): on the grok CLI that starts the coding agent in the current directory, which can read, write and spend on its own. The prescription is now a non-agent round-trip (`grok models`) run from an empty directory, with `grok login` as the fallback, and the message says so. A test pins the prescription to a non-agent command.
diff --git a/docs/frame-interpolation.md b/docs/frame-interpolation.md
index ab58ee1..399d448 100644
--- a/docs/frame-interpolation.md
+++ b/docs/frame-interpolation.md
@@ -75,7 +75,7 @@ instead of a manifest-consistency error.
3. Canvas pads to /32 on the request chroma color; the prompt requires the same flat
chroma background so the extractor keys it out later.
4. `tween_prompt` composes the prompt deterministically from request truth (character
- description, chroma color, t) and `sprite_gen.gen.generate_image` runs the provider
+ description, chroma color, t) and `sprite_gen.gen.generate_image()` runs the provider
with both frames attached as refs.
5. The generated mid frame is saved as the take raw; extraction re-derives the state
row (the frame appears labeled `<label>#0`) and pixel-unfake quantization snaps it
diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md
index 78e8354..247d9ef 100644
--- a/docs/troubleshooting.md
+++ b/docs/troubleshooting.md
@@ -55,20 +55,25 @@
500(`ffmpeg not found`)을 준다. GIF 는 ffmpeg 없이 동작.
- **대처**: 서버 머신에 ffmpeg 설치 (`brew install ffmpeg` 등).
-## 테스트 스위트가 순서에 따라 깨짐 (`pytest tests/packaging tests/gen` 만 빨강)
+## 테스트 스위트가 순서에 따라 깨짐 (`pytest tests/packaging tests/gen` 만 빨강) — 제거됨
-- **증상**: `pytest tests/gen` 과 `pytest tests/packaging` 은 각각 초록인데 한 세션에서
+- **상태**: 2026-09-13 원인 제거(플랜 `gen-generate-image-shim-removal`, v2.3.0). 아래는 기록.
+- **증상(과거)**: `pytest tests/gen` 과 `pytest tests/packaging` 은 각각 초록인데 한 세션에서
packaging → gen 순으로 돌리면 `tests/gen` 이 `TypeError: 'module' object is not
- callable` 로 수십 건 실패.
-- **원인**: 패키징 import-surface 테스트가 `sprite_gen.gen.generate_image` (은퇴한 shim
- 모듈)를 import 한다. 파이썬은 서브모듈을 import 하면 부모 패키지에 같은 이름의
- 속성으로 바인딩하는데, `sprite_gen.gen` 은 이미 같은 이름의 함수
- `generate_image()` 를 export 하므로 함수가 모듈로 덮여 세션 끝까지 남는다.
- `gen.run()` 은 그 이름을 호출하니 이후 gen 테스트 전부가 죽는다.
-- **격리 방식**: `tests/packaging/test_package_surface.py` 의 `import_probe` 픽스처가
- import 전에 부모 속성과 `sys.modules` 항목을 기록하고 테스트 뒤 되돌린다. 프로덕트
- 코드는 그대로다 — 함수와 shim 모듈의 이름 충돌 자체는 남아 있으니, 런타임에서
- `import sprite_gen.gen.generate_image` 를 실행하는 코드는 같은 덮어쓰기를 일으킨다.
+ callable` 로 수십 건 실패. 테스트만의 문제가 아니라 런타임에서도
+ `import sprite_gen.gen.generate_image` 한 줄이 같은 죽음을 일으켰다.
+- **원인(과거)**: 은퇴한 shim 모듈 `sprite_gen/gen/generate_image.py` 가 같은 패키지가
+ export 하는 함수 `generate_image()` 와 이름이 같았다. 파이썬은 서브모듈을 import 하면
+ 부모 패키지에 같은 이름의 속성으로 바인딩하므로 함수가 모듈로 덮여 세션 끝까지 남고,
+ `gen.run()` 은 그 이름을 호출하니 이후 모든 생성이 죽는다.
+- **수리**: shim 모듈을 삭제했다(개명이 아니라 삭제 — 그 경로를 부르는 CLI 동사·MCP 표면·
+ 코드 참조가 0건이라 남길 이름이 없었다). `sprite_gen._modules.MODULE_DOMAIN` 과
+ 패키징 import-surface 목록에서도 행을 뺐다. 이제 `sprite_gen.gen.generate_image` 는
+ 어떤 import 순서에서도 함수로만 해석되고, 옛 모듈 경로 import 는
+ `ModuleNotFoundError` 로 loud 하게 실패한다. 이미지 생성 진입점은 `sprite_gen.gen`
+ / CLI `sprite-gen gen` 하나다.
+- **잔존 장치**: `tests/packaging/test_package_surface.py` 의 `import_probe` 픽스처는
+ 일반 격리 장치로 유지한다(서브모듈 import 가 부모 속성을 덮는 규칙 자체는 남아 있다).
- **확인**: `pytest tests/packaging tests/gen`, `pytest tests/gen tests/packaging`,
`pytest tests/` 가 모두 같은 결과여야 한다.
- **같은 계열(2026-09-13 수리)**: `tests/curate` 가 `tests/frames` 의 헬퍼를 bare 이름
diff --git a/sprite_gen/_modules.py b/sprite_gen/_modules.py
index d0d7c21..2250f0f 100644
--- a/sprite_gen/_modules.py
+++ b/sprite_gen/_modules.py
@@ -19,7 +19,6 @@ MODULE_DOMAIN = {
'layout': 'spec',
'migrate_request': 'spec',
'migrate_breathe': 'spec',
- 'generate_image': 'gen',
'video': 'gen',
'gen_set': 'gen',
'canvas': 'video',
diff --git a/sprite_gen/gen/generate_image.py b/sprite_gen/gen/generate_image.py
deleted file mode 100644
index e6f7e63..0000000
--- a/sprite_gen/gen/generate_image.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# SPDX-License-Identifier: Apache-2.0
-"""Deprecated shim — image generation now lives in `sprite_gen.gen`.
-
-This module previously stood in as a desktop-only placeholder during the package
-split. Provider-backed generation (codex `image_gen`, grok Imagine) is now a
-first-class engine module: `sprite_gen.gen` / CLI `sprite-gen gen`. Keeping two
-generation surfaces would violate SSoT, so this shim redirects and fails loudly
-if called directly.
-"""
-
-from __future__ import annotations
-
-
-def run(**_kwargs: object) -> int:
- raise SystemExit(
- "sprite_gen.gen.generate_image is retired — use `sprite_gen.gen` "
- "(CLI: `sprite-gen gen --provider codex|grok --prompt ... --out ...`)"
- )
diff --git a/tests/packaging/test_package_surface.py b/tests/packaging/test_package_surface.py
index 2003a39..d4d0dab 100644
--- a/tests/packaging/test_package_surface.py
+++ b/tests/packaging/test_package_surface.py
@@ -30,7 +30,6 @@ PACKAGE_RUN_MODULES = [
"extract",
"gen",
"gen_set",
- "generate_image",
"inspect",
"prepare",
"preview",
@@ -63,14 +62,14 @@ def _read_skill_version() -> str:
def import_probe():
"""Import a module for inspection and leave the process as it was.
- Importing a submodule binds it as an attribute on its parent package. When the
- submodule shares its name with a function the package already exports
- (`sprite_gen.gen.generate_image` is a retired shim next to the live
- `sprite_gen.gen.generate_image()` function), that binding replaces the function
- for the rest of the session and every later `gen.run()` dies with
- `'module' object is not callable`. The probe records the parent attribute and the
- `sys.modules` entry before importing and restores both afterwards, so this test
- observes the package without rewriting it for tests that run after it.
+ Importing a submodule binds it as an attribute on its parent package. If a
+ submodule ever shares its name with an attribute the package already exports,
+ that binding replaces the attribute for the rest of the session (the retired
+ `sprite_gen.gen.generate_image` shim did exactly that to the live
+ `generate_image()` function until it was removed on 2026-09-13). The probe records
+ the parent attribute and the `sys.modules` entry before importing and restores
+ both afterwards, so this test observes the package without rewriting it for
+ tests that run after it — a general isolation device, not a fix for any one clash.
"""
restores: list[tuple[object, str, object]] = []
fresh_modules: list[str] = []