feat(seed): stable slug-derived ids (stop dump churn) - #63
Merged
Merged
Conversation
The dump exposes `id`, and an autoincrement counter renumbered every row after an inserted record, so a regenerated dump rewrote pages whose data had not changed. That is what made TechAPI #180 ~1M files: GitHub could render neither its diff nor its merge (502), and the dump PR had to be merged blind. Ids are now blake2b(table:slug) truncated to 48 bits — deterministic, independent of insertion order, and inside the JSON-safe integer range. A collision rehashes with a suffix rather than falling back to a counter. Refs #1
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.
Prerequisite for splitting
gamesout into a satellite repo.Problem.
idis part of the public response (/v1/brands/3dfxetc.), but it came from an autoincrement counter, so inserting one record renumbered everything after it. Sampling #180 showed brand pages differing only inid(3dfx 145→155, acer 128→135) — every category's tree hash changed. That is why the dump PR touched ~1M files and GitHub returned 502 for both its diff and its merge.Change.
app/seed.pyassignsid = blake2b(f"{table}:{slug}")truncated to 48 bits before insert (one_with_idwrapper at eachsession.add). Deterministic, order-independent,< 2**53. Collisions rehash with a#nsuffix.Effect. A dump regenerated from unchanged data should now be byte-identical, so future dump PRs contain only real changes.
Checks.
tests/unit/test_stable_ids.py(5 tests) passes;ruffclean. Full suite has the same 28 pre-existing failures before and after this change (local env, missing data fixtures).Refs #1