Repository navigation
feat(entities): a contract fixup must name the release it became safe after - #474
Merged
Merged
Conversation
… after
`fixups.rs` is the escape hatch for "the operations the declarative reconciler
deliberately never performs" — and the reconciler never performs them because
they break an older reader. So a fixup is where the expand/contract discipline
either holds or quietly does not, and until now nothing checked.
Every fixup now carries a `Kind`, which means the registry cannot be appended
to without classifying the entry, and `Contract` cannot be written without
naming the catalog hash of the release that STOPPED READING the thing:
Safe additive or data-only
Contract { after } the contract half; gated on `after`
ContractUngated { why } destructive but predating the guard
`contract_allowed(after, history, current)` is pure, and separated from the
query for that reason — the decision is the part worth testing and it needs no
database:
- `after` is in the ledger's history -> allow. The store passed through the
release that stopped reading the thing, so at some point only code that
ignored it was serving.
- the history holds nothing but the current catalog -> allow. The store was born
on this release; there is nothing older to protect, and refusing here would
break every fresh install, which is how a guard like this usually goes wrong.
- otherwise -> REFUSE. There is history, but not the history this fixup needs:
the store jumped from something older straight to here.
What that proves is the store's HISTORY, not the absence of old pods. Keeping
one version serving at a time is the deploy's job — which, with the colour
dimension, is what a cutover does. Said plainly in the doc comment rather than
implied.
**Observed refusing, against a real Postgres**, by registering a contract fixup
naming a catalog the store had never seen:
er-server migrate: fixup 9999_demo_refusal removes something the release
before deadbeefcafe still reads, and this store has no record of
deadbeefcafe — deploy that release first
It refused BEFORE reaching the fixup's body — the demo entry had no body and
would have panicked `unreachable` if the guard had let it through, so the
ordering is proven rather than assumed. The same demo on a FRESH store was
allowed, which is the branch that protects first installs. And the registry
test fired on the unreviewed entry, so appending without reviewing fails
locally rather than in a cluster.
`0003_per_dataset_locks` is declared `ContractUngated` with its reason, not
`Safe`. It does drop the superseded org-level locks, and labelling it honestly
is the point: it shipped with the dataset switchover and is already applied
everywhere, so there is no release boundary left to gate on. A test asserts the
reason is more than a token, because an empty one would make the variant
indistinguishable from `Safe`.
Three smaller things:
- `entities/schema_migration/read/history.sql` is a declared statement, because
every persistent query here is. Control-store reads must `return: entity`
(the typed column list is lake-only in this phase), so it reads the rows and
the distinct hashes are collected in Rust — once, outside the loop, since the
advisory lock means the ledger cannot change under us.
- `schema::control_catalog_hash()` is the Postgres sibling of the existing
`lake_catalog_hash()`.
- `Kind::Contract` carries `#[allow(dead_code)]` with its reason, because it
deliberately ships BEFORE its first user — a guard added alongside the first
removal could not have gated it. `#[expect]` was tried first and does not
work: an expectation must be fulfilled in EVERY compilation, and the variant
is dead in the lib target while the unit tests construct it, so `expect`
errors "unfulfilled" on the test target.
Verified: `make check` green, 9 `fixups` unit tests, plus the live refusal and
fresh-store observations above.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.
fixups.rsis the escape hatch for "the operations the declarative reconciler deliberately never performs" — and the reconciler never performs them because they break an older reader. So a fixup is exactly where the expand/contract discipline either holds or quietly doesn't, and until now nothing checked.The registry now forces a decision
Every fixup carries a
Kind. The registry can't be appended to without classifying the entry, andContractcan't be written without naming the catalog hash of the release that stopped reading the thing:SafeContract { after }afterContractUngated { why }The decision is pure, and that's deliberate
contract_allowed(after, history, current)needs no database, because the decision is the part worth testing:afteris in the ledger's history → allow. The store passed through the release that stopped reading the thing, so at some point only code that ignored it was serving.What it proves is the store's history, not the absence of old pods. Keeping one version serving at a time is the deploy's job — which, with the colour dimension (#461), is what a cutover does. That limit is stated in the doc comment rather than implied.
Observed refusing, against a real Postgres
By registering a contract fixup naming a catalog the store had never seen:
Three things that observation pins down:
unreachableif the guard had let it through — so the ordering is proven, not assumed.0003_per_dataset_locksis labelled honestlyDeclared
ContractUngatedwith its reason, notSafe. It does drop the superseded org-level locks and the retiredtenant_schema_statesUNIQUE — but it shipped with the dataset switchover and is already applied everywhere, so there's no release boundary left to gate on. A test asserts the reason is more than a token, because an empty one would make the variant indistinguishable fromSafe.Three smaller things
entities/schema_migration/read/history.sqlis a declared statement, because every persistent query here is. Control-store reads mustreturn: entity(the typed column list is lake-read-only in this phase), so it reads the rows and the distinct hashes are collected in Rust — once, outside the loop, since the advisory lock means the ledger cannot change under us.schema::control_catalog_hash()is the Postgres sibling of the existinglake_catalog_hash().Kind::Contractcarries#[allow(dead_code)]with its reason, because it deliberately ships before its first user — a guard added alongside the first removal could not have gated it.#[expect]was tried first and does not work here: an expectation must be fulfilled in every compilation, and the variant is dead in the lib target while the unit tests construct it, soexpecterrors "unfulfilled" on the test target.Verification
make checkgreen — 9fixupsunit tests.entities-index.mdregenerated for the new declared statement (245 → 246).Independent of the colour stack — Rust and
entities/only — so this bases onmainand can merge in any order.🤖 Generated with Claude Code