Repository navigation
feat(datasets): the control plane stops sharing — reads and writes scope to the dataset (PR8a) - #460
Merged
Merged
Conversation
athvin
force-pushed
the
bm/datasets-p8-rekey
branch
from
November 3, 2026 14:28
422172b to
c96443a
Compare
…ope to the dataset (PR8a) PR6 moved every route under its dataset and PR7 gave tenants the screens to manage them, but the SQL underneath had not moved: nineteen statements still filtered on `org_id` alone. So a tenant with a `people` and an `accounts` dataset opened either one and saw ONE combined config history, ONE model registry, ONE label set, ONE schedule list. The routes said "dataset"; the statements said "org", and the routes were the ones telling the truth. This moves the statements. Config versions, the model registry (including which model is active), schedules, labels, tag applications, staged steward actions, S3 cursors and entity links are now addressed by the dataset that owns them. Nothing here is type-checked by the compiler: every one of these parameters is a `&str`, so passing an org id where a dataset id is now wanted compiles perfectly and returns the wrong rows. That is why the first commit of this work was the test. `pg_dataset_isolation` builds one org with two datasets and asserts each sees its own rows AND NOT the sibling's — the absence half matters, because a statement that returns everything passes a presence-only check. It was observed failing against the old SQL before being trusted. The pg tier then found every mis-threaded call site, which is what it is for: 23 of 94 tests red at the start, walked down to zero. Most were fixtures writing rows with no dataset and reading them back scoped; those now stamp the dataset the way production does, through a shared `common::default_dataset` helper. Two were the raw `INSERT INTO matching_models` statements flagged during PR4 as needing exactly this. Three deliberate non-moves, each checked rather than assumed: - **jobs and task instances** keep their org filters: org-level kinds (`provision`, the migrate sweep) carry a null dataset by design, and the claim's org-level conflict rule reads the org. - **the tag vocabulary** stays org-wide; PR6 moved only its application. - **webhooks** are org endpoints — dataset is a filter and a provenance field there, not an identity. Two seams needed care. The convergence sweep reads a pre-dataset org's published config to learn what entity type the dataset it is about to create should carry — it has no dataset yet, by definition — so it gets an explicitly org-addressed read of its own (`by_org_version`), documented as the one caller that may use it. And `org_active_config` now resolves the org's default dataset rather than taking one, keeping the still-org-driven callers (the S3 poller, `source_priority`) on today's behaviour until the clean break removes them. What this PR does NOT do, deliberately: the natural keys still say `[org_id, …]`. Flipping them needs `dataset_id` NOT NULL, which the reconciler treats as breaking and so must be set before it runs — while the default-dataset converge that would supply the backfill runs after it. That ordering deserves its own migration proof, so version NUMBERING stays org-wide here and the isolation test asserts on which rows a dataset SEES rather than on what they are numbered. Co-Authored-By: Claude Fable 5 <[email protected]>
athvin
force-pushed
the
bm/datasets-p8-rekey
branch
from
November 5, 2026 00:35
c96443a to
a0589e7
Compare
athvin
added a commit
that referenced
this pull request
Nov 5, 2026
…ent statement adds (#483) `main` fails its own `skills-check`: the generated reference says 246 declared statements and the tree has 247. Reproduced on `origin/main` directly, so it is not a branch artifact. Neither contributing PR could have caught it. #460 (datasets PR8a) and #474 (the contract guard's `schema_migration/read/history`) each added a declared statement and each regenerated the count against a `main` that had 245 — so both landed holding 246, and the sum is 247. `main` is `strict: false`, which means a PR merges on a green it earned against a base that may since have moved; this is exactly the combination failure the merge bus was built to prove, and neither PR was in a batch. One line, no behaviour. The drift check runs inside the REQUIRED `fmt + clippy + docs` job, so every PR opened against `main` inherits the failure until this lands. Co-authored-by: bmoore813 <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.
First half of PR8 in the datasets program (PR6 #415 moved the routes, PR7 #427 gave tenants the screens).
The bug this fixes is user-visible. Nineteen statements still filtered on
org_idalone, so a tenant with apeopleand anaccountsdataset opened either one and saw ONE combined config history, ONE model registry, ONE label set, ONE schedule list. The routes said "dataset"; the SQL said "org".Config versions, the model registry (including which model is active), schedules, labels, tag applications, staged steward actions, S3 cursors and entity links now address the dataset that owns them.
Why the test came first
None of this is type-checked: every one of these parameters is a
&str, so passing an org id where a dataset id is now wanted compiles perfectly and quietly returns the wrong rows. So the first thing written waspg_dataset_isolation— one org, two datasets, asserting each sees its own rows and not the sibling's. The absence half is the point; a statement that returns everything passes a presence-only check. It was observed failing against the old SQL before being trusted.The pg tier then found every mis-threaded call site, which is what it is for: 23 of 94 red at the start, walked down to 0. Most were fixtures writing rows with no dataset and reading them back scoped, now stamping it the way production does via a shared
common::default_datasethelper. Two were the rawINSERT INTO matching_modelsstatements flagged back in PR4 as needing exactly this.Three deliberate non-moves, checked rather than assumed
provision, the migrate sweep) carry a null dataset by design, and the claim's org-level conflict rule reads the org.Two seams
The convergence sweep reads a pre-dataset org's published config to learn the entity type for the dataset it is about to create — it has no dataset yet, by definition — so it gets an explicitly org-addressed read (
by_org_version), documented as the only caller entitled to it. Andorg_active_configresolves the org's default dataset rather than taking one, holding the still-org-driven callers (S3 poller,source_priority) on today's behaviour until the clean break removes them.What this does NOT do
The natural keys still say
[org_id, …]. Flipping them needsdataset_idNOT NULL, which the reconciler treats as breaking and so must be set before it runs — while the default-dataset converge that would supply the backfill runs after it. That ordering deserves its own migration proof, so it is PR8b. Version numbering therefore stays org-wide here, and the isolation test asserts on which rows a dataset SEES rather than on what they are numbered.Verification
make checkexit 0 (fmt, clippy, doc, entities-check, skills-check, 92 green test binaries)DEDUPE_E2E_DUCKLAKE=1+ER_TEST_PG_DSN): 94 passed / 0 failed, including the new isolation tester-entity verify: every statement plans and passes the E0xx rules; lint unchanged at 5 pre-existing V15 warnings🤖 Generated with Claude Code