feat(storage): queue-leading primary keys with row-level cross-queue isolation - #537
Merged
Merged
Conversation
behinddwalls
marked this pull request as ready for review
August 6, 2026 17:01
mnoah1
approved these changes
Aug 6, 2026
behinddwalls
force-pushed
the
preetam/storage-factory
branch
from
August 6, 2026 20:46
e0c1223 to
d342ed4
Compare
…isolation ## Summary ### Why? The factory contract made queue-scoped storage instances the only way in, but the schema still let a bound instance reach another queue's rows: `request`, `batch`, `build`, `batch_dependent`, and `request_batch` were keyed by bare IDs. Leading every queue-scoped table's primary key with `queue` makes the binding real at the row level and leaves every table shardable by queue — cheap now (pre-prod, tables recreated), expensive to retrofit later. ### What? `request` and `batch` move to `(queue, id)`, `build` to `(queue, id)` with a new `queue` column, `batch_dependent` to `(queue, batch_id)`, and `request_batch` to `(queue, request_id, batch_id)`; `change`, `queue_batch_state`, and `request_summary_by_queue` were already queue-leading, and the global read-model tables stay queue-free. The bound MySQL stores now stamp their queue into every write and prefix every read with it, so a wrong-queue read misses (`ErrNotFound` / empty) instead of leaking. The `build` key change also removes a latent cross-queue uniqueness assumption on runner-minted build IDs — two queues sharing one CI pipeline may now mint the same identifier. The storage contract suite gains a queue-isolation test covering all five re-keyed stores, and the e2e harness resolves its white-box request reads per queue. ## Test Plan ✅ `go test ./...` ✅ storage integration contract suite via bazel, including the new cross-queue isolation cases ✅ `make fmt` ✅ `make lint` ✅ `make check-tidy` ✅ `make check-gazelle`. Schemas are pre-production: tables are recreated, no data migration.
behinddwalls
force-pushed
the
preetam/queue-leading-schema
branch
from
August 6, 2026 20:47
22d8314 to
ecfcd55
Compare
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.
Summary
Why?
The factory contract made queue-scoped storage instances the only way in, but the schema still let a bound instance reach another queue's rows:
request,batch,build,batch_dependent, andrequest_batchwere keyed by bare IDs. Leading every queue-scoped table's primary key withqueuemakes the binding real at the row level and leaves every table shardable by queue — cheap now (pre-prod, tables recreated), expensive to retrofit later.What?
requestandbatchmove to(queue, id),buildto(queue, id)with a newqueuecolumn,batch_dependentto(queue, batch_id), andrequest_batchto(queue, request_id, batch_id);change,queue_batch_state, andrequest_summary_by_queuewere already queue-leading, and the global read-model tables stay queue-free. The bound MySQL stores now stamp their queue into every write and prefix every read with it, so a wrong-queue read misses (ErrNotFound/ empty) instead of leaking. Thebuildkey change also removes a latent cross-queue uniqueness assumption on runner-minted build IDs — two queues sharing one CI pipeline may now mint the same identifier. The storage contract suite gains a queue-isolation test covering all five re-keyed stores, and the e2e harness resolves its white-box request reads per queue.Test Plan
✅
go test ./...✅ storage integration contract suite via bazel, including the new cross-queue isolation cases ✅make fmt✅make lint✅make check-tidy✅make check-gazelle. Schemas are pre-production: tables are recreated, no data migration.