Skip to content

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

refactor(qa): the inspect-motion report's kind is declared once, as qa.motion.REPORT_KIND, which analyze_motion writes and a scene's stride (scene.model) checks

Soohong Kim96c329bf656a
diff --git a/sprite_gen/qa/motion.py b/sprite_gen/qa/motion.py
index 4c8f412..39be2dc 100644
--- a/sprite_gen/qa/motion.py
+++ b/sprite_gen/qa/motion.py
@@ -38,6 +38,9 @@ if TYPE_CHECKING:
NEAR_SILHOUETTE_IOU = 0.98
+# What an inspect-motion report is (its `kind`): a scene's stride reads a report only when it says this
+# (`scene.model`).
+REPORT_KIND = "sprite-gen-motion-report"
def _number(value, name):
@@ -379,7 +382,7 @@ def analyze_motion(sequence: FrameSequence, *, contacts=None, foot_box=None, fac
if exact or exact_silhouette or near_silhouette:
warnings.append("Repeated poses retain all source frame durations; no frames were removed.")
return {
- "kind": "sprite-gen-motion-report", "version": 1, "status": status,
+ "kind": REPORT_KIND, "version": 1, "status": status,
"frame_count": len(frames), "duration_seconds": elapsed, "size": [width, height],
"anchor_px": anchor, "facing": facing, "contacts": spans, "foot_box": list(box) if box else None,
"duplicate_frames": {"exact": exact, "adjacent_exact": adjacent_exact,
diff --git a/sprite_gen/scene/model.py b/sprite_gen/scene/model.py
index 029344e..e06a425 100644
--- a/sprite_gen/scene/model.py
+++ b/sprite_gen/scene/model.py
@@ -13,6 +13,7 @@ import hashlib
import json
from pathlib import Path
+from sprite_gen.qa.motion import REPORT_KIND as MOTION_REPORT_KIND
from sprite_gen.spec.assets import FrameSequence, finite, load_asset, same_identity
@@ -112,7 +113,7 @@ def bound_stride(measurement, sequence: FrameSequence) -> float:
drive the idle state of the same atlas, and a report taken at another frame
rate cannot drive the sequence at its native timing.
"""
- if not isinstance(measurement, dict) or measurement.get("kind") != "sprite-gen-motion-report":
+ if not isinstance(measurement, dict) or measurement.get("kind") != MOTION_REPORT_KIND:
raise ValueError("stride report must be a sprite-gen-motion-report")
if measurement.get("stride_verified") is not True:
raise ValueError("stride measurement is unverified; provide reliable contact evidence")