@abloatai/transaction 0.57.0 → 0.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (781) hide show
  1. package/CONVENTIONS.md +51 -41
  2. package/README.md +3 -1
  3. package/dist/ai-sdk/modelTools.d.ts +3 -3
  4. package/dist/ai-sdk/modelTools.d.ts.map +1 -1
  5. package/dist/ai-sdk/modelTools.js +1 -1
  6. package/dist/ai-sdk/modelTools.js.map +1 -1
  7. package/dist/ai-sdk/updateTool.d.ts +5 -7
  8. package/dist/ai-sdk/updateTool.d.ts.map +1 -1
  9. package/dist/ai-sdk/updateTool.js +3 -5
  10. package/dist/ai-sdk/updateTool.js.map +1 -1
  11. package/dist/auth/capability.d.ts +5 -0
  12. package/dist/auth/capability.d.ts.map +1 -1
  13. package/dist/auth/capability.js +5 -0
  14. package/dist/auth/capability.js.map +1 -1
  15. package/dist/auth/capabilityLifecycle.d.ts +1 -1
  16. package/dist/auth/capabilityLifecycle.d.ts.map +1 -1
  17. package/dist/auth/credentialPolicy.d.ts +1 -1
  18. package/dist/auth/credentialPolicy.d.ts.map +1 -1
  19. package/dist/auth/identity.d.ts +3 -3
  20. package/dist/auth/identity.d.ts.map +1 -1
  21. package/dist/auth/identity.js +5 -5
  22. package/dist/auth/identity.js.map +1 -1
  23. package/dist/auth/index.d.ts +4 -208
  24. package/dist/auth/index.d.ts.map +1 -1
  25. package/dist/auth/index.js +4 -330
  26. package/dist/auth/index.js.map +1 -1
  27. package/dist/auth/runtime.d.ts +218 -0
  28. package/dist/auth/runtime.d.ts.map +1 -0
  29. package/dist/auth/runtime.js +336 -0
  30. package/dist/auth/runtime.js.map +1 -0
  31. package/dist/auth/sessionMint.d.ts +1 -1
  32. package/dist/auth/sessionMint.d.ts.map +1 -1
  33. package/dist/auth/sessionMint.js +2 -1
  34. package/dist/auth/sessionMint.js.map +1 -1
  35. package/dist/branches.d.ts +25 -21
  36. package/dist/branches.d.ts.map +1 -1
  37. package/dist/branches.js +3 -0
  38. package/dist/branches.js.map +1 -1
  39. package/dist/{coordination/awaitClaimGrant.d.ts → claims/awaitGrant.d.ts} +1 -1
  40. package/dist/claims/awaitGrant.d.ts.map +1 -0
  41. package/dist/{coordination/awaitClaimGrant.js → claims/awaitGrant.js} +4 -4
  42. package/dist/claims/awaitGrant.js.map +1 -0
  43. package/dist/{wire/claims.d.ts → claims/contract.d.ts} +1 -1
  44. package/dist/claims/contract.d.ts.map +1 -0
  45. package/dist/{wire/claims.js → claims/contract.js} +2 -2
  46. package/dist/claims/contract.js.map +1 -0
  47. package/dist/{wire/claimEvent.d.ts → claims/eventContract.d.ts} +1 -1
  48. package/dist/claims/eventContract.d.ts.map +1 -0
  49. package/dist/{wire/claimEvent.js → claims/eventContract.js} +1 -1
  50. package/dist/claims/eventContract.js.map +1 -0
  51. package/dist/{coordination → claims}/events.d.ts +7 -11
  52. package/dist/claims/events.d.ts.map +1 -0
  53. package/dist/claims/events.js +8 -0
  54. package/dist/claims/events.js.map +1 -0
  55. package/dist/{coordination/claimHeartbeatLoop.d.ts → claims/heartbeat.d.ts} +1 -1
  56. package/dist/claims/heartbeat.d.ts.map +1 -0
  57. package/dist/{coordination/claimHeartbeatLoop.js → claims/heartbeat.js} +1 -1
  58. package/dist/claims/heartbeat.js.map +1 -0
  59. package/dist/claims/index.d.ts +17 -0
  60. package/dist/claims/index.d.ts.map +1 -0
  61. package/dist/claims/index.js +16 -0
  62. package/dist/claims/index.js.map +1 -0
  63. package/dist/claims/lifetime.d.ts +26 -0
  64. package/dist/claims/lifetime.d.ts.map +1 -0
  65. package/dist/claims/lifetime.js +62 -0
  66. package/dist/claims/lifetime.js.map +1 -0
  67. package/dist/{coordination → claims}/locator.d.ts +1 -1
  68. package/dist/claims/locator.d.ts.map +1 -0
  69. package/dist/{coordination → claims}/locator.js +2 -2
  70. package/dist/claims/locator.js.map +1 -0
  71. package/dist/{coordination/claimMeta.d.ts → claims/meta.d.ts} +1 -1
  72. package/dist/claims/meta.d.ts.map +1 -0
  73. package/dist/{coordination/claimMeta.js → claims/meta.js} +1 -1
  74. package/dist/claims/meta.js.map +1 -0
  75. package/dist/claims/routes.d.ts +59 -0
  76. package/dist/claims/routes.d.ts.map +1 -0
  77. package/dist/claims/routes.js +69 -0
  78. package/dist/claims/routes.js.map +1 -0
  79. package/dist/claims/targetConflict.d.ts.map +1 -0
  80. package/dist/claims/targetConflict.js.map +1 -0
  81. package/dist/{coordination → claims}/trace.d.ts +2 -2
  82. package/dist/claims/trace.d.ts.map +1 -0
  83. package/dist/{coordination → claims}/trace.js +5 -5
  84. package/dist/claims/trace.js.map +1 -0
  85. package/dist/{ablo.d.ts → client/ablo.d.ts} +8 -18
  86. package/dist/client/ablo.d.ts.map +1 -0
  87. package/dist/{ablo.js → client/ablo.js} +2 -2
  88. package/dist/client/ablo.js.map +1 -0
  89. package/dist/{transactionLayer.d.ts → client/contract.d.ts} +12 -14
  90. package/dist/client/contract.d.ts.map +1 -0
  91. package/dist/{transactionLayer.js → client/contract.js} +4 -5
  92. package/dist/client/contract.js.map +1 -0
  93. package/dist/{headlessClient.d.ts → client/headless.d.ts} +4 -4
  94. package/dist/client/headless.d.ts.map +1 -0
  95. package/dist/{headlessClient.js → client/headless.js} +8 -10
  96. package/dist/{headlessClient.js.map → client/headless.js.map} +1 -1
  97. package/dist/client/index.d.ts +11 -0
  98. package/dist/client/index.d.ts.map +1 -0
  99. package/dist/client/index.js +11 -0
  100. package/dist/client/index.js.map +1 -0
  101. package/dist/{resources → client/resources}/functionalUpdate.d.ts +4 -4
  102. package/dist/client/resources/functionalUpdate.d.ts.map +1 -0
  103. package/dist/{resources → client/resources}/functionalUpdate.js +3 -3
  104. package/dist/client/resources/functionalUpdate.js.map +1 -0
  105. package/dist/{resources → client/resources}/httpResources.d.ts +51 -57
  106. package/dist/client/resources/httpResources.d.ts.map +1 -0
  107. package/dist/{resources → client/resources}/httpResources.js +1 -1
  108. package/dist/client/resources/httpResources.js.map +1 -0
  109. package/dist/{resources → client/resources}/modelCreate.d.ts +1 -1
  110. package/dist/client/resources/modelCreate.d.ts.map +1 -0
  111. package/dist/{resources → client/resources}/modelCreate.js +1 -1
  112. package/dist/client/resources/modelCreate.js.map +1 -0
  113. package/dist/{resources → client/resources}/modelOperations.d.ts +35 -51
  114. package/dist/client/resources/modelOperations.d.ts.map +1 -0
  115. package/dist/{resources → client/resources}/modelOperations.js +1 -1
  116. package/dist/client/resources/modelOperations.js.map +1 -0
  117. package/dist/{resources → client/resources}/mutationOptions.d.ts +4 -17
  118. package/dist/client/resources/mutationOptions.d.ts.map +1 -0
  119. package/dist/client/resources/mutationOptions.js.map +1 -0
  120. package/dist/client/resources/where.d.ts.map +1 -0
  121. package/dist/{resources → client/resources}/where.js +1 -1
  122. package/dist/client/resources/where.js.map +1 -0
  123. package/dist/{resources → client/resources}/writeOptionsSchema.d.ts +2 -35
  124. package/dist/client/resources/writeOptionsSchema.d.ts.map +1 -0
  125. package/dist/{resources → client/resources}/writeOptionsSchema.js +5 -18
  126. package/dist/client/resources/writeOptionsSchema.js.map +1 -0
  127. package/dist/client/surface.d.ts +15 -0
  128. package/dist/client/surface.d.ts.map +1 -0
  129. package/dist/client/surface.js +29 -0
  130. package/dist/client/surface.js.map +1 -0
  131. package/dist/{transactions → commit}/confirmation/commitEnvelope.d.ts +1 -37
  132. package/dist/commit/confirmation/commitEnvelope.d.ts.map +1 -0
  133. package/dist/{transactions → commit}/confirmation/commitEnvelope.js +2 -7
  134. package/dist/commit/confirmation/commitEnvelope.js.map +1 -0
  135. package/dist/commit/confirmation/httpCommitEnvelope.d.ts.map +1 -0
  136. package/dist/{transactions → commit}/confirmation/httpCommitEnvelope.js +1 -1
  137. package/dist/commit/confirmation/httpCommitEnvelope.js.map +1 -0
  138. package/dist/commit/confirmation/idempotencyKey.d.ts.map +1 -0
  139. package/dist/commit/confirmation/idempotencyKey.js.map +1 -0
  140. package/dist/{transactions → commit}/confirmation/pendingWrite.d.ts +2 -33
  141. package/dist/commit/confirmation/pendingWrite.d.ts.map +1 -0
  142. package/dist/{transactions → commit}/confirmation/pendingWrite.js +1 -1
  143. package/dist/commit/confirmation/pendingWrite.js.map +1 -0
  144. package/dist/commit/contract.d.ts +1404 -0
  145. package/dist/commit/contract.d.ts.map +1 -0
  146. package/dist/{wire/commit.js → commit/contract.js} +13 -20
  147. package/dist/commit/contract.js.map +1 -0
  148. package/dist/{durableWrites.d.ts → commit/durableWrites.d.ts} +6 -6
  149. package/dist/commit/durableWrites.d.ts.map +1 -0
  150. package/dist/{durableWrites.js → commit/durableWrites.js} +5 -5
  151. package/dist/commit/durableWrites.js.map +1 -0
  152. package/dist/{transport/httpCommitRequest.d.ts → commit/httpRequest.d.ts} +6 -6
  153. package/dist/commit/httpRequest.d.ts.map +1 -0
  154. package/dist/{transport/httpCommitRequest.js → commit/httpRequest.js} +2 -3
  155. package/dist/commit/httpRequest.js.map +1 -0
  156. package/dist/commit/index.d.ts +17 -0
  157. package/dist/commit/index.d.ts.map +1 -0
  158. package/dist/commit/index.js +17 -0
  159. package/dist/commit/index.js.map +1 -0
  160. package/dist/{readSetContext.d.ts → commit/readSetContext.d.ts} +7 -15
  161. package/dist/commit/readSetContext.d.ts.map +1 -0
  162. package/dist/{readSetContext.js → commit/readSetContext.js} +10 -25
  163. package/dist/commit/readSetContext.js.map +1 -0
  164. package/dist/{commitRecordRuntime.d.ts → commit/recordRuntime.d.ts} +3 -5
  165. package/dist/commit/recordRuntime.d.ts.map +1 -0
  166. package/dist/{commitRecordRuntime.js → commit/recordRuntime.js} +13 -54
  167. package/dist/commit/recordRuntime.js.map +1 -0
  168. package/dist/coordination/index.d.ts +6 -8
  169. package/dist/coordination/index.d.ts.map +1 -1
  170. package/dist/coordination/index.js +3 -9
  171. package/dist/coordination/index.js.map +1 -1
  172. package/dist/coordination/schema.d.ts +11 -459
  173. package/dist/coordination/schema.d.ts.map +1 -1
  174. package/dist/coordination/schema.js +13 -261
  175. package/dist/coordination/schema.js.map +1 -1
  176. package/dist/errorCodes.d.ts +15 -9
  177. package/dist/errorCodes.d.ts.map +1 -1
  178. package/dist/errorCodes.js +13 -6
  179. package/dist/errorCodes.js.map +1 -1
  180. package/dist/errorObservation.d.ts +2 -2
  181. package/dist/errors.d.ts +3 -2
  182. package/dist/errors.d.ts.map +1 -1
  183. package/dist/errors.js +27 -11
  184. package/dist/errors.js.map +1 -1
  185. package/dist/index.d.ts +7 -7
  186. package/dist/index.d.ts.map +1 -1
  187. package/dist/index.js +3 -3
  188. package/dist/index.js.map +1 -1
  189. package/dist/internal/read-set.d.ts +3 -3
  190. package/dist/internal/read-set.d.ts.map +1 -1
  191. package/dist/internal/read-set.js +2 -2
  192. package/dist/internal/read-set.js.map +1 -1
  193. package/dist/observability.d.ts +4 -4
  194. package/dist/observability.d.ts.map +1 -1
  195. package/dist/observability.js +2 -2
  196. package/dist/{wire/delta.d.ts → observation/contract.d.ts} +8 -8
  197. package/dist/observation/contract.d.ts.map +1 -0
  198. package/dist/{wire/delta.js → observation/contract.js} +3 -3
  199. package/dist/observation/contract.js.map +1 -0
  200. package/dist/{wire/feedCursor.d.ts → observation/cursor.d.ts} +1 -1
  201. package/dist/observation/cursor.d.ts.map +1 -0
  202. package/dist/{wire/feedCursor.js → observation/cursor.js} +1 -1
  203. package/dist/observation/cursor.js.map +1 -0
  204. package/dist/{wire/deltaDelivery.d.ts → observation/deliveryContract.d.ts} +1 -1
  205. package/dist/observation/deliveryContract.d.ts.map +1 -0
  206. package/dist/{wire/deltaDelivery.js → observation/deliveryContract.js} +1 -1
  207. package/dist/observation/deliveryContract.js.map +1 -0
  208. package/dist/{wire/feedEvent.d.ts → observation/feedContract.d.ts} +10 -10
  209. package/dist/observation/feedContract.d.ts.map +1 -0
  210. package/dist/{wire/feedEvent.js → observation/feedContract.js} +4 -4
  211. package/dist/observation/feedContract.js.map +1 -0
  212. package/dist/observation/httpFeed.d.ts +4 -0
  213. package/dist/observation/httpFeed.d.ts.map +1 -0
  214. package/dist/{transport → observation}/httpFeed.js +1 -1
  215. package/dist/{transport → observation}/httpFeed.js.map +1 -1
  216. package/dist/observation/index.d.ts +13 -0
  217. package/dist/observation/index.d.ts.map +1 -0
  218. package/dist/observation/index.js +13 -0
  219. package/dist/observation/index.js.map +1 -0
  220. package/dist/{log → observation/persistence}/syncDeltaRow.d.ts +8 -8
  221. package/dist/observation/persistence/syncDeltaRow.d.ts.map +1 -0
  222. package/dist/{log → observation/persistence}/syncDeltaRow.js +4 -4
  223. package/dist/observation/persistence/syncDeltaRow.js.map +1 -0
  224. package/dist/pricing.d.ts +26 -12
  225. package/dist/pricing.d.ts.map +1 -1
  226. package/dist/pricing.js +61 -27
  227. package/dist/pricing.js.map +1 -1
  228. package/dist/schema/ddl.d.ts.map +1 -1
  229. package/dist/schema/ddl.js +1 -1
  230. package/dist/schema/ddl.js.map +1 -1
  231. package/dist/schema/deployment/backfill.d.ts +44 -0
  232. package/dist/schema/deployment/backfill.d.ts.map +1 -0
  233. package/dist/schema/deployment/backfill.js +57 -0
  234. package/dist/schema/deployment/backfill.js.map +1 -0
  235. package/dist/schema/deployment/contracts.d.ts +526 -0
  236. package/dist/schema/deployment/contracts.d.ts.map +1 -0
  237. package/dist/schema/deployment/contracts.js +77 -0
  238. package/dist/schema/deployment/contracts.js.map +1 -0
  239. package/dist/schema/deployment/fingerprint.d.ts +3 -0
  240. package/dist/schema/deployment/fingerprint.d.ts.map +1 -0
  241. package/dist/schema/deployment/fingerprint.js +18 -0
  242. package/dist/schema/deployment/fingerprint.js.map +1 -0
  243. package/dist/schema/deployment/index.d.ts +18 -0
  244. package/dist/schema/deployment/index.d.ts.map +1 -0
  245. package/dist/schema/deployment/index.js +71 -0
  246. package/dist/schema/deployment/index.js.map +1 -0
  247. package/dist/schema/deployment/postgresCatalog.d.ts +39 -0
  248. package/dist/schema/deployment/postgresCatalog.d.ts.map +1 -0
  249. package/dist/schema/deployment/postgresCatalog.js +86 -0
  250. package/dist/schema/deployment/postgresCatalog.js.map +1 -0
  251. package/dist/schema/deployment/reconcile.d.ts +20 -0
  252. package/dist/schema/deployment/reconcile.d.ts.map +1 -0
  253. package/dist/schema/deployment/reconcile.js +226 -0
  254. package/dist/schema/deployment/reconcile.js.map +1 -0
  255. package/dist/schema/deployment/sequence.d.ts +4 -0
  256. package/dist/schema/deployment/sequence.d.ts.map +1 -0
  257. package/dist/schema/deployment/sequence.js +71 -0
  258. package/dist/schema/deployment/sequence.js.map +1 -0
  259. package/dist/schema/index.d.ts +6 -6
  260. package/dist/schema/index.d.ts.map +1 -1
  261. package/dist/schema/index.js +8 -7
  262. package/dist/schema/index.js.map +1 -1
  263. package/dist/schema/model.d.ts +0 -27
  264. package/dist/schema/model.d.ts.map +1 -1
  265. package/dist/schema/model.js +0 -2
  266. package/dist/schema/model.js.map +1 -1
  267. package/dist/schema/openapi.d.ts.map +1 -1
  268. package/dist/schema/openapi.js +45 -6
  269. package/dist/schema/openapi.js.map +1 -1
  270. package/dist/schema/schema.d.ts +11 -3
  271. package/dist/schema/schema.d.ts.map +1 -1
  272. package/dist/schema/schema.js +9 -2
  273. package/dist/schema/schema.js.map +1 -1
  274. package/dist/schema/serialize.d.ts +1 -4
  275. package/dist/schema/serialize.d.ts.map +1 -1
  276. package/dist/schema/serialize.js +0 -4
  277. package/dist/schema/serialize.js.map +1 -1
  278. package/dist/schema/tenancy.d.ts +1 -1
  279. package/dist/server/adapter.d.ts +1 -1
  280. package/dist/server/adapter.d.ts.map +1 -1
  281. package/dist/server/commit.d.ts +6 -14
  282. package/dist/server/commit.d.ts.map +1 -1
  283. package/dist/server/index.d.ts +1 -1
  284. package/dist/server/index.d.ts.map +1 -1
  285. package/dist/server/index.js +1 -1
  286. package/dist/server/index.js.map +1 -1
  287. package/dist/server/storageMode.d.ts +1 -1
  288. package/dist/source/{adapter.d.ts → adapters/adapter.d.ts} +10 -4
  289. package/dist/source/adapters/adapter.d.ts.map +1 -0
  290. package/dist/source/adapters/adapter.js.map +1 -0
  291. package/dist/source/adapters/adapterFactory.d.ts.map +1 -0
  292. package/dist/source/{adapterFactory.js → adapters/adapterFactory.js} +1 -1
  293. package/dist/source/adapters/adapterFactory.js.map +1 -0
  294. package/dist/source/adapters/adapterProfile.d.ts.map +1 -0
  295. package/dist/source/adapters/adapterProfile.js.map +1 -0
  296. package/dist/source/{conformance.d.ts → adapters/conformance.d.ts} +1 -1
  297. package/dist/source/adapters/conformance.d.ts.map +1 -0
  298. package/dist/source/{conformance.js → adapters/conformance.js} +1 -1
  299. package/dist/source/adapters/conformance.js.map +1 -0
  300. package/dist/source/{contract.d.ts → adapters/contract.d.ts} +8 -77
  301. package/dist/source/adapters/contract.d.ts.map +1 -0
  302. package/dist/source/{contract.js → adapters/contract.js} +12 -57
  303. package/dist/source/adapters/contract.js.map +1 -0
  304. package/dist/source/adapters/drizzle.d.ts +1 -1
  305. package/dist/source/adapters/drizzle.d.ts.map +1 -1
  306. package/dist/source/adapters/drizzle.js +21 -23
  307. package/dist/source/adapters/drizzle.js.map +1 -1
  308. package/dist/source/adapters/idempotency.d.ts.map +1 -0
  309. package/dist/source/{idempotency.js → adapters/idempotency.js} +2 -2
  310. package/dist/source/adapters/idempotency.js.map +1 -0
  311. package/dist/source/adapters/index.d.ts +21 -0
  312. package/dist/source/adapters/index.d.ts.map +1 -0
  313. package/dist/source/adapters/index.js +21 -0
  314. package/dist/source/adapters/index.js.map +1 -0
  315. package/dist/source/adapters/kysely.d.ts +1 -1
  316. package/dist/source/adapters/kysely.d.ts.map +1 -1
  317. package/dist/source/adapters/kysely.js +18 -20
  318. package/dist/source/adapters/kysely.js.map +1 -1
  319. package/dist/source/adapters/kyselyMutationCore.d.ts +2 -2
  320. package/dist/source/adapters/kyselyMutationCore.d.ts.map +1 -1
  321. package/dist/source/adapters/kyselyMutationCore.js +1 -1
  322. package/dist/source/adapters/kyselyMutationCore.js.map +1 -1
  323. package/dist/source/adapters/memory.d.ts +3 -3
  324. package/dist/source/adapters/memory.d.ts.map +1 -1
  325. package/dist/source/adapters/memory.js +19 -7
  326. package/dist/source/adapters/memory.js.map +1 -1
  327. package/dist/source/adapters/migration.d.ts +8 -0
  328. package/dist/source/adapters/migration.d.ts.map +1 -0
  329. package/dist/source/adapters/migration.js +9 -0
  330. package/dist/source/adapters/migration.js.map +1 -0
  331. package/dist/source/{migrations.d.ts → adapters/migrations.d.ts} +3 -4
  332. package/dist/source/adapters/migrations.d.ts.map +1 -0
  333. package/dist/source/{migrations.js → adapters/migrations.js} +4 -52
  334. package/dist/source/adapters/migrations.js.map +1 -0
  335. package/dist/source/adapters/prisma.d.ts +1 -1
  336. package/dist/source/adapters/prisma.d.ts.map +1 -1
  337. package/dist/source/adapters/prisma.js +21 -28
  338. package/dist/source/adapters/prisma.js.map +1 -1
  339. package/dist/source/{subjectAuthorization.d.ts → adapters/subjectAuthorization.d.ts} +1 -1
  340. package/dist/source/adapters/subjectAuthorization.d.ts.map +1 -0
  341. package/dist/source/{subjectAuthorization.js → adapters/subjectAuthorization.js} +2 -2
  342. package/dist/source/adapters/subjectAuthorization.js.map +1 -0
  343. package/dist/source/{connector.d.ts → connector/client.d.ts} +6 -1
  344. package/dist/source/connector/client.d.ts.map +1 -0
  345. package/dist/source/{connector.js → connector/client.js} +28 -11
  346. package/dist/source/connector/client.js.map +1 -0
  347. package/dist/source/connector/index.d.ts +4 -0
  348. package/dist/source/connector/index.d.ts.map +1 -0
  349. package/dist/source/connector/index.js +4 -0
  350. package/dist/source/connector/index.js.map +1 -0
  351. package/dist/source/{connectorProtocol.d.ts → connector/protocol.d.ts} +8 -1
  352. package/dist/source/connector/protocol.d.ts.map +1 -0
  353. package/dist/source/{connectorProtocol.js → connector/protocol.js} +10 -3
  354. package/dist/source/connector/protocol.js.map +1 -0
  355. package/dist/source/delivery/index.d.ts +3 -0
  356. package/dist/source/delivery/index.d.ts.map +1 -0
  357. package/dist/source/delivery/index.js +3 -0
  358. package/dist/source/delivery/index.js.map +1 -0
  359. package/dist/source/{pushQueue.d.ts → delivery/pushQueue.d.ts} +1 -1
  360. package/dist/source/delivery/pushQueue.d.ts.map +1 -0
  361. package/dist/source/{pushQueue.js → delivery/pushQueue.js} +1 -1
  362. package/dist/source/delivery/pushQueue.js.map +1 -0
  363. package/dist/source/{factory.d.ts → endpoint/factory.d.ts} +3 -3
  364. package/dist/source/endpoint/factory.d.ts.map +1 -0
  365. package/dist/source/{factory.js → endpoint/factory.js} +9 -4
  366. package/dist/source/endpoint/factory.js.map +1 -0
  367. package/dist/source/endpoint/index.d.ts +5 -0
  368. package/dist/source/endpoint/index.d.ts.map +1 -0
  369. package/dist/source/endpoint/index.js +5 -0
  370. package/dist/source/endpoint/index.js.map +1 -0
  371. package/dist/source/{next.d.ts → endpoint/next.d.ts} +2 -2
  372. package/dist/source/endpoint/next.d.ts.map +1 -0
  373. package/dist/source/{next.js → endpoint/next.js} +1 -1
  374. package/dist/source/endpoint/next.js.map +1 -0
  375. package/dist/source/{signing.d.ts → endpoint/signing.d.ts} +1 -1
  376. package/dist/source/endpoint/signing.d.ts.map +1 -0
  377. package/dist/source/{signing.js → endpoint/signing.js} +1 -1
  378. package/dist/source/endpoint/signing.js.map +1 -0
  379. package/dist/source/index.d.ts +14 -12
  380. package/dist/source/index.d.ts.map +1 -1
  381. package/dist/source/index.js +13 -11
  382. package/dist/source/index.js.map +1 -1
  383. package/dist/source/outbox/contract.d.ts +50 -0
  384. package/dist/source/outbox/contract.d.ts.map +1 -0
  385. package/dist/source/outbox/contract.js +50 -0
  386. package/dist/source/outbox/contract.js.map +1 -0
  387. package/dist/source/outbox/envelope.d.ts +9 -0
  388. package/dist/source/outbox/envelope.d.ts.map +1 -0
  389. package/dist/source/outbox/envelope.js +36 -0
  390. package/dist/source/outbox/envelope.js.map +1 -0
  391. package/dist/source/outbox/index.d.ts +11 -0
  392. package/dist/source/outbox/index.d.ts.map +1 -0
  393. package/dist/source/outbox/index.js +11 -0
  394. package/dist/source/outbox/index.js.map +1 -0
  395. package/dist/source/outbox/migrations.d.ts +4 -0
  396. package/dist/source/outbox/migrations.d.ts.map +1 -0
  397. package/dist/source/outbox/migrations.js +67 -0
  398. package/dist/source/outbox/migrations.js.map +1 -0
  399. package/dist/source/outbox/retention.d.ts +3 -0
  400. package/dist/source/outbox/retention.d.ts.map +1 -0
  401. package/dist/source/outbox/retention.js +3 -0
  402. package/dist/source/outbox/retention.js.map +1 -0
  403. package/dist/source/types.d.ts +16 -17
  404. package/dist/source/types.d.ts.map +1 -1
  405. package/dist/source/types.js +1 -0
  406. package/dist/source/types.js.map +1 -1
  407. package/dist/syncLog/contract.d.ts +19 -2
  408. package/dist/syncLog/contract.d.ts.map +1 -1
  409. package/dist/syncLog/contract.js +19 -2
  410. package/dist/syncLog/contract.js.map +1 -1
  411. package/dist/transport/{credentialLifecycle.d.ts → connection/credentialLifecycle.d.ts} +3 -3
  412. package/dist/transport/connection/credentialLifecycle.d.ts.map +1 -0
  413. package/dist/transport/{credentialLifecycle.js → connection/credentialLifecycle.js} +2 -2
  414. package/dist/transport/connection/credentialLifecycle.js.map +1 -0
  415. package/dist/transport/connection/index.d.ts +5 -0
  416. package/dist/transport/connection/index.d.ts.map +1 -0
  417. package/dist/transport/connection/index.js +5 -0
  418. package/dist/transport/connection/index.js.map +1 -0
  419. package/dist/transport/{connectionManager.d.ts → connection/manager.d.ts} +13 -5
  420. package/dist/transport/connection/manager.d.ts.map +1 -0
  421. package/dist/transport/{connectionManager.js → connection/manager.js} +6 -4
  422. package/dist/transport/connection/manager.js.map +1 -0
  423. package/dist/transport/{networkProbe.d.ts → connection/networkProbe.d.ts} +2 -2
  424. package/dist/transport/connection/networkProbe.d.ts.map +1 -0
  425. package/dist/transport/{networkProbe.js → connection/networkProbe.js} +4 -4
  426. package/dist/transport/connection/networkProbe.js.map +1 -0
  427. package/dist/transport/{httpClient.d.ts → http/client.d.ts} +26 -45
  428. package/dist/transport/http/client.d.ts.map +1 -0
  429. package/dist/transport/{httpClient.js → http/client.js} +84 -124
  430. package/dist/transport/http/client.js.map +1 -0
  431. package/dist/transport/{httpTransportHelpers.d.ts → http/helpers.d.ts} +5 -5
  432. package/dist/transport/http/helpers.d.ts.map +1 -0
  433. package/dist/transport/{httpTransportHelpers.js → http/helpers.js} +5 -5
  434. package/dist/transport/http/helpers.js.map +1 -0
  435. package/dist/transport/http/index.d.ts +6 -0
  436. package/dist/transport/http/index.d.ts.map +1 -0
  437. package/dist/transport/http/index.js +6 -0
  438. package/dist/transport/http/index.js.map +1 -0
  439. package/dist/transport/{httpOptions.d.ts → http/options.d.ts} +7 -7
  440. package/dist/transport/{httpOptions.d.ts.map → http/options.d.ts.map} +1 -1
  441. package/dist/transport/{httpOptions.js → http/options.js} +1 -1
  442. package/dist/transport/http/options.js.map +1 -0
  443. package/dist/transport/http/subscription.d.ts +16 -0
  444. package/dist/transport/http/subscription.d.ts.map +1 -0
  445. package/dist/transport/http/subscription.js +146 -0
  446. package/dist/transport/http/subscription.js.map +1 -0
  447. package/dist/transport/{httpTransport.d.ts → http/transport.d.ts} +9 -6
  448. package/dist/transport/http/transport.d.ts.map +1 -0
  449. package/dist/transport/{httpTransport.js → http/transport.js} +95 -93
  450. package/dist/transport/http/transport.js.map +1 -0
  451. package/dist/transport/index.d.ts +8 -0
  452. package/dist/transport/index.d.ts.map +1 -0
  453. package/dist/transport/index.js +8 -0
  454. package/dist/transport/index.js.map +1 -0
  455. package/dist/transport/{commitFrames.d.ts → websocket/commitFrames.d.ts} +8 -20
  456. package/dist/transport/websocket/commitFrames.d.ts.map +1 -0
  457. package/dist/transport/{commitFrames.js → websocket/commitFrames.js} +6 -25
  458. package/dist/transport/websocket/commitFrames.js.map +1 -0
  459. package/dist/transport/{wsFrameHandlers.d.ts → websocket/frameHandlers.d.ts} +5 -5
  460. package/dist/transport/websocket/frameHandlers.d.ts.map +1 -0
  461. package/dist/transport/{wsFrameHandlers.js → websocket/frameHandlers.js} +10 -51
  462. package/dist/transport/websocket/frameHandlers.js.map +1 -0
  463. package/dist/transport/{heartbeat.d.ts → websocket/heartbeat.d.ts} +1 -1
  464. package/dist/transport/websocket/heartbeat.d.ts.map +1 -0
  465. package/dist/transport/{heartbeat.js → websocket/heartbeat.js} +2 -2
  466. package/dist/transport/websocket/heartbeat.js.map +1 -0
  467. package/dist/transport/websocket/index.d.ts +6 -0
  468. package/dist/transport/websocket/index.d.ts.map +1 -0
  469. package/dist/transport/websocket/index.js +6 -0
  470. package/dist/transport/websocket/index.js.map +1 -0
  471. package/dist/transport/{wsTransport.d.ts → websocket/transport.d.ts} +13 -25
  472. package/dist/transport/websocket/transport.d.ts.map +1 -0
  473. package/dist/transport/{wsTransport.js → websocket/transport.js} +14 -14
  474. package/dist/transport/websocket/transport.js.map +1 -0
  475. package/dist/types/index.d.ts +1 -1
  476. package/dist/types/index.d.ts.map +1 -1
  477. package/dist/types/streams.d.ts +8 -48
  478. package/dist/types/streams.d.ts.map +1 -1
  479. package/dist/types/streams.js +2 -2
  480. package/dist/wire/accountResponses.d.ts +4 -72
  481. package/dist/wire/accountResponses.d.ts.map +1 -1
  482. package/dist/wire/accountResponses.js +2 -10
  483. package/dist/wire/accountResponses.js.map +1 -1
  484. package/dist/wire/frames.d.ts +6 -83
  485. package/dist/wire/frames.d.ts.map +1 -1
  486. package/dist/wire/frames.js +4 -11
  487. package/dist/wire/frames.js.map +1 -1
  488. package/dist/wire/inboundFrames.d.ts +6 -131
  489. package/dist/wire/inboundFrames.d.ts.map +1 -1
  490. package/dist/wire/inboundFrames.js +3 -3
  491. package/dist/wire/inboundFrames.js.map +1 -1
  492. package/dist/wire/index.d.ts +17 -15
  493. package/dist/wire/index.d.ts.map +1 -1
  494. package/dist/wire/index.js +11 -8
  495. package/dist/wire/index.js.map +1 -1
  496. package/dist/wire/modelMutations.d.ts +1 -32
  497. package/dist/wire/modelMutations.d.ts.map +1 -1
  498. package/dist/wire/modelMutations.js +1 -8
  499. package/dist/wire/modelMutations.js.map +1 -1
  500. package/package.json +130 -10
  501. package/src/ai-sdk/modelTools.ts +5 -5
  502. package/src/ai-sdk/updateTool.ts +5 -7
  503. package/src/auth/capability.ts +5 -0
  504. package/src/auth/capabilityLifecycle.ts +1 -1
  505. package/src/auth/credentialPolicy.ts +1 -1
  506. package/src/auth/identity.ts +7 -7
  507. package/src/auth/index.ts +4 -663
  508. package/src/auth/runtime.ts +669 -0
  509. package/src/auth/sessionMint.ts +3 -2
  510. package/src/branches.ts +3 -0
  511. package/src/{coordination/awaitClaimGrant.ts → claims/awaitGrant.ts} +4 -4
  512. package/src/{wire/claims.ts → claims/contract.ts} +1 -1
  513. package/src/{coordination → claims}/events.ts +7 -11
  514. package/src/claims/index.ts +21 -0
  515. package/src/claims/lifetime.ts +78 -0
  516. package/src/{coordination → claims}/locator.ts +3 -3
  517. package/src/claims/routes.ts +81 -0
  518. package/src/{coordination → claims}/trace.ts +5 -5
  519. package/src/{ablo.ts → client/ablo.ts} +10 -22
  520. package/src/{transactionLayer.ts → client/contract.ts} +11 -13
  521. package/src/{headlessClient.ts → client/headless.ts} +13 -15
  522. package/src/client/index.ts +10 -0
  523. package/src/{resources → client/resources}/functionalUpdate.ts +4 -4
  524. package/src/{resources → client/resources}/httpResources.ts +48 -68
  525. package/src/{resources → client/resources}/modelCreate.ts +2 -2
  526. package/src/{resources → client/resources}/modelOperations.ts +46 -55
  527. package/src/{resources → client/resources}/mutationOptions.ts +4 -17
  528. package/src/{resources → client/resources}/where.ts +1 -1
  529. package/src/{resources → client/resources}/writeOptionsSchema.ts +7 -27
  530. package/src/client/surface.ts +50 -0
  531. package/src/{transactions → commit}/confirmation/commitEnvelope.ts +2 -12
  532. package/src/{transactions → commit}/confirmation/httpCommitEnvelope.ts +1 -1
  533. package/src/{transactions → commit}/confirmation/pendingWrite.ts +1 -1
  534. package/src/{wire/commit.ts → commit/contract.ts} +11 -25
  535. package/src/{durableWrites.ts → commit/durableWrites.ts} +7 -7
  536. package/src/{transport/httpCommitRequest.ts → commit/httpRequest.ts} +6 -7
  537. package/src/commit/index.ts +16 -0
  538. package/src/{readSetContext.ts → commit/readSetContext.ts} +16 -41
  539. package/src/{commitRecordRuntime.ts → commit/recordRuntime.ts} +12 -67
  540. package/src/coordination/index.ts +4 -52
  541. package/src/coordination/schema.ts +15 -302
  542. package/src/errorCodes.ts +56 -10
  543. package/src/errors.ts +32 -10
  544. package/src/index.ts +8 -8
  545. package/src/internal/read-set.ts +3 -6
  546. package/src/observability.ts +4 -4
  547. package/src/{wire/delta.ts → observation/contract.ts} +2 -2
  548. package/src/{wire/feedEvent.ts → observation/feedContract.ts} +3 -4
  549. package/src/{transport → observation}/httpFeed.ts +3 -3
  550. package/src/observation/index.ts +12 -0
  551. package/src/{log → observation/persistence}/syncDeltaRow.ts +6 -7
  552. package/src/pricing.ts +61 -26
  553. package/src/schema/ddl.ts +3 -1
  554. package/src/schema/deployment/backfill.ts +88 -0
  555. package/src/schema/deployment/contracts.ts +119 -0
  556. package/src/schema/deployment/fingerprint.ts +13 -0
  557. package/src/schema/deployment/index.ts +81 -0
  558. package/src/schema/deployment/postgresCatalog.ts +131 -0
  559. package/src/schema/deployment/reconcile.ts +219 -0
  560. package/src/schema/deployment/sequence.ts +85 -0
  561. package/src/schema/index.ts +9 -20
  562. package/src/schema/model.ts +0 -33
  563. package/src/schema/openapi.ts +47 -7
  564. package/src/schema/schema.ts +23 -3
  565. package/src/schema/serialize.ts +0 -8
  566. package/src/server/adapter.ts +1 -1
  567. package/src/server/commit.ts +6 -14
  568. package/src/server/index.ts +1 -1
  569. package/src/source/{adapter.ts → adapters/adapter.ts} +9 -5
  570. package/src/source/{adapterFactory.ts → adapters/adapterFactory.ts} +1 -1
  571. package/src/source/{conformance.ts → adapters/conformance.ts} +1 -1
  572. package/src/source/{contract.ts → adapters/contract.ts} +16 -64
  573. package/src/source/adapters/drizzle.ts +29 -27
  574. package/src/source/{idempotency.ts → adapters/idempotency.ts} +2 -2
  575. package/src/source/adapters/index.ts +20 -0
  576. package/src/source/adapters/kysely.ts +32 -25
  577. package/src/source/adapters/kyselyMutationCore.ts +3 -3
  578. package/src/source/adapters/memory.ts +25 -9
  579. package/src/source/adapters/migration.ts +11 -0
  580. package/src/source/{migrations.ts → adapters/migrations.ts} +6 -54
  581. package/src/source/adapters/prisma.ts +33 -32
  582. package/src/source/{subjectAuthorization.ts → adapters/subjectAuthorization.ts} +2 -2
  583. package/src/source/{connector.ts → connector/client.ts} +35 -12
  584. package/src/source/connector/index.ts +3 -0
  585. package/src/source/{connectorProtocol.ts → connector/protocol.ts} +10 -2
  586. package/src/source/delivery/index.ts +2 -0
  587. package/src/source/{pushQueue.ts → delivery/pushQueue.ts} +2 -2
  588. package/src/source/{factory.ts → endpoint/factory.ts} +13 -8
  589. package/src/source/endpoint/index.ts +4 -0
  590. package/src/source/{next.ts → endpoint/next.ts} +2 -2
  591. package/src/source/{signing.ts → endpoint/signing.ts} +1 -1
  592. package/src/source/index.ts +22 -19
  593. package/src/source/outbox/contract.ts +56 -0
  594. package/src/source/outbox/envelope.ts +47 -0
  595. package/src/source/outbox/index.ts +15 -0
  596. package/src/source/outbox/migrations.ts +71 -0
  597. package/src/source/outbox/retention.ts +2 -0
  598. package/src/source/types.ts +17 -17
  599. package/src/syncLog/contract.ts +19 -2
  600. package/src/transport/{credentialLifecycle.ts → connection/credentialLifecycle.ts} +3 -3
  601. package/src/transport/connection/index.ts +4 -0
  602. package/src/transport/{connectionManager.ts → connection/manager.ts} +13 -4
  603. package/src/transport/{networkProbe.ts → connection/networkProbe.ts} +4 -4
  604. package/src/transport/{httpClient.ts → http/client.ts} +128 -209
  605. package/src/transport/{httpTransportHelpers.ts → http/helpers.ts} +7 -7
  606. package/src/transport/http/index.ts +5 -0
  607. package/src/transport/{httpOptions.ts → http/options.ts} +6 -6
  608. package/src/transport/http/subscription.ts +174 -0
  609. package/src/transport/{httpTransport.ts → http/transport.ts} +127 -113
  610. package/src/transport/index.ts +7 -0
  611. package/src/transport/{commitFrames.ts → websocket/commitFrames.ts} +14 -46
  612. package/src/transport/{wsFrameHandlers.ts → websocket/frameHandlers.ts} +11 -54
  613. package/src/transport/{heartbeat.ts → websocket/heartbeat.ts} +2 -2
  614. package/src/transport/websocket/index.ts +5 -0
  615. package/src/transport/{wsTransport.ts → websocket/transport.ts} +16 -30
  616. package/src/types/index.ts +2 -6
  617. package/src/types/streams.ts +7 -61
  618. package/src/webhooks/events.ts +1 -1
  619. package/src/wire/accountResponses.ts +3 -12
  620. package/src/wire/frames.ts +5 -15
  621. package/src/wire/inboundFrames.ts +3 -3
  622. package/src/wire/index.ts +19 -15
  623. package/src/wire/modelMutations.ts +1 -14
  624. package/dist/ablo.d.ts.map +0 -1
  625. package/dist/ablo.js.map +0 -1
  626. package/dist/commitRecordRuntime.d.ts.map +0 -1
  627. package/dist/commitRecordRuntime.js.map +0 -1
  628. package/dist/coordination/awaitClaimGrant.d.ts.map +0 -1
  629. package/dist/coordination/awaitClaimGrant.js.map +0 -1
  630. package/dist/coordination/claimHeartbeatLoop.d.ts.map +0 -1
  631. package/dist/coordination/claimHeartbeatLoop.js.map +0 -1
  632. package/dist/coordination/claimMeta.d.ts.map +0 -1
  633. package/dist/coordination/claimMeta.js.map +0 -1
  634. package/dist/coordination/events.d.ts.map +0 -1
  635. package/dist/coordination/events.js +0 -8
  636. package/dist/coordination/events.js.map +0 -1
  637. package/dist/coordination/locator.d.ts.map +0 -1
  638. package/dist/coordination/locator.js.map +0 -1
  639. package/dist/coordination/targetConflict.d.ts.map +0 -1
  640. package/dist/coordination/targetConflict.js.map +0 -1
  641. package/dist/coordination/trace.d.ts.map +0 -1
  642. package/dist/coordination/trace.js.map +0 -1
  643. package/dist/durableWrites.d.ts.map +0 -1
  644. package/dist/durableWrites.js.map +0 -1
  645. package/dist/headlessClient.d.ts.map +0 -1
  646. package/dist/log/syncDeltaRow.d.ts.map +0 -1
  647. package/dist/log/syncDeltaRow.js.map +0 -1
  648. package/dist/policy/types.d.ts +0 -226
  649. package/dist/policy/types.d.ts.map +0 -1
  650. package/dist/policy/types.js +0 -127
  651. package/dist/policy/types.js.map +0 -1
  652. package/dist/readSetContext.d.ts.map +0 -1
  653. package/dist/readSetContext.js.map +0 -1
  654. package/dist/resources/functionalUpdate.d.ts.map +0 -1
  655. package/dist/resources/functionalUpdate.js.map +0 -1
  656. package/dist/resources/httpResources.d.ts.map +0 -1
  657. package/dist/resources/httpResources.js.map +0 -1
  658. package/dist/resources/modelCreate.d.ts.map +0 -1
  659. package/dist/resources/modelCreate.js.map +0 -1
  660. package/dist/resources/modelOperations.d.ts.map +0 -1
  661. package/dist/resources/modelOperations.js.map +0 -1
  662. package/dist/resources/mutationOptions.d.ts.map +0 -1
  663. package/dist/resources/mutationOptions.js.map +0 -1
  664. package/dist/resources/where.d.ts.map +0 -1
  665. package/dist/resources/where.js.map +0 -1
  666. package/dist/resources/writeOptionsSchema.d.ts.map +0 -1
  667. package/dist/resources/writeOptionsSchema.js.map +0 -1
  668. package/dist/schema/coordination.d.ts +0 -113
  669. package/dist/schema/coordination.d.ts.map +0 -1
  670. package/dist/schema/coordination.js +0 -134
  671. package/dist/schema/coordination.js.map +0 -1
  672. package/dist/source/adapter.d.ts.map +0 -1
  673. package/dist/source/adapter.js.map +0 -1
  674. package/dist/source/adapterFactory.d.ts.map +0 -1
  675. package/dist/source/adapterFactory.js.map +0 -1
  676. package/dist/source/adapterProfile.d.ts.map +0 -1
  677. package/dist/source/adapterProfile.js.map +0 -1
  678. package/dist/source/conformance.d.ts.map +0 -1
  679. package/dist/source/conformance.js.map +0 -1
  680. package/dist/source/connector.d.ts.map +0 -1
  681. package/dist/source/connector.js.map +0 -1
  682. package/dist/source/connectorProtocol.d.ts.map +0 -1
  683. package/dist/source/connectorProtocol.js.map +0 -1
  684. package/dist/source/contract.d.ts.map +0 -1
  685. package/dist/source/contract.js.map +0 -1
  686. package/dist/source/drizzle.d.ts +0 -2
  687. package/dist/source/drizzle.d.ts.map +0 -1
  688. package/dist/source/drizzle.js +0 -2
  689. package/dist/source/drizzle.js.map +0 -1
  690. package/dist/source/factory.d.ts.map +0 -1
  691. package/dist/source/factory.js.map +0 -1
  692. package/dist/source/idempotency.d.ts.map +0 -1
  693. package/dist/source/idempotency.js.map +0 -1
  694. package/dist/source/kysely.d.ts +0 -3
  695. package/dist/source/kysely.d.ts.map +0 -1
  696. package/dist/source/kysely.js +0 -3
  697. package/dist/source/kysely.js.map +0 -1
  698. package/dist/source/migrations.d.ts.map +0 -1
  699. package/dist/source/migrations.js.map +0 -1
  700. package/dist/source/next.d.ts.map +0 -1
  701. package/dist/source/next.js.map +0 -1
  702. package/dist/source/pushQueue.d.ts.map +0 -1
  703. package/dist/source/pushQueue.js.map +0 -1
  704. package/dist/source/signing.d.ts.map +0 -1
  705. package/dist/source/signing.js.map +0 -1
  706. package/dist/source/subjectAuthorization.d.ts.map +0 -1
  707. package/dist/source/subjectAuthorization.js.map +0 -1
  708. package/dist/transactionLayer.d.ts.map +0 -1
  709. package/dist/transactionLayer.js.map +0 -1
  710. package/dist/transactions/confirmation/commitEnvelope.d.ts.map +0 -1
  711. package/dist/transactions/confirmation/commitEnvelope.js.map +0 -1
  712. package/dist/transactions/confirmation/httpCommitEnvelope.d.ts.map +0 -1
  713. package/dist/transactions/confirmation/httpCommitEnvelope.js.map +0 -1
  714. package/dist/transactions/confirmation/idempotencyKey.d.ts.map +0 -1
  715. package/dist/transactions/confirmation/idempotencyKey.js.map +0 -1
  716. package/dist/transactions/confirmation/pendingWrite.d.ts.map +0 -1
  717. package/dist/transactions/confirmation/pendingWrite.js.map +0 -1
  718. package/dist/transport/commitFrames.d.ts.map +0 -1
  719. package/dist/transport/commitFrames.js.map +0 -1
  720. package/dist/transport/connectionManager.d.ts.map +0 -1
  721. package/dist/transport/connectionManager.js.map +0 -1
  722. package/dist/transport/credentialLifecycle.d.ts.map +0 -1
  723. package/dist/transport/credentialLifecycle.js.map +0 -1
  724. package/dist/transport/heartbeat.d.ts.map +0 -1
  725. package/dist/transport/heartbeat.js.map +0 -1
  726. package/dist/transport/httpClient.d.ts.map +0 -1
  727. package/dist/transport/httpClient.js.map +0 -1
  728. package/dist/transport/httpCommitRequest.d.ts.map +0 -1
  729. package/dist/transport/httpCommitRequest.js.map +0 -1
  730. package/dist/transport/httpFeed.d.ts +0 -4
  731. package/dist/transport/httpFeed.d.ts.map +0 -1
  732. package/dist/transport/httpOptions.js.map +0 -1
  733. package/dist/transport/httpTransport.d.ts.map +0 -1
  734. package/dist/transport/httpTransport.js.map +0 -1
  735. package/dist/transport/httpTransportHelpers.d.ts.map +0 -1
  736. package/dist/transport/httpTransportHelpers.js.map +0 -1
  737. package/dist/transport/networkProbe.d.ts.map +0 -1
  738. package/dist/transport/networkProbe.js.map +0 -1
  739. package/dist/transport/wsFrameHandlers.d.ts.map +0 -1
  740. package/dist/transport/wsFrameHandlers.js.map +0 -1
  741. package/dist/transport/wsTransport.d.ts.map +0 -1
  742. package/dist/transport/wsTransport.js.map +0 -1
  743. package/dist/wire/claimEvent.d.ts.map +0 -1
  744. package/dist/wire/claimEvent.js.map +0 -1
  745. package/dist/wire/claims.d.ts.map +0 -1
  746. package/dist/wire/claims.js.map +0 -1
  747. package/dist/wire/commit.d.ts +0 -2866
  748. package/dist/wire/commit.d.ts.map +0 -1
  749. package/dist/wire/commit.js.map +0 -1
  750. package/dist/wire/delta.d.ts.map +0 -1
  751. package/dist/wire/delta.js.map +0 -1
  752. package/dist/wire/deltaDelivery.d.ts.map +0 -1
  753. package/dist/wire/deltaDelivery.js.map +0 -1
  754. package/dist/wire/feedCursor.d.ts.map +0 -1
  755. package/dist/wire/feedCursor.js.map +0 -1
  756. package/dist/wire/feedEvent.d.ts.map +0 -1
  757. package/dist/wire/feedEvent.js.map +0 -1
  758. package/src/policy/types.ts +0 -300
  759. package/src/schema/coordination.ts +0 -161
  760. package/src/source/drizzle.ts +0 -1
  761. package/src/source/kysely.ts +0 -2
  762. /package/dist/{coordination → claims}/targetConflict.d.ts +0 -0
  763. /package/dist/{coordination → claims}/targetConflict.js +0 -0
  764. /package/dist/{resources → client/resources}/mutationOptions.js +0 -0
  765. /package/dist/{resources → client/resources}/where.d.ts +0 -0
  766. /package/dist/{transactions → commit}/confirmation/httpCommitEnvelope.d.ts +0 -0
  767. /package/dist/{transactions → commit}/confirmation/idempotencyKey.d.ts +0 -0
  768. /package/dist/{transactions → commit}/confirmation/idempotencyKey.js +0 -0
  769. /package/dist/source/{adapter.js → adapters/adapter.js} +0 -0
  770. /package/dist/source/{adapterFactory.d.ts → adapters/adapterFactory.d.ts} +0 -0
  771. /package/dist/source/{adapterProfile.d.ts → adapters/adapterProfile.d.ts} +0 -0
  772. /package/dist/source/{adapterProfile.js → adapters/adapterProfile.js} +0 -0
  773. /package/dist/source/{idempotency.d.ts → adapters/idempotency.d.ts} +0 -0
  774. /package/src/{wire/claimEvent.ts → claims/eventContract.ts} +0 -0
  775. /package/src/{coordination/claimHeartbeatLoop.ts → claims/heartbeat.ts} +0 -0
  776. /package/src/{coordination/claimMeta.ts → claims/meta.ts} +0 -0
  777. /package/src/{coordination → claims}/targetConflict.ts +0 -0
  778. /package/src/{transactions → commit}/confirmation/idempotencyKey.ts +0 -0
  779. /package/src/{wire/feedCursor.ts → observation/cursor.ts} +0 -0
  780. /package/src/{wire/deltaDelivery.ts → observation/deliveryContract.ts} +0 -0
  781. /package/src/source/{adapterProfile.ts → adapters/adapterProfile.ts} +0 -0
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * The observability the confirmation core reports on its own behalf.
3
3
  *
4
- * Coordination outcomes — a claim changing state, a stale-write collision that
5
- * notified instead of aborting — happen with no UI and no local store anywhere,
4
+ * Coordination outcomes — a claim changing state or a rejected write collision
5
+ * — happen with no UI and no local store anywhere,
6
6
  * so the core must be able to report them without depending on the consumer's
7
7
  * full provider (ADR 0016).
8
8
  *
@@ -11,13 +11,13 @@
11
11
  * this interface, so a single implementation still satisfies both.
12
12
  */
13
13
 
14
- import type { ClaimEvent, ConflictEvent } from './coordination/events.js';
14
+ import type { ClaimEvent, ConflictEvent } from './claims/events.js';
15
15
 
16
16
  export interface CoordinationObservability {
17
17
  /** Capture a claim state change (acquired / queued / granted / lost / rejected / expired). */
18
18
  captureClaim(event: ClaimEvent): void;
19
19
 
20
- /** Capture a notify-instead-of-abort stale-write collision. */
20
+ /** Capture a rejected stale-write or foreign-claim collision. */
21
21
  captureConflict(event: ConflictEvent): void;
22
22
  }
23
23
 
@@ -6,7 +6,7 @@
6
6
  * layer, alongside the other protocol shapes in `wire/`.
7
7
  *
8
8
  * The wire delta is a projection of the stored `sync_deltas` row (the
9
- * `syncDeltaRowSchema` in `../log/syncDeltaRow.ts`) and differs from it
9
+ * `syncDeltaRowSchema` in `./persistence/syncDeltaRow.ts`) and differs from it
10
10
  * in three ways: it omits `organizationId` (the tenant-isolation predicate is
11
11
  * never broadcast), it uses the full action vocabulary (see
12
12
  * {@link syncDeltaActionSchema}) rather than plain create, update, and delete, and
@@ -26,7 +26,7 @@
26
26
  */
27
27
 
28
28
  import { z } from 'zod';
29
- import { correlationIdSchema } from './commit.js';
29
+ import { correlationIdSchema } from '../commit/contract.js';
30
30
  import { participantKindSchema } from '../coordination/schema.js';
31
31
  import type { ParticipantKind, ParticipantRef } from '../types/participant.js';
32
32
  import type { AssertExact } from '../types/assertExact.js';
@@ -14,9 +14,9 @@
14
14
  */
15
15
 
16
16
  import { z } from 'zod';
17
- import { logEventSchema, logOpSchema, type LogEvent } from './accountResponses.js';
18
- import { claimEventSchema, type ClaimEvent } from './claimEvent.js';
19
- import { listEnvelopeSchema, type ListEnvelope } from './listEnvelope.js';
17
+ import { logEventSchema, logOpSchema, type LogEvent } from '../wire/accountResponses.js';
18
+ import { claimEventSchema, type ClaimEvent } from '../claims/eventContract.js';
19
+ import { listEnvelopeSchema, type ListEnvelope } from '../wire/listEnvelope.js';
20
20
 
21
21
  /**
22
22
  * One entry, from either source. Discriminated on `object`, so a consumer
@@ -71,4 +71,3 @@ export type LogQuery = z.infer<typeof logQuerySchema>;
71
71
  * What is here is the definition the producer will fill: the union parses
72
72
  * today's pages unchanged, and the cursor already carries the second position.
73
73
  */
74
-
@@ -1,9 +1,9 @@
1
- import { formatFeedCursor, parseFeedCursor } from '../wire/feedCursor.js';
2
- import type { HttpLogsResource } from '../resources/httpResources.js';
1
+ import { formatFeedCursor, parseFeedCursor } from './cursor.js';
2
+ import type { HttpLogsResource } from '../client/resources/httpResources.js';
3
3
  import type {
4
4
  ObserveOptions,
5
5
  ObservedDelta,
6
- } from '../transactionLayer.js';
6
+ } from '../client/contract.js';
7
7
 
8
8
  const DEFAULT_PAGE_SIZE = 100;
9
9
  const DEFAULT_POLL_INTERVAL_MS = 500;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Observation subsystem.
3
+ *
4
+ * Start here and descend through delta contracts, feed contracts, cursor
5
+ * handling, delivery inspection, HTTP polling, and persisted row projection.
6
+ */
7
+ export * from './contract.js';
8
+ export * from './cursor.js';
9
+ export * from './feedContract.js';
10
+ export * from './deliveryContract.js';
11
+ export * from './httpFeed.js';
12
+ export * from './persistence/syncDeltaRow.js';
@@ -16,25 +16,25 @@
16
16
  * incorrectly as a physical-residency guarantee.
17
17
  *
18
18
  * This is the stored shape. The delta broadcast to clients is a narrower projection
19
- * of it — see {@link import('../wire/delta.js').syncDeltaWireCoreSchema} — and
19
+ * of it — see {@link import('../contract.js').syncDeltaWireCoreSchema} — and
20
20
  * the field names here mirror those on that wire delta.
21
21
  */
22
22
 
23
23
  import { z } from 'zod';
24
- import type { ModelResidency } from '../schema/residency.js';
24
+ import type { ModelResidency } from '../../schema/residency.js';
25
25
  import {
26
26
  participantKindSchema,
27
27
  confirmationStateSchema,
28
28
  syncDeltaActionSchema,
29
- } from '../wire/delta.js';
29
+ } from '../contract.js';
30
30
 
31
31
  // ── Enumerations that mirror the corresponding Postgres enum types ────────────
32
32
 
33
33
  // `participant_kind` and `confirmation_state` are shared with the wire delta and
34
- // live at the wire layer (see `../wire/delta.js`); they are re-exported here so
34
+ // live in the observation contract (see `../contract.js`); they are re-exported here so
35
35
  // code that imports them from `schema` keeps resolving.
36
- export { participantKindSchema, confirmationStateSchema } from '../wire/delta.js';
37
- export type { ParticipantKind, ConfirmationState } from '../wire/delta.js';
36
+ export { participantKindSchema, confirmationStateSchema } from '../contract.js';
37
+ export type { ParticipantKind, ConfirmationState } from '../contract.js';
38
38
 
39
39
  /** `backfill_provenance` */
40
40
  export const backfillProvenanceSchema = z.enum(['exact', 'inferred', 'unknown']);
@@ -116,4 +116,3 @@ export const DELTA_PHYSICAL_STORAGE = {
116
116
  core: 'control',
117
117
  attribution: 'control',
118
118
  } as const satisfies Record<string, ModelResidency>;
119
-
package/src/pricing.ts CHANGED
@@ -28,10 +28,9 @@
28
28
  * invoice, because raising one number does not fail anything that pins the
29
29
  * other.
30
30
  *
31
- * Storage is deliberately absent from {@link billableAxisSchema}. It is a real
32
- * recurring cost and it is quoted per tier as a ceiling, but no per-organization
33
- * bytes sampler emits it yet, and pricing a dimension nothing measures would be
34
- * a claim the invoice cannot support. Add the axis when the sampler ships.
31
+ * Audit-log storage is quoted as an included allowance plus Scale overage. It
32
+ * remains separate from the request meter because GiB-months come from a
33
+ * periodic storage sampler rather than an API event.
35
34
  */
36
35
 
37
36
  import { z } from 'zod';
@@ -47,7 +46,7 @@ export type { MeterEvent, PlanTier, RateBracket };
47
46
  * could observe the difference. It is emitted into the generated pricing
48
47
  * documentation so a stale copy is identifiable on sight.
49
48
  */
50
- export const PRICING_VERSION = '2026-07-31';
49
+ export const PRICING_VERSION = '2026-08-28';
51
50
 
52
51
  /**
53
52
  * Resolve a stored plan string (`stripe_subscription.plan`) to a tier.
@@ -66,8 +65,8 @@ export function toPlanTier(plan: string | null | undefined): PlanTier {
66
65
  }
67
66
 
68
67
  /**
69
- * The axes a bill is actually computed from: `ops` is metered, `connections` is
70
- * capped. Storage is quoted but not billed, so it is not here.
68
+ * The request-time axes: `ops` is metered and `connections` is capped. Audit
69
+ * storage is sampled periodically, so it does not map from a request event.
71
70
  */
72
71
  export const billableAxisSchema = z.enum(['ops', 'connections']);
73
72
  export type BillableAxis = z.infer<typeof billableAxisSchema>;
@@ -184,11 +183,12 @@ const rateCardSchema = z
184
183
  * knob; the bracket structure is the contract.
185
184
  */
186
185
  export const OPS_RATE_CARD: readonly RateBracket[] = rateCardSchema.parse([
187
- { throughOps: 50_000_000, usdPerMillionOps: 2.0 },
188
- { throughOps: 500_000_000, usdPerMillionOps: 1.2 },
189
- { throughOps: null, usdPerMillionOps: 0.6 },
186
+ { throughOps: null, usdPerMillionOps: 5 },
190
187
  ]);
191
188
 
189
+ /** Scale audit-log storage above the included allowance, per GiB-month. */
190
+ export const AUDIT_LOG_STORAGE_USD_PER_GIB_MONTH = 1;
191
+
192
192
  /**
193
193
  * A tier. `null` on a floor, a cap, or a quota means negotiated rather than
194
194
  * unlimited, and the runtime treats it as "no typed default, use the operator's
@@ -206,9 +206,9 @@ export const planDefinitionSchema = z.object({
206
206
  */
207
207
  monthlyMinimumUsd: z.number().nonnegative().nullable(),
208
208
  /**
209
- * A hard monthly stop on operations. Set only where the tier is not billed at
210
- * all: Free is capped rather than metered, so exceeding it is refused instead
211
- * of invoiced. `null` on every metered tier.
209
+ * The no-billing monthly stop. On Free this is also the included allowance:
210
+ * organizations without billing enabled stop here, while organizations that
211
+ * enable billing pay only for operations above it. `null` on paid tiers.
212
212
  */
213
213
  hardCapOps: z.number().int().positive().nullable(),
214
214
  /**
@@ -220,7 +220,7 @@ export const planDefinitionSchema = z.object({
220
220
  * are billed rather than stopped.
221
221
  */
222
222
  hardCapOpsPerDay: z.number().int().positive().nullable(),
223
- /** Quoted ceiling on stored data, in GiB. Not billed. `null` is negotiated. */
223
+ /** Included audit-log storage, in GiB. `null` means contract-priced capacity. */
224
224
  storageGib: z.number().positive().nullable(),
225
225
  /** Hard concurrent-connection cap, the real Free to Scale boundary. */
226
226
  maxConcurrentConnections: z.number().int().positive().nullable(),
@@ -240,7 +240,7 @@ export const PLANS = z
240
240
  free: {
241
241
  tier: 'free',
242
242
  label: 'Free',
243
- summary: 'Build against the real engine without a card.',
243
+ summary: 'Free for early-stage teams building against the real engine.',
244
244
  monthlyMinimumUsd: 0,
245
245
  hardCapOps: 100_000,
246
246
  hardCapOpsPerDay: 10_000,
@@ -252,20 +252,20 @@ export const PLANS = z
252
252
  scale: {
253
253
  tier: 'scale',
254
254
  label: 'Scale',
255
- summary: 'Production traffic, metered above a monthly floor.',
256
- monthlyMinimumUsd: 20,
255
+ summary: 'Built for scaling teams with production traffic.',
256
+ monthlyMinimumUsd: 250,
257
257
  hardCapOps: null,
258
258
  hardCapOpsPerDay: null,
259
259
  storageGib: 50,
260
- maxConcurrentConnections: 1_000,
260
+ maxConcurrentConnections: 5_000,
261
261
  contractPriced: false,
262
262
  features: ['auditExport'],
263
263
  },
264
264
  enterprise: {
265
265
  tier: 'enterprise',
266
266
  label: 'Enterprise',
267
- summary: 'Committed volume, private networking, and an uptime guarantee.',
268
- monthlyMinimumUsd: 2_000,
267
+ summary: 'Custom infrastructure, security, and support for critical workloads.',
268
+ monthlyMinimumUsd: 4_000,
269
269
  hardCapOps: null,
270
270
  hardCapOpsPerDay: null,
271
271
  storageGib: null,
@@ -336,8 +336,8 @@ export function opsForUsd(usd: number): number {
336
336
  }
337
337
 
338
338
  /**
339
- * The operations a tier includes, as shown on the pricing page. A capped tier
340
- * shows its cap; a metered tier shows what its floor covers, computed from the
339
+ * The operations a tier includes, as shown on the pricing page. Free shows its
340
+ * pay-as-you-go allowance; a tier with a floor shows what that floor covers, computed from the
341
341
  * floor rather than stored beside it. `null` where the terms are contractual.
342
342
  */
343
343
  export function monthlyOpsAllowance(tier: PlanTier): number | null {
@@ -348,17 +348,38 @@ export function monthlyOpsAllowance(tier: PlanTier): number | null {
348
348
  }
349
349
 
350
350
  /**
351
- * The invoice for a month: the floor, or the metered usage, whichever is
352
- * greater. A capped tier is never billed above its floor because the cap is
353
- * enforced before the usage exists. `null` where the terms are contractual.
351
+ * The invoice for a month. Free subtracts its included operations before
352
+ * applying the rate. Scale charges the floor or metered usage, whichever is
353
+ * greater. `null` where the terms are contractual.
354
354
  */
355
355
  export function monthlyBillUsd(tier: PlanTier, ops: number): number | null {
356
356
  const plan = PLANS[tier];
357
357
  if (plan.contractPriced || plan.monthlyMinimumUsd === null) return null;
358
- if (plan.hardCapOps !== null) return plan.monthlyMinimumUsd;
358
+ if (plan.hardCapOps !== null) {
359
+ return roundUsd(usdForOps(Math.max(0, ops - plan.hardCapOps)));
360
+ }
359
361
  return roundUsd(Math.max(plan.monthlyMinimumUsd, usdForOps(ops)));
360
362
  }
361
363
 
364
+ /**
365
+ * Audit-log storage overage for a month. Free and Scale meter only the GiB
366
+ * above their included amount, and Enterprise is priced in the contract.
367
+ */
368
+ export function auditLogStorageBillUsd(tier: PlanTier, storageGib: number): number | null {
369
+ const plan = PLANS[tier];
370
+ if (plan.contractPriced || plan.storageGib === null) return null;
371
+ if (!Number.isFinite(storageGib)) return 0;
372
+ return roundUsd(Math.max(0, storageGib - plan.storageGib) * AUDIT_LOG_STORAGE_USD_PER_GIB_MONTH);
373
+ }
374
+
375
+ /** The complete published estimate across operation and audit-storage usage. */
376
+ export function monthlyEstimateUsd(tier: PlanTier, ops: number, auditStorageGib: number): number | null {
377
+ const operationsBill = monthlyBillUsd(tier, ops);
378
+ const storageBill = auditLogStorageBillUsd(tier, auditStorageGib);
379
+ if (operationsBill === null || storageBill === null) return null;
380
+ return roundUsd(operationsBill + storageBill);
381
+ }
382
+
362
383
  /**
363
384
  * The daily operations cap for a tier: the typed default the quota gate falls
364
385
  * back to when no `plan_limit` row sets one. `null` means the tier is metered
@@ -376,3 +397,17 @@ export function dailyOpsCapForTier(tier: PlanTier): number | null {
376
397
  export function connectionCapForTier(tier: PlanTier): number | null {
377
398
  return PLANS[tier].maxConcurrentConnections;
378
399
  }
400
+
401
+ /**
402
+ * The first public tier that can reserve the requested connection capacity.
403
+ * A `null` cap is negotiated capacity, not infinity in the runtime; it is the
404
+ * commercial catch-all that sends the buyer into an Enterprise capacity plan.
405
+ */
406
+ export function selectPlanForConnectionCapacity(connections: number): PlanTier {
407
+ const requested = Number.isFinite(connections) ? Math.max(1, Math.ceil(connections)) : 1;
408
+ for (const tier of PLAN_ORDER) {
409
+ const cap = PLANS[tier].maxConcurrentConnections;
410
+ if (cap === null || requested <= cap) return tier;
411
+ }
412
+ return 'enterprise';
413
+ }
package/src/schema/ddl.ts CHANGED
@@ -318,7 +318,9 @@ export function generateProvisionPlan(
318
318
  for (const [fieldName, meta] of Object.entries(model.fields)) {
319
319
  const col = meta.column ?? camelToSnake(fieldName);
320
320
  if (BASE_COLUMNS.has(col) || col === orgCol) continue;
321
- statements.push(`ALTER TABLE ${qt} ADD COLUMN IF NOT EXISTS ${q(col)} ${sqlType(meta.type)};`);
321
+ statements.push(
322
+ `ALTER TABLE ${qt} ADD COLUMN IF NOT EXISTS ${q(col)} ${sqlType(meta.type)}${meta.isOptional ? '' : ' NOT NULL'};`,
323
+ );
322
324
  if (meta.type === 'enum' && meta.enumValues && meta.enumValues.length > 0) {
323
325
  const cname = `${table}_${col}_enum`;
324
326
  const allowed = meta.enumValues.map((v) => `'${v.replace(/'/g, "''")}'`).join(', ');
@@ -0,0 +1,88 @@
1
+ export type BackfillStatus = 'pending' | 'running' | 'paused' | 'succeeded' | 'failed' | 'cancelled';
2
+
3
+ export interface BackfillCheckpoint {
4
+ readonly jobId: string;
5
+ readonly idempotencyKey: string;
6
+ readonly cursor: string | null;
7
+ readonly processed: number;
8
+ readonly batches: number;
9
+ readonly status: BackfillStatus;
10
+ readonly updatedAt: string;
11
+ readonly error?: string;
12
+ }
13
+
14
+ export interface BackfillBatchResult {
15
+ readonly nextCursor: string | null;
16
+ readonly processed: number;
17
+ readonly done: boolean;
18
+ }
19
+
20
+ export interface ResumableBackfillEffects {
21
+ readonly load: (jobId: string) => Promise<BackfillCheckpoint | null>;
22
+ readonly save: (checkpoint: BackfillCheckpoint) => Promise<void>;
23
+ /** Must be idempotent for the job idempotency key and input cursor. */
24
+ readonly runBatch: (input: { jobId: string; idempotencyKey: string; cursor: string | null; limit: number; signal?: AbortSignal }) => Promise<BackfillBatchResult>;
25
+ readonly now?: () => string;
26
+ readonly retry?: (error: unknown, attempt: number) => Promise<void>;
27
+ /** Operational throttle checked before each batch; pause preserves the checkpoint for an exact resume. */
28
+ readonly beforeBatch?: (checkpoint: BackfillCheckpoint) => Promise<'run' | 'pause'>;
29
+ readonly onProgress?: (checkpoint: BackfillCheckpoint) => Promise<void> | void;
30
+ }
31
+
32
+ export interface ResumableBackfillOptions {
33
+ readonly jobId: string;
34
+ readonly idempotencyKey: string;
35
+ readonly batchSize?: number;
36
+ readonly maxBatches?: number;
37
+ readonly maxAttempts?: number;
38
+ readonly signal?: AbortSignal;
39
+ }
40
+
41
+ /** Bounded, resumable runner. A durable effect owns checkpoints; the transform owns idempotency. */
42
+ export async function runResumableBackfill(effects: ResumableBackfillEffects, options: ResumableBackfillOptions): Promise<BackfillCheckpoint> {
43
+ if (!options.jobId || !options.idempotencyKey) throw new Error('backfill jobId and idempotencyKey are required');
44
+ const batchSize = options.batchSize ?? 500;
45
+ const maxBatches = options.maxBatches ?? 100;
46
+ const maxAttempts = options.maxAttempts ?? 3;
47
+ if (batchSize < 1 || maxBatches < 1 || maxAttempts < 1) throw new Error('backfill bounds must be positive');
48
+ const now = effects.now ?? (() => new Date().toISOString());
49
+ let checkpoint = await effects.load(options.jobId) ?? { jobId: options.jobId, idempotencyKey: options.idempotencyKey, cursor: null, processed: 0, batches: 0, status: 'pending' as const, updatedAt: now() };
50
+ if (checkpoint.idempotencyKey !== options.idempotencyKey) throw new Error(`backfill job ${options.jobId} was created with a different idempotency key`);
51
+ if (checkpoint.status === 'succeeded') return checkpoint;
52
+ for (let batch = 0; batch < maxBatches; batch++) {
53
+ if (options.signal?.aborted) {
54
+ checkpoint = { ...checkpoint, status: 'cancelled', updatedAt: now() };
55
+ await effects.save(checkpoint);
56
+ return checkpoint;
57
+ }
58
+ if (await effects.beforeBatch?.(checkpoint) === 'pause') {
59
+ checkpoint = { ...checkpoint, status: 'paused', updatedAt: now() };
60
+ await effects.save(checkpoint);
61
+ await effects.onProgress?.(checkpoint);
62
+ return checkpoint;
63
+ }
64
+ let result: BackfillBatchResult | undefined;
65
+ let lastError: unknown;
66
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
67
+ try {
68
+ result = await effects.runBatch({ jobId: options.jobId, idempotencyKey: options.idempotencyKey, cursor: checkpoint.cursor, limit: batchSize, ...(options.signal ? { signal: options.signal } : {}) });
69
+ break;
70
+ } catch (error) {
71
+ lastError = error;
72
+ if (attempt < maxAttempts) await effects.retry?.(error, attempt);
73
+ }
74
+ }
75
+ if (!result) {
76
+ checkpoint = { ...checkpoint, status: 'failed', updatedAt: now(), error: lastError instanceof Error ? lastError.message : String(lastError) };
77
+ await effects.save(checkpoint);
78
+ await effects.onProgress?.(checkpoint);
79
+ return checkpoint;
80
+ }
81
+ if (!result.done && result.nextCursor === checkpoint.cursor) throw new Error(`backfill job ${options.jobId} did not advance its cursor`);
82
+ checkpoint = { jobId: checkpoint.jobId, idempotencyKey: checkpoint.idempotencyKey, cursor: result.nextCursor, processed: checkpoint.processed + result.processed, batches: checkpoint.batches + 1, status: result.done ? 'succeeded' : 'running', updatedAt: now() };
83
+ await effects.save(checkpoint);
84
+ await effects.onProgress?.(checkpoint);
85
+ if (result.done) return checkpoint;
86
+ }
87
+ return checkpoint;
88
+ }
@@ -0,0 +1,119 @@
1
+ import { z } from 'zod';
2
+ import type { SchemaJSON } from '../serialize.js';
3
+ import type { BackfillValue, RenameHints } from '../diff.js';
4
+ import type { MigrationStep } from '../diff.js';
5
+
6
+ export const deploymentPhaseSchema = z.enum(['intent', 'expand', 'dual_write', 'backfill', 'verify', 'switch', 'contract', 'recover']);
7
+ export type DeploymentPhase = z.infer<typeof deploymentPhaseSchema>;
8
+ export const deploymentOwnerSchema = z.enum(['application', 'application_migration', 'ablo']);
9
+ export type DeploymentOwner = z.infer<typeof deploymentOwnerSchema>;
10
+ export const deploymentSeveritySchema = z.enum(['blocker', 'error', 'warning', 'info']);
11
+ export type DeploymentSeverity = z.infer<typeof deploymentSeveritySchema>;
12
+ export const deploymentCategorySchema = z.enum(['policy_intent', 'physical_contract', 'compatibility', 'data_movement', 'destructive_contract', 'advisory', 'observation']);
13
+ export type DeploymentCategory = z.infer<typeof deploymentCategorySchema>;
14
+ export const deploymentDirectionSchema = z.enum(['source_to_active', 'source_to_database', 'active_to_database', 'client_to_active']);
15
+ export type DeploymentDirection = z.infer<typeof deploymentDirectionSchema>;
16
+
17
+ export const databaseColumnSnapshotSchema = z.object({
18
+ name: z.string(), dataType: z.string(), nullable: z.boolean(), default: z.string().nullable(), primary: z.boolean(), unique: z.boolean(),
19
+ /** Capped count of rows whose required routing value is NULL; absent for ordinary columns. */
20
+ nullCount: z.number().int().nonnegative().nullable().optional(),
21
+ });
22
+ export type DatabaseColumnSnapshot = z.infer<typeof databaseColumnSnapshotSchema>;
23
+ export const databaseIndexSnapshotSchema = z.object({
24
+ name: z.string(), columns: z.array(z.string()), unique: z.boolean(), valid: z.boolean(), ready: z.boolean(), predicate: z.string().nullable(),
25
+ });
26
+ export const databaseForeignKeySnapshotSchema = z.object({
27
+ name: z.string(), columns: z.array(z.string()), referencedSchema: z.string(), referencedTable: z.string(), referencedColumns: z.array(z.string()), validated: z.boolean(),
28
+ });
29
+ export const databaseTableSnapshotSchema = z.object({
30
+ schema: z.string(), name: z.string(), columns: z.record(z.string(), databaseColumnSnapshotSchema),
31
+ indexes: z.array(databaseIndexSnapshotSchema).optional(), foreignKeys: z.array(databaseForeignKeySnapshotSchema).optional(),
32
+ rowLevelSecurity: z.boolean().nullable(), forceRowLevelSecurity: z.boolean().nullable(),
33
+ replicaIdentity: z.string().nullable(), publicationMember: z.boolean().nullable(),
34
+ });
35
+ export type DatabaseTableSnapshot = z.infer<typeof databaseTableSnapshotSchema>;
36
+ export const databaseSnapshotSchema = z.object({
37
+ observedAt: z.string(), subject: z.string(), fingerprint: z.string(), appSchema: z.string(), ownership: z.enum(['application', 'ablo']),
38
+ tables: z.record(z.string(), databaseTableSnapshotSchema),
39
+ });
40
+ export type DatabaseSnapshot = z.infer<typeof databaseSnapshotSchema>;
41
+
42
+ export interface SourceSchemaSnapshot { readonly observedAt: string; readonly path: string; readonly hash: string; readonly schema: SchemaJSON; }
43
+ export interface ActiveSchemaSnapshot { readonly observedAt: string; readonly schemaId: string; readonly version: number; readonly hash: string; readonly pushedAt: string | null; readonly schema: SchemaJSON; }
44
+ export interface DeploymentTarget { readonly organizationId: string | null; readonly projectId: string | null; readonly branchId: string | null; readonly databaseSubject: string | null; readonly confirmed: boolean; }
45
+ export const deploymentGateSchema = z.object({
46
+ id: z.string().min(1),
47
+ phase: z.enum(['expand', 'dual_write', 'backfill', 'verify', 'switch', 'contract']),
48
+ owner: deploymentOwnerSchema,
49
+ resource: z.string().min(1),
50
+ title: z.string().min(1),
51
+ action: z.string().min(1),
52
+ status: z.enum(['pending', 'ready', 'satisfied']),
53
+ dependsOn: z.array(z.string()).default([]),
54
+ approval: z.string().min(1).optional(),
55
+ });
56
+ export const deploymentManifestSchema = z.object({
57
+ id: z.string().min(1),
58
+ live: z.boolean().default(true),
59
+ targetPhase: z.enum(['expand', 'dual_write', 'backfill', 'verify', 'switch', 'contract']).default('expand'),
60
+ gates: z.array(deploymentGateSchema),
61
+ });
62
+ export type DeploymentGate = z.infer<typeof deploymentGateSchema>;
63
+ export type DeploymentManifest = z.infer<typeof deploymentManifestSchema>;
64
+ export interface DeploymentIntent { readonly renames?: RenameHints; readonly backfills?: readonly BackfillValue[]; readonly acceptDestructive?: boolean; readonly manifest?: DeploymentManifest; }
65
+ export interface DeploymentObservation { readonly target: DeploymentTarget; readonly source: SourceSchemaSnapshot; readonly active: ActiveSchemaSnapshot | null; readonly database: DatabaseSnapshot | null; readonly intent?: DeploymentIntent; readonly supplementalFindings?: readonly DeploymentFinding[]; }
66
+
67
+ export interface DeploymentFinding {
68
+ readonly id: string; readonly code: string; readonly category: DeploymentCategory; readonly severity: DeploymentSeverity;
69
+ readonly direction: DeploymentDirection; readonly phase: DeploymentPhase; readonly owner: DeploymentOwner;
70
+ readonly model?: string; readonly field?: string; readonly column?: string; readonly from?: unknown; readonly to?: unknown;
71
+ readonly message: string; readonly action: string;
72
+ readonly dependsOn?: readonly string[];
73
+ }
74
+ export interface DeploymentStep {
75
+ readonly id: string; readonly phase: DeploymentPhase; readonly owner: DeploymentOwner; readonly title: string; readonly action: string;
76
+ readonly dependsOn: readonly string[]; readonly findingIds: readonly string[]; readonly status: 'ready' | 'blocked' | 'advisory'; readonly executableByAblo: boolean;
77
+ }
78
+ export interface SchemaDeploymentPlan {
79
+ readonly id: 'ablo-schema-deployment-plan-v1'; readonly mode: 'plan'; readonly createdAt: string; readonly fingerprint: string; readonly target: DeploymentTarget;
80
+ readonly states: { readonly source: Omit<SourceSchemaSnapshot, 'schema'>; readonly active: Omit<ActiveSchemaSnapshot, 'schema'> | null; readonly database: Omit<DatabaseSnapshot, 'tables'> | null; };
81
+ readonly findings: readonly DeploymentFinding[]; readonly steps: readonly DeploymentStep[]; readonly outcome: 'aligned' | 'ready' | 'blocked';
82
+ readonly operations: { readonly sourceToActive: readonly MigrationStep[]; readonly provision: readonly MigrationStep[] };
83
+ readonly rollbackTarget: { readonly schemaId: string; readonly version: number; readonly hash: string; readonly strategy: 'reactivate_artifact'; } | null;
84
+ readonly recovery: 'rollback' | 'forward_only';
85
+ }
86
+ export interface DeploymentApplyResult { readonly plan: SchemaDeploymentPlan; readonly appliedStepIds: readonly string[]; readonly verification: SchemaDeploymentPlan; readonly recorded: boolean; }
87
+
88
+ export const deploymentTargetSchema = z.object({
89
+ organizationId: z.string().nullable(), projectId: z.string().nullable(), branchId: z.string().nullable(), databaseSubject: z.string().nullable(), confirmed: z.boolean(),
90
+ });
91
+ export const deploymentFindingSchema = z.object({
92
+ id: z.string(), code: z.string(), category: deploymentCategorySchema, severity: deploymentSeveritySchema,
93
+ direction: deploymentDirectionSchema, phase: deploymentPhaseSchema, owner: deploymentOwnerSchema,
94
+ model: z.string().optional(), field: z.string().optional(), column: z.string().optional(), from: z.unknown().optional(), to: z.unknown().optional(),
95
+ message: z.string(), action: z.string(),
96
+ dependsOn: z.array(z.string()).readonly().optional(),
97
+ });
98
+ export const deploymentStepSchema = z.object({
99
+ id: z.string(), phase: deploymentPhaseSchema, owner: deploymentOwnerSchema, title: z.string(), action: z.string(),
100
+ dependsOn: z.array(z.string()).readonly(), findingIds: z.array(z.string()).readonly(), status: z.enum(['ready', 'blocked', 'advisory']), executableByAblo: z.boolean(),
101
+ });
102
+ export const schemaDeploymentPlanSchema = z.object({
103
+ id: z.literal('ablo-schema-deployment-plan-v1'), mode: z.literal('plan'), createdAt: z.string(), fingerprint: z.string(), target: deploymentTargetSchema,
104
+ states: z.object({
105
+ source: z.object({ observedAt: z.string(), path: z.string(), hash: z.string() }),
106
+ active: z.object({ observedAt: z.string(), schemaId: z.string(), version: z.number(), hash: z.string(), pushedAt: z.string().nullable() }).nullable(),
107
+ database: z.object({ observedAt: z.string(), subject: z.string(), fingerprint: z.string(), appSchema: z.string(), ownership: z.enum(['application', 'ablo']) }).nullable(),
108
+ }),
109
+ findings: z.array(deploymentFindingSchema).readonly(), steps: z.array(deploymentStepSchema).readonly(), outcome: z.enum(['aligned', 'ready', 'blocked']),
110
+ // Submitted operations are never executed. Apply re-observes and returns a
111
+ // server-built plan; this field is retained only to validate the full plan
112
+ // envelope and obtain its fingerprint.
113
+ operations: z.object({
114
+ sourceToActive: z.array(z.custom<MigrationStep>()).readonly(),
115
+ provision: z.array(z.custom<MigrationStep>()).readonly(),
116
+ }),
117
+ rollbackTarget: z.object({ schemaId: z.string(), version: z.number(), hash: z.string(), strategy: z.literal('reactivate_artifact') }).nullable(),
118
+ recovery: z.enum(['rollback', 'forward_only']),
119
+ });
@@ -0,0 +1,13 @@
1
+ function canonical(value: unknown): string {
2
+ if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`;
3
+ if (value && typeof value === 'object') return `{${Object.entries(value as Record<string, unknown>).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`).join(',')}}`;
4
+ return JSON.stringify(value);
5
+ }
6
+
7
+ /** Stable non-cryptographic identity used only to detect a changed reviewed plan. */
8
+ export function deploymentFingerprint(value: unknown): string {
9
+ const input = canonical(value);
10
+ let hash = 0xcbf29ce484222325n;
11
+ for (let index = 0; index < input.length; index++) { hash ^= BigInt(input.charCodeAt(index)); hash = BigInt.asUintN(64, hash * 0x100000001b3n); }
12
+ return `plan_${hash.toString(16).padStart(16, '0')}`;
13
+ }
@@ -0,0 +1,81 @@
1
+ import type { DeploymentApplyResult, DeploymentObservation, DeploymentStep, SchemaDeploymentPlan } from './contracts.js';
2
+ import { deploymentFingerprint } from './fingerprint.js';
3
+ import { reconcileDeploymentManifest, reconcilePolicyIntent, reconcileSchemaToDatabase, reconcileSourceToActiveResult } from './reconcile.js';
4
+ import { sequenceDeployment } from './sequence.js';
5
+
6
+ export * from './contracts.js';
7
+ export { deploymentFingerprint } from './fingerprint.js';
8
+ export { reconcileClientToActive, reconcileDeploymentManifest, reconcilePolicyIntent, reconcileSchemaToDatabase, reconcileSourceToActive, reconcileSourceToActiveResult } from './reconcile.js';
9
+ export { sequenceDeployment } from './sequence.js';
10
+ export * from './backfill.js';
11
+ export * from './postgresCatalog.js';
12
+
13
+ function planStates(observation: DeploymentObservation): SchemaDeploymentPlan['states'] {
14
+ const { schema: _sourceSchema, ...source } = observation.source;
15
+ const active = observation.active ? (({ schema: _activeSchema, ...state }) => state)(observation.active) : null;
16
+ const database = observation.database ? (({ tables: _tables, ...state }) => state)(observation.database) : null;
17
+ return { source, active, database };
18
+ }
19
+
20
+ /** The one pure reconciliation skeleton every lifecycle surface projects. */
21
+ export function buildSchemaDeploymentPlan(observation: DeploymentObservation, now = new Date().toISOString()): SchemaDeploymentPlan {
22
+ const sourceToActive = reconcileSourceToActiveResult(
23
+ observation.active?.schema ?? null,
24
+ observation.source.schema,
25
+ observation.intent?.renames,
26
+ observation.intent?.backfills,
27
+ );
28
+ const provision = reconcileSourceToActiveResult(null, observation.source.schema).operations;
29
+ const findings = [
30
+ ...reconcilePolicyIntent(observation.source.schema),
31
+ ...reconcileDeploymentManifest(observation.intent?.manifest),
32
+ ...sourceToActive.findings,
33
+ ...reconcileSchemaToDatabase(observation.source.schema, observation.database, 'source_to_database'),
34
+ ...(observation.active ? reconcileSchemaToDatabase(observation.active.schema, observation.database, 'active_to_database') : []),
35
+ ...(observation.supplementalFindings ?? []),
36
+ ];
37
+ const unique = [...new Map(findings.map((finding) => [finding.id, finding])).values()].map((finding) =>
38
+ observation.intent?.acceptDestructive && finding.category === 'destructive_contract' &&
39
+ finding.code !== 'mixed_expand_contract' && finding.code !== 'contract_approval_required' && finding.code !== 'lifecycle_dependency_unsatisfied'
40
+ ? { ...finding, severity: 'warning' as const, action: `${finding.action} Destructive intent was explicitly accepted for this reviewed plan.` }
41
+ : finding
42
+ );
43
+ const steps = sequenceDeployment(unique);
44
+ const blocking = unique.some(({ severity }) => severity === 'blocker' || severity === 'error');
45
+ const meaningful = unique.some(({ category }) => category !== 'advisory');
46
+ const states = planStates(observation);
47
+ const destructive = unique.some(({ category }) => category === 'destructive_contract');
48
+ const rollbackTarget = observation.active && !destructive ? { schemaId: observation.active.schemaId, version: observation.active.version, hash: observation.active.hash, strategy: 'reactivate_artifact' as const } : null;
49
+ const fingerprint = deploymentFingerprint({
50
+ target: observation.target,
51
+ states: {
52
+ source: { hash: states.source.hash },
53
+ active: states.active ? { schemaId: states.active.schemaId, version: states.active.version, hash: states.active.hash } : null,
54
+ database: states.database ? { subject: states.database.subject, fingerprint: states.database.fingerprint, ownership: states.database.ownership } : null,
55
+ },
56
+ intent: observation.intent ?? {}, findings: unique, steps, operations: { sourceToActive: sourceToActive.operations, provision },
57
+ });
58
+ return { id: 'ablo-schema-deployment-plan-v1', mode: 'plan', createdAt: now, fingerprint, target: observation.target, states, findings: unique, steps, operations: { sourceToActive: sourceToActive.operations, provision }, outcome: blocking ? 'blocked' : meaningful ? 'ready' : 'aligned', rollbackTarget, recovery: rollbackTarget ? 'rollback' : 'forward_only' };
59
+ }
60
+
61
+ export interface SchemaDeploymentLifecycleEffects {
62
+ readonly observe: () => Promise<DeploymentObservation>;
63
+ readonly approve?: (plan: SchemaDeploymentPlan) => Promise<boolean>;
64
+ readonly apply?: (step: DeploymentStep, plan: SchemaDeploymentPlan) => Promise<void>;
65
+ readonly record?: (result: Omit<DeploymentApplyResult, 'recorded'>) => Promise<void>;
66
+ }
67
+
68
+ /** One observe → reconcile → sequence → approve → apply → verify → record path. */
69
+ export async function runSchemaDeploymentLifecycle(effects: SchemaDeploymentLifecycleEffects, mode: 'plan' | 'apply' = 'plan'): Promise<SchemaDeploymentPlan | DeploymentApplyResult> {
70
+ const plan = buildSchemaDeploymentPlan(await effects.observe());
71
+ if (mode === 'plan') return plan;
72
+ if (plan.outcome === 'blocked') throw new Error(`schema deployment plan ${plan.fingerprint} is blocked`);
73
+ if (!effects.apply) throw new Error('schema deployment apply effect is not configured');
74
+ if (effects.approve && !(await effects.approve(plan))) throw new Error('schema deployment was not approved');
75
+ const appliedStepIds: string[] = [];
76
+ for (const step of plan.steps) if (step.executableByAblo && step.status === 'ready') { await effects.apply(step, plan); appliedStepIds.push(step.id); }
77
+ const verification = buildSchemaDeploymentPlan(await effects.observe());
78
+ const unrecorded = { plan, appliedStepIds, verification };
79
+ await effects.record?.(unrecorded);
80
+ return { ...unrecorded, recorded: effects.record !== undefined };
81
+ }