@noy-db/hub 0.6.0-pre.9 → 0.7.0-pre.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 (572) hide show
  1. package/CHANGELOG.md +7127 -0
  2. package/README.md +1 -1
  3. package/codemods/0.4.0-pre.json +24 -0
  4. package/codemods/0.6.0-pre.json +229 -0
  5. package/codemods/0.7.0-pre.json +258 -0
  6. package/dist/api-EQYRTZO2.js +20 -0
  7. package/dist/as/index.js +146 -0
  8. package/dist/as/index.js.map +1 -0
  9. package/dist/at/index.js +23 -0
  10. package/dist/attestation/index.js +19 -19
  11. package/dist/{backup-KULFZ2T4.js → backup-Z7ZBTAQ6.js} +36 -18
  12. package/dist/backup-Z7ZBTAQ6.js.map +1 -0
  13. package/dist/blobs/index.js +22 -20
  14. package/dist/blobs/index.js.map +1 -1
  15. package/dist/broker/index.js +12 -12
  16. package/dist/by/index.js +11 -0
  17. package/dist/cargo/index.js +40 -36
  18. package/dist/{chunk-YAWK6AWF.js → chunk-225O5CXQ.js} +2 -2
  19. package/dist/{chunk-MSWYQLMQ.js → chunk-2GXEQUEX.js} +2 -2
  20. package/dist/chunk-2GXEQUEX.js.map +1 -0
  21. package/dist/{chunk-3URQC7EH.js → chunk-2LPVI4PX.js} +355 -132
  22. package/dist/chunk-2LPVI4PX.js.map +1 -0
  23. package/dist/{chunk-JJNOLSG5.js → chunk-3L2MVE36.js} +15 -16
  24. package/dist/chunk-3L2MVE36.js.map +1 -0
  25. package/dist/{chunk-OF3L2SD6.js → chunk-3QARDAYW.js} +2 -2
  26. package/dist/{chunk-WLZ47GSL.js → chunk-467SKJ65.js} +12 -10
  27. package/dist/{chunk-WLZ47GSL.js.map → chunk-467SKJ65.js.map} +1 -1
  28. package/dist/{chunk-W3TVWF6N.js → chunk-4A4TYISP.js} +2 -2
  29. package/dist/{chunk-ZJADGNYF.js → chunk-4AOERLTV.js} +1 -1
  30. package/dist/chunk-4AOERLTV.js.map +1 -0
  31. package/dist/{chunk-CCZJJ4I2.js → chunk-4G25SDQL.js} +6 -6
  32. package/dist/{chunk-4I72F5DF.js → chunk-4LPF226H.js} +11 -14
  33. package/dist/chunk-4LPF226H.js.map +1 -0
  34. package/dist/{chunk-7F4DBNSP.js → chunk-4ZPE6SKS.js} +135 -18
  35. package/dist/chunk-4ZPE6SKS.js.map +1 -0
  36. package/dist/{chunk-7TSYBD3E.js → chunk-5263OEM3.js} +2 -2
  37. package/dist/{chunk-WFUIE565.js → chunk-57JTHWLQ.js} +17 -14
  38. package/dist/chunk-57JTHWLQ.js.map +1 -0
  39. package/dist/{chunk-FNSMZQS4.js → chunk-5ACAVJUI.js} +2 -2
  40. package/dist/{chunk-PDLLCOGD.js → chunk-5AFMP532.js} +20 -17
  41. package/dist/chunk-5AFMP532.js.map +1 -0
  42. package/dist/{chunk-JRKZTEZZ.js → chunk-5W7YXFV5.js} +444 -73
  43. package/dist/chunk-5W7YXFV5.js.map +1 -0
  44. package/dist/chunk-6EW2UCVF.js +190 -0
  45. package/dist/chunk-6EW2UCVF.js.map +1 -0
  46. package/dist/{chunk-4VUPLMZ6.js → chunk-6FOGTKBY.js} +68 -73
  47. package/dist/chunk-6FOGTKBY.js.map +1 -0
  48. package/dist/{chunk-VMCCGUQB.js → chunk-7LYUJNU3.js} +2 -2
  49. package/dist/{chunk-52JPHN5N.js → chunk-A2YW5EMU.js} +27 -149
  50. package/dist/chunk-A2YW5EMU.js.map +1 -0
  51. package/dist/{chunk-WLYIROCJ.js → chunk-AB5P32RE.js} +2 -2
  52. package/dist/{chunk-PL2GHSCM.js → chunk-ALB64CZM.js} +157 -90
  53. package/dist/chunk-ALB64CZM.js.map +1 -0
  54. package/dist/{chunk-SUFG5E73.js → chunk-ALUNQEBY.js} +2 -2
  55. package/dist/{chunk-CADUYBQD.js → chunk-ATL3ZVXT.js} +2 -2
  56. package/dist/{chunk-BWVKEOPE.js → chunk-ATV637J7.js} +7 -11
  57. package/dist/chunk-ATV637J7.js.map +1 -0
  58. package/dist/{chunk-DG27IUVI.js → chunk-CBRS2NEK.js} +2 -11
  59. package/dist/chunk-CBRS2NEK.js.map +1 -0
  60. package/dist/{chunk-7MNBICB5.js → chunk-CN6B5PEN.js} +16 -14
  61. package/dist/chunk-CN6B5PEN.js.map +1 -0
  62. package/dist/{chunk-6FJWSWFT.js → chunk-DBNYPLWY.js} +3 -3
  63. package/dist/{chunk-5JY5TSVY.js → chunk-DFAUMLD7.js} +25 -31
  64. package/dist/chunk-DFAUMLD7.js.map +1 -0
  65. package/dist/{chunk-FFDNKRCY.js → chunk-DKWPJOYH.js} +2 -2
  66. package/dist/chunk-DKWPJOYH.js.map +1 -0
  67. package/dist/{chunk-VJFMXYKP.js → chunk-E6YA6UAP.js} +2 -2
  68. package/dist/{chunk-WASHZV34.js → chunk-F23WQK3G.js} +65 -27
  69. package/dist/chunk-F23WQK3G.js.map +1 -0
  70. package/dist/{chunk-JIUVJ4M7.js → chunk-F7ZFRPGQ.js} +3 -3
  71. package/dist/{chunk-HXGUIPQB.js → chunk-FOG7YEJP.js} +3 -3
  72. package/dist/{chunk-QULVCV3M.js → chunk-GK4DRVUD.js} +6 -6
  73. package/dist/chunk-GK4DRVUD.js.map +1 -0
  74. package/dist/{chunk-BRVW2GS5.js → chunk-H36KSN6X.js} +87 -34
  75. package/dist/chunk-H36KSN6X.js.map +1 -0
  76. package/dist/{chunk-O2ERS4UJ.js → chunk-H4M7ADXY.js} +81 -52
  77. package/dist/chunk-H4M7ADXY.js.map +1 -0
  78. package/dist/{chunk-FZ6NYJ7L.js → chunk-H7HP56F6.js} +11 -8
  79. package/dist/chunk-H7HP56F6.js.map +1 -0
  80. package/dist/chunk-HK67PX4J.js +27 -0
  81. package/dist/chunk-HK67PX4J.js.map +1 -0
  82. package/dist/{chunk-X56RTUK3.js → chunk-HM4JSXX2.js} +3 -3
  83. package/dist/{chunk-AHLJSVRL.js → chunk-HTGRQZFB.js} +5 -7
  84. package/dist/chunk-HTGRQZFB.js.map +1 -0
  85. package/dist/{chunk-GQ3BX5EA.js → chunk-I3ISCYT7.js} +2 -2
  86. package/dist/{chunk-Q6TEJXBX.js → chunk-IESNYJXZ.js} +31 -49
  87. package/dist/chunk-IESNYJXZ.js.map +1 -0
  88. package/dist/{chunk-FUHKW252.js → chunk-J4MN6XIU.js} +2 -2
  89. package/dist/{chunk-ADW22QSB.js → chunk-J4UJ5FRV.js} +4 -4
  90. package/dist/{chunk-HNGSV2YC.js → chunk-JBIV4FLR.js} +67 -10
  91. package/dist/chunk-JBIV4FLR.js.map +1 -0
  92. package/dist/{chunk-HVQGCKY4.js → chunk-JVLSU7S2.js} +2 -2
  93. package/dist/{chunk-AR2JDFAE.js → chunk-KDJGJR7F.js} +2 -2
  94. package/dist/{chunk-NPP5R7FF.js → chunk-KN4W2OQ4.js} +22 -18
  95. package/dist/chunk-KN4W2OQ4.js.map +1 -0
  96. package/dist/{chunk-G6S5VVHP.js → chunk-L6GTLZRK.js} +10 -10
  97. package/dist/chunk-L6GTLZRK.js.map +1 -0
  98. package/dist/{chunk-2BMRJ6LQ.js → chunk-LF6DMX4C.js} +8 -11
  99. package/dist/{chunk-2BMRJ6LQ.js.map → chunk-LF6DMX4C.js.map} +1 -1
  100. package/dist/chunk-LFUID7OW.js +163 -0
  101. package/dist/chunk-LFUID7OW.js.map +1 -0
  102. package/dist/{chunk-747LRSOO.js → chunk-LKFKXS5K.js} +2 -2
  103. package/dist/{chunk-U5O6GIWZ.js → chunk-LR4Z47QD.js} +3 -3
  104. package/dist/{chunk-VZ3XFUQ7.js → chunk-MTBXJAS4.js} +16 -22
  105. package/dist/chunk-MTBXJAS4.js.map +1 -0
  106. package/dist/chunk-N4CNVSUF.js +66 -0
  107. package/dist/chunk-N4CNVSUF.js.map +1 -0
  108. package/dist/{chunk-RTAMLDWP.js → chunk-NLKLXXTO.js} +2 -2
  109. package/dist/{chunk-IGJCYUT5.js → chunk-NSITFOCJ.js} +1 -1
  110. package/dist/chunk-NSITFOCJ.js.map +1 -0
  111. package/dist/{chunk-FDX7OWWI.js → chunk-OPXR4PB2.js} +2 -2
  112. package/dist/{chunk-4GZ6XOVW.js → chunk-OWLVBOWO.js} +44 -42
  113. package/dist/chunk-OWLVBOWO.js.map +1 -0
  114. package/dist/{chunk-Z45YRGFO.js → chunk-P6ASQOZR.js} +2 -2
  115. package/dist/{chunk-5O5HRRTV.js → chunk-PCQDY6QN.js} +7 -7
  116. package/dist/{chunk-5O5HRRTV.js.map → chunk-PCQDY6QN.js.map} +1 -1
  117. package/dist/{chunk-BEFVYAR5.js → chunk-PGFKIOR3.js} +4 -4
  118. package/dist/chunk-PGFKIOR3.js.map +1 -0
  119. package/dist/{chunk-3FSX6LDG.js → chunk-POS53FG6.js} +18 -3
  120. package/dist/{chunk-3FSX6LDG.js.map → chunk-POS53FG6.js.map} +1 -1
  121. package/dist/{chunk-3IXIU6FP.js → chunk-PQ6Z2TAP.js} +7 -10
  122. package/dist/chunk-PQ6Z2TAP.js.map +1 -0
  123. package/dist/{chunk-CEJWMBXO.js → chunk-PUJTKLPL.js} +6 -2
  124. package/dist/chunk-PUJTKLPL.js.map +1 -0
  125. package/dist/{chunk-GAG7QOVO.js → chunk-QGJ4XIA7.js} +53 -18
  126. package/dist/chunk-QGJ4XIA7.js.map +1 -0
  127. package/dist/{chunk-2DHSSLOD.js → chunk-QHJKK77B.js} +13 -15
  128. package/dist/chunk-QHJKK77B.js.map +1 -0
  129. package/dist/{chunk-2Z3NCLNX.js → chunk-QI5NWLVW.js} +7 -7
  130. package/dist/{chunk-6SAFL5YE.js → chunk-RC4BROYR.js} +3 -3
  131. package/dist/{chunk-NJDQ4YSV.js → chunk-RDHUZ674.js} +4 -4
  132. package/dist/{chunk-YPYHVOXP.js → chunk-RK7N4OQ5.js} +2 -2
  133. package/dist/chunk-RK7N4OQ5.js.map +1 -0
  134. package/dist/{chunk-3737A6EA.js → chunk-S2VG3ABP.js} +127 -31
  135. package/dist/chunk-S2VG3ABP.js.map +1 -0
  136. package/dist/{chunk-3JVXVJ7L.js → chunk-S35S77YU.js} +10 -10
  137. package/dist/{chunk-KUDZVJKQ.js → chunk-SHILAQH5.js} +2 -2
  138. package/dist/{chunk-4UVDI4XE.js → chunk-T3PHCEN4.js} +4 -4
  139. package/dist/{chunk-55LKVALY.js → chunk-T7IR4N2S.js} +1 -3
  140. package/dist/chunk-T7IR4N2S.js.map +1 -0
  141. package/dist/{chunk-RXYYFSBB.js → chunk-TOV6VMHF.js} +6 -6
  142. package/dist/chunk-TOV6VMHF.js.map +1 -0
  143. package/dist/{chunk-W77KZHCW.js → chunk-TVIFAHZR.js} +16 -17
  144. package/dist/chunk-TVIFAHZR.js.map +1 -0
  145. package/dist/chunk-UBSFPGVJ.js +1 -0
  146. package/dist/{chunk-FAXZQ5UF.js → chunk-UCUALOSM.js} +2 -2
  147. package/dist/{chunk-4HDYQL3J.js → chunk-VAG47QHV.js} +2 -2
  148. package/dist/{chunk-35EBKWQU.js → chunk-VFIWDPXZ.js} +4 -4
  149. package/dist/{chunk-5ZKS6ZE2.js → chunk-VTG7327U.js} +4 -4
  150. package/dist/chunk-VTG7327U.js.map +1 -0
  151. package/dist/{chunk-VCETL77O.js → chunk-W5LHQXZU.js} +36 -7
  152. package/dist/chunk-W5LHQXZU.js.map +1 -0
  153. package/dist/{chunk-6NVPFKN3.js → chunk-WK5FSW7T.js} +92 -35
  154. package/dist/chunk-WK5FSW7T.js.map +1 -0
  155. package/dist/{chunk-HNHCQ556.js → chunk-WLLUM35R.js} +2 -2
  156. package/dist/{chunk-YJ6IONGA.js → chunk-X62MEF2O.js} +13 -5
  157. package/dist/chunk-X62MEF2O.js.map +1 -0
  158. package/dist/{chunk-7G6VDWXB.js → chunk-X67FCULK.js} +5 -5
  159. package/dist/chunk-X67FCULK.js.map +1 -0
  160. package/dist/{chunk-UHXCLPGC.js → chunk-XDVVBETV.js} +2 -2
  161. package/dist/chunk-XDVVBETV.js.map +1 -0
  162. package/dist/chunk-XJ3FEKEY.js +15 -0
  163. package/dist/chunk-XJ3FEKEY.js.map +1 -0
  164. package/dist/{chunk-E6427JU2.js → chunk-XSN63FUS.js} +19 -3
  165. package/dist/chunk-XSN63FUS.js.map +1 -0
  166. package/dist/{chunk-JRCYZEHU.js → chunk-XVU7J43V.js} +2 -2
  167. package/dist/{chunk-2GAJGUNM.js → chunk-Y3YLJORD.js} +408 -260
  168. package/dist/chunk-Y3YLJORD.js.map +1 -0
  169. package/dist/{chunk-6BU3L4UE.js → chunk-Y6GZ2P4M.js} +7 -10
  170. package/dist/chunk-Y6GZ2P4M.js.map +1 -0
  171. package/dist/{chunk-DMQCLZ4Z.js → chunk-YCSM3GZU.js} +2 -2
  172. package/dist/{chunk-RV3ARMPN.js → chunk-YKPGQJFU.js} +30 -180
  173. package/dist/chunk-YKPGQJFU.js.map +1 -0
  174. package/dist/{chunk-FMQJZH4R.js → chunk-YMLQBZFJ.js} +6 -6
  175. package/dist/{chunk-6HFM7EIT.js → chunk-YPSOHDNC.js} +2 -2
  176. package/dist/{chunk-CDB2HVQW.js → chunk-YXA2TCTZ.js} +14 -15
  177. package/dist/chunk-YXA2TCTZ.js.map +1 -0
  178. package/dist/{chunk-N35NC4JH.js → chunk-Z2PWOSCJ.js} +2 -2
  179. package/dist/{chunk-XWX7GL56.js → chunk-Z2WK53N6.js} +47 -23
  180. package/dist/chunk-Z2WK53N6.js.map +1 -0
  181. package/dist/{chunk-HPLWFNG4.js → chunk-Z7ZXZL6Y.js} +2 -2
  182. package/dist/{chunk-PNKHAKQ7.js → chunk-ZO252Q5S.js} +17 -10
  183. package/dist/chunk-ZO252Q5S.js.map +1 -0
  184. package/dist/classified/index.js +5 -5
  185. package/dist/{classified-marker-2KJAXRRO.js → classified-marker-BSQHU4JT.js} +3 -3
  186. package/dist/collection-facade-LG3NYZVB.js +45 -0
  187. package/dist/{computed-6G5M3UPH.js → computed-ASBNTLOK.js} +3 -3
  188. package/dist/consent/index.js +10 -10
  189. package/dist/cover/index.js +10 -3
  190. package/dist/custody/index.js +12 -11
  191. package/dist/{dead-filter-DCB62VWW.js → dead-filter-QKU56XTQ.js} +2 -2
  192. package/dist/debug/index.js +1 -1
  193. package/dist/{delegation-MO7YZYJS.js → delegation-XWRPYODW.js} +24 -23
  194. package/dist/delegation-XWRPYODW.js.map +1 -0
  195. package/dist/derivations/index.js +12 -12
  196. package/dist/derive-CXHCY46K.js +22 -0
  197. package/dist/directory/index.js +10 -10
  198. package/dist/{dispatch-MJ6SHB3Y.js → dispatch-4AP4PUZU.js} +18 -18
  199. package/dist/{dispatch-FZEAWKVM.js → dispatch-VR4LRXZ7.js} +9 -6
  200. package/dist/dispatch-VR4LRXZ7.js.map +1 -0
  201. package/dist/{enclave-JU4YIEPB.js → enclave-NYPT7WA7.js} +31 -9
  202. package/dist/executor-3KFRQETS.js +29 -0
  203. package/dist/executor-AFHQYRAU.js +9 -0
  204. package/dist/executor-YYDW6XQI.js +9 -0
  205. package/dist/export-accessible-BX2ILB4C.js +23 -0
  206. package/dist/extract-partition-UPOVITFI.js +38 -0
  207. package/dist/{fanout-sidecar-NNAJQXMX.js → fanout-sidecar-IWP3R4RC.js} +18 -27
  208. package/dist/fanout-sidecar-IWP3R4RC.js.map +1 -0
  209. package/dist/{fence-watcher-DHQ775JB.js → fence-watcher-ZVSMLKQD.js} +1 -1
  210. package/dist/fence-watcher-ZVSMLKQD.js.map +1 -0
  211. package/dist/find-SZBL2HPB.js +11 -0
  212. package/dist/forget/index.js +9 -9
  213. package/dist/guards/index.js +4 -4
  214. package/dist/history/index.js +23 -20
  215. package/dist/history/index.js.map +1 -1
  216. package/dist/i18n/index.js +14 -14
  217. package/dist/index.d.ts +35 -18
  218. package/dist/index.js +199 -204
  219. package/dist/index.js.map +1 -1
  220. package/dist/indexing/index.js +4 -4
  221. package/dist/introspection/index.js +12 -11
  222. package/dist/issue-G53NB6EW.js +19 -0
  223. package/dist/kernel/collection-config.d.ts +9 -9
  224. package/dist/kernel/collection.d.ts +9 -3
  225. package/dist/kernel/constants.d.ts +36 -0
  226. package/dist/kernel/enclave/crypto.d.ts +52 -4
  227. package/dist/kernel/enclave/index.d.ts +10 -3
  228. package/dist/kernel/enclave/record-aad.d.ts +131 -0
  229. package/dist/kernel/enclave/record-envelope.d.ts +76 -0
  230. package/dist/kernel/enclave/record-keys/envelope-body.d.ts +34 -2
  231. package/dist/kernel/enclave/record-keys/lifecycle.d.ts +22 -5
  232. package/dist/kernel/enclave/record-keys/record-codec.d.ts +47 -14
  233. package/dist/kernel/enclave/record-keys/rekey-blob.d.ts +88 -0
  234. package/dist/kernel/enclave/record-keys/rekey.d.ts +91 -0
  235. package/dist/kernel/enclave/record-keys/tombstone.d.ts +3 -2
  236. package/dist/kernel/errors.d.ts +134 -14
  237. package/dist/kernel/merge-authority.d.ts +25 -0
  238. package/dist/kernel/noydb.d.ts +33 -10
  239. package/dist/kernel/query/builder.d.ts +51 -4
  240. package/dist/kernel/query/join.d.ts +27 -0
  241. package/dist/kernel/query/live.d.ts +31 -9
  242. package/dist/kernel/query/predicate.d.ts +9 -0
  243. package/dist/kernel/refs.d.ts +3 -1
  244. package/dist/kernel/secret-mode.d.ts +1 -1
  245. package/dist/kernel/sync-policy.d.ts +0 -2
  246. package/dist/kernel/tier-visibility.d.ts +34 -0
  247. package/dist/kernel/types.d.ts +145 -28
  248. package/dist/kernel/vault.d.ts +16 -7
  249. package/dist/kernel/via/compose.d.ts +3 -3
  250. package/dist/kernel/via/index.d.ts +15 -6
  251. package/dist/kernel/via/pipeline.d.ts +6 -6
  252. package/dist/kernel/via/reconcile.d.ts +14 -2
  253. package/dist/kernel/via/taint-binding.d.ts +3 -3
  254. package/dist/{ledger-AETNF4OM.js → ledger-T5K4P2D7.js} +11 -11
  255. package/dist/liberate-VEOZRESE.js +25 -0
  256. package/dist/{link-set-E5HNY67I.js → link-set-76JZ6YB4.js} +11 -11
  257. package/dist/{managed-secret-CWQ6PND5.js → managed-secret-6YC32VXG.js} +13 -5
  258. package/dist/materialized-views/index.js +27 -27
  259. package/dist/migrate-cek-LBRKYUZZ.js +19 -0
  260. package/dist/migrate-cek-LBRKYUZZ.js.map +1 -0
  261. package/dist/money/index.js +5 -5
  262. package/dist/noydb-EDJA4JNJ.js +86 -0
  263. package/dist/on/index.js +1 -0
  264. package/dist/overlay-views/index.js +4 -4
  265. package/dist/periods/index.js +12 -12
  266. package/dist/pod/index.js +79 -88
  267. package/dist/pod-handle-P6DPBM5U.js +41 -0
  268. package/dist/pod-handle-P6DPBM5U.js.map +1 -0
  269. package/dist/policy/index.js +11 -4
  270. package/dist/port/as/active.d.ts +10 -0
  271. package/dist/port/as/index.d.ts +32 -0
  272. package/dist/port/as/types.d.ts +113 -0
  273. package/dist/port/at/index.d.ts +37 -0
  274. package/dist/port/by/default-provider.d.ts +3 -3
  275. package/dist/port/by/index.d.ts +32 -10
  276. package/dist/port/by/types.d.ts +29 -11
  277. package/dist/port/on/index.d.ts +50 -0
  278. package/dist/port/to/index.d.ts +4 -4
  279. package/dist/port/to/locator.d.ts +54 -8
  280. package/dist/port/with/computed-strategy.d.ts +1 -1
  281. package/dist/port/with/device-seal-strategy.d.ts +2 -2
  282. package/dist/port/with/formats-strategy.d.ts +76 -0
  283. package/dist/port/with/i18n-strategy.d.ts +4 -1
  284. package/dist/port/with/lookup-strategy.d.ts +4 -1
  285. package/dist/port/with/merge-authority.d.ts +52 -0
  286. package/dist/port/with/service-bus.d.ts +0 -4
  287. package/dist/port/with/strategies.d.ts +13 -5
  288. package/dist/port/with/team-strategy.d.ts +5 -1
  289. package/dist/portability/index.js +8 -8
  290. package/dist/{post-register-2XSSMGEQ.js → post-register-53O7AJRZ.js} +6 -6
  291. package/dist/query/index.js +6 -6
  292. package/dist/reduce/index.js +6 -6
  293. package/dist/register-6TCBR6XD.js +32 -0
  294. package/dist/registry-DH2L4O2V.js +18 -0
  295. package/dist/registry-IWFMXCHX.js +9 -0
  296. package/dist/registry-Q3FG3OAX.js +9 -0
  297. package/dist/registry-YC3IFG3A.js +19 -0
  298. package/dist/request-withdrawal-NM5VYR6F.js +31 -0
  299. package/dist/{reveal-BW36KCOQ.js → reveal-XBIMHAXR.js} +6 -6
  300. package/dist/revoke-MJNYWO72.js +24 -0
  301. package/dist/satellites/index.js +1 -1
  302. package/dist/schema-update/index.js +2 -2
  303. package/dist/sealed-record/index.js +20 -13
  304. package/dist/sealed-record/index.js.map +1 -1
  305. package/dist/search/index.js +4 -4
  306. package/dist/{seed-GDV5PT4R.js → seed-NSNIGYXE.js} +20 -22
  307. package/dist/seed-NSNIGYXE.js.map +1 -0
  308. package/dist/sequence/index.js +9 -9
  309. package/dist/session/index.js +10 -10
  310. package/dist/shadow/index.js +2 -2
  311. package/dist/share-link/index.js +1 -1
  312. package/dist/signer-6XVS2AU3.js +25 -0
  313. package/dist/snapshots/index.js +10 -10
  314. package/dist/snapshots/index.js.map +1 -1
  315. package/dist/{stale-ARHFVL5U.js → stale-MCS46TFO.js} +10 -10
  316. package/dist/storage-ZXUT476I.js +23 -0
  317. package/dist/storage-ZXUT476I.js.map +1 -0
  318. package/dist/{store-coordination-provider-GFCUOBR6.js → store-coordination-provider-6FM26VQM.js} +22 -15
  319. package/dist/store-coordination-provider-6FM26VQM.js.map +1 -0
  320. package/dist/sync/index.js +11 -11
  321. package/dist/team/index.js +17 -16
  322. package/dist/tiers/index.js +11 -10
  323. package/dist/to/index.js +17 -9
  324. package/dist/to/index.js.map +1 -1
  325. package/dist/transactions/index.js +4 -4
  326. package/dist/{ulid-PTAIMDG4.js → ulid-VQW6ERQN.js} +2 -2
  327. package/dist/ulid-VQW6ERQN.js.map +1 -0
  328. package/dist/util/index.js +1 -1
  329. package/dist/vault-diff-FE5J35NJ.js +9 -0
  330. package/dist/vault-diff-FE5J35NJ.js.map +1 -0
  331. package/dist/vault-head/index.js +115 -0
  332. package/dist/vault-head/index.js.map +1 -0
  333. package/dist/{verify-RO5RTZOJ.js → verify-WYOFLSNA.js} +5 -5
  334. package/dist/via/blob/binding.d.ts +6 -6
  335. package/dist/via/blob/index.d.ts +3 -0
  336. package/dist/via/classified/binding.d.ts +9 -9
  337. package/dist/via/computed/binding.d.ts +2 -2
  338. package/dist/via/i18n/binding.d.ts +4 -4
  339. package/dist/via/lookup/binding.d.ts +5 -5
  340. package/dist/via/lookup/handle.d.ts +4 -1
  341. package/dist/via/lookup/index.d.ts +1 -1
  342. package/dist/via/lookup/snapshot.d.ts +1 -1
  343. package/dist/via/money/binding.d.ts +3 -3
  344. package/dist/via/money/normalize.d.ts +1 -1
  345. package/dist/via/money/where.d.ts +3 -3
  346. package/dist/walk-JNEOYCAU.js +21 -0
  347. package/dist/walk-JNEOYCAU.js.map +1 -0
  348. package/dist/with-audit/periods/periods.d.ts +1 -1
  349. package/dist/with-audit/periods/strategy.d.ts +1 -1
  350. package/dist/with-audit/sealed-record/index.d.ts +13 -0
  351. package/dist/with-audit/tiers/index.d.ts +17 -2
  352. package/dist/with-cargo/adopt-partition.d.ts +7 -7
  353. package/dist/with-cargo/extract-partition.d.ts +1 -1
  354. package/dist/with-cargo/floor.d.ts +1 -1
  355. package/dist/with-cargo/index.d.ts +2 -2
  356. package/dist/with-commit/history/history.d.ts +26 -0
  357. package/dist/with-commit/history/index.d.ts +2 -1
  358. package/dist/with-commit/history/ledger/store.d.ts +7 -1
  359. package/dist/with-commit/history/strategy.d.ts +11 -1
  360. package/dist/with-commit/numbering/index.d.ts +0 -5
  361. package/dist/with-commit/vault-head/active.d.ts +2 -0
  362. package/dist/with-commit/vault-head/head.d.ts +28 -0
  363. package/dist/with-commit/vault-head/index.d.ts +10 -0
  364. package/dist/with-commit/vault-head/strategy.d.ts +127 -0
  365. package/dist/with-commit/vault-head/verify.d.ts +90 -0
  366. package/dist/with-formula/materialized-views/dependency-analyzer.d.ts +4 -0
  367. package/dist/with-formula/materialized-views/projection-legs.d.ts +59 -0
  368. package/dist/with-formula/materialized-views/registry.d.ts +50 -0
  369. package/dist/with-formula/materialized-views/types.d.ts +68 -10
  370. package/dist/with-party/directory/cover/storage.d.ts +0 -8
  371. package/dist/with-party/directory/storage.d.ts +0 -11
  372. package/dist/with-party/directory/visibility.d.ts +0 -21
  373. package/dist/with-party/policy/storage.d.ts +0 -10
  374. package/dist/with-party/team/deed.d.ts +4 -4
  375. package/dist/with-party/team/device-seal.d.ts +5 -5
  376. package/dist/with-party/team/echo-ceremony.d.ts +2 -2
  377. package/dist/with-party/team/echo-secret.d.ts +4 -4
  378. package/dist/with-party/team/index.d.ts +3 -3
  379. package/dist/with-party/team/keyring.d.ts +141 -4
  380. package/dist/with-party/team/managed-secret.d.ts +21 -11
  381. package/dist/with-party/team/noydb-facade.d.ts +7 -3
  382. package/dist/with-party/team/{shamir-recovery-provider.d.ts → noydb-shamir.d.ts} +1 -1
  383. package/dist/with-party/team/recovery.d.ts +3 -3
  384. package/dist/with-party/team/roster-tag.d.ts +101 -0
  385. package/dist/with-party/team/rotate-recover.d.ts +5 -5
  386. package/dist/with-party/team/tiers.d.ts +2 -1
  387. package/dist/with-pod/format.d.ts +11 -13
  388. package/dist/with-pod/index.d.ts +10 -10
  389. package/dist/with-pod/open.d.ts +2 -2
  390. package/dist/with-pod/pod-handle.d.ts +19 -0
  391. package/dist/with-pod/pod-store.d.ts +0 -8
  392. package/dist/with-pod/{bundle.d.ts → pod.d.ts} +17 -25
  393. package/dist/with-pod/ulid.d.ts +1 -1
  394. package/dist/with-shape/blobs/blob-compaction.d.ts +13 -0
  395. package/dist/with-shape/blobs/blob-set.d.ts +83 -11
  396. package/dist/with-shape/blobs/orphan-report.d.ts +62 -0
  397. package/dist/with-shape/introspection/describe.d.ts +2 -2
  398. package/dist/with-shape/schema-update/fence-controller.d.ts +4 -4
  399. package/dist/with-shape/schema-update/fence-watcher.d.ts +4 -4
  400. package/dist/with-shape/schema-update/store-coordination-provider.d.ts +7 -6
  401. package/dist/with-sync/engine.d.ts +54 -5
  402. package/dist/with-sync/strategy.d.ts +3 -0
  403. package/dist/withdraw-accessible-ILTSXTIE.js +28 -0
  404. package/dist/withdraw-accessible-ILTSXTIE.js.map +1 -0
  405. package/package.json +29 -5
  406. package/dist/api-RXUMEKT3.js +0 -20
  407. package/dist/backup-KULFZ2T4.js.map +0 -1
  408. package/dist/bundle-handle-GFNHT52M.js +0 -36
  409. package/dist/bundle-handle-GFNHT52M.js.map +0 -1
  410. package/dist/chunk-2DHSSLOD.js.map +0 -1
  411. package/dist/chunk-2GAJGUNM.js.map +0 -1
  412. package/dist/chunk-3737A6EA.js.map +0 -1
  413. package/dist/chunk-3IXIU6FP.js.map +0 -1
  414. package/dist/chunk-3URQC7EH.js.map +0 -1
  415. package/dist/chunk-4GZ6XOVW.js.map +0 -1
  416. package/dist/chunk-4I72F5DF.js.map +0 -1
  417. package/dist/chunk-4VUPLMZ6.js.map +0 -1
  418. package/dist/chunk-52JPHN5N.js.map +0 -1
  419. package/dist/chunk-55LKVALY.js.map +0 -1
  420. package/dist/chunk-5JY5TSVY.js.map +0 -1
  421. package/dist/chunk-5ZKS6ZE2.js.map +0 -1
  422. package/dist/chunk-6BU3L4UE.js.map +0 -1
  423. package/dist/chunk-6NVPFKN3.js.map +0 -1
  424. package/dist/chunk-7F4DBNSP.js.map +0 -1
  425. package/dist/chunk-7G6VDWXB.js.map +0 -1
  426. package/dist/chunk-7H73RIE3.js +0 -45
  427. package/dist/chunk-7H73RIE3.js.map +0 -1
  428. package/dist/chunk-7MNBICB5.js.map +0 -1
  429. package/dist/chunk-AFHQATY4.js +0 -47
  430. package/dist/chunk-AFHQATY4.js.map +0 -1
  431. package/dist/chunk-AHLJSVRL.js.map +0 -1
  432. package/dist/chunk-BEFVYAR5.js.map +0 -1
  433. package/dist/chunk-BRVW2GS5.js.map +0 -1
  434. package/dist/chunk-BWVKEOPE.js.map +0 -1
  435. package/dist/chunk-CDB2HVQW.js.map +0 -1
  436. package/dist/chunk-CEJWMBXO.js.map +0 -1
  437. package/dist/chunk-DG27IUVI.js.map +0 -1
  438. package/dist/chunk-E6427JU2.js.map +0 -1
  439. package/dist/chunk-FFDNKRCY.js.map +0 -1
  440. package/dist/chunk-FZ6NYJ7L.js.map +0 -1
  441. package/dist/chunk-G6S5VVHP.js.map +0 -1
  442. package/dist/chunk-GAG7QOVO.js.map +0 -1
  443. package/dist/chunk-HNGSV2YC.js.map +0 -1
  444. package/dist/chunk-IGJCYUT5.js.map +0 -1
  445. package/dist/chunk-JJNOLSG5.js.map +0 -1
  446. package/dist/chunk-JRKZTEZZ.js.map +0 -1
  447. package/dist/chunk-MSWYQLMQ.js.map +0 -1
  448. package/dist/chunk-NPP5R7FF.js.map +0 -1
  449. package/dist/chunk-O2ERS4UJ.js.map +0 -1
  450. package/dist/chunk-PDLLCOGD.js.map +0 -1
  451. package/dist/chunk-PL2GHSCM.js.map +0 -1
  452. package/dist/chunk-PNKHAKQ7.js.map +0 -1
  453. package/dist/chunk-Q6TEJXBX.js.map +0 -1
  454. package/dist/chunk-QULVCV3M.js.map +0 -1
  455. package/dist/chunk-RV3ARMPN.js.map +0 -1
  456. package/dist/chunk-RXYYFSBB.js.map +0 -1
  457. package/dist/chunk-UHXCLPGC.js.map +0 -1
  458. package/dist/chunk-VCETL77O.js.map +0 -1
  459. package/dist/chunk-VZ3XFUQ7.js.map +0 -1
  460. package/dist/chunk-W77KZHCW.js.map +0 -1
  461. package/dist/chunk-WASHZV34.js.map +0 -1
  462. package/dist/chunk-WFUIE565.js.map +0 -1
  463. package/dist/chunk-XWX7GL56.js.map +0 -1
  464. package/dist/chunk-YJ6IONGA.js.map +0 -1
  465. package/dist/chunk-YPYHVOXP.js.map +0 -1
  466. package/dist/chunk-ZJADGNYF.js.map +0 -1
  467. package/dist/collection-facade-QEJIM6BC.js +0 -45
  468. package/dist/delegation-MO7YZYJS.js.map +0 -1
  469. package/dist/derive-IUA6JFLB.js +0 -22
  470. package/dist/dispatch-FZEAWKVM.js.map +0 -1
  471. package/dist/executor-CYJQLKKI.js +0 -9
  472. package/dist/executor-S4QIKEHW.js +0 -9
  473. package/dist/executor-YIQB2S6N.js +0 -29
  474. package/dist/export-accessible-4S36PQNR.js +0 -23
  475. package/dist/extract-partition-IO7FDZ2P.js +0 -38
  476. package/dist/fanout-sidecar-NNAJQXMX.js.map +0 -1
  477. package/dist/fence-watcher-DHQ775JB.js.map +0 -1
  478. package/dist/find-RBBYKXI7.js +0 -11
  479. package/dist/issue-RIVHSY2S.js +0 -19
  480. package/dist/liberate-GFN4C7RR.js +0 -24
  481. package/dist/noydb-ASEXNJS6.js +0 -83
  482. package/dist/register-4EFJCVYD.js +0 -32
  483. package/dist/registry-4SDHHOJ7.js +0 -18
  484. package/dist/registry-CZVINVQH.js +0 -9
  485. package/dist/registry-IKUR2MXD.js +0 -9
  486. package/dist/registry-OYTFGWVK.js +0 -19
  487. package/dist/request-withdrawal-KGXGDPVQ.js +0 -31
  488. package/dist/revoke-JFN773KF.js +0 -24
  489. package/dist/seed-GDV5PT4R.js.map +0 -1
  490. package/dist/signer-TA55QB6R.js +0 -25
  491. package/dist/storage-V7MTFAQJ.js +0 -23
  492. package/dist/store-coordination-provider-GFCUOBR6.js.map +0 -1
  493. package/dist/walk-3ZECBFDA.js +0 -21
  494. package/dist/with-pod/bundle-handle.d.ts +0 -9
  495. package/dist/withdraw-accessible-7PG4DYQK.js +0 -28
  496. /package/dist/{api-RXUMEKT3.js.map → api-EQYRTZO2.js.map} +0 -0
  497. /package/dist/{collection-facade-QEJIM6BC.js.map → at/index.js.map} +0 -0
  498. /package/dist/{computed-6G5M3UPH.js.map → by/index.js.map} +0 -0
  499. /package/dist/{chunk-YAWK6AWF.js.map → chunk-225O5CXQ.js.map} +0 -0
  500. /package/dist/{chunk-OF3L2SD6.js.map → chunk-3QARDAYW.js.map} +0 -0
  501. /package/dist/{chunk-W3TVWF6N.js.map → chunk-4A4TYISP.js.map} +0 -0
  502. /package/dist/{chunk-CCZJJ4I2.js.map → chunk-4G25SDQL.js.map} +0 -0
  503. /package/dist/{chunk-7TSYBD3E.js.map → chunk-5263OEM3.js.map} +0 -0
  504. /package/dist/{chunk-FNSMZQS4.js.map → chunk-5ACAVJUI.js.map} +0 -0
  505. /package/dist/{chunk-VMCCGUQB.js.map → chunk-7LYUJNU3.js.map} +0 -0
  506. /package/dist/{chunk-WLYIROCJ.js.map → chunk-AB5P32RE.js.map} +0 -0
  507. /package/dist/{chunk-SUFG5E73.js.map → chunk-ALUNQEBY.js.map} +0 -0
  508. /package/dist/{chunk-CADUYBQD.js.map → chunk-ATL3ZVXT.js.map} +0 -0
  509. /package/dist/{chunk-6FJWSWFT.js.map → chunk-DBNYPLWY.js.map} +0 -0
  510. /package/dist/{chunk-VJFMXYKP.js.map → chunk-E6YA6UAP.js.map} +0 -0
  511. /package/dist/{chunk-JIUVJ4M7.js.map → chunk-F7ZFRPGQ.js.map} +0 -0
  512. /package/dist/{chunk-HXGUIPQB.js.map → chunk-FOG7YEJP.js.map} +0 -0
  513. /package/dist/{chunk-X56RTUK3.js.map → chunk-HM4JSXX2.js.map} +0 -0
  514. /package/dist/{chunk-GQ3BX5EA.js.map → chunk-I3ISCYT7.js.map} +0 -0
  515. /package/dist/{chunk-FUHKW252.js.map → chunk-J4MN6XIU.js.map} +0 -0
  516. /package/dist/{chunk-ADW22QSB.js.map → chunk-J4UJ5FRV.js.map} +0 -0
  517. /package/dist/{chunk-HVQGCKY4.js.map → chunk-JVLSU7S2.js.map} +0 -0
  518. /package/dist/{chunk-AR2JDFAE.js.map → chunk-KDJGJR7F.js.map} +0 -0
  519. /package/dist/{chunk-747LRSOO.js.map → chunk-LKFKXS5K.js.map} +0 -0
  520. /package/dist/{chunk-U5O6GIWZ.js.map → chunk-LR4Z47QD.js.map} +0 -0
  521. /package/dist/{chunk-RTAMLDWP.js.map → chunk-NLKLXXTO.js.map} +0 -0
  522. /package/dist/{chunk-FDX7OWWI.js.map → chunk-OPXR4PB2.js.map} +0 -0
  523. /package/dist/{chunk-Z45YRGFO.js.map → chunk-P6ASQOZR.js.map} +0 -0
  524. /package/dist/{chunk-2Z3NCLNX.js.map → chunk-QI5NWLVW.js.map} +0 -0
  525. /package/dist/{chunk-6SAFL5YE.js.map → chunk-RC4BROYR.js.map} +0 -0
  526. /package/dist/{chunk-NJDQ4YSV.js.map → chunk-RDHUZ674.js.map} +0 -0
  527. /package/dist/{chunk-3JVXVJ7L.js.map → chunk-S35S77YU.js.map} +0 -0
  528. /package/dist/{chunk-KUDZVJKQ.js.map → chunk-SHILAQH5.js.map} +0 -0
  529. /package/dist/{chunk-4UVDI4XE.js.map → chunk-T3PHCEN4.js.map} +0 -0
  530. /package/dist/{derive-IUA6JFLB.js.map → chunk-UBSFPGVJ.js.map} +0 -0
  531. /package/dist/{chunk-FAXZQ5UF.js.map → chunk-UCUALOSM.js.map} +0 -0
  532. /package/dist/{chunk-4HDYQL3J.js.map → chunk-VAG47QHV.js.map} +0 -0
  533. /package/dist/{chunk-35EBKWQU.js.map → chunk-VFIWDPXZ.js.map} +0 -0
  534. /package/dist/{chunk-HNHCQ556.js.map → chunk-WLLUM35R.js.map} +0 -0
  535. /package/dist/{chunk-JRCYZEHU.js.map → chunk-XVU7J43V.js.map} +0 -0
  536. /package/dist/{chunk-DMQCLZ4Z.js.map → chunk-YCSM3GZU.js.map} +0 -0
  537. /package/dist/{chunk-FMQJZH4R.js.map → chunk-YMLQBZFJ.js.map} +0 -0
  538. /package/dist/{chunk-6HFM7EIT.js.map → chunk-YPSOHDNC.js.map} +0 -0
  539. /package/dist/{chunk-N35NC4JH.js.map → chunk-Z2PWOSCJ.js.map} +0 -0
  540. /package/dist/{chunk-HPLWFNG4.js.map → chunk-Z7ZXZL6Y.js.map} +0 -0
  541. /package/dist/{classified-marker-2KJAXRRO.js.map → classified-marker-BSQHU4JT.js.map} +0 -0
  542. /package/dist/{enclave-JU4YIEPB.js.map → collection-facade-LG3NYZVB.js.map} +0 -0
  543. /package/dist/{executor-CYJQLKKI.js.map → computed-ASBNTLOK.js.map} +0 -0
  544. /package/dist/{dead-filter-DCB62VWW.js.map → dead-filter-QKU56XTQ.js.map} +0 -0
  545. /package/dist/{executor-S4QIKEHW.js.map → derive-CXHCY46K.js.map} +0 -0
  546. /package/dist/{dispatch-MJ6SHB3Y.js.map → dispatch-4AP4PUZU.js.map} +0 -0
  547. /package/dist/{executor-YIQB2S6N.js.map → enclave-NYPT7WA7.js.map} +0 -0
  548. /package/dist/{export-accessible-4S36PQNR.js.map → executor-3KFRQETS.js.map} +0 -0
  549. /package/dist/{extract-partition-IO7FDZ2P.js.map → executor-AFHQYRAU.js.map} +0 -0
  550. /package/dist/{find-RBBYKXI7.js.map → executor-YYDW6XQI.js.map} +0 -0
  551. /package/dist/{issue-RIVHSY2S.js.map → export-accessible-BX2ILB4C.js.map} +0 -0
  552. /package/dist/{ledger-AETNF4OM.js.map → extract-partition-UPOVITFI.js.map} +0 -0
  553. /package/dist/{liberate-GFN4C7RR.js.map → find-SZBL2HPB.js.map} +0 -0
  554. /package/dist/{link-set-E5HNY67I.js.map → issue-G53NB6EW.js.map} +0 -0
  555. /package/dist/{managed-secret-CWQ6PND5.js.map → ledger-T5K4P2D7.js.map} +0 -0
  556. /package/dist/{noydb-ASEXNJS6.js.map → liberate-VEOZRESE.js.map} +0 -0
  557. /package/dist/{register-4EFJCVYD.js.map → link-set-76JZ6YB4.js.map} +0 -0
  558. /package/dist/{registry-4SDHHOJ7.js.map → managed-secret-6YC32VXG.js.map} +0 -0
  559. /package/dist/{registry-CZVINVQH.js.map → noydb-EDJA4JNJ.js.map} +0 -0
  560. /package/dist/{registry-IKUR2MXD.js.map → on/index.js.map} +0 -0
  561. /package/dist/{post-register-2XSSMGEQ.js.map → post-register-53O7AJRZ.js.map} +0 -0
  562. /package/dist/{registry-OYTFGWVK.js.map → register-6TCBR6XD.js.map} +0 -0
  563. /package/dist/{request-withdrawal-KGXGDPVQ.js.map → registry-DH2L4O2V.js.map} +0 -0
  564. /package/dist/{revoke-JFN773KF.js.map → registry-IWFMXCHX.js.map} +0 -0
  565. /package/dist/{signer-TA55QB6R.js.map → registry-Q3FG3OAX.js.map} +0 -0
  566. /package/dist/{stale-ARHFVL5U.js.map → registry-YC3IFG3A.js.map} +0 -0
  567. /package/dist/{storage-V7MTFAQJ.js.map → request-withdrawal-NM5VYR6F.js.map} +0 -0
  568. /package/dist/{reveal-BW36KCOQ.js.map → reveal-XBIMHAXR.js.map} +0 -0
  569. /package/dist/{ulid-PTAIMDG4.js.map → revoke-MJNYWO72.js.map} +0 -0
  570. /package/dist/{walk-3ZECBFDA.js.map → signer-6XVS2AU3.js.map} +0 -0
  571. /package/dist/{withdraw-accessible-7PG4DYQK.js.map → stale-MCS46TFO.js.map} +0 -0
  572. /package/dist/{verify-RO5RTZOJ.js.map → verify-WYOFLSNA.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/with-formula/materialized-views/dependency-analyzer.ts","../src/with-formula/materialized-views/query-hash.ts","../src/with-formula/materialized-views/projection-legs.ts","../src/with-formula/materialized-views/registry.ts"],"sourcesContent":["import type { Query, QueryPlan } from '../../kernel/query/builder.js'\nimport type { JoinContext } from '../../kernel/query/join.js'\nimport type { MaterializedViewSpec } from './types.js'\n\n/**\n * Walks a `Query<T>` plan and returns the set of source collection\n * names that any source-write should trigger a refresh on.\n *\n * Handles:\n * - root collection (the one the query was built from)\n * - FK join targets (`.join(field, { as })`)\n *\n * Also handles:\n * - cross-join targets (`.crossJoin(target, { as })`) — v3\n *\n * Deferred:\n * - `.wherePredicate(name)` — v2 predicate primitive\n * - Overlay-name expansion to {base, overlay}\n *\n * The set is materialized at MV registration time. The MV registry\n * uses it to (a) dispatch `onSourceWrite` only to MVs that actually\n * care, and (b) contribute edges to the shared cycle-detection graph.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function analyzeDependencies(query: Query<any>): Set<string> {\n const deps = new Set<string>()\n const plan = query._plan()\n const ctx = query._joinContext()\n\n // The root collection is always a dependency.\n if (ctx?.leftCollection) {\n deps.add(ctx.leftCollection)\n }\n\n // FK join targets contribute additional sources.\n for (const leg of plan.joins) {\n deps.add(leg.target)\n }\n\n // Cross-join targets are also dependency sources — writes to either side\n // must trigger MV refresh. Symmetric with FK-join target handling above.\n for (const clause of plan.clauses) {\n if (clause.type === 'crossJoin') {\n deps.add(clause.target)\n }\n }\n\n // Sub-plans inside OR clauses can carry nested joins. Walk them.\n // (Today only top-level `.join()` populates `plan.joins`, but the\n // OR-group machinery permits sub-plans, so we recurse defensively.)\n walkClausesForJoins(plan, deps, ctx)\n\n return deps\n}\n\nfunction walkClausesForJoins(\n plan: QueryPlan,\n deps: Set<string>,\n ctx: JoinContext | undefined,\n): void {\n void ctx\n // Today `plan.joins` carries all join legs at top level. Sub-plans\n // inside OR groups don't currently support nested joins, so the loop\n // below is a no-op safety net for future builder extensions.\n for (const clause of plan.clauses) {\n if (clause.type === 'group') {\n // Group clauses don't (yet) carry their own joins; this is a\n // forward-compat anchor for when OR-groups support nested\n // sources.\n }\n }\n}\n\n/**\n * Convenience: produce a stable string summary of the query plan\n * suitable for `queryHash` derivation. Captures everything the\n * dependency analyzer reads + the where/orderBy/limit/offset\n * structure that affects materialized rows.\n *\n * `joinContext` is intentionally NOT included — the join-resolution\n * function references would defeat hash determinism. The set of join\n * TARGETS (collection names) IS included via the plan.joins legs.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function summarizeQueryPlan(query: Query<any>): string {\n const plan = query._plan()\n const ctx = query._joinContext()\n return JSON.stringify({\n root: ctx?.leftCollection ?? null,\n clauses: plan.clauses.map(c => {\n if (c.type === 'crossJoin') {\n return {\n type: 'crossJoin',\n target: c.target,\n as: c.as,\n // Inline on: callback: use sentinel — drift detection disabled for this MV\n onPredicateName: c.onPredicateName ?? (c.on ? '[inline]' : null),\n maxRows: c.maxRows ?? null,\n // `outer` changes the row set, so it is part of the plan's identity\n // for drift detection, not decoration (#1130).\n outer: c.outer ?? false,\n }\n }\n return c\n }),\n orderBy: plan.orderBy,\n limit: plan.limit ?? null,\n offset: plan.offset,\n joins: plan.joins.map(j => ({ field: j.field, as: j.as, target: j.target, mode: j.mode })),\n })\n}\n\n/**\n * Canonical string description of a UNION MV's plan, used as input to\n * `computeQueryHash`.\n *\n * Asymmetry note:\n * - Arm collection names are NOT sorted. Declaration order is\n * semantically meaningful for the dedup-only UNION path —\n * `materializeUnionResult` iterates `spec.unionSources` in\n * declaration order and keeps the first-seen row per composite key\n * (tie-break precedence). If we sorted arms here, a consumer who\n * reordered `unionSources` to change precedence would compute the\n * same `queryHash`, refresh would be a no-op, and stale MV rows\n * would persist. Hashing in declaration order makes any reorder\n * trigger a refresh.\n * - `groupBy` fields ARE sorted. Multi-key groupBy buckets are\n * commutative (`canonicalGroupKey` produces the same composite key\n * regardless of field order in the input spec).\n * - `aggregate` keys ARE sorted. Reducer-spec keys are independent\n * of each other — order of declaration doesn't change output.\n *\n * Per-arm `map` functions are NOT fingerprinted; consumers must bump\n * the MV's `name` (or rely on application-level cache busting) when\n * `map` semantics change non-equivalently.\n */\nexport function summarizeUnionPlan<T extends Record<string, unknown>>(\n spec: MaterializedViewSpec<T>,\n): string {\n return `union(${summarizeUnionArms(spec)})${summarizeGroupingTail(spec)}`\n}\n\n/**\n * Canonical string description of a projection MV's plan (#810), used\n * as input to `computeQueryHash`.\n *\n * Leg descriptors ARE sorted (contrast with UNION arm order): every\n * leg attaches under a distinct `as` alias, forward legs are\n * one-to-one attachments and collect legs are independent\n * hash-grouped passes, so declaration order never changes the\n * materialized rows — a pure reorder must NOT force a refresh.\n * `from` (#1140) constrains the legal orderings (a leg must follow the\n * alias it attaches to) without making order meaningful: each descriptor\n * carries its own `@alias`, and aliases are unique, so the sorted set\n * still determines the leg graph exactly.\n *\n * The projection `map` is NOT fingerprinted (identical limitation as\n * the UNION arm `map`); consumers must bump the MV's `name` when\n * `map` semantics change non-equivalently.\n */\nexport function summarizeProjectionPlan<T extends Record<string, unknown>>(\n spec: MaterializedViewSpec<T>,\n): string {\n const projection = spec.projection!\n const legs = projection.joins\n .map(leg => {\n // #1140 — `from` changes which rows a leg attaches to, so it is part of\n // the plan's identity. Omitting it would let two structurally different\n // projections share a queryHash and silently skip a refresh.\n const at = leg.from !== undefined ? `@${leg.from}` : ''\n return 'collect' in leg\n ? `collect${at}:${leg.collect}.${leg.on}→${leg.as}`\n : `field${at}:${leg.field}→${leg.as}`\n })\n .sort()\n const body = JSON.stringify({ source: projection.source, legs })\n return `projection(${body})${summarizeGroupingTail(spec)}`\n}\n\n/** Arm descriptors for `summarizeUnionPlan` — declaration order preserved (see its doc). */\nfunction summarizeUnionArms<T extends Record<string, unknown>>(\n spec: MaterializedViewSpec<T>,\n): string {\n return (spec.unionSources ?? [])\n .map(s => {\n // Fold each arm's join legs into the summary so adding or\n // reordering joins (which changes the materialized rows) bumps\n // queryHash. Leg order is declaration-significant (legs chain), so\n // it is NOT sorted — same rationale as arm declaration order.\n const joins = s.join?.length\n ? `[${s.join.map(j => `${j.field}→${j.as}`).join(';')}]`\n : ''\n return `${s.collection}${joins}`\n })\n .join(',')\n}\n\n/**\n * Shared `|groupBy(…)|aggregate(…)|money(…)` tail for the UNION and\n * projection summaries — both feed the same post-map grouping pipeline,\n * so the same spec fields fold into both hashes with the same rules.\n */\nfunction summarizeGroupingTail<T extends Record<string, unknown>>(\n spec: MaterializedViewSpec<T>,\n): string {\n const groupBy: string = Array.isArray(spec.groupBy)\n ? [...spec.groupBy].sort().join(',')\n : typeof spec.groupBy === 'string'\n ? spec.groupBy\n : ''\n const aggKeys = spec.aggregate ? Object.keys(spec.aggregate).sort().join(',') : ''\n // `moneyFields` changes reducer semantics (float → exact BigInt), so\n // declaring / removing / re-keying it must bump queryHash. Keys are\n // sorted — they're independent of each other (one descriptor per\n // output field), same rationale as aggregate keys.\n const moneyKeys = spec.moneyFields ? Object.keys(spec.moneyFields).sort().join(',') : ''\n return `|groupBy(${groupBy})|aggregate(${aggKeys})|money(${moneyKeys})`\n}\n","/**\n * Deterministic hash of a materialized view strategy's \"shape\": MV\n * name + canonical query-plan summary + sorted dependency-set.\n *\n * Used to detect strategy drift: a row whose `_materializedFrom.queryHash`\n * doesn't match the current strategy is considered stale.\n *\n * Web Crypto SHA-256 — no extra deps. Mirrors the v1\n * `computeStrategyHash` pattern.\n */\nimport { sha256Hex } from '../../kernel/enclave/index.js'\n\nexport async function computeQueryHash(\n mvName: string,\n /**\n * Source-collection set the query depends on. Sorted before\n * canonicalization so set iteration order doesn't affect the hash.\n */\n dependencies: ReadonlySet<string>,\n /**\n * Stringified query-plan summary. The caller produces this from the\n * `Query<T>` builder — concretely: a JSON serialization of clauses +\n * orderBy + limit + offset + joins. Function bodies inside\n * `wherePredicate` are NOT included here (those carry their own\n * `predicateHash` to be folded in by a later sub-issue).\n */\n queryPlanSummary: string,\n): Promise<string> {\n const canonical = JSON.stringify({\n mvName,\n dependencies: [...dependencies].sort(),\n queryPlanSummary,\n })\n const bytes = new TextEncoder().encode(canonical)\n return sha256Hex(bytes)\n}\n\n/**\n * Canonicalize a query plan for hashing. Walks the plan structure\n * with sorted keys so insertion order doesn't perturb the result.\n * Lives here rather than in `query/builder.ts` to keep that module\n * stable across MV-specific evolutions.\n *\n * @internal exported for testing\n */\nexport function canonicalizeQueryPlan(plan: unknown): string {\n return JSON.stringify(plan, (_key, value) => {\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n const sorted: Record<string, unknown> = {}\n for (const k of Object.keys(value as Record<string, unknown>).sort()) {\n sorted[k] = (value as Record<string, unknown>)[k]\n }\n return sorted\n }\n return value\n })\n}\n","/**\n * Projection-leg topology (#810, extended by #1140).\n *\n * A projection MV's legs originally all attached to the PRIMARY row: a forward\n * leg named an FK field on `projection.source`, and a reverse `collect` leg's\n * `on` field had to `ref()` the source itself. Anything two FKs away was\n * therefore inexpressible — `bill → entity → client` has no leg shape, because\n * the bill has no `clientId` and `clients.entityId` refs `entities`, not\n * `bills`.\n *\n * `from` closes that: a leg may attach to a previously-declared ALIAS instead of\n * to the primary row. This module owns the two questions that follow from it —\n * *is this leg graph well-formed?* and *which collection does a leg's rows come\n * from?* — so neither the registry nor the executor has to re-derive them.\n *\n * **Why cycles are impossible by construction, and there is no depth cap.**\n * `from` may only name an alias declared EARLIER in `joins`. A leg can therefore\n * never reach forward, the graph is a forest rooted at the primary row, and its\n * depth is bounded by the number of legs. Validation refuses an unknown or\n * not-yet-declared alias, which is the same check.\n */\n\nimport { MaterializedViewConfigError } from '../../kernel/errors.js'\nimport type { ProjectionJoinLeg, ProjectionSpec } from './types.js'\n\n/** Reverse (one-to-many) leg — discriminated on `collect`, as the type is. */\nexport function isCollectLeg(\n leg: ProjectionJoinLeg,\n): leg is Extract<ProjectionJoinLeg, { collect: string }> {\n return 'collect' in leg\n}\n\n/**\n * Refuse a malformed leg graph where `withMaterializedView()` checks the rest of\n * the leg shape — at spec CONSTRUCTION, not at vault open and not at first\n * materialization. Alias wiring is pure configuration: it needs no refs, no\n * records and no store, so the earliest failure is the best one.\n * (Ref EXISTENCE still resolves at first materialization, unchanged — refs\n * cannot exist until after `openVault()` returns.)\n */\nexport function validateProjectionLegs<T extends Record<string, unknown>>(\n mvName: string,\n projection: ProjectionSpec<T>,\n): void {\n // Non-empty and unique `as` are already refused by `withMaterializedView()`\n // itself, earlier and with its own message — not re-checked here. This\n // function owns the `from` wiring and nothing else.\n const seen = new Map<string, ProjectionJoinLeg>()\n for (const leg of projection.joins) {\n if (leg.from !== undefined) {\n const parent = seen.get(leg.from)\n if (!parent) {\n throw new MaterializedViewConfigError(\n `\"${mvName}\": projection leg \"${leg.as}\" declares from: \"${leg.from}\", which is not an ` +\n `alias declared EARLIER in \\`joins\\`. A leg may only attach to the primary row or to a ` +\n `preceding leg — that ordering rule is what makes a cycle impossible. Known so far: ` +\n `${[...seen.keys()].map(a => `\"${a}\"`).join(', ') || '(none)'}`,\n )\n }\n if (isCollectLeg(parent)) {\n throw new MaterializedViewConfigError(\n `\"${mvName}\": projection leg \"${leg.as}\" declares from: \"${leg.from}\", but \"${leg.from}\" ` +\n `is a collect leg and holds an ARRAY of rows, not one record. A leg can only hang off a ` +\n `forward leg (record | null). Attach it to the primary row instead, or collect the ` +\n `far side directly if its ref() reaches \"${projection.source}\".`,\n )\n }\n }\n seen.set(leg.as, leg)\n }\n}\n\n/**\n * The collection a leg's rows come from — the primary source for a root leg, the\n * `from` leg's own target otherwise.\n *\n * Returns `null` when a forward `ref()` somewhere along the chain is not\n * declared yet, which at registration time is the normal case rather than an\n * error: refs are declared after `openVault()` returns, so the registry retries\n * this on every dispatch until it resolves (`_pendingForwardDeps`).\n *\n * `resolveRef` is passed in rather than imported so this module stays free of\n * vault wiring — the registry hands it the ref registry's `getOutbound`, the\n * executor hands it a join context lookup. Both answer the same question.\n */\nexport type RefLookup = (collection: string, field: string) => { target: string } | null\n\nexport function resolveLegOwner(\n leg: ProjectionJoinLeg,\n joins: ReadonlyArray<ProjectionJoinLeg>,\n source: string,\n resolveRef: RefLookup,\n): string | null {\n if (leg.from === undefined) return source\n const parent = joins.find(l => l.as === leg.from)\n if (!parent) return null // refused by validateProjectionLegs; defensive here\n if (isCollectLeg(parent)) return parent.collect // refused too, same reason\n const parentOwner = resolveLegOwner(parent, joins, source, resolveRef)\n if (parentOwner === null) return null\n return resolveRef(parentOwner, parent.field)?.target ?? null\n}\n\n/**\n * The collection a FORWARD leg resolves INTO — i.e. its dependency. `null` while\n * any ref in the chain (including this leg's own) is still undeclared.\n */\nexport function resolveForwardLegTarget(\n leg: Extract<ProjectionJoinLeg, { field: string }>,\n joins: ReadonlyArray<ProjectionJoinLeg>,\n source: string,\n resolveRef: RefLookup,\n): string | null {\n const owner = resolveLegOwner(leg, joins, source, resolveRef)\n if (owner === null) return null\n return resolveRef(owner, leg.field)?.target ?? null\n}\n","import { MaterializedViewSourceUnknownError, RefNotDeclaredError } from '../../kernel/errors.js'\nimport type { ViaGraph, FieldRef, EdgeKind, Grain } from '../../kernel/via/graph.js'\nimport type { Clause, FieldClause } from '../../kernel/query/predicate.js'\nimport type { DeclaredPredicate } from '../../kernel/query/builder.js'\nimport { analyzeDependencies, summarizeQueryPlan, summarizeUnionPlan, summarizeProjectionPlan } from './dependency-analyzer.js'\nimport { computeQueryHash } from './query-hash.js'\nimport { isCollectLeg, resolveForwardLegTarget } from './projection-legs.js'\nimport type { MaterializedViewSpec, MVQueryContext } from './types.js'\n\n/**\n * Whole-record artifact-grain field marker (#638 Task 2) — MUST match\n * `derivations/registry.ts`'s and `vault.ts`'s overlay-edge marker so\n * cross-registry edges (a derivation feeding an MV, or vice versa) resolve\n * to the SAME graph node. See that file's `WHOLE_RECORD` doc comment.\n */\nconst WHOLE_RECORD = '*'\n\n/**\n * One registered MV strategy alongside its derived metadata. Stored\n * type-erased on `TRow` so the registry can hold heterogeneous MVs.\n */\nexport interface RegisteredMV {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n readonly spec: MaterializedViewSpec<any>\n /** Output collection name (`spec.output?.collection ?? spec.name`). */\n readonly outputCollection: string\n /** Set of source collections; populated at registration via the analyzer. */\n readonly dependencies: ReadonlySet<string>\n /** Canonical `queryHash` — `_materializedFrom.queryHash` for every emitted row. */\n readonly queryHash: string\n /**\n * Top-level FieldClauses on the partition field, captured at\n * registration time. Used by the cycle detector to resolve\n * same-collection-as-source edges via the partition-discriminator\n * check. Empty when `spec.output?.partition` is undefined.\n */\n readonly partitionClauses: readonly FieldClause[]\n /**\n * #638 Task 2 — `'record'` for a row-per-source-row Query<T> or\n * `unionSources` MV, `'aggregate'` for a `.groupBy().aggregate()` MV\n * (the shape that requires explicit `sources`, since the dependency\n * analyzer can't walk an aggregate plan). Feeds `edges()`'s grain.\n */\n readonly grain: Grain\n}\n\n/**\n * Vault-internal registry of MV strategies. Owned by `Vault`; not\n * exported. Parallel to v1's `DerivationRegistry`; the two graphs share\n * a single cycle-detection pass at vault open (see `validate`).\n *\n * @internal\n */\nexport class MaterializedViewRegistry {\n /** Keyed by `spec.name`. */\n private readonly _byName = new Map<string, RegisteredMV>()\n /** Keyed by dependency source-collection → MVs that depend on it. */\n private readonly _bySource = new Map<string, RegisteredMV[]>()\n /**\n * Projection MVs (#810) whose forward-leg ref() targets could not be\n * resolved at registration time. A forward leg names only the FK\n * FIELD; its dependency is the field's ref() TARGET, declared on the\n * source collection — but registration runs at vault open, BEFORE\n * user code declares collections (and their refs). Constructing the\n * source collection here to look them up would be worse: a later\n * `vault.collection(source, { refs })` call only registers refs on a\n * cache miss, so an early construction would silently drop them.\n * Instead each entry carries a non-constructive ref-registry probe;\n * `mvsForSource` retries on every dispatch until every forward\n * target has resolved (see `_resolvePendingForwardDeps`).\n */\n private readonly _pendingForwardDeps: Array<{\n reg: RegisteredMV\n /** Forward-leg ALIASES still awaiting resolution (#1140 — a leg is identified\n * by its alias, not its field: with `from`, two legs may name the same FK\n * field on different collections). */\n aliases: Set<string>\n resolveTarget: (alias: string) => string | null\n }> = []\n\n /**\n * Query-form strategies whose `query()` callback could not be planned at\n * registration time because a `.join()` names a field whose `ref()` is not\n * declared YET (#1139).\n *\n * Registration runs inside `openVault()`; a collection's refs can only be\n * declared afterwards, so for a query-form MV that joins a declared FK there\n * is NO call ordering the consumer can choose — the plan is simply built too\n * early. Rather than failing the vault open, the strategy is parked here and\n * replanned from {@link resolvePendingPlans}, which every write dispatch and\n * `vault.refreshView()` call runs first. This is the query-form counterpart\n * of `_pendingForwardDeps`, one level up: that defers a leg's TARGET, this\n * defers the whole plan.\n *\n * Only `RefNotDeclaredError` parks a strategy. Every other planning failure\n * still throws out of `openVault()` exactly as before, so a typo'd source or\n * a malformed spec keeps its loud, early error.\n *\n * A parked strategy is invisible until it resolves: it contributes no\n * `_bySource` entries and no cycle-detection edges (same caveat as a\n * late-resolved forward target — `edges()` runs once at vault open). It also\n * cannot be dispatched, which is why {@link hasPendingPlans} forces the\n * conservative branch in `Collection._txAtomicSafe`: the atomic write path\n * skips MV dispatch, and skipping it here would mean the write that was\n * supposed to trigger the first replan is the one that gets missed.\n */\n private readonly _pendingPlans: Array<{\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n spec: MaterializedViewSpec<any>\n db: MVQueryContext\n options?: { knownCollections?: (name: string) => boolean }\n }> = []\n\n /**\n * Register an MV. Invokes `spec.query()` once at registration time to\n * read the plan + join context; the resulting `Query<T>` is discarded\n * after dependency extraction. `vault.collection(...)` must therefore\n * be functional by the time this runs — typically wired from\n * `Vault._initMaterializedViews` after collection bootstrap.\n *\n * Throws `MaterializedViewSourceUnknownError` if the analyzer\n * surfaces a dependency the vault doesn't know about (when a\n * `knownCollections` checker is supplied).\n */\n async register(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n spec: MaterializedViewSpec<any>,\n db: MVQueryContext,\n options?: { knownCollections?: (name: string) => boolean },\n ): Promise<void> {\n // Build a predicate-aware db wrapper. If `spec.predicates` is\n // declared, the wrapper intercepts `.collection().query()` and\n // attaches the predicates map to the resulting Query<T>. With no\n // predicates declared, the wrapper is the original db unchanged.\n const dbForQuery = spec.predicates ? wrapDbWithPredicates(db, spec.predicates) : db\n\n // Invoke the query callback once to inspect its plan / dependencies.\n // For Query<T> shapes the analyzer extracts deps + plan summary\n // automatically. Reduction / GroupedReduction shapes don't\n // expose the underlying Query, so the spec must declare `sources`\n // explicitly. `partitionClauses` are only populated for Query<T>\n // since same-collection-partition is a non-aggregate concern.\n // UNION-form strategies: dependencies and plan summary come\n // straight off the strategy — no `query` callback to introspect.\n // The dependency-analyzer + summarizer are bypassed entirely; the\n // executor handles materialization via `materializeUnionResult`.\n let dependencies: Set<string>\n let queryPlanSummary: string\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let qAny: any = null\n let isQuery = false\n // Projection-form (#810): forward legs whose ref() target wasn't\n // resolvable at registration time — folded in lazily, see\n // `_pendingForwardDeps`.\n const pendingForwardFields: string[] = []\n if (spec.unionSources) {\n dependencies = new Set(spec.unionSources.map(s => s.collection))\n // Per-arm joins resolve right-side collections that aren't among\n // the arm `collection`s. The consumer lists those in `sources`;\n // fold them into the dependency set so a write to a join-target\n // collection triggers MV refresh (and contributes a cycle edge).\n if (spec.sources) for (const s of spec.sources) dependencies.add(s)\n queryPlanSummary = summarizeUnionPlan(spec)\n } else if (spec.projection) {\n // Projection-form (#810): dependencies are all AUTO — the primary\n // source, every collect leg's collection (both literal names), and\n // every forward leg's ref() target. Forward targets usually can't\n // resolve yet (refs are declared after vault open) — those go\n // through the pending-resolution path below. Explicit `sources`\n // remains additive, same as the other two forms.\n const projection = spec.projection\n dependencies = new Set([projection.source])\n for (const leg of projection.joins) {\n // A collect leg's dependency is its literal collection name, whatever it\n // attaches to — which is why `from` needs no new dependency machinery on\n // that side. A forward leg's dependency is a ref() target, still unknown.\n if (isCollectLeg(leg)) dependencies.add(leg.collect)\n else pendingForwardFields.push(leg.as)\n }\n if (spec.sources) for (const s of spec.sources) dependencies.add(s)\n queryPlanSummary = summarizeProjectionPlan(spec)\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let q: any\n try {\n q = spec.query!(dbForQuery)\n } catch (e) {\n // #1139 — a join on a ref that is not declared YET. Park and replan;\n // see `_pendingPlans`. Anything else is a real registration failure.\n if (!(e instanceof RefNotDeclaredError)) throw e\n this._pendingPlans.push({ spec, db, ...(options !== undefined ? { options } : {}) })\n return\n }\n qAny = q // already `any` — see the declaration above\n isQuery = typeof qAny._plan === 'function'\n if (isQuery) {\n // `q` is the `Query` arm of the union here (runtime-confirmed via\n // `qAny._plan` above); reuse the already-`any` `qAny` the block uses\n // for `_plan()` rather than re-narrowing.\n dependencies = analyzeDependencies(qAny)\n queryPlanSummary = summarizeQueryPlan(qAny)\n // Fold `.wherePredicate(name, ctx)` references into the plan\n // summary so predicate function or ctx changes (signalled by\n // bumping `hash` or supplying a different ctx) propagate into\n // `queryHash` and force refresh on next visit.\n const predicateRefs = extractPredicateRefs(qAny._plan())\n if (predicateRefs.length > 0) {\n queryPlanSummary = JSON.stringify({ plan: queryPlanSummary, predicates: predicateRefs })\n }\n // If `sources` is ALSO declared, take the union (consumer's\n // explicit list extends the auto-analyzed set).\n if (spec.sources) for (const s of spec.sources) dependencies.add(s)\n } else {\n // Aggregate shape: require explicit `sources`.\n if (!spec.sources || spec.sources.length === 0) {\n throw new Error(\n `withMaterializedView \"${spec.name}\": query() returned an aggregate ` +\n `(Reduction or GroupedReduction) but no \\`sources\\` field is declared. ` +\n `The dependency analyzer cannot walk through groupBy().aggregate() ` +\n `back to the source — declare sources: [...] explicitly.`,\n )\n }\n dependencies = new Set(spec.sources)\n // Aggregate plans don't carry a chainable query plan for summary\n // purposes; the dep-set + spec.name serve as the queryHash inputs.\n queryPlanSummary = JSON.stringify({ aggregate: true, sources: [...spec.sources].sort() })\n }\n }\n\n // Sanity-check declared dependencies against the vault's known\n // collections. Optional — when the checker isn't supplied (test\n // wiring, in-process composition) the registration succeeds and\n // any typo surfaces at first onSourceWrite as a no-op.\n if (options?.knownCollections) {\n for (const dep of dependencies) {\n if (!options.knownCollections(dep)) {\n throw new MaterializedViewSourceUnknownError(spec.name, dep)\n }\n }\n }\n\n const outputCollection = spec.output?.collection ?? spec.name\n const queryHash = await computeQueryHash(spec.name, dependencies, queryPlanSummary)\n // For same-collection-as-source MVs, capture the where-clauses on\n // the partition field so cycle detection can prove disjointness.\n // Only applicable to Query<T> shapes — aggregate MVs don't carry\n // a chainable plan to inspect (and same-collection aggregation\n // doesn't make sense for same-collection aggregation).\n const partitionClauses: FieldClause[] = []\n const partitionField = spec.output?.partition?.field\n if (partitionField !== undefined && isQuery) {\n const plan = qAny._plan()\n for (const clause of plan.clauses) {\n if (isFieldClauseOnField(clause, partitionField)) partitionClauses.push(clause)\n }\n }\n // #638 Task 2 — 'aggregate' only for the explicit-sources aggregate shape\n // (groupBy().aggregate() with no chainable plan); a row-per-source-row\n // Query<T>, unionSources, or projection MV is 'record'.\n const grain: Grain = spec.unionSources || spec.projection || isQuery ? 'record' : 'aggregate'\n const reg: RegisteredMV = { spec, outputCollection, dependencies, queryHash, partitionClauses, grain }\n\n this._byName.set(spec.name, reg)\n for (const dep of dependencies) {\n const arr = this._bySource.get(dep)\n if (arr) arr.push(reg)\n else this._bySource.set(dep, [reg])\n }\n if (pendingForwardFields.length > 0) {\n // Non-constructive ref-registry probe: the Vault (the real\n // MVQueryContext) carries its RefRegistry as a private field,\n // reachable structurally at runtime. Test stubs without one simply\n // never resolve — forward deps then come only from explicit `sources`.\n const refRegistry = (db as unknown as {\n refRegistry?: { getOutbound(collection: string): Record<string, { target: string }> }\n }).refRegistry\n const projectionSpec = spec.projection!\n const resolveRef = (c: string, f: string): { target: string } | null =>\n refRegistry?.getOutbound(c)[f] ?? null\n this._pendingForwardDeps.push({\n reg,\n aliases: new Set(pendingForwardFields),\n resolveTarget: (alias) => {\n const leg = projectionSpec.joins.find(l => l.as === alias)\n if (!leg || isCollectLeg(leg)) return null\n // Walks the `from` chain — every hop needs its own ref declared, so a\n // two-hop leg simply resolves one dispatch later than a one-hop one.\n return resolveForwardLegTarget(leg, projectionSpec.joins, projectionSpec.source, resolveRef)\n },\n })\n // Immediate attempt — covers refs already declared by the time\n // this MV registers (re-registration flows, test wiring).\n this._resolvePendingForwardDeps()\n }\n }\n\n /**\n * `true` while any query-form strategy is still unplanned (#1139). Read by\n * `Collection._txAtomicSafe`, which must refuse the atomic write path while\n * this holds — see the `_pendingPlans` doc comment for why.\n */\n hasPendingPlans(): boolean {\n return this._pendingPlans.length > 0\n }\n\n /**\n * Replan every parked query-form strategy (#1139). Called at the head of both\n * write dispatchers and of `vault.refreshView()`, so a strategy resolves on the\n * first write or refresh after its source collection's refs are declared —\n * which is the earliest moment it could produce a correct plan, and strictly\n * before the first moment it could have any output to produce.\n *\n * Each entry is handed straight back to {@link register}, so a strategy that\n * is STILL unplannable simply re-parks itself and the next dispatch tries\n * again. Idempotent and cheap: the array empties as strategies resolve, and\n * both callers skip the await entirely once it is empty.\n *\n * A late-resolved strategy does NOT retro-feed `edges()` — the unified cycle\n * pass runs once at vault open, before refs exist. Same caveat, and the same\n * reason, as a late-resolved forward-leg target.\n */\n async resolvePendingPlans(): Promise<void> {\n if (this._pendingPlans.length === 0) return\n // Splice first: `register` re-parks anything still unplannable, and reading\n // a live array it is concurrently pushing to would loop.\n const parked = this._pendingPlans.splice(0)\n for (const entry of parked) {\n await this.register(entry.spec, entry.db, entry.options)\n }\n }\n\n /** All MVs that depend on `source`, in registration order. */\n mvsForSource(source: string): ReadonlyArray<RegisteredMV> {\n if (this._pendingForwardDeps.length > 0) this._resolvePendingForwardDeps()\n return this._bySource.get(source) ?? []\n }\n\n /**\n * Retry ref() resolution for every pending projection forward leg\n * (#810). A field resolves once its source collection's refs have\n * been declared; the target then folds into the owning MV's\n * dependency set and `_bySource`, so subsequent writes to it\n * dispatch a refresh. Idempotent and cheap — the pending list\n * empties as fields resolve, and `mvsForSource` skips the call\n * entirely once it's empty.\n *\n * Late-resolved targets do NOT retro-feed `edges()` — the cycle\n * pass runs once at vault open, before refs exist. A cycle routed\n * exclusively through a forward leg is therefore not detected at\n * open (collect + source edges, the literal names, are).\n */\n private _resolvePendingForwardDeps(): void {\n for (let i = this._pendingForwardDeps.length - 1; i >= 0; i--) {\n const entry = this._pendingForwardDeps[i]!\n for (const alias of [...entry.aliases]) {\n const target = entry.resolveTarget(alias)\n if (target === null) continue\n entry.aliases.delete(alias)\n if (entry.reg.dependencies.has(target)) continue\n // `dependencies` is declared ReadonlySet for consumers; the\n // registry owns the underlying Set and is the one writer.\n ;(entry.reg.dependencies as Set<string>).add(target)\n const arr = this._bySource.get(target)\n if (arr) arr.push(entry.reg)\n else this._bySource.set(target, [entry.reg])\n }\n if (entry.aliases.size === 0) this._pendingForwardDeps.splice(i, 1)\n }\n }\n\n /** Single MV by name, or `undefined`. */\n byName(name: string): RegisteredMV | undefined {\n return this._byName.get(name)\n }\n\n /** Iterate over every registered MV. */\n all(): ReadonlyArray<RegisteredMV> {\n return [...this._byName.values()]\n }\n\n /**\n * Graph edges for #638 Task 2: one `'mv'` edge per registered MV — target\n * = the output collection (a `WHOLE_RECORD` artifact node), sources =\n * every dependency (also `WHOLE_RECORD` nodes). Same-collection edges\n * (`dep === outputCollection`) are skipped IFF the MV declares an\n * `output.partition` discriminator AND the query has a where-clause that\n * provably excludes the partition value (`partitionDisjoint`) — the SAME\n * condition the old local DFS used. Grain comes from the registration-time\n * `RegisteredMV.grain`.\n */\n edges(): ReadonlyArray<{ readonly target: FieldRef; readonly sources: readonly FieldRef[]; readonly kind: EdgeKind; readonly grain: Grain }> {\n const out: Array<{ target: FieldRef; sources: FieldRef[]; kind: EdgeKind; grain: Grain }> = []\n for (const reg of this._byName.values()) {\n const sources: FieldRef[] = []\n for (const dep of reg.dependencies) {\n if (dep === reg.outputCollection && partitionDisjoint(reg)) continue\n sources.push({ collection: dep, field: WHOLE_RECORD })\n }\n if (sources.length === 0) continue\n out.push({ target: { collection: reg.outputCollection, field: WHOLE_RECORD }, sources, kind: 'mv', grain: reg.grain })\n }\n return out\n }\n\n /**\n * Cycle detection, delegated to `ViaGraph.assertAcyclic()` (#638 Task 2 —\n * retires the local DFS). `graph` is the caller's shared per-vault graph,\n * ALREADY carrying this registry's `edges()` AND `DerivationRegistry`'s\n * (registered by the caller — see `Vault._initMaterializedViews`, which\n * runs after `_initDerivations`, so a pure-derivation cycle already threw\n * `DerivationCycleError` there; any cycle surfacing here necessarily\n * touches an MV edge). Throws `MaterializedViewCycleError` — SAME class as\n * before.\n */\n validate(graph: ViaGraph): void {\n graph.assertAcyclic()\n }\n}\n\n/**\n * Type guard: is the clause a top-level `FieldClause` on the given\n * field? Used by the partition-disjoint check.\n *\n * @internal\n */\nfunction isFieldClauseOnField(clause: Clause, field: string): clause is FieldClause {\n return clause.type === 'field' && clause.field === field\n}\n\n/**\n * Wrap an `MVQueryContext` so its `.collection().query()` returns a\n * Query<T> with the MV's declared predicates attached. Bare Queries\n * (outside of any MV) don't gain `.wherePredicate()` — only Queries\n * obtained through this wrapped db do.\n *\n * @internal\n */\nexport function wrapDbWithPredicates(\n db: MVQueryContext,\n predicates: NonNullable<MaterializedViewSpec<Record<string, unknown>>['predicates']>,\n): MVQueryContext {\n // Build the predicate map once — the fn signature in the MV spec\n // is row-typed but the QueryBuilder casts to unknown, so we widen\n // here for the Map.\n const map = new Map<string, DeclaredPredicate>()\n for (const [name, decl] of Object.entries(predicates)) {\n map.set(name, {\n hash: decl.hash,\n fn: decl.fn as (record: unknown, ctx?: unknown) => boolean,\n })\n }\n return {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n collection<T extends Record<string, unknown>>(name: string): any {\n const c = db.collection<T>(name)\n // Return an object that delegates everything to `c` but\n // overrides `.query()` to attach predicates via the new\n // `Query._withPredicates()` accessor.\n return new Proxy(c, {\n get(target, prop, receiver) {\n if (prop === 'query') {\n return (...args: unknown[]) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const q = (target.query as any)(...args)\n // For non-aggregate Query<T>, attach predicates. For\n // legacy predicate-arg overload that returns T[] (sync\n // filter), pass through unchanged.\n \n if (q && typeof q._withPredicates === 'function') {\n return q._withPredicates(map)\n }\n return q\n }\n }\n return Reflect.get(target, prop, receiver)\n },\n })\n },\n }\n}\n\n/**\n * Walk a QueryPlan's clauses and collect predicate-reference markers\n * for `queryHash` derivation. Returns a sorted array (deterministic\n * order) of `{ name, predicateHash, ctxHash }` tuples — these are the\n * hashable identity of each `.wherePredicate()` call site.\n *\n * @internal\n */\nfunction extractPredicateRefs(\n plan: { clauses: readonly Clause[] },\n): Array<{ name: string; predicateHash: string; ctxHash: string }> {\n const refs: Array<{ name: string; predicateHash: string; ctxHash: string }> = []\n const walk = (clauses: readonly Clause[]): void => {\n for (const c of clauses) {\n if (c.type === 'wherePredicate') {\n refs.push({ name: c.name, predicateHash: c.predicateHash, ctxHash: c.ctxHash })\n } else if (c.type === 'group') {\n walk(c.clauses)\n }\n }\n }\n walk(plan.clauses)\n // Stable-sort by (name, predicateHash, ctxHash) — same predicate\n // appearing twice with different ctx hashes both flow through.\n refs.sort((a, b) => {\n if (a.name !== b.name) return a.name < b.name ? -1 : 1\n if (a.predicateHash !== b.predicateHash) return a.predicateHash < b.predicateHash ? -1 : 1\n return a.ctxHash < b.ctxHash ? -1 : a.ctxHash > b.ctxHash ? 1 : 0\n })\n return refs\n}\n\n/**\n * Provability check for the same-collection partition-discriminator.\n * Returns `true` when\n * the captured partition clauses on the MV's query provably exclude\n * the partition's value — meaning the input filter and the output\n * partition are disjoint and the same-collection edge isn't really a\n * cycle.\n *\n * Supported provability shapes (narrow on purpose — DERIV-PP30-001\n * is the load-bearing case):\n *\n * - `.where(field, '==', X)` where X !== partition.value → disjoint\n * - `.where(field, '!=', partition.value)` → disjoint\n * - `.where(field, 'in', [...])` where partition.value NOT in list → disjoint\n *\n * Anything else (no clause on the partition field, an 'in' list that\n * contains partition.value, unsupported operators) → not disjoint,\n * the cycle detector surfaces `MaterializedViewCycleError`.\n *\n * @internal\n */\nfunction partitionDisjoint(reg: RegisteredMV): boolean {\n const partition = reg.spec.output?.partition\n if (partition === undefined) return false\n const value = partition.value\n // The OR-semantics of multiple where-clauses on the same field\n // would muddy this check. v2 only treats AND-chained clauses;\n // any clause that proves disjoint is sufficient.\n for (const c of reg.partitionClauses) {\n if (c.op === '==' && c.value !== value) return true\n if (c.op === '!=' && c.value === value) return true\n if (c.op === 'in' && Array.isArray(c.value)) {\n const list = c.value as readonly unknown[]\n if (!list.includes(value)) return true\n }\n }\n return false\n}\n"],"mappings":";;;;;;;;;;AAwBO,SAAS,oBAAoB,OAAgC;AAClE,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,OAAO,MAAM,MAAM;AACzB,QAAM,MAAM,MAAM,aAAa;AAG/B,MAAI,KAAK,gBAAgB;AACvB,SAAK,IAAI,IAAI,cAAc;AAAA,EAC7B;AAGA,aAAW,OAAO,KAAK,OAAO;AAC5B,SAAK,IAAI,IAAI,MAAM;AAAA,EACrB;AAIA,aAAW,UAAU,KAAK,SAAS;AACjC,QAAI,OAAO,SAAS,aAAa;AAC/B,WAAK,IAAI,OAAO,MAAM;AAAA,IACxB;AAAA,EACF;AAKA,sBAAoB,MAAM,MAA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,EAAE,UAAU,MAAO,QAAO;AAC/C,QAAI,EAAE,OAAO,QAAQ,MAAM,QAAQ,EAAE,KAAK,GAAG;AAC3C,YAAM,OAAO,EAAE;AACf,UAAI,CAAC,KAAK,SAAS,KAAK,EAAG,QAAO;AAAA,IACpC;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DerivationCycleError,
3
3
  MaterializedViewCycleError
4
- } from "./chunk-HNGSV2YC.js";
4
+ } from "./chunk-JBIV4FLR.js";
5
5
 
6
6
  // src/kernel/via/graph.ts
7
7
  var DEFAULT_POSTURE = { encryptedAtRest: "envelope", queryable: "full", exportable: true, forgettable: false };
@@ -341,4 +341,4 @@ export {
341
341
  DEFAULT_POSTURE,
342
342
  ViaGraph
343
343
  };
344
- //# sourceMappingURL=chunk-7TSYBD3E.js.map
344
+ //# sourceMappingURL=chunk-5263OEM3.js.map
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  envelopePayloadHash
3
- } from "./chunk-6SAFL5YE.js";
3
+ } from "./chunk-RC4BROYR.js";
4
4
  import {
5
5
  NOYDB_FORMAT_VERSION
6
- } from "./chunk-YPYHVOXP.js";
6
+ } from "./chunk-RK7N4OQ5.js";
7
7
  import {
8
8
  DictKeyMissingError,
9
9
  PermissionDeniedError
10
- } from "./chunk-HNGSV2YC.js";
10
+ } from "./chunk-JBIV4FLR.js";
11
11
 
12
12
  // src/via/lookup/handle.ts
13
13
  function isDeleteMarker(envelope) {
@@ -102,14 +102,17 @@ var LookupHandle = class {
102
102
  _by: this.keyring.userId
103
103
  };
104
104
  }
105
- const envelope = await this.reservedEnvelopes.encrypt(this.collName, JSON.stringify(entry), version);
106
- return { ...envelope, _by: this.keyring.userId };
105
+ return this.reservedEnvelopes.encrypt(
106
+ { collection: this.collName, id: entry.key, by: this.keyring.userId },
107
+ JSON.stringify(entry),
108
+ version
109
+ );
107
110
  }
108
- async decryptEntry(envelope) {
111
+ async decryptEntry(key, envelope) {
109
112
  if (!this.encrypted) {
110
113
  return JSON.parse(envelope._data);
111
114
  }
112
- const json = await this.reservedEnvelopes.decrypt(this.collName, envelope);
115
+ const json = await this.reservedEnvelopes.decrypt(this.collName, key, envelope);
113
116
  return JSON.parse(json);
114
117
  }
115
118
  /** @internal #650 Task 4 — re-read `key`'s CURRENT adapter truth into `_syncCache` (delete the
@@ -123,7 +126,7 @@ var LookupHandle = class {
123
126
  this._syncCache.delete(key);
124
127
  return;
125
128
  }
126
- this._syncCache.set(key, await this.decryptEntry(envelope));
129
+ this._syncCache.set(key, await this.decryptEntry(key, envelope));
127
130
  }
128
131
  // ─── Public API ───────────────────────────────────────────────────
129
132
  /**
@@ -194,7 +197,7 @@ var LookupHandle = class {
194
197
  key
195
198
  );
196
199
  if (!envelope || isDeleteMarker(envelope)) return null;
197
- const entry = await this.decryptEntry(envelope);
200
+ const entry = await this.decryptEntry(key, envelope);
198
201
  return entry.labels;
199
202
  }
200
203
  /**
@@ -224,7 +227,7 @@ var LookupHandle = class {
224
227
  }
225
228
  const nextVersion = existing._v + 1;
226
229
  if (this.onDirty) {
227
- await this.adapter.put(this.compartmentName, this.collName, key, this.buildDeleteMarker(nextVersion, this.keyring.userId));
230
+ await this.adapter.put(this.compartmentName, this.collName, key, this.buildDeleteMarker({ collection: this.collName, id: key }, nextVersion, this.keyring.userId));
228
231
  } else {
229
232
  await this.adapter.delete(this.compartmentName, this.collName, key);
230
233
  }
@@ -280,7 +283,7 @@ var LookupHandle = class {
280
283
  if (!existing || isDeleteMarker(existing)) {
281
284
  throw new DictKeyMissingError(this.dictionaryName, oldKey);
282
285
  }
283
- const oldEntry = await this.decryptEntry(existing);
286
+ const oldEntry = await this.decryptEntry(oldKey, existing);
284
287
  const newEntry = { key: newKey, labels: oldEntry.labels };
285
288
  const newEnvelope = await this.encryptEntry(newEntry, 1);
286
289
  await this.adapter.put(
@@ -295,7 +298,7 @@ var LookupHandle = class {
295
298
  }
296
299
  const oldKeyNextVersion = existing._v + 1;
297
300
  if (this.onDirty) {
298
- await this.adapter.put(this.compartmentName, this.collName, oldKey, this.buildDeleteMarker(oldKeyNextVersion, this.keyring.userId));
301
+ await this.adapter.put(this.compartmentName, this.collName, oldKey, this.buildDeleteMarker({ collection: this.collName, id: oldKey }, oldKeyNextVersion, this.keyring.userId));
299
302
  } else {
300
303
  await this.adapter.delete(this.compartmentName, this.collName, oldKey);
301
304
  }
@@ -353,7 +356,7 @@ var LookupHandle = class {
353
356
  this._syncCache.delete(key);
354
357
  continue;
355
358
  }
356
- const entry = await this.decryptEntry(envelope);
359
+ const entry = await this.decryptEntry(key, envelope);
357
360
  entries.push(entry);
358
361
  this._syncCache.set(key, entry);
359
362
  }
@@ -389,4 +392,4 @@ export {
389
392
  dictCollectionName,
390
393
  LookupHandle
391
394
  };
392
- //# sourceMappingURL=chunk-WFUIE565.js.map
395
+ //# sourceMappingURL=chunk-57JTHWLQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/via/lookup/handle.ts"],"sourcesContent":["/**\n * `_dict_*` reserved-collection storage engine — `LookupHandle`.\n *\n * Verbatim move of `DictionaryHandle` out of `via/i18n/dictionary.ts`\n * (#650 Task 1 — via-lookup extraction, phase D). The class is renamed to\n * `LookupHandle` (the dict tier is one backing kind the eventual lookup\n * layer supports); `via/i18n/dictionary.ts` re-exports it as\n * `DictionaryHandle` for one release so existing importers compile\n * unchanged. `DictEntry` / `DictionaryOptions` / `DICT_COLLECTION_PREFIX` /\n * `dictCollectionName` move with it — they were exclusively consumed by\n * this class's constructor/methods.\n *\n * No behavior change from the pre-move class: same encryption door\n * (`reservedEnvelopes('_dict_')`, #629 Task 4), same ACL, same ledger\n * shape, same sync-cache/snapshot contract for dict joins.\n */\n\nimport type { NoydbStore, EncryptedEnvelope } from '../../kernel/types.js'\nimport type { NoydbEventEmitter } from '../../kernel/events.js'\nimport { NOYDB_FORMAT_VERSION } from '../../kernel/types.js'\nimport type { UnlockedKeyring } from '../../with-party/team/keyring.js'\nimport type { ViaCryptoCtx } from '../../kernel/via/index.js'\nimport type { LedgerStore } from '../../with-commit/history/ledger/store.js'\nimport { envelopePayloadHash } from '../../with-commit/history/ledger/hash.js'\nimport {\n PermissionDeniedError,\n DictKeyMissingError,\n} from '../../kernel/errors.js'\n\n/**\n * Delete-marker predicate, duplicated (not imported) from\n * `kernel/enclave/record-keys/tombstone.ts`'s `isDeleteMarker` (#647 fix wave 1).\n * `via/lookup/**` may not statically import `kernel/enclave/` — not even the barrel\n * (Check 15, `via-enclave-isolation`) — and this predicate carries zero crypto/protected-body\n * surface (just the `_del` protocol-header field, not `_iv`/`_data`), so duplicating it here\n * mirrors the same call `port/with/i18n-strategy.ts` already makes for `isDictCollectionName`\n * (see its doc comment). Keep the two in sync if the marker shape ever changes.\n *\n * `buildDeleteMarker` (which DOES construct the protected `_iv`/`_data` body fields — Check 11,\n * `enclave-body-only`) can't be duplicated the same way; it's injected via the constructor\n * instead, built from the real `kernel/enclave` function at the Vault call site.\n */\nfunction isDeleteMarker(envelope: EncryptedEnvelope): boolean {\n return envelope._del === true\n}\n\n/** Reserved collection name prefix. Never collides with user collections. */\nexport const DICT_COLLECTION_PREFIX = '_dict_'\n\n/** Return the adapter collection name for a named dictionary. */\nexport function dictCollectionName(dictionaryName: string): string {\n return `${DICT_COLLECTION_PREFIX}${dictionaryName}`\n}\n\n// ─── Dictionary entry shape ────────────────────────────────────────────\n\n/**\n * One entry in a `_dict_*` collection. The record `id` (adapter-side\n * key) IS the stable dictionary key (e.g. `'paid'`). The `labels`\n * record maps locale codes to display strings.\n */\nexport interface DictEntry {\n /** Stable key — same as the record id in the adapter. */\n readonly key: string\n /** Locale → label map, e.g. `{ en: 'Paid', th: 'ชำระแล้ว' }`. */\n readonly labels: Record<string, string>\n}\n\n// ─── Per-dictionary options ────────────────────────────────────────────\n\n/**\n * Options for `vault.dictionary(name, options?)`.\n *\n * `writableBy` controls the minimum role for write operations (put,\n * putAll, delete, rename). Defaults to `'admin'` to match the standard\n * \"dictionary contents are owned by admins\" convention; set to\n * `'operator'` for user-editable dictionaries like custom tags.\n */\nexport interface DictionaryOptions {\n /** Minimum role allowed to write dictionary entries. Default: `'admin'`. */\n readonly writableBy?: 'owner' | 'admin' | 'operator'\n}\n\n// ─── LookupHandle ───────────────────────────────────────────────────────\n\n/**\n * Handle to a named dictionary within a vault.\n *\n * Obtained via `vault.dictionary(name)`. Provides strongly-typed\n * CRUD for dictionary entries, plus the `rename()` operation that is the\n * only sanctioned mass-mutation path for dictKey fields.\n *\n * All writes are encrypted under the compartment's DEK for the\n * `_dict_<name>` collection. Adapters never see plaintext.\n */\nexport class LookupHandle<Keys extends string = string> {\n private readonly collName: string\n\n /**\n * Synchronous write-through cache for dict-join support.\n * Populated on every `put()`, `delete()`, and `rename()`. The snapshot\n * is built from this cache by `snapshotEntries()` — the query executor\n * calls this synchronously inside `.toArray()`.\n *\n * `null` means \"not yet initialized\" — callers should use `list()`\n * to warm the cache before using dict joins on pre-existing data.\n */\n private readonly _syncCache = new Map<string, DictEntry>()\n\n /**\n * Return all cached entries as `{ key, labels, ...labels }` records —\n * usable synchronously by the join executor's `snapshot()` call.\n * Returns an empty array when the cache has never been populated.\n */\n snapshotEntries(): readonly Record<string, unknown>[] {\n return Array.from(this._syncCache.values()).map((e) => ({\n key: e.key,\n labels: e.labels,\n ...e.labels,\n }))\n }\n\n constructor(\n private readonly adapter: NoydbStore,\n private readonly compartmentName: string,\n private readonly dictionaryName: string,\n private readonly keyring: UnlockedKeyring,\n /**\n * The `reservedEnvelopes('_dict_')` capability — this handle's sanctioned\n * crypto door onto its `_dict_<name>` collection (#629 Task 4). Bound by\n * the Vault; never a keyring, raw DEK, or enclave import.\n */\n private readonly reservedEnvelopes: ReturnType<ViaCryptoCtx['reservedEnvelopes']>,\n private readonly encrypted: boolean,\n private readonly ledger: LedgerStore | undefined,\n private readonly options: DictionaryOptions,\n /**\n * Callback provided by the Vault to find and rewrite records\n * in any registered collection that has a dictKeyField pointing at\n * this dictionary, used by `rename()`.\n */\n private readonly findAndUpdateReferences:\n | ((\n dictionaryName: string,\n oldKey: string,\n newKey: string,\n ) => Promise<void>)\n | undefined,\n private readonly emitter: NoydbEventEmitter,\n /**\n * #647 fix wave 1 — mints a version-ordered delete-marker envelope (the reserved-tier\n * mirror of #589's ordinary-collection delete marker). Injected rather than imported:\n * `buildDeleteMarker` constructs the envelope's protected-body fields (`_iv`/`_data`), and\n * `via/lookup/**` may not reach `kernel/enclave/` directly (Check 11\n * `enclave-body-only` / Check 15 `via-enclave-isolation`) — the Vault binds the real\n * `kernel/enclave` function at construction time, same pattern as `reservedEnvelopes` above.\n */\n private readonly buildDeleteMarker: (identity: { collection: string; id: string }, version: number, actor: string) => EncryptedEnvelope,\n /** #650 Task 4 (#647) — dirty-log participation hook (origin `local-write`), threaded from `BuildLookupHandleOptions`. */\n private readonly onDirty?: (collection: string, id: string, action: 'put' | 'delete', version: number) => Promise<void>,\n /** #650 Task 4 — thin `graphDispatch.collect`-equivalent; opens/collects/flushes a one-shot wave for this touch. */\n private readonly onRecordMutated?: (collection: string, id: string, action: 'put' | 'delete', version: number) => Promise<void>,\n /** #650 Task 5 (#648) — the real reference check `delete()`'s strict branch calls: restrict\n * throws `DictKeyInUseError`, cascade/nullify apply their propagation. Vault-bound; a no-op\n * when the dimension has no declared lookup-referencing edges. */\n private readonly checkReferencesOnDelete?: (key: string) => Promise<unknown>,\n ) {\n this.collName = dictCollectionName(dictionaryName)\n }\n\n // ─── Access checks ────────────────────────────────────────────────\n\n private requireWriteAccess(): void {\n const minRole = this.options.writableBy ?? 'admin'\n const roleRank: Record<string, number> = {\n client: 1,\n viewer: 2,\n operator: 3,\n admin: 4,\n owner: 5,\n }\n const callerRank = roleRank[this.keyring.role] ?? 0\n const requiredRank = roleRank[minRole] ?? 4\n if (callerRank < requiredRank) {\n throw new PermissionDeniedError(\n `Dictionary \"${this.dictionaryName}\" writes require \"${minRole}\" role or above. ` +\n `Current role: \"${this.keyring.role}\".`,\n )\n }\n }\n\n // ─── Internal helpers ─────────────────────────────────────────────\n\n private async encryptEntry(entry: DictEntry, version: number): Promise<EncryptedEnvelope> {\n if (!this.encrypted) {\n // Plaintext/debug vault: no AEAD, therefore no AAD to bind — this literal\n // has nothing `buildRecordEnvelope` could authenticate, and `via/lookup/**`\n // may not import `kernel/enclave/` to reach it anyway (Check 15,\n // `via-enclave-isolation`). The ENCRYPTED branch below is the one that\n // matters, and it is bound: `reservedEnvelopes.encrypt` holds the DEK, so\n // it is where identity AAD is applied (#1051).\n return {\n _noydb: NOYDB_FORMAT_VERSION,\n _v: version,\n _ts: new Date().toISOString(),\n _iv: '',\n _data: JSON.stringify(entry),\n _by: this.keyring.userId,\n }\n }\n // `entry.key` IS the record id this envelope is stored under. `_by` goes\n // IN, not on afterwards: stamping it on the returned envelope would leave\n // it outside the AAD the door just sealed (#1041).\n return this.reservedEnvelopes.encrypt(\n { collection: this.collName, id: entry.key, by: this.keyring.userId },\n JSON.stringify(entry),\n version,\n )\n }\n\n private async decryptEntry(key: string, envelope: EncryptedEnvelope): Promise<DictEntry> {\n if (!this.encrypted) {\n return JSON.parse(envelope._data) as DictEntry\n }\n // `key` IS the record id this envelope is stored under, and the identity the\n // writer sealed it against (#1041).\n const json = await this.reservedEnvelopes.decrypt(this.collName, key, envelope)\n return JSON.parse(json) as DictEntry\n }\n\n /** @internal #650 Task 4 — re-read `key`'s CURRENT adapter truth into `_syncCache` (delete the\n * cache entry when the key is now gone). Called by `Vault._invalidateSyncApplied` after a\n * reserved-lookup row applies via sync, so an already-warmed snapshot/membership/altIndex read\n * never sees a stale verdict for a pulled vocabulary edit — the same invalidation a local\n * put()/delete()/rename() already triggers via `_syncCache.set`/`delete` above. */\n async _refreshSyncCache(key: string): Promise<void> {\n const envelope = await this.adapter.get(this.compartmentName, this.collName, key)\n if (!envelope || isDeleteMarker(envelope)) { this._syncCache.delete(key); return }\n this._syncCache.set(key, await this.decryptEntry(key, envelope))\n }\n\n // ─── Public API ───────────────────────────────────────────────────\n\n /**\n * Add or overwrite a single dictionary entry.\n *\n * @param key The stable key to store (e.g. `'paid'`).\n * @param labels Locale → label map (e.g. `{ en: 'Paid', th: 'ชำระแล้ว' }`).\n */\n async put(key: Keys, labels: Record<string, string>): Promise<void> {\n this.requireWriteAccess()\n\n const entry: DictEntry = { key, labels }\n const existing = await this.adapter.get(\n this.compartmentName,\n this.collName,\n key,\n )\n const version = existing ? existing._v + 1 : 1\n const envelope = await this.encryptEntry(entry, version)\n\n await this.adapter.put(\n this.compartmentName,\n this.collName,\n key,\n envelope,\n existing ? existing._v : undefined,\n )\n\n // Maintain synchronous cache for dict-join snapshot\n this._syncCache.set(key, entry)\n\n // #650 Task 4 (#647) — choke-point participation: dirty-log tracking BEFORE the emit (mirrors\n // Collection._onRecordMutated's local-write order), then the wave-open hook AFTER.\n await this.onDirty?.(this.collName, key, 'put', version)\n\n this.emitter.emit('change', {\n vault: this.compartmentName,\n collection: this.collName,\n id: key,\n action: 'put',\n })\n\n await this.onRecordMutated?.(this.collName, key, 'put', version)\n\n if (this.ledger) {\n await this.ledger.append({\n op: 'put',\n collection: this.collName,\n id: key,\n version,\n actor: this.keyring.userId,\n // — must be the real envelope hash so\n // vault.verifyBackupIntegrity()'s data-cross-check matches.\n payloadHash: await envelopePayloadHash(envelope),\n })\n }\n }\n\n /**\n * Batch-add or overwrite multiple dictionary entries in one call.\n *\n * @param entries `{ key: { locale: label } }` map.\n */\n async putAll(entries: Record<Keys, Record<string, string>>): Promise<void> {\n this.requireWriteAccess()\n for (const [key, labels] of Object.entries(entries) as [Keys, Record<string, string>][]) {\n await this.put(key, labels)\n }\n }\n\n /**\n * Load the label map for a single key.\n *\n * @returns The label map, or `null` if the key doesn't exist.\n */\n async get(key: Keys): Promise<Record<string, string> | null> {\n const envelope = await this.adapter.get(\n this.compartmentName,\n this.collName,\n key,\n )\n if (!envelope || isDeleteMarker(envelope)) return null\n const entry = await this.decryptEntry(key, envelope)\n return entry.labels\n }\n\n /**\n * Delete a dictionary key.\n *\n * Default mode is `'strict'` — throws `DictKeyInUseError` if any\n * registered collection has a record referencing this key. Pass\n * `{ mode: 'warn' }` to skip the check (dev-mode cleanup only).\n *\n * Under sync, deletion writes a version-ordered delete-marker row rather than removing the\n * adapter key outright (#647 fix wave 1) — markers accumulate over time; GC is future work,\n * acceptable for vocabulary-scale data.\n */\n async delete(key: Keys, opts: { mode?: 'strict' | 'warn' } = {}): Promise<void> {\n this.requireWriteAccess()\n\n const existing = await this.adapter.get(\n this.compartmentName,\n this.collName,\n key,\n )\n if (!existing || isDeleteMarker(existing)) {\n throw new DictKeyMissingError(this.dictionaryName, key)\n }\n\n // #650 Task 5 (#648) — the real reference check: restrict throws `DictKeyInUseError` naming\n // the referencing collection, cascade/nullify apply their propagation. `mode: 'warn'` skips\n // this entirely (today's dev-mode-cleanup escape hatch, unconditional delete). A dimension\n // with no declared lookup-referencing edges is a no-op (undeclared refs keep dangling).\n const mode = opts.mode ?? 'strict'\n if (mode === 'strict') {\n await this.checkReferencesOnDelete?.(key)\n }\n\n // #647 fix wave 1 — mirrors Collection._doDelete's identical `this.onDirty`-gated branch\n // (#589): under sync, a raw adapter.delete() is invisible to a peer's next pull (the key\n // simply stops appearing in remote.list()) — a deleted key never propagates and can be\n // silently resurrected by a later edit. Write a version-ordered DELETE-MARKER instead, so\n // the removal round-trips like any other row. No-op (plain adapter.delete) when sync isn't wired.\n const nextVersion = existing._v + 1\n if (this.onDirty) {\n await this.adapter.put(this.compartmentName, this.collName, key, this.buildDeleteMarker({ collection: this.collName, id: key }, nextVersion, this.keyring.userId))\n } else {\n await this.adapter.delete(this.compartmentName, this.collName, key)\n }\n\n // Maintain synchronous cache for dict-join snapshot\n this._syncCache.delete(key)\n\n // #650 Task 4 (#647) — same choke-point ordering as put() above.\n // #647 fix wave 1: the dirty entry's ACTION is 'put' (not 'delete') — mirrors\n // Collection._onRecordMutated's 'local-delete' case exactly: the marker rides push's\n // CAS-put path, not push's raw remote.delete() path (which would strip the marker off the\n // remote too and reopen this same hole). The version is the MARKER's version, so push's CAS\n // (expectedVersion = entry.version - 1) matches the pre-delete remote copy.\n await this.onDirty?.(this.collName, key, 'put', nextVersion)\n\n this.emitter.emit('change', {\n vault: this.compartmentName,\n collection: this.collName,\n id: key,\n action: 'delete',\n })\n\n await this.onRecordMutated?.(this.collName, key, 'delete', nextVersion)\n\n if (this.ledger) {\n await this.ledger.append({\n op: 'delete',\n collection: this.collName,\n id: key,\n version: existing._v,\n actor: this.keyring.userId,\n // — for delete the prior envelope is what was just\n // removed; we hash it so the chain captures intent. The\n // verifyBackupIntegrity data-cross-check skips delete\n // entries entirely (the live record is gone), but the\n // chain still benefits from a stable non-empty hash.\n payloadHash: await envelopePayloadHash(existing),\n })\n }\n }\n\n /**\n * Rename a dictionary key — the only sanctioned mass-mutation path.\n *\n * Atomically:\n * 1. Adds the new key with the same labels as the old key.\n * 2. Updates every registered record that stores the old key to\n * store the new key instead.\n * 3. Deletes the old key.\n * 4. Appends a single ledger entry recording the rename.\n *\n * Respects ACL: throws `PermissionDeniedError` before any mutation\n * if the caller can't write. The cascade is best-effort atomic\n * within this call — no two-phase commit across adapter calls.\n *\n * Cascade-on-delete is NOT supported. Use `rename()` when you need\n * to change a key that records reference.\n */\n async rename(oldKey: Keys, newKey: string): Promise<void> {\n this.requireWriteAccess()\n\n // 1. Load old entry\n const existing = await this.adapter.get(\n this.compartmentName,\n this.collName,\n oldKey,\n )\n if (!existing || isDeleteMarker(existing)) {\n throw new DictKeyMissingError(this.dictionaryName, oldKey)\n }\n const oldEntry = await this.decryptEntry(oldKey, existing)\n\n // 2. Write new key\n const newEntry: DictEntry = { key: newKey, labels: oldEntry.labels }\n const newEnvelope = await this.encryptEntry(newEntry, 1)\n await this.adapter.put(\n this.compartmentName,\n this.collName,\n newKey,\n newEnvelope,\n )\n\n // #670 — publish newKey to the sync cache BEFORE step 3 rewrites referencing records: a\n // vocabulary:'closed' referencing field's enforceWrite reads checkLookupMembership ->\n // snapshotEntries() -> this._syncCache, so if newKey isn't a member yet, step 3's own write of\n // newKey into those records self-refuses with UnknownLookupKeyError. Transition semantics:\n // mid-rename BOTH oldKey and newKey are legitimately members (records are transitioning\n // old->new during the rewrite) — oldKey stays a member until its removal completes below.\n this._syncCache.set(newKey, newEntry)\n\n // 3. Update all referencing records in registered collections\n if (this.findAndUpdateReferences) {\n await this.findAndUpdateReferences(this.dictionaryName, oldKey, newKey)\n }\n\n // 4. Remove old key — #647 fix wave 1: same delete-marker convention as delete() above, so\n // the old key's removal propagates on sync instead of leaving a phantom stale row on a peer\n // that only observes the new key arriving.\n const oldKeyNextVersion = existing._v + 1\n if (this.onDirty) {\n await this.adapter.put(this.compartmentName, this.collName, oldKey, this.buildDeleteMarker({ collection: this.collName, id: oldKey }, oldKeyNextVersion, this.keyring.userId))\n } else {\n await this.adapter.delete(this.compartmentName, this.collName, oldKey)\n }\n\n // Maintain synchronous cache for dict-join snapshot — oldKey's removal from the cache lands\n // here (after step 3), completing the old->new membership transition begun above.\n this._syncCache.delete(oldKey)\n\n // #650 Task 4 (#647) — same choke-point ordering as put()/delete() above, for BOTH touches.\n // #647 fix wave 1: oldKey's dirty action is 'put' (not 'delete') — see delete()'s comment\n // above for why the marker must ride push's CAS-put path, at the marker's version.\n await this.onDirty?.(this.collName, oldKey, 'put', oldKeyNextVersion)\n this.emitter.emit('change', {\n vault: this.compartmentName,\n collection: this.collName,\n id: oldKey,\n action: 'delete',\n })\n await this.onRecordMutated?.(this.collName, oldKey, 'delete', oldKeyNextVersion)\n\n await this.onDirty?.(this.collName, newKey, 'put', 1)\n this.emitter.emit('change', {\n vault: this.compartmentName,\n collection: this.collName,\n id: newKey,\n action: 'put',\n })\n await this.onRecordMutated?.(this.collName, newKey, 'put', 1)\n\n // 5. Ledger — record the rename as delete(oldKey) + put(newKey)\n // so verifyBackupIntegrity()'s data-cross-check matches reality\n // (the oldKey envelope is gone; the newKey envelope is what was\n // just written). Two entries instead of one — the chain still\n // captures the rename intent via the matching ts + actor.\n if (this.ledger) {\n await this.ledger.append({\n op: 'delete',\n collection: this.collName,\n id: oldKey,\n version: existing._v,\n actor: this.keyring.userId,\n payloadHash: await envelopePayloadHash(existing),\n })\n await this.ledger.append({\n op: 'put',\n collection: this.collName,\n id: newKey,\n version: 1,\n actor: this.keyring.userId,\n payloadHash: await envelopePayloadHash(newEnvelope),\n })\n }\n }\n\n /**\n * List all entries in this dictionary.\n *\n * @returns Array of `{ key, labels }` objects.\n */\n async list(): Promise<DictEntry[]> {\n const keys = await this.adapter.list(this.compartmentName, this.collName)\n const entries: DictEntry[] = []\n for (const key of keys) {\n const envelope = await this.adapter.get(\n this.compartmentName,\n this.collName,\n key,\n )\n // #647 fix wave 1 — a delete-marker row is a removed key, not a live entry: exclude it\n // from the listing and drop any stale cache entry a prior warm may have left under it.\n if (!envelope || isDeleteMarker(envelope)) { this._syncCache.delete(key); continue }\n const entry = await this.decryptEntry(key, envelope)\n entries.push(entry)\n // Warm the synchronous cache\n this._syncCache.set(key, entry)\n }\n return entries\n }\n\n /**\n * Resolve a key to its label for the given locale.\n *\n * Used by the collection's locale-aware read path to populate\n * `<field>Label` virtual fields. Returns `undefined` when the\n * key doesn't exist or has no label for the requested locale\n * (after exhausting the fallback chain).\n */\n async resolveLabel(\n key: string,\n locale: string,\n fallback?: string | readonly string[],\n ): Promise<string | undefined> {\n const labels = await this.get(key as Keys)\n if (!labels) return undefined\n\n // Try primary locale\n if (labels[locale] !== undefined) return labels[locale]\n\n // Try fallback chain\n const chain = Array.isArray(fallback) ? (fallback as readonly string[]) : fallback ? [fallback as string] : []\n for (const fb of chain) {\n if (fb === 'any') {\n // Return any available label\n const any = Object.values(labels)[0]\n if (any !== undefined) return any\n } else if (labels[fb] !== undefined) {\n return labels[fb]\n }\n }\n\n return undefined\n }\n}\n\n// Compat alias — existing importers of `DictionaryHandle` (the pre-#650\n// name) keep compiling unchanged. `via/i18n/dictionary.ts` re-exports\n// this same binding for one release.\nexport { LookupHandle as Dictionary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,CAAC,YAAY,eAAe,QAAQ,GAAG;AAAE,aAAK,WAAW,OAAO,GAAG;AAAG;AAAA,MAAS;AACnF,YAAM,QAAQ,MAAM,KAAK,aAAa,KAAK,QAAQ;AACnD,cAAQ,KAAK,KAAK;AAElB,WAAK,WAAW,IAAI,KAAK,KAAK;AAAA,IAChC;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,aACJ,KACA,QACA,UAC6B;AAC7B,UAAM,SAAS,MAAM,KAAK,IAAI,GAAW;AACzC,QAAI,CAAC,OAAQ,QAAO;AAGpB,QAAI,OAAO,MAAM,MAAM,OAAW,QAAO,OAAO,MAAM;AAGtD,UAAM,QAAQ,MAAM,QAAQ,QAAQ,IAAK,WAAiC,WAAW,CAAC,QAAkB,IAAI,CAAC;AAC7G,eAAW,MAAM,OAAO;AACtB,UAAI,OAAO,OAAO;AAEhB,cAAM,MAAM,OAAO,OAAO,MAAM,EAAE,CAAC;AACnC,YAAI,QAAQ,OAAW,QAAO;AAAA,MAChC,WAAW,OAAO,EAAE,MAAM,QAAW;AACnC,eAAO,OAAO,EAAE;AAAA,MAClB;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -2,7 +2,7 @@ import {
2
2
  OverlayBaseIsVirtualError,
3
3
  OverlayCollectionUnavailableError,
4
4
  OverlayNameCollisionError
5
- } from "./chunk-HNGSV2YC.js";
5
+ } from "./chunk-JBIV4FLR.js";
6
6
 
7
7
  // src/with-formula/overlay-views/registry.ts
8
8
  var OverlayedViewRegistry = class {
@@ -68,4 +68,4 @@ var OverlayedViewRegistry = class {
68
68
  export {
69
69
  OverlayedViewRegistry
70
70
  };
71
- //# sourceMappingURL=chunk-FNSMZQS4.js.map
71
+ //# sourceMappingURL=chunk-5ACAVJUI.js.map
@@ -1,19 +1,20 @@
1
1
  import {
2
2
  linkCollectionName,
3
3
  linkRowKey
4
- } from "./chunk-HNHCQ556.js";
4
+ } from "./chunk-WLLUM35R.js";
5
5
  import {
6
+ buildRecordAad,
6
7
  openEnvelopeJson
7
- } from "./chunk-3URQC7EH.js";
8
+ } from "./chunk-2LPVI4PX.js";
8
9
  import {
9
- encrypt
10
- } from "./chunk-VCETL77O.js";
10
+ buildRecordEnvelope
11
+ } from "./chunk-N4CNVSUF.js";
11
12
  import {
12
- NOYDB_FORMAT_VERSION
13
- } from "./chunk-YPYHVOXP.js";
13
+ encrypt
14
+ } from "./chunk-W5LHQXZU.js";
14
15
  import {
15
16
  NoydbError
16
- } from "./chunk-HNGSV2YC.js";
17
+ } from "./chunk-JBIV4FLR.js";
17
18
 
18
19
  // src/with-shape/links/link-set.ts
19
20
  var LinkSet = class {
@@ -44,15 +45,17 @@ var LinkSet = class {
44
45
  if (!this.dekPromise) this.dekPromise = this.getDEK(this.collName);
45
46
  return this.dekPromise;
46
47
  }
47
- async encryptEntry(entry, version) {
48
+ async encryptEntry(entry, version, key) {
48
49
  const json = JSON.stringify(entry);
49
- const base = { _noydb: NOYDB_FORMAT_VERSION, _v: version, _ts: (/* @__PURE__ */ new Date()).toISOString(), _by: this.actor };
50
- if (!this.encrypted) return { ...base, _iv: "", _data: json };
51
- const { iv, data } = await encrypt(json, await this.dek());
52
- return { ...base, _iv: iv, _data: data };
50
+ const identity = { collection: this.collName, id: key, by: this.actor, version };
51
+ if (!this.encrypted) {
52
+ return buildRecordEnvelope(identity, { iv: "", data: json });
53
+ }
54
+ const { iv, data } = await encrypt(json, await this.dek(), buildRecordAad(identity));
55
+ return buildRecordEnvelope(identity, { iv, data });
53
56
  }
54
- async decryptEntry(env) {
55
- const json = this.encrypted ? await openEnvelopeJson(env, await this.dek()) : env._data;
57
+ async decryptEntry(key, env) {
58
+ const json = this.encrypted ? await openEnvelopeJson({ collection: this.collName, id: key }, env, await this.dek()) : env._data;
56
59
  return JSON.parse(json);
57
60
  }
58
61
  async connect(aId, bId, meta) {
@@ -65,7 +68,7 @@ var LinkSet = class {
65
68
  const key = linkRowKey(aId, bId);
66
69
  const entry = meta !== void 0 ? { a: aId, b: bId, meta } : { a: aId, b: bId };
67
70
  const existing = await this.adapter.get(this.vault, this.collName, key);
68
- const env = await this.encryptEntry(entry, (existing?._v ?? 0) + 1);
71
+ const env = await this.encryptEntry(entry, (existing?._v ?? 0) + 1, key);
69
72
  await this.adapter.put(this.vault, this.collName, key, env, existing?._v);
70
73
  this.emitter.emit("change", { vault: this.vault, collection: this.collName, id: key, action: "put" });
71
74
  }
@@ -89,7 +92,7 @@ var LinkSet = class {
89
92
  for (const key of keys) {
90
93
  const env = await this.adapter.get(this.vault, this.collName, key);
91
94
  if (!env) continue;
92
- const e = await this.decryptEntry(env);
95
+ const e = await this.decryptEntry(key, env);
93
96
  out.push(e.meta !== void 0 ? { a: e.a, b: e.b, meta: e.meta } : { a: e.a, b: e.b });
94
97
  }
95
98
  return out;
@@ -127,4 +130,4 @@ export {
127
130
  LinkSet,
128
131
  LinkEndpointError
129
132
  };
130
- //# sourceMappingURL=chunk-PDLLCOGD.js.map
133
+ //# sourceMappingURL=chunk-5AFMP532.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/with-shape/links/link-set.ts"],"sourcesContent":["/**\n * `_links_*` reserved collections — managed bidirectional many-to-many\n * junctions (design B).\n *\n * Where `refArray` (design A) stores an id-array on one owning record,\n * `vault.link()` creates a first-class junction: a dedicated encrypted\n * `_links_<name>` collection whose rows are `{ a, b, meta? }` link tuples.\n * It is queryable from BOTH sides (`of(id)`), carries optional per-link\n * metadata, and cascades on endpoint delete.\n *\n * Each link is slot-typed: `a` is an id in the `a` endpoint collection,\n * `b` an id in the `b` endpoint collection (they may be the same\n * collection for self-links). A link's identity is the ordered pair\n * `(a, b)`; `of(id)` matches either slot.\n *\n * Rows are encrypted under a dedicated `_links_<name>` DEK — same\n * zero-knowledge stack as every other collection (the store sees only\n * ciphertext). Backup/restore rides the normal `loadAll` path.\n */\n\nimport type { NoydbStore, EncryptedEnvelope } from '../../kernel/types.js'\nimport type { NoydbEventEmitter } from '../../kernel/events.js'\nimport { buildRecordAad, buildRecordEnvelope, encrypt, openEnvelopeJson, type EnclaveKey } from '../../kernel/enclave/index.js'\nimport { NoydbError } from '../../kernel/errors.js'\n\n// Naming helpers, declaration types, and LinkIntegrityError live in\n// `names.ts` (the always-loadable slice — #553); re-exported here so\n// existing import paths and the root barrel are unchanged.\nexport {\n LINK_COLLECTION_PREFIX,\n linkCollectionName,\n isLinkCollectionName,\n linkRowKey,\n LinkIntegrityError,\n} from './names.js'\nexport type { LinkOnDelete, LinkSpec, LinkRow, LinkSetHandle } from './names.js'\nimport { linkCollectionName, linkRowKey } from './names.js'\nimport type { LinkSpec, LinkRow, LinkSetHandle } from './names.js'\n\n/** Stored form (also the row key derivation source). */\ninterface LinkEntry {\n a: string\n b: string\n meta?: Record<string, unknown>\n}\n\n/**\n * @internal — the concrete handle. The Vault owns construction (one per\n * link name) and the cascade hooks; consumers use the {@link LinkSetHandle}\n * surface via `vault.links(name)`.\n */\nexport class LinkSet implements LinkSetHandle {\n private readonly collName: string\n private dekPromise: Promise<EnclaveKey> | null = null\n\n constructor(\n private readonly adapter: NoydbStore,\n private readonly vault: string,\n private readonly name: string,\n private readonly spec: LinkSpec,\n private readonly encrypted: boolean,\n private readonly getDEK: (collectionName: string) => Promise<EnclaveKey>,\n private readonly actor: string,\n private readonly emitter: NoydbEventEmitter,\n /** Vault-provided existence check for endpoint validation on connect(). */\n private readonly endpointExists: (collection: string, id: string) => Promise<boolean>,\n ) {\n this.collName = linkCollectionName(name)\n }\n\n private dek(): Promise<EnclaveKey> {\n if (!this.dekPromise) this.dekPromise = this.getDEK(this.collName)\n return this.dekPromise\n }\n\n private async encryptEntry(entry: LinkEntry, version: number, key: string): Promise<EncryptedEnvelope> {\n const json = JSON.stringify(entry)\n const identity = { collection: this.collName, id: key, by: this.actor, version }\n if (!this.encrypted) {\n return buildRecordEnvelope(identity, { iv: '', data: json})\n }\n const { iv, data } = await encrypt(json, await this.dek(), buildRecordAad(identity))\n return buildRecordEnvelope(identity, { iv, data})\n }\n\n private async decryptEntry(key: string, env: EncryptedEnvelope): Promise<LinkEntry> {\n const json = this.encrypted ? await openEnvelopeJson({ collection: this.collName, id: key }, env, await this.dek()) : env._data\n return JSON.parse(json) as LinkEntry\n }\n\n async connect(aId: string, bId: string, meta?: Record<string, unknown>): Promise<void> {\n if (!(await this.endpointExists(this.spec.a, aId))) {\n throw new LinkEndpointError(this.name, this.spec.a, aId)\n }\n if (!(await this.endpointExists(this.spec.b, bId))) {\n throw new LinkEndpointError(this.name, this.spec.b, bId)\n }\n const key = linkRowKey(aId, bId)\n const entry: LinkEntry = meta !== undefined ? { a: aId, b: bId, meta } : { a: aId, b: bId }\n const existing = await this.adapter.get(this.vault, this.collName, key)\n const env = await this.encryptEntry(entry, (existing?._v ?? 0) + 1, key)\n await this.adapter.put(this.vault, this.collName, key, env, existing?._v)\n this.emitter.emit('change', { vault: this.vault, collection: this.collName, id: key, action: 'put' })\n }\n\n async disconnect(aId: string, bId: string): Promise<void> {\n const key = linkRowKey(aId, bId)\n const existing = await this.adapter.get(this.vault, this.collName, key)\n if (!existing) return\n await this.adapter.delete(this.vault, this.collName, key)\n this.emitter.emit('change', { vault: this.vault, collection: this.collName, id: key, action: 'delete' })\n }\n\n async has(aId: string, bId: string): Promise<boolean> {\n return (await this.adapter.get(this.vault, this.collName, linkRowKey(aId, bId))) !== null\n }\n\n async of(id: string): Promise<LinkRow[]> {\n const rows = await this.list()\n return rows.filter((r) => r.a === id || r.b === id)\n }\n\n async list(): Promise<LinkRow[]> {\n const keys = await this.adapter.list(this.vault, this.collName)\n const out: LinkRow[] = []\n for (const key of keys) {\n const env = await this.adapter.get(this.vault, this.collName, key)\n if (!env) continue\n const e = await this.decryptEntry(key, env)\n out.push(e.meta !== undefined ? { a: e.a, b: e.b, meta: e.meta } : { a: e.a, b: e.b })\n }\n return out\n }\n\n // ── Vault-internal cascade helpers ──────────────────────────────────\n\n /** @internal — rows where the deleted endpoint id matches the relevant slot. */\n async _rowsTouchingEndpoint(collection: string, id: string): Promise<LinkRow[]> {\n const rows = await this.list()\n return rows.filter(\n (r) => (this.spec.a === collection && r.a === id) || (this.spec.b === collection && r.b === id),\n )\n }\n\n /** @internal — the storage collection name (for tx pre-image capture). */\n get _collectionName(): string {\n return this.collName\n }\n}\n\n/** Thrown by `connect()` when an endpoint record does not exist. */\nexport class LinkEndpointError extends NoydbError {\n readonly link: string\n readonly endpoint: string\n readonly missingId: string\n constructor(link: string, endpoint: string, missingId: string) {\n super(\n 'LINK_ENDPOINT',\n `link(\"${link}\").connect: endpoint \"${endpoint}\" has no record \"${missingId}\".`,\n )\n this.name = 'LinkEndpointError'\n this.link = link\n this.endpoint = endpoint\n this.missingId = missingId\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmDO,IAAM,UAAN,MAAuC;AAAA,EAI5C,YACmB,SACA,OACA,MACA,MACA,WACA,QACA,OACA,SAEA,gBACjB;AAViB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEjB,SAAK,WAAW,mBAAmB,IAAI;AAAA,EACzC;AAAA,EAZmB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAbF;AAAA,EACT,aAAyC;AAAA,EAiBzC,MAA2B;AACjC,QAAI,CAAC,KAAK,WAAY,MAAK,aAAa,KAAK,OAAO,KAAK,QAAQ;AACjE,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAc,aAAa,OAAkB,SAAiB,KAAyC;AACrG,UAAM,OAAO,KAAK,UAAU,KAAK;AACjC,UAAM,WAAW,EAAE,YAAY,KAAK,UAAU,IAAI,KAAK,IAAI,KAAK,OAAO,QAAQ;AAC/E,QAAI,CAAC,KAAK,WAAW;AACnB,aAAO,oBAAoB,UAAU,EAAE,IAAI,IAAI,MAAM,KAAI,CAAC;AAAA,IAC5D;AAC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