Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.
test(video): the held-part and step-screen invariance tests read the 2.39 source record
Soohong Kima810840223e0
diff --git a/tests/video/test_loop_prop_seam_held.py b/tests/video/test_loop_prop_seam_held.pyindex e5e6afe..7901f30 100644--- a/tests/video/test_loop_prop_seam_held.py+++ b/tests/video/test_loop_prop_seam_held.py@@ -362,12 +362,14 @@ def test_cycle_align_aligns_a_two_step_loop_as_the_one_cycle_it_is(held, tmp_patassert "steps" not in json.loads((root / "out" / "loop.strip.json").read_text())-# What v2.35.0 wrote for a loop whose steps nobody counted (no `steps` in its strip metadata):-# aligning it writes exactly these, so a set without a held part is rewritten as before.+# What v2.35.0 wrote for a loop whose steps nobody counted (no `steps` in its strip metadata), and the+# source each cut names since 2.39 (docs/loop-comparison.md): aligning it writes exactly these, so a set+# without a held part is rewritten as before.STRIP_KEYS_2350 = {"body_h", "body_height_target", "body_ref", "body_src_h", "cell_cap", "cell_height_cap", "cycle_align","cycle_drawings", "cycle_frames", "cycle_seconds", "delay_ms", "drawings", "drift_px", "foot_anchor","foot_sway_px", "foot_x", "frames", "h", "kind", "loop", "motion_anchor", "scale", "state", "subsampled","top_margin_px", "w"}+SOURCE_KEYS_2390 = {"sample_indices", "source_cut", "source_rect"}CYCLE_ALIGN_KEYS_2350 = {"between", "cycle_screen", "cycles_given", "drawings", "foot_why", "fps", "from", "made_at","made_by_rife", "nearest_at", "reach_swing", "retake", "seam_ratio", "source", "start_foot","start_foot_source", "stride_swing", "strikes", "taken", "to", "turned_by", "turned_on", "view"}@@ -375,7 +377,16 @@ CYCLE_ALIGN_KEYS_2350 = {"between", "cycle_screen", "cycles_given", "drawings",def test_cycle_align_writes_a_loop_without_a_held_part_as_before(tmp_path):src = tmp_path / "src"- _cut(src, _keyed(src, staff=False))+ report = _cut(src, _keyed(src, staff=False))+ cut = json.loads((src / "out" / "loop.strip.json").read_text())+ # The cut names its cells' source: the keyed frames it read, its window in them, and each cell's frame+ # there — every frame of the window one cell, under one crop.+ start, length = report["cycle"]["start"], report["cycle"]["length"]+ assert cut["frames"] == length and cut["sample_indices"] == list(range(length))+ assert cut["source_cut"] == {"source": report["source"], "start": start, "length": length,+ "samples": list(range(start, start + length))}+ left, top, right, bottom = cut["source_rect"]+ assert cut["scale"] == 1.0 and [right - left, bottom - top, top] == [cut["w"], cut["h"], cut["top_margin_px"]]dirs = []for name in ("a", "b"):shutil.copytree(src / "out", tmp_path / name)@@ -384,4 +395,10 @@ def test_cycle_align_writes_a_loop_without_a_held_part_as_before(tmp_path):assert all("cycles_kept" not in row and "steps" not in row for row in out["loops"])for d in dirs:meta = json.loads((d / "loop.strip.json").read_text())- assert set(meta) == STRIP_KEYS_2350 and set(meta["cycle_align"]) == CYCLE_ALIGN_KEYS_2350+ assert set(meta) == STRIP_KEYS_2350 | SOURCE_KEYS_2390+ assert set(meta["cycle_align"]) == CYCLE_ALIGN_KEYS_2350+ # The cut's source stays as the cut wrote it: `cycle_align` says the cells were turned after it, so it+ # no longer names each cell's frame (docs/loop-comparison.md). The rebuilt strip names its own cells —+ # the same frames, turned, under the same crop.+ assert meta["source_cut"] == cut["source_cut"]+ assert meta["sample_indices"] == list(range(length)) and meta["source_rect"] == cut["source_rect"]diff --git a/tests/video/test_one_step_cut.py b/tests/video/test_one_step_cut.pyindex 462cc11..5ab7c23 100644--- a/tests/video/test_one_step_cut.py+++ b/tests/video/test_one_step_cut.py@@ -105,8 +105,11 @@ def _same_but_the_screen(a: Path, b: Path) -> None:assert frames == sorted(p.name for p in (b / "cycle").glob("*.png"))assert all((a / "cycle" / f).read_bytes() == (b / "cycle" / f).read_bytes() for f in frames)left, right = (json.loads((d / "loop.loop.report.json").read_text().replace(str(d), "@")) for d in (a, b))- left["cycle"].pop("step_screen")- right["cycle"].pop("step_screen")+ for report in (left, right):+ # The gait observation keeps a copy of the screen's record (sprite_gen/video/evidence.py): each+ # report's copy is its own record, and nothing else of the gait is set aside with it.+ screens = report["gait"]["screens"]+ assert "step_screen" in screens and screens.pop("step_screen") == report["cycle"].pop("step_screen")assert left == right@@ -114,7 +117,8 @@ def _same_but_the_screen(a: Path, b: Path) -> None:def test_the_step_screen_changes_nothing_but_its_own_record(tmp_path, monkeypatch, cycle, suspect):"""A one-step cut, a cycle on a frame count that is not whole (23.5 frames: twice it repeatsbetter, being whole there — a suspect that is no step) and a whole cycle of 25: with the screen- or without it, every image, the strip metadata and the report are the same but for its record."""+ or without it, every image, the strip metadata and the report are the same but for its record, and+ the gait observation's copy of it."""keyed = _keyed(tmp_path, cycle)report = _cut(tmp_path / "screened", keyed)assert report["cycle"]["step_screen"]["suspect"] is suspect