@nicia-ai/typegraph 0.46.2 → 0.48.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 (310) hide show
  1. package/README.md +20 -1
  2. package/dist/backend/drizzle/indexes.cjs +9 -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 +5 -5
  6. package/dist/backend/index.cjs +58 -49
  7. package/dist/backend/index.d.cts +37 -55
  8. package/dist/backend/index.d.ts +37 -55
  9. package/dist/backend/index.js +11 -10
  10. package/dist/backend/postgres/index.cjs +27 -26
  11. package/dist/backend/postgres/index.d.cts +21 -7
  12. package/dist/backend/postgres/index.d.ts +21 -7
  13. package/dist/backend/postgres/index.js +14 -13
  14. package/dist/backend/postgres/pglite-store.cjs +34 -33
  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 +30 -29
  19. package/dist/backend/postgres/pglite-store.js.map +1 -1
  20. package/dist/backend/postgres/pglite.cjs +16 -15
  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 +15 -14
  24. package/dist/backend/sqlite/index.cjs +24 -23
  25. package/dist/backend/sqlite/index.d.cts +20 -7
  26. package/dist/backend/sqlite/index.d.ts +20 -7
  27. package/dist/backend/sqlite/index.js +12 -11
  28. package/dist/backend/sqlite/libsql.cjs +19 -18
  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 +14 -13
  33. package/dist/backend/sqlite/libsql.js.map +1 -1
  34. package/dist/backend/sqlite/local-store.cjs +35 -34
  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 +31 -30
  39. package/dist/backend/sqlite/local-store.js.map +1 -1
  40. package/dist/backend/sqlite/local.cjs +17 -16
  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 +15 -14
  44. package/dist/{chunk-TCT66A7N.cjs → chunk-26YKDNUD.cjs} +10 -10
  45. package/dist/{chunk-TCT66A7N.cjs.map → chunk-26YKDNUD.cjs.map} +1 -1
  46. package/dist/{chunk-E4OSGBCM.cjs → chunk-2HIYYMWY.cjs} +139 -136
  47. package/dist/chunk-2HIYYMWY.cjs.map +1 -0
  48. package/dist/chunk-2QGYQBS2.cjs +161 -0
  49. package/dist/chunk-2QGYQBS2.cjs.map +1 -0
  50. package/dist/{chunk-GWXXHOLU.js → chunk-2SYZXD54.js} +21 -18
  51. package/dist/chunk-2SYZXD54.js.map +1 -0
  52. package/dist/{chunk-KA4L2NZ3.js → chunk-2TYSSBU5.js} +14 -14
  53. package/dist/{chunk-KA4L2NZ3.js.map → chunk-2TYSSBU5.js.map} +1 -1
  54. package/dist/{chunk-QOJ2L2AD.js → chunk-3DMMGT6S.js} +3 -3
  55. package/dist/{chunk-QOJ2L2AD.js.map → chunk-3DMMGT6S.js.map} +1 -1
  56. package/dist/{chunk-F36KZDFX.cjs → chunk-3FPR224C.cjs} +91 -91
  57. package/dist/{chunk-F36KZDFX.cjs.map → chunk-3FPR224C.cjs.map} +1 -1
  58. package/dist/{chunk-32UETY6S.cjs → chunk-3KOY4FH3.cjs} +207 -28
  59. package/dist/chunk-3KOY4FH3.cjs.map +1 -0
  60. package/dist/{chunk-QU7QLJA4.cjs → chunk-3U5ABFDW.cjs} +26 -26
  61. package/dist/{chunk-QU7QLJA4.cjs.map → chunk-3U5ABFDW.cjs.map} +1 -1
  62. package/dist/{chunk-RFDEYLIK.js → chunk-4WMMBDS5.js} +7 -7
  63. package/dist/chunk-4WMMBDS5.js.map +1 -0
  64. package/dist/{chunk-R7EWHKID.js → chunk-5K2BKEBD.js} +19 -145
  65. package/dist/chunk-5K2BKEBD.js.map +1 -0
  66. package/dist/chunk-5PRKMB24.cjs +124 -0
  67. package/dist/chunk-5PRKMB24.cjs.map +1 -0
  68. package/dist/chunk-6LN7FIVU.js +107 -0
  69. package/dist/chunk-6LN7FIVU.js.map +1 -0
  70. package/dist/{chunk-D6GCNNMK.cjs → chunk-6NGW27EO.cjs} +10 -10
  71. package/dist/{chunk-D6GCNNMK.cjs.map → chunk-6NGW27EO.cjs.map} +1 -1
  72. package/dist/{chunk-WHS2Y43J.js → chunk-6SWPJEYN.js} +5 -5
  73. package/dist/{chunk-WHS2Y43J.js.map → chunk-6SWPJEYN.js.map} +1 -1
  74. package/dist/{chunk-7TKNK32B.js → chunk-7SQSZN2J.js} +5 -5
  75. package/dist/{chunk-7TKNK32B.js.map → chunk-7SQSZN2J.js.map} +1 -1
  76. package/dist/{chunk-UTVQPZPN.cjs → chunk-7XUYFFR4.cjs} +20 -20
  77. package/dist/chunk-7XUYFFR4.cjs.map +1 -0
  78. package/dist/{chunk-KXSMF6PL.js → chunk-ACGSAMD3.js} +39 -34
  79. package/dist/chunk-ACGSAMD3.js.map +1 -0
  80. package/dist/{chunk-PYKF7UIL.cjs → chunk-AOSSQDVO.cjs} +13 -13
  81. package/dist/{chunk-PYKF7UIL.cjs.map → chunk-AOSSQDVO.cjs.map} +1 -1
  82. package/dist/{chunk-AT3MLMJV.js → chunk-AX6JGVTZ.js} +91 -20
  83. package/dist/chunk-AX6JGVTZ.js.map +1 -0
  84. package/dist/{chunk-WA64ZSCA.cjs → chunk-BFUOME67.cjs} +11 -11
  85. package/dist/{chunk-WA64ZSCA.cjs.map → chunk-BFUOME67.cjs.map} +1 -1
  86. package/dist/{chunk-YQ4JONWE.js → chunk-BRRP76WO.js} +401 -131
  87. package/dist/chunk-BRRP76WO.js.map +1 -0
  88. package/dist/{chunk-FCIZNUW5.js → chunk-CHAOFCHV.js} +3 -3
  89. package/dist/{chunk-FCIZNUW5.js.map → chunk-CHAOFCHV.js.map} +1 -1
  90. package/dist/chunk-CICO5GXD.cjs +12 -0
  91. package/dist/{chunk-73MWKDFK.cjs.map → chunk-CICO5GXD.cjs.map} +1 -1
  92. package/dist/{chunk-S3G5VLSW.js → chunk-CT3ZKTOF.js} +7 -6
  93. package/dist/chunk-CT3ZKTOF.js.map +1 -0
  94. package/dist/{chunk-SXWLLQ3D.js → chunk-D5R42W5D.js} +4 -4
  95. package/dist/{chunk-SXWLLQ3D.js.map → chunk-D5R42W5D.js.map} +1 -1
  96. package/dist/{chunk-BZZI7B43.cjs → chunk-DO7SAMEK.cjs} +47 -47
  97. package/dist/{chunk-BZZI7B43.cjs.map → chunk-DO7SAMEK.cjs.map} +1 -1
  98. package/dist/chunk-DZAICA5J.js +147 -0
  99. package/dist/chunk-DZAICA5J.js.map +1 -0
  100. package/dist/{chunk-2ZWM2RFH.cjs → chunk-EDN4Y4ZG.cjs} +9 -9
  101. package/dist/{chunk-2ZWM2RFH.cjs.map → chunk-EDN4Y4ZG.cjs.map} +1 -1
  102. package/dist/{chunk-A4R3H7RU.cjs → chunk-EZEEWCFJ.cjs} +264 -361
  103. package/dist/chunk-EZEEWCFJ.cjs.map +1 -0
  104. package/dist/{chunk-BEB4OFZF.cjs → chunk-FA2AFWLP.cjs} +51 -59
  105. package/dist/chunk-FA2AFWLP.cjs.map +1 -0
  106. package/dist/{chunk-ZBVZ7HXD.cjs → chunk-FQPEMEWX.cjs} +12 -12
  107. package/dist/{chunk-ZBVZ7HXD.cjs.map → chunk-FQPEMEWX.cjs.map} +1 -1
  108. package/dist/{chunk-LNIWCQR4.js → chunk-GLHXM7C4.js} +3 -3
  109. package/dist/{chunk-LNIWCQR4.js.map → chunk-GLHXM7C4.js.map} +1 -1
  110. package/dist/{chunk-6BD6ZBKT.cjs → chunk-GYEG3ZLZ.cjs} +10 -10
  111. package/dist/{chunk-6BD6ZBKT.cjs.map → chunk-GYEG3ZLZ.cjs.map} +1 -1
  112. package/dist/{chunk-A7NMUYEL.cjs → chunk-HDL2ARHX.cjs} +27 -27
  113. package/dist/{chunk-A7NMUYEL.cjs.map → chunk-HDL2ARHX.cjs.map} +1 -1
  114. package/dist/{chunk-5ZJOB5YS.js → chunk-HEV35TGT.js} +4 -4
  115. package/dist/{chunk-5ZJOB5YS.js.map → chunk-HEV35TGT.js.map} +1 -1
  116. package/dist/{chunk-LHYSY6SE.js → chunk-I4GAZH5Z.js} +186 -9
  117. package/dist/chunk-I4GAZH5Z.js.map +1 -0
  118. package/dist/{chunk-BQM5P2NO.cjs → chunk-JB6T4GLL.cjs} +260 -223
  119. package/dist/chunk-JB6T4GLL.cjs.map +1 -0
  120. package/dist/{chunk-QPOQX2DI.cjs → chunk-JFRT7S3B.cjs} +1026 -369
  121. package/dist/chunk-JFRT7S3B.cjs.map +1 -0
  122. package/dist/{chunk-JCNTKRAK.js → chunk-JONXFAPO.js} +5 -5
  123. package/dist/{chunk-JCNTKRAK.js.map → chunk-JONXFAPO.js.map} +1 -1
  124. package/dist/{chunk-WEJHA7AD.js → chunk-KF6K7TGH.js} +109 -75
  125. package/dist/chunk-KF6K7TGH.js.map +1 -0
  126. package/dist/{chunk-EDJDDY6H.js → chunk-KKBDXCLQ.js} +4 -4
  127. package/dist/{chunk-EDJDDY6H.js.map → chunk-KKBDXCLQ.js.map} +1 -1
  128. package/dist/{chunk-ZHOAZD7Q.cjs → chunk-L3LQNR34.cjs} +161 -161
  129. package/dist/{chunk-ZHOAZD7Q.cjs.map → chunk-L3LQNR34.cjs.map} +1 -1
  130. package/dist/{chunk-AF3TWL5C.cjs → chunk-LRQKXRXO.cjs} +4 -4
  131. package/dist/{chunk-AF3TWL5C.cjs.map → chunk-LRQKXRXO.cjs.map} +1 -1
  132. package/dist/chunk-MKJ4KXL5.cjs +12 -0
  133. package/dist/{chunk-6LAXM4J2.cjs.map → chunk-MKJ4KXL5.cjs.map} +1 -1
  134. package/dist/{chunk-KCH7WQA5.cjs → chunk-MRDBBHIZ.cjs} +48 -2
  135. package/dist/chunk-MRDBBHIZ.cjs.map +1 -0
  136. package/dist/{chunk-FXNHZFZV.js → chunk-MYKHJI2J.js} +3 -3
  137. package/dist/{chunk-FXNHZFZV.js.map → chunk-MYKHJI2J.js.map} +1 -1
  138. package/dist/{chunk-Z43KWLZF.js → chunk-NACVVDWB.js} +213 -12
  139. package/dist/chunk-NACVVDWB.js.map +1 -0
  140. package/dist/{chunk-72WUT4GG.js → chunk-NVY5CJFP.js} +4 -4
  141. package/dist/{chunk-72WUT4GG.js.map → chunk-NVY5CJFP.js.map} +1 -1
  142. package/dist/{chunk-WYFB7BN3.js → chunk-OD4SSY2U.js} +166 -48
  143. package/dist/chunk-OD4SSY2U.js.map +1 -0
  144. package/dist/{chunk-ZIH42CRX.cjs → chunk-OI2GQ25X.cjs} +7 -7
  145. package/dist/{chunk-ZIH42CRX.cjs.map → chunk-OI2GQ25X.cjs.map} +1 -1
  146. package/dist/{chunk-AU3IJNNP.js → chunk-OMZ37BM2.js} +5 -5
  147. package/dist/{chunk-AU3IJNNP.js.map → chunk-OMZ37BM2.js.map} +1 -1
  148. package/dist/{chunk-C4DYN2SD.cjs → chunk-OORXGFL5.cjs} +48 -48
  149. package/dist/{chunk-C4DYN2SD.cjs.map → chunk-OORXGFL5.cjs.map} +1 -1
  150. package/dist/{chunk-HNYLMPQQ.cjs → chunk-OTUPEF2W.cjs} +149 -78
  151. package/dist/chunk-OTUPEF2W.cjs.map +1 -0
  152. package/dist/{chunk-BRN3RGD2.js → chunk-OVI7IXYX.js} +3 -3
  153. package/dist/{chunk-BRN3RGD2.js.map → chunk-OVI7IXYX.js.map} +1 -1
  154. package/dist/{chunk-WMKEGJG4.js → chunk-P6YLZTRE.js} +3 -3
  155. package/dist/{chunk-WMKEGJG4.js.map → chunk-P6YLZTRE.js.map} +1 -1
  156. package/dist/{chunk-C2ZP5YS6.cjs → chunk-PFBRJBUL.cjs} +278 -160
  157. package/dist/chunk-PFBRJBUL.cjs.map +1 -0
  158. package/dist/{chunk-EJSYWAEV.js → chunk-QTD6HX4O.js} +5 -5
  159. package/dist/{chunk-EJSYWAEV.js.map → chunk-QTD6HX4O.js.map} +1 -1
  160. package/dist/{chunk-JL5UEBWT.cjs → chunk-ROR5ZR6A.cjs} +45 -45
  161. package/dist/{chunk-JL5UEBWT.cjs.map → chunk-ROR5ZR6A.cjs.map} +1 -1
  162. package/dist/{chunk-EDHV4CBU.js → chunk-S5TERQVW.js} +37 -134
  163. package/dist/chunk-S5TERQVW.js.map +1 -0
  164. package/dist/{chunk-FSLTU57P.js → chunk-SDBBMD4N.js} +3 -3
  165. package/dist/{chunk-FSLTU57P.js.map → chunk-SDBBMD4N.js.map} +1 -1
  166. package/dist/{chunk-36LIJXWC.js → chunk-SHFBB23Q.js} +4 -4
  167. package/dist/{chunk-36LIJXWC.js.map → chunk-SHFBB23Q.js.map} +1 -1
  168. package/dist/chunk-SIT26LAZ.cjs +614 -0
  169. package/dist/chunk-SIT26LAZ.cjs.map +1 -0
  170. package/dist/{chunk-C6KE2HSQ.cjs → chunk-SR725PWF.cjs} +1662 -1392
  171. package/dist/chunk-SR725PWF.cjs.map +1 -0
  172. package/dist/{chunk-S7WIRFNS.cjs → chunk-TKZXMWQF.cjs} +13 -12
  173. package/dist/chunk-TKZXMWQF.cjs.map +1 -0
  174. package/dist/{chunk-5PDSCELM.cjs → chunk-TQHGE7UC.cjs} +29 -164
  175. package/dist/chunk-TQHGE7UC.cjs.map +1 -0
  176. package/dist/{chunk-XBHRKLZU.cjs → chunk-TUNPBZY3.cjs} +4 -4
  177. package/dist/{chunk-XBHRKLZU.cjs.map → chunk-TUNPBZY3.cjs.map} +1 -1
  178. package/dist/{chunk-KOAI3KIV.cjs → chunk-TZEGUG6D.cjs} +4 -4
  179. package/dist/{chunk-KOAI3KIV.cjs.map → chunk-TZEGUG6D.cjs.map} +1 -1
  180. package/dist/chunk-UGHG7PGX.js +592 -0
  181. package/dist/chunk-UGHG7PGX.js.map +1 -0
  182. package/dist/{chunk-N3QTGPC7.cjs → chunk-UMGZDVOA.cjs} +303 -101
  183. package/dist/chunk-UMGZDVOA.cjs.map +1 -0
  184. package/dist/{chunk-RHDOAQCT.cjs → chunk-WCCATHMB.cjs} +140 -135
  185. package/dist/chunk-WCCATHMB.cjs.map +1 -0
  186. package/dist/{chunk-DYPRZ53S.cjs → chunk-WODMN3Q2.cjs} +27 -27
  187. package/dist/{chunk-DYPRZ53S.cjs.map → chunk-WODMN3Q2.cjs.map} +1 -1
  188. package/dist/{chunk-OZJCH7ZS.js → chunk-XVWOYKIK.js} +3 -3
  189. package/dist/{chunk-OZJCH7ZS.js.map → chunk-XVWOYKIK.js.map} +1 -1
  190. package/dist/{chunk-IHRDX7K6.js → chunk-YIURNGXI.js} +46 -56
  191. package/dist/chunk-YIURNGXI.js.map +1 -0
  192. package/dist/{chunk-GWUWRZXW.js → chunk-YVF2EM7B.js} +3 -3
  193. package/dist/{chunk-GWUWRZXW.js.map → chunk-YVF2EM7B.js.map} +1 -1
  194. package/dist/{chunk-EAMVXR5B.js → chunk-ZDKTPBGV.js} +4 -4
  195. package/dist/{chunk-EAMVXR5B.js.map → chunk-ZDKTPBGV.js.map} +1 -1
  196. package/dist/{chunk-A2LJG5GM.js → chunk-ZFMCDJGB.js} +803 -148
  197. package/dist/chunk-ZFMCDJGB.js.map +1 -0
  198. package/dist/{chunk-62ZXBMSD.js → chunk-ZLONH2UD.js} +46 -3
  199. package/dist/chunk-ZLONH2UD.js.map +1 -0
  200. package/dist/core/index.cjs +28 -27
  201. package/dist/core/index.d.cts +4 -4
  202. package/dist/core/index.d.ts +4 -4
  203. package/dist/core/index.js +8 -7
  204. package/dist/ddl-BL1NZLMY.d.cts +78 -0
  205. package/dist/ddl-D_oW-EVO.d.ts +78 -0
  206. package/dist/graph-extension/index.cjs +20 -20
  207. package/dist/graph-extension/index.d.cts +4 -4
  208. package/dist/graph-extension/index.d.ts +4 -4
  209. package/dist/graph-extension/index.js +4 -4
  210. package/dist/graph-merge/index.cjs +3418 -706
  211. package/dist/graph-merge/index.cjs.map +1 -1
  212. package/dist/graph-merge/index.d.cts +550 -58
  213. package/dist/graph-merge/index.d.ts +550 -58
  214. package/dist/graph-merge/index.js +3191 -497
  215. package/dist/graph-merge/index.js.map +1 -1
  216. package/dist/{index-Deyu8IXL.d.ts → index-COs_z6nV.d.cts} +47 -3
  217. package/dist/{index-DrRS51Ld.d.cts → index-D7d1u2gr.d.ts} +47 -3
  218. package/dist/index.cjs +233 -216
  219. package/dist/index.cjs.map +1 -1
  220. package/dist/index.d.cts +12 -12
  221. package/dist/index.d.ts +12 -12
  222. package/dist/index.js +35 -34
  223. package/dist/index.js.map +1 -1
  224. package/dist/indexes/index.cjs +13 -13
  225. package/dist/indexes/index.d.cts +4 -4
  226. package/dist/indexes/index.d.ts +4 -4
  227. package/dist/indexes/index.js +6 -6
  228. package/dist/interchange/index.cjs +53 -52
  229. package/dist/interchange/index.cjs.map +1 -1
  230. package/dist/interchange/index.d.cts +17 -13
  231. package/dist/interchange/index.d.ts +17 -13
  232. package/dist/interchange/index.js +17 -16
  233. package/dist/interchange/index.js.map +1 -1
  234. package/dist/{manager-ptr3JLRP.d.cts → manager-CYaff3n3.d.cts} +2 -2
  235. package/dist/{manager-DX983gJ0.d.ts → manager-D9eRT_ns.d.ts} +2 -2
  236. package/dist/{materialize-indexes-CpXoggWU.d.ts → materialize-indexes-DJ3ykH59.d.ts} +1 -1
  237. package/dist/{materialize-indexes-BXz77YqO.d.cts → materialize-indexes-DTtAnvfY.d.cts} +1 -1
  238. package/dist/{postgres-DwgEXSPI.d.cts → postgres-CcL4bAHS.d.ts} +1 -1
  239. package/dist/{postgres-QdOMHTBz.d.ts → postgres-DMj39MEu.d.cts} +1 -1
  240. package/dist/profiler/index.d.cts +9 -9
  241. package/dist/profiler/index.d.ts +9 -9
  242. package/dist/provenance/index.cjs +46 -46
  243. package/dist/provenance/index.cjs.map +1 -1
  244. package/dist/provenance/index.d.cts +7 -7
  245. package/dist/provenance/index.d.ts +7 -7
  246. package/dist/provenance/index.js +13 -13
  247. package/dist/provenance/index.js.map +1 -1
  248. package/dist/repair-validity-windows-BFNZvd_H.d.cts +166 -0
  249. package/dist/repair-validity-windows-DlUSqwCg.d.ts +166 -0
  250. package/dist/schema/index.cjs +45 -44
  251. package/dist/schema/index.d.cts +6 -6
  252. package/dist/schema/index.d.ts +6 -6
  253. package/dist/schema/index.js +18 -17
  254. package/dist/{searchable-BOUuA83f.d.ts → searchable-DHJMh_nj.d.cts} +1 -1
  255. package/dist/{searchable-BrUh0pdc.d.cts → searchable-bpE1bBfc.d.ts} +1 -1
  256. package/dist/{sqlite-BfYcV61E.d.cts → sqlite-D7Oz0SQh.d.ts} +1 -1
  257. package/dist/{sqlite-DK40XVR1.d.ts → sqlite-YppHrNFb.d.cts} +1 -1
  258. package/dist/{store-FTqBpuJD.d.cts → store-JUVvtmR4.d.cts} +228 -92
  259. package/dist/{store-Bo1psfVZ.d.ts → store-UzrGvZOo.d.ts} +228 -92
  260. package/dist/{temporal-DPtn0HOu.d.ts → temporal-5GqpYCk2.d.cts} +1 -1
  261. package/dist/{temporal-CXewwLTB.d.cts → temporal-CbnLzTmM.d.ts} +1 -1
  262. package/dist/{types-Du78EvpN.d.ts → types-BqFZTQmV.d.cts} +60 -9
  263. package/dist/{types-Du78EvpN.d.cts → types-BqFZTQmV.d.ts} +60 -9
  264. package/dist/{types-CeT7xM4M.d.ts → types-Bx74kaTt.d.ts} +1 -1
  265. package/dist/{types-XR1nHERK.d.cts → types-CXAhpW-c.d.cts} +1 -1
  266. package/dist/{where-CJsp-YUf.d.cts → where-DI_Fqz-X.d.cts} +1 -1
  267. package/dist/{where-CMbFiWwp.d.ts → where-O-k2wgYm.d.ts} +1 -1
  268. package/package.json +1 -1
  269. package/dist/chunk-32UETY6S.cjs.map +0 -1
  270. package/dist/chunk-5PDSCELM.cjs.map +0 -1
  271. package/dist/chunk-62ZXBMSD.js.map +0 -1
  272. package/dist/chunk-6LAXM4J2.cjs +0 -12
  273. package/dist/chunk-73MWKDFK.cjs +0 -12
  274. package/dist/chunk-A2LJG5GM.js.map +0 -1
  275. package/dist/chunk-A4R3H7RU.cjs.map +0 -1
  276. package/dist/chunk-ANKOXPCC.cjs +0 -267
  277. package/dist/chunk-ANKOXPCC.cjs.map +0 -1
  278. package/dist/chunk-AT3MLMJV.js.map +0 -1
  279. package/dist/chunk-BEB4OFZF.cjs.map +0 -1
  280. package/dist/chunk-BQM5P2NO.cjs.map +0 -1
  281. package/dist/chunk-C2ZP5YS6.cjs.map +0 -1
  282. package/dist/chunk-C6KE2HSQ.cjs.map +0 -1
  283. package/dist/chunk-DSAWGCMP.js +0 -254
  284. package/dist/chunk-DSAWGCMP.js.map +0 -1
  285. package/dist/chunk-E4OSGBCM.cjs.map +0 -1
  286. package/dist/chunk-EDHV4CBU.js.map +0 -1
  287. package/dist/chunk-FA6Z7B5L.js +0 -244
  288. package/dist/chunk-FA6Z7B5L.js.map +0 -1
  289. package/dist/chunk-GVAMRRZR.cjs +0 -268
  290. package/dist/chunk-GVAMRRZR.cjs.map +0 -1
  291. package/dist/chunk-GWXXHOLU.js.map +0 -1
  292. package/dist/chunk-HNYLMPQQ.cjs.map +0 -1
  293. package/dist/chunk-IHRDX7K6.js.map +0 -1
  294. package/dist/chunk-KCH7WQA5.cjs.map +0 -1
  295. package/dist/chunk-KXSMF6PL.js.map +0 -1
  296. package/dist/chunk-LHYSY6SE.js.map +0 -1
  297. package/dist/chunk-N3QTGPC7.cjs.map +0 -1
  298. package/dist/chunk-QPOQX2DI.cjs.map +0 -1
  299. package/dist/chunk-R7EWHKID.js.map +0 -1
  300. package/dist/chunk-RFDEYLIK.js.map +0 -1
  301. package/dist/chunk-RHDOAQCT.cjs.map +0 -1
  302. package/dist/chunk-S3G5VLSW.js.map +0 -1
  303. package/dist/chunk-S7WIRFNS.cjs.map +0 -1
  304. package/dist/chunk-UTVQPZPN.cjs.map +0 -1
  305. package/dist/chunk-WEJHA7AD.js.map +0 -1
  306. package/dist/chunk-WYFB7BN3.js.map +0 -1
  307. package/dist/chunk-YQ4JONWE.js.map +0 -1
  308. package/dist/chunk-Z43KWLZF.js.map +0 -1
  309. package/dist/ddl-mE07h_EM.d.cts +0 -38
  310. package/dist/ddl-opIn8DfX.d.ts +0 -38
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var chunkA4R3H7RU_cjs = require('./chunk-A4R3H7RU.cjs');
4
- var chunkGVAMRRZR_cjs = require('./chunk-GVAMRRZR.cjs');
5
- var chunkANKOXPCC_cjs = require('./chunk-ANKOXPCC.cjs');
6
- var chunk5PDSCELM_cjs = require('./chunk-5PDSCELM.cjs');
7
- var chunkZHOAZD7Q_cjs = require('./chunk-ZHOAZD7Q.cjs');
8
- var chunk2ZWM2RFH_cjs = require('./chunk-2ZWM2RFH.cjs');
9
- var chunkKCH7WQA5_cjs = require('./chunk-KCH7WQA5.cjs');
3
+ var chunkEZEEWCFJ_cjs = require('./chunk-EZEEWCFJ.cjs');
4
+ var chunkSIT26LAZ_cjs = require('./chunk-SIT26LAZ.cjs');
5
+ var chunk5PRKMB24_cjs = require('./chunk-5PRKMB24.cjs');
6
+ var chunkTQHGE7UC_cjs = require('./chunk-TQHGE7UC.cjs');
7
+ var chunkL3LQNR34_cjs = require('./chunk-L3LQNR34.cjs');
8
+ var chunkEDN4Y4ZG_cjs = require('./chunk-EDN4Y4ZG.cjs');
9
+ var chunkMRDBBHIZ_cjs = require('./chunk-MRDBBHIZ.cjs');
10
10
  var chunkN66HCGCY_cjs = require('./chunk-N66HCGCY.cjs');
11
11
 
12
12
  // src/errors/validation.ts
@@ -30,7 +30,7 @@ function validateProps(schema, props, context) {
30
30
  }
31
31
  const issues = zodIssuesToValidationIssues(result.error);
32
32
  const location = buildLocationString(context);
33
- throw new chunkKCH7WQA5_cjs.ValidationError(
33
+ throw new chunkMRDBBHIZ_cjs.ValidationError(
34
34
  `Invalid ${context.entityType} props for ${location}: ${result.error.message}`,
35
35
  {
36
36
  entityType: context.entityType,
@@ -57,7 +57,7 @@ function validateEdgeProps(schema, props, context) {
57
57
  function wrapZodError(error, context) {
58
58
  const issues = zodIssuesToValidationIssues(error);
59
59
  const location = buildLocationString(context);
60
- return new chunkKCH7WQA5_cjs.ValidationError(
60
+ return new chunkMRDBBHIZ_cjs.ValidationError(
61
61
  `Validation failed for ${context.entityType} ${location}: ${error.message}`,
62
62
  {
63
63
  entityType: context.entityType,
@@ -70,7 +70,7 @@ function wrapZodError(error, context) {
70
70
  );
71
71
  }
72
72
  function createValidationError(message, issues, context) {
73
- return new chunkKCH7WQA5_cjs.ValidationError(message, {
73
+ return new chunkMRDBBHIZ_cjs.ValidationError(message, {
74
74
  ...context?.entityType !== void 0 && {
75
75
  entityType: context.entityType
76
76
  },
@@ -81,16 +81,11 @@ function createValidationError(message, issues, context) {
81
81
  });
82
82
  }
83
83
 
84
- // src/utils/tuple-key.ts
85
- function encodeTupleKey(values) {
86
- return JSON.stringify(values);
87
- }
88
-
89
84
  // src/identity/row-codec.ts
90
85
  function toCanonicalIdentityTimestamp(value) {
91
- const canonical = chunk5PDSCELM_cjs.canonicalizeDatabaseTimestamp(value);
86
+ const canonical = chunkTQHGE7UC_cjs.canonicalizeDatabaseTimestamp(value);
92
87
  if (canonical === void 0) {
93
- throw new chunkKCH7WQA5_cjs.ConfigurationError(
88
+ throw new chunkMRDBBHIZ_cjs.ConfigurationError(
94
89
  "Identity relation returned a timestamp that is not a representable instant.",
95
90
  { value },
96
91
  {
@@ -135,11 +130,11 @@ function toTransferAssertion(row) {
135
130
 
136
131
  // src/identity/reference.ts
137
132
  function identityReferenceKey(ref) {
138
- return encodeTupleKey([ref.kind, ref.id]);
133
+ return chunkEZEEWCFJ_cjs.encodeTupleKey([ref.kind, ref.id]);
139
134
  }
140
135
  function compareIdentityReferences(left, right) {
141
- const kindOrder = chunkA4R3H7RU_cjs.compareCodePoints(left.kind, right.kind);
142
- return kindOrder === 0 ? chunkA4R3H7RU_cjs.compareCodePoints(left.id, right.id) : kindOrder;
136
+ const kindOrder = chunkEZEEWCFJ_cjs.compareCodePoints(left.kind, right.kind);
137
+ return kindOrder === 0 ? chunkEZEEWCFJ_cjs.compareCodePoints(left.id, right.id) : kindOrder;
143
138
  }
144
139
  function normalizeIdentityPair(first, second) {
145
140
  return compareIdentityReferences(first, second) <= 0 ? [first, second] : [second, first];
@@ -174,12 +169,12 @@ function spanningDifferentAssertion(assertions, first, second) {
174
169
  // src/identity/sql-target.ts
175
170
  var MAX_REFERENCE_CHUNK_SIZE = 200;
176
171
  function identityChunkSize(target, input) {
177
- const parameterLimit = chunkA4R3H7RU_cjs.recordedBindParamBudget(target);
172
+ const parameterLimit = chunkEZEEWCFJ_cjs.recordedBindParamBudget(target);
178
173
  const chunkSize = Math.floor(
179
174
  (parameterLimit - input.fixedParameters) / input.parametersPerItem
180
175
  );
181
176
  if (chunkSize < 1) {
182
- throw new chunkKCH7WQA5_cjs.ConfigurationError(
177
+ throw new chunkMRDBBHIZ_cjs.ConfigurationError(
183
178
  "Operational Identity cannot fit this statement within the backend bind-parameter limit.",
184
179
  {
185
180
  code: "IDENTITY_BIND_BUDGET_TOO_SMALL",
@@ -193,7 +188,7 @@ function identityChunkSize(target, input) {
193
188
  }
194
189
  function requireStatementTarget(target) {
195
190
  if (target.executeStatement === void 0) {
196
- throw new chunkKCH7WQA5_cjs.ConfigurationError(
191
+ throw new chunkMRDBBHIZ_cjs.ConfigurationError(
197
192
  "Operational Identity requires statement execution support.",
198
193
  { code: "IDENTITY_REQUIRES_STATEMENT_EXECUTION" },
199
194
  {
@@ -203,7 +198,7 @@ function requireStatementTarget(target) {
203
198
  }
204
199
  }
205
200
  function identityWriterSlotError(cause) {
206
- return new chunkKCH7WQA5_cjs.ConfigurationError(
201
+ return new chunkMRDBBHIZ_cjs.ConfigurationError(
207
202
  "Operational Identity could not take the SQLite writer slot: this transaction was begun DEFERRED and another connection committed before the identity write, so its read snapshot is stale.",
208
203
  {
209
204
  code: "IDENTITY_TRANSACTION_NOT_WRITE_FENCED",
@@ -218,9 +213,9 @@ function identityWriterSlotError(cause) {
218
213
  async function executeIdentityStatement(target, statement) {
219
214
  requireStatementTarget(target);
220
215
  try {
221
- await target.executeStatement(chunk2ZWM2RFH_cjs.asCompiledStatementSql(statement));
216
+ await target.executeStatement(chunkEDN4Y4ZG_cjs.asCompiledStatementSql(statement));
222
217
  } catch (error) {
223
- if (!chunkGVAMRRZR_cjs.isSqliteStaleSnapshotError(error)) throw error;
218
+ if (!chunkSIT26LAZ_cjs.isSqliteStaleSnapshotError(error)) throw error;
224
219
  throw identityWriterSlotError(error);
225
220
  }
226
221
  }
@@ -234,7 +229,7 @@ function plainRef(ref) {
234
229
  function registeredPlainRef(ctx, ref) {
235
230
  const result = plainRef(ref);
236
231
  if (!ctx.registry.nodeKinds.has(result.kind)) {
237
- throw new chunkKCH7WQA5_cjs.KindNotFoundError(result.kind, "node", {
232
+ throw new chunkMRDBBHIZ_cjs.KindNotFoundError(result.kind, "node", {
238
233
  graphId: ctx.graphId
239
234
  });
240
235
  }
@@ -253,7 +248,7 @@ function normalizePair(first, second) {
253
248
  return normalizeIdentityPair(first, second);
254
249
  }
255
250
  function clampValidTo(timestamp, validFrom) {
256
- return chunkA4R3H7RU_cjs.compareCodePoints(timestamp, validFrom) < 0 ? validFrom : timestamp;
251
+ return chunkEZEEWCFJ_cjs.compareCodePoints(timestamp, validFrom) < 0 ? validFrom : timestamp;
257
252
  }
258
253
  function publicAssertion(row) {
259
254
  return {
@@ -274,7 +269,7 @@ function publicNodeRef(ref) {
274
269
  async function lockIdentityGraph(target, graphId) {
275
270
  if (target.dialect !== "postgres") return;
276
271
  await target.execute(
277
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
272
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
278
273
  SELECT pg_advisory_xact_lock(
279
274
  hashtext('typegraph:identity'),
280
275
  hashtext(${graphId})
@@ -286,14 +281,14 @@ async function lockIdentityEnablementNodes(target, schema) {
286
281
  if (target.dialect !== "postgres") return;
287
282
  await executeIdentityStatement(
288
283
  target,
289
- chunk2ZWM2RFH_cjs.sql`LOCK TABLE ${schema.nodesTable} IN SHARE MODE`
284
+ chunkEDN4Y4ZG_cjs.sql`LOCK TABLE ${schema.nodesTable} IN SHARE MODE`
290
285
  );
291
286
  }
292
287
  async function loadNodeSnapshot(target, schema, graphId, coordinate) {
293
- const sqlCoordinate = chunkA4R3H7RU_cjs.identitySqlCoordinate(coordinate, chunk5PDSCELM_cjs.nowIso());
288
+ const sqlCoordinate = chunkEZEEWCFJ_cjs.identitySqlCoordinate(coordinate, chunkTQHGE7UC_cjs.nowIso());
294
289
  const rows = await target.execute(
295
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(
296
- chunkA4R3H7RU_cjs.identityNodeSnapshotSource(schema, graphId, sqlCoordinate)
290
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(
291
+ chunkEZEEWCFJ_cjs.identityNodeSnapshotSource(schema, graphId, sqlCoordinate)
297
292
  )
298
293
  );
299
294
  return rows.map((row) => ({
@@ -319,7 +314,7 @@ async function loadCurrentStructuralClasses(target, schema, graphId, references)
319
314
  });
320
315
  if (uniqueReferences.length > chunkSize) {
321
316
  const combined = /* @__PURE__ */ new Map();
322
- for (const refChunk of chunkGVAMRRZR_cjs.chunk(uniqueReferences, chunkSize)) {
317
+ for (const refChunk of chunkSIT26LAZ_cjs.chunk(uniqueReferences, chunkSize)) {
323
318
  const classes2 = await loadCurrentStructuralClasses(
324
319
  target,
325
320
  schema,
@@ -330,12 +325,12 @@ async function loadCurrentStructuralClasses(target, schema, graphId, references)
330
325
  }
331
326
  return combined;
332
327
  }
333
- const seedRows = chunk2ZWM2RFH_cjs.sql.join(
334
- uniqueReferences.map((ref) => chunk2ZWM2RFH_cjs.sql`(${ref.kind}, ${ref.id})`),
335
- chunk2ZWM2RFH_cjs.sql`, `
328
+ const seedRows = chunkEDN4Y4ZG_cjs.sql.join(
329
+ uniqueReferences.map((ref) => chunkEDN4Y4ZG_cjs.sql`(${ref.kind}, ${ref.id})`),
330
+ chunkEDN4Y4ZG_cjs.sql`, `
336
331
  );
337
332
  const rows = await target.execute(
338
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
333
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
339
334
  WITH seeds(seed_kind, seed_id) AS (
340
335
  VALUES ${seedRows}
341
336
  ), anchors AS (
@@ -373,10 +368,10 @@ async function loadCurrentStructuralClasses(target, schema, graphId, references)
373
368
  );
374
369
  }
375
370
  async function loadCurrentVisibleMembers(target, schema, graphId, ref) {
376
- const now = chunk5PDSCELM_cjs.nowIso();
377
- const coordinate = chunkA4R3H7RU_cjs.identitySqlCoordinate(void 0, now);
371
+ const now = chunkTQHGE7UC_cjs.nowIso();
372
+ const coordinate = chunkEZEEWCFJ_cjs.identitySqlCoordinate(void 0, now);
378
373
  const rows = await target.execute(
379
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
374
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
380
375
  WITH anchor AS (
381
376
  SELECT class_kind, class_id
382
377
  FROM ${schema.identityClosureTable}
@@ -400,7 +395,7 @@ async function loadCurrentVisibleMembers(target, schema, graphId, ref) {
400
395
  WHERE n.graph_id = ${graphId}
401
396
  AND n.kind = m.kind
402
397
  AND n.id = m.id
403
- AND ${chunkA4R3H7RU_cjs.identityNodeVisibilitySql(coordinate, "n")}
398
+ AND ${chunkEZEEWCFJ_cjs.identityNodeVisibilitySql(coordinate, "n")}
404
399
  `)
405
400
  );
406
401
  const members = rows.map((row) => ({ kind: row.kind, id: row.id })).toSorted((left, right) => compareReferences(left, right));
@@ -435,7 +430,7 @@ async function loadHistoricalClasses(target, schema, graphId, references, coordi
435
430
  });
436
431
  if (uniqueReferences.length > chunkSize) {
437
432
  const combined = /* @__PURE__ */ new Map();
438
- for (const refChunk of chunkGVAMRRZR_cjs.chunk(uniqueReferences, chunkSize)) {
433
+ for (const refChunk of chunkSIT26LAZ_cjs.chunk(uniqueReferences, chunkSize)) {
439
434
  const classes = await loadHistoricalClasses(
440
435
  target,
441
436
  schema,
@@ -448,26 +443,26 @@ async function loadHistoricalClasses(target, schema, graphId, references, coordi
448
443
  }
449
444
  return combined;
450
445
  }
451
- const currentInstant = chunk5PDSCELM_cjs.nowIso();
452
- const sqlCoordinate = chunkA4R3H7RU_cjs.identitySqlCoordinate(coordinate, currentInstant);
453
- const seeds = chunk2ZWM2RFH_cjs.sql.join(
454
- uniqueReferences.map((ref) => chunk2ZWM2RFH_cjs.sql`(${ref.kind}, ${ref.id})`),
455
- chunk2ZWM2RFH_cjs.sql`, `
446
+ const currentInstant = chunkTQHGE7UC_cjs.nowIso();
447
+ const sqlCoordinate = chunkEZEEWCFJ_cjs.identitySqlCoordinate(coordinate, currentInstant);
448
+ const seeds = chunkEDN4Y4ZG_cjs.sql.join(
449
+ uniqueReferences.map((ref) => chunkEDN4Y4ZG_cjs.sql`(${ref.kind}, ${ref.id})`),
450
+ chunkEDN4Y4ZG_cjs.sql`, `
456
451
  );
457
- const reconstruction = chunkA4R3H7RU_cjs.historicalIdentityReconstructionCtes({
452
+ const reconstruction = chunkEZEEWCFJ_cjs.historicalIdentityReconstructionCtes({
458
453
  schema,
459
454
  graphId,
460
455
  coordinate: sqlCoordinate,
461
- seedSource: chunk2ZWM2RFH_cjs.sql`VALUES ${seeds}`,
456
+ seedSource: chunkEDN4Y4ZG_cjs.sql`VALUES ${seeds}`,
462
457
  sameIdAcrossKinds
463
458
  });
464
459
  const rows = await target.execute(
465
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
460
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
466
461
  WITH RECURSIVE
467
462
  ${reconstruction}
468
463
  SELECT member.seed_kind, member.seed_id,
469
464
  member.kind AS member_kind, member.id AS member_id,
470
- CASE WHEN ${chunkA4R3H7RU_cjs.identityNodeVisibilitySql(sqlCoordinate, "n")}
465
+ CASE WHEN ${chunkEZEEWCFJ_cjs.identityNodeVisibilitySql(sqlCoordinate, "n")}
471
466
  THEN 1 ELSE 0 END AS is_visible
472
467
  FROM identity_members member
473
468
  JOIN node_snapshot n ON n.kind = member.kind AND n.id = member.id
@@ -518,24 +513,24 @@ function visibleMembersAtCoordinate(ctx, ref) {
518
513
  );
519
514
  }
520
515
  async function loadAssertions(target, schema, graphId, coordinate, currentInstant) {
521
- const source = chunkA4R3H7RU_cjs.identityAssertionSnapshotSource(
516
+ const source = chunkEZEEWCFJ_cjs.identityAssertionSnapshotSource(
522
517
  schema,
523
518
  graphId,
524
- chunkA4R3H7RU_cjs.identitySqlCoordinate(coordinate, currentInstant),
519
+ chunkEZEEWCFJ_cjs.identitySqlCoordinate(coordinate, currentInstant),
525
520
  void 0
526
521
  );
527
522
  const rows = await target.execute(
528
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(source)
523
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(source)
529
524
  );
530
525
  return rows.map((row) => normalizeIdentityAssertionRow(row));
531
526
  }
532
527
  function referenceCondition(kindColumn, idColumn, references) {
533
- if (references.length === 0) return chunk2ZWM2RFH_cjs.sql`1 = 0`;
534
- return chunk2ZWM2RFH_cjs.sql`(${chunk2ZWM2RFH_cjs.sql.join(
528
+ if (references.length === 0) return chunkEDN4Y4ZG_cjs.sql`1 = 0`;
529
+ return chunkEDN4Y4ZG_cjs.sql`(${chunkEDN4Y4ZG_cjs.sql.join(
535
530
  references.map(
536
- (ref) => chunk2ZWM2RFH_cjs.sql`(${kindColumn} = ${ref.kind} AND ${idColumn} = ${ref.id})`
531
+ (ref) => chunkEDN4Y4ZG_cjs.sql`(${kindColumn} = ${ref.kind} AND ${idColumn} = ${ref.id})`
537
532
  ),
538
- chunk2ZWM2RFH_cjs.sql` OR `
533
+ chunkEDN4Y4ZG_cjs.sql` OR `
539
534
  )})`;
540
535
  }
541
536
  async function loadAssertionsTouching(target, schema, graphId, references, coordinate, relation) {
@@ -547,7 +542,7 @@ async function loadAssertionsTouching(target, schema, graphId, references, coord
547
542
  });
548
543
  if (references.length > chunkSize) {
549
544
  const byId = /* @__PURE__ */ new Map();
550
- for (const refChunk of chunkGVAMRRZR_cjs.chunk(references, chunkSize)) {
545
+ for (const refChunk of chunkSIT26LAZ_cjs.chunk(references, chunkSize)) {
551
546
  const assertions = await loadAssertionsTouching(
552
547
  target,
553
548
  schema,
@@ -560,25 +555,25 @@ async function loadAssertionsTouching(target, schema, graphId, references, coord
560
555
  }
561
556
  return [...byId.values()];
562
557
  }
563
- const source = chunkA4R3H7RU_cjs.identityAssertionSnapshotSource(
558
+ const source = chunkEZEEWCFJ_cjs.identityAssertionSnapshotSource(
564
559
  schema,
565
560
  graphId,
566
- chunkA4R3H7RU_cjs.identitySqlCoordinate(coordinate, chunk5PDSCELM_cjs.nowIso()),
561
+ chunkEZEEWCFJ_cjs.identitySqlCoordinate(coordinate, chunkTQHGE7UC_cjs.nowIso()),
567
562
  relation
568
563
  );
569
564
  const aMatches = referenceCondition(
570
- chunk2ZWM2RFH_cjs.sql`identity_assertions.a_kind`,
571
- chunk2ZWM2RFH_cjs.sql`identity_assertions.a_id`,
565
+ chunkEDN4Y4ZG_cjs.sql`identity_assertions.a_kind`,
566
+ chunkEDN4Y4ZG_cjs.sql`identity_assertions.a_id`,
572
567
  references
573
568
  );
574
569
  const bMatches = referenceCondition(
575
- chunk2ZWM2RFH_cjs.sql`identity_assertions.b_kind`,
576
- chunk2ZWM2RFH_cjs.sql`identity_assertions.b_id`,
570
+ chunkEDN4Y4ZG_cjs.sql`identity_assertions.b_kind`,
571
+ chunkEDN4Y4ZG_cjs.sql`identity_assertions.b_id`,
577
572
  references
578
573
  );
579
574
  const rows = await target.execute(
580
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
581
- SELECT ${chunkA4R3H7RU_cjs.IDENTITY_ASSERTION_COLUMNS}
575
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
576
+ SELECT ${chunkEZEEWCFJ_cjs.IDENTITY_ASSERTION_COLUMNS}
582
577
  FROM (${source}) identity_assertions
583
578
  WHERE ${aMatches} OR ${bMatches}
584
579
  `)
@@ -599,11 +594,11 @@ async function loadSpanningDifferentAssertion(target, schema, graphId, firstClas
599
594
 
600
595
  // src/identity/interchange-read.ts
601
596
  function codePointOrderedAssertionId(target) {
602
- return chunkZHOAZD7Q_cjs.getDialect(target.dialect).binaryText(chunk2ZWM2RFH_cjs.sql`identity_assertions.id`);
597
+ return chunkL3LQNR34_cjs.getDialect(target.dialect).binaryText(chunkEDN4Y4ZG_cjs.sql`identity_assertions.id`);
603
598
  }
604
599
  async function readIdentityAssertionPageAtTarget(ctx, target, mode, options) {
605
600
  if (!Number.isSafeInteger(options.limit) || options.limit <= 0) {
606
- throw new chunkKCH7WQA5_cjs.ConfigurationError(
601
+ throw new chunkMRDBBHIZ_cjs.ConfigurationError(
607
602
  "Identity assertion page limit must be a positive safe integer.",
608
603
  { limit: options.limit }
609
604
  );
@@ -615,17 +610,17 @@ async function readIdentityAssertionPageAtTarget(ctx, target, mode, options) {
615
610
  parametersPerItem: 2
616
611
  });
617
612
  const filterKindsInMemory = nodeKinds !== void 0 && nodeKinds.length > kindFilterChunkSize;
618
- const kindFilter = nodeKinds === void 0 ? chunk2ZWM2RFH_cjs.sql`` : nodeKinds.length === 0 ? chunk2ZWM2RFH_cjs.sql`AND 1 = 0` : filterKindsInMemory ? chunk2ZWM2RFH_cjs.sql`` : chunk2ZWM2RFH_cjs.sql`
619
- AND identity_assertions.a_kind IN (${chunk2ZWM2RFH_cjs.sql.join(
620
- nodeKinds.map((kind) => chunk2ZWM2RFH_cjs.sql`${kind}`),
621
- chunk2ZWM2RFH_cjs.sql`, `
613
+ const kindFilter = nodeKinds === void 0 ? chunkEDN4Y4ZG_cjs.sql`` : nodeKinds.length === 0 ? chunkEDN4Y4ZG_cjs.sql`AND 1 = 0` : filterKindsInMemory ? chunkEDN4Y4ZG_cjs.sql`` : chunkEDN4Y4ZG_cjs.sql`
614
+ AND identity_assertions.a_kind IN (${chunkEDN4Y4ZG_cjs.sql.join(
615
+ nodeKinds.map((kind) => chunkEDN4Y4ZG_cjs.sql`${kind}`),
616
+ chunkEDN4Y4ZG_cjs.sql`, `
622
617
  )})
623
- AND identity_assertions.b_kind IN (${chunk2ZWM2RFH_cjs.sql.join(
624
- nodeKinds.map((kind) => chunk2ZWM2RFH_cjs.sql`${kind}`),
625
- chunk2ZWM2RFH_cjs.sql`, `
618
+ AND identity_assertions.b_kind IN (${chunkEDN4Y4ZG_cjs.sql.join(
619
+ nodeKinds.map((kind) => chunkEDN4Y4ZG_cjs.sql`${kind}`),
620
+ chunkEDN4Y4ZG_cjs.sql`, `
626
621
  )})
627
622
  `;
628
- const liveEndpointJoins = options.includeDeleted === false ? chunk2ZWM2RFH_cjs.sql`
623
+ const liveEndpointJoins = options.includeDeleted === false ? chunkEDN4Y4ZG_cjs.sql`
629
624
  JOIN ${ctx.schema.nodesTable} identity_a_node
630
625
  ON identity_a_node.graph_id = identity_assertions.graph_id
631
626
  AND identity_a_node.kind = identity_assertions.a_kind
@@ -636,10 +631,10 @@ async function readIdentityAssertionPageAtTarget(ctx, target, mode, options) {
636
631
  AND identity_b_node.kind = identity_assertions.b_kind
637
632
  AND identity_b_node.id = identity_assertions.b_id
638
633
  AND identity_b_node.deleted_at IS NULL
639
- ` : chunk2ZWM2RFH_cjs.sql``;
634
+ ` : chunkEDN4Y4ZG_cjs.sql``;
640
635
  const assertionIdKey = codePointOrderedAssertionId(target);
641
636
  const rows = await target.execute(
642
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
637
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
643
638
  SELECT identity_assertions.graph_id AS graph_id,
644
639
  identity_assertions.id AS id,
645
640
  identity_assertions.rel AS rel,
@@ -658,8 +653,8 @@ async function readIdentityAssertionPageAtTarget(ctx, target, mode, options) {
658
653
  ${liveEndpointJoins}
659
654
  WHERE identity_assertions.graph_id = ${ctx.graphId}
660
655
  AND identity_assertions.deleted_at IS NULL
661
- ${options.after === void 0 ? chunk2ZWM2RFH_cjs.sql`` : chunk2ZWM2RFH_cjs.sql`AND ${assertionIdKey} > ${options.after}`}
662
- ${mode === "state" ? chunk2ZWM2RFH_cjs.sql`AND identity_assertions.valid_to IS NULL` : chunk2ZWM2RFH_cjs.sql``}
656
+ ${options.after === void 0 ? chunkEDN4Y4ZG_cjs.sql`` : chunkEDN4Y4ZG_cjs.sql`AND ${assertionIdKey} > ${options.after}`}
657
+ ${mode === "state" ? chunkEDN4Y4ZG_cjs.sql`AND identity_assertions.valid_to IS NULL` : chunkEDN4Y4ZG_cjs.sql``}
663
658
  ${kindFilter}
664
659
  ORDER BY ${assertionIdKey} ASC
665
660
  LIMIT ${options.limit}
@@ -686,6 +681,12 @@ async function readIdentityAssertionsForInterchange(ctx, mode, options) {
686
681
 
687
682
  // src/store/operations/write-transaction.ts
688
683
  var writeTransactionSessions = /* @__PURE__ */ new WeakMap();
684
+ function forceWriteTransactionRevision(target) {
685
+ const session = writeTransactionSessions.get(target);
686
+ if (session === void 0) return false;
687
+ session.wrote = true;
688
+ return true;
689
+ }
689
690
  var heldGraphWriteLocks = /* @__PURE__ */ new WeakMap();
690
691
  async function withWriteTransactionSession(target, ctx, fn) {
691
692
  const session = {
@@ -696,7 +697,7 @@ async function withWriteTransactionSession(target, ctx, fn) {
696
697
  try {
697
698
  const result = await fn();
698
699
  if (session.wrote && ctx.revisionTrackingEnabled && !ctx.historyEnabled) {
699
- await chunkA4R3H7RU_cjs.advanceRevisionClock(target, ctx.revisionSchema, ctx.graphId, true);
700
+ await chunkEZEEWCFJ_cjs.advanceRevisionClock(target, ctx.revisionSchema, ctx.graphId, true);
700
701
  }
701
702
  return result;
702
703
  } finally {
@@ -707,7 +708,7 @@ async function lockSchemaVersionForStoreWrite(ctx, backend) {
707
708
  const expectedVersion = ctx.schemaVersion;
708
709
  if (expectedVersion === void 0) return;
709
710
  if ("transaction" in backend && !backend.capabilities.transactions) {
710
- throw new chunkKCH7WQA5_cjs.ConfigurationError(
711
+ throw new chunkMRDBBHIZ_cjs.ConfigurationError(
711
712
  "Schema-managed Store writes require a transactional backend so schema changes and entity writes can share one fence.",
712
713
  {
713
714
  code: "SCHEMA_WRITE_FENCE_UNSUPPORTED",
@@ -717,7 +718,7 @@ async function lockSchemaVersionForStoreWrite(ctx, backend) {
717
718
  }
718
719
  const lockSchemaVersionForWrite = backend.lockSchemaVersionForWrite;
719
720
  if (lockSchemaVersionForWrite === void 0) {
720
- throw new chunkKCH7WQA5_cjs.ConfigurationError(
721
+ throw new chunkMRDBBHIZ_cjs.ConfigurationError(
721
722
  "This backend cannot fence schema-managed Store writes against a concurrent schema change.",
722
723
  {
723
724
  code: "SCHEMA_WRITE_FENCE_UNSUPPORTED",
@@ -740,7 +741,7 @@ function graphWriteFenceRefusal(ctx, backend, reason) {
740
741
  if (!("transaction" in backend) || backend.capabilities.transactions) {
741
742
  return void 0;
742
743
  }
743
- return new chunkKCH7WQA5_cjs.ConfigurationError(
744
+ return new chunkMRDBBHIZ_cjs.ConfigurationError(
744
745
  "This backend cannot fence a constrained write: enforcing a declared constraint requires a transaction to scope the per-graph write lock to, and this backend has no transactions.",
745
746
  {
746
747
  code: "CONSTRAINT_WRITE_FENCE_UNSUPPORTED",
@@ -758,19 +759,19 @@ function runInWriteTransaction(ctx, backend, fn, options) {
758
759
  const refusal = fenceReason === void 0 ? void 0 : graphWriteFenceRefusal(ctx, backend, fenceReason);
759
760
  if (refusal !== void 0) return Promise.reject(refusal);
760
761
  const needsGraphWriteLock = ctx.historyEnabled || ctx.revisionTrackingEnabled || fenceReason !== void 0;
761
- return chunkANKOXPCC_cjs.runOptionallyInTransaction(backend, async (target) => {
762
+ return chunk5PRKMB24_cjs.runOptionallyInTransaction(backend, async (target) => {
762
763
  await lockSchemaVersionForStoreWrite(ctx, target);
763
764
  const session = needsGraphWriteLock ? writeTransactionSessions.get(target) : void 0;
764
765
  const held = heldGraphWriteLocks.get(target) ?? /* @__PURE__ */ new Set();
765
766
  heldGraphWriteLocks.set(target, held);
766
767
  const acquiresLock = needsGraphWriteLock && session?.lock === void 0 && !held.has(ctx.graphId);
767
768
  if (acquiresLock) held.add(ctx.graphId);
768
- const lock = acquiresLock ? await chunkA4R3H7RU_cjs.lockRecordedGraphWrite(target, ctx.graphId).catch(
769
+ const lock = acquiresLock ? await chunkEZEEWCFJ_cjs.lockRecordedGraphWrite(target, ctx.graphId).catch(
769
770
  (error) => {
770
771
  held.delete(ctx.graphId);
771
772
  throw error;
772
773
  }
773
- ) : session?.lock ?? chunkA4R3H7RU_cjs.uncapturedGraphWriteLock();
774
+ ) : session?.lock ?? chunkEZEEWCFJ_cjs.uncapturedGraphWriteLock();
774
775
  if (session !== void 0) session.lock = lock;
775
776
  const result = await (acquiresLock ? fn(target, lock).finally(() => held.delete(ctx.graphId)) : fn(target, lock));
776
777
  if (session !== void 0) {
@@ -778,7 +779,7 @@ function runInWriteTransaction(ctx, backend, fn, options) {
778
779
  return result;
779
780
  }
780
781
  if (ctx.revisionTrackingEnabled && !ctx.historyEnabled && (options?.didWrite?.(result) ?? true)) {
781
- await chunkA4R3H7RU_cjs.advanceRevisionClock(
782
+ await chunkEZEEWCFJ_cjs.advanceRevisionClock(
782
783
  target,
783
784
  ctx.revisionSchema,
784
785
  ctx.graphId,
@@ -897,7 +898,7 @@ function identityActiveKinds(registry) {
897
898
  return new Set(registry.nodeKinds.keys());
898
899
  }
899
900
  async function loadSnapshot(target, schema, graphId, coordinate, allowedKinds, sameIdAcrossKinds = "fold") {
900
- const currentInstant = chunk5PDSCELM_cjs.nowIso();
901
+ const currentInstant = chunkTQHGE7UC_cjs.nowIso();
901
902
  const [nodes, assertions] = await Promise.all([
902
903
  loadNodeSnapshot(target, schema, graphId, coordinate),
903
904
  loadAssertions(target, schema, graphId, coordinate, currentInstant)
@@ -981,7 +982,7 @@ function validateSnapshotIntegrity(snapshot, registry, graphId) {
981
982
  const a = { kind: assertion.a_kind, id: assertion.a_id };
982
983
  const b = { kind: assertion.b_kind, id: assertion.b_id };
983
984
  if (!structuralKeys.has(refKey(a)) || !structuralKeys.has(refKey(b))) {
984
- throw new chunkKCH7WQA5_cjs.ConfigurationError(
985
+ throw new chunkMRDBBHIZ_cjs.ConfigurationError(
985
986
  "Operational Identity contains a current assertion with a missing or deleted endpoint.",
986
987
  {
987
988
  code: "IDENTITY_SCHEMA_CONTRADICTION",
@@ -993,7 +994,7 @@ function validateSnapshotIntegrity(snapshot, registry, graphId) {
993
994
  );
994
995
  }
995
996
  if (assertion.rel === "different" && sameComponent(snapshot, a, b)) {
996
- throw new chunkKCH7WQA5_cjs.ConfigurationError(
997
+ throw new chunkMRDBBHIZ_cjs.ConfigurationError(
997
998
  "Operational Identity contains a different assertion within one identity class.",
998
999
  {
999
1000
  code: "IDENTITY_SCHEMA_CONTRADICTION",
@@ -1015,7 +1016,7 @@ function validateSnapshotIntegrity(snapshot, registry, graphId) {
1015
1016
  component
1016
1017
  );
1017
1018
  if (conflictingKinds !== void 0) {
1018
- throw new chunkKCH7WQA5_cjs.ConfigurationError(
1019
+ throw new chunkMRDBBHIZ_cjs.ConfigurationError(
1019
1020
  "Operational Identity class conflicts with ontology disjointness.",
1020
1021
  {
1021
1022
  code: "IDENTITY_SCHEMA_CONTRADICTION",
@@ -1028,7 +1029,7 @@ function validateSnapshotIntegrity(snapshot, registry, graphId) {
1028
1029
  }
1029
1030
  }
1030
1031
  function closureMismatchError(graphId, detail) {
1031
- return new chunkKCH7WQA5_cjs.ConfigurationError(
1032
+ return new chunkMRDBBHIZ_cjs.ConfigurationError(
1032
1033
  "Operational Identity materialized closure does not match computed identity components.",
1033
1034
  { code: "IDENTITY_SCHEMA_CONTRADICTION", graphId, ...detail },
1034
1035
  {
@@ -1049,7 +1050,7 @@ async function assertClosureMatchesComponents(target, schema, graphId, component
1049
1050
  }
1050
1051
  }
1051
1052
  const rows = await target.execute(
1052
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
1053
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
1053
1054
  SELECT member_kind, member_id, class_kind, class_id
1054
1055
  FROM ${schema.identityClosureTable}
1055
1056
  WHERE graph_id = ${graphId}
@@ -1079,7 +1080,7 @@ async function assertClosureMatchesComponents(target, schema, graphId, component
1079
1080
  }
1080
1081
  }
1081
1082
  function selfAssertionError(relation) {
1082
- return new chunkKCH7WQA5_cjs.ValidationError(
1083
+ return new chunkMRDBBHIZ_cjs.ValidationError(
1083
1084
  `Identity ${relation} assertions require two distinct node references.`,
1084
1085
  {
1085
1086
  issues: [
@@ -1098,7 +1099,7 @@ function selfAssertionError(relation) {
1098
1099
  async function requireLiveEndpoint(target, graphId, ref) {
1099
1100
  const row = await target.getNode(graphId, ref.kind, ref.id);
1100
1101
  if (row === void 0 || row.deleted_at !== void 0) {
1101
- throw new chunkKCH7WQA5_cjs.NodeNotFoundError(ref.kind, ref.id);
1102
+ throw new chunkMRDBBHIZ_cjs.NodeNotFoundError(ref.kind, ref.id);
1102
1103
  }
1103
1104
  }
1104
1105
  async function loadLiveReferences(target, schema, graphId, references) {
@@ -1110,15 +1111,15 @@ async function loadLiveReferences(target, schema, graphId, references) {
1110
1111
  });
1111
1112
  if (references.length > chunkSize) {
1112
1113
  const byKey = /* @__PURE__ */ new Map();
1113
- for (const refChunk of chunkGVAMRRZR_cjs.chunk(references, chunkSize)) {
1114
+ for (const refChunk of chunkSIT26LAZ_cjs.chunk(references, chunkSize)) {
1114
1115
  const live = await loadLiveReferences(target, schema, graphId, refChunk);
1115
1116
  for (const ref of live) byKey.set(refKey(ref), ref);
1116
1117
  }
1117
1118
  return [...byKey.values()];
1118
1119
  }
1119
- const matches = referenceCondition(chunk2ZWM2RFH_cjs.sql`kind`, chunk2ZWM2RFH_cjs.sql`id`, references);
1120
+ const matches = referenceCondition(chunkEDN4Y4ZG_cjs.sql`kind`, chunkEDN4Y4ZG_cjs.sql`id`, references);
1120
1121
  const rows = await target.execute(
1121
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
1122
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
1122
1123
  SELECT kind, id
1123
1124
  FROM ${schema.nodesTable}
1124
1125
  WHERE graph_id = ${graphId}
@@ -1134,7 +1135,7 @@ async function requireLiveEndpoints(target, schema, graphId, references) {
1134
1135
  const live = await loadLiveReferences(target, schema, graphId, references);
1135
1136
  const liveKeys = new Set(live.map((ref) => refKey(ref)));
1136
1137
  for (const [key, ref] of uniqueByKey) {
1137
- if (!liveKeys.has(key)) throw new chunkKCH7WQA5_cjs.NodeNotFoundError(ref.kind, ref.id);
1138
+ if (!liveKeys.has(key)) throw new chunkMRDBBHIZ_cjs.NodeNotFoundError(ref.kind, ref.id);
1138
1139
  }
1139
1140
  }
1140
1141
  async function requireStructuralEndpoints(target, schema, graphId, references) {
@@ -1148,10 +1149,10 @@ async function requireStructuralEndpoints(target, schema, graphId, references) {
1148
1149
  parametersPerItem: 2
1149
1150
  });
1150
1151
  const presentKeys = /* @__PURE__ */ new Set();
1151
- for (const refChunk of chunkGVAMRRZR_cjs.chunk(unique, chunkSize)) {
1152
- const matches = referenceCondition(chunk2ZWM2RFH_cjs.sql`kind`, chunk2ZWM2RFH_cjs.sql`id`, refChunk);
1152
+ for (const refChunk of chunkSIT26LAZ_cjs.chunk(unique, chunkSize)) {
1153
+ const matches = referenceCondition(chunkEDN4Y4ZG_cjs.sql`kind`, chunkEDN4Y4ZG_cjs.sql`id`, refChunk);
1153
1154
  const rows = await target.execute(
1154
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
1155
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
1155
1156
  SELECT kind, id
1156
1157
  FROM ${schema.nodesTable}
1157
1158
  WHERE graph_id = ${graphId}
@@ -1163,21 +1164,21 @@ async function requireStructuralEndpoints(target, schema, graphId, references) {
1163
1164
  }
1164
1165
  }
1165
1166
  for (const [key, ref] of uniqueByKey) {
1166
- if (!presentKeys.has(key)) throw new chunkKCH7WQA5_cjs.NodeNotFoundError(ref.kind, ref.id);
1167
+ if (!presentKeys.has(key)) throw new chunkMRDBBHIZ_cjs.NodeNotFoundError(ref.kind, ref.id);
1167
1168
  }
1168
1169
  }
1169
1170
 
1170
1171
  // src/identity/separation.ts
1171
1172
  var MAX_SEPARATION_INSERT_CHUNK_SIZE = 100;
1172
1173
  function identityClassKey(ref) {
1173
- return encodeTupleKey([ref.kind, ref.id]);
1174
+ return chunkEZEEWCFJ_cjs.encodeTupleKey([ref.kind, ref.id]);
1174
1175
  }
1175
1176
  var PAIR_KEY_SEPARATOR = "\0";
1176
1177
  function pairKey(pair) {
1177
1178
  return `${pair.low}${PAIR_KEY_SEPARATOR}${pair.high}`;
1178
1179
  }
1179
1180
  function orderedPair(first, second) {
1180
- return chunkA4R3H7RU_cjs.compareCodePoints(first, second) <= 0 ? { low: first, high: second } : { low: second, high: first };
1181
+ return chunkEZEEWCFJ_cjs.compareCodePoints(first, second) <= 0 ? { low: first, high: second } : { low: second, high: first };
1181
1182
  }
1182
1183
  function buildSeparationProjection(assertions, classKeyOf) {
1183
1184
  const pairs = /* @__PURE__ */ new Map();
@@ -1202,7 +1203,7 @@ function buildSeparationProjection(assertions, classKeyOf) {
1202
1203
  async function deleteSeparationForGraph(target, schema, graphId) {
1203
1204
  await executeIdentityStatement(
1204
1205
  target,
1205
- chunk2ZWM2RFH_cjs.sql`DELETE FROM ${schema.identitySeparationTable} WHERE graph_id = ${graphId}`
1206
+ chunkEDN4Y4ZG_cjs.sql`DELETE FROM ${schema.identitySeparationTable} WHERE graph_id = ${graphId}`
1206
1207
  );
1207
1208
  }
1208
1209
  async function deleteSeparationForClassKeys(target, schema, graphId, classKeys) {
@@ -1213,14 +1214,14 @@ async function deleteSeparationForClassKeys(target, schema, graphId, classKeys)
1213
1214
  maxItems: MAX_REFERENCE_CHUNK_SIZE,
1214
1215
  parametersPerItem: 2
1215
1216
  });
1216
- for (const keyChunk of chunkGVAMRRZR_cjs.chunk(unique, chunkSize)) {
1217
- const keyList = chunk2ZWM2RFH_cjs.sql.join(
1218
- keyChunk.map((key) => chunk2ZWM2RFH_cjs.sql`${key}`),
1219
- chunk2ZWM2RFH_cjs.sql`, `
1217
+ for (const keyChunk of chunkSIT26LAZ_cjs.chunk(unique, chunkSize)) {
1218
+ const keyList = chunkEDN4Y4ZG_cjs.sql.join(
1219
+ keyChunk.map((key) => chunkEDN4Y4ZG_cjs.sql`${key}`),
1220
+ chunkEDN4Y4ZG_cjs.sql`, `
1220
1221
  );
1221
1222
  await executeIdentityStatement(
1222
1223
  target,
1223
- chunk2ZWM2RFH_cjs.sql`
1224
+ chunkEDN4Y4ZG_cjs.sql`
1224
1225
  DELETE FROM ${schema.identitySeparationTable}
1225
1226
  WHERE graph_id = ${graphId}
1226
1227
  AND (class_key_low IN (${keyList}) OR class_key_high IN (${keyList}))
@@ -1257,7 +1258,7 @@ function proveSeparationReadiness(registry, graphId) {
1257
1258
  async function probeSeparationPair(target, schema, graphId, pair) {
1258
1259
  try {
1259
1260
  const rows = await target.execute(
1260
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
1261
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
1261
1262
  SELECT
1262
1263
  (
1263
1264
  SELECT COUNT(*) FROM ${schema.identitySeparationTable}
@@ -1280,7 +1281,7 @@ async function probeSeparationPair(target, schema, graphId, pair) {
1280
1281
  pairSeparated: countOf(row, "pair_rows") > 0
1281
1282
  };
1282
1283
  } catch (error) {
1283
- if (!chunkGVAMRRZR_cjs.isMissingTableError(error)) throw error;
1284
+ if (!chunkSIT26LAZ_cjs.isMissingTableError(error)) throw error;
1284
1285
  throw separationUnreadableError(graphId, schema, error);
1285
1286
  }
1286
1287
  }
@@ -1288,7 +1289,7 @@ function countOf(row, column) {
1288
1289
  return Number(row?.[column] ?? 0);
1289
1290
  }
1290
1291
  function separationUnreadableError(graphId, schema, cause) {
1291
- return new chunkKCH7WQA5_cjs.ConfigurationError(
1292
+ return new chunkMRDBBHIZ_cjs.ConfigurationError(
1292
1293
  "Operational Identity could not read the materialized separation relation.",
1293
1294
  {
1294
1295
  code: "IDENTITY_STORAGE_MISSING",
@@ -1302,7 +1303,7 @@ function separationUnreadableError(graphId, schema, cause) {
1302
1303
  );
1303
1304
  }
1304
1305
  function separationUnfilledError(graphId, schema) {
1305
- return new chunkKCH7WQA5_cjs.ConfigurationError(
1306
+ return new chunkMRDBBHIZ_cjs.ConfigurationError(
1306
1307
  "Operational Identity found the separation relation present but never filled for this graph.",
1307
1308
  {
1308
1309
  code: "IDENTITY_STORAGE_MISSING",
@@ -1328,7 +1329,7 @@ async function separationRebuildRequired(target, schema, graphId, options) {
1328
1329
  }
1329
1330
  async function hasSeparationRows(target, schema, graphId) {
1330
1331
  const rows = await target.execute(
1331
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
1332
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
1332
1333
  SELECT 1 AS present
1333
1334
  FROM ${schema.identitySeparationTable}
1334
1335
  WHERE graph_id = ${graphId}
@@ -1341,7 +1342,7 @@ async function hasLiveDifferentAssertions(target, schema, graphId, registry) {
1341
1342
  if (!await probeAnyLiveDifferent(target, schema, graphId)) return false;
1342
1343
  const activeKinds = [...identityActiveKinds(registry)];
1343
1344
  if (activeKinds.length === 0) return false;
1344
- const kindChunks = chunkGVAMRRZR_cjs.chunk(activeKinds, owedProbeChunkSize(target));
1345
+ const kindChunks = chunkSIT26LAZ_cjs.chunk(activeKinds, owedProbeChunkSize(target));
1345
1346
  for (const first of kindChunks) {
1346
1347
  for (const second of kindChunks) {
1347
1348
  if (await probeOwedSeparation(target, schema, graphId, [first, second])) {
@@ -1355,7 +1356,7 @@ var IDENTITY_SNAPSHOT_PARAMETERS = 4;
1355
1356
  var OWED_SEPARATION_PROBE_PARAMETERS = IDENTITY_SNAPSHOT_PARAMETERS + 2;
1356
1357
  async function probeAnyLiveDifferent(target, schema, graphId) {
1357
1358
  const rows = await target.execute(
1358
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
1359
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
1359
1360
  SELECT 1 AS present
1360
1361
  FROM (${liveDifferentSource(schema, graphId)}) live_different
1361
1362
  LIMIT 1
@@ -1365,7 +1366,7 @@ async function probeAnyLiveDifferent(target, schema, graphId) {
1365
1366
  }
1366
1367
  async function probeOwedSeparation(target, schema, graphId, kinds) {
1367
1368
  const rows = await target.execute(
1368
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
1369
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
1369
1370
  SELECT 1 AS present
1370
1371
  FROM (${liveDifferentSource(schema, graphId)}) live_different
1371
1372
  LEFT JOIN ${schema.identityClosureTable} class_a
@@ -1397,22 +1398,22 @@ function owedProbeChunkSize(target) {
1397
1398
  });
1398
1399
  }
1399
1400
  function liveDifferentSource(schema, graphId) {
1400
- return chunkA4R3H7RU_cjs.identityAssertionSnapshotSource(
1401
+ return chunkEZEEWCFJ_cjs.identityAssertionSnapshotSource(
1401
1402
  schema,
1402
1403
  graphId,
1403
- chunkA4R3H7RU_cjs.identitySqlCoordinate(void 0, chunk5PDSCELM_cjs.nowIso()),
1404
+ chunkEZEEWCFJ_cjs.identitySqlCoordinate(void 0, chunkTQHGE7UC_cjs.nowIso()),
1404
1405
  "different"
1405
1406
  );
1406
1407
  }
1407
1408
  function kindList(kinds) {
1408
- return chunk2ZWM2RFH_cjs.sql.join(
1409
- kinds.map((kind) => chunk2ZWM2RFH_cjs.sql`${kind}`),
1410
- chunk2ZWM2RFH_cjs.sql`, `
1409
+ return chunkEDN4Y4ZG_cjs.sql.join(
1410
+ kinds.map((kind) => chunkEDN4Y4ZG_cjs.sql`${kind}`),
1411
+ chunkEDN4Y4ZG_cjs.sql`, `
1411
1412
  );
1412
1413
  }
1413
1414
  async function readSeparationForGraph(target, schema, graphId) {
1414
1415
  const rows = await target.execute(
1415
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
1416
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
1416
1417
  SELECT class_key_low, class_key_high
1417
1418
  FROM ${schema.identitySeparationTable}
1418
1419
  WHERE graph_id = ${graphId}
@@ -1429,23 +1430,23 @@ async function insertSeparationRows(target, schema, graphId, projection) {
1429
1430
  maxItems: MAX_SEPARATION_INSERT_CHUNK_SIZE,
1430
1431
  parametersPerItem: 3
1431
1432
  });
1432
- for (const pairChunk of chunkGVAMRRZR_cjs.chunk(projection.pairs, chunkSize)) {
1433
+ for (const pairChunk of chunkSIT26LAZ_cjs.chunk(projection.pairs, chunkSize)) {
1433
1434
  const values = pairChunk.map(
1434
- (pair) => chunk2ZWM2RFH_cjs.sql`(${graphId}, ${pair.low}, ${pair.high})`
1435
+ (pair) => chunkEDN4Y4ZG_cjs.sql`(${graphId}, ${pair.low}, ${pair.high})`
1435
1436
  );
1436
1437
  try {
1437
1438
  await executeIdentityStatement(
1438
1439
  target,
1439
- chunk2ZWM2RFH_cjs.sql`
1440
+ chunkEDN4Y4ZG_cjs.sql`
1440
1441
  INSERT INTO ${schema.identitySeparationTable} (
1441
1442
  graph_id, class_key_low, class_key_high
1442
- ) VALUES ${chunk2ZWM2RFH_cjs.sql.join(values, chunk2ZWM2RFH_cjs.sql`, `)}
1443
+ ) VALUES ${chunkEDN4Y4ZG_cjs.sql.join(values, chunkEDN4Y4ZG_cjs.sql`, `)}
1443
1444
  `
1444
1445
  );
1445
1446
  } catch (error) {
1446
1447
  const collapsed = collapsedIn(projection, pairChunk);
1447
1448
  if (collapsed === void 0) throw error;
1448
- throw new chunkKCH7WQA5_cjs.IdentitySeparationViolationError(
1449
+ throw new chunkMRDBBHIZ_cjs.IdentitySeparationViolationError(
1449
1450
  { graphId, enforcedBy: "database", ...collapsed },
1450
1451
  { cause: error }
1451
1452
  );
@@ -1453,7 +1454,7 @@ async function insertSeparationRows(target, schema, graphId, projection) {
1453
1454
  }
1454
1455
  const accepted = projection.collapsed[0];
1455
1456
  if (accepted === void 0) return;
1456
- throw new chunkKCH7WQA5_cjs.IdentitySeparationViolationError({
1457
+ throw new chunkMRDBBHIZ_cjs.IdentitySeparationViolationError({
1457
1458
  graphId,
1458
1459
  enforcedBy: "writer",
1459
1460
  ...accepted
@@ -1483,7 +1484,7 @@ function assertSeparationMatchesProjection(graphId, persisted, projection) {
1483
1484
  }
1484
1485
  }
1485
1486
  function separationMismatchError(graphId, detail) {
1486
- return new chunkKCH7WQA5_cjs.ConfigurationError(
1487
+ return new chunkMRDBBHIZ_cjs.ConfigurationError(
1487
1488
  "Operational Identity materialized separation relation does not match the assertion ledger.",
1488
1489
  { code: "IDENTITY_SCHEMA_CONTRADICTION", graphId, ...detail },
1489
1490
  {
@@ -1492,6 +1493,51 @@ function separationMismatchError(graphId, detail) {
1492
1493
  );
1493
1494
  }
1494
1495
 
1496
+ // src/identity/validity-window.ts
1497
+ function hasExplicitIdentityValidityWindow(window) {
1498
+ return window?.validFrom !== void 0 || window?.validTo !== void 0;
1499
+ }
1500
+ function resolveIdentityValidityWindow(window, operationInstant) {
1501
+ const validFrom = chunkTQHGE7UC_cjs.validateOptionalCanonicalIsoDate(window?.validFrom, "validFrom") ?? operationInstant;
1502
+ const validTo = chunkTQHGE7UC_cjs.validateOptionalCanonicalIsoDate(window?.validTo, "validTo");
1503
+ if (chunkEZEEWCFJ_cjs.compareCodePoints(validFrom, operationInstant) > 0) {
1504
+ throw new chunkMRDBBHIZ_cjs.IdentityValidityWindowError({
1505
+ reason: "future-valid-from",
1506
+ validFrom,
1507
+ ...validTo === void 0 ? {} : { validTo },
1508
+ operationInstant
1509
+ });
1510
+ }
1511
+ if (validTo !== void 0 && chunkEZEEWCFJ_cjs.compareCodePoints(validTo, operationInstant) > 0) {
1512
+ throw new chunkMRDBBHIZ_cjs.IdentityValidityWindowError({
1513
+ reason: "future-valid-to",
1514
+ validFrom,
1515
+ validTo,
1516
+ operationInstant
1517
+ });
1518
+ }
1519
+ if (validTo !== void 0 && chunkEZEEWCFJ_cjs.compareCodePoints(validTo, validFrom) < 0) {
1520
+ throw new chunkMRDBBHIZ_cjs.IdentityValidityWindowError({
1521
+ reason: "inverted",
1522
+ validFrom,
1523
+ validTo,
1524
+ operationInstant
1525
+ });
1526
+ }
1527
+ const effective = validTo === validFrom ? "empty" : validTo === void 0 ? "current" : "historical";
1528
+ return {
1529
+ validFrom,
1530
+ ...validTo === void 0 ? {} : { validTo },
1531
+ effective
1532
+ };
1533
+ }
1534
+ function identityValidityWindowsOverlap(left, right) {
1535
+ if (left.validFrom === left.validTo || right.validFrom === right.validTo) {
1536
+ return false;
1537
+ }
1538
+ return (right.validTo === void 0 || left.validFrom < right.validTo) && (left.validTo === void 0 || right.validFrom < left.validTo);
1539
+ }
1540
+
1495
1541
  // src/identity/service-mutation.ts
1496
1542
  async function validateCurrentRelation(ctx, target, relation, operation, a, b) {
1497
1543
  const classes = await loadCurrentStructuralClasses(
@@ -1504,7 +1550,7 @@ async function validateCurrentRelation(ctx, target, relation, operation, a, b) {
1504
1550
  const bClass = chunkN66HCGCY_cjs.requireDefined(classes.get(refKey(b)));
1505
1551
  if (relation === "different") {
1506
1552
  if (!containsRef(aClass, b)) return;
1507
- throw new chunkKCH7WQA5_cjs.IdentityContradictionError({
1553
+ throw new chunkMRDBBHIZ_cjs.IdentityContradictionError({
1508
1554
  operation,
1509
1555
  a,
1510
1556
  b,
@@ -1523,7 +1569,7 @@ async function validateCurrentRelation(ctx, target, relation, operation, a, b) {
1523
1569
  );
1524
1570
  if (different === void 0)
1525
1571
  throw unexpectedSeparationError(ctx.graphId, aKey, bKey);
1526
- throw new chunkKCH7WQA5_cjs.IdentityContradictionError({
1572
+ throw new chunkMRDBBHIZ_cjs.IdentityContradictionError({
1527
1573
  operation,
1528
1574
  a,
1529
1575
  b,
@@ -1533,7 +1579,7 @@ async function validateCurrentRelation(ctx, target, relation, operation, a, b) {
1533
1579
  }
1534
1580
  const disjointKinds = classHasDisjointKinds(ctx.registry, aClass, bClass);
1535
1581
  if (disjointKinds === void 0) return;
1536
- throw new chunkKCH7WQA5_cjs.IdentityContradictionError({
1582
+ throw new chunkMRDBBHIZ_cjs.IdentityContradictionError({
1537
1583
  operation,
1538
1584
  a,
1539
1585
  b,
@@ -1543,8 +1589,8 @@ async function validateCurrentRelation(ctx, target, relation, operation, a, b) {
1543
1589
  }
1544
1590
  async function currentAssertionForPair(target, schema, graphId, relation, a, b) {
1545
1591
  const rows = await target.execute(
1546
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
1547
- SELECT ${chunkA4R3H7RU_cjs.IDENTITY_ASSERTION_COLUMNS}
1592
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
1593
+ SELECT ${chunkEZEEWCFJ_cjs.IDENTITY_ASSERTION_COLUMNS}
1548
1594
  FROM ${schema.identityAssertionsTable}
1549
1595
  WHERE graph_id = ${graphId}
1550
1596
  AND rel = ${relation}
@@ -1559,23 +1605,50 @@ async function currentAssertionForPair(target, schema, graphId, relation, a, b)
1559
1605
  );
1560
1606
  return rows[0] === void 0 ? void 0 : normalizeIdentityAssertionRow(rows[0]);
1561
1607
  }
1562
- async function insertAssertion(target, schema, graphId, relation, a, b, timestamp, touch, preserved) {
1563
- const row = buildAssertionRow(graphId, relation, a, b, timestamp, preserved);
1608
+ async function assertionForExactWindow(target, schema, graphId, relation, a, b, window) {
1609
+ const validToMatch = window.validTo === void 0 ? chunkEDN4Y4ZG_cjs.sql`valid_to IS NULL` : chunkEDN4Y4ZG_cjs.sql`valid_to = ${window.validTo}`;
1610
+ const rows = await target.execute(
1611
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
1612
+ SELECT ${chunkEZEEWCFJ_cjs.IDENTITY_ASSERTION_COLUMNS}
1613
+ FROM ${schema.identityAssertionsTable}
1614
+ WHERE graph_id = ${graphId}
1615
+ AND rel = ${relation}
1616
+ AND a_kind = ${a.kind}
1617
+ AND a_id = ${a.id}
1618
+ AND b_kind = ${b.kind}
1619
+ AND b_id = ${b.id}
1620
+ AND valid_from = ${window.validFrom}
1621
+ AND ${validToMatch}
1622
+ AND deleted_at IS NULL
1623
+ LIMIT 1
1624
+ `)
1625
+ );
1626
+ return rows[0] === void 0 ? void 0 : normalizeIdentityAssertionRow(rows[0]);
1627
+ }
1628
+ async function insertAssertion(target, schema, graphId, relation, a, b, operationInstant, touch, options) {
1629
+ const row = buildAssertionRow(
1630
+ graphId,
1631
+ relation,
1632
+ a,
1633
+ b,
1634
+ operationInstant,
1635
+ options
1636
+ );
1564
1637
  await insertAssertionRows(target, schema, [row]);
1565
1638
  touch(graphId, row.id, row);
1566
1639
  return row;
1567
1640
  }
1568
- function buildAssertionRow(graphId, relation, a, b, timestamp, preserved) {
1641
+ function buildAssertionRow(graphId, relation, a, b, timestamp, options) {
1569
1642
  return {
1570
1643
  graph_id: graphId,
1571
- id: preserved?.id ?? chunkA4R3H7RU_cjs.generateId(),
1644
+ id: options?.id ?? chunkEZEEWCFJ_cjs.generateId(),
1572
1645
  rel: relation,
1573
1646
  a_kind: a.kind,
1574
1647
  a_id: a.id,
1575
1648
  b_kind: b.kind,
1576
1649
  b_id: b.id,
1577
- valid_from: preserved?.validFrom ?? timestamp,
1578
- valid_to: void 0,
1650
+ valid_from: options?.validFrom ?? timestamp,
1651
+ valid_to: options?.validTo,
1579
1652
  created_at: timestamp,
1580
1653
  updated_at: timestamp,
1581
1654
  deleted_at: void 0,
@@ -1583,8 +1656,331 @@ function buildAssertionRow(graphId, relation, a, b, timestamp, preserved) {
1583
1656
  ended_by_id: void 0
1584
1657
  };
1585
1658
  }
1659
+ function canonicalEndpointTimestamp(value) {
1660
+ if (value === void 0 || value === null) return void 0;
1661
+ return chunkTQHGE7UC_cjs.canonicalizeDatabaseTimestamp(value);
1662
+ }
1663
+ async function requireEndpointsCoverIdentityWindow(target, graphId, references, window) {
1664
+ for (const ref of references) {
1665
+ const row = await target.getNode(graphId, ref.kind, ref.id);
1666
+ if (row === void 0) throw new chunkMRDBBHIZ_cjs.NodeNotFoundError(ref.kind, ref.id);
1667
+ if (window.effective === "empty") continue;
1668
+ const validFrom = canonicalEndpointTimestamp(row.valid_from);
1669
+ const validTo = canonicalEndpointTimestamp(row.valid_to);
1670
+ const deletedAt = canonicalEndpointTimestamp(row.deleted_at);
1671
+ const endpointWindow = {
1672
+ ...validFrom === void 0 ? {} : { validFrom },
1673
+ ...validTo === void 0 ? {} : { validTo },
1674
+ ...deletedAt === void 0 ? {} : { deletedAt }
1675
+ };
1676
+ const startsTooLate = endpointWindow.validFrom !== void 0 && endpointWindow.validFrom > window.validFrom;
1677
+ const effectiveEnd = [endpointWindow.validTo, endpointWindow.deletedAt].filter((value) => value !== void 0).toSorted()[0];
1678
+ const endsTooEarly = window.validTo === void 0 ? effectiveEnd !== void 0 : effectiveEnd !== void 0 && effectiveEnd < window.validTo;
1679
+ if (!startsTooLate && !endsTooEarly) continue;
1680
+ throw new chunkMRDBBHIZ_cjs.IdentityEndpointValidityError({
1681
+ endpoint: ref,
1682
+ assertionWindow: {
1683
+ validFrom: window.validFrom,
1684
+ ...window.validTo === void 0 ? {} : { validTo: window.validTo }
1685
+ },
1686
+ endpointWindow
1687
+ });
1688
+ }
1689
+ }
1690
+ function windowOverlapSql(alias, lowerBoundary, upperBoundary) {
1691
+ const column = (name) => chunkEDN4Y4ZG_cjs.sql`${chunkEDN4Y4ZG_cjs.sql.identifier(alias)}.${chunkEDN4Y4ZG_cjs.sql.identifier(name)}`;
1692
+ return chunkEDN4Y4ZG_cjs.sql`
1693
+ ${column("deleted_at")} IS NULL
1694
+ AND ${column("valid_from")} <= ${upperBoundary}
1695
+ AND (${column("valid_to")} IS NULL OR ${column("valid_to")} > ${lowerBoundary})
1696
+ `;
1697
+ }
1698
+ async function loadIdentityWindowLedger(target, schema, graphId, requests, operationInstant, sameIdAcrossKinds) {
1699
+ const activeRequests = requests.filter(
1700
+ (request) => request.window.effective !== "empty"
1701
+ );
1702
+ if (activeRequests.length === 0) return { nodes: [], assertions: [] };
1703
+ const referencesByKey = /* @__PURE__ */ new Map();
1704
+ for (const request of activeRequests) {
1705
+ for (const reference of request.references) {
1706
+ referencesByKey.set(refKey(reference), reference);
1707
+ }
1708
+ }
1709
+ const references = [...referencesByKey.values()];
1710
+ const lowerBoundary = chunkN66HCGCY_cjs.requireDefined(
1711
+ activeRequests.map((request) => request.window.validFrom).toSorted()[0]
1712
+ );
1713
+ const upperBoundary = chunkN66HCGCY_cjs.requireDefined(
1714
+ activeRequests.map((request) => request.window.validTo ?? operationInstant).toSorted().at(-1)
1715
+ );
1716
+ const seedChunkSize = identityChunkSize(target, {
1717
+ fixedParameters: 20,
1718
+ maxItems: MAX_REFERENCE_CHUNK_SIZE,
1719
+ parametersPerItem: 2
1720
+ });
1721
+ const rows = [];
1722
+ for (const referenceChunk of chunkSIT26LAZ_cjs.chunk(references, seedChunkSize)) {
1723
+ const seedRows = chunkEDN4Y4ZG_cjs.sql.join(
1724
+ referenceChunk.map(
1725
+ (reference) => chunkEDN4Y4ZG_cjs.sql`(${reference.kind}, ${reference.id})`
1726
+ ),
1727
+ chunkEDN4Y4ZG_cjs.sql`, `
1728
+ );
1729
+ const component = sameIdAcrossKinds === "fold" ? chunkEDN4Y4ZG_cjs.sql`
1730
+ neighbor_modes(mode) AS (
1731
+ VALUES ('assertion'), ('fold')
1732
+ ),
1733
+ component(kind, id) AS (
1734
+ SELECT seed_kind, seed_id FROM seeds
1735
+ UNION
1736
+ SELECT CASE
1737
+ WHEN neighbor_modes.mode = 'fold' THEN folded.kind
1738
+ WHEN assertion.a_kind = component.kind AND assertion.a_id = component.id
1739
+ THEN assertion.b_kind
1740
+ ELSE assertion.a_kind
1741
+ END,
1742
+ CASE
1743
+ WHEN neighbor_modes.mode = 'fold' THEN folded.id
1744
+ WHEN assertion.a_kind = component.kind AND assertion.a_id = component.id
1745
+ THEN assertion.b_id
1746
+ ELSE assertion.a_id
1747
+ END
1748
+ FROM component
1749
+ JOIN neighbor_modes ON 1 = 1
1750
+ LEFT JOIN ${schema.identityAssertionsTable} assertion
1751
+ ON neighbor_modes.mode = 'assertion'
1752
+ AND assertion.graph_id = ${graphId}
1753
+ AND assertion.rel = 'same'
1754
+ AND ${windowOverlapSql("assertion", lowerBoundary, upperBoundary)}
1755
+ AND ((assertion.a_kind = component.kind AND assertion.a_id = component.id)
1756
+ OR (assertion.b_kind = component.kind AND assertion.b_id = component.id))
1757
+ LEFT JOIN ${schema.nodesTable} folded
1758
+ ON neighbor_modes.mode = 'fold'
1759
+ AND folded.graph_id = ${graphId}
1760
+ AND folded.id = component.id
1761
+ WHERE assertion.id IS NOT NULL OR folded.id IS NOT NULL
1762
+ )
1763
+ ` : chunkEDN4Y4ZG_cjs.sql`
1764
+ component(kind, id) AS (
1765
+ SELECT seed_kind, seed_id FROM seeds
1766
+ UNION
1767
+ SELECT CASE
1768
+ WHEN assertion.a_kind = component.kind AND assertion.a_id = component.id
1769
+ THEN assertion.b_kind
1770
+ ELSE assertion.a_kind
1771
+ END,
1772
+ CASE
1773
+ WHEN assertion.a_kind = component.kind AND assertion.a_id = component.id
1774
+ THEN assertion.b_id
1775
+ ELSE assertion.a_id
1776
+ END
1777
+ FROM component
1778
+ JOIN ${schema.identityAssertionsTable} assertion
1779
+ ON assertion.graph_id = ${graphId}
1780
+ AND assertion.rel = 'same'
1781
+ AND ${windowOverlapSql("assertion", lowerBoundary, upperBoundary)}
1782
+ AND ((assertion.a_kind = component.kind AND assertion.a_id = component.id)
1783
+ OR (assertion.b_kind = component.kind AND assertion.b_id = component.id))
1784
+ )
1785
+ `;
1786
+ rows.push(
1787
+ ...await target.execute(
1788
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
1789
+ WITH RECURSIVE
1790
+ seeds(seed_kind, seed_id) AS (VALUES ${seedRows}),
1791
+ ${component},
1792
+ selected_assertions AS (
1793
+ SELECT DISTINCT assertion.*
1794
+ FROM ${schema.identityAssertionsTable} assertion
1795
+ JOIN component
1796
+ ON (assertion.a_kind = component.kind AND assertion.a_id = component.id)
1797
+ OR (assertion.b_kind = component.kind AND assertion.b_id = component.id)
1798
+ WHERE assertion.graph_id = ${graphId}
1799
+ AND ${windowOverlapSql("assertion", lowerBoundary, upperBoundary)}
1800
+ )
1801
+ SELECT 'assertion' AS row_type, ${chunkEZEEWCFJ_cjs.IDENTITY_ASSERTION_COLUMNS},
1802
+ NULL AS node_kind, NULL AS node_id,
1803
+ NULL AS node_created_at, NULL AS node_deleted_at
1804
+ FROM selected_assertions
1805
+ UNION ALL
1806
+ SELECT 'node', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1807
+ NULL, NULL, NULL, NULL, NULL,
1808
+ node.kind, node.id, node.created_at, node.deleted_at
1809
+ FROM ${schema.nodesTable} node
1810
+ JOIN component ON component.kind = node.kind AND component.id = node.id
1811
+ WHERE node.graph_id = ${graphId}
1812
+ `)
1813
+ )
1814
+ );
1815
+ }
1816
+ const nodesByKey = /* @__PURE__ */ new Map();
1817
+ const assertionsById = /* @__PURE__ */ new Map();
1818
+ for (const row of rows) {
1819
+ if (row.row_type === "assertion") {
1820
+ const assertion = normalizeIdentityAssertionRow(row);
1821
+ assertionsById.set(assertion.id, assertion);
1822
+ continue;
1823
+ }
1824
+ if (typeof row.node_kind !== "string" || typeof row.node_id !== "string")
1825
+ continue;
1826
+ const createdAt = canonicalEndpointTimestamp(row.node_created_at);
1827
+ if (createdAt === void 0) continue;
1828
+ const deletedAt = canonicalEndpointTimestamp(row.node_deleted_at);
1829
+ const node = {
1830
+ ref: { kind: row.node_kind, id: row.node_id },
1831
+ createdAt,
1832
+ ...deletedAt === void 0 ? {} : { deletedAt }
1833
+ };
1834
+ nodesByKey.set(refKey(node.ref), node);
1835
+ }
1836
+ return {
1837
+ nodes: [...nodesByKey.values()],
1838
+ assertions: [...assertionsById.values()]
1839
+ };
1840
+ }
1841
+ function identityWindowCheckpoints(window, operationInstant, nodes, assertions) {
1842
+ if (window.effective === "empty") return [];
1843
+ const checkpoints = /* @__PURE__ */ new Set([window.validFrom]);
1844
+ if (window.validTo === void 0) checkpoints.add(operationInstant);
1845
+ for (const row of [...assertions, ...nodes]) {
1846
+ for (const value of [
1847
+ "valid_from" in row ? row.valid_from : void 0,
1848
+ "valid_to" in row ? row.valid_to : void 0,
1849
+ "createdAt" in row ? row.createdAt : void 0,
1850
+ "deletedAt" in row ? row.deletedAt : void 0
1851
+ ]) {
1852
+ const boundary = canonicalEndpointTimestamp(value);
1853
+ if (boundary === void 0 || boundary < window.validFrom) continue;
1854
+ if (window.validTo !== void 0 && boundary >= window.validTo) continue;
1855
+ if (boundary > operationInstant) continue;
1856
+ checkpoints.add(boundary);
1857
+ }
1858
+ }
1859
+ return [...checkpoints].toSorted();
1860
+ }
1861
+ function validateRelationAgainstLedger(ctx, nodes, assertions, relation, operation, a, b, window, operationInstant) {
1862
+ const checkpoints = identityWindowCheckpoints(
1863
+ window,
1864
+ operationInstant,
1865
+ nodes,
1866
+ assertions
1867
+ );
1868
+ for (const instant of checkpoints) {
1869
+ const structuralNodes = nodes.map((node) => node.ref);
1870
+ const activeAssertions = assertions.filter(
1871
+ (assertion) => assertion.deleted_at === void 0 && assertion.valid_from <= instant && (assertion.valid_to === void 0 || assertion.valid_to > instant)
1872
+ );
1873
+ const activeFoldReferences = nodes.filter(
1874
+ (node) => node.createdAt <= instant && (node.deletedAt === void 0 || node.deletedAt > instant)
1875
+ ).map((node) => node.ref);
1876
+ const foldAssertions = [];
1877
+ if (ctx.sameIdAcrossKinds === "fold") {
1878
+ const byId = /* @__PURE__ */ new Map();
1879
+ for (const reference of activeFoldReferences) {
1880
+ const sameId = byId.get(reference.id) ?? [];
1881
+ sameId.push(reference);
1882
+ byId.set(reference.id, sameId);
1883
+ }
1884
+ for (const sameId of byId.values()) {
1885
+ const first = sameId[0];
1886
+ if (first === void 0) continue;
1887
+ for (const other of sameId.slice(1)) {
1888
+ foldAssertions.push({
1889
+ rel: "same",
1890
+ a_kind: first.kind,
1891
+ a_id: first.id,
1892
+ b_kind: other.kind,
1893
+ b_id: other.id
1894
+ });
1895
+ }
1896
+ }
1897
+ }
1898
+ const components = buildComponents(
1899
+ structuralNodes,
1900
+ [...activeAssertions, ...foldAssertions],
1901
+ "ignore"
1902
+ );
1903
+ const aClass = components.get(refKey(a)) ?? [];
1904
+ const bClass = components.get(refKey(b)) ?? [];
1905
+ if (relation === "different") {
1906
+ if (!containsRef(aClass, b)) continue;
1907
+ throw new chunkMRDBBHIZ_cjs.IdentityContradictionError({
1908
+ operation,
1909
+ a,
1910
+ b,
1911
+ reason: "same-class"
1912
+ });
1913
+ }
1914
+ const different = spanningDifferentAssertion(
1915
+ activeAssertions,
1916
+ aClass,
1917
+ bClass
1918
+ );
1919
+ if (different !== void 0) {
1920
+ throw new chunkMRDBBHIZ_cjs.IdentityContradictionError({
1921
+ operation,
1922
+ a,
1923
+ b,
1924
+ reason: "different-assertion",
1925
+ conflictingAssertionId: different.id
1926
+ });
1927
+ }
1928
+ const disjointKinds = classHasDisjointKinds(ctx.registry, aClass, bClass);
1929
+ if (disjointKinds === void 0) continue;
1930
+ throw new chunkMRDBBHIZ_cjs.IdentityContradictionError({
1931
+ operation,
1932
+ a,
1933
+ b,
1934
+ reason: "disjoint-kinds",
1935
+ conflictingKinds: disjointKinds
1936
+ });
1937
+ }
1938
+ }
1939
+ async function createIdentityWindowValidator(ctx, target, requests, operationInstant, ignoredAssertionIds = /* @__PURE__ */ new Set()) {
1940
+ const ledger = await loadIdentityWindowLedger(
1941
+ target,
1942
+ ctx.schema,
1943
+ ctx.graphId,
1944
+ requests,
1945
+ operationInstant,
1946
+ ctx.sameIdAcrossKinds
1947
+ );
1948
+ if (ignoredAssertionIds.size > 0) {
1949
+ const retained = ledger.assertions.filter(
1950
+ (assertion) => !ignoredAssertionIds.has(assertion.id)
1951
+ );
1952
+ ledger.assertions.splice(0, ledger.assertions.length, ...retained);
1953
+ }
1954
+ return {
1955
+ validate(relation, operation, a, b, window) {
1956
+ validateRelationAgainstLedger(
1957
+ ctx,
1958
+ ledger.nodes,
1959
+ ledger.assertions,
1960
+ relation,
1961
+ operation,
1962
+ a,
1963
+ b,
1964
+ window,
1965
+ operationInstant
1966
+ );
1967
+ },
1968
+ record(assertion) {
1969
+ ledger.assertions.push(assertion);
1970
+ }
1971
+ };
1972
+ }
1973
+ async function validateRelationThroughoutIdentityWindow(ctx, target, relation, operation, a, b, window, operationInstant) {
1974
+ const validator = await createIdentityWindowValidator(
1975
+ ctx,
1976
+ target,
1977
+ [{ references: [a, b], window }],
1978
+ operationInstant
1979
+ );
1980
+ validator.validate(relation, operation, a, b, window);
1981
+ }
1586
1982
  function nullableAssertionValue(value) {
1587
- return value === void 0 ? chunk2ZWM2RFH_cjs.sql`NULL` : chunk2ZWM2RFH_cjs.sql`${value}`;
1983
+ return value === void 0 ? chunkEDN4Y4ZG_cjs.sql`NULL` : chunkEDN4Y4ZG_cjs.sql`${value}`;
1588
1984
  }
1589
1985
  async function insertAssertionRows(target, schema, rows) {
1590
1986
  if (rows.length === 0) return;
@@ -1593,9 +1989,9 @@ async function insertAssertionRows(target, schema, rows) {
1593
1989
  maxItems: MAX_ASSERTION_INSERT_CHUNK_SIZE,
1594
1990
  parametersPerItem: 14
1595
1991
  });
1596
- for (const rowChunk of chunkGVAMRRZR_cjs.chunk(rows, chunkSize)) {
1992
+ for (const rowChunk of chunkSIT26LAZ_cjs.chunk(rows, chunkSize)) {
1597
1993
  const values = rowChunk.map(
1598
- (row) => chunk2ZWM2RFH_cjs.sql`
1994
+ (row) => chunkEDN4Y4ZG_cjs.sql`
1599
1995
  (
1600
1996
  ${row.graph_id}, ${row.id}, ${row.rel}, ${row.a_kind}, ${row.a_id},
1601
1997
  ${row.b_kind}, ${row.b_id}, ${row.valid_from},
@@ -1609,8 +2005,8 @@ async function insertAssertionRows(target, schema, rows) {
1609
2005
  );
1610
2006
  await executeIdentityStatement(
1611
2007
  target,
1612
- chunk2ZWM2RFH_cjs.sql`
1613
- INSERT INTO ${schema.identityAssertionsTable} (${chunkA4R3H7RU_cjs.IDENTITY_ASSERTION_COLUMNS}) VALUES ${chunk2ZWM2RFH_cjs.sql.join(values, chunk2ZWM2RFH_cjs.sql`, `)}
2008
+ chunkEDN4Y4ZG_cjs.sql`
2009
+ INSERT INTO ${schema.identityAssertionsTable} (${chunkEZEEWCFJ_cjs.IDENTITY_ASSERTION_COLUMNS}) VALUES ${chunkEDN4Y4ZG_cjs.sql.join(values, chunkEDN4Y4ZG_cjs.sql`, `)}
1614
2010
  `
1615
2011
  );
1616
2012
  }
@@ -1624,14 +2020,14 @@ async function loadAssertionsByIds(target, schema, graphId, ids) {
1624
2020
  maxItems: MAX_REFERENCE_CHUNK_SIZE,
1625
2021
  parametersPerItem: 1
1626
2022
  });
1627
- for (const idChunk of chunkGVAMRRZR_cjs.chunk(uniqueIds, chunkSize)) {
1628
- const idList = chunk2ZWM2RFH_cjs.sql.join(
1629
- idChunk.map((id) => chunk2ZWM2RFH_cjs.sql`${id}`),
1630
- chunk2ZWM2RFH_cjs.sql`, `
2023
+ for (const idChunk of chunkSIT26LAZ_cjs.chunk(uniqueIds, chunkSize)) {
2024
+ const idList = chunkEDN4Y4ZG_cjs.sql.join(
2025
+ idChunk.map((id) => chunkEDN4Y4ZG_cjs.sql`${id}`),
2026
+ chunkEDN4Y4ZG_cjs.sql`, `
1631
2027
  );
1632
2028
  const rows = await target.execute(
1633
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
1634
- SELECT ${chunkA4R3H7RU_cjs.IDENTITY_ASSERTION_COLUMNS}
2029
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
2030
+ SELECT ${chunkEZEEWCFJ_cjs.IDENTITY_ASSERTION_COLUMNS}
1635
2031
  FROM ${schema.identityAssertionsTable}
1636
2032
  WHERE graph_id = ${graphId} AND id IN (${idList})
1637
2033
  `)
@@ -1653,13 +2049,13 @@ async function loadCurrentClassAnchors(target, schema, graphId, references) {
1653
2049
  maxItems: MAX_REFERENCE_CHUNK_SIZE,
1654
2050
  parametersPerItem: 2
1655
2051
  });
1656
- for (const refChunk of chunkGVAMRRZR_cjs.chunk(uniqueReferences, chunkSize)) {
1657
- const seedRows = chunk2ZWM2RFH_cjs.sql.join(
1658
- refChunk.map((ref) => chunk2ZWM2RFH_cjs.sql`(${ref.kind}, ${ref.id})`),
1659
- chunk2ZWM2RFH_cjs.sql`, `
2052
+ for (const refChunk of chunkSIT26LAZ_cjs.chunk(uniqueReferences, chunkSize)) {
2053
+ const seedRows = chunkEDN4Y4ZG_cjs.sql.join(
2054
+ refChunk.map((ref) => chunkEDN4Y4ZG_cjs.sql`(${ref.kind}, ${ref.id})`),
2055
+ chunkEDN4Y4ZG_cjs.sql`, `
1660
2056
  );
1661
2057
  const rows = await target.execute(
1662
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
2058
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
1663
2059
  WITH seeds(seed_kind, seed_id) AS (
1664
2060
  VALUES ${seedRows}
1665
2061
  )
@@ -1754,7 +2150,7 @@ async function replaceClosure(target, schema, graphId, allowedKinds, sameIdAcros
1754
2150
  );
1755
2151
  await executeIdentityStatement(
1756
2152
  target,
1757
- chunk2ZWM2RFH_cjs.sql`DELETE FROM ${schema.identityClosureTable} WHERE graph_id = ${graphId}`
2153
+ chunkEDN4Y4ZG_cjs.sql`DELETE FROM ${schema.identityClosureTable} WHERE graph_id = ${graphId}`
1758
2154
  );
1759
2155
  await insertClosureComponents(target, schema, graphId, snapshot.components);
1760
2156
  await deleteSeparationForGraph(target, schema, graphId);
@@ -1777,7 +2173,7 @@ async function insertClosureComponents(target, schema, graphId, components) {
1777
2173
  for (const member of component) {
1778
2174
  emitted.add(refKey(member));
1779
2175
  values.push(
1780
- chunk2ZWM2RFH_cjs.sql`(${graphId}, ${member.kind}, ${member.id}, ${canonical.kind}, ${canonical.id})`
2176
+ chunkEDN4Y4ZG_cjs.sql`(${graphId}, ${member.kind}, ${member.id}, ${canonical.kind}, ${canonical.id})`
1781
2177
  );
1782
2178
  }
1783
2179
  }
@@ -1787,13 +2183,13 @@ async function insertClosureComponents(target, schema, graphId, components) {
1787
2183
  maxItems: MAX_CLOSURE_INSERT_CHUNK_SIZE,
1788
2184
  parametersPerItem: 5
1789
2185
  });
1790
- for (const valueChunk of chunkGVAMRRZR_cjs.chunk(values, chunkSize)) {
2186
+ for (const valueChunk of chunkSIT26LAZ_cjs.chunk(values, chunkSize)) {
1791
2187
  await executeIdentityStatement(
1792
2188
  target,
1793
- chunk2ZWM2RFH_cjs.sql`
2189
+ chunkEDN4Y4ZG_cjs.sql`
1794
2190
  INSERT INTO ${schema.identityClosureTable} (
1795
2191
  graph_id, member_kind, member_id, class_kind, class_id
1796
- ) VALUES ${chunk2ZWM2RFH_cjs.sql.join(valueChunk, chunk2ZWM2RFH_cjs.sql`, `)}
2192
+ ) VALUES ${chunkEDN4Y4ZG_cjs.sql.join(valueChunk, chunkEDN4Y4ZG_cjs.sql`, `)}
1797
2193
  `
1798
2194
  );
1799
2195
  }
@@ -1832,15 +2228,15 @@ async function replaceAffectedClosure(target, schema, graphId, references, sameI
1832
2228
  maxItems: MAX_REFERENCE_CHUNK_SIZE,
1833
2229
  parametersPerItem: 2
1834
2230
  });
1835
- for (const affectedChunk of chunkGVAMRRZR_cjs.chunk(affected, chunkSize)) {
2231
+ for (const affectedChunk of chunkSIT26LAZ_cjs.chunk(affected, chunkSize)) {
1836
2232
  const matches = referenceCondition(
1837
- chunk2ZWM2RFH_cjs.sql`member_kind`,
1838
- chunk2ZWM2RFH_cjs.sql`member_id`,
2233
+ chunkEDN4Y4ZG_cjs.sql`member_kind`,
2234
+ chunkEDN4Y4ZG_cjs.sql`member_id`,
1839
2235
  affectedChunk
1840
2236
  );
1841
2237
  await executeIdentityStatement(
1842
2238
  target,
1843
- chunk2ZWM2RFH_cjs.sql`
2239
+ chunkEDN4Y4ZG_cjs.sql`
1844
2240
  DELETE FROM ${schema.identityClosureTable}
1845
2241
  WHERE graph_id = ${graphId} AND ${matches}
1846
2242
  `
@@ -1876,7 +2272,7 @@ async function mergeCurrentClasses(target, schema, graphId, a, b) {
1876
2272
  if (refKey(previousCanonical) === refKey(canonical)) return;
1877
2273
  await executeIdentityStatement(
1878
2274
  target,
1879
- chunk2ZWM2RFH_cjs.sql`
2275
+ chunkEDN4Y4ZG_cjs.sql`
1880
2276
  UPDATE ${schema.identityClosureTable}
1881
2277
  SET class_kind = ${canonical.kind}, class_id = ${canonical.id}
1882
2278
  WHERE graph_id = ${graphId}
@@ -1892,47 +2288,120 @@ async function mergeCurrentClasses(target, schema, graphId, a, b) {
1892
2288
  );
1893
2289
  if (singletonMembers.length > 0) {
1894
2290
  const values = singletonMembers.map(
1895
- (member) => chunk2ZWM2RFH_cjs.sql`(${graphId}, ${member.kind}, ${member.id}, ${canonical.kind}, ${canonical.id})`
2291
+ (member) => chunkEDN4Y4ZG_cjs.sql`(${graphId}, ${member.kind}, ${member.id}, ${canonical.kind}, ${canonical.id})`
1896
2292
  );
1897
2293
  await executeIdentityStatement(
1898
2294
  target,
1899
- chunk2ZWM2RFH_cjs.sql`
2295
+ chunkEDN4Y4ZG_cjs.sql`
1900
2296
  INSERT INTO ${schema.identityClosureTable} (
1901
2297
  graph_id, member_kind, member_id, class_kind, class_id
1902
- ) VALUES ${chunk2ZWM2RFH_cjs.sql.join(values, chunk2ZWM2RFH_cjs.sql`, `)}
2298
+ ) VALUES ${chunkEDN4Y4ZG_cjs.sql.join(values, chunkEDN4Y4ZG_cjs.sql`, `)}
1903
2299
  `
1904
2300
  );
1905
2301
  }
1906
2302
  await replaceSeparationForMembers(target, schema, graphId, fusedMembers);
1907
2303
  }
1908
- async function assertPair(ctx, target, relation, firstInput, secondInput, touch) {
2304
+ async function assertPair(ctx, target, relation, firstInput, secondInput, touch, windowInput, operationInstant, windowValidator) {
1909
2305
  const first = registeredPlainRef(ctx, firstInput);
1910
2306
  const second = registeredPlainRef(ctx, secondInput);
1911
2307
  if (refKey(first) === refKey(second)) throw selfAssertionError(relation);
1912
2308
  const [a, b] = normalizePair(first, second);
1913
- await Promise.all([
1914
- requireLiveEndpoint(target, ctx.graphId, a),
1915
- requireLiveEndpoint(target, ctx.graphId, b)
1916
- ]);
1917
- const existing = await currentAssertionForPair(
2309
+ if (windowInput === void 0) {
2310
+ const current = await currentAssertionForPair(
2311
+ target,
2312
+ ctx.schema,
2313
+ ctx.graphId,
2314
+ relation,
2315
+ a,
2316
+ b
2317
+ );
2318
+ if (current !== void 0) {
2319
+ return assertionResult(publicAssertion(current), "existing");
2320
+ }
2321
+ await Promise.all([
2322
+ requireLiveEndpoint(target, ctx.graphId, a),
2323
+ requireLiveEndpoint(target, ctx.graphId, b)
2324
+ ]);
2325
+ await validateCurrentRelation(
2326
+ ctx,
2327
+ target,
2328
+ relation,
2329
+ relation === "same" ? "assertSame" : "assertDifferent",
2330
+ a,
2331
+ b
2332
+ );
2333
+ const row2 = await insertAssertion(
2334
+ target,
2335
+ ctx.schema,
2336
+ ctx.graphId,
2337
+ relation,
2338
+ a,
2339
+ b,
2340
+ operationInstant,
2341
+ touch
2342
+ );
2343
+ windowValidator?.record(row2);
2344
+ if (relation === "same") {
2345
+ await mergeCurrentClasses(target, ctx.schema, ctx.graphId, a, b);
2346
+ } else {
2347
+ await replaceSeparationForReferences(target, ctx.schema, ctx.graphId, [
2348
+ a,
2349
+ b
2350
+ ]);
2351
+ }
2352
+ return assertionResult(publicAssertion(row2), "created");
2353
+ }
2354
+ const window = resolveIdentityValidityWindow(windowInput, operationInstant);
2355
+ await requireEndpointsCoverIdentityWindow(
2356
+ target,
2357
+ ctx.graphId,
2358
+ [a, b],
2359
+ window
2360
+ );
2361
+ const existing = await assertionForExactWindow(
1918
2362
  target,
1919
2363
  ctx.schema,
1920
2364
  ctx.graphId,
1921
2365
  relation,
1922
2366
  a,
1923
- b
2367
+ b,
2368
+ window
1924
2369
  );
1925
2370
  if (existing !== void 0) {
1926
2371
  return assertionResult(publicAssertion(existing), "existing");
1927
2372
  }
1928
- await validateCurrentRelation(
1929
- ctx,
1930
- target,
1931
- relation,
1932
- relation === "same" ? "assertSame" : "assertDifferent",
1933
- a,
1934
- b
1935
- );
2373
+ if (window.effective === "current") {
2374
+ const current = await currentAssertionForPair(
2375
+ target,
2376
+ ctx.schema,
2377
+ ctx.graphId,
2378
+ relation,
2379
+ a,
2380
+ b
2381
+ );
2382
+ if (current !== void 0) {
2383
+ throw new chunkMRDBBHIZ_cjs.IdentityValidityWindowError({
2384
+ reason: "overlapping-open-window",
2385
+ validFrom: window.validFrom,
2386
+ operationInstant
2387
+ });
2388
+ }
2389
+ }
2390
+ const operation = relation === "same" ? "assertSame" : "assertDifferent";
2391
+ if (windowValidator === void 0) {
2392
+ await validateRelationThroughoutIdentityWindow(
2393
+ ctx,
2394
+ target,
2395
+ relation,
2396
+ operation,
2397
+ a,
2398
+ b,
2399
+ window,
2400
+ operationInstant
2401
+ );
2402
+ } else {
2403
+ windowValidator.validate(relation, operation, a, b, window);
2404
+ }
1936
2405
  const row = await insertAssertion(
1937
2406
  target,
1938
2407
  ctx.schema,
@@ -1940,9 +2409,17 @@ async function assertPair(ctx, target, relation, firstInput, secondInput, touch)
1940
2409
  relation,
1941
2410
  a,
1942
2411
  b,
1943
- chunk5PDSCELM_cjs.nowIso(),
1944
- touch
2412
+ operationInstant,
2413
+ touch,
2414
+ {
2415
+ validFrom: window.validFrom,
2416
+ ...window.validTo === void 0 ? {} : { validTo: window.validTo }
2417
+ }
1945
2418
  );
2419
+ windowValidator?.record(row);
2420
+ if (window.effective !== "current") {
2421
+ return assertionResult(publicAssertion(row), "created");
2422
+ }
1946
2423
  if (relation === "same") {
1947
2424
  await mergeCurrentClasses(target, ctx.schema, ctx.graphId, a, b);
1948
2425
  } else {
@@ -1956,7 +2433,7 @@ async function assertPair(ctx, target, relation, firstInput, secondInput, touch)
1956
2433
 
1957
2434
  // src/identity/assertion-key.ts
1958
2435
  function identityAssertionSemanticKey(relation, a, b) {
1959
- return encodeTupleKey([relation, a.kind, a.id, b.kind, b.id]);
2436
+ return chunkEZEEWCFJ_cjs.encodeTupleKey([relation, a.kind, a.id, b.kind, b.id]);
1960
2437
  }
1961
2438
 
1962
2439
  // src/identity/service-facade.ts
@@ -2053,7 +2530,7 @@ async function bulkAssertPairs(ctx, target, relation, pairs, touch) {
2053
2530
  const createdRows = [];
2054
2531
  const results = [];
2055
2532
  const closureReferences = [];
2056
- const timestamp = chunk5PDSCELM_cjs.nowIso();
2533
+ const timestamp = chunkTQHGE7UC_cjs.nowIso();
2057
2534
  const operation = relation === "same" ? "assertSame" : "assertDifferent";
2058
2535
  for (const [a, b] of normalizedPairs) {
2059
2536
  const semanticKey = assertionSemanticKey(relation, a, b);
@@ -2066,7 +2543,7 @@ async function bulkAssertPairs(ctx, target, relation, pairs, touch) {
2066
2543
  const rootB = unionFind.root(b);
2067
2544
  if (relation === "different") {
2068
2545
  if (rootA === rootB) {
2069
- throw new chunkKCH7WQA5_cjs.IdentityContradictionError({
2546
+ throw new chunkMRDBBHIZ_cjs.IdentityContradictionError({
2070
2547
  operation,
2071
2548
  a,
2072
2549
  b,
@@ -2076,7 +2553,7 @@ async function bulkAssertPairs(ctx, target, relation, pairs, touch) {
2076
2553
  } else {
2077
2554
  const spanning = differentByRoot.get(rootA)?.get(rootB);
2078
2555
  if (spanning !== void 0) {
2079
- throw new chunkKCH7WQA5_cjs.IdentityContradictionError({
2556
+ throw new chunkMRDBBHIZ_cjs.IdentityContradictionError({
2080
2557
  operation,
2081
2558
  a,
2082
2559
  b,
@@ -2090,7 +2567,7 @@ async function bulkAssertPairs(ctx, target, relation, pairs, touch) {
2090
2567
  kindsByRoot.get(rootB) ?? /* @__PURE__ */ new Set([b.kind])
2091
2568
  );
2092
2569
  if (disjointKinds !== void 0) {
2093
- throw new chunkKCH7WQA5_cjs.IdentityContradictionError({
2570
+ throw new chunkMRDBBHIZ_cjs.IdentityContradictionError({
2094
2571
  operation,
2095
2572
  a,
2096
2573
  b,
@@ -2147,10 +2624,44 @@ async function bulkAssertPairs(ctx, target, relation, pairs, touch) {
2147
2624
  }
2148
2625
  return results;
2149
2626
  }
2627
+ async function bulkAssertWindowedPairs(ctx, target, relation, pairs, touch, operationInstant) {
2628
+ const windowRequests = pairs.map((pair) => {
2629
+ const first = registeredPlainRef(ctx, pair.a);
2630
+ const second = registeredPlainRef(ctx, pair.b);
2631
+ return {
2632
+ references: normalizePair(first, second),
2633
+ window: resolveIdentityValidityWindow(pair, operationInstant)
2634
+ };
2635
+ });
2636
+ const windowValidator = await createIdentityWindowValidator(
2637
+ ctx,
2638
+ target,
2639
+ windowRequests,
2640
+ operationInstant
2641
+ );
2642
+ const results = [];
2643
+ for (const pair of pairs) {
2644
+ const window = hasExplicitIdentityValidityWindow(pair) ? pair : void 0;
2645
+ results.push(
2646
+ await assertPair(
2647
+ ctx,
2648
+ target,
2649
+ relation,
2650
+ pair.a,
2651
+ pair.b,
2652
+ touch,
2653
+ window,
2654
+ operationInstant,
2655
+ windowValidator
2656
+ )
2657
+ );
2658
+ }
2659
+ return results;
2660
+ }
2150
2661
  async function findCurrentAssertionById(target, schema, graphId, id) {
2151
2662
  const rows = await target.execute(
2152
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
2153
- SELECT ${chunkA4R3H7RU_cjs.IDENTITY_ASSERTION_COLUMNS}
2663
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
2664
+ SELECT ${chunkEZEEWCFJ_cjs.IDENTITY_ASSERTION_COLUMNS}
2154
2665
  FROM ${schema.identityAssertionsTable}
2155
2666
  WHERE graph_id = ${graphId}
2156
2667
  AND id = ${id}
@@ -2169,12 +2680,12 @@ async function retractById(ctx, target, id, touch) {
2169
2680
  id
2170
2681
  );
2171
2682
  if (existing === void 0) return void 0;
2172
- const now = chunk5PDSCELM_cjs.nowIso();
2683
+ const now = chunkTQHGE7UC_cjs.nowIso();
2173
2684
  const validTo = clampValidTo(now, existing.valid_from);
2174
2685
  const ended = { ...existing, valid_to: validTo, updated_at: now };
2175
2686
  await executeIdentityStatement(
2176
2687
  target,
2177
- chunk2ZWM2RFH_cjs.sql`
2688
+ chunkEDN4Y4ZG_cjs.sql`
2178
2689
  UPDATE ${ctx.schema.identityAssertionsTable}
2179
2690
  SET valid_to = ${validTo}, updated_at = ${now}
2180
2691
  WHERE graph_id = ${ctx.graphId}
@@ -2185,7 +2696,7 @@ async function retractById(ctx, target, id, touch) {
2185
2696
  touch(ctx.graphId, id, ended);
2186
2697
  return ended;
2187
2698
  }
2188
- async function retractByIds(ctx, target, ids, touch) {
2699
+ async function retractCurrentAssertions(ctx, target, ids, touch, resolveValidTo) {
2189
2700
  const uniqueIds = [...new Set(ids)];
2190
2701
  if (uniqueIds.length === 0) return [];
2191
2702
  const current = [];
@@ -2194,14 +2705,14 @@ async function retractByIds(ctx, target, ids, touch) {
2194
2705
  maxItems: MAX_REFERENCE_CHUNK_SIZE,
2195
2706
  parametersPerItem: 1
2196
2707
  });
2197
- for (const idChunk of chunkGVAMRRZR_cjs.chunk(uniqueIds, readChunkSize)) {
2198
- const placeholders = chunk2ZWM2RFH_cjs.sql.join(
2199
- idChunk.map((id) => chunk2ZWM2RFH_cjs.sql`${id}`),
2200
- chunk2ZWM2RFH_cjs.sql`, `
2708
+ for (const idChunk of chunkSIT26LAZ_cjs.chunk(uniqueIds, readChunkSize)) {
2709
+ const placeholders = chunkEDN4Y4ZG_cjs.sql.join(
2710
+ idChunk.map((id) => chunkEDN4Y4ZG_cjs.sql`${id}`),
2711
+ chunkEDN4Y4ZG_cjs.sql`, `
2201
2712
  );
2202
2713
  const rows = await target.execute(
2203
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
2204
- SELECT ${chunkA4R3H7RU_cjs.IDENTITY_ASSERTION_COLUMNS}
2714
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
2715
+ SELECT ${chunkEZEEWCFJ_cjs.IDENTITY_ASSERTION_COLUMNS}
2205
2716
  FROM ${ctx.schema.identityAssertionsTable}
2206
2717
  WHERE graph_id = ${ctx.graphId}
2207
2718
  AND id IN (${placeholders})
@@ -2212,11 +2723,11 @@ async function retractByIds(ctx, target, ids, touch) {
2212
2723
  current.push(...rows.map((row) => normalizeIdentityAssertionRow(row)));
2213
2724
  }
2214
2725
  if (current.length === 0) return [];
2215
- const now = chunk5PDSCELM_cjs.nowIso();
2726
+ const operationInstant = chunkTQHGE7UC_cjs.nowIso();
2216
2727
  const byValidTo = /* @__PURE__ */ new Map();
2217
2728
  const endedById = /* @__PURE__ */ new Map();
2218
2729
  for (const row of current) {
2219
- const validTo = clampValidTo(now, row.valid_from);
2730
+ const validTo = resolveValidTo(row, operationInstant);
2220
2731
  endedById.set(row.id, validTo);
2221
2732
  const group = byValidTo.get(validTo) ?? [];
2222
2733
  group.push(row.id);
@@ -2228,16 +2739,16 @@ async function retractByIds(ctx, target, ids, touch) {
2228
2739
  parametersPerItem: 1
2229
2740
  });
2230
2741
  for (const [validTo, ids2] of byValidTo) {
2231
- for (const idChunk of chunkGVAMRRZR_cjs.chunk(ids2, updateChunkSize)) {
2232
- const placeholders = chunk2ZWM2RFH_cjs.sql.join(
2233
- idChunk.map((id) => chunk2ZWM2RFH_cjs.sql`${id}`),
2234
- chunk2ZWM2RFH_cjs.sql`, `
2742
+ for (const idChunk of chunkSIT26LAZ_cjs.chunk(ids2, updateChunkSize)) {
2743
+ const placeholders = chunkEDN4Y4ZG_cjs.sql.join(
2744
+ idChunk.map((id) => chunkEDN4Y4ZG_cjs.sql`${id}`),
2745
+ chunkEDN4Y4ZG_cjs.sql`, `
2235
2746
  );
2236
2747
  await executeIdentityStatement(
2237
2748
  target,
2238
- chunk2ZWM2RFH_cjs.sql`
2749
+ chunkEDN4Y4ZG_cjs.sql`
2239
2750
  UPDATE ${ctx.schema.identityAssertionsTable}
2240
- SET valid_to = ${validTo}, updated_at = ${now}
2751
+ SET valid_to = ${validTo}, updated_at = ${operationInstant}
2241
2752
  WHERE graph_id = ${ctx.graphId}
2242
2753
  AND id IN (${placeholders})
2243
2754
  AND valid_to IS NULL
@@ -2253,7 +2764,7 @@ async function retractByIds(ctx, target, ids, touch) {
2253
2764
  {
2254
2765
  ...row,
2255
2766
  valid_to: chunkN66HCGCY_cjs.requireDefined(endedById.get(row.id)),
2256
- updated_at: now
2767
+ updated_at: operationInstant
2257
2768
  }
2258
2769
  ];
2259
2770
  });
@@ -2262,6 +2773,44 @@ async function retractByIds(ctx, target, ids, touch) {
2262
2773
  }
2263
2774
  return ended;
2264
2775
  }
2776
+ async function retractByIds(ctx, target, ids, touch) {
2777
+ return retractCurrentAssertions(
2778
+ ctx,
2779
+ target,
2780
+ ids,
2781
+ touch,
2782
+ (row, operationInstant) => clampValidTo(operationInstant, row.valid_from)
2783
+ );
2784
+ }
2785
+ async function retractPlannedAssertions(ctx, target, retractions, touch) {
2786
+ const retractionById = new Map(
2787
+ retractions.map((retraction) => [retraction.id, retraction])
2788
+ );
2789
+ return retractCurrentAssertions(
2790
+ ctx,
2791
+ target,
2792
+ retractions.map((retraction) => retraction.id),
2793
+ touch,
2794
+ (row, operationInstant) => {
2795
+ const retraction = chunkN66HCGCY_cjs.requireDefined(retractionById.get(row.id));
2796
+ if (retraction.validTo === void 0) {
2797
+ throw new chunkMRDBBHIZ_cjs.ConfigurationError(
2798
+ `Identity merge retraction ${retraction.id} is missing validTo.`,
2799
+ {
2800
+ code: "IDENTITY_MERGE_RETRACTION_REQUIRES_END",
2801
+ assertionId: retraction.id
2802
+ }
2803
+ );
2804
+ }
2805
+ return chunkN66HCGCY_cjs.requireDefined(
2806
+ resolveIdentityValidityWindow(
2807
+ { validFrom: row.valid_from, validTo: retraction.validTo },
2808
+ operationInstant
2809
+ ).validTo
2810
+ );
2811
+ }
2812
+ );
2813
+ }
2265
2814
  async function runIdentityMutation(ctx, fn) {
2266
2815
  let touched = false;
2267
2816
  return runInWriteTransaction(
@@ -2275,7 +2824,7 @@ async function runIdentityMutation(ctx, fn) {
2275
2824
  ctx.backend,
2276
2825
  async (target) => {
2277
2826
  await lockIdentityGraph(target, ctx.graphId);
2278
- return chunkA4R3H7RU_cjs.withRecordedIdentityMutationTarget(
2827
+ return chunkEZEEWCFJ_cjs.withRecordedIdentityMutationTarget(
2279
2828
  target,
2280
2829
  (rawTarget, touch) => fn(
2281
2830
  rawTarget,
@@ -2400,7 +2949,7 @@ function createIdentityReadFacade(ctx) {
2400
2949
  );
2401
2950
  return assertions.filter(
2402
2951
  (assertion) => assertion.a_kind === ref.kind && assertion.a_id === ref.id || assertion.b_kind === ref.kind && assertion.b_id === ref.id
2403
- ).toSorted((left, right) => chunkA4R3H7RU_cjs.compareCodePoints(left.id, right.id)).map((assertion) => publicAssertion(assertion));
2952
+ ).toSorted((left, right) => chunkEZEEWCFJ_cjs.compareCodePoints(left.id, right.id)).map((assertion) => publicAssertion(assertion));
2404
2953
  }
2405
2954
  };
2406
2955
  }
@@ -2423,29 +2972,65 @@ function partitionRetractedEndpoints(retracted) {
2423
2972
  function createIdentityFacade(ctx) {
2424
2973
  return {
2425
2974
  ...createIdentityReadFacade(ctx),
2426
- assertSame(a, b) {
2427
- return runIdentityMutation(
2428
- ctx,
2429
- (target, touch) => assertPair(ctx, target, "same", a, b, touch)
2430
- );
2975
+ assertSame(a, b, window) {
2976
+ return runIdentityMutation(ctx, (target, touch) => {
2977
+ const operationInstant = chunkTQHGE7UC_cjs.nowIso();
2978
+ return assertPair(
2979
+ ctx,
2980
+ target,
2981
+ "same",
2982
+ a,
2983
+ b,
2984
+ touch,
2985
+ hasExplicitIdentityValidityWindow(window) ? window : void 0,
2986
+ operationInstant
2987
+ );
2988
+ });
2431
2989
  },
2432
- assertDifferent(a, b) {
2433
- return runIdentityMutation(
2434
- ctx,
2435
- (target, touch) => assertPair(ctx, target, "different", a, b, touch)
2436
- );
2990
+ assertDifferent(a, b, window) {
2991
+ return runIdentityMutation(ctx, (target, touch) => {
2992
+ const operationInstant = chunkTQHGE7UC_cjs.nowIso();
2993
+ return assertPair(
2994
+ ctx,
2995
+ target,
2996
+ "different",
2997
+ a,
2998
+ b,
2999
+ touch,
3000
+ hasExplicitIdentityValidityWindow(window) ? window : void 0,
3001
+ operationInstant
3002
+ );
3003
+ });
2437
3004
  },
2438
3005
  bulkAssertSame(pairs) {
2439
- return runIdentityMutation(
2440
- ctx,
2441
- (target, touch) => bulkAssertPairs(ctx, target, "same", pairs, touch)
2442
- );
3006
+ return runIdentityMutation(ctx, (target, touch) => {
3007
+ if (!pairs.some((pair) => hasExplicitIdentityValidityWindow(pair))) {
3008
+ return bulkAssertPairs(ctx, target, "same", pairs, touch);
3009
+ }
3010
+ return bulkAssertWindowedPairs(
3011
+ ctx,
3012
+ target,
3013
+ "same",
3014
+ pairs,
3015
+ touch,
3016
+ chunkTQHGE7UC_cjs.nowIso()
3017
+ );
3018
+ });
2443
3019
  },
2444
3020
  bulkAssertDifferent(pairs) {
2445
- return runIdentityMutation(
2446
- ctx,
2447
- (target, touch) => bulkAssertPairs(ctx, target, "different", pairs, touch)
2448
- );
3021
+ return runIdentityMutation(ctx, (target, touch) => {
3022
+ if (!pairs.some((pair) => hasExplicitIdentityValidityWindow(pair))) {
3023
+ return bulkAssertPairs(ctx, target, "different", pairs, touch);
3024
+ }
3025
+ return bulkAssertWindowedPairs(
3026
+ ctx,
3027
+ target,
3028
+ "different",
3029
+ pairs,
3030
+ touch,
3031
+ chunkTQHGE7UC_cjs.nowIso()
3032
+ );
3033
+ });
2449
3034
  },
2450
3035
  retractAssertion(id) {
2451
3036
  return runIdentityMutation(ctx, async (target, touch) => {
@@ -2551,7 +3136,7 @@ function createIdentityFacade(ctx) {
2551
3136
 
2552
3137
  // src/identity/service-interchange-write.ts
2553
3138
  function transferShapeError(assertion, message, issue) {
2554
- return new chunkKCH7WQA5_cjs.ValidationError(message, {
3139
+ return new chunkMRDBBHIZ_cjs.ValidationError(message, {
2555
3140
  issues: [
2556
3141
  {
2557
3142
  path: "identity.assertions",
@@ -2562,7 +3147,7 @@ function transferShapeError(assertion, message, issue) {
2562
3147
  ]
2563
3148
  });
2564
3149
  }
2565
- function validateTransferShape(ctx, assertion, mode) {
3150
+ function validateTransferShape(ctx, assertion, mode, operationInstant) {
2566
3151
  if (!ctx.registry.nodeKinds.has(assertion.a.kind) || !ctx.registry.nodeKinds.has(assertion.b.kind)) {
2567
3152
  throw transferShapeError(
2568
3153
  assertion,
@@ -2604,25 +3189,31 @@ function validateTransferShape(ctx, assertion, mode) {
2604
3189
  }
2605
3190
  );
2606
3191
  }
2607
- const now = chunk5PDSCELM_cjs.nowIso();
2608
- if (assertion.validTo === void 0 && chunkA4R3H7RU_cjs.compareCodePoints(assertion.validFrom, now) > 0) {
2609
- throw transferShapeError(
2610
- assertion,
2611
- "Identity import cannot contain future-dated open assertions.",
3192
+ let window;
3193
+ try {
3194
+ window = resolveIdentityValidityWindow(
2612
3195
  {
2613
- message: `Assertion ${assertion.id} validFrom is in the future`,
2614
- code: "IDENTITY_IMPORT_FUTURE_VALID_FROM"
2615
- }
3196
+ validFrom: assertion.validFrom,
3197
+ ...assertion.validTo === void 0 ? {} : { validTo: assertion.validTo }
3198
+ },
3199
+ operationInstant
2616
3200
  );
2617
- }
2618
- if (assertion.validTo !== void 0 && chunkA4R3H7RU_cjs.compareCodePoints(assertion.validTo, assertion.validFrom) < 0) {
3201
+ } catch (error) {
3202
+ if (!(error instanceof chunkMRDBBHIZ_cjs.IdentityValidityWindowError)) throw error;
3203
+ const issue = error.details.reason === "future-valid-from" ? {
3204
+ code: "IDENTITY_IMPORT_FUTURE_VALID_FROM",
3205
+ message: `Assertion ${assertion.id} validFrom is in the future`
3206
+ } : error.details.reason === "future-valid-to" ? {
3207
+ code: "IDENTITY_IMPORT_FUTURE_VALID_TO",
3208
+ message: `Assertion ${assertion.id} validTo is in the future`
3209
+ } : {
3210
+ code: "IDENTITY_IMPORT_INVALID_WINDOW",
3211
+ message: `Assertion ${assertion.id} validTo must not precede validFrom`
3212
+ };
2619
3213
  throw transferShapeError(
2620
3214
  assertion,
2621
- "Identity assertion validity window is empty.",
2622
- {
2623
- message: `Assertion ${assertion.id} validTo must not precede validFrom`,
2624
- code: "IDENTITY_IMPORT_INVALID_WINDOW"
2625
- }
3215
+ "Identity import contains an unsupported validity window.",
3216
+ issue
2626
3217
  );
2627
3218
  }
2628
3219
  if (assertion.endedBy !== void 0) {
@@ -2648,17 +3239,7 @@ function validateTransferShape(ctx, assertion, mode) {
2648
3239
  );
2649
3240
  }
2650
3241
  }
2651
- if (assertion.validTo !== void 0 && chunkA4R3H7RU_cjs.compareCodePoints(assertion.validTo, now) > 0) {
2652
- throw transferShapeError(
2653
- assertion,
2654
- "Identity import cannot contain assertions that end in the future.",
2655
- {
2656
- message: `Assertion ${assertion.id} validTo is in the future`,
2657
- code: "IDENTITY_IMPORT_FUTURE_VALID_TO"
2658
- }
2659
- );
2660
- }
2661
- return normalized;
3242
+ return { endpoints: normalized, window };
2662
3243
  }
2663
3244
  var IDENTITY_IMPORT_FAILED_ASSERTION = /* @__PURE__ */ Symbol(
2664
3245
  "typegraph.identity.failedAssertionId"
@@ -2681,13 +3262,14 @@ function rethrowTaggedWithAssertion(error, assertionId, progress) {
2681
3262
  }
2682
3263
  throw error;
2683
3264
  }
2684
- async function importIdentityAssertionsIntoTarget(ctx, target, assertions, mode) {
3265
+ async function importIdentityAssertionsIntoTarget(ctx, target, assertions, mode, ignoredAssertionIds = /* @__PURE__ */ new Set()) {
2685
3266
  let created = 0;
2686
3267
  let skipped = 0;
2687
- await chunkA4R3H7RU_cjs.withRecordedIdentityMutationTarget(target, async (rawTarget, touch) => {
3268
+ await chunkEZEEWCFJ_cjs.withRecordedIdentityMutationTarget(target, async (rawTarget, touch) => {
3269
+ const operationInstant = chunkTQHGE7UC_cjs.nowIso();
2688
3270
  const normalized = assertions.map((assertion) => ({
2689
3271
  assertion,
2690
- endpoints: validateTransferShape(ctx, assertion, mode)
3272
+ ...validateTransferShape(ctx, assertion, mode, operationInstant)
2691
3273
  }));
2692
3274
  const existingById = await loadAssertionsByIds(
2693
3275
  rawTarget,
@@ -2706,7 +3288,7 @@ async function importIdentityAssertionsIntoTarget(ctx, target, assertions, mode)
2706
3288
  }
2707
3289
  }
2708
3290
  const attributeMissingEndpoint = (error, ended) => {
2709
- if (error instanceof chunkKCH7WQA5_cjs.NodeNotFoundError) {
3291
+ if (error instanceof chunkMRDBBHIZ_cjs.NodeNotFoundError) {
2710
3292
  const missing = { kind: error.details.kind, id: error.details.id };
2711
3293
  const failing = normalized.find(
2712
3294
  ({ assertion, endpoints }) => assertion.validTo !== void 0 === ended && endpoints.some(
@@ -2742,7 +3324,17 @@ async function importIdentityAssertionsIntoTarget(ctx, target, assertions, mode)
2742
3324
  } catch (error) {
2743
3325
  attributeMissingEndpoint(error, true);
2744
3326
  }
2745
- for (const { assertion, endpoints } of normalized) {
3327
+ const windowValidator = await createIdentityWindowValidator(
3328
+ ctx,
3329
+ rawTarget,
3330
+ normalized.map(({ endpoints, window }) => ({
3331
+ references: endpoints,
3332
+ window
3333
+ })),
3334
+ operationInstant,
3335
+ ignoredAssertionIds
3336
+ );
3337
+ for (const { assertion, endpoints, window } of normalized) {
2746
3338
  const [a, b] = endpoints;
2747
3339
  try {
2748
3340
  const sameId = existingById.get(assertion.id);
@@ -2752,7 +3344,7 @@ async function importIdentityAssertionsIntoTarget(ctx, target, assertions, mode)
2752
3344
  skipped += 1;
2753
3345
  continue;
2754
3346
  }
2755
- throw new chunkKCH7WQA5_cjs.ConfigurationError(
3347
+ throw new chunkMRDBBHIZ_cjs.ConfigurationError(
2756
3348
  `Identity assertion id ${assertion.id} already identifies different truth.`,
2757
3349
  {
2758
3350
  code: "IDENTITY_IMPORT_ID_CONFLICT",
@@ -2761,73 +3353,102 @@ async function importIdentityAssertionsIntoTarget(ctx, target, assertions, mode)
2761
3353
  }
2762
3354
  );
2763
3355
  }
2764
- if (assertion.validTo !== void 0) {
2765
- const timestamp = assertion.validFrom;
2766
- const row = {
2767
- graph_id: ctx.graphId,
2768
- id: assertion.id,
2769
- rel: assertion.relation,
2770
- a_kind: a.kind,
2771
- a_id: a.id,
2772
- b_kind: b.kind,
2773
- b_id: b.id,
2774
- valid_from: assertion.validFrom,
2775
- valid_to: assertion.validTo,
2776
- created_at: timestamp,
2777
- updated_at: assertion.validTo,
2778
- deleted_at: void 0,
2779
- ended_by_kind: assertion.endedBy?.kind,
2780
- ended_by_id: assertion.endedBy?.id
2781
- };
2782
- await insertAssertionRows(rawTarget, ctx.schema, [row]);
2783
- touch(ctx.graphId, row.id, row);
2784
- existingById.set(row.id, row);
2785
- created += 1;
2786
- continue;
2787
- }
2788
- const existing = await currentAssertionForPair(
3356
+ const exactWindow = await assertionForExactWindow(
2789
3357
  rawTarget,
2790
3358
  ctx.schema,
2791
3359
  ctx.graphId,
2792
3360
  assertion.relation,
2793
3361
  a,
2794
- b
3362
+ b,
3363
+ window
2795
3364
  );
2796
- if (existing !== void 0) {
3365
+ if (exactWindow !== void 0) {
2797
3366
  skipped += 1;
2798
3367
  continue;
2799
3368
  }
2800
- await validateCurrentRelation(
2801
- ctx,
2802
- rawTarget,
2803
- assertion.relation,
2804
- "import",
2805
- a,
2806
- b
2807
- );
2808
- const inserted = await insertAssertion(
2809
- rawTarget,
2810
- ctx.schema,
2811
- ctx.graphId,
2812
- assertion.relation,
2813
- a,
2814
- b,
2815
- chunk5PDSCELM_cjs.nowIso(),
2816
- touch,
2817
- { id: assertion.id, validFrom: assertion.validFrom }
2818
- );
2819
- existingById.set(inserted.id, inserted);
2820
- created += 1;
2821
- if (assertion.relation === "same") {
2822
- await mergeCurrentClasses(rawTarget, ctx.schema, ctx.graphId, a, b);
2823
- } else {
2824
- await replaceSeparationForReferences(
3369
+ if (window.effective === "current") {
3370
+ const current = await currentAssertionForPair(
3371
+ rawTarget,
3372
+ ctx.schema,
3373
+ ctx.graphId,
3374
+ assertion.relation,
3375
+ a,
3376
+ b
3377
+ );
3378
+ if (current !== void 0) {
3379
+ skipped += 1;
3380
+ continue;
3381
+ }
3382
+ await requireEndpointsCoverIdentityWindow(
3383
+ rawTarget,
3384
+ ctx.graphId,
3385
+ [a, b],
3386
+ window
3387
+ );
3388
+ windowValidator.validate(assertion.relation, "import", a, b, window);
3389
+ await validateCurrentRelation(
3390
+ ctx,
3391
+ rawTarget,
3392
+ assertion.relation,
3393
+ "import",
3394
+ a,
3395
+ b
3396
+ );
3397
+ const inserted = await insertAssertion(
2825
3398
  rawTarget,
2826
3399
  ctx.schema,
2827
3400
  ctx.graphId,
2828
- [a, b]
3401
+ assertion.relation,
3402
+ a,
3403
+ b,
3404
+ operationInstant,
3405
+ touch,
3406
+ { id: assertion.id, validFrom: window.validFrom }
2829
3407
  );
3408
+ existingById.set(inserted.id, inserted);
3409
+ windowValidator.record(inserted);
3410
+ created += 1;
3411
+ if (assertion.relation === "same") {
3412
+ await mergeCurrentClasses(rawTarget, ctx.schema, ctx.graphId, a, b);
3413
+ } else {
3414
+ await replaceSeparationForReferences(
3415
+ rawTarget,
3416
+ ctx.schema,
3417
+ ctx.graphId,
3418
+ [a, b]
3419
+ );
3420
+ }
3421
+ continue;
2830
3422
  }
3423
+ await requireEndpointsCoverIdentityWindow(
3424
+ rawTarget,
3425
+ ctx.graphId,
3426
+ [a, b],
3427
+ window
3428
+ );
3429
+ windowValidator.validate(assertion.relation, "import", a, b, window);
3430
+ const timestamp = window.validFrom;
3431
+ const row = {
3432
+ graph_id: ctx.graphId,
3433
+ id: assertion.id,
3434
+ rel: assertion.relation,
3435
+ a_kind: a.kind,
3436
+ a_id: a.id,
3437
+ b_kind: b.kind,
3438
+ b_id: b.id,
3439
+ valid_from: window.validFrom,
3440
+ valid_to: window.validTo,
3441
+ created_at: timestamp,
3442
+ updated_at: window.validTo ?? window.validFrom,
3443
+ deleted_at: void 0,
3444
+ ended_by_kind: assertion.endedBy?.kind,
3445
+ ended_by_id: assertion.endedBy?.id
3446
+ };
3447
+ await insertAssertionRows(rawTarget, ctx.schema, [row]);
3448
+ touch(ctx.graphId, row.id, row);
3449
+ existingById.set(row.id, row);
3450
+ windowValidator.record(row);
3451
+ created += 1;
2831
3452
  } catch (error) {
2832
3453
  rethrowTaggedWithAssertion(error, assertion.id, { created, skipped });
2833
3454
  }
@@ -2835,12 +3456,17 @@ async function importIdentityAssertionsIntoTarget(ctx, target, assertions, mode)
2835
3456
  });
2836
3457
  return { created, skipped };
2837
3458
  }
2838
- async function applyIdentityChangesForContext(ctx, retractionIds, assertions) {
2839
- if (retractionIds.length === 0 && assertions.length === 0) {
3459
+ async function applyIdentityChangesForContext(ctx, retractions, assertions) {
3460
+ if (retractions.length === 0 && assertions.length === 0) {
2840
3461
  return { created: 0, retracted: 0 };
2841
3462
  }
2842
3463
  return runIdentityMutation(ctx, async (target, touch, markWritten) => {
2843
- const retracted = await retractByIds(ctx, target, retractionIds, touch);
3464
+ const retracted = await retractPlannedAssertions(
3465
+ ctx,
3466
+ target,
3467
+ retractions,
3468
+ touch
3469
+ );
2844
3470
  const { closureReferences, separationReferences } = partitionRetractedEndpoints(retracted);
2845
3471
  if (closureReferences.length > 0) {
2846
3472
  await replaceAffectedClosure(
@@ -2861,7 +3487,8 @@ async function applyIdentityChangesForContext(ctx, retractionIds, assertions) {
2861
3487
  ctx,
2862
3488
  target,
2863
3489
  assertions,
2864
- "state"
3490
+ "archival",
3491
+ new Set(retracted.map((assertion) => assertion.id))
2865
3492
  );
2866
3493
  if (summary.created > 0) markWritten();
2867
3494
  return { created: summary.created, retracted: retracted.length };
@@ -2871,7 +3498,7 @@ async function applyIdentityChangesForContext(ctx, retractionIds, assertions) {
2871
3498
  // src/identity/service-maintenance.ts
2872
3499
  function requireAtomicIdentityBackend(backend, graphId) {
2873
3500
  if (!backend.capabilities.transactions) {
2874
- throw new chunkKCH7WQA5_cjs.ConfigurationError(
3501
+ throw new chunkMRDBBHIZ_cjs.ConfigurationError(
2875
3502
  "Operational Identity requires atomic transaction support.",
2876
3503
  { code: "IDENTITY_REQUIRES_ATOMIC_BACKEND", graphId }
2877
3504
  );
@@ -2888,7 +3515,7 @@ async function rebuildIdentityClosureForContext(ctx) {
2888
3515
  requireAtomicIdentityBackend(ctx.backend, ctx.graphId);
2889
3516
  async function rebuildAtTarget(target) {
2890
3517
  await lockIdentityGraph(target, ctx.graphId);
2891
- await chunkA4R3H7RU_cjs.withRecordedIdentityMutationTarget(target, async (rawTarget) => {
3518
+ await chunkEZEEWCFJ_cjs.withRecordedIdentityMutationTarget(target, async (rawTarget) => {
2892
3519
  const activeKinds = identityActiveKinds(ctx.registry);
2893
3520
  const snapshot = await loadSnapshot(
2894
3521
  rawTarget,
@@ -2986,7 +3613,7 @@ async function findAffectedClassInconsistency(ctx, target, seeds) {
2986
3613
  const [leftKind, rightKind] = conflictingKinds;
2987
3614
  return {
2988
3615
  kind: "contradiction",
2989
- error: new chunkKCH7WQA5_cjs.IdentityContradictionError({
3616
+ error: new chunkMRDBBHIZ_cjs.IdentityContradictionError({
2990
3617
  operation: "merge",
2991
3618
  a: firstMemberOfKind(members, leftKind),
2992
3619
  b: firstMemberOfKind(members, rightKind),
@@ -3012,7 +3639,7 @@ async function findAffectedClassInconsistency(ctx, target, seeds) {
3012
3639
  if (aClassKey === void 0 || aClassKey !== bClassKey) continue;
3013
3640
  return {
3014
3641
  kind: "contradiction",
3015
- error: new chunkKCH7WQA5_cjs.IdentityContradictionError({
3642
+ error: new chunkMRDBBHIZ_cjs.IdentityContradictionError({
3016
3643
  operation: "merge",
3017
3644
  a,
3018
3645
  b,
@@ -3080,7 +3707,7 @@ async function assertAffectedIdentityClassesConsistent(ctx, target, seeds) {
3080
3707
  await lockIdentityGraph(target, ctx.graphId);
3081
3708
  const observed = await findAffectedClassInconsistency(ctx, target, seeds);
3082
3709
  if (observed === void 0) return;
3083
- await chunkA4R3H7RU_cjs.withRecordedIdentityMutationTarget(target, async (rawTarget) => {
3710
+ await chunkEZEEWCFJ_cjs.withRecordedIdentityMutationTarget(target, async (rawTarget) => {
3084
3711
  await replaceClosure(
3085
3712
  rawTarget,
3086
3713
  ctx.schema,
@@ -3103,14 +3730,14 @@ async function deleteAssertionsTouchingKinds(target, schema, graphId, kinds, tou
3103
3730
  maxItems: MAX_REFERENCE_CHUNK_SIZE,
3104
3731
  parametersPerItem: 2
3105
3732
  });
3106
- for (const kindChunk of chunkGVAMRRZR_cjs.chunk(removedKinds, kindChunkSize)) {
3107
- const kindList2 = chunk2ZWM2RFH_cjs.sql.join(
3108
- kindChunk.map((kind) => chunk2ZWM2RFH_cjs.sql`${kind}`),
3109
- chunk2ZWM2RFH_cjs.sql`, `
3733
+ for (const kindChunk of chunkSIT26LAZ_cjs.chunk(removedKinds, kindChunkSize)) {
3734
+ const kindList2 = chunkEDN4Y4ZG_cjs.sql.join(
3735
+ kindChunk.map((kind) => chunkEDN4Y4ZG_cjs.sql`${kind}`),
3736
+ chunkEDN4Y4ZG_cjs.sql`, `
3110
3737
  );
3111
3738
  const rows = await target.execute(
3112
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
3113
- SELECT ${chunkA4R3H7RU_cjs.IDENTITY_ASSERTION_COLUMNS}
3739
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
3740
+ SELECT ${chunkEZEEWCFJ_cjs.IDENTITY_ASSERTION_COLUMNS}
3114
3741
  FROM ${schema.identityAssertionsTable}
3115
3742
  WHERE graph_id = ${graphId}
3116
3743
  AND (a_kind IN (${kindList2}) OR b_kind IN (${kindList2}))
@@ -3127,14 +3754,14 @@ async function deleteAssertionsTouchingKinds(target, schema, graphId, kinds, tou
3127
3754
  maxItems: MAX_REFERENCE_CHUNK_SIZE,
3128
3755
  parametersPerItem: 1
3129
3756
  });
3130
- for (const idChunk of chunkGVAMRRZR_cjs.chunk(ids, idChunkSize)) {
3131
- const idList = chunk2ZWM2RFH_cjs.sql.join(
3132
- idChunk.map((id) => chunk2ZWM2RFH_cjs.sql`${id}`),
3133
- chunk2ZWM2RFH_cjs.sql`, `
3757
+ for (const idChunk of chunkSIT26LAZ_cjs.chunk(ids, idChunkSize)) {
3758
+ const idList = chunkEDN4Y4ZG_cjs.sql.join(
3759
+ idChunk.map((id) => chunkEDN4Y4ZG_cjs.sql`${id}`),
3760
+ chunkEDN4Y4ZG_cjs.sql`, `
3134
3761
  );
3135
3762
  await executeIdentityStatement(
3136
3763
  target,
3137
- chunk2ZWM2RFH_cjs.sql`
3764
+ chunkEDN4Y4ZG_cjs.sql`
3138
3765
  DELETE FROM ${schema.identityAssertionsTable}
3139
3766
  WHERE graph_id = ${graphId} AND id IN (${idList})
3140
3767
  `
@@ -3151,13 +3778,13 @@ async function hasAssertionsTouchingKinds(target, schema, graphId, kinds) {
3151
3778
  maxItems: MAX_REFERENCE_CHUNK_SIZE,
3152
3779
  parametersPerItem: 2
3153
3780
  });
3154
- for (const kindChunk of chunkGVAMRRZR_cjs.chunk(probedKinds, kindChunkSize)) {
3155
- const kindList2 = chunk2ZWM2RFH_cjs.sql.join(
3156
- kindChunk.map((kind) => chunk2ZWM2RFH_cjs.sql`${kind}`),
3157
- chunk2ZWM2RFH_cjs.sql`, `
3781
+ for (const kindChunk of chunkSIT26LAZ_cjs.chunk(probedKinds, kindChunkSize)) {
3782
+ const kindList2 = chunkEDN4Y4ZG_cjs.sql.join(
3783
+ kindChunk.map((kind) => chunkEDN4Y4ZG_cjs.sql`${kind}`),
3784
+ chunkEDN4Y4ZG_cjs.sql`, `
3158
3785
  );
3159
3786
  const rows = await target.execute(
3160
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
3787
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
3161
3788
  SELECT id
3162
3789
  FROM ${schema.identityAssertionsTable}
3163
3790
  WHERE graph_id = ${graphId}
@@ -3171,7 +3798,7 @@ async function hasAssertionsTouchingKinds(target, schema, graphId, kinds) {
3171
3798
  }
3172
3799
  async function purgeAssertionsWithUnregisteredKinds(target, schema, graphId, registeredKinds, touch) {
3173
3800
  const pairs = await target.execute(
3174
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
3801
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
3175
3802
  SELECT DISTINCT a_kind, b_kind
3176
3803
  FROM ${schema.identityAssertionsTable}
3177
3804
  WHERE graph_id = ${graphId}
@@ -3221,13 +3848,13 @@ async function liveNodeKindsSharingIds(ctx, target, ids) {
3221
3848
  maxItems: MAX_REFERENCE_CHUNK_SIZE,
3222
3849
  parametersPerItem: 1
3223
3850
  });
3224
- for (const idChunk of chunkGVAMRRZR_cjs.chunk(uniqueIds, chunkSize)) {
3225
- const idList = chunk2ZWM2RFH_cjs.sql.join(
3226
- idChunk.map((id) => chunk2ZWM2RFH_cjs.sql`${id}`),
3227
- chunk2ZWM2RFH_cjs.sql`, `
3851
+ for (const idChunk of chunkSIT26LAZ_cjs.chunk(uniqueIds, chunkSize)) {
3852
+ const idList = chunkEDN4Y4ZG_cjs.sql.join(
3853
+ idChunk.map((id) => chunkEDN4Y4ZG_cjs.sql`${id}`),
3854
+ chunkEDN4Y4ZG_cjs.sql`, `
3228
3855
  );
3229
3856
  const rows = await target.execute(
3230
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
3857
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
3231
3858
  SELECT kind, id
3232
3859
  FROM ${ctx.schema.nodesTable}
3233
3860
  WHERE graph_id = ${ctx.graphId}
@@ -3247,7 +3874,7 @@ async function liveNodeKindsSharingIds(ctx, target, ids) {
3247
3874
  async function foldIdentityForCreatedNodes(ctx, target, references) {
3248
3875
  if (references.length === 0 || ctx.sameIdAcrossKinds === "ignore") return;
3249
3876
  await lockIdentityGraph(target, ctx.graphId);
3250
- await chunkA4R3H7RU_cjs.withRecordedIdentityMutationTarget(target, async (rawTarget) => {
3877
+ await chunkEZEEWCFJ_cjs.withRecordedIdentityMutationTarget(target, async (rawTarget) => {
3251
3878
  const liveKindsById = await liveNodeKindsSharingIds(
3252
3879
  ctx,
3253
3880
  rawTarget,
@@ -3287,7 +3914,7 @@ async function foldIdentityForCreatedNodes(ctx, target, references) {
3287
3914
  }
3288
3915
  async function hasMaterializedIdentityClass(target, schema, graphId, ref) {
3289
3916
  const rows = await target.execute(
3290
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
3917
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
3291
3918
  SELECT member_kind, member_id
3292
3919
  FROM ${schema.identityClosureTable}
3293
3920
  WHERE graph_id = ${graphId}
@@ -3300,7 +3927,7 @@ async function hasMaterializedIdentityClass(target, schema, graphId, ref) {
3300
3927
  }
3301
3928
  async function readNodeDeletionInstant(target, schema, graphId, ref) {
3302
3929
  const rows = await target.execute(
3303
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
3930
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
3304
3931
  SELECT deleted_at
3305
3932
  FROM ${schema.nodesTable}
3306
3933
  WHERE graph_id = ${graphId}
@@ -3312,19 +3939,47 @@ async function readNodeDeletionInstant(target, schema, graphId, ref) {
3312
3939
  const row = rows.at(0);
3313
3940
  return row === void 0 ? void 0 : optionalIdentityTimestamp(row.deleted_at);
3314
3941
  }
3942
+ async function requireNodeValidityEndCompatible(ctx, target, ref, validTo) {
3943
+ const rows = await target.execute(
3944
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
3945
+ SELECT ${chunkEZEEWCFJ_cjs.IDENTITY_ASSERTION_COLUMNS}
3946
+ FROM ${ctx.schema.identityAssertionsTable}
3947
+ WHERE graph_id = ${ctx.graphId}
3948
+ AND deleted_at IS NULL
3949
+ AND (valid_to IS NULL OR valid_to > ${validTo})
3950
+ AND (
3951
+ (a_kind = ${ref.kind} AND a_id = ${ref.id})
3952
+ OR (b_kind = ${ref.kind} AND b_id = ${ref.id})
3953
+ )
3954
+ ORDER BY id
3955
+ LIMIT 1
3956
+ `)
3957
+ );
3958
+ const row = rows.at(0);
3959
+ if (row === void 0) return;
3960
+ const assertion = normalizeIdentityAssertionRow(row);
3961
+ throw new chunkMRDBBHIZ_cjs.IdentityEndpointValidityError({
3962
+ endpoint: ref,
3963
+ assertionWindow: {
3964
+ validFrom: assertion.valid_from,
3965
+ ...assertion.valid_to === void 0 ? {} : { validTo: assertion.valid_to }
3966
+ },
3967
+ endpointWindow: { validTo }
3968
+ });
3969
+ }
3315
3970
  async function detachIdentityForNode(ctx, target, ref, mode) {
3316
3971
  await lockIdentityGraph(target, ctx.graphId);
3317
- await chunkA4R3H7RU_cjs.withRecordedIdentityMutationTarget(target, async (rawTarget, touch) => {
3318
- const touchesNode = chunk2ZWM2RFH_cjs.sql`
3972
+ await chunkEZEEWCFJ_cjs.withRecordedIdentityMutationTarget(target, async (rawTarget, touch) => {
3973
+ const touchesNode = chunkEDN4Y4ZG_cjs.sql`
3319
3974
  (
3320
3975
  (a_kind = ${ref.kind} AND a_id = ${ref.id})
3321
3976
  OR (b_kind = ${ref.kind} AND b_id = ${ref.id})
3322
3977
  )
3323
3978
  `;
3324
- const scope = mode === "hard" ? chunk2ZWM2RFH_cjs.sql`` : chunk2ZWM2RFH_cjs.sql`AND valid_to IS NULL AND deleted_at IS NULL`;
3979
+ const scope = mode === "hard" ? chunkEDN4Y4ZG_cjs.sql`` : chunkEDN4Y4ZG_cjs.sql`AND valid_to IS NULL AND deleted_at IS NULL`;
3325
3980
  const rows = await rawTarget.execute(
3326
- chunk2ZWM2RFH_cjs.asCompiledRowsSql(chunk2ZWM2RFH_cjs.sql`
3327
- SELECT ${chunkA4R3H7RU_cjs.IDENTITY_ASSERTION_COLUMNS}
3981
+ chunkEDN4Y4ZG_cjs.asCompiledRowsSql(chunkEDN4Y4ZG_cjs.sql`
3982
+ SELECT ${chunkEZEEWCFJ_cjs.IDENTITY_ASSERTION_COLUMNS}
3328
3983
  FROM ${ctx.schema.identityAssertionsTable}
3329
3984
  WHERE graph_id = ${ctx.graphId}
3330
3985
  ${scope}
@@ -3339,7 +3994,7 @@ async function detachIdentityForNode(ctx, target, ref, mode) {
3339
3994
  )) {
3340
3995
  return;
3341
3996
  }
3342
- const now = chunk5PDSCELM_cjs.nowIso();
3997
+ const now = chunkTQHGE7UC_cjs.nowIso();
3343
3998
  const cascadeInstant = mode === "hard" || rows.length === 0 ? now : await readNodeDeletionInstant(
3344
3999
  rawTarget,
3345
4000
  ctx.schema,
@@ -3351,7 +4006,7 @@ async function detachIdentityForNode(ctx, target, ref, mode) {
3351
4006
  if (mode === "hard") {
3352
4007
  await executeIdentityStatement(
3353
4008
  rawTarget,
3354
- chunk2ZWM2RFH_cjs.sql`
4009
+ chunkEDN4Y4ZG_cjs.sql`
3355
4010
  DELETE FROM ${ctx.schema.identityAssertionsTable}
3356
4011
  WHERE graph_id = ${ctx.graphId} AND id = ${row.id}
3357
4012
  `
@@ -3368,7 +4023,7 @@ async function detachIdentityForNode(ctx, target, ref, mode) {
3368
4023
  };
3369
4024
  await executeIdentityStatement(
3370
4025
  rawTarget,
3371
- chunk2ZWM2RFH_cjs.sql`
4026
+ chunkEDN4Y4ZG_cjs.sql`
3372
4027
  UPDATE ${ctx.schema.identityAssertionsTable}
3373
4028
  SET valid_to = ${validTo},
3374
4029
  updated_at = ${now},
@@ -3399,11 +4054,12 @@ exports.createIdentityReadFacade = createIdentityReadFacade;
3399
4054
  exports.createValidationError = createValidationError;
3400
4055
  exports.deleteAssertionsTouchingKinds = deleteAssertionsTouchingKinds;
3401
4056
  exports.detachIdentityForNode = detachIdentityForNode;
3402
- exports.encodeTupleKey = encodeTupleKey;
3403
4057
  exports.foldIdentityForCreatedNodes = foldIdentityForCreatedNodes;
4058
+ exports.forceWriteTransactionRevision = forceWriteTransactionRevision;
3404
4059
  exports.hasAssertionsTouchingKinds = hasAssertionsTouchingKinds;
3405
4060
  exports.identityAssertionSemanticKey = identityAssertionSemanticKey;
3406
4061
  exports.identityReferenceKey = identityReferenceKey;
4062
+ exports.identityValidityWindowsOverlap = identityValidityWindowsOverlap;
3407
4063
  exports.importIdentityAssertionsIntoTarget = importIdentityAssertionsIntoTarget;
3408
4064
  exports.liveNodeKindsSharingIds = liveNodeKindsSharingIds;
3409
4065
  exports.loadAssertionsByIds = loadAssertionsByIds;
@@ -3418,6 +4074,7 @@ exports.readIdentityAssertionsForInterchange = readIdentityAssertionsForIntercha
3418
4074
  exports.rebuildIdentityClosureForContext = rebuildIdentityClosureForContext;
3419
4075
  exports.refKey = refKey;
3420
4076
  exports.removeIdentityKindsForContext = removeIdentityKindsForContext;
4077
+ exports.requireNodeValidityEndCompatible = requireNodeValidityEndCompatible;
3421
4078
  exports.runHookedWriteOperation = runHookedWriteOperation;
3422
4079
  exports.runInWriteTransaction = runInWriteTransaction;
3423
4080
  exports.separationRebuildRequired = separationRebuildRequired;
@@ -3428,5 +4085,5 @@ exports.validateNodeProps = validateNodeProps;
3428
4085
  exports.validateProps = validateProps;
3429
4086
  exports.withWriteTransactionSession = withWriteTransactionSession;
3430
4087
  exports.wrapZodError = wrapZodError;
3431
- //# sourceMappingURL=chunk-QPOQX2DI.cjs.map
3432
- //# sourceMappingURL=chunk-QPOQX2DI.cjs.map
4088
+ //# sourceMappingURL=chunk-JFRT7S3B.cjs.map
4089
+ //# sourceMappingURL=chunk-JFRT7S3B.cjs.map