Repository navigation
feat(datasets): the switchover — every tenant surface moves under its dataset (PR6) - #415
Merged
Merged
Conversation
… dataset (PR6)
The dataset stops being a stamped column and becomes the address. Backend: 56
lake and control-plane handlers widen to `Path((org, ds))` behind
`dataset_or_404` + `refuse_unless_active_dataset`; the session trio, delivery
preconditions, golden/auto-merge opens and the dispatcher's model resolution
all read the DATASET env; 58 route literals and the utoipa doc paths move
under `/v1/orgs/{org}/datasets/{ds}/`, with org routes keeping only identity,
keys, audit, webhooks and the tag vocabulary. Tag APPLICATION moves with the
lake (subjects are lake-local ids); the vocabulary stays org-wide.
Frontend: the BFF directory moves wholesale (34 dirs, 70+ route files) onto
`requireDatasetAccess`/`datasetPath`, pages move to `(tenant)/[org]/[ds]/`
with the settings surface split (config studio + models are the dataset's;
members, profile, webhooks, AI and audit stay the org's, one SettingsNav
splitting hrefs so it still reads as one surface). Dataset context flows
through `useDatasetSlug()` (URL param, `default` fallback) rather than prop
threading, and every dataset-scoped query key re-roots as
`["org", org, "ds", ds, …]` — the signature break is what enumerated the
sweep: 260 type errors burned down to zero, no call site left guessing. A
minimal switcher sits in the top bar; org-switch, login and impersonation land
on `/{org}`, which redirects to `default/dashboard` until the management
phase's real dispatcher.
The widget token gains a REQUIRED `d` claim: mint embeds the dataset, verify
refuses a payload without it, so a pre-dataset token dies at claim parsing
even though its HMAC still verifies — the unit test reproduces the module's
key derivation with a positive control so that refusal can never be mistaken
for a bad signature. erweb rows the BFF writes (saved views, segments, review
recommendations) now carry their dataset column instead of leaning on the
migration default.
Four bugs only this PR's gates could surface, all fixed here:
- **Publish repointed only the org.** `pg::publish_config_version` moved
`orgs.active_config_version` and never the dataset row, so every
dataset-scoped read (`dataset_active_config`, delivery preconditions)
answered "no published config" the moment the routes switched. It now takes
the dataset id and moves both pointers.
- **The dispatcher's webhook `detail_path` pointed at a removed route.** The
entity-event aggregate now names `/datasets/{ds}/runs/…/entity-events`,
resolved from the job's dataset.
- **A live older store could not boot.** The baseline replay runs before the
reconciler, and the dataset indexes it now carries reference columns the
reconciler has not added yet — on any pre-dataset control plane (the dev
stack's volume was one) `ensure_schema` died with `column "dataset_id" does
not exist`, because IF NOT EXISTS skips an existing INDEX, not a missing
COLUMN. The replay now defers undefined-column statements under a savepoint
and replays them strictly after reconcile; `pg_schema_replay.rs` ages a
store back to the pre-dataset shape and proves one boot heals the whole
distance — the migration proof the plan asked for.
- **Provisioned orgs kept a forever-provisioning dataset.** The converge
copies the org's state at creation — `provisioning` — and nothing ever
flipped the dataset when the provision job promoted the org, because until
now nothing READ dataset state. The dispatcher's activate step now takes the
default dataset along under the same expected-state guard, and
`pg_provision` asserts it; the full-stack tier caught this as every fresh
tenant rendering "Setting up…" forever.
Supporting changes: the pg test tier addresses the dataset routes (257 path
lines over 27 files); `pg::ensure_org` converges the default dataset the way
the create-org handlers do, while `upsert_org_byo` deliberately does not (the
sweep's own test needs an unconverged org) — below-HTTP fixtures use the new
`pg::converge_default_datasets` + `pg::merge_dataset_envs`; the migrate-tenants
sweep labels converged tenants `org/dataset`. Contracts regenerated in the §9
order (envelopes.json, er-mcp/tools.json, the reshaped mock with per-dataset
lake keying and `GET /datasets[/{ds}]` fixtures); openapi.json is schemas-only
by design, so the route move leaves it byte-identical. `kill-servers.sh` now
also sweeps 3200 — the e2e config adopts a reused server as-is, and a
nine-day-old `next start` once served an entire tier run. The e2e suspend spec
polls the engine's own view of the org before asserting the 409: asserting in
the UI-flip window once enqueued a real train on a tenant the operator had
just frozen. All 42 visual baselines
regenerated in the pinned container (the dataset label reaches every
rail-bearing screen); regeneration needs two consecutive identical captures,
so `update-baselines.sh` now runs with a scoped 30s expect budget — webkit's
full-page shots of the longest screens overran the default 5s there while the
ordinary single-capture compare fits it comfortably.
Known interim, closed by the clean-break phase's re-key: config / models /
schedules / labels PG lists are still org-scoped in SQL (the jobs list and
dispatcher model resolution are dataset-filtered). Two datasets of one org
share those lists until the natural keys flip.
Co-Authored-By: Claude Fable 5 <[email protected]>
This was referenced Nov 3, 2026
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.
PR6 of the datasets program (PR1 #380, PR2 #381, PR3 #383, PR4 #392, PR5 #396): the switchover. Old org-scoped lake routes are REMOVED (the sanctioned clean break); er-openapi-check breaking advisories are EXPECTED on this PR.
The dataset stops being a stamped column and becomes the address. Backend: 56
lake and control-plane handlers widen to
Path((org, ds))behinddataset_or_404+refuse_unless_active_dataset; the session trio, deliverypreconditions, golden/auto-merge opens and the dispatcher's model resolution
all read the DATASET env; 58 route literals and the utoipa doc paths move
under
/v1/orgs/{org}/datasets/{ds}/, with org routes keeping only identity,keys, audit, webhooks and the tag vocabulary. Tag APPLICATION moves with the
lake (subjects are lake-local ids); the vocabulary stays org-wide.
Frontend: the BFF directory moves wholesale (34 dirs, 70+ route files) onto
requireDatasetAccess/datasetPath, pages move to(tenant)/[org]/[ds]/with the settings surface split (config studio + models are the dataset's;
members, profile, webhooks, AI and audit stay the org's, one SettingsNav
splitting hrefs so it still reads as one surface). Dataset context flows
through
useDatasetSlug()(URL param,defaultfallback) rather than propthreading, and every dataset-scoped query key re-roots as
["org", org, "ds", ds, …]— the signature break is what enumerated thesweep: 260 type errors burned down to zero, no call site left guessing. A
minimal switcher sits in the top bar; org-switch, login and impersonation land
on
/{org}, which redirects todefault/dashboarduntil the managementphase's real dispatcher.
The widget token gains a REQUIRED
dclaim: mint embeds the dataset, verifyrefuses a payload without it, so a pre-dataset token dies at claim parsing
even though its HMAC still verifies — the unit test reproduces the module's
key derivation with a positive control so that refusal can never be mistaken
for a bad signature. erweb rows the BFF writes (saved views, segments, review
recommendations) now carry their dataset column instead of leaning on the
migration default.
Four bugs only this PR's gates could surface, all fixed here:
pg::publish_config_versionmovedorgs.active_config_versionand never the dataset row, so everydataset-scoped read (
dataset_active_config, delivery preconditions)answered "no published config" the moment the routes switched. It now takes
the dataset id and moves both pointers.
detail_pathpointed at a removed route. Theentity-event aggregate now names
/datasets/{ds}/runs/…/entity-events,resolved from the job's dataset.
reconciler, and the dataset indexes it now carries reference columns the
reconciler has not added yet — on any pre-dataset control plane (the dev
stack's volume was one)
ensure_schemadied withcolumn "dataset_id" does not exist, because IF NOT EXISTS skips an existing INDEX, not a missingCOLUMN. The replay now defers undefined-column statements under a savepoint
and replays them strictly after reconcile;
pg_schema_replay.rsages astore back to the pre-dataset shape and proves one boot heals the whole
distance — the migration proof the plan asked for.
copies the org's state at creation —
provisioning— and nothing everflipped the dataset when the provision job promoted the org, because until
now nothing READ dataset state. The dispatcher's activate step now takes the
default dataset along under the same expected-state guard, and
pg_provisionasserts it; the full-stack tier caught this as every freshtenant rendering "Setting up…" forever.
Supporting changes: the pg test tier addresses the dataset routes (257 path
lines over 27 files);
pg::ensure_orgconverges the default dataset the waythe create-org handlers do, while
upsert_org_byodeliberately does not (thesweep's own test needs an unconverged org) — below-HTTP fixtures use the new
pg::converge_default_datasets+pg::merge_dataset_envs; the migrate-tenantssweep labels converged tenants
org/dataset. Contracts regenerated in the §9order (envelopes.json, er-mcp/tools.json, the reshaped mock with per-dataset
lake keying and
GET /datasets[/{ds}]fixtures); openapi.json is schemas-onlyby design, so the route move leaves it byte-identical.
kill-servers.shnowalso sweeps 3200 — the e2e config adopts a reused server as-is, and a
nine-day-old
next startonce served an entire tier run. The e2e suspend specpolls the engine's own view of the org before asserting the 409: asserting in
the UI-flip window once enqueued a real train on a tenant the operator had
just frozen. All 42 visual baselines
regenerated in the pinned container (the dataset label reaches every
rail-bearing screen); regeneration needs two consecutive identical captures,
so
update-baselines.shnow runs with a scoped 30s expect budget — webkit'sfull-page shots of the longest screens overran the default 5s there while the
ordinary single-capture compare fits it comfortably.
Known interim, closed by the clean-break phase's re-key: config / models /
schedules / labels PG lists are still org-scoped in SQL (the jobs list and
dispatcher model resolution are dataset-filtered). Two datasets of one org
share those lists until the natural keys flip.
Verification
make checkgreen on the rebased commit (fmt, clippy, doc, entities-check, skills-check, 91 test binaries)DEDUPE_E2E_DUCKLAKE=1+ER_TEST_PG_DSN): 90 passed / 0 failed, including the newpg_schema_replaymigration proofmake check-e2elegs: dedupe-cli + er-cli + er-entity-diff all greenmake frontend-dev+ seed +test:e2e:full): 24/24 against the real engine — train, full and incremental runs all through the per-dataset queue🤖 Generated with Claude Code