Skip to content

World: tags follow the sketch across versions; tag filter resolves latest first - #1353

Merged
bwhitman merged 1 commit into
mainfrom
world-tags-latest-version
Sep 10, 2026
Merged

World: tags follow the sketch across versions; tag filter resolves latest first#1353
bwhitman merged 1 commit into
mainfrom
world-tags-latest-version

Conversation

@bwhitman

Copy link
Copy Markdown
Collaborator

The bug

Downloading dx7_groove_128_bpm from AMYboard World's #featured chip gave the pre-migration source (def loop():), while browsing the plain list gave the migrated one (def loop(tick):). Same for Dan vs Brian — it depended on which route you clicked, not on browser cache.

Row 920 (original, tagged featured, def loop():) and row 1187 (loop-arg migration re-upload, no tags, def loop(tick):) both exist for generator/dx7_groove_128_bpm.py. The migration scripts re-upload each rewritten sketch as a new version without copying tags, and _list_file_rows applied ?tag= before deduping to the latest version per (username, filename). So the featured filter only ever saw the stale row and served it.

Scope in production: all 17 featured sketches plus 257 hardware-tagged generator sketches (#display, #cv, …) have their tags stuck on a superseded version.

Server fixes

  • Listing_list_file_rows now ranks versions with a window function over all live rows first (ROW_NUMBER() OVER (PARTITION BY lower(username), lower(filename) ORDER BY created_at_ms DESC, id DESC)), then applies q / tag / username filters to the rank = 1 rows. A filter can only ever match a sketch's current version. Keeps the highest-id tie-break from AMYboard I2C follower: frame messages instead of dispatching raw reads #1345-era dedup fix; latest_per_user_env=false is unchanged.
  • Upload_insert_file_row inherits the previous live version's tags (case-insensitive username match). Caller-supplied hardware tags (the generator's detector) replace inherited hardware tags; featured and other curation tags survive. This also fixes a regular user re-saving their featured sketch from the web silently losing the tag, and means the migration scripts need no changes.

Data backfill

tulip/server/backfill_world_tags.py copies the union of superseded versions' tags onto the latest version via the admin tags endpoint. Report mode by default; --apply writes. Token from AMYBOARDWORLD_ADMIN_TOKEN (e.g. railway run python3 tulip/server/backfill_world_tags.py --apply). Report mode against production currently plans 274 updates in amyboardworld, 0 in tulipworld.

Tests

tulip/server/test_tag_versions.py (new, 13 checks) — stale tagged version never surfaces under ?tag= or ?q=, soft-deleting the latest reveals the previous, latest_per_user_env=false still lists all, inheritance on re-upload incl. case-insensitive usernames and hardware-tag replacement. test_latest_dedup.py and test_hardware_tags.py still pass.

🤖 Generated with Claude Code

…test first

The loop(tick) migration (and the ticks= one before it) re-uploaded every
World sketch as a new version without copying the old row's tags. The listing
then applied ?tag= *before* deduping to the latest version per
(username, filename), so the #featured chip served the stale tagged row
(`def loop():`) while the plain listing served the migrated one — the
"it works for Dan but not for me" bug. All 17 featured sketches and 257
hardware-tagged generator sketches were affected.

Server fixes:
- _list_file_rows resolves the latest live version per (username, filename)
  with a window function first, then applies q/tag/username filters, so a
  filter can only ever match a sketch's current version.
- _insert_file_row inherits the previous live version's tags (case-insensitive
  username match). Caller-detected hardware tags replace inherited hardware
  tags; #featured and other curation tags survive. This also fixes a regular
  user re-saving their featured sketch from the web losing the tag.

Data: backfill_world_tags.py copies tags from superseded versions onto the
latest one via the admin tags endpoint (report mode by default, --apply to
write; token from AMYBOARDWORLD_ADMIN_TOKEN, e.g. under `railway run`).

Tests: test_tag_versions.py; existing test_latest_dedup.py and
test_hardware_tags.py still pass.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@bwhitman
bwhitman merged commit 0f47614 into main Sep 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant