feat(u7): filename groups — the last v1 unit, and a table that did not reproduce
Completes U7 with its fourth component: a jump-to-group rail derived from filename prefixes, replacing the subfolder sections ROADMAP named. The scope departure was ratified by the operator 2026-09-22; this commit deletes test_no_group_rail_is_shipped_yet, the guard that held it back, in the same change that builds what it guarded against. All seven v1 capabilities are now landed. The 1.0 cut is a decision, not a dependency, and it is the operator's — no version bump here, because a commit is not a release. THE RULE CHANGED AT IMPLEMENTATION, ON MEASURED GROUNDS. The contract specified `strip ONE trailing run of digits`; run against the live set that yields 24 groups for sindra-bakeoff's 40 images and 27 for sindra's 30 — a rail with a row per tile — because it keys on the END of the stem, where the instance number lives. The contract's own table claimed 5 and 1 for those two booths and neither reproduces; the numbers are reachable only by two OTHER heuristics, so the table that justified the design was assembled from more than one rule. Its own worked example contradicts it in plain sight. The shipped rule keys on the first separator-delimited segment, where the family lives, destemming only when the stem has no separator at all — so `ac01` -> `ac` while `v30-seed8302` and `v35-seed8302` stay apart. Re-measured across all 17 live booths; the table is in the contract. INV-3 GAINED ITS SECOND DEGENERACY. The contract guarded one group for everything (sc-iso-spread: DSC0001-DSC0006). The live set's actual failure is the opposite — pewpew-ui-brief yields 23 groups for 34 items, dfa-concepts 13 for 20 — and the contract as written would have shipped a rail that is a second copy of the grid. The rail now renders only when grouping is informative: two or more groups, and the middle group holding more than one item. That predicate gets all 17 booths right. Grouping is a VIEW. The grid stays sorted(rel) and the zoom ring stays that order filtered to images; the group fixture interleaves across subdirectories precisely so a (group, rel) re-sort goes red. Groups are derived from the RENDERED list, not the full gallery, so no anchor points at a filtered-out tile. booth/items.py _group_of + Item.group, derived in the resolver (INV-1) booth/app.py _groups() builds the rail rows; build_gallery carries it booth/templates/ the rail-groups nav and its CSS tests/ +16 tests; 639 green Every new falsifier was proved by running its defeating change (12/12). Three were vacuous first time out: one fixture's positional order happened to be alphabetical, one assertion miscounted elements, and the harness itself certified a broken test twice — no green baseline, and byte-identical mutations silently defeated by the pyc cache's one-second mtime granularity.
This commit is contained in:
@@ -258,3 +258,61 @@ def test_list_booths_counts_match_the_resolver(tmp_path):
|
||||
|
||||
got = list_booths(tmp_path, ttl_seconds=86400)[0]
|
||||
assert got["count"] == len(booth_items(b)) == 2
|
||||
|
||||
|
||||
# --- U7: the group, derived here and nowhere else -------------------------
|
||||
#
|
||||
# ⚠ THE RULE IS NOT THE ONE THE CONTRACT FIRST STATED, and the change is
|
||||
# measured rather than preferred. The contract's `strip ONE trailing run of
|
||||
# digits` yields 24 groups for sindra-bakeoff's 40 images and 27 for sindra's
|
||||
# 30 — a rail with one row per tile, which is a second copy of the grid rather
|
||||
# than a way through it. Measured against all 17 live booths on 2026-09-22;
|
||||
# the numbers are in the contract's rewritten table.
|
||||
|
||||
|
||||
def test_group_of_takes_the_first_segment(tmp_path):
|
||||
from booth.items import _group_of
|
||||
|
||||
assert _group_of("00-sheet-c1-market-noon.png") == "00"
|
||||
assert _group_of("m-c1-market-noon-9401.png") == "m"
|
||||
assert _group_of("flag-rear.png") == "flag"
|
||||
assert _group_of("v30-seed8302-HELD.png") == "v30"
|
||||
|
||||
|
||||
def test_group_of_destems_only_a_flat_name(tmp_path):
|
||||
"""`ac01.png` has no separator, so the digits ARE the separator and the
|
||||
group is `ac`. `v30-seed8302` HAS one, so `v30` survives intact — stripping
|
||||
there would merge v30 with v35, which is the axis that booth is about."""
|
||||
from booth.items import _group_of
|
||||
|
||||
assert _group_of("ac01.png") == "ac"
|
||||
assert _group_of("DSC0001.jpg") == "DSC"
|
||||
assert _group_of("v30-seed8302.png") == "v30"
|
||||
assert _group_of("v35-seed8302.png") == "v35"
|
||||
|
||||
|
||||
def test_group_of_is_none_when_there_is_no_prefix(tmp_path):
|
||||
"""A stem that is entirely digits has nothing to group on. Inventing one
|
||||
would file every numbered render under the empty string."""
|
||||
from booth.items import _group_of
|
||||
|
||||
assert _group_of("01.png") is None
|
||||
assert _group_of("0042.jpg") is None
|
||||
assert _group_of("-leading.png") is None
|
||||
|
||||
|
||||
def test_group_is_derived_from_the_basename_not_the_path(tmp_path):
|
||||
"""A booth WITH subdirectories still groups on the filename. Sections and
|
||||
groups are different questions; `Item.section` still carries the path."""
|
||||
from booth.items import _group_of
|
||||
|
||||
assert _group_of("sub/dir/ac01.png") == "ac"
|
||||
|
||||
|
||||
def test_booth_items_carries_the_group(tmp_path):
|
||||
b = tmp_path / "g"
|
||||
_touch(b / "ac01.png")
|
||||
_touch(b / "ac02.png")
|
||||
_touch(b / "99.png")
|
||||
got = {it.rel: it.group for it in booth_items(b)}
|
||||
assert got == {"ac01.png": "ac", "ac02.png": "ac", "99.png": None}
|
||||
|
||||
Reference in New Issue
Block a user