Repository navigation
fix(schema): a healed control store enforces the fresh store's CHECK and FK constraints (#914) - #1438
Merged
Merged
Conversation
…and FK constraints (#914) A column the reconciler added to an existing store was born without the CHECK (accepted_values) or REFERENCES the fresh DDL gives it inline. So dev, prod and a freshly provisioned store enforced different rules: tags.kind and tags.apply_min_role, and every constrained column added after a store's birth (42 CHECK clauses across the generated DDL). - The reconciler's ADD COLUMN now carries REFERENCES and CHECK, so a column added from now on is born constrained. - Every boot's baseline replay adds any missing CHECK or FK per constrained column. It checks by constraint kind and the one column covered, adds it NOT VALID, then attempts VALIDATE; a historical violation leaves the constraint enforcing new writes rather than failing the boot. Postgres auto-names it as the inline form does. On a store without the column yet, it hits undefined_column and is deferred past the reconciler by ensure_schema's existing mechanism. pg_constraint_parity drops every entity CHECK and FK from a fresh store, boots again, and requires the same constraints by name and definition. It then plants a violating tags row and requires the boot to succeed, the constraint to return NOT VALID, and a new violating write to be refused. The migrate test's pinned ADD COLUMN SQL is updated, because it encoded the old, constraint-less behaviour. pg_schema_replay and the migration pg tests pass. entity-framework-design records it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
athvin
temporarily deployed
to
marketing-preview
November 29, 2026 12:14 — with
GitHub Actions
Inactive
This branch was previously deployed
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.
Closes #914
What
A store the reconciler healed now carries the fresh store's CHECK and FK constraints.
ADD COLUMNcarriesREFERENCESandCHECK (… IN …).NOT VALID, then attemptsVALIDATE. If historical rows violate it, the constraint stays in force for new writes and the boot continues. Postgres auto-names it exactly as the inline form does.Why
Healed stores enforced fewer rules than fresh ones:
tags.kind,tags.apply_min_role, and every constrained column added after a store's birth (42 CHECK clauses across the generated DDL). #914's done-when, generalised: a reconciled store and a fresh store report the samepg_constraintCHECK and FK set. Choice: convergence happens on every boot, by kind and column rather than by name, andNOT VALIDfirst, so a dirty store can't block a deploy.Proof
make checkexit 0. Newpg_constraint_paritydrops every entity CHECK and FK from a fresh store, boots, and requires the identical set by name and definition. It then plants a violatingtagsrow and requires the boot to succeed, the constraint to come backNOT VALID, and a new violating write to be refused.pg_schema_replayand the migration pg tests pass. The migrate unit test's pinned ADD SQL is updated, because it encoded the old behaviour.Risk & rollback
Every deploy runs the new idempotent DO blocks at boot; on a store that already has the constraints they are catalogue lookups only. A constraint that existing data violates is added NOT VALID with a warning, never a boot failure. Rollback:
git revert <merge-sha>; a constraint already added stays, which is the intended state.Post-merge ledger
Closed by: agent · session
Claude Code:24d16c2e-fec6-49d8-9797-060338df4848onbrians-MacBook-Pro· 2026-11-29T12:31:44Zmainis green with this change on it — the merge SHA, and the runthat proves it. A later head SHA with this commit as an ancestor counts;
a cancelled run with zero jobs does not: — 8997ed3, rust 46261216721 + frontend 46261216641 success
imagesbuilt, or correctly never ran because nothing that goes intoan image changed: — success, run 46261216701
deployconverged — proved by a line the running process emitted, notby the image digest and not by the workflow conclusion: — run 46261602367 (DEPLOY_SHA 8997ed3) success; web-api-green logged 'er-server listening' at 12:21:17Z, after ensure_schema ran the new constraint DO blocks against the real dev store
deploy,drift,kind's nightly leg) is green, or knowingly red for a reason that is notthis change: — infra success on 8997ed3
Donethrough the automation rather than byhand, and the issue closed: — Reconciler-added columns never get their CHECK constraints — healed stores drift from fresh DDL #914 CLOSED by fix(schema): a healed control store enforces the fresh store's CHECK and FK constraints (#914) #1438 via automation
(a skill, a reference, memory) — or nothing new was learned: — entity-framework-design records constraint convergence; a violating historical row leaves the constraint NOT VALID rather than failing a boot
Specific to this change
Context — plan, discoveries, measurements, files
Plan
Discoveries
Measurements
Files
Size: most of the diff is regenerated DDL. Each constrained column's DO block appears in both the
.sqlfiles and the compiled baseline.🤖 Generated with Claude Code