Repository navigation
feat: a baseline that covers bundles applied outside ExponetDB (ADR-0040, OD-72) - #69
Merged
Merged
Conversation
…040, OD-72) A target imported after other targets of its project applied stream bundles, whose history holds their effect, names those bundles in its baseline (covers). Each becomes a ledger row of the baseline under the bundle's own id (origin legacy_import, provenance legacy_applied_statements, covered: true), before the baseline row. Planning counts such rows as applied bundles; the set is closed under dependsOn and needs staging evidence on production; the baseline's verification runs their verify.sql as its runtime layer (newest revision with the recorded checksum). serve holds observer sessions only, so there is no plan-time dry run. Contract: BaselinePlanRequest.covers (additive). CLI: migration import baseline --covers. Integration test on real PostgreSQL added; not run yet (the local Docker daemon does not start). Developed by @davdxpx
…al PostgreSQL A covered bundle without dependencies is refused (MIGRATION_DEPENDENCY_MISSING): in a stream with a baseline only baselines are roots, so every later plan on the target would fail on it. The integration test now baselines staging and production on one history and passes on PostgreSQL 16, 17 and 18. Developed by @davdxpx
…mer code bound, evidence re-read at apply, a covered row's own status - A production cover without verify.sql is refused: nothing would check its effect there. - Each covered verify.sql is admitted and resolved as the observer at planning; the consumer code it calls is bound into the plan and checked when it runs. - checkBindings re-reads the staging evidence of production covers. - The runtime layer keeps one failure per covered bundle that did not hold, and migration status reads each covered row's own share (it read passed before). - Integration test: a covered verify.sql that does not hold fails the baseline and the row (PostgreSQL 16, 17, 18). Developed by @davdxpx
1 of 2 tasks
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.
Summary
Why. A target imported after other targets of its project applied stream bundles, whose history already holds their effect, could not be baselined at the stream's head. Planning counts only
exponetdbledger rows as applied, so every such bundle stayed pending. The case is REOSA production: 40 bundles went to staging through ExponetDB and reached production as legacy files. Owner decision OD-72 (a), recorded in #68.What. The baseline plan request takes
covers, a list of stream bundle ids. On the CLI this ismigration import baseline <report> --covers <ids>.Planning refuses a cover when:
dependsOn(MIGRATION_DEPENDENCY_UNKNOWN);MIGRATION_DEPENDENCY_MISSING, because in a baselined stream only baselines are roots);collectEvidence, the same function as a migration plan, with no break-glass.On production, planning also requires:
verify.sqlfor every covered bundle;verify.sqlis admitted and resolved as the observer. The consumer code it calls is bound into the plan.Apply:
baseline:<slug>row. Each row uses the bundle's own id, originlegacy_import, provenancelegacy_applied_statementsandsource.covered = true. The target ledger's schema is unchanged;checkBindings.Planning afterwards.
planOrdercounts alegacy_importrow with a bundle id as an applied bundle.Verification. The baseline's run gains a runtime layer: each covered
verify.sql, from the newest revision with the recorded checksum. A failure fails the run, which keeps production plans blocked throughmigration.dependencies-verified. The layer keeps one failure per covered bundle, andmigration statusreads each covered row's own share. A correctedverify.sqlis a new revision of the same checksum, somigration verify baseline:<slug>picks it up.serve holds observer sessions only. So there is no plan-time dry run of
verify.sql; it runs as the verifier in the worker.Contract.
BaselinePlanRequest.coversis additive and optional. The generated OpenAPI and SDK and the CLI reference are regenerated.Docs. New ADR-0040,
legacy-import.mdStep 6 and §3, and the ADR index.An independent review found no P1. Its three P2 and one of its P3 findings are fixed in
e1f34e00:verify.sqlrequired on production, consumer code bound, evidence re-read at apply, each covered row's own status.Order. Merge #68 first, because ADR-0040 links OD-72 there. A redeploy happens only on the owner's word (W10-D10).
Test plan
packages/migrations-engineintegration suite on PostgreSQL 16, 17 and 18: 22 files, 261 tests passed. This includes the newbaseline-covers.int.test.tswith 18 tests:verify.sqlthat does not hold, failing the baseline and the row.biome check .,verify:generated,golden:checkandboundaries.--covers.Developed by @davdxpx