@nicia-ai/typegraph 0.49.0 → 0.51.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 (370) hide show
  1. package/README.md +12 -0
  2. package/dist/backend/drizzle/indexes.cjs +11 -9
  3. package/dist/backend/drizzle/indexes.d.cts +1 -1
  4. package/dist/backend/drizzle/indexes.d.ts +1 -1
  5. package/dist/backend/drizzle/indexes.js +7 -5
  6. package/dist/backend/index.cjs +190 -53
  7. package/dist/backend/index.d.cts +90 -4
  8. package/dist/backend/index.d.ts +90 -4
  9. package/dist/backend/index.js +9 -12
  10. package/dist/backend/postgres/index.cjs +36 -28
  11. package/dist/backend/postgres/index.d.cts +7 -7
  12. package/dist/backend/postgres/index.d.ts +7 -7
  13. package/dist/backend/postgres/index.js +19 -15
  14. package/dist/backend/postgres/pglite-store.cjs +7 -62
  15. package/dist/backend/postgres/pglite-store.cjs.map +1 -1
  16. package/dist/backend/postgres/pglite-store.d.cts +8 -8
  17. package/dist/backend/postgres/pglite-store.d.ts +8 -8
  18. package/dist/backend/postgres/pglite-store.js +7 -62
  19. package/dist/backend/postgres/pglite-store.js.map +1 -1
  20. package/dist/backend/postgres/pglite.cjs +21 -17
  21. package/dist/backend/postgres/pglite.d.cts +3 -3
  22. package/dist/backend/postgres/pglite.d.ts +3 -3
  23. package/dist/backend/postgres/pglite.js +20 -16
  24. package/dist/backend/sqlite/index.cjs +33 -25
  25. package/dist/backend/sqlite/index.d.cts +7 -7
  26. package/dist/backend/sqlite/index.d.ts +7 -7
  27. package/dist/backend/sqlite/index.js +17 -13
  28. package/dist/backend/sqlite/libsql.cjs +24 -20
  29. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  30. package/dist/backend/sqlite/libsql.d.cts +3 -3
  31. package/dist/backend/sqlite/libsql.d.ts +3 -3
  32. package/dist/backend/sqlite/libsql.js +19 -15
  33. package/dist/backend/sqlite/libsql.js.map +1 -1
  34. package/dist/backend/sqlite/local-store.cjs +9 -64
  35. package/dist/backend/sqlite/local-store.cjs.map +1 -1
  36. package/dist/backend/sqlite/local-store.d.cts +8 -8
  37. package/dist/backend/sqlite/local-store.d.ts +8 -8
  38. package/dist/backend/sqlite/local-store.js +8 -64
  39. package/dist/backend/sqlite/local-store.js.map +1 -1
  40. package/dist/backend/sqlite/local.cjs +25 -20
  41. package/dist/backend/sqlite/local.d.cts +3 -3
  42. package/dist/backend/sqlite/local.d.ts +3 -3
  43. package/dist/backend/sqlite/local.js +21 -16
  44. package/dist/chunk-2CVDZCXH.cjs +1278 -0
  45. package/dist/chunk-2CVDZCXH.cjs.map +1 -0
  46. package/dist/{chunk-MYKHJI2J.js → chunk-2DWTBNSH.js} +3 -3
  47. package/dist/{chunk-MYKHJI2J.js.map → chunk-2DWTBNSH.js.map} +1 -1
  48. package/dist/{chunk-JB6T4GLL.cjs → chunk-2KCTP3U2.cjs} +870 -528
  49. package/dist/chunk-2KCTP3U2.cjs.map +1 -0
  50. package/dist/{chunk-OORXGFL5.cjs → chunk-322TBTOQ.cjs} +48 -48
  51. package/dist/{chunk-OORXGFL5.cjs.map → chunk-322TBTOQ.cjs.map} +1 -1
  52. package/dist/{chunk-FA2AFWLP.cjs → chunk-36SX6QXP.cjs} +31 -12
  53. package/dist/chunk-36SX6QXP.cjs.map +1 -0
  54. package/dist/{chunk-SDBBMD4N.js → chunk-36VYWVQU.js} +3 -3
  55. package/dist/{chunk-SDBBMD4N.js.map → chunk-36VYWVQU.js.map} +1 -1
  56. package/dist/chunk-4DKY6RIU.js +1253 -0
  57. package/dist/chunk-4DKY6RIU.js.map +1 -0
  58. package/dist/chunk-4QKOZYMV.js +9 -0
  59. package/dist/chunk-4QKOZYMV.js.map +1 -0
  60. package/dist/{chunk-WIC7DRXW.js → chunk-57JM6NW3.js} +9 -19
  61. package/dist/chunk-57JM6NW3.js.map +1 -0
  62. package/dist/chunk-5WWEYV4H.cjs +5113 -0
  63. package/dist/chunk-5WWEYV4H.cjs.map +1 -0
  64. package/dist/chunk-6KQEICJ6.cjs +12 -0
  65. package/dist/{chunk-MKJ4KXL5.cjs.map → chunk-6KQEICJ6.cjs.map} +1 -1
  66. package/dist/{chunk-DZAICA5J.js → chunk-6NKSE5AU.js} +4 -4
  67. package/dist/{chunk-DZAICA5J.js.map → chunk-6NKSE5AU.js.map} +1 -1
  68. package/dist/{chunk-KKBDXCLQ.js → chunk-6NLYIMJO.js} +4 -4
  69. package/dist/{chunk-KKBDXCLQ.js.map → chunk-6NLYIMJO.js.map} +1 -1
  70. package/dist/{chunk-BFUOME67.cjs → chunk-7B7I7YAW.cjs} +20 -11
  71. package/dist/chunk-7B7I7YAW.cjs.map +1 -0
  72. package/dist/{chunk-ZDKTPBGV.js → chunk-7G5IYROL.js} +6 -548
  73. package/dist/chunk-7G5IYROL.js.map +1 -0
  74. package/dist/{chunk-3DMMGT6S.js → chunk-7QFRK6PU.js} +4 -8
  75. package/dist/chunk-7QFRK6PU.js.map +1 -0
  76. package/dist/chunk-A4C4NJ5U.cjs +12 -0
  77. package/dist/chunk-A4C4NJ5U.cjs.map +1 -0
  78. package/dist/{chunk-CHAOFCHV.js → chunk-AH2A74OZ.js} +3 -3
  79. package/dist/{chunk-CHAOFCHV.js.map → chunk-AH2A74OZ.js.map} +1 -1
  80. package/dist/{chunk-UGHQV7MP.cjs → chunk-B3MN7EJR.cjs} +228 -162
  81. package/dist/chunk-B3MN7EJR.cjs.map +1 -0
  82. package/dist/{chunk-TZEGUG6D.cjs → chunk-BZ5MVITP.cjs} +4 -4
  83. package/dist/{chunk-TZEGUG6D.cjs.map → chunk-BZ5MVITP.cjs.map} +1 -1
  84. package/dist/{chunk-YVF2EM7B.js → chunk-CAI6SMP6.js} +3 -3
  85. package/dist/{chunk-YVF2EM7B.js.map → chunk-CAI6SMP6.js.map} +1 -1
  86. package/dist/{chunk-JONXFAPO.js → chunk-CBOD7TXH.js} +5 -5
  87. package/dist/{chunk-JONXFAPO.js.map → chunk-CBOD7TXH.js.map} +1 -1
  88. package/dist/{chunk-FQPEMEWX.cjs → chunk-CRZ56SZU.cjs} +81 -32
  89. package/dist/chunk-CRZ56SZU.cjs.map +1 -0
  90. package/dist/{chunk-DO7SAMEK.cjs → chunk-D3GWARN7.cjs} +47 -47
  91. package/dist/{chunk-DO7SAMEK.cjs.map → chunk-D3GWARN7.cjs.map} +1 -1
  92. package/dist/{chunk-QTD6HX4O.js → chunk-D3OUDFU7.js} +5 -5
  93. package/dist/{chunk-QTD6HX4O.js.map → chunk-D3OUDFU7.js.map} +1 -1
  94. package/dist/{chunk-2QGYQBS2.cjs → chunk-DWUDZ66O.cjs} +10 -10
  95. package/dist/{chunk-2QGYQBS2.cjs.map → chunk-DWUDZ66O.cjs.map} +1 -1
  96. package/dist/chunk-EKG2UXNX.cjs +23 -0
  97. package/dist/chunk-EKG2UXNX.cjs.map +1 -0
  98. package/dist/chunk-FMMW3KX7.cjs +148 -0
  99. package/dist/chunk-FMMW3KX7.cjs.map +1 -0
  100. package/dist/{chunk-XVWOYKIK.js → chunk-FZHF5UWR.js} +3 -3
  101. package/dist/{chunk-XVWOYKIK.js.map → chunk-FZHF5UWR.js.map} +1 -1
  102. package/dist/chunk-H2VWDQWC.cjs +571 -0
  103. package/dist/chunk-H2VWDQWC.cjs.map +1 -0
  104. package/dist/chunk-H4FY6OZK.js +13 -0
  105. package/dist/chunk-H4FY6OZK.js.map +1 -0
  106. package/dist/{chunk-EDN4Y4ZG.cjs → chunk-H5IJSROF.cjs} +9 -15
  107. package/dist/chunk-H5IJSROF.cjs.map +1 -0
  108. package/dist/chunk-HZUB5CON.js +27 -0
  109. package/dist/chunk-HZUB5CON.js.map +1 -0
  110. package/dist/{chunk-NACVVDWB.js → chunk-I5IOSA27.js} +103 -105
  111. package/dist/chunk-I5IOSA27.js.map +1 -0
  112. package/dist/{chunk-OI2GQ25X.cjs → chunk-I7YAY2VQ.cjs} +7 -7
  113. package/dist/{chunk-OI2GQ25X.cjs.map → chunk-I7YAY2VQ.cjs.map} +1 -1
  114. package/dist/chunk-IRCWIA3R.js +20 -0
  115. package/dist/chunk-IRCWIA3R.js.map +1 -0
  116. package/dist/chunk-IVQBLXBK.cjs +55 -0
  117. package/dist/chunk-IVQBLXBK.cjs.map +1 -0
  118. package/dist/{chunk-7SQSZN2J.js → chunk-IZD4HTCP.js} +5 -5
  119. package/dist/{chunk-7SQSZN2J.js.map → chunk-IZD4HTCP.js.map} +1 -1
  120. package/dist/{chunk-3FPR224C.cjs → chunk-JHRUZ73O.cjs} +116 -107
  121. package/dist/chunk-JHRUZ73O.cjs.map +1 -0
  122. package/dist/{chunk-EZEEWCFJ.cjs → chunk-JQKMEKKW.cjs} +525 -298
  123. package/dist/chunk-JQKMEKKW.cjs.map +1 -0
  124. package/dist/chunk-JVA3KDEA.cjs +691 -0
  125. package/dist/chunk-JVA3KDEA.cjs.map +1 -0
  126. package/dist/{chunk-5K2BKEBD.js → chunk-K46SDNQD.js} +10 -4
  127. package/dist/chunk-K46SDNQD.js.map +1 -0
  128. package/dist/{chunk-7LZJNLA5.js → chunk-K67P5DLL.js} +108 -42
  129. package/dist/chunk-K67P5DLL.js.map +1 -0
  130. package/dist/{chunk-3G5W2U2L.cjs → chunk-KACEYDYV.cjs} +335 -258
  131. package/dist/chunk-KACEYDYV.cjs.map +1 -0
  132. package/dist/{chunk-JFRT7S3B.cjs → chunk-L6EVYIID.cjs} +318 -478
  133. package/dist/chunk-L6EVYIID.cjs.map +1 -0
  134. package/dist/{chunk-SHFBB23Q.js → chunk-LI4K2KEJ.js} +6 -4
  135. package/dist/chunk-LI4K2KEJ.js.map +1 -0
  136. package/dist/chunk-LKZDQ2B4.js +1581 -0
  137. package/dist/chunk-LKZDQ2B4.js.map +1 -0
  138. package/dist/{chunk-WODMN3Q2.cjs → chunk-LLFPQOBA.cjs} +27 -27
  139. package/dist/{chunk-WODMN3Q2.cjs.map → chunk-LLFPQOBA.cjs.map} +1 -1
  140. package/dist/{chunk-P6YLZTRE.js → chunk-LZMQ3SFK.js} +3 -3
  141. package/dist/{chunk-P6YLZTRE.js.map → chunk-LZMQ3SFK.js.map} +1 -1
  142. package/dist/{chunk-HEV35TGT.js → chunk-M3VTS3F6.js} +13 -4
  143. package/dist/chunk-M3VTS3F6.js.map +1 -0
  144. package/dist/{chunk-TQHGE7UC.cjs → chunk-M5MSP3BI.cjs} +18 -10
  145. package/dist/chunk-M5MSP3BI.cjs.map +1 -0
  146. package/dist/{chunk-D4QLTJSM.js → chunk-NBOS7BY3.js} +63 -23
  147. package/dist/chunk-NBOS7BY3.js.map +1 -0
  148. package/dist/chunk-NGQDGL5X.js +140 -0
  149. package/dist/chunk-NGQDGL5X.js.map +1 -0
  150. package/dist/{chunk-SIT26LAZ.cjs → chunk-NLX5OWK7.cjs} +33 -5
  151. package/dist/chunk-NLX5OWK7.cjs.map +1 -0
  152. package/dist/chunk-NUQ2YFFH.cjs +1637 -0
  153. package/dist/chunk-NUQ2YFFH.cjs.map +1 -0
  154. package/dist/{chunk-UMGZDVOA.cjs → chunk-OGL4X4PH.cjs} +206 -208
  155. package/dist/chunk-OGL4X4PH.cjs.map +1 -0
  156. package/dist/{chunk-LRQKXRXO.cjs → chunk-OTNTGEXR.cjs} +4 -4
  157. package/dist/{chunk-LRQKXRXO.cjs.map → chunk-OTNTGEXR.cjs.map} +1 -1
  158. package/dist/chunk-OTWE63BW.js +53 -0
  159. package/dist/chunk-OTWE63BW.js.map +1 -0
  160. package/dist/chunk-PC5NGH5A.js +549 -0
  161. package/dist/chunk-PC5NGH5A.js.map +1 -0
  162. package/dist/{chunk-26YKDNUD.cjs → chunk-PS3TUWJM.cjs} +12 -10
  163. package/dist/chunk-PS3TUWJM.cjs.map +1 -0
  164. package/dist/{chunk-OMZ37BM2.js → chunk-PVFFH7TL.js} +5 -5
  165. package/dist/{chunk-OMZ37BM2.js.map → chunk-PVFFH7TL.js.map} +1 -1
  166. package/dist/chunk-QCD5JKU4.cjs +15 -0
  167. package/dist/chunk-QCD5JKU4.cjs.map +1 -0
  168. package/dist/{chunk-UGHG7PGX.js → chunk-QG5VEOKX.js} +30 -4
  169. package/dist/chunk-QG5VEOKX.js.map +1 -0
  170. package/dist/{chunk-TUNPBZY3.cjs → chunk-QLLZM5I3.cjs} +4 -4
  171. package/dist/{chunk-TUNPBZY3.cjs.map → chunk-QLLZM5I3.cjs.map} +1 -1
  172. package/dist/{chunk-BRRP76WO.js → chunk-RCBG6YMT.js} +781 -375
  173. package/dist/chunk-RCBG6YMT.js.map +1 -0
  174. package/dist/{chunk-LTXQOEIC.js → chunk-RI7RJH4G.js} +281 -204
  175. package/dist/chunk-RI7RJH4G.js.map +1 -0
  176. package/dist/{chunk-GYEG3ZLZ.cjs → chunk-RJMHU2MG.cjs} +121 -18
  177. package/dist/chunk-RJMHU2MG.cjs.map +1 -0
  178. package/dist/{chunk-GLHXM7C4.js → chunk-RVUL2HXY.js} +61 -23
  179. package/dist/chunk-RVUL2HXY.js.map +1 -0
  180. package/dist/chunk-RWUWTJQY.cjs +30 -0
  181. package/dist/chunk-RWUWTJQY.cjs.map +1 -0
  182. package/dist/{chunk-2O4PCIZ6.cjs → chunk-S5GU4LUN.cjs} +13 -13
  183. package/dist/{chunk-2O4PCIZ6.cjs.map → chunk-S5GU4LUN.cjs.map} +1 -1
  184. package/dist/{chunk-JPD2CTC3.js → chunk-SDPWO2Z5.js} +7 -7
  185. package/dist/{chunk-JPD2CTC3.js.map → chunk-SDPWO2Z5.js.map} +1 -1
  186. package/dist/{chunk-OVI7IXYX.js → chunk-SLGGT2XD.js} +3 -3
  187. package/dist/{chunk-OVI7IXYX.js.map → chunk-SLGGT2XD.js.map} +1 -1
  188. package/dist/{chunk-ROR5ZR6A.cjs → chunk-TIJUA4I6.cjs} +45 -45
  189. package/dist/{chunk-ROR5ZR6A.cjs.map → chunk-TIJUA4I6.cjs.map} +1 -1
  190. package/dist/{chunk-AOSSQDVO.cjs → chunk-TM54OBHX.cjs} +13 -13
  191. package/dist/{chunk-AOSSQDVO.cjs.map → chunk-TM54OBHX.cjs.map} +1 -1
  192. package/dist/{chunk-KF6K7TGH.js → chunk-TYEYRCXL.js} +766 -433
  193. package/dist/chunk-TYEYRCXL.js.map +1 -0
  194. package/dist/{chunk-Z2JCLZFJ.js → chunk-UKOVGCRN.js} +2151 -570
  195. package/dist/chunk-UKOVGCRN.js.map +1 -0
  196. package/dist/chunk-UYKDYE5D.cjs +12 -0
  197. package/dist/{chunk-CICO5GXD.cjs.map → chunk-UYKDYE5D.cjs.map} +1 -1
  198. package/dist/{chunk-S5TERQVW.js → chunk-VAAC7L57.js} +284 -66
  199. package/dist/chunk-VAAC7L57.js.map +1 -0
  200. package/dist/{chunk-7UOLHNWC.cjs → chunk-VKHXYVN7.cjs} +22 -33
  201. package/dist/chunk-VKHXYVN7.cjs.map +1 -0
  202. package/dist/{chunk-6NGW27EO.cjs → chunk-VLBTRXA2.cjs} +10 -10
  203. package/dist/{chunk-6NGW27EO.cjs.map → chunk-VLBTRXA2.cjs.map} +1 -1
  204. package/dist/{chunk-YIURNGXI.js → chunk-VUQZNUHU.js} +22 -6
  205. package/dist/chunk-VUQZNUHU.js.map +1 -0
  206. package/dist/{chunk-YYUHLYM2.cjs → chunk-WDM5WQK4.cjs} +183 -143
  207. package/dist/chunk-WDM5WQK4.cjs.map +1 -0
  208. package/dist/{chunk-ZFMCDJGB.js → chunk-WFSYYU4W.js} +70 -220
  209. package/dist/chunk-WFSYYU4W.js.map +1 -0
  210. package/dist/{chunk-SR725PWF.cjs → chunk-WRBV2FNH.cjs} +2065 -1659
  211. package/dist/chunk-WRBV2FNH.cjs.map +1 -0
  212. package/dist/{chunk-MRDBBHIZ.cjs → chunk-X4GDXBOP.cjs} +2 -2
  213. package/dist/chunk-X4GDXBOP.cjs.map +1 -0
  214. package/dist/chunk-XORONCV3.js +202 -0
  215. package/dist/chunk-XORONCV3.js.map +1 -0
  216. package/dist/{chunk-D5R42W5D.js → chunk-XZW2CTNO.js} +115 -12
  217. package/dist/chunk-XZW2CTNO.js.map +1 -0
  218. package/dist/{chunk-ZLONH2UD.js → chunk-YDEJQWOL.js} +2 -2
  219. package/dist/chunk-YDEJQWOL.js.map +1 -0
  220. package/dist/{chunk-2TYSSBU5.js → chunk-YT2IVFAI.js} +30 -21
  221. package/dist/chunk-YT2IVFAI.js.map +1 -0
  222. package/dist/chunk-ZGVTNKTX.cjs +217 -0
  223. package/dist/chunk-ZGVTNKTX.cjs.map +1 -0
  224. package/dist/core/index.cjs +29 -28
  225. package/dist/core/index.d.cts +4 -4
  226. package/dist/core/index.d.ts +4 -4
  227. package/dist/core/index.js +9 -8
  228. package/dist/{ddl-D_oW-EVO.d.ts → ddl-BvcbgzHo.d.ts} +3 -3
  229. package/dist/{ddl-BL1NZLMY.d.cts → ddl-Ufebz5q5.d.cts} +3 -3
  230. package/dist/graph-extension/index.cjs +21 -20
  231. package/dist/graph-extension/index.d.cts +2 -4
  232. package/dist/graph-extension/index.d.ts +2 -4
  233. package/dist/graph-extension/index.js +5 -4
  234. package/dist/graph-merge/index.cjs +324 -307
  235. package/dist/graph-merge/index.cjs.map +1 -1
  236. package/dist/graph-merge/index.d.cts +8 -9
  237. package/dist/graph-merge/index.d.ts +8 -9
  238. package/dist/graph-merge/index.js +51 -34
  239. package/dist/graph-merge/index.js.map +1 -1
  240. package/dist/index.cjs +224 -222
  241. package/dist/index.cjs.map +1 -1
  242. package/dist/index.d.cts +11 -12
  243. package/dist/index.d.ts +11 -12
  244. package/dist/index.js +38 -36
  245. package/dist/index.js.map +1 -1
  246. package/dist/indexes/index.cjs +15 -13
  247. package/dist/indexes/index.d.cts +4 -4
  248. package/dist/indexes/index.d.ts +4 -4
  249. package/dist/indexes/index.js +8 -6
  250. package/dist/{ingestion-import-target-dNeL7iAv.d.ts → ingestion-import-target-CAs1OX-l.d.cts} +1 -1
  251. package/dist/{ingestion-import-target-XPxZYw89.d.cts → ingestion-import-target-DCQSPfNx.d.ts} +1 -1
  252. package/dist/interchange/index.cjs +57 -54
  253. package/dist/interchange/index.cjs.map +1 -1
  254. package/dist/interchange/index.d.cts +19 -8
  255. package/dist/interchange/index.d.ts +19 -8
  256. package/dist/interchange/index.js +21 -18
  257. package/dist/interchange/index.js.map +1 -1
  258. package/dist/local-store-impl-6DDTFM32.cjs +77 -0
  259. package/dist/local-store-impl-6DDTFM32.cjs.map +1 -0
  260. package/dist/local-store-impl-OXTOVU2J.js +75 -0
  261. package/dist/local-store-impl-OXTOVU2J.js.map +1 -0
  262. package/dist/{manager-CYaff3n3.d.cts → manager-B68OrPR2.d.ts} +29 -2
  263. package/dist/{manager-D9eRT_ns.d.ts → manager-D_t7oK69.d.cts} +29 -2
  264. package/dist/pglite-store-impl-6EMZGL7K.js +73 -0
  265. package/dist/pglite-store-impl-6EMZGL7K.js.map +1 -0
  266. package/dist/pglite-store-impl-GJG3Y7RP.cjs +75 -0
  267. package/dist/pglite-store-impl-GJG3Y7RP.cjs.map +1 -0
  268. package/dist/{postgres-CcL4bAHS.d.ts → postgres-BPLSVyHM.d.ts} +279 -2
  269. package/dist/{postgres-DMj39MEu.d.cts → postgres-CqvtFC2y.d.cts} +279 -2
  270. package/dist/profiler/index.d.cts +9 -9
  271. package/dist/profiler/index.d.ts +9 -9
  272. package/dist/provenance/index.cjs +59 -44
  273. package/dist/provenance/index.cjs.map +1 -1
  274. package/dist/provenance/index.d.cts +7 -7
  275. package/dist/provenance/index.d.ts +7 -7
  276. package/dist/provenance/index.js +28 -13
  277. package/dist/provenance/index.js.map +1 -1
  278. package/dist/{repair-validity-windows-BFNZvd_H.d.cts → repair-validity-windows-DEzCKAdy.d.cts} +7 -3
  279. package/dist/{repair-validity-windows-DlUSqwCg.d.ts → repair-validity-windows-GMdaS2AH.d.ts} +7 -3
  280. package/dist/resolve-D_H8MHtq.d.ts +1805 -0
  281. package/dist/resolve-WEW8gWws.d.cts +1805 -0
  282. package/dist/schema/index.cjs +48 -46
  283. package/dist/schema/index.d.cts +4 -6
  284. package/dist/schema/index.d.ts +4 -6
  285. package/dist/schema/index.js +21 -19
  286. package/dist/{searchable-bpE1bBfc.d.ts → searchable-C_UREI9K.d.ts} +1 -1
  287. package/dist/{searchable-DHJMh_nj.d.cts → searchable-ClgET_i7.d.cts} +1 -1
  288. package/dist/{sqlite-YppHrNFb.d.cts → sqlite-D1mXO9Kp.d.cts} +310 -2
  289. package/dist/{sqlite-D7Oz0SQh.d.ts → sqlite-MZA3oZNB.d.ts} +310 -2
  290. package/dist/{store-bphCSo7z.d.cts → store-CuFX7fCx.d.cts} +117 -31
  291. package/dist/{store-DRrFCx5x.d.ts → store-D-ZjXQpW.d.ts} +117 -31
  292. package/dist/{temporal-CbnLzTmM.d.ts → temporal-CpyEiRY8.d.cts} +1 -1
  293. package/dist/{temporal-5GqpYCk2.d.cts → temporal-y0Aep9Su.d.ts} +1 -1
  294. package/dist/{types-BqFZTQmV.d.cts → types-6yf0Vv-_.d.cts} +2016 -94
  295. package/dist/{types-BqFZTQmV.d.ts → types-6yf0Vv-_.d.ts} +2016 -94
  296. package/dist/{types-Bx74kaTt.d.ts → types-DzJ4dlzk.d.cts} +1 -1
  297. package/dist/{types-CXAhpW-c.d.cts → types-_vVSB9k-.d.ts} +1 -1
  298. package/dist/{where-O-k2wgYm.d.ts → where-DuG2LCLe.d.ts} +1 -1
  299. package/dist/{where-DI_Fqz-X.d.cts → where-Mhf_yyKX.d.cts} +1 -1
  300. package/package.json +7 -2
  301. package/dist/chunk-26YKDNUD.cjs.map +0 -1
  302. package/dist/chunk-2TYSSBU5.js.map +0 -1
  303. package/dist/chunk-3DMMGT6S.js.map +0 -1
  304. package/dist/chunk-3FPR224C.cjs.map +0 -1
  305. package/dist/chunk-3G5W2U2L.cjs.map +0 -1
  306. package/dist/chunk-3KOY4FH3.cjs +0 -934
  307. package/dist/chunk-3KOY4FH3.cjs.map +0 -1
  308. package/dist/chunk-3QNZ5SAJ.cjs +0 -3502
  309. package/dist/chunk-3QNZ5SAJ.cjs.map +0 -1
  310. package/dist/chunk-3U5ABFDW.cjs +0 -259
  311. package/dist/chunk-3U5ABFDW.cjs.map +0 -1
  312. package/dist/chunk-5K2BKEBD.js.map +0 -1
  313. package/dist/chunk-5PRKMB24.cjs +0 -124
  314. package/dist/chunk-5PRKMB24.cjs.map +0 -1
  315. package/dist/chunk-6LN7FIVU.js +0 -107
  316. package/dist/chunk-6LN7FIVU.js.map +0 -1
  317. package/dist/chunk-6SWPJEYN.js +0 -1126
  318. package/dist/chunk-6SWPJEYN.js.map +0 -1
  319. package/dist/chunk-7LZJNLA5.js.map +0 -1
  320. package/dist/chunk-7UOLHNWC.cjs.map +0 -1
  321. package/dist/chunk-BFUOME67.cjs.map +0 -1
  322. package/dist/chunk-BRRP76WO.js.map +0 -1
  323. package/dist/chunk-CICO5GXD.cjs +0 -12
  324. package/dist/chunk-D4QLTJSM.js.map +0 -1
  325. package/dist/chunk-D5R42W5D.js.map +0 -1
  326. package/dist/chunk-EDN4Y4ZG.cjs.map +0 -1
  327. package/dist/chunk-EZEEWCFJ.cjs.map +0 -1
  328. package/dist/chunk-FA2AFWLP.cjs.map +0 -1
  329. package/dist/chunk-FQPEMEWX.cjs.map +0 -1
  330. package/dist/chunk-GLHXM7C4.js.map +0 -1
  331. package/dist/chunk-GYEG3ZLZ.cjs.map +0 -1
  332. package/dist/chunk-HDL2ARHX.cjs +0 -1156
  333. package/dist/chunk-HDL2ARHX.cjs.map +0 -1
  334. package/dist/chunk-HEV35TGT.js.map +0 -1
  335. package/dist/chunk-I4GAZH5Z.js +0 -913
  336. package/dist/chunk-I4GAZH5Z.js.map +0 -1
  337. package/dist/chunk-JB6T4GLL.cjs.map +0 -1
  338. package/dist/chunk-JBQQ7THH.js +0 -20
  339. package/dist/chunk-JBQQ7THH.js.map +0 -1
  340. package/dist/chunk-JFRT7S3B.cjs.map +0 -1
  341. package/dist/chunk-KF6K7TGH.js.map +0 -1
  342. package/dist/chunk-L3LQNR34.cjs +0 -1254
  343. package/dist/chunk-L3LQNR34.cjs.map +0 -1
  344. package/dist/chunk-LTXQOEIC.js.map +0 -1
  345. package/dist/chunk-MKJ4KXL5.cjs +0 -12
  346. package/dist/chunk-MRDBBHIZ.cjs.map +0 -1
  347. package/dist/chunk-NACVVDWB.js.map +0 -1
  348. package/dist/chunk-NVY5CJFP.js +0 -244
  349. package/dist/chunk-NVY5CJFP.js.map +0 -1
  350. package/dist/chunk-PWLJ77UV.cjs +0 -23
  351. package/dist/chunk-PWLJ77UV.cjs.map +0 -1
  352. package/dist/chunk-S5TERQVW.js.map +0 -1
  353. package/dist/chunk-SHFBB23Q.js.map +0 -1
  354. package/dist/chunk-SIT26LAZ.cjs.map +0 -1
  355. package/dist/chunk-SR725PWF.cjs.map +0 -1
  356. package/dist/chunk-TQHGE7UC.cjs.map +0 -1
  357. package/dist/chunk-UGHG7PGX.js.map +0 -1
  358. package/dist/chunk-UGHQV7MP.cjs.map +0 -1
  359. package/dist/chunk-UMGZDVOA.cjs.map +0 -1
  360. package/dist/chunk-WIC7DRXW.js.map +0 -1
  361. package/dist/chunk-YIURNGXI.js.map +0 -1
  362. package/dist/chunk-YYUHLYM2.cjs.map +0 -1
  363. package/dist/chunk-Z2JCLZFJ.js.map +0 -1
  364. package/dist/chunk-ZDKTPBGV.js.map +0 -1
  365. package/dist/chunk-ZFMCDJGB.js.map +0 -1
  366. package/dist/chunk-ZLONH2UD.js.map +0 -1
  367. package/dist/index-COs_z6nV.d.cts +0 -1132
  368. package/dist/index-D7d1u2gr.d.ts +0 -1132
  369. package/dist/materialize-indexes-DJ3ykH59.d.ts +0 -266
  370. package/dist/materialize-indexes-DTtAnvfY.d.cts +0 -266
@@ -1,19 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var chunk3KOY4FH3_cjs = require('./chunk-3KOY4FH3.cjs');
4
- var chunkJFRT7S3B_cjs = require('./chunk-JFRT7S3B.cjs');
5
- var chunkEZEEWCFJ_cjs = require('./chunk-EZEEWCFJ.cjs');
6
- var chunkPWLJ77UV_cjs = require('./chunk-PWLJ77UV.cjs');
7
- var chunkSIT26LAZ_cjs = require('./chunk-SIT26LAZ.cjs');
8
- var chunk3U5ABFDW_cjs = require('./chunk-3U5ABFDW.cjs');
9
- var chunk5PRKMB24_cjs = require('./chunk-5PRKMB24.cjs');
10
- var chunkFQPEMEWX_cjs = require('./chunk-FQPEMEWX.cjs');
11
- var chunkTQHGE7UC_cjs = require('./chunk-TQHGE7UC.cjs');
12
- var chunkL3LQNR34_cjs = require('./chunk-L3LQNR34.cjs');
13
- var chunkEDN4Y4ZG_cjs = require('./chunk-EDN4Y4ZG.cjs');
3
+ var chunk2CVDZCXH_cjs = require('./chunk-2CVDZCXH.cjs');
4
+ var chunkFMMW3KX7_cjs = require('./chunk-FMMW3KX7.cjs');
5
+ var chunkL6EVYIID_cjs = require('./chunk-L6EVYIID.cjs');
6
+ var chunkJQKMEKKW_cjs = require('./chunk-JQKMEKKW.cjs');
7
+ var chunkNLX5OWK7_cjs = require('./chunk-NLX5OWK7.cjs');
8
+ var chunkZGVTNKTX_cjs = require('./chunk-ZGVTNKTX.cjs');
9
+ var chunkNUQ2YFFH_cjs = require('./chunk-NUQ2YFFH.cjs');
10
+ var chunkCRZ56SZU_cjs = require('./chunk-CRZ56SZU.cjs');
11
+ var chunkM5MSP3BI_cjs = require('./chunk-M5MSP3BI.cjs');
12
+ var chunkJVA3KDEA_cjs = require('./chunk-JVA3KDEA.cjs');
13
+ var chunkH5IJSROF_cjs = require('./chunk-H5IJSROF.cjs');
14
14
  var chunkHAHNRASW_cjs = require('./chunk-HAHNRASW.cjs');
15
- var chunk6NGW27EO_cjs = require('./chunk-6NGW27EO.cjs');
16
- var chunkMRDBBHIZ_cjs = require('./chunk-MRDBBHIZ.cjs');
15
+ var chunkVLBTRXA2_cjs = require('./chunk-VLBTRXA2.cjs');
16
+ var chunkX4GDXBOP_cjs = require('./chunk-X4GDXBOP.cjs');
17
17
  var chunkA7J2YDDI_cjs = require('./chunk-A7J2YDDI.cjs');
18
18
  var chunkN66HCGCY_cjs = require('./chunk-N66HCGCY.cjs');
19
19
 
@@ -22,8 +22,8 @@ function nullToUndefined(value) {
22
22
  return value === null ? void 0 : value;
23
23
  }
24
24
  function rowToNode(row) {
25
- const rawProps = chunk5PRKMB24_cjs.rowPropsToObject(row.props);
26
- const props = chunk6NGW27EO_cjs.filterReservedKeys(rawProps, chunk6NGW27EO_cjs.RESERVED_NODE_KEYS);
25
+ const rawProps = chunkNUQ2YFFH_cjs.rowPropsToObject(row.props);
26
+ const props = chunkVLBTRXA2_cjs.filterReservedKeys(rawProps, chunkVLBTRXA2_cjs.RESERVED_NODE_KEYS);
27
27
  return {
28
28
  kind: row.kind,
29
29
  id: row.id,
@@ -42,8 +42,8 @@ function rowToNodeMeta(row) {
42
42
  };
43
43
  }
44
44
  function rowToEdge(row) {
45
- const rawProps = chunk5PRKMB24_cjs.rowPropsToObject(row.props);
46
- const props = chunk6NGW27EO_cjs.filterReservedKeys(rawProps, chunk6NGW27EO_cjs.RESERVED_EDGE_KEYS);
45
+ const rawProps = chunkNUQ2YFFH_cjs.rowPropsToObject(row.props);
46
+ const props = chunkVLBTRXA2_cjs.filterReservedKeys(rawProps, chunkVLBTRXA2_cjs.RESERVED_EDGE_KEYS);
47
47
  return {
48
48
  id: row.id,
49
49
  kind: row.kind,
@@ -70,96 +70,496 @@ function edgeWriteNeedsConstraintFence(cardinality) {
70
70
  return cardinality === "many" ? void 0 : "edgeCardinality";
71
71
  }
72
72
  function nodeWriteNeedsConstraintFence(registry, kind, uniqueConstraints, operation) {
73
- if (operation === "create" && registry.getDisjointKinds(kind).length > 0) {
74
- return "nodeDisjointness";
73
+ return chunk2CVDZCXH_cjs.nodeClaimSites(registry, kind, uniqueConstraints, operation).find(
74
+ (site) => site.needsLockFence
75
+ )?.refusalReason;
76
+ }
77
+ function graphOwesClaims(graph, registry) {
78
+ for (const [kind, registration] of Object.entries(graph.nodes)) {
79
+ for (const operation of ["create", "update"]) {
80
+ const gating = chunk2CVDZCXH_cjs.nodeClaimSites(
81
+ registry,
82
+ kind,
83
+ registration.unique ?? [],
84
+ operation
85
+ ).find((site) => site.placement === "pre-insert");
86
+ if (gating !== void 0) return gating.refusalReason;
87
+ }
75
88
  }
76
- const sharedScope = uniqueConstraints.some(
77
- (constraint) => chunkFQPEMEWX_cjs.getKindsForUniquenessCheck(kind, constraint.scope, registry).length > 1
78
- );
79
- return sharedScope ? "nodeUniquenessScope" : void 0;
89
+ for (const registration of Object.values(graph.edges)) {
90
+ const reason = edgeWriteNeedsConstraintFence(
91
+ registration.cardinality ?? "many"
92
+ );
93
+ if (reason !== void 0) return reason;
94
+ }
95
+ return void 0;
80
96
  }
81
97
  async function checkDisjointnessConstraint(ctx, kind, id) {
82
98
  const disjointKinds = ctx.registry.getDisjointKinds(kind);
83
99
  for (const disjointKind of disjointKinds) {
84
100
  const existing = await ctx.backend.getNode(ctx.graphId, disjointKind, id);
85
101
  if (existing && !existing.deleted_at) {
86
- const error = chunkFQPEMEWX_cjs.checkDisjointness(id, kind, [disjointKind], ctx.registry);
102
+ const error = chunkCRZ56SZU_cjs.checkDisjointness(id, kind, [disjointKind], ctx.registry);
87
103
  if (error) throw error;
88
104
  }
89
105
  }
90
106
  }
91
107
  async function checkCardinalityConstraint(ctx, edgeKind, cardinality, fromKind, fromId, toKind, toId, validTo) {
92
- switch (cardinality) {
93
- case "many": {
108
+ if (cardinality === "many") return;
109
+ const spec = chunkFMMW3KX7_cjs.EDGE_CARDINALITY_SPECS[cardinality];
110
+ if (!spec.claimsWhenBornEnded && validTo !== void 0) return;
111
+ if (spec.keyShape === "fromAndTo") {
112
+ const exists = await ctx.backend.edgeExistsBetween({
113
+ graphId: ctx.graphId,
114
+ edgeKind,
115
+ fromKind,
116
+ fromId,
117
+ toKind,
118
+ toId
119
+ });
120
+ const error2 = chunkCRZ56SZU_cjs.checkUniqueEdge(
121
+ edgeKind,
122
+ fromKind,
123
+ fromId,
124
+ toKind,
125
+ toId,
126
+ exists ? 1 : 0
127
+ );
128
+ if (error2) throw error2;
129
+ return;
130
+ }
131
+ const count = await ctx.backend.countEdgesFrom({
132
+ graphId: ctx.graphId,
133
+ edgeKind,
134
+ fromKind,
135
+ fromId,
136
+ activeOnly: spec.holderLiveness === "liveAndActive"
137
+ });
138
+ const error = chunkCRZ56SZU_cjs.checkCardinality(
139
+ edgeKind,
140
+ fromKind,
141
+ fromId,
142
+ cardinality,
143
+ count,
144
+ count > 0
145
+ );
146
+ if (error) throw error;
147
+ }
148
+
149
+ // src/store/operations/edge-batch-validation.ts
150
+ function buildEdgeEndpointCacheKey(graphId, kind, id) {
151
+ return chunkCRZ56SZU_cjs.encodeTupleKey([graphId, kind, id]);
152
+ }
153
+ function buildEdgeFromCacheKey(graphId, edgeKind, fromKind, fromId) {
154
+ return chunkCRZ56SZU_cjs.encodeTupleKey([graphId, edgeKind, fromKind, fromId]);
155
+ }
156
+ function buildEdgeBetweenCacheKey(graphId, edgeKind, fromKind, fromId, toKind, toId) {
157
+ return chunkCRZ56SZU_cjs.encodeTupleKey([graphId, edgeKind, fromKind, fromId, toKind, toId]);
158
+ }
159
+ function buildCountEdgesFromCacheKey(params) {
160
+ const activeOnly = params.activeOnly === true ? "1" : "0";
161
+ return chunkCRZ56SZU_cjs.encodeTupleKey([
162
+ params.graphId,
163
+ params.edgeKind,
164
+ params.fromKind,
165
+ params.fromId,
166
+ activeOnly
167
+ ]);
168
+ }
169
+ function incrementPendingCount(counts, key) {
170
+ const previous = counts.get(key) ?? 0;
171
+ counts.set(key, previous + 1);
172
+ }
173
+ function createEdgeBatchValidationBackend(backend) {
174
+ const endpointCache = /* @__PURE__ */ new Map();
175
+ const countEdgesFromCache = /* @__PURE__ */ new Map();
176
+ const edgeExistsCache = /* @__PURE__ */ new Map();
177
+ const pendingOneCounts = /* @__PURE__ */ new Map();
178
+ const pendingOneActiveCounts = /* @__PURE__ */ new Map();
179
+ const pendingUniquePairs = /* @__PURE__ */ new Set();
180
+ async function getNodeCached(graphId, kind, id) {
181
+ const cacheKey = buildEdgeEndpointCacheKey(graphId, kind, id);
182
+ if (endpointCache.has(cacheKey)) {
183
+ return endpointCache.get(cacheKey);
184
+ }
185
+ const node = await backend.getNode(graphId, kind, id);
186
+ endpointCache.set(cacheKey, node);
187
+ return node;
188
+ }
189
+ function seedEndpointRow(graphId, kind, id, row) {
190
+ const cacheKey = buildEdgeEndpointCacheKey(graphId, kind, id);
191
+ if (endpointCache.has(cacheKey)) return;
192
+ endpointCache.set(cacheKey, row);
193
+ }
194
+ async function countEdgesFromCached(params) {
195
+ const cacheKey = buildCountEdgesFromCacheKey(params);
196
+ let baseCount = countEdgesFromCache.get(cacheKey);
197
+ if (baseCount === void 0) {
198
+ baseCount = await backend.countEdgesFrom(params);
199
+ countEdgesFromCache.set(cacheKey, baseCount);
200
+ }
201
+ const pendingKey = buildEdgeFromCacheKey(
202
+ params.graphId,
203
+ params.edgeKind,
204
+ params.fromKind,
205
+ params.fromId
206
+ );
207
+ const pendingCount = params.activeOnly === true ? pendingOneActiveCounts.get(pendingKey) ?? 0 : pendingOneCounts.get(pendingKey) ?? 0;
208
+ return baseCount + pendingCount;
209
+ }
210
+ async function edgeExistsBetweenCached(params) {
211
+ const cacheKey = buildEdgeBetweenCacheKey(
212
+ params.graphId,
213
+ params.edgeKind,
214
+ params.fromKind,
215
+ params.fromId,
216
+ params.toKind,
217
+ params.toId
218
+ );
219
+ if (pendingUniquePairs.has(cacheKey)) {
220
+ return true;
221
+ }
222
+ if (edgeExistsCache.has(cacheKey)) {
223
+ return edgeExistsCache.get(cacheKey) ?? false;
224
+ }
225
+ const exists = await backend.edgeExistsBetween(params);
226
+ edgeExistsCache.set(cacheKey, exists);
227
+ return exists;
228
+ }
229
+ function registerPendingEdgeForCardinality(insertParams, cardinality) {
230
+ const fromCacheKey = buildEdgeFromCacheKey(
231
+ insertParams.graphId,
232
+ insertParams.kind,
233
+ insertParams.fromKind,
234
+ insertParams.fromId
235
+ );
236
+ if (cardinality === "one") {
237
+ incrementPendingCount(pendingOneCounts, fromCacheKey);
94
238
  return;
95
239
  }
96
- case "one": {
97
- const count = await ctx.backend.countEdgesFrom({
98
- graphId: ctx.graphId,
99
- edgeKind,
100
- fromKind,
101
- fromId
102
- });
103
- const error = chunkFQPEMEWX_cjs.checkCardinality(
104
- edgeKind,
105
- fromKind,
106
- fromId,
107
- "one",
108
- count,
109
- false
110
- );
111
- if (error) throw error;
240
+ if (cardinality === "oneActive") {
241
+ if (insertParams.validTo === void 0) {
242
+ incrementPendingCount(pendingOneActiveCounts, fromCacheKey);
243
+ }
112
244
  return;
113
245
  }
114
- case "unique": {
115
- const exists = await ctx.backend.edgeExistsBetween({
116
- graphId: ctx.graphId,
117
- edgeKind,
118
- fromKind,
119
- fromId,
120
- toKind,
121
- toId
122
- });
123
- const error = chunkFQPEMEWX_cjs.checkUniqueEdge(
124
- edgeKind,
125
- fromKind,
126
- fromId,
127
- toKind,
128
- toId,
129
- exists ? 1 : 0
246
+ if (cardinality === "unique") {
247
+ const uniqueCacheKey = buildEdgeBetweenCacheKey(
248
+ insertParams.graphId,
249
+ insertParams.kind,
250
+ insertParams.fromKind,
251
+ insertParams.fromId,
252
+ insertParams.toKind,
253
+ insertParams.toId
130
254
  );
131
- if (error) throw error;
132
- return;
255
+ pendingUniquePairs.add(uniqueCacheKey);
133
256
  }
134
- case "oneActive": {
135
- if (validTo !== void 0) {
136
- return;
257
+ }
258
+ const validationBackend = chunkNLX5OWK7_cjs.deriveBackend(backend, {
259
+ getNode: getNodeCached,
260
+ countEdgesFrom: countEdgesFromCached,
261
+ edgeExistsBetween: edgeExistsBetweenCached
262
+ });
263
+ return {
264
+ backend: validationBackend,
265
+ registerPendingEdgeForCardinality,
266
+ seedEndpointRow
267
+ };
268
+ }
269
+
270
+ // src/store/operations/edge-write-pipeline.ts
271
+ function createEdgeWriteContext(graphId, lock, claimsVerdict) {
272
+ return { graphId, lock, claimsVerdict };
273
+ }
274
+ async function applyEdgeUpdate(ctx, args, backend) {
275
+ const { claim, ...rowWork } = args;
276
+ if (claim !== void 0) {
277
+ await chunkFMMW3KX7_cjs.claimEdgeCardinality(backend, ctx.claimsVerdict(), claim);
278
+ }
279
+ const updateParams = { graphId: ctx.graphId, ...rowWork };
280
+ return backend.updateEdge(updateParams);
281
+ }
282
+ function applyEdgeSoftDelete(ctx, work, backend) {
283
+ return backend.deleteEdge({
284
+ graphId: ctx.graphId,
285
+ id: work.id,
286
+ kind: work.kind
287
+ });
288
+ }
289
+ async function applyEdgeHardDelete(ctx, work, backend) {
290
+ await backend.hardDeleteEdge({
291
+ graphId: ctx.graphId,
292
+ id: work.id,
293
+ kind: work.kind
294
+ });
295
+ if (work.holdsCardinalityClaim) {
296
+ await chunkFMMW3KX7_cjs.purgeEdgeClaims(backend, ctx.claimsVerdict(), ctx.graphId, [work.id]);
297
+ }
298
+ }
299
+
300
+ // src/store/operations/write-fences.ts
301
+ function createWriteParamsDraft() {
302
+ return {};
303
+ }
304
+ function assertsStoredWindowState(fences) {
305
+ return chunkM5MSP3BI_cjs.assertsStoredLowerBound(fences.validityLowerBound) || chunkM5MSP3BI_cjs.assertsStoredUpperBound(fences.validityUpperBound);
306
+ }
307
+ var UnsupportedWriteFenceError = class extends Error {
308
+ fence;
309
+ kind;
310
+ constructor(fence, kind) {
311
+ super(
312
+ `The ${kind} statement cannot carry the "${fence}" fence, so the write is refused rather than run unfenced. Assert nothing ({}) or use a write shape whose statement carries it.`
313
+ );
314
+ this.name = "UnsupportedWriteFenceError";
315
+ this.fence = fence;
316
+ this.kind = kind;
317
+ }
318
+ };
319
+ function applyValidityLowerBound(fence, draft) {
320
+ if (!chunkM5MSP3BI_cjs.assertsStoredLowerBound(fence)) return;
321
+ draft.expectedValidFrom = fence.expectedValidFrom;
322
+ }
323
+ var NODE_UPDATE_FENCE_APPLIERS = {
324
+ validityLowerBound: applyValidityLowerBound
325
+ };
326
+ var NODE_SET_UPDATE_FENCE_APPLIERS = {
327
+ validityLowerBound: (fence) => {
328
+ if (!chunkM5MSP3BI_cjs.assertsStoredLowerBound(fence)) return;
329
+ throw new UnsupportedWriteFenceError("validityLowerBound", "nodeSetUpdate");
330
+ }
331
+ };
332
+ function applyEdgeIdentity(fence, draft) {
333
+ draft.kind = fence.kind;
334
+ if (fence.fromKind !== void 0) draft.fromKind = fence.fromKind;
335
+ if (fence.fromId !== void 0) draft.fromId = fence.fromId;
336
+ if (fence.toKind !== void 0) draft.toKind = fence.toKind;
337
+ if (fence.toId !== void 0) draft.toId = fence.toId;
338
+ }
339
+ function applyValidityUpperBound(fence, draft) {
340
+ if (!chunkM5MSP3BI_cjs.assertsStoredUpperBound(fence)) return;
341
+ draft.expectedValidTo = fence.expectedValidTo;
342
+ }
343
+ var EDGE_UPDATE_FENCE_APPLIERS = {
344
+ validityLowerBound: applyValidityLowerBound,
345
+ validityUpperBound: applyValidityUpperBound,
346
+ edgeIdentity: applyEdgeIdentity
347
+ };
348
+ function applyWriteFences(appliers, fences, draft) {
349
+ for (const key of Object.keys(appliers)) {
350
+ const applier = appliers[key];
351
+ applier(fences[key], draft);
352
+ }
353
+ }
354
+
355
+ // src/store/operations/write-session.ts
356
+ function unfencedTarget(target) {
357
+ return target;
358
+ }
359
+ function edgeBatchClaims(work) {
360
+ return work.flatMap((item) => item.claim === void 0 ? [] : [item.claim]);
361
+ }
362
+ function createWriteSession(ctx, target, lock) {
363
+ const writeContext = chunk2CVDZCXH_cjs.createNodeWriteContext(
364
+ ctx.graphId,
365
+ ctx.registry,
366
+ lock,
367
+ ctx.claimsVerdict,
368
+ ctx.uniqueSidecarBatch
369
+ );
370
+ const dispatch = chunkJQKMEKKW_cjs.nodeInsertDispatch(target);
371
+ const edgeContext = createEdgeWriteContext(
372
+ ctx.graphId,
373
+ lock,
374
+ ctx.claimsVerdict
375
+ );
376
+ const edgeDispatch = chunkJQKMEKKW_cjs.edgeInsertDispatch(target);
377
+ return {
378
+ // The pinned coordination order, spelled once per insert shape:
379
+ // pre-insert claims, the row, post-insert claims, the sync fans. The claim
380
+ // seam owns the two groups and the compensation between them; this surface
381
+ // owns only "the row write it gates is THIS one".
382
+ createNode: async (work) => {
383
+ const row = await chunk2CVDZCXH_cjs.withNodeCreateClaims(
384
+ writeContext,
385
+ work.claim,
386
+ target,
387
+ () => dispatch.one(work.params)
388
+ );
389
+ await chunk2CVDZCXH_cjs.applyNodeInsertSyncFans(writeContext, work.sideEffects, target);
390
+ return row;
391
+ },
392
+ createNodeNoReturn: async (work) => {
393
+ await chunk2CVDZCXH_cjs.withNodeCreateClaims(
394
+ writeContext,
395
+ work.claim,
396
+ target,
397
+ () => chunkJQKMEKKW_cjs.runInsertNoReturn(dispatch, work.params)
398
+ );
399
+ await chunk2CVDZCXH_cjs.applyNodeInsertSyncFans(writeContext, work.sideEffects, target);
400
+ },
401
+ createNodes: async (work) => {
402
+ const rows = await chunk2CVDZCXH_cjs.withNodeCreateClaimsBatch(
403
+ writeContext,
404
+ work.map((item) => item.claim),
405
+ target,
406
+ () => chunkJQKMEKKW_cjs.runInsertBatchReturning(
407
+ dispatch,
408
+ work.map((item) => item.params)
409
+ )
410
+ );
411
+ await chunk2CVDZCXH_cjs.applyNodeInsertSyncFansBatch(
412
+ writeContext,
413
+ work.map((item) => item.sideEffects),
414
+ target
415
+ );
416
+ return rows;
417
+ },
418
+ createNodesNoReturn: async (work) => {
419
+ await chunk2CVDZCXH_cjs.withNodeCreateClaimsBatch(
420
+ writeContext,
421
+ work.map((item) => item.claim),
422
+ target,
423
+ () => chunkJQKMEKKW_cjs.runInsertBatch(
424
+ dispatch,
425
+ work.map((item) => item.params)
426
+ )
427
+ );
428
+ await chunk2CVDZCXH_cjs.applyNodeInsertSyncFansBatch(
429
+ writeContext,
430
+ work.map((item) => item.sideEffects),
431
+ target
432
+ );
433
+ },
434
+ reviseNode: (work, fences) => {
435
+ const draft = createWriteParamsDraft();
436
+ applyWriteFences(NODE_UPDATE_FENCE_APPLIERS, fences, draft);
437
+ return chunk2CVDZCXH_cjs.applyNodeUpdate(writeContext, { ...work, ...draft }, target);
438
+ },
439
+ retireNode: (work, policy) => chunk2CVDZCXH_cjs.applyNodeSoftDelete(writeContext, work, target, policy),
440
+ purgeNode: (work) => chunk2CVDZCXH_cjs.applyNodeHardDelete(writeContext, work, target),
441
+ reviveNode: (work) => chunk2CVDZCXH_cjs.applyNodeResurrect(writeContext, work, target),
442
+ reviseNodeSet: (work, fences) => {
443
+ applyWriteFences(
444
+ NODE_SET_UPDATE_FENCE_APPLIERS,
445
+ fences,
446
+ createWriteParamsDraft()
447
+ );
448
+ return chunk2CVDZCXH_cjs.applyNodeSetUpdate(writeContext, work, target);
449
+ },
450
+ // An edge write obliges no DERIVED data, so these apply no sync fans — but a
451
+ // constrained kind owes its cardinality claim, at the same PRE-INSERT
452
+ // placement a node's scope-spanning claim takes and for the same reason: the
453
+ // probe that authorised the insert read a population no key fences. The
454
+ // batch issues ONE sorted statement (`claimEdgeCardinalityBatch` orders by
455
+ // `compareClaimTargets`), so a batch and a peer batch take their row locks
456
+ // in the same order.
457
+ createEdge: async (work) => {
458
+ if (work.claim !== void 0) {
459
+ await chunkFMMW3KX7_cjs.claimEdgeCardinality(target, ctx.claimsVerdict(), work.claim);
137
460
  }
138
- const count = await ctx.backend.countEdgesFrom({
139
- graphId: ctx.graphId,
140
- edgeKind,
141
- fromKind,
142
- fromId,
143
- activeOnly: true
144
- });
145
- const error = chunkFQPEMEWX_cjs.checkCardinality(
146
- edgeKind,
147
- fromKind,
148
- fromId,
149
- "oneActive",
150
- count,
151
- count > 0
461
+ return edgeDispatch.one(work.params);
462
+ },
463
+ createEdgeNoReturn: async (work) => {
464
+ if (work.claim !== void 0) {
465
+ await chunkFMMW3KX7_cjs.claimEdgeCardinality(target, ctx.claimsVerdict(), work.claim);
466
+ }
467
+ await chunkJQKMEKKW_cjs.runInsertNoReturn(edgeDispatch, work.params);
468
+ },
469
+ createEdges: async (work) => {
470
+ await chunkFMMW3KX7_cjs.claimEdgeCardinalityBatch(
471
+ target,
472
+ ctx.claimsVerdict(),
473
+ edgeBatchClaims(work)
152
474
  );
153
- if (error) throw error;
154
- return;
475
+ return chunkJQKMEKKW_cjs.runInsertBatchReturning(
476
+ edgeDispatch,
477
+ work.map((item) => item.params)
478
+ );
479
+ },
480
+ createEdgesNoReturn: async (work) => {
481
+ await chunkFMMW3KX7_cjs.claimEdgeCardinalityBatch(
482
+ target,
483
+ ctx.claimsVerdict(),
484
+ edgeBatchClaims(work)
485
+ );
486
+ await chunkJQKMEKKW_cjs.runInsertBatch(
487
+ edgeDispatch,
488
+ work.map((item) => item.params)
489
+ );
490
+ },
491
+ reviseEdge: (work, fences) => {
492
+ const draft = createWriteParamsDraft();
493
+ applyWriteFences(EDGE_UPDATE_FENCE_APPLIERS, fences, draft);
494
+ return applyEdgeUpdate(edgeContext, { ...work, ...draft }, target);
495
+ },
496
+ retireEdge: (work) => applyEdgeSoftDelete(edgeContext, work, target),
497
+ purgeEdge: (work) => applyEdgeHardDelete(edgeContext, work, target)
498
+ };
499
+ }
500
+
501
+ // src/store/operations/write-executor.ts
502
+ function planFrame(ctx, plan, rowWork) {
503
+ return async (target, lock) => {
504
+ if (plan.requiresIdentityLock) {
505
+ const acquireIdentityLock = chunkN66HCGCY_cjs.requireDefined(
506
+ ctx.identityLock,
507
+ "write plan declares identity participation with no acquirer"
508
+ );
509
+ await acquireIdentityLock(target);
155
510
  }
156
- }
511
+ const mintSessionOver = (sessionTarget) => createWriteSession(ctx, sessionTarget, lock);
512
+ const mintOverlaidSession = (reads) => mintSessionOver(chunkNLX5OWK7_cjs.deriveBackend(target, reads));
513
+ return rowWork(
514
+ mintSessionOver(target),
515
+ target,
516
+ mintOverlaidSession
517
+ );
518
+ };
519
+ }
520
+ function planTransactionOptions(plan, options) {
521
+ return { ...options, fencesConstraintProbe: plan.constraintProbe };
522
+ }
523
+ function runWritePlan(ctx, plan, backend, rowWork, options) {
524
+ return chunkJQKMEKKW_cjs.runInWriteTransaction(
525
+ ctx,
526
+ backend,
527
+ planFrame(ctx, plan, rowWork),
528
+ planTransactionOptions(plan, options)
529
+ );
530
+ }
531
+ function runHookedWritePlan(ctx, opContext, plan, backend, rowWork, options) {
532
+ return chunkJQKMEKKW_cjs.runHookedWriteOperation(
533
+ ctx,
534
+ opContext,
535
+ backend,
536
+ planFrame(ctx, plan, rowWork),
537
+ planTransactionOptions(plan, options)
538
+ );
539
+ }
540
+
541
+ // src/store/operations/write-plan.ts
542
+ function nodeWritePlan(constraintProbe, requiresIdentityLock) {
543
+ return { entity: "node", constraintProbe, requiresIdentityLock };
544
+ }
545
+ function nodeBatchWritePlan(constraintProbes, requiresIdentityLock) {
546
+ return {
547
+ entity: "node",
548
+ constraintProbe: constraintProbes.find((probe) => probe !== void 0),
549
+ requiresIdentityLock
550
+ };
551
+ }
552
+ function edgeWritePlan(constraintProbe) {
553
+ return { entity: "edge", constraintProbe, requiresIdentityLock: false };
554
+ }
555
+ function mixedWritePlan(constraintProbe, requiresIdentityLock) {
556
+ return { entity: "mixed", constraintProbe, requiresIdentityLock };
157
557
  }
158
558
 
159
559
  // src/store/validity-end.ts
160
560
  function assertValidityEndMutation(input, context) {
161
561
  if (input.validTo === void 0 || input.clearValidTo !== true) return;
162
- throw new chunkMRDBBHIZ_cjs.ValidationError(
562
+ throw new chunkX4GDXBOP_cjs.ValidationError(
163
563
  '"validTo" and "clearValidTo" are mutually exclusive',
164
564
  {
165
565
  ...context,
@@ -179,7 +579,7 @@ function validityEndAfterMutation(input, current) {
179
579
  }
180
580
  function assertClearValidToSupported(backend, entityType) {
181
581
  if (backend.capabilities.clearValidTo === true) return;
182
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
582
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
183
583
  `This backend does not support clearing ${entityType} validTo`,
184
584
  {
185
585
  code: "CLEAR_VALID_TO_UNSUPPORTED",
@@ -195,7 +595,7 @@ var ENTITY_LABELS = {
195
595
  };
196
596
  function alreadyExistsError(entity, kind, id, detail, cause) {
197
597
  const label = ENTITY_LABELS[entity];
198
- return new chunkMRDBBHIZ_cjs.ValidationError(
598
+ return new chunkX4GDXBOP_cjs.ValidationError(
199
599
  `${label.title} already exists: ${detail}`,
200
600
  {
201
601
  entityType: entity,
@@ -205,7 +605,7 @@ function alreadyExistsError(entity, kind, id, detail, cause) {
205
605
  issues: [
206
606
  {
207
607
  path: "id",
208
- code: chunkMRDBBHIZ_cjs.ENTITY_ALREADY_EXISTS_CODE,
608
+ code: chunkX4GDXBOP_cjs.ENTITY_ALREADY_EXISTS_CODE,
209
609
  message: `${label.article} with this ID already exists`
210
610
  }
211
611
  ]
@@ -220,7 +620,7 @@ function createAlreadyExistsError(entity, kind, id) {
220
620
  return alreadyExistsError(entity, kind, id, `${kind}/${id}`, void 0);
221
621
  }
222
622
  function isDuplicateKeyInsertError(error, entity) {
223
- return error instanceof chunkMRDBBHIZ_cjs.DatabaseOperationError && error.details.operation === "insert" && error.details.entity === entity && error.details.reason === "duplicate_key";
623
+ return error instanceof chunkX4GDXBOP_cjs.DatabaseOperationError && error.details.operation === "insert" && error.details.entity === entity && error.details.reason === "duplicate_key";
224
624
  }
225
625
  function rethrowAsAlreadyExists(error, entity) {
226
626
  if (!isDuplicateKeyInsertError(error, entity)) throw error;
@@ -254,9 +654,9 @@ async function withAlreadyExistsTranslation(entity, run) {
254
654
 
255
655
  // src/store/operations/node-operations.ts
256
656
  function getNodeRegistration(graph, kind) {
257
- if (!chunkN66HCGCY_cjs.hasOwnKey(graph.nodes, kind)) throw new chunkMRDBBHIZ_cjs.KindNotFoundError(kind, "node");
657
+ if (!chunkN66HCGCY_cjs.hasOwnKey(graph.nodes, kind)) throw new chunkX4GDXBOP_cjs.KindNotFoundError(kind, "node");
258
658
  const registration = graph.nodes[kind];
259
- if (registration === void 0) throw new chunkMRDBBHIZ_cjs.KindNotFoundError(kind, "node");
659
+ if (registration === void 0) throw new chunkX4GDXBOP_cjs.KindNotFoundError(kind, "node");
260
660
  return registration;
261
661
  }
262
662
  function nodeFencesConstraintProbe(ctx, kind, operation) {
@@ -268,18 +668,24 @@ function nodeFencesConstraintProbe(ctx, kind, operation) {
268
668
  operation
269
669
  );
270
670
  }
271
- function nodeBatchFencesConstraintProbe(ctx, inputs, operation) {
272
- for (const input of inputs) {
273
- const reason = nodeFencesConstraintProbe(ctx, input.kind, operation);
274
- if (reason !== void 0) return reason;
275
- }
276
- return void 0;
671
+ function nodeBatchConstraintProbes(ctx, inputs, operation) {
672
+ return inputs.map(
673
+ (input) => nodeFencesConstraintProbe(ctx, input.kind, operation)
674
+ );
675
+ }
676
+ function nodeWritePlanContext(ctx) {
677
+ const identity = ctx.identity;
678
+ if (identity === void 0) return ctx;
679
+ return { ...ctx, identityLock: identity.lock };
680
+ }
681
+ function nodeRequiresIdentityLock(ctx) {
682
+ return ctx.identity !== void 0;
277
683
  }
278
684
  function buildNodeCacheKey(graphId, kind, id) {
279
- return chunkEZEEWCFJ_cjs.encodeTupleKey([graphId, kind, id]);
685
+ return chunkCRZ56SZU_cjs.encodeTupleKey([graphId, kind, id]);
280
686
  }
281
687
  function buildUniqueCacheKey(graphId, nodeKind, constraintName, key) {
282
- return chunkEZEEWCFJ_cjs.encodeTupleKey([graphId, nodeKind, constraintName, key]);
688
+ return chunkCRZ56SZU_cjs.encodeTupleKey([graphId, nodeKind, constraintName, key]);
283
689
  }
284
690
  function buildInsertNodeParams(graphId, kind, id, props, validFrom, validTo) {
285
691
  const insertParams = {
@@ -292,14 +698,14 @@ function buildInsertNodeParams(graphId, kind, id, props, validFrom, validTo) {
292
698
  if (validTo !== void 0) insertParams.validTo = validTo;
293
699
  return insertParams;
294
700
  }
295
- function createPendingUniqueRow(graphId, nodeKind, constraintName, key, nodeId) {
701
+ function createPendingUniqueRow(graphId, nodeKind, constraintName, key, owner) {
296
702
  return {
297
703
  graph_id: graphId,
298
704
  node_kind: nodeKind,
299
705
  constraint_name: constraintName,
300
706
  key,
301
- node_id: nodeId,
302
- concrete_kind: nodeKind,
707
+ node_id: owner.nodeId,
708
+ concrete_kind: owner.concreteKind,
303
709
  deleted_at: void 0
304
710
  };
305
711
  }
@@ -310,11 +716,11 @@ function resolveConstraint(graph, kind, constraintName) {
310
716
  (candidate) => candidate.name === constraintName
311
717
  );
312
718
  if (constraint === void 0) {
313
- throw new chunkMRDBBHIZ_cjs.NodeConstraintNotFoundError(constraintName, kind);
719
+ throw new chunkX4GDXBOP_cjs.NodeConstraintNotFoundError(constraintName, kind);
314
720
  }
315
721
  return constraint;
316
722
  }
317
- function createNodeBatchValidationBackend(graphId, registry, backend) {
723
+ function createNodeBatchValidationSeams(graphId, registry, backend) {
318
724
  const nodeCache = /* @__PURE__ */ new Map();
319
725
  const pendingNodes = /* @__PURE__ */ new Map();
320
726
  const uniqueCache = /* @__PURE__ */ new Map();
@@ -370,71 +776,72 @@ function createNodeBatchValidationBackend(graphId, registry, backend) {
370
776
  });
371
777
  }
372
778
  function registerPendingUniqueEntries(kind, id, props, constraints) {
373
- for (const constraint of constraints) {
374
- if (!chunkFQPEMEWX_cjs.checkWherePredicate(constraint, props)) continue;
375
- const key = chunkFQPEMEWX_cjs.computeUniqueKey(
376
- props,
377
- constraint.fields,
378
- constraint.collation
379
- );
380
- const concreteEntryKey = buildUniqueCacheKey(
381
- graphId,
382
- kind,
383
- constraint.name,
384
- key
779
+ for (const entry of chunk2CVDZCXH_cjs.nodeClaimEntries(
780
+ registry,
781
+ kind,
782
+ id,
783
+ props,
784
+ constraints,
785
+ "create"
786
+ )) {
787
+ pendingUniqueOwners.set(
788
+ buildUniqueCacheKey(
789
+ graphId,
790
+ entry.axis,
791
+ entry.constraintName,
792
+ entry.key
793
+ ),
794
+ { concreteKind: kind, nodeId: id }
385
795
  );
386
- pendingUniqueOwners.set(concreteEntryKey, id);
387
- if (constraint.scope !== "kind") {
388
- const kindsToCheck = chunkFQPEMEWX_cjs.getKindsForUniquenessCheck(
389
- kind,
390
- constraint.scope,
391
- registry
392
- );
393
- for (const kindToCheck of kindsToCheck) {
394
- const inheritedEntryKey = buildUniqueCacheKey(
395
- graphId,
396
- kindToCheck,
397
- constraint.name,
398
- key
399
- );
400
- pendingUniqueOwners.set(inheritedEntryKey, id);
401
- }
402
- }
403
796
  }
404
797
  }
405
798
  function registerAppliedNodeUpdate(kind, id, oldProps, newProps, constraints) {
799
+ const owner = { concreteKind: kind, nodeId: id };
800
+ const oldEntries = new Map(
801
+ chunk2CVDZCXH_cjs.nodeClaimEntries(registry, kind, id, oldProps, constraints, "update").map(
802
+ (entry) => [entry.constraintName, entry]
803
+ )
804
+ );
805
+ const newEntries = new Map(
806
+ chunk2CVDZCXH_cjs.nodeClaimEntries(registry, kind, id, newProps, constraints, "update").map(
807
+ (entry) => [entry.constraintName, entry]
808
+ )
809
+ );
406
810
  for (const constraint of constraints) {
407
- const oldApplies = chunkFQPEMEWX_cjs.checkWherePredicate(constraint, oldProps);
408
- const newApplies = chunkFQPEMEWX_cjs.checkWherePredicate(constraint, newProps);
409
- const oldKey = oldApplies ? chunkFQPEMEWX_cjs.computeUniqueKey(oldProps, constraint.fields, constraint.collation) : void 0;
410
- const newKey = newApplies ? chunkFQPEMEWX_cjs.computeUniqueKey(newProps, constraint.fields, constraint.collation) : void 0;
411
- if (oldKey === newKey) continue;
412
- const kindsToCheck = chunkFQPEMEWX_cjs.getKindsForUniquenessCheck(
811
+ const oldEntry = oldEntries.get(constraint.name);
812
+ const newEntry = newEntries.get(constraint.name);
813
+ if (oldEntry?.key === newEntry?.key) continue;
814
+ const kindsToCheck = chunkCRZ56SZU_cjs.uniquenessProbeKinds(
413
815
  kind,
414
816
  constraint.scope,
415
817
  registry
416
818
  );
417
- if (oldKey !== void 0) {
819
+ if (oldEntry !== void 0) {
418
820
  for (const kindToCheck of kindsToCheck) {
419
821
  const cacheKey = buildUniqueCacheKey(
420
822
  graphId,
421
823
  kindToCheck,
422
824
  constraint.name,
423
- oldKey
825
+ oldEntry.key
424
826
  );
425
827
  pendingUniqueOwners.delete(cacheKey);
426
828
  uniqueCache.set(cacheKey, void 0);
427
829
  }
428
830
  }
429
- if (newKey !== void 0) {
831
+ if (newEntry !== void 0) {
430
832
  for (const kindToCheck of kindsToCheck) {
431
833
  const cacheKey = buildUniqueCacheKey(
432
834
  graphId,
433
835
  kindToCheck,
434
836
  constraint.name,
435
- newKey
837
+ newEntry.key
436
838
  );
437
- pendingUniqueOwners.set(cacheKey, id);
839
+ if (kindToCheck === newEntry.axis) {
840
+ pendingUniqueOwners.set(cacheKey, owner);
841
+ continue;
842
+ }
843
+ pendingUniqueOwners.delete(cacheKey);
844
+ uniqueCache.set(cacheKey, void 0);
438
845
  }
439
846
  }
440
847
  }
@@ -449,12 +856,13 @@ function createNodeBatchValidationBackend(graphId, registry, backend) {
449
856
  if (uniqueCache.has(cacheKey)) return;
450
857
  uniqueCache.set(cacheKey, row);
451
858
  }
452
- const validationBackend = chunkSIT26LAZ_cjs.deriveBackend(backend, {
859
+ const reads = {
453
860
  getNode: getNodeCached,
454
861
  checkUnique: checkUniqueCached
455
- });
862
+ };
456
863
  return {
457
- backend: validationBackend,
864
+ reads,
865
+ reader: chunkNLX5OWK7_cjs.deriveBackend(backend, reads),
458
866
  registerPendingNode,
459
867
  registerPendingUniqueEntries,
460
868
  registerAppliedNodeUpdate,
@@ -466,16 +874,16 @@ function draftNodeCreate(ctx, input, id, options) {
466
874
  const kind = input.kind;
467
875
  const registration = getNodeRegistration(ctx.graph, kind);
468
876
  const nodeKind = registration.type;
469
- const validatedProps = options?.propsPreValidated === true ? input.props : chunkJFRT7S3B_cjs.validateNodeProps(nodeKind.schema, input.props, {
877
+ const validatedProps = options?.propsPreValidated === true ? input.props : chunkJQKMEKKW_cjs.validateNodeProps(nodeKind.schema, input.props, {
470
878
  kind,
471
879
  operation: "create"
472
880
  });
473
- const validFrom = chunkTQHGE7UC_cjs.validateOptionalCanonicalIsoDate(
881
+ const validFrom = chunkM5MSP3BI_cjs.validateOptionalCanonicalIsoDate(
474
882
  input.validFrom,
475
883
  "validFrom"
476
884
  );
477
- const validTo = chunkTQHGE7UC_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo");
478
- chunkTQHGE7UC_cjs.assertOrderedValidityWindow(`${kind} "${id}"`, validFrom, validTo);
885
+ const validTo = chunkM5MSP3BI_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo");
886
+ chunkM5MSP3BI_cjs.assertOrderedValidityWindow(`${kind} "${id}"`, validFrom, validTo);
479
887
  return {
480
888
  kind,
481
889
  id,
@@ -499,8 +907,13 @@ async function finishNodeCreatePreparation(ctx, draft, backend) {
499
907
  backend
500
908
  };
501
909
  await checkDisjointnessConstraint(constraintContext, kind, id);
502
- await chunk3KOY4FH3_cjs.checkUniquenessConstraints(
503
- chunk3KOY4FH3_cjs.createUniquenessContext(ctx.graphId, ctx.registry, backend),
910
+ await chunk2CVDZCXH_cjs.checkUniquenessConstraints(
911
+ chunk2CVDZCXH_cjs.createUniquenessContext(
912
+ ctx.graphId,
913
+ ctx.registry,
914
+ backend,
915
+ ctx.uniqueSidecarBatch
916
+ ),
504
917
  kind,
505
918
  id,
506
919
  validatedProps,
@@ -531,38 +944,36 @@ async function validateAndPrepareNodeCreate(ctx, input, id, backend, options) {
531
944
  backend
532
945
  );
533
946
  }
534
- async function finalizeNodeCreateBatch(ctx, preparedCreates, backend, lock) {
535
- await chunk3KOY4FH3_cjs.applyNodeInsertSideEffectsBatch(
536
- chunk3KOY4FH3_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
537
- preparedCreates.map((prepared) => ({
538
- kind: prepared.kind,
539
- id: prepared.id,
540
- schema: prepared.nodeKind.schema,
541
- props: prepared.validatedProps,
542
- uniqueConstraints: prepared.uniqueConstraints
543
- })),
544
- backend
545
- );
947
+ function nodeCreateSideEffectItem(prepared) {
948
+ return {
949
+ kind: prepared.kind,
950
+ id: prepared.id,
951
+ schema: prepared.nodeKind.schema,
952
+ props: prepared.validatedProps,
953
+ uniqueConstraints: prepared.uniqueConstraints
954
+ };
955
+ }
956
+ function nodeCreateClaimItem(prepared) {
957
+ return {
958
+ kind: prepared.kind,
959
+ id: prepared.id,
960
+ props: prepared.validatedProps,
961
+ constraints: prepared.uniqueConstraints
962
+ };
963
+ }
964
+ function nodeInsertWork(prepared) {
965
+ return {
966
+ params: prepared.insertParams,
967
+ claim: nodeCreateClaimItem(prepared),
968
+ sideEffects: nodeCreateSideEffectItem(prepared)
969
+ };
546
970
  }
547
971
  function foldReferences(preparedCreates) {
548
972
  return preparedCreates.filter((prepared) => prepared.idProvided).map((prepared) => ({ kind: prepared.kind, id: prepared.id }));
549
973
  }
550
- async function finalizeNodeCreate(ctx, prepared, backend, lock) {
551
- await chunk3KOY4FH3_cjs.applyNodeInsertSideEffects(
552
- chunk3KOY4FH3_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
553
- {
554
- kind: prepared.kind,
555
- id: prepared.id,
556
- schema: prepared.nodeKind.schema,
557
- props: prepared.validatedProps,
558
- uniqueConstraints: prepared.uniqueConstraints
559
- },
560
- backend
561
- );
562
- }
563
974
  function computeNodeUpdate(ctx, kind, id, existingProps, inputProps) {
564
975
  const registration = getNodeRegistration(ctx.graph, kind);
565
- const validatedProps = chunkJFRT7S3B_cjs.validateNodeProps(
976
+ const validatedProps = chunkJQKMEKKW_cjs.validateNodeProps(
566
977
  registration.type.schema,
567
978
  { ...existingProps, ...inputProps },
568
979
  { kind, operation: "update", id }
@@ -570,7 +981,7 @@ function computeNodeUpdate(ctx, kind, id, existingProps, inputProps) {
570
981
  return { registration, validatedProps };
571
982
  }
572
983
  function resolveNodeUpdateProps(ctx, existing, inputProps) {
573
- const existingProps = chunk5PRKMB24_cjs.rowPropsToObject(existing.props);
984
+ const existingProps = chunkNUQ2YFFH_cjs.rowPropsToObject(existing.props);
574
985
  const { registration, validatedProps } = computeNodeUpdate(
575
986
  ctx,
576
987
  existing.kind,
@@ -590,30 +1001,30 @@ function nodeUpsertDirtyCheck(ctx, kind, id, existingProps, inputProps) {
590
1001
  );
591
1002
  return {
592
1003
  validatedProps,
593
- unchanged: chunkPWLJ77UV_cjs.canonicalEqual(validatedProps, existingProps)
1004
+ unchanged: chunkNLX5OWK7_cjs.canonicalEqual(validatedProps, existingProps)
594
1005
  };
595
1006
  }
596
- async function performNodeUpdate(ctx, input, backend, lock, options) {
1007
+ async function performNodeUpdate(ctx, input, session, target, options) {
597
1008
  const { kind, id } = input;
598
1009
  assertValidityEndMutation(input, { entityType: "node", kind, id });
599
- const existing = await backend.getNode(ctx.graphId, kind, id);
600
- if (!existing) throw new chunkMRDBBHIZ_cjs.NodeNotFoundError(kind, id);
1010
+ const existing = await target.getNode(ctx.graphId, kind, id);
1011
+ if (!existing) throw new chunkX4GDXBOP_cjs.NodeNotFoundError(kind, id);
601
1012
  const { registration, validatedProps } = resolveNodeUpdateProps(
602
1013
  ctx,
603
1014
  existing,
604
1015
  input.props
605
1016
  );
606
1017
  const nodeKind = registration.type;
607
- const validTo = chunkTQHGE7UC_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo");
608
- const resurrectionInstant = options?.clearDeleted === true && existing.deleted_at !== void 0 ? chunkTQHGE7UC_cjs.nowIso() : void 0;
609
- const preservesLiveLowerBound = resurrectionInstant === void 0 && chunkTQHGE7UC_cjs.preservesImmutableLowerBound(input.onImmutableLowerBound);
610
- const statedValidFrom = chunkTQHGE7UC_cjs.validateOptionalCanonicalIsoDate(
1018
+ const validTo = chunkM5MSP3BI_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo");
1019
+ const resurrectionInstant = options?.clearDeleted === true && existing.deleted_at !== void 0 ? chunkM5MSP3BI_cjs.nowIso() : void 0;
1020
+ const preservesLiveLowerBound = resurrectionInstant === void 0 && chunkM5MSP3BI_cjs.preservesImmutableLowerBound(input.onImmutableLowerBound);
1021
+ const statedValidFrom = chunkM5MSP3BI_cjs.validateOptionalCanonicalIsoDate(
611
1022
  input.validFrom,
612
1023
  "validFrom"
613
1024
  );
614
1025
  const validFrom = preservesLiveLowerBound ? void 0 : statedValidFrom;
615
- const resurrectionBound = resurrectionInstant === void 0 ? void 0 : chunkTQHGE7UC_cjs.resolveStampedValidityLowerBound(validFrom, validTo, resurrectionInstant);
616
- const windowVerdict = chunkTQHGE7UC_cjs.assertWritableValidityWindow(
1026
+ const resurrectionBound = resurrectionInstant === void 0 ? void 0 : chunkM5MSP3BI_cjs.resolveStampedValidityLowerBound(validFrom, validTo, resurrectionInstant);
1027
+ const windowVerdict = chunkM5MSP3BI_cjs.assertWritableValidityWindow(
617
1028
  `${kind} "${id}"`,
618
1029
  validFrom,
619
1030
  resurrectionInstant === void 0 ? {
@@ -628,55 +1039,44 @@ async function performNodeUpdate(ctx, input, backend, lock, options) {
628
1039
  },
629
1040
  validTo
630
1041
  );
631
- const writeContext = chunk3KOY4FH3_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock);
632
1042
  const shared = {
633
1043
  schema: nodeKind.schema,
634
1044
  validatedProps,
635
1045
  uniqueConstraints: registration.unique ?? [],
636
1046
  ...validTo !== void 0 && { validTo },
637
- ...input.clearValidTo === true && { clearValidTo: true },
638
- // The bound the verdict above READ, carried into the UPDATE's own `WHERE`
639
- // so the row this writes is the row that was judged. The verdict hands over
640
- // the predicate rather than a flag, so both conditions that decide it — did
641
- // the verdict consult the effective bound, and WAS that bound the row's
642
- // stored one — are answered where they are known. A plain
643
- // `update({ props })` states no window, reads no bound, and stays unfenced:
644
- // the same rule `UpdateEdgeParams`'s identity components follow, for the
645
- // same reason. The resurrecting leg is judged against `resurrectionInstant`
646
- // and so fences on `deleted_at IS NOT NULL` alone, converging through the
647
- // recovery below.
648
- ...windowVerdict.storedLowerBoundFence
1047
+ ...input.clearValidTo === true && { clearValidTo: true }
1048
+ };
1049
+ const fences = {
1050
+ validityLowerBound: windowVerdict.storedLowerBoundFence
649
1051
  };
650
1052
  if (options?.clearDeleted) {
651
1053
  const resurrectionLowerBound = resurrectionInstant === void 0 ? validFrom !== void 0 && { validFrom } : { validFrom: resurrectionBound ?? null };
652
- const row2 = await chunk3KOY4FH3_cjs.applyNodeUpdate(
653
- writeContext,
1054
+ const row2 = await session.reviseNode(
654
1055
  { ...shared, existing, clearDeleted: true, ...resurrectionLowerBound },
655
- backend
1056
+ fences
656
1057
  );
657
1058
  return rowToNode(row2);
658
1059
  }
659
- if (!chunk5PRKMB24_cjs.isLiveNodeRow(existing)) throw new chunkMRDBBHIZ_cjs.NodeNotFoundError(kind, id);
660
- const row = await chunk3KOY4FH3_cjs.applyNodeUpdate(
661
- writeContext,
1060
+ if (!chunkNUQ2YFFH_cjs.isLiveNodeRow(existing)) throw new chunkX4GDXBOP_cjs.NodeNotFoundError(kind, id);
1061
+ const row = await session.reviseNode(
662
1062
  // An in-place update must not rewrite the stored bound, so it keeps the
663
1063
  // conditional spread: `buildUpdateNode` ignores `validFrom` off the
664
1064
  // resurrection leg, and stating one here would claim a rewrite that no
665
1065
  // statement performs.
666
1066
  { ...shared, existing, ...validFrom !== void 0 && { validFrom } },
667
- backend
1067
+ fences
668
1068
  );
669
1069
  return rowToNode(row);
670
1070
  }
671
1071
  var NODE_UPDATE_ATTEMPTS = 2;
672
- async function performNodeUpdateWithResurrectionRecovery(ctx, input, target, lock, options) {
1072
+ async function performNodeUpdateWithResurrectionRecovery(ctx, input, session, target, options) {
673
1073
  for (let attempt = 1; attempt <= NODE_UPDATE_ATTEMPTS; attempt += 1) {
674
1074
  try {
675
1075
  return await performNodeUpdate(
676
1076
  ctx,
677
1077
  input,
1078
+ session,
678
1079
  target,
679
- lock,
680
1080
  attempt === 1 ? options : void 0
681
1081
  );
682
1082
  } catch (error) {
@@ -685,15 +1085,15 @@ async function performNodeUpdateWithResurrectionRecovery(ctx, input, target, loc
685
1085
  }
686
1086
  const current = await target.getNode(ctx.graphId, input.kind, input.id);
687
1087
  if (current === void 0 || current.deleted_at !== void 0) {
688
- throw new chunkMRDBBHIZ_cjs.NodeNotFoundError(input.kind, input.id);
1088
+ throw new chunkX4GDXBOP_cjs.NodeNotFoundError(input.kind, input.id);
689
1089
  }
690
1090
  }
691
1091
  }
692
- throw new chunkMRDBBHIZ_cjs.NodeNotFoundError(input.kind, input.id);
1092
+ throw new chunkX4GDXBOP_cjs.NodeNotFoundError(input.kind, input.id);
693
1093
  }
694
1094
  function nodeUpdateRaceError(input, error) {
695
1095
  if (!isNodeUpdateNoRowError(error)) return error;
696
- return new chunkMRDBBHIZ_cjs.DatabaseOperationError(
1096
+ return new chunkX4GDXBOP_cjs.DatabaseOperationError(
697
1097
  `Node update for ${input.kind} "${input.id}" could not be applied to a stable row after ${NODE_UPDATE_ATTEMPTS} attempts: the row was removed and recreated between each read and its write. A concurrent writer is replacing this node faster than it can be read; serialize the writers, or retry.`,
698
1098
  {
699
1099
  operation: "update",
@@ -704,7 +1104,12 @@ function nodeUpdateRaceError(input, error) {
704
1104
  );
705
1105
  }
706
1106
  async function primeBatchValidationCaches(ctx, drafts, backend, seams) {
707
- if (backend.getNodes !== void 0) {
1107
+ const boundGetNodes = chunkNUQ2YFFH_cjs.bindExtraIfReachable(
1108
+ backend,
1109
+ ctx.batchPointRead.extras.getNodes,
1110
+ chunkNUQ2YFFH_cjs.BATCH_POINT_READ.id
1111
+ );
1112
+ if (boundGetNodes !== void 0) {
708
1113
  const idsByKind = /* @__PURE__ */ new Map();
709
1114
  for (const draft of drafts) {
710
1115
  const ids = idsByKind.get(draft.kind) ?? /* @__PURE__ */ new Set();
@@ -713,30 +1118,39 @@ async function primeBatchValidationCaches(ctx, drafts, backend, seams) {
713
1118
  }
714
1119
  for (const [kind, ids] of idsByKind) {
715
1120
  const orderedIds = [...ids];
716
- const rows = await backend.getNodes(ctx.graphId, kind, orderedIds);
1121
+ const rows = await boundGetNodes.getNodes(ctx.graphId, kind, orderedIds);
717
1122
  const rowsById = new Map(rows.map((row) => [row.id, row]));
718
1123
  for (const id of orderedIds) {
719
1124
  seams.seedNodeRow(kind, id, rowsById.get(id));
720
1125
  }
721
1126
  }
722
1127
  }
723
- if (backend.checkUniqueBatch !== void 0) {
1128
+ const boundCheckUniqueBatch = chunkNUQ2YFFH_cjs.bindExtraIfReachable(
1129
+ backend,
1130
+ ctx.uniqueSidecarBatch.extras.checkUniqueBatch,
1131
+ chunkNUQ2YFFH_cjs.UNIQUE_SIDECAR_BATCH.id
1132
+ );
1133
+ if (boundCheckUniqueBatch !== void 0) {
724
1134
  const groups = /* @__PURE__ */ new Map();
725
1135
  for (const draft of drafts) {
726
- for (const constraint of draft.uniqueConstraints) {
727
- if (!chunkFQPEMEWX_cjs.checkWherePredicate(constraint, draft.validatedProps)) continue;
728
- const key = chunkFQPEMEWX_cjs.computeUniqueKey(
729
- draft.validatedProps,
730
- constraint.fields,
731
- constraint.collation
732
- );
733
- const kindsToCheck = chunkFQPEMEWX_cjs.getKindsForUniquenessCheck(
1136
+ for (const entry of chunk2CVDZCXH_cjs.nodeClaimEntries(
1137
+ ctx.registry,
1138
+ draft.kind,
1139
+ draft.id,
1140
+ draft.validatedProps,
1141
+ draft.uniqueConstraints,
1142
+ "create"
1143
+ )) {
1144
+ if (entry.refusal.kind !== "uniqueness") continue;
1145
+ const constraint = entry.refusal.constraint;
1146
+ const key = entry.key;
1147
+ const kindsToCheck = chunkCRZ56SZU_cjs.uniquenessProbeKinds(
734
1148
  draft.kind,
735
1149
  constraint.scope,
736
1150
  ctx.registry
737
1151
  );
738
1152
  for (const kindToCheck of kindsToCheck) {
739
- const groupKey = chunkEZEEWCFJ_cjs.encodeTupleKey([kindToCheck, constraint.name]);
1153
+ const groupKey = chunkCRZ56SZU_cjs.encodeTupleKey([kindToCheck, constraint.name]);
740
1154
  const group = groups.get(groupKey) ?? {
741
1155
  nodeKind: kindToCheck,
742
1156
  constraintName: constraint.name,
@@ -749,7 +1163,7 @@ async function primeBatchValidationCaches(ctx, drafts, backend, seams) {
749
1163
  }
750
1164
  for (const group of groups.values()) {
751
1165
  const orderedKeys = [...group.keys];
752
- const rows = await backend.checkUniqueBatch({
1166
+ const rows = await boundCheckUniqueBatch.checkUniqueBatch({
753
1167
  graphId: ctx.graphId,
754
1168
  nodeKind: group.nodeKind,
755
1169
  constraintName: group.constraintName,
@@ -769,14 +1183,14 @@ async function primeBatchValidationCaches(ctx, drafts, backend, seams) {
769
1183
  }
770
1184
  async function prepareBatchCreates(ctx, inputs, backend, options) {
771
1185
  const {
772
- backend: validationBackend,
1186
+ reader: validationBackend,
773
1187
  registerPendingNode,
774
1188
  registerPendingUniqueEntries,
775
1189
  seedNodeRow,
776
1190
  seedUniqueRow
777
- } = createNodeBatchValidationBackend(ctx.graphId, ctx.registry, backend);
1191
+ } = createNodeBatchValidationSeams(ctx.graphId, ctx.registry, backend);
778
1192
  const drafts = inputs.map(
779
- (input) => draftNodeCreate(ctx, input, input.id ?? chunkEZEEWCFJ_cjs.generateId(), options)
1193
+ (input) => draftNodeCreate(ctx, input, input.id ?? chunkJQKMEKKW_cjs.generateId(), options)
780
1194
  );
781
1195
  await primeBatchValidationCaches(ctx, drafts, backend, {
782
1196
  seedNodeRow,
@@ -813,12 +1227,12 @@ function partitionCreates(preparedCreates) {
813
1227
  return { inserts, resurrections };
814
1228
  }
815
1229
  function isNodeUpdateNoRowError(error) {
816
- return error instanceof chunkMRDBBHIZ_cjs.DatabaseOperationError && error.details.operation === "update" && error.details.entity === "node" && error.details.reason === "no_row_returned";
1230
+ return error instanceof chunkX4GDXBOP_cjs.DatabaseOperationError && error.details.operation === "update" && error.details.entity === "node" && error.details.reason === "no_row_returned";
817
1231
  }
818
- async function resurrectPreparedNode(ctx, target, lock, prepared) {
1232
+ async function resurrectPreparedNode(ctx, session, target, prepared) {
819
1233
  const current = await target.getNode(ctx.graphId, prepared.kind, prepared.id);
820
1234
  if (current === void 0) {
821
- throw new chunkMRDBBHIZ_cjs.DatabaseOperationError(
1235
+ throw new chunkX4GDXBOP_cjs.DatabaseOperationError(
822
1236
  `Node tombstone disappeared before resurrection: ${prepared.kind} ${prepared.id}`,
823
1237
  { operation: "update", entity: "node" }
824
1238
  );
@@ -826,15 +1240,14 @@ async function resurrectPreparedNode(ctx, target, lock, prepared) {
826
1240
  if (current.deleted_at === void 0) {
827
1241
  throw createAlreadyExistsError("node", prepared.kind, prepared.id);
828
1242
  }
829
- const resurrectionInstant = chunkTQHGE7UC_cjs.nowIso();
830
- const resurrectionBound = chunkTQHGE7UC_cjs.resolveStampedValidityLowerBound(
1243
+ const resurrectionInstant = chunkM5MSP3BI_cjs.nowIso();
1244
+ const resurrectionBound = chunkM5MSP3BI_cjs.resolveStampedValidityLowerBound(
831
1245
  prepared.insertParams.validFrom,
832
1246
  prepared.insertParams.validTo,
833
1247
  resurrectionInstant
834
1248
  );
835
1249
  try {
836
- return await chunk3KOY4FH3_cjs.applyNodeUpdate(
837
- chunk3KOY4FH3_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
1250
+ return await session.reviseNode(
838
1251
  {
839
1252
  existing: current,
840
1253
  clearDeleted: true,
@@ -847,7 +1260,11 @@ async function resurrectPreparedNode(ctx, target, lock, prepared) {
847
1260
  validFrom: resurrectionBound ?? null,
848
1261
  ...prepared.insertParams.validTo === void 0 ? {} : { validTo: prepared.insertParams.validTo }
849
1262
  },
850
- target
1263
+ // This resurrection reads no stored bound: it rewrites the whole window
1264
+ // and is fenced by the UPDATE's own `deleted_at IS NOT NULL` predicate,
1265
+ // so it asserts nothing about `valid_from`. `{}` is how a write states
1266
+ // that, and it is the only way to state it.
1267
+ { validityLowerBound: {} }
851
1268
  );
852
1269
  } catch (error) {
853
1270
  if (!isNodeUpdateNoRowError(error)) throw error;
@@ -862,7 +1279,12 @@ async function resurrectPreparedNode(ctx, target, lock, prepared) {
862
1279
  throw error;
863
1280
  }
864
1281
  }
1282
+ function prefersClaimRow(incumbent, candidate) {
1283
+ if (incumbent === void 0) return true;
1284
+ return incumbent.deleted_at !== void 0 && candidate.deleted_at === void 0;
1285
+ }
865
1286
  async function findUniqueRowAcrossKinds(backend, graphId, constraintName, key, kindsToCheck, includeDeleted) {
1287
+ let preferred;
866
1288
  for (const kindToCheck of kindsToCheck) {
867
1289
  const row = await backend.checkUnique({
868
1290
  graphId,
@@ -871,16 +1293,27 @@ async function findUniqueRowAcrossKinds(backend, graphId, constraintName, key, k
871
1293
  key,
872
1294
  includeDeleted
873
1295
  });
874
- if (row !== void 0) return row;
1296
+ if (row === void 0) continue;
1297
+ if (!prefersClaimRow(preferred, row)) continue;
1298
+ preferred = row;
1299
+ if (row.deleted_at === void 0) return row;
875
1300
  }
876
- return void 0;
1301
+ return preferred;
877
1302
  }
878
- async function batchCheckUniqueAcrossKinds(backend, graphId, constraintName, uniqueKeys, kindsToCheck, includeDeleted) {
1303
+ async function batchCheckUniqueAcrossKinds(backend, uniqueSidecarBatch, graphId, constraintName, uniqueKeys, kindsToCheck, includeDeleted) {
879
1304
  const existingByKey = /* @__PURE__ */ new Map();
1305
+ const boundCheckUniqueBatch = chunkNUQ2YFFH_cjs.bindExtraIfReachable(
1306
+ backend,
1307
+ uniqueSidecarBatch.extras.checkUniqueBatch,
1308
+ chunkNUQ2YFFH_cjs.UNIQUE_SIDECAR_BATCH.id
1309
+ );
880
1310
  for (const kindToCheck of kindsToCheck) {
881
- if (backend.checkUniqueBatch === void 0) {
1311
+ if (boundCheckUniqueBatch === void 0) {
882
1312
  for (const key of uniqueKeys) {
883
- if (existingByKey.has(key)) continue;
1313
+ const incumbent = existingByKey.get(key);
1314
+ if (incumbent !== void 0 && incumbent.deleted_at === void 0) {
1315
+ continue;
1316
+ }
884
1317
  const row = await backend.checkUnique({
885
1318
  graphId,
886
1319
  nodeKind: kindToCheck,
@@ -888,12 +1321,12 @@ async function batchCheckUniqueAcrossKinds(backend, graphId, constraintName, uni
888
1321
  key,
889
1322
  includeDeleted
890
1323
  });
891
- if (row !== void 0) {
1324
+ if (row !== void 0 && prefersClaimRow(incumbent, row)) {
892
1325
  existingByKey.set(row.key, row);
893
1326
  }
894
1327
  }
895
1328
  } else {
896
- const rows = await backend.checkUniqueBatch({
1329
+ const rows = await boundCheckUniqueBatch.checkUniqueBatch({
897
1330
  graphId,
898
1331
  nodeKind: kindToCheck,
899
1332
  constraintName,
@@ -901,7 +1334,7 @@ async function batchCheckUniqueAcrossKinds(backend, graphId, constraintName, uni
901
1334
  includeDeleted
902
1335
  });
903
1336
  for (const row of rows) {
904
- if (!existingByKey.has(row.key)) {
1337
+ if (prefersClaimRow(existingByKey.get(row.key), row)) {
905
1338
  existingByKey.set(row.key, row);
906
1339
  }
907
1340
  }
@@ -911,16 +1344,19 @@ async function batchCheckUniqueAcrossKinds(backend, graphId, constraintName, uni
911
1344
  }
912
1345
  async function executeNodeCreateInternal(ctx, input, backend, options) {
913
1346
  const kind = input.kind;
914
- const id = input.id ?? chunkEZEEWCFJ_cjs.generateId();
1347
+ const id = input.id ?? chunkJQKMEKKW_cjs.generateId();
915
1348
  const opContext = ctx.createOperationContext("create", "node", kind, id);
916
1349
  const shouldReturnRow = options?.returnRow ?? true;
917
- return chunkJFRT7S3B_cjs.runHookedWriteOperation(
918
- ctx,
1350
+ return runHookedWritePlan(
1351
+ nodeWritePlanContext(ctx),
919
1352
  opContext,
1353
+ nodeWritePlan(
1354
+ nodeFencesConstraintProbe(ctx, kind, "create"),
1355
+ nodeRequiresIdentityLock(ctx)
1356
+ ),
920
1357
  backend,
921
- async (target, lock) => {
1358
+ async (session, target) => {
922
1359
  const identity = ctx.identity;
923
- if (identity !== void 0) await identity.lock(target);
924
1360
  const prepared = await validateAndPrepareNodeCreate(
925
1361
  ctx,
926
1362
  input,
@@ -932,8 +1368,8 @@ async function executeNodeCreateInternal(ctx, input, backend, options) {
932
1368
  if (existing !== void 0) {
933
1369
  const resurrected = await resurrectPreparedNode(
934
1370
  ctx,
1371
+ session,
935
1372
  target,
936
- lock,
937
1373
  prepared
938
1374
  );
939
1375
  if (identity !== void 0) {
@@ -942,22 +1378,16 @@ async function executeNodeCreateInternal(ctx, input, backend, options) {
942
1378
  return shouldReturnRow ? rowToNode(resurrected) : void 0;
943
1379
  }
944
1380
  const row = await withAlreadyExistsTranslation("node", async () => {
945
- if (shouldReturnRow) return target.insertNode(prepared.insertParams);
946
- await chunkEZEEWCFJ_cjs.runInsertNoReturn(
947
- chunkEZEEWCFJ_cjs.nodeInsertDispatch(target),
948
- prepared.insertParams
949
- );
1381
+ const work = nodeInsertWork(prepared);
1382
+ if (shouldReturnRow) return session.createNode(work);
1383
+ await session.createNodeNoReturn(work);
950
1384
  return;
951
1385
  });
952
- await finalizeNodeCreate(ctx, prepared, target, lock);
953
1386
  if (identity !== void 0) {
954
1387
  await identity.foldCreated(target, foldReferences([prepared]));
955
1388
  }
956
1389
  if (row === void 0) return;
957
1390
  return rowToNode(row);
958
- },
959
- {
960
- fencesConstraintProbe: nodeFencesConstraintProbe(ctx, kind, "create")
961
1391
  }
962
1392
  );
963
1393
  }
@@ -967,7 +1397,7 @@ async function executeNodeCreate(ctx, input, backend, options) {
967
1397
  ...options
968
1398
  });
969
1399
  if (!result) {
970
- throw new chunkMRDBBHIZ_cjs.DatabaseOperationError(
1400
+ throw new chunkX4GDXBOP_cjs.DatabaseOperationError(
971
1401
  "Node create failed: expected created node row",
972
1402
  { operation: "insert", entity: "node" }
973
1403
  );
@@ -976,46 +1406,43 @@ async function executeNodeCreate(ctx, input, backend, options) {
976
1406
  }
977
1407
  async function executeNodeCreateNoReturnBatch(ctx, inputs, backend) {
978
1408
  if (inputs.length === 0) return;
979
- await chunkJFRT7S3B_cjs.runInWriteTransaction(
980
- ctx,
1409
+ await runWritePlan(
1410
+ nodeWritePlanContext(ctx),
1411
+ nodeBatchWritePlan(
1412
+ nodeBatchConstraintProbes(ctx, inputs, "create"),
1413
+ nodeRequiresIdentityLock(ctx)
1414
+ ),
981
1415
  backend,
982
- async (target, lock) => {
1416
+ async (session, target) => {
983
1417
  const identity = ctx.identity;
984
- if (identity !== void 0) await identity.lock(target);
985
1418
  const preparedCreates = await prepareBatchCreates(ctx, inputs, target);
986
1419
  const partition = partitionCreates(preparedCreates);
987
1420
  await withAlreadyExistsTranslation(
988
1421
  "node",
989
- () => chunkEZEEWCFJ_cjs.runInsertBatch(
990
- chunkEZEEWCFJ_cjs.nodeInsertDispatch(target),
991
- partition.inserts.map((prepared) => prepared.insertParams)
1422
+ () => session.createNodesNoReturn(
1423
+ partition.inserts.map((prepared) => nodeInsertWork(prepared))
992
1424
  )
993
1425
  );
994
1426
  for (const prepared of partition.resurrections) {
995
- await resurrectPreparedNode(ctx, target, lock, prepared);
1427
+ await resurrectPreparedNode(ctx, session, target, prepared);
996
1428
  }
997
- await finalizeNodeCreateBatch(ctx, partition.inserts, target, lock);
998
1429
  if (identity !== void 0) {
999
1430
  await identity.foldCreated(target, foldReferences(preparedCreates));
1000
1431
  }
1001
- },
1002
- {
1003
- fencesConstraintProbe: nodeBatchFencesConstraintProbe(
1004
- ctx,
1005
- inputs,
1006
- "create"
1007
- )
1008
1432
  }
1009
1433
  );
1010
1434
  }
1011
1435
  async function executeNodeCreateBatch(ctx, inputs, backend, options) {
1012
1436
  if (inputs.length === 0) return [];
1013
- return chunkJFRT7S3B_cjs.runInWriteTransaction(
1014
- ctx,
1437
+ return runWritePlan(
1438
+ nodeWritePlanContext(ctx),
1439
+ nodeBatchWritePlan(
1440
+ nodeBatchConstraintProbes(ctx, inputs, "create"),
1441
+ nodeRequiresIdentityLock(ctx)
1442
+ ),
1015
1443
  backend,
1016
- async (target, lock) => {
1444
+ async (session, target) => {
1017
1445
  const identity = ctx.identity;
1018
- if (identity !== void 0) await identity.lock(target);
1019
1446
  const preparedCreates = await prepareBatchCreates(
1020
1447
  ctx,
1021
1448
  inputs,
@@ -1025,27 +1452,25 @@ async function executeNodeCreateBatch(ctx, inputs, backend, options) {
1025
1452
  const partition = partitionCreates(preparedCreates);
1026
1453
  const inserted = await withAlreadyExistsTranslation(
1027
1454
  "node",
1028
- () => chunkEZEEWCFJ_cjs.runInsertBatchReturning(
1029
- chunkEZEEWCFJ_cjs.nodeInsertDispatch(target),
1030
- partition.inserts.map((prepared) => prepared.insertParams)
1455
+ () => session.createNodes(
1456
+ partition.inserts.map((prepared) => nodeInsertWork(prepared))
1031
1457
  )
1032
1458
  );
1033
1459
  const resurrected = [];
1034
1460
  for (const prepared of partition.resurrections) {
1035
1461
  resurrected.push(
1036
- await resurrectPreparedNode(ctx, target, lock, prepared)
1462
+ await resurrectPreparedNode(ctx, session, target, prepared)
1037
1463
  );
1038
1464
  }
1039
- await finalizeNodeCreateBatch(ctx, partition.inserts, target, lock);
1040
1465
  const byReference = new Map(
1041
1466
  [...inserted, ...resurrected].map((row) => [
1042
- chunkJFRT7S3B_cjs.refKey({ kind: row.kind, id: row.id }),
1467
+ chunkL6EVYIID_cjs.refKey({ kind: row.kind, id: row.id }),
1043
1468
  row
1044
1469
  ])
1045
1470
  );
1046
1471
  const rows = preparedCreates.map(
1047
1472
  (prepared) => chunkN66HCGCY_cjs.requireDefined(
1048
- byReference.get(chunkJFRT7S3B_cjs.refKey({ kind: prepared.kind, id: prepared.id })),
1473
+ byReference.get(chunkL6EVYIID_cjs.refKey({ kind: prepared.kind, id: prepared.id })),
1049
1474
  `Missing written row for ${prepared.kind} ${prepared.id}`
1050
1475
  )
1051
1476
  );
@@ -1053,39 +1478,36 @@ async function executeNodeCreateBatch(ctx, inputs, backend, options) {
1053
1478
  await identity.foldCreated(target, foldReferences(preparedCreates));
1054
1479
  }
1055
1480
  return rows.map((row) => rowToNode(row));
1056
- },
1057
- {
1058
- fencesConstraintProbe: nodeBatchFencesConstraintProbe(
1059
- ctx,
1060
- inputs,
1061
- "create"
1062
- )
1063
1481
  }
1064
1482
  );
1065
1483
  }
1066
1484
  async function executeNodeUpdate(ctx, input, backend, options) {
1485
+ if (input.clearValidTo === true) {
1486
+ assertClearValidToSupported(backend, "node");
1487
+ }
1067
1488
  const opContext = ctx.createOperationContext(
1068
1489
  "update",
1069
1490
  "node",
1070
1491
  input.kind,
1071
1492
  input.id
1072
1493
  );
1073
- return chunkJFRT7S3B_cjs.runHookedWriteOperation(
1074
- ctx,
1494
+ return runHookedWritePlan(
1495
+ nodeWritePlanContext(ctx),
1075
1496
  opContext,
1497
+ nodeWritePlan(
1498
+ nodeFencesConstraintProbe(ctx, input.kind, "update"),
1499
+ // Identity participates in an update when it RESURRECTS, and when it
1500
+ // states a validity end: a live-row update cannot change a node's kind, so
1501
+ // nothing folds, but an end reads the identity assertions that touch it.
1502
+ options?.clearDeleted === true || input.validTo !== void 0 ? nodeRequiresIdentityLock(ctx) : false
1503
+ ),
1076
1504
  backend,
1077
- async (target, lock) => {
1078
- if (input.clearValidTo === true) {
1079
- assertClearValidToSupported(backend, "node");
1080
- }
1081
- const validTo = chunkTQHGE7UC_cjs.validateOptionalCanonicalIsoDate(
1505
+ async (session, target) => {
1506
+ const validTo = chunkM5MSP3BI_cjs.validateOptionalCanonicalIsoDate(
1082
1507
  input.validTo,
1083
1508
  "validTo"
1084
1509
  );
1085
1510
  const identity = ctx.identity;
1086
- if (identity !== void 0 && (options?.clearDeleted === true || input.validTo !== void 0)) {
1087
- await identity.lock(target);
1088
- }
1089
1511
  if (identity !== void 0 && validTo !== void 0) {
1090
1512
  await identity.requireValidityEndCompatible(
1091
1513
  target,
@@ -1096,8 +1518,8 @@ async function executeNodeUpdate(ctx, input, backend, options) {
1096
1518
  const node = await performNodeUpdateWithResurrectionRecovery(
1097
1519
  ctx,
1098
1520
  input,
1521
+ session,
1099
1522
  target,
1100
- lock,
1101
1523
  options
1102
1524
  );
1103
1525
  if (options?.clearDeleted && identity !== void 0) {
@@ -1106,13 +1528,6 @@ async function executeNodeUpdate(ctx, input, backend, options) {
1106
1528
  ]);
1107
1529
  }
1108
1530
  return node;
1109
- },
1110
- {
1111
- fencesConstraintProbe: nodeFencesConstraintProbe(
1112
- ctx,
1113
- input.kind,
1114
- "update"
1115
- )
1116
1531
  }
1117
1532
  );
1118
1533
  }
@@ -1121,19 +1536,19 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
1121
1536
  const schema = registration.type.schema;
1122
1537
  const uniqueConstraints = registration.unique ?? [];
1123
1538
  if (!backend.capabilities.transactions) {
1124
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
1539
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
1125
1540
  "updateWhere() requires a transactional backend so validation and sidecars are atomic",
1126
1541
  { code: "SET_UPDATE_TRANSACTIONS_REQUIRED", kind }
1127
1542
  );
1128
1543
  }
1129
1544
  if (backend.updateNodeSet === void 0) {
1130
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
1545
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
1131
1546
  "This backend does not support set-based node updates",
1132
1547
  { code: "SET_UPDATE_UNSUPPORTED", kind }
1133
1548
  );
1134
1549
  }
1135
1550
  if (Object.keys(inputPatch).length === 0) {
1136
- throw new chunkMRDBBHIZ_cjs.ValidationError("updateWhere() patch must not be empty", {
1551
+ throw new chunkX4GDXBOP_cjs.ValidationError("updateWhere() patch must not be empty", {
1137
1552
  entityType: "node",
1138
1553
  kind,
1139
1554
  operation: "update",
@@ -1144,7 +1559,7 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
1144
1559
  (property) => !Object.hasOwn(schema.shape, property)
1145
1560
  );
1146
1561
  if (unknownProperty !== void 0) {
1147
- throw new chunkMRDBBHIZ_cjs.ValidationError(
1562
+ throw new chunkX4GDXBOP_cjs.ValidationError(
1148
1563
  `Unknown ${kind} property in updateWhere() patch: ${unknownProperty}`,
1149
1564
  {
1150
1565
  entityType: "node",
@@ -1159,7 +1574,7 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
1159
1574
  }
1160
1575
  );
1161
1576
  }
1162
- const parsedPatch = chunkJFRT7S3B_cjs.validateNodeProps(schema.partial(), inputPatch, {
1577
+ const parsedPatch = chunkJQKMEKKW_cjs.validateNodeProps(schema.partial(), inputPatch, {
1163
1578
  kind,
1164
1579
  operation: "update"
1165
1580
  });
@@ -1170,11 +1585,11 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
1170
1585
  unsetProperties.push(property);
1171
1586
  continue;
1172
1587
  }
1173
- chunk6NGW27EO_cjs.assertJsonValue(value, property, `Node "${kind}" updateWhere patch`);
1588
+ chunkVLBTRXA2_cjs.assertJsonValue(value, property, `Node "${kind}" updateWhere patch`);
1174
1589
  patch[property] = value;
1175
1590
  }
1176
1591
  if (Object.keys(patch).length === 0 && unsetProperties.length === 0) {
1177
- throw new chunkMRDBBHIZ_cjs.ValidationError(
1592
+ throw new chunkX4GDXBOP_cjs.ValidationError(
1178
1593
  "updateWhere() patch has no recognized properties",
1179
1594
  {
1180
1595
  entityType: "node",
@@ -1186,20 +1601,24 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
1186
1601
  }
1187
1602
  );
1188
1603
  }
1189
- if (uniqueConstraints.length > 0 && (backend.hardDeleteUniquesByNodeIds === void 0 || backend.insertUniqueBatch === void 0 || backend.checkUniqueBatch === void 0)) {
1190
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
1604
+ if (uniqueConstraints.length > 0 && chunkZGVTNKTX_cjs.missingRequiredExtras(
1605
+ chunkNUQ2YFFH_cjs.UNIQUE_SIDECAR_BATCH,
1606
+ ctx.uniqueSidecarBatch,
1607
+ "set-based node update"
1608
+ ).length > 0) {
1609
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
1191
1610
  "updateWhere() requires batched uniqueness sidecar operations for constrained nodes",
1192
1611
  { code: "SET_UPDATE_UNIQUENESS_UNSUPPORTED", kind }
1193
1612
  );
1194
1613
  }
1195
1614
  if (chunkHAHNRASW_cjs.getSearchableFields(schema).length > 0 && (backend.upsertFulltext === void 0 || backend.deleteFulltext === void 0 || backend.upsertFulltextBatch === void 0 || backend.deleteFulltextBatch === void 0)) {
1196
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
1615
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
1197
1616
  "updateWhere() requires batched fulltext sidecar operations for searchable nodes",
1198
1617
  { code: "SET_UPDATE_FULLTEXT_UNSUPPORTED", kind }
1199
1618
  );
1200
1619
  }
1201
- if (chunk3KOY4FH3_cjs.getEmbeddingFields(schema).length > 0 && (backend.upsertEmbedding === void 0 || backend.deleteEmbedding === void 0 || backend.upsertEmbeddingBatch === void 0 || backend.deleteEmbeddingBatch === void 0)) {
1202
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
1620
+ if (chunk2CVDZCXH_cjs.getEmbeddingFields(schema).length > 0 && (backend.upsertEmbedding === void 0 || backend.deleteEmbedding === void 0 || backend.upsertEmbeddingBatch === void 0 || backend.deleteEmbeddingBatch === void 0)) {
1621
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
1203
1622
  "updateWhere() requires batched vector sidecar operations for embedded nodes",
1204
1623
  { code: "SET_UPDATE_VECTOR_UNSUPPORTED", kind }
1205
1624
  );
@@ -1207,107 +1626,32 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
1207
1626
  const hookContext = ctx.createBulkOperationContext("updateWhere", kind);
1208
1627
  return ctx.withBulkOperationHooks(
1209
1628
  hookContext,
1210
- () => chunkJFRT7S3B_cjs.runInWriteTransaction(
1211
- ctx,
1629
+ () => runWritePlan(
1630
+ nodeWritePlanContext(ctx),
1631
+ // The set update re-checks every changed unique key across the
1632
+ // constraint's scope before rebuilding the sidecars, so a shared-scope
1633
+ // constraint makes it a constrained write like any other update.
1634
+ // Identity does not participate: a set update rewrites props, and no
1635
+ // patch can change a node's kind.
1636
+ nodeWritePlan(nodeFencesConstraintProbe(ctx, kind, "update"), false),
1212
1637
  backend,
1213
- async (target, lock) => {
1214
- const updateNodeSet = target.updateNodeSet;
1215
- if (updateNodeSet === void 0) {
1216
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
1217
- "The transaction backend does not support set-based node updates",
1218
- { code: "SET_UPDATE_UNSUPPORTED", kind }
1219
- );
1220
- }
1221
- const hardDeleteUniquesByNodeIds = target.hardDeleteUniquesByNodeIds;
1222
- if (uniqueConstraints.length > 0 && (hardDeleteUniquesByNodeIds === void 0 || target.insertUniqueBatch === void 0 || target.checkUniqueBatch === void 0)) {
1223
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
1224
- "The transaction backend lacks batched uniqueness operations",
1225
- { code: "SET_UPDATE_UNIQUENESS_UNSUPPORTED", kind }
1226
- );
1227
- }
1228
- if (chunkHAHNRASW_cjs.getSearchableFields(schema).length > 0 && (target.upsertFulltext === void 0 || target.deleteFulltext === void 0 || target.upsertFulltextBatch === void 0 || target.deleteFulltextBatch === void 0)) {
1229
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
1230
- "The transaction backend lacks batched fulltext operations",
1231
- { code: "SET_UPDATE_FULLTEXT_UNSUPPORTED", kind }
1232
- );
1233
- }
1234
- if (chunk3KOY4FH3_cjs.getEmbeddingFields(schema).length > 0 && (target.upsertEmbedding === void 0 || target.deleteEmbedding === void 0 || target.upsertEmbeddingBatch === void 0 || target.deleteEmbeddingBatch === void 0)) {
1235
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
1236
- "The transaction backend lacks batched vector operations",
1237
- { code: "SET_UPDATE_VECTOR_UNSUPPORTED", kind }
1238
- );
1239
- }
1240
- const result = await updateNodeSet({
1241
- graphId: ctx.graphId,
1638
+ (session) => session.reviseNodeSet(
1639
+ {
1242
1640
  kind,
1641
+ schema,
1642
+ uniqueConstraints,
1243
1643
  patch,
1244
1644
  unsetProperties,
1245
1645
  candidateIds,
1246
1646
  candidateIdColumn
1247
- });
1248
- if (result.affectedCount === 0) return { affectedCount: 0 };
1249
- const sidecarItems = result.rows.map((row) => {
1250
- const props = chunk5PRKMB24_cjs.rowPropsToObject(row.props);
1251
- const validatedProps = chunkJFRT7S3B_cjs.validateNodeProps(schema, props, {
1252
- kind,
1253
- operation: "update",
1254
- id: row.id
1255
- });
1256
- if (!chunkPWLJ77UV_cjs.canonicalEqual(validatedProps, props)) {
1257
- throw new chunkMRDBBHIZ_cjs.ValidationError(
1258
- `Set update would persist a non-canonical ${kind} row`,
1259
- {
1260
- entityType: "node",
1261
- kind,
1262
- operation: "update",
1263
- id: row.id,
1264
- issues: [
1265
- {
1266
- path: "props",
1267
- message: "The complete row requires schema normalization"
1268
- }
1269
- ]
1270
- }
1271
- );
1272
- }
1273
- return {
1274
- kind,
1275
- id: row.id,
1276
- schema,
1277
- props: validatedProps,
1278
- uniqueConstraints
1279
- };
1280
- });
1281
- if (uniqueConstraints.length > 0) {
1282
- await chunk3KOY4FH3_cjs.validateResolvedNodeUniqueness(
1283
- chunk3KOY4FH3_cjs.createUniquenessContext(ctx.graphId, ctx.registry, target),
1284
- sidecarItems.map((item) => ({
1285
- kind: item.kind,
1286
- id: item.id,
1287
- props: item.props,
1288
- constraints: item.uniqueConstraints
1289
- }))
1290
- );
1291
- await chunkN66HCGCY_cjs.requireDefined(hardDeleteUniquesByNodeIds)({
1292
- graphId: ctx.graphId,
1293
- concreteKind: kind,
1294
- nodeIds: result.rows.map((row) => row.id)
1295
- });
1296
- }
1297
- await chunk3KOY4FH3_cjs.applyNodeInsertSideEffectsBatch(
1298
- chunk3KOY4FH3_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
1299
- sidecarItems,
1300
- target
1301
- );
1302
- return { affectedCount: result.affectedCount };
1303
- },
1304
- {
1305
- didWrite: (result) => result.affectedCount > 0,
1306
- // The set update re-checks every changed unique key across the
1307
- // constraint's scope before rebuilding the sidecars, so a shared-scope
1308
- // constraint makes it a constrained write like any other update.
1309
- fencesConstraintProbe: nodeFencesConstraintProbe(ctx, kind, "update")
1310
- }
1647
+ },
1648
+ // This path states no window — it patches properties — so the write
1649
+ // asserts no stored lower bound. The set UPDATE has no field to
1650
+ // carry one, so a future windowed set update is refused here rather
1651
+ // than run unfenced.
1652
+ { validityLowerBound: {} }
1653
+ ),
1654
+ { didWrite: (result) => result.affectedCount > 0 }
1311
1655
  )
1312
1656
  );
1313
1657
  }
@@ -1315,18 +1659,22 @@ async function executeNodeUpsertUpdate(ctx, input, backend, options) {
1315
1659
  if (input.clearValidTo === true) {
1316
1660
  assertClearValidToSupported(backend, "node");
1317
1661
  }
1318
- return chunkJFRT7S3B_cjs.runInWriteTransaction(
1319
- ctx,
1662
+ return runWritePlan(
1663
+ nodeWritePlanContext(ctx),
1664
+ nodeWritePlan(
1665
+ nodeFencesConstraintProbe(ctx, input.kind, "update"),
1666
+ // Conditional for the same reason as {@link executeNodeUpdate}: a
1667
+ // resurrecting upsert folds, and stating a validity end reads the
1668
+ // identity's other members, so both take the lock.
1669
+ options?.clearDeleted === true || input.validTo !== void 0 ? nodeRequiresIdentityLock(ctx) : false
1670
+ ),
1320
1671
  backend,
1321
- async (target, lock) => {
1322
- const validTo = chunkTQHGE7UC_cjs.validateOptionalCanonicalIsoDate(
1672
+ async (session, target) => {
1673
+ const validTo = chunkM5MSP3BI_cjs.validateOptionalCanonicalIsoDate(
1323
1674
  input.validTo,
1324
1675
  "validTo"
1325
1676
  );
1326
1677
  const identity = ctx.identity;
1327
- if (identity !== void 0 && (options?.clearDeleted === true || input.validTo !== void 0)) {
1328
- await identity.lock(target);
1329
- }
1330
1678
  if (identity !== void 0 && validTo !== void 0) {
1331
1679
  await identity.requireValidityEndCompatible(
1332
1680
  target,
@@ -1337,8 +1685,8 @@ async function executeNodeUpsertUpdate(ctx, input, backend, options) {
1337
1685
  const node = await performNodeUpdateWithResurrectionRecovery(
1338
1686
  ctx,
1339
1687
  input,
1688
+ session,
1340
1689
  target,
1341
- lock,
1342
1690
  options
1343
1691
  );
1344
1692
  if (options?.clearDeleted && identity !== void 0) {
@@ -1347,13 +1695,6 @@ async function executeNodeUpsertUpdate(ctx, input, backend, options) {
1347
1695
  ]);
1348
1696
  }
1349
1697
  return node;
1350
- },
1351
- {
1352
- fencesConstraintProbe: nodeFencesConstraintProbe(
1353
- ctx,
1354
- input.kind,
1355
- "update"
1356
- )
1357
1698
  }
1358
1699
  );
1359
1700
  }
@@ -1361,26 +1702,22 @@ async function executeNodeDelete(ctx, kind, id, backend) {
1361
1702
  const gate = await backend.getNode(ctx.graphId, kind, id);
1362
1703
  if (!gate || gate.deleted_at) return;
1363
1704
  const opContext = ctx.createOperationContext("delete", "node", kind, id);
1364
- return chunkJFRT7S3B_cjs.runHookedWriteOperation(
1365
- ctx,
1705
+ return runHookedWritePlan(
1706
+ nodeWritePlanContext(ctx),
1366
1707
  opContext,
1708
+ nodeWritePlan(void 0, nodeRequiresIdentityLock(ctx)),
1367
1709
  backend,
1368
- async (target, lock) => {
1710
+ async (session, target) => {
1369
1711
  const identity = ctx.identity;
1370
- if (identity !== void 0) await identity.lock(target);
1371
1712
  const registration = getNodeRegistration(ctx.graph, kind);
1372
1713
  const preflight = await target.getNode(ctx.graphId, kind, id);
1373
- if (!preflight || !chunk5PRKMB24_cjs.isLiveNodeRow(preflight)) return;
1374
- await chunk3KOY4FH3_cjs.applyNodeSoftDelete(
1375
- chunk3KOY4FH3_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
1376
- {
1377
- existing: preflight,
1378
- schema: registration.type.schema,
1379
- uniqueConstraints: registration.unique ?? [],
1380
- onDelete: registration.onDelete
1381
- },
1382
- target
1383
- );
1714
+ if (!preflight || !chunkNUQ2YFFH_cjs.isLiveNodeRow(preflight)) return;
1715
+ await session.retireNode({
1716
+ existing: preflight,
1717
+ schema: registration.type.schema,
1718
+ uniqueConstraints: registration.unique ?? [],
1719
+ onDelete: registration.onDelete
1720
+ });
1384
1721
  if (identity !== void 0) {
1385
1722
  await identity.detachDeleted(target, { kind, id }, "soft");
1386
1723
  }
@@ -1388,32 +1725,23 @@ async function executeNodeDelete(ctx, kind, id, backend) {
1388
1725
  );
1389
1726
  }
1390
1727
  async function executeNodeDeleteBatch(ctx, kind, ids, backend) {
1391
- await chunkJFRT7S3B_cjs.runInWriteTransaction(
1392
- ctx,
1728
+ await runWritePlan(
1729
+ nodeWritePlanContext(ctx),
1730
+ nodeWritePlan(void 0, nodeRequiresIdentityLock(ctx)),
1393
1731
  backend,
1394
- async (target, lock) => {
1732
+ async (session, target) => {
1395
1733
  const identity = ctx.identity;
1396
- if (identity !== void 0) await identity.lock(target);
1397
1734
  const registration = getNodeRegistration(ctx.graph, kind);
1398
- const writeContext = chunk3KOY4FH3_cjs.createNodeWriteContext(
1399
- ctx.graphId,
1400
- ctx.registry,
1401
- lock
1402
- );
1403
1735
  let affectedCount = 0;
1404
1736
  for (const id of ids) {
1405
1737
  const preflight = await target.getNode(ctx.graphId, kind, id);
1406
- if (!preflight || !chunk5PRKMB24_cjs.isLiveNodeRow(preflight)) continue;
1407
- await chunk3KOY4FH3_cjs.applyNodeSoftDelete(
1408
- writeContext,
1409
- {
1410
- existing: preflight,
1411
- schema: registration.type.schema,
1412
- uniqueConstraints: registration.unique ?? [],
1413
- onDelete: registration.onDelete
1414
- },
1415
- target
1416
- );
1738
+ if (!preflight || !chunkNUQ2YFFH_cjs.isLiveNodeRow(preflight)) continue;
1739
+ await session.retireNode({
1740
+ existing: preflight,
1741
+ schema: registration.type.schema,
1742
+ uniqueConstraints: registration.unique ?? [],
1743
+ onDelete: registration.onDelete
1744
+ });
1417
1745
  if (identity !== void 0) {
1418
1746
  await identity.detachDeleted(target, { kind, id }, "soft");
1419
1747
  }
@@ -1428,24 +1756,20 @@ async function executeNodeHardDelete(ctx, kind, id, backend) {
1428
1756
  const gate = await backend.getNode(ctx.graphId, kind, id);
1429
1757
  if (!gate) return;
1430
1758
  const opContext = ctx.createOperationContext("delete", "node", kind, id);
1431
- return chunkJFRT7S3B_cjs.runHookedWriteOperation(
1432
- ctx,
1759
+ return runHookedWritePlan(
1760
+ nodeWritePlanContext(ctx),
1433
1761
  opContext,
1762
+ nodeWritePlan(void 0, nodeRequiresIdentityLock(ctx)),
1434
1763
  backend,
1435
- async (target, lock) => {
1764
+ async (session, target) => {
1436
1765
  const identity = ctx.identity;
1437
- if (identity !== void 0) await identity.lock(target);
1438
1766
  const registration = getNodeRegistration(ctx.graph, kind);
1439
- await chunk3KOY4FH3_cjs.applyNodeHardDelete(
1440
- chunk3KOY4FH3_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
1441
- {
1442
- kind,
1443
- id,
1444
- schema: registration.type.schema,
1445
- onDelete: registration.onDelete
1446
- },
1447
- target
1448
- );
1767
+ await session.purgeNode({
1768
+ kind,
1769
+ id,
1770
+ schema: registration.type.schema,
1771
+ onDelete: registration.onDelete
1772
+ });
1449
1773
  if (identity !== void 0) {
1450
1774
  await identity.detachDeleted(target, { kind, id }, "hard");
1451
1775
  }
@@ -1456,12 +1780,12 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
1456
1780
  const ifExists = options?.ifExists ?? "return";
1457
1781
  const registration = getNodeRegistration(ctx.graph, kind);
1458
1782
  const nodeKind = registration.type;
1459
- const validatedProps = chunkJFRT7S3B_cjs.validateNodeProps(nodeKind.schema, props, {
1783
+ const validatedProps = chunkJQKMEKKW_cjs.validateNodeProps(nodeKind.schema, props, {
1460
1784
  kind,
1461
1785
  operation: "create"
1462
1786
  });
1463
1787
  const constraint = resolveConstraint(ctx.graph, kind, constraintName);
1464
- if (!chunkFQPEMEWX_cjs.checkWherePredicate(constraint, validatedProps)) {
1788
+ if (!chunkCRZ56SZU_cjs.checkWherePredicate(constraint, validatedProps)) {
1465
1789
  const node = await executeNodeCreate(
1466
1790
  ctx,
1467
1791
  { kind, props: validatedProps },
@@ -1470,12 +1794,12 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
1470
1794
  );
1471
1795
  return { node, action: "created" };
1472
1796
  }
1473
- const key = chunkFQPEMEWX_cjs.computeUniqueKey(
1797
+ const key = chunkCRZ56SZU_cjs.computeUniqueKey(
1474
1798
  validatedProps,
1475
1799
  constraint.fields,
1476
1800
  constraint.collation
1477
1801
  );
1478
- const kindsToCheck = chunkFQPEMEWX_cjs.getKindsForUniquenessCheck(
1802
+ const kindsToCheck = chunkCRZ56SZU_cjs.uniquenessProbeKinds(
1479
1803
  kind,
1480
1804
  constraint.scope,
1481
1805
  ctx.registry
@@ -1532,25 +1856,25 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
1532
1856
  try {
1533
1857
  return await attempt();
1534
1858
  } catch (error) {
1535
- if (!(error instanceof chunkMRDBBHIZ_cjs.UniquenessError)) throw error;
1859
+ if (!(error instanceof chunkX4GDXBOP_cjs.UniquenessError)) throw error;
1536
1860
  return attempt();
1537
1861
  }
1538
1862
  }
1539
1863
  async function executeNodeFindByConstraint(ctx, kind, constraintName, props, backend) {
1540
1864
  const registration = getNodeRegistration(ctx.graph, kind);
1541
1865
  const nodeKind = registration.type;
1542
- const validatedProps = chunkJFRT7S3B_cjs.validateNodeProps(nodeKind.schema, props, {
1866
+ const validatedProps = chunkJQKMEKKW_cjs.validateNodeProps(nodeKind.schema, props, {
1543
1867
  kind,
1544
1868
  operation: "create"
1545
1869
  });
1546
1870
  const constraint = resolveConstraint(ctx.graph, kind, constraintName);
1547
- if (!chunkFQPEMEWX_cjs.checkWherePredicate(constraint, validatedProps)) return void 0;
1548
- const key = chunkFQPEMEWX_cjs.computeUniqueKey(
1871
+ if (!chunkCRZ56SZU_cjs.checkWherePredicate(constraint, validatedProps)) return void 0;
1872
+ const key = chunkCRZ56SZU_cjs.computeUniqueKey(
1549
1873
  validatedProps,
1550
1874
  constraint.fields,
1551
1875
  constraint.collation
1552
1876
  );
1553
- const kindsToCheck = chunkFQPEMEWX_cjs.getKindsForUniquenessCheck(
1877
+ const kindsToCheck = chunkCRZ56SZU_cjs.uniquenessProbeKinds(
1554
1878
  kind,
1555
1879
  constraint.scope,
1556
1880
  ctx.registry
@@ -1576,12 +1900,12 @@ async function executeNodeFindByConstraint(ctx, kind, constraintName, props, bac
1576
1900
  function validateAndComputeKeys(nodeKind, kind, constraint, items) {
1577
1901
  const validated = [];
1578
1902
  for (const item of items) {
1579
- const validatedProps = chunkJFRT7S3B_cjs.validateNodeProps(nodeKind.schema, item.props, {
1903
+ const validatedProps = chunkJQKMEKKW_cjs.validateNodeProps(nodeKind.schema, item.props, {
1580
1904
  kind,
1581
1905
  operation: "create"
1582
1906
  });
1583
- const applies = chunkFQPEMEWX_cjs.checkWherePredicate(constraint, validatedProps);
1584
- const key = applies ? chunkFQPEMEWX_cjs.computeUniqueKey(
1907
+ const applies = chunkCRZ56SZU_cjs.checkWherePredicate(constraint, validatedProps);
1908
+ const key = applies ? chunkCRZ56SZU_cjs.computeUniqueKey(
1585
1909
  validatedProps,
1586
1910
  constraint.fields,
1587
1911
  constraint.collation
@@ -1604,13 +1928,14 @@ async function executeNodeBulkFindByConstraint(ctx, kind, constraintName, items,
1604
1928
  const constraint = resolveConstraint(ctx.graph, kind, constraintName);
1605
1929
  const validated = validateAndComputeKeys(nodeKind, kind, constraint, items);
1606
1930
  const uniqueKeys = collectUniqueKeys(validated);
1607
- const kindsToCheck = chunkFQPEMEWX_cjs.getKindsForUniquenessCheck(
1931
+ const kindsToCheck = chunkCRZ56SZU_cjs.uniquenessProbeKinds(
1608
1932
  kind,
1609
1933
  constraint.scope,
1610
1934
  ctx.registry
1611
1935
  );
1612
1936
  const existingByKey = uniqueKeys.length > 0 ? await batchCheckUniqueAcrossKinds(
1613
1937
  backend,
1938
+ ctx.uniqueSidecarBatch,
1614
1939
  ctx.graphId,
1615
1940
  constraint.name,
1616
1941
  uniqueKeys,
@@ -1654,10 +1979,10 @@ function resolveNodeIndex(graph, kind, indexName) {
1654
1979
  (candidate) => candidate.entity === "node" && candidate.kind === kind && candidate.name === indexName
1655
1980
  );
1656
1981
  if (declaration?.entity !== "node") {
1657
- throw new chunkMRDBBHIZ_cjs.NodeIndexNotFoundError(indexName, kind);
1982
+ throw new chunkX4GDXBOP_cjs.NodeIndexNotFoundError(indexName, kind);
1658
1983
  }
1659
1984
  if (declaration.method !== void 0) {
1660
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
1985
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
1661
1986
  `bulkFindByIndex cannot probe index "${indexName}" (method "${declaration.method}"): only btree indexes serve equality probes.`,
1662
1987
  { indexName, kind, method: declaration.method }
1663
1988
  );
@@ -1695,7 +2020,7 @@ function validateIndexProbeValue(value, valueType, pointer, kind) {
1695
2020
  }
1696
2021
  }
1697
2022
  function indexProbeTypeError(pointer, kind, expected, value) {
1698
- return new chunkMRDBBHIZ_cjs.ValidationError(
2023
+ return new chunkX4GDXBOP_cjs.ValidationError(
1699
2024
  `Index probe value for "${pointer}" on node kind "${kind}" has an incompatible type`,
1700
2025
  {
1701
2026
  entityType: "node",
@@ -1729,7 +2054,7 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
1729
2054
  if (items.length === 0) return [];
1730
2055
  const index = resolveNodeIndex(ctx.graph, kind, indexName);
1731
2056
  if (index.fields.length === 0) {
1732
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
2057
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
1733
2058
  `bulkFindByIndex requires an index with at least one prop-based field on index "${indexName}" (node kind "${kind}")`,
1734
2059
  { indexName, kind },
1735
2060
  {
@@ -1738,7 +2063,7 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
1738
2063
  );
1739
2064
  }
1740
2065
  if (index.fieldValueTypes.includes("date")) {
1741
- throw new chunkMRDBBHIZ_cjs.ConfigurationError(
2066
+ throw new chunkX4GDXBOP_cjs.ConfigurationError(
1742
2067
  `bulkFindByIndex does not support date-typed key fields on index "${indexName}" (node kind "${kind}")`,
1743
2068
  { indexName, kind },
1744
2069
  {
@@ -1748,7 +2073,7 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
1748
2073
  }
1749
2074
  const limitPerInput = options?.limitPerInput;
1750
2075
  if (limitPerInput !== void 0 && (!Number.isInteger(limitPerInput) || limitPerInput <= 0)) {
1751
- throw new chunkMRDBBHIZ_cjs.ValidationError(
2076
+ throw new chunkX4GDXBOP_cjs.ValidationError(
1752
2077
  "bulkFindByIndex limitPerInput must be a positive integer",
1753
2078
  {
1754
2079
  entityType: "node",
@@ -1763,7 +2088,7 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
1763
2088
  }
1764
2089
  );
1765
2090
  }
1766
- const adapter = chunkL3LQNR34_cjs.getDialect(backend.dialect);
2091
+ const adapter = chunkJVA3KDEA_cjs.getDialect(backend.dialect);
1767
2092
  const probes = items.map(
1768
2093
  (item) => index.fields.map((pointer, position) => {
1769
2094
  const value = chunkA7J2YDDI_cjs.resolveJsonPointer(item.props, pointer);
@@ -1790,51 +2115,52 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
1790
2115
  }
1791
2116
  groupToInputs[existing]?.push(inputIndex);
1792
2117
  }
1793
- const schema = backend.tableNames ? chunk3U5ABFDW_cjs.createSqlSchema(backend.tableNames) : chunk3U5ABFDW_cjs.DEFAULT_SQL_SCHEMA;
2118
+ const schema = backend.tableNames ? chunkNUQ2YFFH_cjs.createSqlSchema(backend.tableNames) : chunkNUQ2YFFH_cjs.DEFAULT_SQL_SCHEMA;
1794
2119
  const compileContext = {
1795
2120
  dialect: backend.dialect,
1796
- propsColumn: chunkEDN4Y4ZG_cjs.sql.raw(`"props"`),
1797
- systemColumn: (column) => chunkEDN4Y4ZG_cjs.sql.raw(`"${column}"`)
2121
+ propsColumn: chunkH5IJSROF_cjs.sql.raw(`"props"`),
2122
+ systemColumn: (column) => chunkH5IJSROF_cjs.sql.raw(`"${column}"`)
1798
2123
  };
1799
- const fieldKeys = chunkL3LQNR34_cjs.compileNodeIndexFieldKeys(index, compileContext);
2124
+ const fieldKeys = chunkJVA3KDEA_cjs.compileNodeIndexFieldKeys(index, compileContext);
1800
2125
  const groupPredicates = groupProbes.map(
1801
- (probe) => chunkEDN4Y4ZG_cjs.sql`(${chunkEDN4Y4ZG_cjs.sql.join(
2126
+ (probe) => chunkH5IJSROF_cjs.sql`(${chunkH5IJSROF_cjs.sql.join(
1802
2127
  fieldKeys.map((fieldKey, position) => {
1803
2128
  const value = probe[position];
1804
2129
  if (value === void 0 || value === null) {
1805
- return chunkEDN4Y4ZG_cjs.sql`${fieldKey} IS NULL`;
2130
+ return chunkH5IJSROF_cjs.sql`${fieldKey} IS NULL`;
1806
2131
  }
1807
2132
  return adapter.nullSafeEquals(
1808
2133
  fieldKey,
1809
- chunkEDN4Y4ZG_cjs.sql`${coerceIndexProbeBind(value, adapter)}`
2134
+ chunkH5IJSROF_cjs.sql`${coerceIndexProbeBind(value, adapter)}`
1810
2135
  );
1811
2136
  }),
1812
- chunkEDN4Y4ZG_cjs.sql` AND `
2137
+ chunkH5IJSROF_cjs.sql` AND `
1813
2138
  )})`
1814
2139
  );
1815
2140
  const caseBranches = groupPredicates.map(
1816
- (predicate, group) => chunkEDN4Y4ZG_cjs.sql`WHEN ${predicate} THEN ${chunkEDN4Y4ZG_cjs.sql.raw(String(group))}`
2141
+ (predicate, group) => chunkH5IJSROF_cjs.sql`WHEN ${predicate} THEN ${chunkH5IJSROF_cjs.sql.raw(String(group))}`
1817
2142
  );
1818
- const probeIndexExpr = chunkEDN4Y4ZG_cjs.sql`CASE ${chunkEDN4Y4ZG_cjs.sql.join(caseBranches, chunkEDN4Y4ZG_cjs.sql` `)} ELSE NULL END`;
2143
+ const probeIndexExpr = chunkH5IJSROF_cjs.sql`CASE ${chunkH5IJSROF_cjs.sql.join(caseBranches, chunkH5IJSROF_cjs.sql` `)} ELSE NULL END`;
1819
2144
  const conditions = [
1820
- chunkEDN4Y4ZG_cjs.sql`"graph_id" = ${ctx.graphId}`,
1821
- chunkEDN4Y4ZG_cjs.sql`"kind" = ${kind}`,
1822
- chunkEDN4Y4ZG_cjs.sql`"deleted_at" IS NULL`
2145
+ chunkH5IJSROF_cjs.sql`"graph_id" = ${ctx.graphId}`,
2146
+ chunkH5IJSROF_cjs.sql`"kind" = ${kind}`,
2147
+ chunkH5IJSROF_cjs.sql`"deleted_at" IS NULL`
1823
2148
  ];
1824
2149
  if (index.where !== void 0) {
1825
- conditions.push(chunkL3LQNR34_cjs.compileIndexWhere(compileContext, index.where));
2150
+ conditions.push(chunkJVA3KDEA_cjs.compileIndexWhere(compileContext, index.where));
1826
2151
  }
1827
- conditions.push(chunkEDN4Y4ZG_cjs.sql`(${chunkEDN4Y4ZG_cjs.sql.join(groupPredicates, chunkEDN4Y4ZG_cjs.sql` OR `)})`);
1828
- const whereClause = chunkEDN4Y4ZG_cjs.sql.join(conditions, chunkEDN4Y4ZG_cjs.sql` AND `);
1829
- const probedSelect = chunkEDN4Y4ZG_cjs.sql`SELECT "id", ${probeIndexExpr} AS probe_idx FROM ${schema.nodesTable} WHERE ${whereClause}`;
2152
+ conditions.push(chunkH5IJSROF_cjs.sql`(${chunkH5IJSROF_cjs.sql.join(groupPredicates, chunkH5IJSROF_cjs.sql` OR `)})`);
2153
+ const whereClause = chunkH5IJSROF_cjs.sql.join(conditions, chunkH5IJSROF_cjs.sql` AND `);
2154
+ const probedSelect = chunkH5IJSROF_cjs.sql`SELECT "id", ${probeIndexExpr} AS probe_idx FROM ${schema.nodesTable} WHERE ${whereClause}`;
1830
2155
  const capInSql = limitPerInput !== void 0 && backend.capabilities.windowFunctions;
1831
- const query = capInSql ? chunkEDN4Y4ZG_cjs.sql`SELECT "id", probe_idx FROM (SELECT "id", probe_idx, ROW_NUMBER() OVER (PARTITION BY probe_idx ORDER BY "id") AS probe_rank FROM (${probedSelect}) AS probed) AS ranked WHERE probe_rank <= ${limitPerInput} ORDER BY probe_idx, "id"` : chunkEDN4Y4ZG_cjs.sql`${probedSelect} ORDER BY probe_idx, "id"`;
2156
+ const query = capInSql ? chunkH5IJSROF_cjs.sql`SELECT "id", probe_idx FROM (SELECT "id", probe_idx, ROW_NUMBER() OVER (PARTITION BY probe_idx ORDER BY "id") AS probe_rank FROM (${probedSelect}) AS probed) AS ranked WHERE probe_rank <= ${limitPerInput} ORDER BY probe_idx, "id"` : chunkH5IJSROF_cjs.sql`${probedSelect} ORDER BY probe_idx, "id"`;
1832
2157
  const rawMatches = await backend.execute(
1833
- chunkEDN4Y4ZG_cjs.asCompiledRowsSql(query)
2158
+ chunkH5IJSROF_cjs.asCompiledRowsSql(query)
1834
2159
  );
1835
2160
  const matches = limitPerInput !== void 0 && !capInSql ? capMatchesPerGroup(rawMatches, limitPerInput) : rawMatches;
1836
2161
  const nodesById = await hydrateNodesById(
1837
2162
  backend,
2163
+ ctx.batchPointRead,
1838
2164
  ctx.graphId,
1839
2165
  kind,
1840
2166
  matches.map((match) => match.id)
@@ -1862,8 +2188,14 @@ function capMatchesPerGroup(matches, limitPerInput) {
1862
2188
  }
1863
2189
  return capped;
1864
2190
  }
1865
- async function hydrateNodesById(backend, graphId, kind, ids) {
1866
- const rowsById = await chunkEZEEWCFJ_cjs.getNodeRowsByIds(backend, graphId, kind, ids);
2191
+ async function hydrateNodesById(backend, batchPointRead, graphId, kind, ids) {
2192
+ const rowsById = await chunkJQKMEKKW_cjs.getNodeRowsByIds(
2193
+ backend,
2194
+ batchPointRead,
2195
+ graphId,
2196
+ kind,
2197
+ ids
2198
+ );
1867
2199
  const nodesById = /* @__PURE__ */ new Map();
1868
2200
  for (const [id, row] of rowsById) {
1869
2201
  if (row.deleted_at !== void 0) continue;
@@ -1879,7 +2211,7 @@ async function executeNodeBulkGetOrCreateByConstraint(ctx, kind, constraintName,
1879
2211
  const constraint = resolveConstraint(ctx.graph, kind, constraintName);
1880
2212
  const validated = validateAndComputeKeys(nodeKind, kind, constraint, items);
1881
2213
  const uniqueKeys = collectUniqueKeys(validated);
1882
- const kindsToCheck = chunkFQPEMEWX_cjs.getKindsForUniquenessCheck(
2214
+ const kindsToCheck = chunkCRZ56SZU_cjs.uniquenessProbeKinds(
1883
2215
  kind,
1884
2216
  constraint.scope,
1885
2217
  ctx.registry
@@ -1887,6 +2219,7 @@ async function executeNodeBulkGetOrCreateByConstraint(ctx, kind, constraintName,
1887
2219
  async function attempt() {
1888
2220
  const existingByKey = uniqueKeys.length > 0 ? await batchCheckUniqueAcrossKinds(
1889
2221
  backend,
2222
+ ctx.uniqueSidecarBatch,
1890
2223
  ctx.graphId,
1891
2224
  constraint.name,
1892
2225
  uniqueKeys,
@@ -1982,16 +2315,20 @@ async function executeNodeBulkGetOrCreateByConstraint(ctx, kind, constraintName,
1982
2315
  try {
1983
2316
  return await attempt();
1984
2317
  } catch (error) {
1985
- if (!(error instanceof chunkMRDBBHIZ_cjs.UniquenessError)) throw error;
2318
+ if (!(error instanceof chunkX4GDXBOP_cjs.UniquenessError)) throw error;
1986
2319
  return attempt();
1987
2320
  }
1988
2321
  }
1989
2322
 
1990
2323
  exports.assertClearValidToSupported = assertClearValidToSupported;
1991
2324
  exports.assertValidityEndMutation = assertValidityEndMutation;
2325
+ exports.assertsStoredWindowState = assertsStoredWindowState;
1992
2326
  exports.checkCardinalityConstraint = checkCardinalityConstraint;
1993
- exports.createNodeBatchValidationBackend = createNodeBatchValidationBackend;
2327
+ exports.checkDisjointnessConstraint = checkDisjointnessConstraint;
2328
+ exports.createEdgeBatchValidationBackend = createEdgeBatchValidationBackend;
2329
+ exports.createNodeBatchValidationSeams = createNodeBatchValidationSeams;
1994
2330
  exports.edgeWriteNeedsConstraintFence = edgeWriteNeedsConstraintFence;
2331
+ exports.edgeWritePlan = edgeWritePlan;
1995
2332
  exports.executeNodeBulkFindByConstraint = executeNodeBulkFindByConstraint;
1996
2333
  exports.executeNodeBulkFindByIndex = executeNodeBulkFindByIndex;
1997
2334
  exports.executeNodeBulkGetOrCreateByConstraint = executeNodeBulkGetOrCreateByConstraint;
@@ -2006,13 +2343,18 @@ exports.executeNodeHardDelete = executeNodeHardDelete;
2006
2343
  exports.executeNodeUpdate = executeNodeUpdate;
2007
2344
  exports.executeNodeUpdateWhere = executeNodeUpdateWhere;
2008
2345
  exports.executeNodeUpsertUpdate = executeNodeUpsertUpdate;
2346
+ exports.graphOwesClaims = graphOwesClaims;
2347
+ exports.mixedWritePlan = mixedWritePlan;
2009
2348
  exports.nodeUpsertDirtyCheck = nodeUpsertDirtyCheck;
2010
2349
  exports.primeBatchValidationCaches = primeBatchValidationCaches;
2011
2350
  exports.rowToEdge = rowToEdge;
2012
2351
  exports.rowToEdgeMeta = rowToEdgeMeta;
2013
2352
  exports.rowToNode = rowToNode;
2014
2353
  exports.rowToNodeMeta = rowToNodeMeta;
2354
+ exports.runHookedWritePlan = runHookedWritePlan;
2355
+ exports.runWritePlan = runWritePlan;
2356
+ exports.unfencedTarget = unfencedTarget;
2015
2357
  exports.validityEndAfterMutation = validityEndAfterMutation;
2016
2358
  exports.withAlreadyExistsTranslation = withAlreadyExistsTranslation;
2017
- //# sourceMappingURL=chunk-JB6T4GLL.cjs.map
2018
- //# sourceMappingURL=chunk-JB6T4GLL.cjs.map
2359
+ //# sourceMappingURL=chunk-2KCTP3U2.cjs.map
2360
+ //# sourceMappingURL=chunk-2KCTP3U2.cjs.map