Repository navigation
feat(datasets): every control-plane row knows its dataset — nullable columns, stamping, backfill (PR4) - #392
Merged
Merged
Conversation
…columns, stamping, and the ledgered backfill (PR4) Thirteen Postgres entities gain a nullable dataset_id (FK -> datasets.id) with a V17-compliant dataset-leading index; audit_log gains a nullable dataset NAME column instead, matching its org-name convention (it has no org_id to sit beside, and the ledger outlives both). Every INSERT path stamps the column: handlers resolve the org's default dataset once (stamp_dataset — best-effort by design: the column is nullable, the backfill heals NULLs, and failing a request over a stamp the schema does not require would invert priorities); dispatcher paths carry job.dataset_id; schedule_tick copies the schedule's; the task-instance retry/clear INSERT..SELECTs carry the predecessor's. Fixup 0002_backfill_dataset_ids — the framework's first passenger — stamps every pre-dataset row with its org's default dataset via eleven declared UPDATE statements (E009 made each declare its read of datasets), ledgered semantics-once. Org creation now converges the default dataset inline (ensure_default_dataset_by_name), so nothing an org's first minutes write goes unstamped waiting for the next boot. The org-level exceptions stamp None on purpose: the provision job (it creates the tenant itself), api-key audits, org lifecycle audits, and webhook rows (NULL = subscribed to every dataset). Mechanical consequences the gates drove: 20 E003s (entity-returning SELECT lists), 8 by-name row-decode misses in mode-partial reads the analyser does not column-check, 43 RETURNING lists, and the OpenAPI/schema.d.ts regen for the seven registered schemas that grew a field. pg_dataset_sweep gains the backfill proof (a NULL row heals to its org's default dataset id). Co-Authored-By: Claude Fable 5 <[email protected]>
…shape (dataset_id) Co-Authored-By: Claude Fable 5 <[email protected]>
…log (dataset_id) Co-Authored-By: Claude Fable 5 <[email protected]>
This was referenced Nov 2, 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.
PR 4 of the datasets program (after #380/#381/#383; rebased over #384's trace-context hop, which restructured the same enqueue plumbing). Inert to behavior: every new column is nullable, every unique constraint is unchanged (per-dataset re-keying is PR5/PR8), and a NULL dataset_id means exactly what the pre-dataset world meant.
What
dataset_id(FK →datasets.id, nullable) with a V17-compliant dataset-leading index each: config_version, matching_model, job, task_instance, schedule, s3_ingest_cursor, pair_label, tenant_schema_state, entity_link, tagging, staged_steward_action, webhook (NULL = subscribed to all datasets), webhook_delivery. audit_log gains a nullable dataset NAME column instead — it has noorg_idto sit beside (its tenant column is the org name), and the ledger outlives both.stamp_dataset— best-effort by design: the column is nullable, the backfill heals NULLs, and failing a request over a stamp the schema does not require would invert priorities). Dispatcher paths carryjob.dataset_id;schedule_tickcopies the schedule's; the task-instance retry/clearINSERT … SELECTs carry the predecessor's for free. Org-level stamps areNoneon purpose: the provision job, api-key and org-lifecycle audits.0002_backfill_dataset_ids— the ledgered fixup framework's first passenger: eleven declared UPDATE statements (E009 made each declarereads: [dataset]) stamp every pre-dataset row with its org's default dataset, semantics-once.ensure_default_dataset_by_nameafter the org upsert and in provisioning), so nothing an org's first minutes write goes unstamped waiting for the next boot's sweep.What the gates drove (worth recording)
mode: partialreads (matching_model/read/active*,job/read/lock,task_instance/read/{live_claimed_pods,retry_lineage,stale_heartbeats},webhook/read/for_delivery) decoderow.get("dataset_id")by name — found by the pg suite, not E0xx.schema.d.tsregen (seven registered schemas grew a field); er-entity-diff'slive_jobfixture.Tests
pg_dataset_sweepgains the backfill proof (a NULL job heals to its org's default dataset id; the fixup is ledgered semantics-once). Full pg suite green locally (48/48) after the #384 rebase,make checkgreen,pnpm checkgreen.🤖 Generated with Claude Code