Skip to content

feat(seed): stable slug-derived ids (stop dump churn) - #63

Merged
Seungpyo1007 merged 2 commits into
mainfrom
feat/stable-ids
Sep 16, 2026
Merged

Seungpyo1007 merged 2 commits into
mainfrom
feat/stable-ids

Conversation

@Seungpyo1007

Copy link
Copy Markdown
Member

Prerequisite for splitting games out into a satellite repo.

Problem. id is part of the public response (/v1/brands/3dfx etc.), but it came from an autoincrement counter, so inserting one record renumbered everything after it. Sampling #180 showed brand pages differing only in id (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.py assigns id = blake2b(f"{table}:{slug}") truncated to 48 bits before insert (one _with_id wrapper at each session.add). Deterministic, order-independent, < 2**53. Collisions rehash with a #n suffix.

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; ruff clean. Full suite has the same 28 pre-existing failures before and after this change (local env, missing data fixtures).

Refs #1

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
@Seungpyo1007
Seungpyo1007 merged commit 8c4a101 into main Sep 16, 2026
1 check passed
@Seungpyo1007
Seungpyo1007 deleted the feat/stable-ids branch September 23, 2026 12:27
@github-project-automation github-project-automation Bot moved this from Todo to Done in TechAPI-Project Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant