Skip to content

feat(datasets): the dataset entity, the fixup ledger, the convergence sweep, and dataset CRUD (PR3) - #383

Merged
athvin merged 3 commits into
mainfrom
bm/datasets-p3-entity
Nov 2, 2026
Merged

athvin merged 3 commits into
mainfrom
bm/datasets-p3-entity

Conversation

@athvin

@athvin athvin commented Nov 2, 2026

Copy link
Copy Markdown
Owner

PR 3 of the datasets program (after #380 attach seam, #381 frontend prep). This lands the control-plane half of a dataset — one of a tenant's resolution domains, with its own lake location, config pointer, entity type and lifecycle. Nothing reads a dataset's lake yet; the dispatcher still runs on the org env until PR5.

What

  • entities/dataset: natural key (org_id, name), history, the org's lake/config/ingest columns mirrored per dataset. entities/fixup: the ledger for named one-shot fixups.
  • V17 (warning): a dataset_id column must reference datasets(id), keep org_id beside it, and carry a usable index — V15's dataset analogue, landed before its first subject so every table that gains the column arrives well-formed. Fixture-pinned both ways.
  • er-server/src/fixups.rs: the two-phase ledgered fixup pass wired into ensure_schema — BeforeReconcile for constraint surgery the reconciler refuses (the PR8 SET NOT NULLs), AfterReconcile for backfills (the PR4 dataset_id stamp). This is the mechanism the declarative reconciler deliberately isn't (it never drops, never re-keys, never backfills).
  • ensure_default_datasets — deliberately NOT a fixup: "each org has a default dataset" is a convergence invariant, not an event, so it runs on every boot and an org created between deploys is converged by the next one. The org's env/config/ingest fields ride verbatim — nothing moves on disk or in any catalog, and config.tenant (hash-bearing) is untouched.
  • Routes: GET/POST /v1/orgs/{org}/datasets, GET/PATCH …/{ds}, …/suspend, …/resume. Create is BYO + operator-only until dataset_provision exists (the honest 503, exactly as org auto-provisioning once was); reserved names datasets/settings are refused (frontend static segments); the config_path/env.ER_CONFIG_PATH one-source-of-truth rule is enforced as on orgs; detail/list never echo env or config_path.
  • Contract: Dataset joins the OpenAPI components (13 → 14); openapi.json, schema.d.ts, envelopes.json regenerated. The mock serves nothing new (mock ⊆ router holds).

Tests

  • pg_datasets — CRUD, every validation edge (reserved names, entity types, slug, env mismatch, 409-on-collision-leaves-row-untouched, suspended-org 409), the role boundary (viewer reads / operator creates / admin runs the lifecycle), and the suspend/resume 409 edges.
  • pg_dataset_sweep — an org created after boot is converged by the next; env rides verbatim; re-running neither duplicates nor overwrites; entity_type follows the active published config (self-checking account fixture).
  • Full make check green; the whole pg suite green locally against Postgres 16 (46/46 before these two — the every-boot sweep breaks no existing test).

🤖 Generated with Claude Code

bmoore813 and others added 3 commits November 2, 2026 10:01
… sweep, and dataset CRUD (PR3)

A dataset is one of a tenant's resolution domains: its own lake location,
config pointer, entity type and lifecycle state. This lands the control-plane
half — nothing reads a dataset's lake yet.

- entities/dataset: natural key (org_id, name), history, the org's lake/config/
  ingest columns mirrored per dataset; entities/fixup: the ledger for named
  one-shot fixups.
- V17 (warning): a dataset_id column must reference datasets(id), keep org_id
  beside it, and carry a usable index — the dataset analogue of V15, landed
  before its first subject so every table arrives well-formed.
- er-server/src/fixups.rs: the two-phase ledgered fixup pass (BeforeReconcile
  for constraint surgery the reconciler refuses; AfterReconcile for backfills)
  wired into ensure_schema — the mechanism the reconciler deliberately isn't.
  Plus ensure_default_datasets, which is NOT a fixup: "each org has a default
  dataset" is a convergence invariant, so it runs every boot and an org created
  between deploys is converged by the next one. Env/config/ingest fields ride
  verbatim — nothing moves on disk or in any catalog.
- Routes: GET/POST /v1/orgs/{org}/datasets, GET/PATCH /{ds}, /suspend,
  /resume. Create is BYO + operator-only until dataset_provision exists (the
  honest 503, as org auto-provisioning was); reserved names 'datasets' and
  'settings' are refused; the config_path/env.ER_CONFIG_PATH one-source rule
  is enforced as on orgs; detail never echoes env or config_path.
- Contract: Dataset joins the OpenAPI components (13 -> 14), openapi.json /
  schema.d.ts / envelopes.json regenerated.
- pg_datasets (CRUD, validation edges, role boundary, lifecycle 409s) and
  pg_dataset_sweep (convergence, verbatim copy, no-overwrite, entity_type
  from the published config) both green against Postgres 16.

Co-Authored-By: Claude Fable 5 <[email protected]>
…he dataset entity mirrors the org's columns, so best-match attribution ties and flips (the header's own attribution limit)

Co-Authored-By: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants