keiro-migrations 0.24.0.0 → 0.25.0.0
raw patch · 7 files changed
+67/−21 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +7/−0
- expected-schema/native/keiro-v18.txt +3/−0
- keiro-migrations.cabal +1/−1
- migrations.native.lock +1/−0
- migrations/0033.sql +8/−0
- migrations/manifest +1/−0
- test/Main.hs +46/−20
CHANGELOG.md view
@@ -6,6 +6,13 @@ ## [Unreleased] +## 0.25.0.0 — 2026-11-14++### New Features++- Migration `0033` adds nullable timer `traceparent`/`tracestate` columns and the+ advisory workflow `trace_awaited_step` hint. Legacy named-column writes remain compatible.+ ## 0.24.0.0 — 2026-11-05 No changes this release.
expected-schema/native/keiro-v18.txt view
@@ -265,6 +265,8 @@ column keiro_timers.resume_lease_until timestamp with time zone column keiro_timers.status text not null default 'scheduled'::text column keiro_timers.timer_id uuid not null+column keiro_timers.traceparent text+column keiro_timers.tracestate text column keiro_timers.updated_at timestamp with time zone not null default now() column keiro_workflow_children.await_step text not null column keiro_workflow_children.child_id text not null@@ -292,6 +294,7 @@ column keiro_workflows.leased_by text column keiro_workflows.next_attempt_at timestamp with time zone column keiro_workflows.status text not null default 'running'::text+column keiro_workflows.trace_awaited_step text column keiro_workflows.updated_at timestamp with time zone not null default now() column keiro_workflows.wake_after timestamp with time zone column keiro_workflows.workflow_id text not null
keiro-migrations.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: keiro-migrations-version: 0.24.0.0+version: 0.25.0.0 synopsis: Schema migrations for keiro description: Embedded PostgreSQL schema migrations and a migration runner for the Keiro
migrations.native.lock view
@@ -30,3 +30,4 @@ 0e0b847088d178290e77913224df82435b86c00062feb47c79351ed014a605a1 0030.sql d78b8400638b3a9005f4e964f2cb10d3863d60d1038735ed6fa09507a912a26e 0031.sql b0fd734dde0a23d13f844a5e137fe92859f726ded171e14ca531c3e10f3dcf47 0032.sql+3c309929582a4504559d85c774c7ca8aafeb75821afdaad7fcd2458b07a45dd6 0033.sql
+ migrations/0033.sql view
@@ -0,0 +1,8 @@+-- persist timer creation context and workflow trace await hints+ALTER TABLE keiro.keiro_timers+ ADD COLUMN traceparent text,+ ADD COLUMN tracestate text;++-- Advisory attribution only: this hint never controls readiness or replay.+ALTER TABLE keiro.keiro_workflows+ ADD COLUMN trace_awaited_step text;
migrations/manifest view
@@ -30,3 +30,4 @@ 0030.sql 0031.sql 0032.sql+0033.sql
test/Main.hs view
@@ -57,7 +57,7 @@ main :: IO () main = hspec $ do describe "native Keiro migration definition" $ do- it "tracks thirty-two native files in manifest order" $ do+ it "tracks thirty-three native files in manifest order" $ do directory <- findMigrationsDirectory manifest <- Text.lines <$> Text.IO.readFile (directory </> "manifest") manifest `shouldBe` Text.pack <$> nativeMigrationFiles@@ -70,7 +70,7 @@ bytes <- ByteString.readFile (directory </> nativeName) lookup legacyName lockEntries `shouldBe` Just (checksumText bytes) - it "builds component keiro with dependency kiroku and thirty-two migrations" $ do+ it "builds component keiro with dependency kiroku and thirty-three migrations" $ do plan <- requirePlan let PlanDescription components = planDescription plan case toList components of@@ -83,7 +83,7 @@ componentNameText keiroName `shouldBe` "keiro" dependencyName <- requireRight (componentName "kiroku") keiroDependencies `shouldBe` Set.singleton dependencyName- length keiroEntries `shouldBe` 32+ length keiroEntries `shouldBe` 33 actual -> expectationFailure ("unexpected plan description: " <> show actual) validateHistoryMappingTargets plan frameworkCoddHistoryMappings `shouldBe` Right () @@ -172,7 +172,7 @@ [("9999-fixture.sql", "-- Never set search_path in a migration.\nSELECT 1;")] `shouldBe` [] - it "passes all 32 embedded native bodies" $ do+ it "passes all 33 embedded native bodies" $ do lintViolations config (toList embeddedMigrationEntries) `shouldBe` [] describe "startup handshake" $ do@@ -186,7 +186,7 @@ plan >>= requireRight Keiro.pendingMigrations handshake `shouldBe` planMigrationIds plan- length (Keiro.pendingMigrations handshake) `shouldBe` 49+ length (Keiro.pendingMigrations handshake) `shouldBe` 50 Keiro.ledgerIssues handshake `shouldBe` [] handshakePassed handshake `shouldBe` False @@ -212,7 +212,7 @@ handshake <- missingMigrations defaultRunOptions provider plan >>= requireRight Keiro.pendingMigrations handshake `shouldBe` drop 17 (planMigrationIds plan)- length (Keiro.pendingMigrations handshake) `shouldBe` 32+ length (Keiro.pendingMigrations handshake) `shouldBe` 33 Keiro.ledgerIssues handshake `shouldBe` [] handshakePassed handshake `shouldBe` False @@ -448,12 +448,12 @@ assertSchema connection let provider = providerFor connection rerun <- runMigrationPlanWith defaultRunOptions provider plan >>= requireRight- reportOutcomes rerun `shouldBe` replicate 49 AlreadyApplied+ reportOutcomes rerun `shouldBe` replicate 50 AlreadyApplied verified <- verifyMigrationPlanWith defaultRunOptions provider plan >>= requireRight case verified of VerificationReport verificationIssues applied pending unknown -> do verificationIssues `shouldBe` []- length applied `shouldBe` 49+ length applied `shouldBe` 50 pending `shouldBe` [] unknown `shouldBe` [] either (expectationFailure . show) pure result@@ -502,7 +502,7 @@ (runMigrationPlan defaultRunOptions settings plan >>= requireRight) (runMigrationPlan defaultRunOptions settings plan >>= requireRight) sort [reportOutcomes first, reportOutcomes second]- `shouldBe` sort [replicate 49 AppliedNow, replicate 49 AlreadyApplied]+ `shouldBe` sort [replicate 50 AppliedNow, replicate 50 AlreadyApplied] it "upgrades singleton read-model rows into deterministic rebuild groups" $ do fullPlan <- requirePlan@@ -522,7 +522,7 @@ useSession connection (Session.script legacyReadModelFixtureSql) report <- runMigrationPlan defaultRunOptions settings fullPlan >>= requireRight Prelude.drop (length (planMigrationIds priorPlan)) (reportOutcomes report)- `shouldBe` replicate 11 AppliedNow+ `shouldBe` replicate 12 AppliedNow withConnection settings $ \connection -> do rows <- useSession connection (Session.statement () legacyGroupUpgradeStatement) rows@@ -549,7 +549,7 @@ useSession connection (Session.script preCanonicalRebuildFixtureSql) report <- runMigrationPlan defaultRunOptions settings fullPlan >>= requireRight Prelude.drop (length (planMigrationIds priorPlan)) (reportOutcomes report)- `shouldBe` replicate 9 AppliedNow+ `shouldBe` replicate 10 AppliedNow withConnection settings $ \connection -> do rows <- useSession connection (Session.statement () preCanonicalRebuildShapeStatement) rows@@ -575,7 +575,7 @@ useSession connection (Session.script preStatusContractFixtureSql) report <- runMigrationPlan defaultRunOptions settings fullPlan >>= requireRight Prelude.drop (length (planMigrationIds priorPlan)) (reportOutcomes report)- `shouldBe` replicate 7 AppliedNow+ `shouldBe` replicate 8 AppliedNow withConnection settings $ \connection -> do facts <- useSession connection (Session.statement () preStatusContractFactsStatement) facts `shouldBe` ("unmanaged", 0, "unmanaged", True, True)@@ -599,7 +599,7 @@ useSession connection (Session.statement () guardFunctionOidStatement) report <- runMigrationPlan defaultRunOptions settings fullPlan >>= requireRight Prelude.drop (length (planMigrationIds priorPlan)) (reportOutcomes report)- `shouldBe` replicate 3 AppliedNow+ `shouldBe` replicate 4 AppliedNow withConnection settings $ \connection -> do (afterOid, epochFenced, publicRevoked) <- useSession connection (Session.statement () upgradedGuardFactsStatement)@@ -625,7 +625,7 @@ useSession connection (Session.script preRejectionOutboxFixtureSql) report <- runMigrationPlan defaultRunOptions settings fullPlan >>= requireRight Prelude.drop (length (planMigrationIds priorPlan)) (reportOutcomes report)- `shouldBe` replicate 2 AppliedNow+ `shouldBe` replicate 3 AppliedNow withConnection settings $ \connection -> do useSession connection (Session.script validRejectionAuditSql) missingAudit <- Connection.use connection (Session.script missingRejectionAuditSql)@@ -677,6 +677,30 @@ wrongState `shouldSatisfy` isLeft useSession connection (Session.script "UPDATE keiro.keiro_timers SET resume_claim_token = '00000000-0000-0000-0000-000000000001', resume_lease_until = now() WHERE status = 'firing'") + it "0033 preserves legacy timer/workflow rows with nullable advisory trace fields" $ do+ fullPlan <- requirePlan+ kiroku <- requireRight Kiroku.kirokuMigrations+ priorKeiro <- requireRight (migrationComponentFromEmbeddedSql "keiro" (Set.singleton "kiroku") (NonEmpty.fromList (take 32 (toList embeddedMigrationEntries))))+ priorPlan <- requireRight (frameworkMigrationPlan kiroku priorKeiro)+ withKeiroPg $ \database -> do+ let settings = Pg.connectionSettings database+ _ <- runMigrationPlan defaultRunOptions settings priorPlan >>= requireRight+ withConnection settings $ \connection ->+ useSession connection $+ Session.script+ "INSERT INTO keiro.keiro_timers (timer_id,process_manager_name,correlation_id,fire_at,payload,status,attempts) VALUES ('00000000-0000-0000-0000-000000000001','legacy','legacy',now(),'{\"work\":1}','scheduled',7); INSERT INTO keiro.keiro_workflows (workflow_id,workflow_name,generation,status) VALUES ('legacy','legacy',2,'suspended')"+ report <- runMigrationPlan defaultRunOptions settings fullPlan >>= requireRight+ Prelude.drop (length (planMigrationIds priorPlan)) (reportOutcomes report) `shouldBe` [AppliedNow]+ withConnection settings $ \connection -> do+ preserved <-+ useSession connection $+ Session.statement () $+ Statement.preparable+ "SELECT t.payload = '{\"work\":1}'::jsonb AND t.attempts = 7 AND t.status = 'scheduled' AND t.traceparent IS NULL AND t.tracestate IS NULL AND w.generation = 2 AND w.status = 'suspended' AND w.trace_awaited_step IS NULL FROM keiro.keiro_timers t CROSS JOIN keiro.keiro_workflows w WHERE w.workflow_id = 'legacy'"+ Encoders.noParams+ (Decoders.singleRow (Decoders.column (Decoders.nonNullable Decoders.bool)))+ preserved `shouldBe` True+ it "enforces replay source, adapter, and verification membership constraints" $ do plan <- requirePlan result <- withMigratedDatabase plan $ \connection -> do@@ -838,7 +862,7 @@ `shouldBe` replicate 7 AlreadyApplied <> replicate 10 AppliedNow <> replicate 16 AlreadyApplied- <> replicate 16 AppliedNow+ <> replicate 17 AppliedNow verifiedAfterUp <- verifyMigrationPlan defaultRunOptions settings plan >>= requireRight@@ -1275,12 +1299,12 @@ `shouldBe` replicate 7 AlreadyApplied <> replicate 10 AppliedNow <> replicate 16 AlreadyApplied- <> replicate 16 AppliedNow+ <> replicate 17 AppliedNow verifiedAfterCanaries <- verifyMigrationPlan defaultRunOptions settings plan >>= requireRight case verifiedAfterCanaries of VerificationReport verificationIssues _ _ _ -> verificationIssues `shouldBe` [] rerun <- runMigrationPlan defaultRunOptions settings plan >>= requireRight- reportOutcomes rerun `shouldBe` replicate 49 AlreadyApplied+ reportOutcomes rerun `shouldBe` replicate 50 AlreadyApplied second <- importCoddHistory defaultImportOptions config provider plan frameworkCoddHistoryMappings >>= requireRight@@ -1290,7 +1314,7 @@ sourceRows <- useSession connection (Session.statement () (sourceRowCountStatement sourceSchema)) sourceRows `shouldBe` 23 facts <- useSession connection (Session.statement () importFactsStatement)- facts `shouldBe` (49, 23, True)+ facts `shouldBe` (50, 23, True) postCoddImportPendingIssues :: IO [VerificationIssue] postCoddImportPendingIssues =@@ -1325,7 +1349,8 @@ ("keiro", "0029"), ("keiro", "0030"), ("keiro", "0031"),- ("keiro", "0032")+ ("keiro", "0032"),+ ("keiro", "0033") ] assertPoisonedLedger :: Settings.Settings -> Expectation@@ -1370,7 +1395,8 @@ "0029.sql", "0030.sql", "0031.sql",- "0032.sql"+ "0032.sql",+ "0033.sql" ] findMigrationsDirectory :: IO FilePath