Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.
test(video): --anchor body reads a cell given way as filmed in the wrap after its ramp; ghosts at both ends at once
Soohong Kim25b515b2c962
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0f5c90b..aff8ae2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -14,7 +14,7 @@ All notable public changes to `sprite-gen` are recorded here. Versions track the- **Fix: a GIF or WebP that holds a frame shown twice in a row passes its check.** Both formats hold two identical frames in a row as one frame of twice the delay, and `video-loop` checked its GIF and WebP for one frame per cell: a cut with two identical frames in a row — what giving a ghost way to the frame beside it leaves — failed (`walk.gif failed verification: 19 frames, expected 20`). `video-loop` and `video-follow` now check for one frame per run of identical cells, as `video-cycle-align` already did (`loop.shown_runs`), and the restoration's playback check (`playback.verify`) reads such a run as one frame held for the sum of its delays (in hundredths of a second in the GIF, as it stores it); its `strip_indices` still lists every scheduled cell.- **Output change: source restoration reads the ghost — the ghost guard.** A cell `video-loop` gave a filmed ghost way is a cell the jump repair replaced, and its source frame is the ghost: the source's pixels clear any fault the cell carries, the smear and outline faults measure a frame only against its neighbours, and partial coverage was read only beyond the source reference's own, which is the ghost — so `source-restoration-v4` could propose the cell and accept the ghost back. Now no cell whose source frame the cut's ghost screen names (`interpolation_quality.ghost_screen` on the cropped source frames, at their own size, as the cut read them) is a target; every final cell's faults carry its own ghost reading where the screen reads the loop; and the comparison's new `axes.ghost` reads each cell's own `rife.ghost` on final pixels (`baseline`, `candidate`, `reference`, `threshold` 0.003, `filmed` — the screen), any rise of the excess over the limit `regressed` with `ghost:regressed`. A loop the screen does not read is not judged (`reason: "loop-drawn-part-covered"`). [docs/loop-comparison.md](docs/loop-comparison.md#the-ghost-guard).- **Contract versions: repair report schema 4, comparison schema 6, metric `source-restoration-v5`, policy `key-protected-source-copy-one-step-cap-jump-ghost-guard-v1`.** A restored cell's pixels are made as in v4. Evidence and receipts of `source-restoration-v4` (2.40.0 – 2.43.0) are refused, never read as v5: a v4 repair report given to `video-loop-compare` is an input error, and a request whose baseline carries a v4 receipt in its loop report is shared `unknown`, `restoration-receipt-policy-unsupported`. The origin itself is still a valid first request. Proposal IDs change with the versions. `video-loop-compare` without the origin and the source (`same-sample-defects-v1`) is unchanged.-- **`tests/video/test_ghost_given_way.py`** draws the walk of `tests/video/test_cycle_align.py` with a band of 0.3 coverage beside the foot: a small one, four times the ghost limit and no jump, delivered as cut before and now given way to RIFE's frame between its neighbours (a stand-in that draws the walk's true frame) or, without RIFE, to the frame after it, the GIF and WebP holding it as one frame; two identical frames in a row passing the check; three ghosts in a row, the middle one kept and named; a wide band that also reads as a jump, named by the screen read before the repair; `--repair off` and `--repair on` without RIFE; an alignment reading the cut given way and carrying its record; with the default seam gate, the walk cut where its wrap is an ordinary step, its ghost at the cut's first frame given way without RIFE or with RIFE's frame a ghost too (refused before, 2.17 times the mean step), at its last given way to its first (read 0.0 before), both beside a frame made, and a cut that does not close whose last frame gives way to its first (delivered before); the side walker of `tests/video/test_one_step_cut.py` cut with the application's walk flags (`--anchor motion-auto --size-hold auto --body-height 160`), through a stand-in and through the real RIFE (marked `real_rife`); and the cut's source projection proving every other cell and listing the cell given way, a restoration request reading its playback and proposing nothing there. `tests/video/test_source_restoration.py` adds a source frame that is a filmed ghost the smear and outline faults pass, whose cell v4 proposed first: it is no target, and the ghost restored there regresses.+- **`tests/video/test_ghost_given_way.py`** draws the walk of `tests/video/test_cycle_align.py` with a band of 0.3 coverage beside the foot: a small one, four times the ghost limit and no jump, delivered as cut before and now given way to RIFE's frame between its neighbours (a stand-in that draws the walk's true frame) or, without RIFE, to the frame after it, the GIF and WebP holding it as one frame; two identical frames in a row passing the check; three ghosts in a row, the middle one kept and named; a wide band that also reads as a jump, named by the screen read before the repair; `--repair off` and `--repair on` without RIFE; an alignment reading the cut given way and carrying its record; with the default seam gate, the walk cut where its wrap is an ordinary step, its ghost at the cut's first frame given way without RIFE or with RIFE's frame a ghost too (refused before, 2.17 times the mean step), at its last given way to its first (read 0.0 before), both beside a frame made, ghosts at its first and last frames at once given way inward (refused before, 2.40), and a cut that does not close whose last frame gives way to its first (delivered before), under `--anchor none` and `--anchor body`; under `--anchor body`, the walk's default, the strip's `seam_ratio_after_anchor` reading a ghost given way at the cut's first frame, its last or both as `--repair off` reads it (read on `cycle/` before: 0.0 at the last); the side walker of `tests/video/test_one_step_cut.py` cut with the application's walk flags (`--anchor motion-auto --size-hold auto --body-height 160`), through a stand-in and through the real RIFE (marked `real_rife`); and the cut's source projection proving every other cell and listing the cell given way, a restoration request reading its playback and proposing nothing there. `tests/video/test_source_restoration.py` adds a source frame that is a filmed ghost the smear and outline faults pass, whose cell v4 proposed first: it is no target, and the ghost restored there regresses.- **`tests/video/test_ghost_retake.py`** reproduces on the synthetic legs of `tests/video/test_ghost_screen.py` a ghost kept at a whole time (three in a row), one kept at a time made between two (the stand-in RIFE, and the real one, marked `real_rife`), and a held loop on twos that keeps ghosts too (both reasons, `held-drawings` first); under `--between rife` only the ghost with no clean frame beside it is counted; the fault line names the kept cell as it is.## v2.43.0 - No loop delivers a ghost frame unmeasured; a cross-fade inside one silhouette is named, not judgeddiff --git a/tests/video/test_ghost_given_way.py b/tests/video/test_ghost_given_way.pyindex c3bffde..e17b560 100644--- a/tests/video/test_ghost_given_way.py+++ b/tests/video/test_ghost_given_way.py@@ -10,6 +10,7 @@ the GIF and WebP are checked for one frame per run of identical cells (a cell gibeside it is that frame shown twice in a row). The seam gate, on in every cut here, reads a cell givenway to the frame beside it as filmed (`seam_as_filmed`): at the wrap that frame twice in a row is astep of two or a step of nothing, which would refuse a cut that closes or pass one that does not.+`--anchor body`, the walk's default, reads the wrap of its strip (`seam_ratio_after_anchor`) the same way.The fixtures are synthetic: the walk of tests/video/test_cycle_align.py (a body and a foot going round,20 frames a cycle) with a band of 0.3 coverage beside the foot (tests/video/test_ghost_screen.py `_band`)@@ -58,12 +59,12 @@ def _keyed(root: Path, name: str, ghosts: tuple[int, ...], box=SMALL, phase: intreturn keyed-def _cut(keyed: Path, out: Path, length: int = L, **kw) -> dict:- """`video-loop --cycle fixed --start 0 --anchor none` with the jump repair (auto unless given) and the seam gate,- the default `--seam-max` the application cuts with."""+def _cut(keyed: Path, out: Path, length: int = L, anchor: str = "none", **kw) -> dict:+ """`video-loop --cycle fixed --start 0 --anchor none` (or the anchor given) with the jump repair (auto unless given)+ and the seam gate, the default `--seam-max` the application cuts with."""return loop_mod.run_loop(keyed, out, fps=24.0, state="walk", min_len=None, max_len=None, n_out=None,seam_max=loop_mod.SEAM_RATIO_MAX, name="walk", report_path=None, cycle_mode="fixed", start=0,- length=length, anchor="none", **kw)+ length=length, anchor=anchor, **kw)class _Middle:@@ -320,19 +321,38 @@ def test_a_ghost_at_the_cuts_last_frame_given_way_to_its_first_leaves_the_seam_tassert report["seam_as_filmed"] == [L - 1] and report["seam_measurement"] == "source-frames"+def test_ghosts_at_both_ends_of_the_cut_given_way_inward_leave_the_seam_the_cut_closes_with(tmp_path, monkeypatch):+ """Filmed ghosts at the cut's first and last frames at once: across the wrap each has the other beside it, so no+ frame is made between its neighbours — frame 0 gives way to the frame after it, the last frame to the one before+ it — and the GIF and WebP hold two runs of two. On the cells as they play the wrap was three steps (2.40, refused).+ Read as filmed, it is the seam `--repair off` reads."""+ filmed = _cut(_keyed(tmp_path, "filmed", (0, L - 1), phase=EVEN), tmp_path / "filmed", repair="off")+ _no_rife(monkeypatch, tmp_path)+ report = _cut(_keyed(tmp_path, "E", (0, L - 1), phase=EVEN), tmp_path / "E") # before: refused+ out = tmp_path / "E"+ assert [(g["frame"], g["taken"]) for g in report["ghost_given_way"]] == [(0, {"source": 1}), (L - 1, {"source": L - 2})]+ assert _cycle(out, 0).tobytes() == _cycle(out, 1).tobytes() and _cycle(out, L - 1).tobytes() == _cycle(out, L - 2).tobytes()+ _delivered_clean(out)+ assert report["seam_as_filmed"] == [0, L - 1] and report["seam_measurement"] == "source-frames"+ assert report["resampled_seam_ratio"] == filmed["resampled_seam_ratio"] < loop_mod.SEAM_RATIO_MAX+ assert report["gif"]["n_frames"] == report["webp"]["n_frames"] == L - 2++SHORT = 14 # a cut six frames short of the walk's cycle: its wrap is six steps and does not close-def test_a_cut_that_does_not_close_is_refused_though_its_last_frame_gives_way_to_its_first(tmp_path, monkeypatch):[email protected]("anchor", ["none", "body"])+def test_a_cut_that_does_not_close_is_refused_though_its_last_frame_gives_way_to_its_first(tmp_path, monkeypatch, anchor):"""A cut 14 frames long of a walk 20 frames a cycle does not close (`--repair off` refuses it); its last frame a- filmed ghost given way to its first, the wrap read on the cells was a step of nothing and the cut was delivered.- Read as filmed, it is refused as it is filmed."""+ filmed ghost given way to its first, the wrap read on the cells was a step of nothing and the cut was delivered,+ under `--anchor body` (the walk's default) as under `none`. Read as filmed, it is refused as it is filmed."""with pytest.raises(SystemExit, match="the cycle does not close"):- _cut(_keyed(tmp_path, "filmed", (SHORT - 1,), phase=EVEN), tmp_path / "filmed", length=SHORT, repair="off")+ _cut(_keyed(tmp_path, "filmed", (SHORT - 1,), phase=EVEN), tmp_path / "filmed", length=SHORT, anchor=anchor,+ repair="off")filmed = json.loads((tmp_path / "filmed" / "walk.loop.report.json").read_text())_no_rife(monkeypatch, tmp_path)with pytest.raises(SystemExit, match="the cycle does not close"): # before: delivered, the seam read 0.0- _cut(_keyed(tmp_path, "E", (SHORT - 1,), phase=EVEN), tmp_path / "E", length=SHORT)+ _cut(_keyed(tmp_path, "E", (SHORT - 1,), phase=EVEN), tmp_path / "E", length=SHORT, anchor=anchor)report = json.loads((tmp_path / "E" / "walk.loop.report.json").read_text())assert [(g["frame"], g["taken"]) for g in report["ghost_given_way"]] == [(SHORT - 1, {"source": 0})]assert report["seam_as_filmed"] == [SHORT - 1]@@ -356,6 +376,27 @@ def test_a_cut_with_a_frame_made_reads_its_cell_given_way_as_filmed_on_the_cells_delivered_clean(tmp_path / "E")[email protected]("ghosts", [(0,), (L - 1,), (0, L - 1)], ids=["first", "last", "both"])+def test_anchor_body_reads_a_cell_given_way_as_filmed_in_the_wrap_after_its_ramp(tmp_path, monkeypatch, ghosts):+ """`--anchor body`, the walk's default, ramps the cut so its last frame returns to its first and records the wrap+ as it then plays in the strip metadata (`seam_ratio_after_anchor`: the last frame against the first, over the mean+ step). Read on `cycle/`, a ghost at the cut's last frame given way to its first was no step at all (0.0, as the+ gate read it too), and one at the first frame given way to the second two steps (the gate refused it, 2.17; 2.40+ with both ends). The gate and the wrap after the ramp read a cell given way as filmed: what `--repair off` reads."""+ filmed = _cut(_keyed(tmp_path, "filmed", ghosts, phase=EVEN), tmp_path / "filmed", anchor="body", repair="off")+ _no_rife(monkeypatch, tmp_path)+ report = _cut(_keyed(tmp_path, "E", ghosts, phase=EVEN), tmp_path / "E", anchor="body") # before: refused, or 0.0++ def seams(r: dict) -> tuple[float, float]:+ return r["resampled_seam_ratio"], r["strip"]["seam_ratio_after_anchor"]++ assert seams(report) == seams(filmed)+ assert filmed["resampled_seam_ratio"] < loop_mod.SEAM_RATIO_MAX and filmed["strip"]["seam_ratio_after_anchor"] > 0.5+ assert [g["frame"] for g in report["ghost_given_way"]] == sorted(ghosts)+ assert report["seam_as_filmed"] == sorted(ghosts) and report["seam_measurement"] == "source-frames"+ _delivered_clean(tmp_path / "E")++# --- the application's walk: motion anchoring, size hold, body height ------------------------------