World: tags follow the sketch across versions; tag filter resolves latest first - #1353
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
Downloading
dx7_groove_128_bpmfrom 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 forgenerator/dx7_groove_128_bpm.py. The migration scripts re-upload each rewritten sketch as a new version without copying tags, and_list_file_rowsapplied?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
_list_file_rowsnow 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 therank = 1rows. 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=falseis unchanged._insert_file_rowinherits the previous live version's tags (case-insensitive username match). Caller-supplied hardware tags (the generator's detector) replace inherited hardware tags;featuredand 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.pycopies the union of superseded versions' tags onto the latest version via the admin tags endpoint. Report mode by default;--applywrites. Token fromAMYBOARDWORLD_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=falsestill lists all, inheritance on re-upload incl. case-insensitive usernames and hardware-tag replacement.test_latest_dedup.pyandtest_hardware_tags.pystill pass.🤖 Generated with Claude Code