@sentropic/cluster-mesh 0.18.0 → 0.19.1

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 (540) hide show
  1. package/README.md +30 -0
  2. package/assets/storage/comments/oracle/conformance.mjs +1 -0
  3. package/assets/storage/comments/oracle/manifest.json +24 -0
  4. package/assets/storage/comments/oracle/revision-hash-v1.json +1 -0
  5. package/assets/storage/comments/transport-v1.json +1 -0
  6. package/assets/storage/postgres/001-core.sql +51 -0
  7. package/assets/storage/postgres/002-map.sql +83 -0
  8. package/assets/storage/postgres/003-staged.sql +11 -0
  9. package/assets/storage/postgres/004-queries.sql +20 -0
  10. package/assets/storage/postgres/005-cleanup.sql +3 -0
  11. package/assets/storage/postgres/006-staged-coverage.sql +5 -0
  12. package/assets/storage/postgres/comments/001-projections.sql +18 -0
  13. package/assets/storage/postgres/comments/002-transport.sql +13 -0
  14. package/assets/storage/postgres/comments/003-exports.sql +9 -0
  15. package/assets/storage/postgres/comments/004-authority.sql +7 -0
  16. package/assets/storage/postgres/comments/005-lifecycle-evidence.sql +3 -0
  17. package/assets/storage/postgres/comments/006-review-evidence.sql +6 -0
  18. package/assets/storage/postgres/comments/manifest.json +89 -0
  19. package/assets/storage/postgres/manifest.json +81 -0
  20. package/dist/comments/admission.d.ts +11 -0
  21. package/dist/comments/admission.d.ts.map +1 -0
  22. package/dist/comments/admission.js +44 -0
  23. package/dist/comments/admission.js.map +1 -0
  24. package/dist/comments/authority-projection.d.ts +6 -0
  25. package/dist/comments/authority-projection.d.ts.map +1 -0
  26. package/dist/comments/authority-projection.js +80 -0
  27. package/dist/comments/authority-projection.js.map +1 -0
  28. package/dist/comments/authority.d.ts +14 -0
  29. package/dist/comments/authority.d.ts.map +1 -0
  30. package/dist/comments/authority.js +73 -0
  31. package/dist/comments/authority.js.map +1 -0
  32. package/dist/comments/binding-codec.d.ts +6 -0
  33. package/dist/comments/binding-codec.d.ts.map +1 -0
  34. package/dist/comments/binding-codec.js +86 -0
  35. package/dist/comments/binding-codec.js.map +1 -0
  36. package/dist/comments/boundary-codec.d.ts +27 -0
  37. package/dist/comments/boundary-codec.d.ts.map +1 -0
  38. package/dist/comments/boundary-codec.js +56 -0
  39. package/dist/comments/boundary-codec.js.map +1 -0
  40. package/dist/comments/command-contracts.d.ts +22 -0
  41. package/dist/comments/command-contracts.d.ts.map +1 -0
  42. package/dist/comments/command-contracts.js +2 -0
  43. package/dist/comments/command-contracts.js.map +1 -0
  44. package/dist/comments/command-services.d.ts +10 -0
  45. package/dist/comments/command-services.d.ts.map +1 -0
  46. package/dist/comments/command-services.js +21 -0
  47. package/dist/comments/command-services.js.map +1 -0
  48. package/dist/comments/context.d.ts +26 -0
  49. package/dist/comments/context.d.ts.map +1 -0
  50. package/dist/comments/context.js +123 -0
  51. package/dist/comments/context.js.map +1 -0
  52. package/dist/comments/contract.d.ts +2 -0
  53. package/dist/comments/contract.d.ts.map +1 -0
  54. package/dist/comments/contract.js +2 -0
  55. package/dist/comments/contract.js.map +1 -0
  56. package/dist/comments/export-authority.d.ts +5 -0
  57. package/dist/comments/export-authority.d.ts.map +1 -0
  58. package/dist/comments/export-authority.js +17 -0
  59. package/dist/comments/export-authority.js.map +1 -0
  60. package/dist/comments/export-control.d.ts +7 -0
  61. package/dist/comments/export-control.d.ts.map +1 -0
  62. package/dist/comments/export-control.js +58 -0
  63. package/dist/comments/export-control.js.map +1 -0
  64. package/dist/comments/export-pages.d.ts +7 -0
  65. package/dist/comments/export-pages.d.ts.map +1 -0
  66. package/dist/comments/export-pages.js +90 -0
  67. package/dist/comments/export-pages.js.map +1 -0
  68. package/dist/comments/export-prepare.d.ts +5 -0
  69. package/dist/comments/export-prepare.d.ts.map +1 -0
  70. package/dist/comments/export-prepare.js +112 -0
  71. package/dist/comments/export-prepare.js.map +1 -0
  72. package/dist/comments/export-readers.d.ts +18 -0
  73. package/dist/comments/export-readers.d.ts.map +1 -0
  74. package/dist/comments/export-readers.js +91 -0
  75. package/dist/comments/export-readers.js.map +1 -0
  76. package/dist/comments/export-services.d.ts +9 -0
  77. package/dist/comments/export-services.d.ts.map +1 -0
  78. package/dist/comments/export-services.js +30 -0
  79. package/dist/comments/export-services.js.map +1 -0
  80. package/dist/comments/fragment-codec.d.ts +8 -0
  81. package/dist/comments/fragment-codec.d.ts.map +1 -0
  82. package/dist/comments/fragment-codec.js +72 -0
  83. package/dist/comments/fragment-codec.js.map +1 -0
  84. package/dist/comments/http-authority.d.ts +12 -0
  85. package/dist/comments/http-authority.d.ts.map +1 -0
  86. package/dist/comments/http-authority.js +61 -0
  87. package/dist/comments/http-authority.js.map +1 -0
  88. package/dist/comments/http-boundary.d.ts +25 -0
  89. package/dist/comments/http-boundary.d.ts.map +1 -0
  90. package/dist/comments/http-boundary.js +76 -0
  91. package/dist/comments/http-boundary.js.map +1 -0
  92. package/dist/comments/import-authority.d.ts +5 -0
  93. package/dist/comments/import-authority.d.ts.map +1 -0
  94. package/dist/comments/import-authority.js +41 -0
  95. package/dist/comments/import-authority.js.map +1 -0
  96. package/dist/comments/import-control.d.ts +17 -0
  97. package/dist/comments/import-control.d.ts.map +1 -0
  98. package/dist/comments/import-control.js +82 -0
  99. package/dist/comments/import-control.js.map +1 -0
  100. package/dist/comments/import-effects.d.ts +12 -0
  101. package/dist/comments/import-effects.d.ts.map +1 -0
  102. package/dist/comments/import-effects.js +167 -0
  103. package/dist/comments/import-effects.js.map +1 -0
  104. package/dist/comments/import-policy.d.ts +4 -0
  105. package/dist/comments/import-policy.d.ts.map +1 -0
  106. package/dist/comments/import-policy.js +35 -0
  107. package/dist/comments/import-policy.js.map +1 -0
  108. package/dist/comments/import-prepare.d.ts +5 -0
  109. package/dist/comments/import-prepare.d.ts.map +1 -0
  110. package/dist/comments/import-prepare.js +123 -0
  111. package/dist/comments/import-prepare.js.map +1 -0
  112. package/dist/comments/import-projection.d.ts +5 -0
  113. package/dist/comments/import-projection.d.ts.map +1 -0
  114. package/dist/comments/import-projection.js +76 -0
  115. package/dist/comments/import-projection.js.map +1 -0
  116. package/dist/comments/import-recovery.d.ts +22 -0
  117. package/dist/comments/import-recovery.d.ts.map +1 -0
  118. package/dist/comments/import-recovery.js +95 -0
  119. package/dist/comments/import-recovery.js.map +1 -0
  120. package/dist/comments/import-services.d.ts +36 -0
  121. package/dist/comments/import-services.d.ts.map +1 -0
  122. package/dist/comments/import-services.js +38 -0
  123. package/dist/comments/import-services.js.map +1 -0
  124. package/dist/comments/import-state.d.ts +42 -0
  125. package/dist/comments/import-state.d.ts.map +1 -0
  126. package/dist/comments/import-state.js +33 -0
  127. package/dist/comments/import-state.js.map +1 -0
  128. package/dist/comments/index.d.ts +56 -0
  129. package/dist/comments/index.d.ts.map +1 -0
  130. package/dist/comments/index.js +28 -0
  131. package/dist/comments/index.js.map +1 -0
  132. package/dist/comments/installed-store.d.ts +4 -0
  133. package/dist/comments/installed-store.d.ts.map +1 -0
  134. package/dist/comments/installed-store.js +30 -0
  135. package/dist/comments/installed-store.js.map +1 -0
  136. package/dist/comments/lifecycle-contracts.d.ts +27 -0
  137. package/dist/comments/lifecycle-contracts.d.ts.map +1 -0
  138. package/dist/comments/lifecycle-contracts.js +3 -0
  139. package/dist/comments/lifecycle-contracts.js.map +1 -0
  140. package/dist/comments/lifecycle-evidence.d.ts +4 -0
  141. package/dist/comments/lifecycle-evidence.d.ts.map +1 -0
  142. package/dist/comments/lifecycle-evidence.js +31 -0
  143. package/dist/comments/lifecycle-evidence.js.map +1 -0
  144. package/dist/comments/lifecycle-io.d.ts +13 -0
  145. package/dist/comments/lifecycle-io.d.ts.map +1 -0
  146. package/dist/comments/lifecycle-io.js +69 -0
  147. package/dist/comments/lifecycle-io.js.map +1 -0
  148. package/dist/comments/lifecycle.d.ts +4 -0
  149. package/dist/comments/lifecycle.d.ts.map +1 -0
  150. package/dist/comments/lifecycle.js +135 -0
  151. package/dist/comments/lifecycle.js.map +1 -0
  152. package/dist/comments/limits.d.ts +4 -0
  153. package/dist/comments/limits.d.ts.map +1 -0
  154. package/dist/comments/limits.js +14 -0
  155. package/dist/comments/limits.js.map +1 -0
  156. package/dist/comments/postgres-projections.d.ts +5 -0
  157. package/dist/comments/postgres-projections.d.ts.map +1 -0
  158. package/dist/comments/postgres-projections.js +58 -0
  159. package/dist/comments/postgres-projections.js.map +1 -0
  160. package/dist/comments/postgres-queries.d.ts +3 -0
  161. package/dist/comments/postgres-queries.d.ts.map +1 -0
  162. package/dist/comments/postgres-queries.js +75 -0
  163. package/dist/comments/postgres-queries.js.map +1 -0
  164. package/dist/comments/postgres-records.d.ts +6 -0
  165. package/dist/comments/postgres-records.d.ts.map +1 -0
  166. package/dist/comments/postgres-records.js +74 -0
  167. package/dist/comments/postgres-records.js.map +1 -0
  168. package/dist/comments/postgres.d.ts +47 -0
  169. package/dist/comments/postgres.d.ts.map +1 -0
  170. package/dist/comments/postgres.js +142 -0
  171. package/dist/comments/postgres.js.map +1 -0
  172. package/dist/comments/purge.d.ts +5 -0
  173. package/dist/comments/purge.d.ts.map +1 -0
  174. package/dist/comments/purge.js +41 -0
  175. package/dist/comments/purge.js.map +1 -0
  176. package/dist/comments/read-audience.d.ts +3 -0
  177. package/dist/comments/read-audience.d.ts.map +1 -0
  178. package/dist/comments/read-audience.js +7 -0
  179. package/dist/comments/read-audience.js.map +1 -0
  180. package/dist/comments/read-command.d.ts +18 -0
  181. package/dist/comments/read-command.d.ts.map +1 -0
  182. package/dist/comments/read-command.js +65 -0
  183. package/dist/comments/read-command.js.map +1 -0
  184. package/dist/comments/record-effects.d.ts +4 -0
  185. package/dist/comments/record-effects.d.ts.map +1 -0
  186. package/dist/comments/record-effects.js +22 -0
  187. package/dist/comments/record-effects.js.map +1 -0
  188. package/dist/comments/record-validation.d.ts +4 -0
  189. package/dist/comments/record-validation.d.ts.map +1 -0
  190. package/dist/comments/record-validation.js +70 -0
  191. package/dist/comments/record-validation.js.map +1 -0
  192. package/dist/comments/relationships.d.ts +4 -0
  193. package/dist/comments/relationships.d.ts.map +1 -0
  194. package/dist/comments/relationships.js +19 -0
  195. package/dist/comments/relationships.js.map +1 -0
  196. package/dist/comments/review-evidence.d.ts +4 -0
  197. package/dist/comments/review-evidence.d.ts.map +1 -0
  198. package/dist/comments/review-evidence.js +52 -0
  199. package/dist/comments/review-evidence.js.map +1 -0
  200. package/dist/comments/revision-command.d.ts +5 -0
  201. package/dist/comments/revision-command.d.ts.map +1 -0
  202. package/dist/comments/revision-command.js +80 -0
  203. package/dist/comments/revision-command.js.map +1 -0
  204. package/dist/comments/router-binding.d.ts +9 -0
  205. package/dist/comments/router-binding.d.ts.map +1 -0
  206. package/dist/comments/router-binding.js +6 -0
  207. package/dist/comments/router-binding.js.map +1 -0
  208. package/dist/comments/services.d.ts +43 -0
  209. package/dist/comments/services.d.ts.map +1 -0
  210. package/dist/comments/services.js +20 -0
  211. package/dist/comments/services.js.map +1 -0
  212. package/dist/comments/storage-adapter.d.ts +16 -0
  213. package/dist/comments/storage-adapter.d.ts.map +1 -0
  214. package/dist/comments/storage-adapter.js +108 -0
  215. package/dist/comments/storage-adapter.js.map +1 -0
  216. package/dist/comments/storage-contracts.d.ts +57 -0
  217. package/dist/comments/storage-contracts.d.ts.map +1 -0
  218. package/dist/comments/storage-contracts.js +2 -0
  219. package/dist/comments/storage-contracts.js.map +1 -0
  220. package/dist/comments/storage-schema.d.ts +32 -0
  221. package/dist/comments/storage-schema.d.ts.map +1 -0
  222. package/dist/comments/storage-schema.js +70 -0
  223. package/dist/comments/storage-schema.js.map +1 -0
  224. package/dist/comments/store.d.ts +5 -0
  225. package/dist/comments/store.d.ts.map +1 -0
  226. package/dist/comments/store.js +43 -0
  227. package/dist/comments/store.js.map +1 -0
  228. package/dist/comments/transport-contracts.d.ts +110 -0
  229. package/dist/comments/transport-contracts.d.ts.map +1 -0
  230. package/dist/comments/transport-contracts.js +29 -0
  231. package/dist/comments/transport-contracts.js.map +1 -0
  232. package/dist/compose/comments.d.ts +31 -0
  233. package/dist/compose/comments.d.ts.map +1 -0
  234. package/dist/compose/comments.js +48 -0
  235. package/dist/compose/comments.js.map +1 -0
  236. package/dist/hono/comments-router.d.ts +4 -0
  237. package/dist/hono/comments-router.d.ts.map +1 -0
  238. package/dist/hono/comments-router.js +83 -0
  239. package/dist/hono/comments-router.js.map +1 -0
  240. package/dist/integrations/comments/index.d.ts +3 -0
  241. package/dist/integrations/comments/index.d.ts.map +1 -0
  242. package/dist/integrations/comments/index.js +3 -0
  243. package/dist/integrations/comments/index.js.map +1 -0
  244. package/dist/loaders/comments/index.d.ts +5 -0
  245. package/dist/loaders/comments/index.d.ts.map +1 -0
  246. package/dist/loaders/comments/index.js +6 -0
  247. package/dist/loaders/comments/index.js.map +1 -0
  248. package/dist/modules/catalog.d.ts +3 -2
  249. package/dist/modules/catalog.d.ts.map +1 -1
  250. package/dist/modules/catalog.js +6 -3
  251. package/dist/modules/catalog.js.map +1 -1
  252. package/dist/modules/contracts.d.ts +2 -2
  253. package/dist/modules/contracts.d.ts.map +1 -1
  254. package/dist/modules/contracts.js +1 -1
  255. package/dist/modules/contracts.js.map +1 -1
  256. package/dist/storage/atomic.d.ts +108 -0
  257. package/dist/storage/atomic.d.ts.map +1 -0
  258. package/dist/storage/atomic.js +163 -0
  259. package/dist/storage/atomic.js.map +1 -0
  260. package/dist/storage/authority.d.ts +37 -0
  261. package/dist/storage/authority.d.ts.map +1 -0
  262. package/dist/storage/authority.js +88 -0
  263. package/dist/storage/authority.js.map +1 -0
  264. package/dist/storage/backend.d.ts +80 -0
  265. package/dist/storage/backend.d.ts.map +1 -0
  266. package/dist/storage/backend.js +92 -0
  267. package/dist/storage/backend.js.map +1 -0
  268. package/dist/storage/contracts.d.ts +64 -0
  269. package/dist/storage/contracts.d.ts.map +1 -0
  270. package/dist/storage/contracts.js +129 -0
  271. package/dist/storage/contracts.js.map +1 -0
  272. package/dist/storage/descriptor.d.ts +52 -0
  273. package/dist/storage/descriptor.d.ts.map +1 -0
  274. package/dist/storage/descriptor.js +94 -0
  275. package/dist/storage/descriptor.js.map +1 -0
  276. package/dist/storage/errors.d.ts +49 -0
  277. package/dist/storage/errors.d.ts.map +1 -0
  278. package/dist/storage/errors.js +119 -0
  279. package/dist/storage/errors.js.map +1 -0
  280. package/dist/storage/index.d.ts +16 -0
  281. package/dist/storage/index.d.ts.map +1 -0
  282. package/dist/storage/index.js +15 -0
  283. package/dist/storage/index.js.map +1 -0
  284. package/dist/storage/indexed-history.d.ts +15 -0
  285. package/dist/storage/indexed-history.d.ts.map +1 -0
  286. package/dist/storage/indexed-history.js +37 -0
  287. package/dist/storage/indexed-history.js.map +1 -0
  288. package/dist/storage/indexed-map.d.ts +20 -0
  289. package/dist/storage/indexed-map.d.ts.map +1 -0
  290. package/dist/storage/indexed-map.js +50 -0
  291. package/dist/storage/indexed-map.js.map +1 -0
  292. package/dist/storage/indexed-tree.d.ts +16 -0
  293. package/dist/storage/indexed-tree.d.ts.map +1 -0
  294. package/dist/storage/indexed-tree.js +86 -0
  295. package/dist/storage/indexed-tree.js.map +1 -0
  296. package/dist/storage/kernel.d.ts +49 -0
  297. package/dist/storage/kernel.d.ts.map +1 -0
  298. package/dist/storage/kernel.js +104 -0
  299. package/dist/storage/kernel.js.map +1 -0
  300. package/dist/storage/manifest.d.ts +56 -0
  301. package/dist/storage/manifest.d.ts.map +1 -0
  302. package/dist/storage/manifest.js +131 -0
  303. package/dist/storage/manifest.js.map +1 -0
  304. package/dist/storage/mutation-coordinator.d.ts +35 -0
  305. package/dist/storage/mutation-coordinator.d.ts.map +1 -0
  306. package/dist/storage/mutation-coordinator.js +123 -0
  307. package/dist/storage/mutation-coordinator.js.map +1 -0
  308. package/dist/storage/postgres/blobs.d.ts +5 -0
  309. package/dist/storage/postgres/blobs.d.ts.map +1 -0
  310. package/dist/storage/postgres/blobs.js +45 -0
  311. package/dist/storage/postgres/blobs.js.map +1 -0
  312. package/dist/storage/postgres/cleanup.d.ts +17 -0
  313. package/dist/storage/postgres/cleanup.d.ts.map +1 -0
  314. package/dist/storage/postgres/cleanup.js +70 -0
  315. package/dist/storage/postgres/cleanup.js.map +1 -0
  316. package/dist/storage/postgres/codec.d.ts +9 -0
  317. package/dist/storage/postgres/codec.d.ts.map +1 -0
  318. package/dist/storage/postgres/codec.js +34 -0
  319. package/dist/storage/postgres/codec.js.map +1 -0
  320. package/dist/storage/postgres/core.d.ts +53 -0
  321. package/dist/storage/postgres/core.d.ts.map +1 -0
  322. package/dist/storage/postgres/core.js +210 -0
  323. package/dist/storage/postgres/core.js.map +1 -0
  324. package/dist/storage/postgres/coverage.d.ts +4 -0
  325. package/dist/storage/postgres/coverage.d.ts.map +1 -0
  326. package/dist/storage/postgres/coverage.js +28 -0
  327. package/dist/storage/postgres/coverage.js.map +1 -0
  328. package/dist/storage/postgres/digest.d.ts +14 -0
  329. package/dist/storage/postgres/digest.d.ts.map +1 -0
  330. package/dist/storage/postgres/digest.js +67 -0
  331. package/dist/storage/postgres/digest.js.map +1 -0
  332. package/dist/storage/postgres/effects.d.ts +27 -0
  333. package/dist/storage/postgres/effects.d.ts.map +1 -0
  334. package/dist/storage/postgres/effects.js +130 -0
  335. package/dist/storage/postgres/effects.js.map +1 -0
  336. package/dist/storage/postgres/errors.d.ts +16 -0
  337. package/dist/storage/postgres/errors.d.ts.map +1 -0
  338. package/dist/storage/postgres/errors.js +51 -0
  339. package/dist/storage/postgres/errors.js.map +1 -0
  340. package/dist/storage/postgres/hidden-coverage.d.ts +12 -0
  341. package/dist/storage/postgres/hidden-coverage.d.ts.map +1 -0
  342. package/dist/storage/postgres/hidden-coverage.js +43 -0
  343. package/dist/storage/postgres/hidden-coverage.js.map +1 -0
  344. package/dist/storage/postgres/hidden-session.d.ts +6 -0
  345. package/dist/storage/postgres/hidden-session.d.ts.map +1 -0
  346. package/dist/storage/postgres/hidden-session.js +20 -0
  347. package/dist/storage/postgres/hidden-session.js.map +1 -0
  348. package/dist/storage/postgres/index.d.ts +29 -0
  349. package/dist/storage/postgres/index.d.ts.map +1 -0
  350. package/dist/storage/postgres/index.js +40 -0
  351. package/dist/storage/postgres/index.js.map +1 -0
  352. package/dist/storage/postgres/installed-contracts.d.ts +41 -0
  353. package/dist/storage/postgres/installed-contracts.d.ts.map +1 -0
  354. package/dist/storage/postgres/installed-contracts.js +2 -0
  355. package/dist/storage/postgres/installed-contracts.js.map +1 -0
  356. package/dist/storage/postgres/installed.d.ts +9 -0
  357. package/dist/storage/postgres/installed.d.ts.map +1 -0
  358. package/dist/storage/postgres/installed.js +197 -0
  359. package/dist/storage/postgres/installed.js.map +1 -0
  360. package/dist/storage/postgres/journal.d.ts +24 -0
  361. package/dist/storage/postgres/journal.d.ts.map +1 -0
  362. package/dist/storage/postgres/journal.js +237 -0
  363. package/dist/storage/postgres/journal.js.map +1 -0
  364. package/dist/storage/postgres/lifecycle.d.ts +8 -0
  365. package/dist/storage/postgres/lifecycle.d.ts.map +1 -0
  366. package/dist/storage/postgres/lifecycle.js +164 -0
  367. package/dist/storage/postgres/lifecycle.js.map +1 -0
  368. package/dist/storage/postgres/maintenance-readers.d.ts +22 -0
  369. package/dist/storage/postgres/maintenance-readers.d.ts.map +1 -0
  370. package/dist/storage/postgres/maintenance-readers.js +60 -0
  371. package/dist/storage/postgres/maintenance-readers.js.map +1 -0
  372. package/dist/storage/postgres/manifests.d.ts +11 -0
  373. package/dist/storage/postgres/manifests.d.ts.map +1 -0
  374. package/dist/storage/postgres/manifests.js +105 -0
  375. package/dist/storage/postgres/manifests.js.map +1 -0
  376. package/dist/storage/postgres/migrations.d.ts +46 -0
  377. package/dist/storage/postgres/migrations.d.ts.map +1 -0
  378. package/dist/storage/postgres/migrations.js +182 -0
  379. package/dist/storage/postgres/migrations.js.map +1 -0
  380. package/dist/storage/postgres/module-effects.d.ts +7 -0
  381. package/dist/storage/postgres/module-effects.d.ts.map +1 -0
  382. package/dist/storage/postgres/module-effects.js +59 -0
  383. package/dist/storage/postgres/module-effects.js.map +1 -0
  384. package/dist/storage/postgres/ordinary-transactions.d.ts +12 -0
  385. package/dist/storage/postgres/ordinary-transactions.d.ts.map +1 -0
  386. package/dist/storage/postgres/ordinary-transactions.js +168 -0
  387. package/dist/storage/postgres/ordinary-transactions.js.map +1 -0
  388. package/dist/storage/postgres/preparation.d.ts +12 -0
  389. package/dist/storage/postgres/preparation.d.ts.map +1 -0
  390. package/dist/storage/postgres/preparation.js +127 -0
  391. package/dist/storage/postgres/preparation.js.map +1 -0
  392. package/dist/storage/postgres/profiles.d.ts +107 -0
  393. package/dist/storage/postgres/profiles.d.ts.map +1 -0
  394. package/dist/storage/postgres/profiles.js +75 -0
  395. package/dist/storage/postgres/profiles.js.map +1 -0
  396. package/dist/storage/postgres/protocol.d.ts +115 -0
  397. package/dist/storage/postgres/protocol.d.ts.map +1 -0
  398. package/dist/storage/postgres/protocol.js +20 -0
  399. package/dist/storage/postgres/protocol.js.map +1 -0
  400. package/dist/storage/postgres/queries.d.ts +22 -0
  401. package/dist/storage/postgres/queries.d.ts.map +1 -0
  402. package/dist/storage/postgres/queries.js +113 -0
  403. package/dist/storage/postgres/queries.js.map +1 -0
  404. package/dist/storage/postgres/readers.d.ts +43 -0
  405. package/dist/storage/postgres/readers.d.ts.map +1 -0
  406. package/dist/storage/postgres/readers.js +139 -0
  407. package/dist/storage/postgres/readers.js.map +1 -0
  408. package/dist/storage/postgres/recovery.d.ts +15 -0
  409. package/dist/storage/postgres/recovery.d.ts.map +1 -0
  410. package/dist/storage/postgres/recovery.js +71 -0
  411. package/dist/storage/postgres/recovery.js.map +1 -0
  412. package/dist/storage/postgres/registered-effects.d.ts +2 -0
  413. package/dist/storage/postgres/registered-effects.d.ts.map +1 -0
  414. package/dist/storage/postgres/registered-effects.js +2 -0
  415. package/dist/storage/postgres/registered-effects.js.map +1 -0
  416. package/dist/storage/postgres/roots.d.ts +34 -0
  417. package/dist/storage/postgres/roots.d.ts.map +1 -0
  418. package/dist/storage/postgres/roots.js +127 -0
  419. package/dist/storage/postgres/roots.js.map +1 -0
  420. package/dist/storage/postgres/scope.d.ts +136 -0
  421. package/dist/storage/postgres/scope.d.ts.map +1 -0
  422. package/dist/storage/postgres/scope.js +275 -0
  423. package/dist/storage/postgres/scope.js.map +1 -0
  424. package/dist/storage/postgres/seals.d.ts +23 -0
  425. package/dist/storage/postgres/seals.d.ts.map +1 -0
  426. package/dist/storage/postgres/seals.js +149 -0
  427. package/dist/storage/postgres/seals.js.map +1 -0
  428. package/dist/storage/postgres/snapshots.d.ts +13 -0
  429. package/dist/storage/postgres/snapshots.d.ts.map +1 -0
  430. package/dist/storage/postgres/snapshots.js +55 -0
  431. package/dist/storage/postgres/snapshots.js.map +1 -0
  432. package/dist/storage/postgres/staged-module.d.ts +23 -0
  433. package/dist/storage/postgres/staged-module.d.ts.map +1 -0
  434. package/dist/storage/postgres/staged-module.js +38 -0
  435. package/dist/storage/postgres/staged-module.js.map +1 -0
  436. package/dist/storage/postgres/staged.d.ts +15 -0
  437. package/dist/storage/postgres/staged.d.ts.map +1 -0
  438. package/dist/storage/postgres/staged.js +190 -0
  439. package/dist/storage/postgres/staged.js.map +1 -0
  440. package/dist/storage/postgres/transactions.d.ts +9 -0
  441. package/dist/storage/postgres/transactions.d.ts.map +1 -0
  442. package/dist/storage/postgres/transactions.js +86 -0
  443. package/dist/storage/postgres/transactions.js.map +1 -0
  444. package/dist/storage/postgres/units.d.ts +55 -0
  445. package/dist/storage/postgres/units.d.ts.map +1 -0
  446. package/dist/storage/postgres/units.js +57 -0
  447. package/dist/storage/postgres/units.js.map +1 -0
  448. package/dist/storage/profiles.d.ts +24 -0
  449. package/dist/storage/profiles.d.ts.map +1 -0
  450. package/dist/storage/profiles.js +88 -0
  451. package/dist/storage/profiles.js.map +1 -0
  452. package/dist/storage/projection-runtime.d.ts +46 -0
  453. package/dist/storage/projection-runtime.d.ts.map +1 -0
  454. package/dist/storage/projection-runtime.js +105 -0
  455. package/dist/storage/projection-runtime.js.map +1 -0
  456. package/dist/storage/readers.d.ts +47 -0
  457. package/dist/storage/readers.d.ts.map +1 -0
  458. package/dist/storage/readers.js +136 -0
  459. package/dist/storage/readers.js.map +1 -0
  460. package/dist/storage/record-runtime.d.ts +85 -0
  461. package/dist/storage/record-runtime.d.ts.map +1 -0
  462. package/dist/storage/record-runtime.js +387 -0
  463. package/dist/storage/record-runtime.js.map +1 -0
  464. package/dist/storage/root-facade.d.ts +128 -0
  465. package/dist/storage/root-facade.d.ts.map +1 -0
  466. package/dist/storage/root-facade.js +116 -0
  467. package/dist/storage/root-facade.js.map +1 -0
  468. package/dist/storage/root-journal.d.ts +25 -0
  469. package/dist/storage/root-journal.d.ts.map +1 -0
  470. package/dist/storage/root-journal.js +121 -0
  471. package/dist/storage/root-journal.js.map +1 -0
  472. package/dist/storage/root-lifecycle.d.ts +11 -0
  473. package/dist/storage/root-lifecycle.d.ts.map +1 -0
  474. package/dist/storage/root-lifecycle.js +114 -0
  475. package/dist/storage/root-lifecycle.js.map +1 -0
  476. package/dist/storage/root-manifest.d.ts +15 -0
  477. package/dist/storage/root-manifest.d.ts.map +1 -0
  478. package/dist/storage/root-manifest.js +79 -0
  479. package/dist/storage/root-manifest.js.map +1 -0
  480. package/dist/storage/root-profiles.d.ts +104 -0
  481. package/dist/storage/root-profiles.d.ts.map +1 -0
  482. package/dist/storage/root-profiles.js +35 -0
  483. package/dist/storage/root-profiles.js.map +1 -0
  484. package/dist/storage/root-query.d.ts +31 -0
  485. package/dist/storage/root-query.d.ts.map +1 -0
  486. package/dist/storage/root-query.js +70 -0
  487. package/dist/storage/root-query.js.map +1 -0
  488. package/dist/storage/root-snapshot.d.ts +13 -0
  489. package/dist/storage/root-snapshot.d.ts.map +1 -0
  490. package/dist/storage/root-snapshot.js +59 -0
  491. package/dist/storage/root-snapshot.js.map +1 -0
  492. package/dist/storage/scope-runtime.d.ts +155 -0
  493. package/dist/storage/scope-runtime.d.ts.map +1 -0
  494. package/dist/storage/scope-runtime.js +597 -0
  495. package/dist/storage/scope-runtime.js.map +1 -0
  496. package/dist/storage/staged-codec.d.ts +32 -0
  497. package/dist/storage/staged-codec.d.ts.map +1 -0
  498. package/dist/storage/staged-codec.js +86 -0
  499. package/dist/storage/staged-codec.js.map +1 -0
  500. package/dist/storage/staged-core.d.ts +43 -0
  501. package/dist/storage/staged-core.d.ts.map +1 -0
  502. package/dist/storage/staged-core.js +120 -0
  503. package/dist/storage/staged-core.js.map +1 -0
  504. package/dist/storage/staged-effects.d.ts +13 -0
  505. package/dist/storage/staged-effects.d.ts.map +1 -0
  506. package/dist/storage/staged-effects.js +101 -0
  507. package/dist/storage/staged-effects.js.map +1 -0
  508. package/dist/storage/staged-factory.d.ts +22 -0
  509. package/dist/storage/staged-factory.d.ts.map +1 -0
  510. package/dist/storage/staged-factory.js +36 -0
  511. package/dist/storage/staged-factory.js.map +1 -0
  512. package/dist/storage/staged-operations.d.ts +22 -0
  513. package/dist/storage/staged-operations.d.ts.map +1 -0
  514. package/dist/storage/staged-operations.js +125 -0
  515. package/dist/storage/staged-operations.js.map +1 -0
  516. package/dist/storage/staged-preparation.d.ts +19 -0
  517. package/dist/storage/staged-preparation.d.ts.map +1 -0
  518. package/dist/storage/staged-preparation.js +128 -0
  519. package/dist/storage/staged-preparation.js.map +1 -0
  520. package/dist/storage/staged-recovery.d.ts +27 -0
  521. package/dist/storage/staged-recovery.d.ts.map +1 -0
  522. package/dist/storage/staged-recovery.js +49 -0
  523. package/dist/storage/staged-recovery.js.map +1 -0
  524. package/dist/storage/staged-seal.d.ts +37 -0
  525. package/dist/storage/staged-seal.d.ts.map +1 -0
  526. package/dist/storage/staged-seal.js +120 -0
  527. package/dist/storage/staged-seal.js.map +1 -0
  528. package/dist/storage/staged-state.d.ts +156 -0
  529. package/dist/storage/staged-state.d.ts.map +1 -0
  530. package/dist/storage/staged-state.js +43 -0
  531. package/dist/storage/staged-state.js.map +1 -0
  532. package/dist/storage/staged-units.d.ts +95 -0
  533. package/dist/storage/staged-units.d.ts.map +1 -0
  534. package/dist/storage/staged-units.js +129 -0
  535. package/dist/storage/staged-units.js.map +1 -0
  536. package/dist/storage/tokens.d.ts +50 -0
  537. package/dist/storage/tokens.d.ts.map +1 -0
  538. package/dist/storage/tokens.js +135 -0
  539. package/dist/storage/tokens.js.map +1 -0
  540. package/package.json +31 -3
@@ -0,0 +1,156 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ /// <reference types="node" resolution-mode="require"/>
4
+ import type { Hash } from 'node:crypto';
5
+ import type { AtomicUnit, CommitReceipt } from './atomic.js';
6
+ import type { BackendScopeState } from './backend.js';
7
+ import type { StorageScope, WriterFence } from './contracts.js';
8
+ import type { ModuleDescriptor } from './descriptor.js';
9
+ import { IndexedHistory } from './indexed-history.js';
10
+ import { IndexedMap } from './indexed-map.js';
11
+ import { ProjectionRuntime } from './projection-runtime.js';
12
+ import type { FragmentReceipt, StagedBeginInput, StagedCommitRoot, StagedState, StagedUnitHandle, StagedUnitSeal } from './staged-units.js';
13
+ export interface AuthenticatedStagedHandle extends StagedUnitHandle {
14
+ readonly capability: string;
15
+ }
16
+ export interface AuthenticatedStagedSeal extends StagedUnitSeal {
17
+ readonly capability: string;
18
+ }
19
+ export interface RootJournalEvent {
20
+ readonly seq: number;
21
+ readonly eventId: string;
22
+ readonly scope: StorageScope;
23
+ readonly commitId: string;
24
+ readonly rootVersion: string;
25
+ readonly operationKey?: string;
26
+ readonly segment?: {
27
+ readonly operationKey: string;
28
+ readonly from: number;
29
+ readonly to: number;
30
+ };
31
+ }
32
+ export type PurgePolicy = 'unconfigured' | 'optional' | 'required';
33
+ export interface RootPurgeJob {
34
+ readonly target: string;
35
+ readonly intentId: string;
36
+ readonly authorizedBy: string;
37
+ readonly state: 'pending' | 'held' | 'complete' | 'failed';
38
+ readonly outcomeId: string | null;
39
+ readonly payloadDisposition: 'retained' | 'erased' | null;
40
+ }
41
+ export interface RootBlob {
42
+ readonly bytes: string | null;
43
+ readonly owners: IndexedMap<true>;
44
+ }
45
+ export interface RootPurgeEvidence {
46
+ readonly intentId: string;
47
+ readonly outcomeId: string;
48
+ }
49
+ export interface StagedRootData {
50
+ readonly kind: 'staged-root-v1';
51
+ readonly barriers: IndexedMap<{
52
+ readonly reason: string;
53
+ readonly createdAt: string;
54
+ }>;
55
+ readonly coverage: IndexedMap<string>;
56
+ readonly disposed: IndexedMap<true>;
57
+ readonly jobs: IndexedMap<RootPurgeJob>;
58
+ readonly holds: IndexedMap<string>;
59
+ readonly blobs: IndexedMap<RootBlob>;
60
+ readonly journal: IndexedHistory<RootJournalEvent>;
61
+ readonly audit: IndexedHistory<CommitReceipt>;
62
+ readonly outcomes: IndexedHistory<RootPurgeEvidence>;
63
+ readonly notifications: IndexedHistory<RootPurgeEvidence>;
64
+ readonly unitRoots: IndexedMap<StagedCommitRoot>;
65
+ readonly projections: ProjectionRuntime;
66
+ policy: PurgePolicy;
67
+ }
68
+ export declare const createStagedRootData: (descriptor?: ModuleDescriptor) => StagedRootData;
69
+ export declare const forkStagedRootData: (base: StagedRootData) => StagedRootData;
70
+ export declare const lockStagedRootData: (data: StagedRootData) => StagedRootData;
71
+ export declare const coveredBy: (data: StagedRootData, id: string) => string | null;
72
+ export interface OwnedStagedFragment {
73
+ readonly ordinal: string;
74
+ readonly predecessorHash: string | null;
75
+ readonly fragmentDigest: string;
76
+ readonly effects: AtomicUnit;
77
+ readonly dependencyPart: Buffer;
78
+ readonly effectPart: Buffer;
79
+ readonly itemCosts: readonly (readonly number[])[];
80
+ }
81
+ export interface RootSealProgress {
82
+ readonly base: BackendScopeState;
83
+ readonly prepared: BackendScopeState;
84
+ readonly data: StagedRootData;
85
+ readonly root: StagedCommitRoot;
86
+ readonly dependencyHash: Hash;
87
+ readonly effectHash: Hash;
88
+ fragment: number;
89
+ section: number;
90
+ item: number;
91
+ dependencyOffset: number;
92
+ effectOffset: number;
93
+ checked: number;
94
+ bytes: number;
95
+ effectiveRecords: number;
96
+ effectiveAppends: number;
97
+ failed?: string;
98
+ receipt?: CommitReceipt;
99
+ }
100
+ export interface StagedOperation {
101
+ readonly unitId: string;
102
+ capability: string;
103
+ ownerId: string;
104
+ readonly incarnation: string;
105
+ fence: WriterFence;
106
+ readonly begin: StagedBeginInput;
107
+ readonly scope: StorageScope;
108
+ fragments: IndexedHistory<OwnedStagedFragment>;
109
+ readonly commitId: string;
110
+ readonly receipts: IndexedMap<FragmentReceipt>;
111
+ state: StagedState;
112
+ progress: RootSealProgress | null;
113
+ seal: AuthenticatedStagedSeal | null;
114
+ receipt: CommitReceipt | null;
115
+ moduleResult?: AtomicUnit['moduleResult'];
116
+ reason?: string;
117
+ totalEffects: number;
118
+ barrierCount: number;
119
+ purgeCount: number;
120
+ }
121
+ export interface RootConsumer {
122
+ cursor: number;
123
+ status: 'running' | 'stalled' | 'paused';
124
+ failedEvent: string | null;
125
+ failedReason: string | null;
126
+ failedSeq: number | null;
127
+ scanned: number;
128
+ retryAuthorized: boolean;
129
+ deliveredPoison: boolean;
130
+ readonly actions: {
131
+ readonly by: string;
132
+ readonly eventId: string | null;
133
+ readonly at: string;
134
+ }[];
135
+ }
136
+ export interface RootSnapshot {
137
+ readonly root: BackendScopeState;
138
+ readonly journalSeq: number;
139
+ readonly consumer: string;
140
+ readonly ownerId: string;
141
+ consumed: number;
142
+ }
143
+ export interface StagedControl {
144
+ readonly units: Map<string, StagedOperation>;
145
+ readonly byId: Map<string, StagedOperation>;
146
+ readonly consumers: Map<string, RootConsumer>;
147
+ readonly snapshots: Map<string, RootSnapshot>;
148
+ readonly fences: Map<string, {
149
+ readonly value: WriterFence;
150
+ readonly ownerId: string;
151
+ readonly expiresAt: string | null;
152
+ }>;
153
+ readonly journalLanes: Map<string, string>;
154
+ }
155
+ export declare const createStagedControl: () => StagedControl;
156
+ //# sourceMappingURL=staged-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staged-state.d.ts","sourceRoot":"","sources":["../../src/storage/staged-state.ts"],"names":[],"mappings":";;;AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aA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QAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IAC3H,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C;AACD,eAAO,MAAM,mBAAmB,QAAO,aAErC,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { IndexedHistory } from './indexed-history.js';
2
+ import { IndexedMap } from './indexed-map.js';
3
+ import { ProjectionRuntime } from './projection-runtime.js';
4
+ export const createStagedRootData = (descriptor) => {
5
+ const projections = new ProjectionRuntime();
6
+ if (descriptor)
7
+ projections.registerDescriptor(descriptor);
8
+ return {
9
+ kind: 'staged-root-v1',
10
+ barriers: new IndexedMap(), coverage: new IndexedMap(), disposed: new IndexedMap(), jobs: new IndexedMap(),
11
+ holds: new IndexedMap(), blobs: new IndexedMap(), journal: new IndexedHistory(), audit: new IndexedHistory(),
12
+ outcomes: new IndexedHistory(), notifications: new IndexedHistory(), unitRoots: new IndexedMap(), projections, policy: 'optional',
13
+ };
14
+ };
15
+ export const forkStagedRootData = (base) => ({
16
+ kind: 'staged-root-v1',
17
+ barriers: base.barriers.fork(), coverage: base.coverage.fork(), disposed: base.disposed.fork(), jobs: base.jobs.fork(),
18
+ holds: base.holds.fork(), blobs: base.blobs.fork(), journal: base.journal.fork(), audit: base.audit.fork(),
19
+ outcomes: base.outcomes.fork(), notifications: base.notifications.fork(), unitRoots: base.unitRoots.fork(),
20
+ projections: base.projections.fork(), policy: base.policy,
21
+ });
22
+ export const lockStagedRootData = (data) => {
23
+ for (const value of Object.values(data)) {
24
+ if (value instanceof IndexedMap || value instanceof IndexedHistory || value instanceof ProjectionRuntime)
25
+ value.lock();
26
+ }
27
+ return Object.freeze(data);
28
+ };
29
+ export const coveredBy = (data, id) => {
30
+ const seen = new Set();
31
+ let current = id;
32
+ while (current !== undefined && !seen.has(current)) {
33
+ if (data.barriers.has(current) || data.disposed.has(current))
34
+ return current;
35
+ seen.add(current);
36
+ current = data.coverage.get(current);
37
+ }
38
+ return null;
39
+ };
40
+ export const createStagedControl = () => ({
41
+ units: new Map(), byId: new Map(), consumers: new Map(), snapshots: new Map(), fences: new Map(), journalLanes: new Map(),
42
+ });
43
+ //# sourceMappingURL=staged-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staged-state.js","sourceRoot":"","sources":["../../src/storage/staged-state.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AA4B5D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,UAA6B,EAAkB,EAAE;IACpF,MAAM,WAAW,GAAG,IAAI,iBAAiB,EAAE,CAAC;IAC5C,IAAI,UAAU;QAAE,WAAW,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAC3D,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,QAAQ,EAAE,IAAI,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,UAAU,EAAE;QAC1G,KAAK,EAAE,IAAI,UAAU,EAAE,EAAE,KAAK,EAAE,IAAI,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,cAAc,EAAE,EAAE,KAAK,EAAE,IAAI,cAAc,EAAE;QAC5G,QAAQ,EAAE,IAAI,cAAc,EAAE,EAAE,aAAa,EAAE,IAAI,cAAc,EAAE,EAAE,SAAS,EAAE,IAAI,UAAU,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU;KAClI,CAAC;AACJ,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAoB,EAAkB,EAAE,CAAC,CAAC;IAC3E,IAAI,EAAE,gBAAgB;IACtB,QAAQ,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SAAS,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC;YAAE,OAAO,OAAO,CAAC;QAC7E,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAkCF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAkB,EAAE,CAAC,CAAC;IACvD,KAAK,EAAE,IAAI,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,GAAG,EAAE,EAAE,YAAY,EAAE,IAAI,GAAG,EAAE;CAC1H,CAAC,CAAC"}
@@ -0,0 +1,95 @@
1
+ import { validateStorageScope, type StorageModuleId, type StorageScope, type ValidationResult, type WorkLimits, type WriterFence } from './contracts.js';
2
+ import type { AtomicUnit } from './atomic.js';
3
+ export declare const STAGED_STATES: readonly ["staging", "sealing", "sealed", "committed", "aborted"];
4
+ export type StagedState = (typeof STAGED_STATES)[number];
5
+ export declare const STAGED_EVENTS: readonly ["begin-seal", "seal", "commit", "abort"];
6
+ export type StagedEvent = (typeof STAGED_EVENTS)[number];
7
+ export declare const nextStagedState: (current: StagedState, event: StagedEvent) => StagedState | null;
8
+ export interface StagedUnitHandle {
9
+ readonly unitId: string;
10
+ readonly operationKey: string;
11
+ readonly moduleId: StorageModuleId;
12
+ readonly scope: StorageScope;
13
+ readonly state: StagedState;
14
+ }
15
+ export interface StagedBeginInput {
16
+ readonly operationKey: string;
17
+ readonly inputDigest: string;
18
+ readonly contractDigest: string;
19
+ readonly sourceBoundary: string;
20
+ readonly fence: WriterFence;
21
+ }
22
+ export declare const validateBeginInput: (input: StagedBeginInput) => ValidationResult;
23
+ export interface FragmentBinding {
24
+ readonly moduleId: StorageModuleId;
25
+ readonly scope: StorageScope;
26
+ readonly operationId: string;
27
+ readonly contractVersion: string;
28
+ readonly sourceBoundary: string;
29
+ readonly ordinal: string;
30
+ readonly predecessorHash: string | null;
31
+ readonly effectDigest: string;
32
+ }
33
+ export declare const canonicalFragmentEncoding: (binding: FragmentBinding) => string;
34
+ export interface StagedFragmentInput {
35
+ readonly unitId: string;
36
+ readonly ordinal: string;
37
+ readonly predecessorHash: string | null;
38
+ readonly fragmentDigest: string;
39
+ readonly effects: AtomicUnit;
40
+ readonly fence: WriterFence;
41
+ }
42
+ export declare const validateFragmentInput: (input: StagedFragmentInput, limits?: WorkLimits) => ValidationResult;
43
+ export interface AcceptedFragment {
44
+ readonly ordinal: string;
45
+ readonly fragmentDigest: string;
46
+ }
47
+ export declare const validateFragmentSequence: (accepted: readonly AcceptedFragment[], next: {
48
+ readonly ordinal: string;
49
+ readonly predecessorHash: string | null;
50
+ readonly fragmentDigest: string;
51
+ }) => ValidationResult;
52
+ export interface StagedCommitRoot {
53
+ readonly operationId: string;
54
+ readonly contractDigest: string;
55
+ readonly sourceBoundary: string;
56
+ readonly finalFragmentHash: string;
57
+ readonly fragmentCount: string;
58
+ readonly dependencyRoot: string;
59
+ readonly effectRoot: string;
60
+ }
61
+ export declare const validateCommitRoot: (root: StagedCommitRoot) => ValidationResult;
62
+ export interface StagedUnitSeal {
63
+ readonly unitId: string;
64
+ readonly commitRoot: StagedCommitRoot;
65
+ }
66
+ export interface FragmentReceipt {
67
+ readonly unitId: string;
68
+ readonly ordinal: string;
69
+ readonly fragmentDigest: string;
70
+ }
71
+ export type StagedUnitStatus = {
72
+ readonly state: 'staging';
73
+ readonly acceptedFragments: string;
74
+ } | {
75
+ readonly state: 'sealing';
76
+ readonly acceptedFragments: string;
77
+ } | {
78
+ readonly state: 'sealed';
79
+ readonly seal: StagedUnitSeal;
80
+ } | {
81
+ readonly state: 'committed';
82
+ readonly commitId: string;
83
+ } | {
84
+ readonly state: 'aborted';
85
+ readonly reason: string;
86
+ };
87
+ export interface StagedSealInput {
88
+ readonly unitId: string;
89
+ readonly root: StagedCommitRoot;
90
+ readonly limits: WorkLimits;
91
+ readonly fence: WriterFence;
92
+ }
93
+ export declare const validateSealInput: (input: StagedSealInput) => ValidationResult;
94
+ export { validateStorageScope };
95
+ //# sourceMappingURL=staged-units.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staged-units.d.ts","sourceRoot":"","sources":["../../src/storage/staged-units.ts"],"names":[],"mappings":"AAIA,OAAO,EAML,oBAAoB,EAGpB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,eAAO,MAAM,aAAa,mEAAoE,CAAC;AAC/F,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,eAAO,MAAM,aAAa,oDAAqD,CAAC;AAChF,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAUzD,eAAO,MAAM,eAAe,YAAa,WAAW,SAAS,WAAW,KAAG,WAAW,GAAG,IAC7C,CAAC;AAE7C,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAED,MAAM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IAAI,EAAE,cAAc,CAAA;CAAE,GAC3D;IAAE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC1D;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAED,eAAO,MAAM,iBAAiB,UAAW,eAAe,KAAG,gBAU1D,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
@@ -0,0 +1,129 @@
1
+ // K1 staged coherent units and groups (L3a v4.1 frozen §7). Protocol types plus
2
+ // data-pure fragment/state validators. Hidden-state and publication
3
+ // machinery arrive in K4; no backend here.
4
+ import { encodeCompoundKey, errResult, isDecimalCounter, isNonEmptyString, okResult, validateStorageScope, validateWorkLimits, validateWriterFence, } from './contracts.js';
5
+ import { validateAtomicUnit } from './atomic.js';
6
+ export const STAGED_STATES = ['staging', 'sealing', 'sealed', 'committed', 'aborted'];
7
+ export const STAGED_EVENTS = ['begin-seal', 'seal', 'commit', 'abort'];
8
+ const STAGED_TRANSITIONS = {
9
+ staging: { 'begin-seal': 'sealing', abort: 'aborted' },
10
+ sealing: { seal: 'sealed', abort: 'aborted' },
11
+ sealed: { commit: 'committed', abort: 'aborted' },
12
+ committed: {},
13
+ aborted: {},
14
+ };
15
+ export const nextStagedState = (current, event) => STAGED_TRANSITIONS[current][event] ?? null;
16
+ export const validateBeginInput = (input) => {
17
+ const errors = [];
18
+ if (!isNonEmptyString(input.operationKey))
19
+ errors.push('begin requires an operationKey');
20
+ if (!isNonEmptyString(input.inputDigest))
21
+ errors.push('begin requires an inputDigest');
22
+ if (!isNonEmptyString(input.contractDigest))
23
+ errors.push('begin requires a contractDigest');
24
+ if (!isNonEmptyString(input.sourceBoundary))
25
+ errors.push('begin requires a sourceBoundary');
26
+ const fence = validateWriterFence(input.fence);
27
+ if (!fence.ok)
28
+ errors.push(fence.errors.join('; '));
29
+ return errors.length === 0 ? okResult() : errResult(...errors);
30
+ };
31
+ // Canonical fragment binding (§7.3): module + scope + operation/unit/group
32
+ // identity, contract version + source boundary, ordinal + predecessor +
33
+ // canonical effect digest. Domain-separated and explicitly versioned.
34
+ export const canonicalFragmentEncoding = (binding) => encodeCompoundKey([
35
+ 'staged-fragment',
36
+ 'v1',
37
+ binding.moduleId,
38
+ binding.scope.tenantId,
39
+ binding.scope.workspaceId,
40
+ binding.operationId,
41
+ binding.contractVersion,
42
+ binding.sourceBoundary,
43
+ binding.ordinal,
44
+ binding.predecessorHash ?? '',
45
+ binding.effectDigest,
46
+ ]);
47
+ export const validateFragmentInput = (input, limits) => {
48
+ const errors = [];
49
+ if (!isNonEmptyString(input.unitId))
50
+ errors.push('fragment requires a unitId');
51
+ if (!isDecimalCounter(input.ordinal))
52
+ errors.push('fragment requires a decimal ordinal');
53
+ if (input.ordinal !== '0' && !isNonEmptyString(input.predecessorHash)) {
54
+ errors.push('non-first fragments require a predecessorHash');
55
+ }
56
+ if (input.ordinal === '0' && input.predecessorHash !== null) {
57
+ errors.push('the first fragment binds a null predecessor');
58
+ }
59
+ if (!isNonEmptyString(input.fragmentDigest))
60
+ errors.push('fragment requires a fragmentDigest');
61
+ const unit = validateAtomicUnit(input.effects, limits);
62
+ if (!unit.ok)
63
+ errors.push(unit.errors.join('; '));
64
+ const fence = validateWriterFence(input.fence);
65
+ if (!fence.ok)
66
+ errors.push(fence.errors.join('; '));
67
+ return errors.length === 0 ? okResult() : errResult(...errors);
68
+ };
69
+ // Next-ordinal acceptance (§7.3): the next ordinal is accepted, identical
70
+ // retries return the same receipt, gaps and reordering cannot advance.
71
+ export const validateFragmentSequence = (accepted, next) => {
72
+ if (!isDecimalCounter(next.ordinal))
73
+ return errResult('fragment ordinal must be decimal');
74
+ if (accepted.length === 0) {
75
+ if (next.ordinal !== '0')
76
+ return errResult('the first ordinal is zero');
77
+ if (next.predecessorHash !== null)
78
+ return errResult('the first predecessor is null');
79
+ return okResult();
80
+ }
81
+ const last = accepted[accepted.length - 1];
82
+ const expectedOrdinal = String(Number(last.ordinal) + 1);
83
+ if (next.ordinal === last.ordinal) {
84
+ if (next.fragmentDigest === last.fragmentDigest)
85
+ return okResult();
86
+ return errResult('changed bytes at an accepted ordinal conflict');
87
+ }
88
+ if (next.ordinal !== expectedOrdinal)
89
+ return errResult('gaps and reordering cannot advance the frontier');
90
+ if (next.predecessorHash !== last.fragmentDigest)
91
+ return errResult('predecessor must bind the accepted frontier');
92
+ return okResult();
93
+ };
94
+ export const validateCommitRoot = (root) => {
95
+ const errors = [];
96
+ if (!isNonEmptyString(root.operationId))
97
+ errors.push('root requires an operationId');
98
+ if (!isNonEmptyString(root.contractDigest))
99
+ errors.push('root requires a contractDigest');
100
+ if (!isNonEmptyString(root.sourceBoundary))
101
+ errors.push('root requires a sourceBoundary');
102
+ if (!isNonEmptyString(root.finalFragmentHash))
103
+ errors.push('root requires a finalFragmentHash');
104
+ if (!isDecimalCounter(root.fragmentCount) || root.fragmentCount === '0') {
105
+ errors.push('root requires a positive fragmentCount');
106
+ }
107
+ if (!isNonEmptyString(root.dependencyRoot))
108
+ errors.push('root requires a dependencyRoot');
109
+ if (!isNonEmptyString(root.effectRoot))
110
+ errors.push('root requires an effectRoot');
111
+ return errors.length === 0 ? okResult() : errResult(...errors);
112
+ };
113
+ export const validateSealInput = (input) => {
114
+ const errors = [];
115
+ if (!isNonEmptyString(input.unitId))
116
+ errors.push('seal requires a unitId');
117
+ const root = validateCommitRoot(input.root);
118
+ if (!root.ok)
119
+ errors.push(root.errors.join('; '));
120
+ const limits = validateWorkLimits(input.limits);
121
+ if (!limits.ok)
122
+ errors.push(limits.errors.join('; '));
123
+ const fence = validateWriterFence(input.fence);
124
+ if (!fence.ok)
125
+ errors.push(fence.errors.join('; '));
126
+ return errors.length === 0 ? okResult() : errResult(...errors);
127
+ };
128
+ export { validateStorageScope };
129
+ //# sourceMappingURL=staged-units.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staged-units.js","sourceRoot":"","sources":["../../src/storage/staged-units.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,oEAAoE;AACpE,2CAA2C;AAE3C,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,EACR,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GAMpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,CAAU,CAAC;AAG/F,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAU,CAAC;AAGhF,MAAM,kBAAkB,GAA6E;IACnG,OAAO,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;IACtD,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE;IAC7C,MAAM,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE;IACjD,SAAS,EAAE,EAAE;IACb,OAAO,EAAE,EAAE;CACZ,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAoB,EAAE,KAAkB,EAAsB,EAAE,CAC9F,kBAAkB,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;AAkB7C,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAA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C,wBAAwB,CAAC,CAAC;IAC3E,MAAM,IAAI,GAAG,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5C,IAAI,CAAC,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,kBAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAChD,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACtD,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/C,IAAI,CAAC,KAAK,CAAC,EAAE;QAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACpD,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,CAAC;AACjE,CAAC,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { StorageScope } from './contracts.js';
2
+ export interface ChainCursor {
3
+ readonly position: number;
4
+ readonly head: string;
5
+ readonly seq: number;
6
+ readonly allocation: string;
7
+ }
8
+ /** The cursor is well-formed but bound to an incarnation or key this kernel
9
+ * does not hold (§8.2 changed incarnation): the caller gets an explicit
10
+ * unavailable/incomplete result, not an invalid-command refusal. */
11
+ export interface UnknownCursorBoundary {
12
+ readonly unknownBoundary: true;
13
+ }
14
+ export declare const isUnknownCursorBoundary: (value: unknown) => value is UnknownCursorBoundary;
15
+ export type CursorVerification = ChainCursor | UnknownCursorBoundary | null;
16
+ export interface ChainBoundaryRecord {
17
+ readonly moduleId: string;
18
+ readonly scope: StorageScope;
19
+ readonly incarnation: string;
20
+ readonly selection: string;
21
+ readonly position: number;
22
+ readonly head: string;
23
+ readonly seq: number;
24
+ readonly allocation: string;
25
+ }
26
+ export interface ChainBoundaryProvider {
27
+ mint(record: ChainBoundaryRecord): string;
28
+ verify(selection: string, cursor: unknown, opts: {
29
+ readonly moduleId: string;
30
+ readonly scope: StorageScope;
31
+ readonly incarnation: string;
32
+ }): CursorVerification;
33
+ }
34
+ /** G3 designated provider for readChainPage: exact head, sequence and
35
+ * allocation, immutable. */
36
+ export declare class HmacExactHeadBoundaryProvider implements ChainBoundaryProvider {
37
+ private readonly key;
38
+ private readonly keyId;
39
+ constructor(secret?: string);
40
+ private mac;
41
+ mint(record: ChainBoundaryRecord): string;
42
+ verify(selection: string, cursor: unknown, opts: {
43
+ readonly moduleId: string;
44
+ readonly scope: StorageScope;
45
+ readonly incarnation: string;
46
+ }): CursorVerification;
47
+ }
48
+ /** Opaque kernel-issued identities (commit, event, operation). */
49
+ export declare const createOpaqueIssuer: (prefix: string) => (() => string);
50
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/storage/tokens.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;oEAEoE;AACpE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC;CAChC;AAED,eAAO,MAAM,uBAAuB,UAAW,OAAO,mCAGa,CAAC;AAEpE,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG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AAED,kEAAkE;AAClE,eAAO,MAAM,kBAAkB,WAAY,MAAM,KAAG,CAAC,MAAM,MAAM,CAGhE,CAAC"}
@@ -0,0 +1,135 @@
1
+ // K3 chain-boundary tokens and opaque identities (L3a v4.1 frozen §8.2).
2
+ // G3: readChainPage uses the HMAC exact-head boundary provider below.
3
+ // Cursors are self-contained opaque strings: [version, position, head, seq,
4
+ // allocation, incarnation, keyId, mac] base64url-encoded. Position, head,
5
+ // sequence, allocation, incarnation and key id travel in plaintext: the
6
+ // reader needs them to resolve the immutable boundary and to tell an
7
+ // unknown boundary (changed incarnation, retired or default key) apart from
8
+ // a broken seal. Every plaintext field is integrity-protected by the MAC:
9
+ // the seal is verified first, so an altered field breaks the seal
10
+ // (invalid-command) while a valid seal under a foreign incarnation or key
11
+ // reports unknown-boundary (incomplete). Head hashes stay readable in the token;
12
+ // comments retains hashes required by its contract without an anonymity
13
+ // claim (§5.1). Minting and verification are pure: a thousand-page
14
+ // traversal leaves no pins, no registry entries, no leases. Restart
15
+ // stability comes from the secret: two kernels sharing moduleId,
16
+ // incarnation and cursorSecret verify each other's cursors; without a
17
+ // configured secret each kernel mints with a fresh random key, so its
18
+ // cursors read as an unknown boundary after a restart (explicit
19
+ // `incomplete`, never `invalid-command`, never a redirect to the latest
20
+ // head). Tokens stay compact by construction (fixed-size MAC plus the
21
+ // caller-sized head), so the §8.2 oversized server-side recipe is not needed.
22
+ import { createHash, createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
23
+ import { StorageInvalidCommandError } from './errors.js';
24
+ export const isUnknownCursorBoundary = (value) => typeof value === 'object' &&
25
+ value !== null &&
26
+ value.unknownBoundary === true;
27
+ const CURSOR_VERSION = 2;
28
+ const CURSOR_ORDERING = 'seq-asc';
29
+ /** G3 designated provider for readChainPage: exact head, sequence and
30
+ * allocation, immutable. */
31
+ export class HmacExactHeadBoundaryProvider {
32
+ key;
33
+ keyId;
34
+ constructor(secret) {
35
+ if (secret === undefined) {
36
+ this.key = randomBytes(32);
37
+ this.keyId = randomBytes(9).toString('base64url');
38
+ return;
39
+ }
40
+ if (typeof secret !== 'string' || secret.length === 0) {
41
+ throw new StorageInvalidCommandError('cursor secret must be a non-empty string');
42
+ }
43
+ this.key = createHash('sha256').update(secret, 'utf8').digest();
44
+ this.keyId = createHash('sha256').update(`k3-cursor-key-id-v1:${secret}`, 'utf8').digest().subarray(0, 9).toString('base64url');
45
+ }
46
+ mac(moduleId, scope, incarnation, keyId, selection, position, head, seq, allocation) {
47
+ return createHmac('sha256', this.key)
48
+ .update(JSON.stringify([
49
+ 'k3-cursor-v2',
50
+ moduleId,
51
+ scope.tenantId,
52
+ scope.workspaceId,
53
+ incarnation,
54
+ keyId,
55
+ selection,
56
+ head,
57
+ seq,
58
+ allocation,
59
+ CURSOR_ORDERING,
60
+ position,
61
+ ]), 'utf8')
62
+ .digest()
63
+ .subarray(0, 16)
64
+ .toString('base64url');
65
+ }
66
+ mint(record) {
67
+ const tag = this.mac(record.moduleId, record.scope, record.incarnation, this.keyId, record.selection, record.position, record.head, record.seq, record.allocation);
68
+ return Buffer.from(JSON.stringify([
69
+ CURSOR_VERSION,
70
+ record.position,
71
+ record.head,
72
+ record.seq,
73
+ record.allocation,
74
+ record.incarnation,
75
+ this.keyId,
76
+ tag,
77
+ ]), 'utf8').toString('base64url');
78
+ }
79
+ verify(selection, cursor, opts) {
80
+ if (typeof cursor !== 'string' || cursor.length === 0)
81
+ return null;
82
+ let parts;
83
+ try {
84
+ parts = JSON.parse(Buffer.from(cursor, 'base64url').toString('utf8'));
85
+ }
86
+ catch {
87
+ return null;
88
+ }
89
+ if (!Array.isArray(parts) || parts.length !== 8)
90
+ return null;
91
+ const [version, position, head, seq, allocation, incarnation, keyId, tag] = parts;
92
+ if (version !== CURSOR_VERSION)
93
+ return null;
94
+ if (!Number.isSafeInteger(position) || position < 0)
95
+ return null;
96
+ if (typeof head !== 'string' || head.length === 0)
97
+ return null;
98
+ if (!Number.isSafeInteger(seq) || seq < 0)
99
+ return null;
100
+ if (typeof allocation !== 'string' || allocation.length === 0)
101
+ return null;
102
+ if (typeof incarnation !== 'string' || incarnation.length === 0)
103
+ return null;
104
+ if (typeof keyId !== 'string' || keyId.length === 0)
105
+ return null;
106
+ if (typeof tag !== 'string' || tag.length === 0)
107
+ return null;
108
+ // Unknown key first: under a retired or foreign key the seal cannot be
109
+ // checked, so the cursor is an unknown boundary (§8.2), not a break-in.
110
+ if (keyId !== this.keyId)
111
+ return { unknownBoundary: true };
112
+ // Seal first, with the token-carried incarnation: any altered plaintext
113
+ // field breaks the seal (null → invalid-command). Only a valid seal
114
+ // under a foreign incarnation is an unknown boundary.
115
+ const expected = this.mac(opts.moduleId, opts.scope, incarnation, this.keyId, selection, position, head, seq, allocation);
116
+ const actual = Buffer.from(tag, 'utf8');
117
+ const wanted = Buffer.from(expected, 'utf8');
118
+ if (actual.length !== wanted.length || !timingSafeEqual(actual, wanted))
119
+ return null;
120
+ if (incarnation !== opts.incarnation)
121
+ return { unknownBoundary: true };
122
+ return { position: position, head: head, seq: seq, allocation: allocation };
123
+ }
124
+ }
125
+ /** Opaque kernel-issued identities (commit, event, operation). */
126
+ export const createOpaqueIssuer = (prefix) => {
127
+ let seq = 0;
128
+ return () => `${prefix}-${(seq += 1)}`;
129
+ };
130
+ // The provider forges the cursors every handle reads: freezing the shared
131
+ // prototype closes the cross-module channel (O1, same realm limit as
132
+ // Sol-1), so replacing mint or verify throws instead of minting forged
133
+ // cursors inside a handle's scope.
134
+ Object.freeze(HmacExactHeadBoundaryProvider.prototype);
135
+ //# sourceMappingURL=tokens.js.map