@noy-db/hub 0.8.0 → 0.9.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 (533) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +8 -8
  3. package/codemods/0.4.0-pre.json +1 -1
  4. package/codemods/0.8.0-pre.json +1 -1
  5. package/dist/api-MSJXVYQG.js +18 -0
  6. package/dist/as/index.js +33 -23
  7. package/dist/as/index.js.map +1 -1
  8. package/dist/at/index.js +8 -8
  9. package/dist/attestation/index.js +18 -18
  10. package/dist/{backup-YE2VQ26S.js → backup-7RKNZMQO.js} +11 -11
  11. package/dist/blobs/index.js +12 -12
  12. package/dist/broker/index.js +19 -11
  13. package/dist/broker/index.js.map +1 -1
  14. package/dist/by/index.js +2 -2
  15. package/dist/capsule/contract.d.ts +1 -1
  16. package/dist/capsule/contract.js +6 -6
  17. package/dist/capsule/enclave-aes/broker/proof.d.ts +12 -3
  18. package/dist/capsule/enclave-aes/index.d.ts +1 -1
  19. package/dist/capsule/enclave-aes/index.js +40 -14
  20. package/dist/capsule/enclave-aes/index.js.map +1 -1
  21. package/dist/capsule/index.d.ts +1 -1
  22. package/dist/capsule/plumbing/record-codec.d.ts +7 -0
  23. package/dist/{capsule-VOLX3QRQ.js → capsule-57BDK7LG.js} +8 -8
  24. package/dist/cargo/index.js +32 -32
  25. package/dist/{chunk-A4XMIZT3.js → chunk-226V6XXJ.js} +41 -6
  26. package/dist/chunk-226V6XXJ.js.map +1 -0
  27. package/dist/{chunk-LNSVGRHO.js → chunk-2A56DSRI.js} +2 -2
  28. package/dist/chunk-2DX4JCRI.js +1 -0
  29. package/dist/{chunk-SV2PM2OY.js → chunk-2ELOCEXE.js} +1 -1
  30. package/dist/chunk-2ELOCEXE.js.map +1 -0
  31. package/dist/{chunk-6QVKPHBF.js → chunk-2WJKJZSO.js} +2 -2
  32. package/dist/{chunk-TKVUE4JF.js → chunk-2ZFD2UJC.js} +9 -9
  33. package/dist/{chunk-2AFX33YA.js → chunk-3V6LZHUO.js} +3 -3
  34. package/dist/chunk-3V6LZHUO.js.map +1 -0
  35. package/dist/{chunk-4JPMZTJY.js → chunk-3Y5JLSXS.js} +2 -2
  36. package/dist/{chunk-XSPFDUDG.js → chunk-45VHWE4C.js} +51 -16
  37. package/dist/chunk-45VHWE4C.js.map +1 -0
  38. package/dist/{chunk-LGNDFRYC.js → chunk-4CFHL5RY.js} +1 -1
  39. package/dist/chunk-4CFHL5RY.js.map +1 -0
  40. package/dist/{chunk-EZGV6F47.js → chunk-4J3MNVVX.js} +1 -1
  41. package/dist/{chunk-EZGV6F47.js.map → chunk-4J3MNVVX.js.map} +1 -1
  42. package/dist/{chunk-O2IMQSNA.js → chunk-4UIP3QNW.js} +2 -2
  43. package/dist/{chunk-EJLV62NI.js → chunk-55P6OBB7.js} +2 -2
  44. package/dist/{chunk-Y3LPTBG7.js → chunk-5HNW4ZTA.js} +6 -9
  45. package/dist/chunk-5HNW4ZTA.js.map +1 -0
  46. package/dist/{chunk-TEHHROZL.js → chunk-5LMCVBMY.js} +5 -5
  47. package/dist/{chunk-4V3Q35WG.js → chunk-5UUJE4FP.js} +3 -3
  48. package/dist/{chunk-JWWYRR4Q.js → chunk-5XONHAFD.js} +2 -2
  49. package/dist/{chunk-PD64727P.js → chunk-6QLCS7ET.js} +2 -2
  50. package/dist/chunk-6QLCS7ET.js.map +1 -0
  51. package/dist/{chunk-QBLT6POL.js → chunk-6WS35E6X.js} +2 -2
  52. package/dist/{chunk-IUBMZPHM.js → chunk-6Y5E4SJU.js} +5 -6
  53. package/dist/chunk-6Y5E4SJU.js.map +1 -0
  54. package/dist/{chunk-GZT3NQRA.js → chunk-72XBVN4J.js} +8 -2
  55. package/dist/{chunk-GZT3NQRA.js.map → chunk-72XBVN4J.js.map} +1 -1
  56. package/dist/{chunk-EYG2CY2X.js → chunk-7BMOS4JQ.js} +11 -11
  57. package/dist/chunk-7BMOS4JQ.js.map +1 -0
  58. package/dist/{chunk-UA372JHH.js → chunk-7CT6SX4M.js} +3 -3
  59. package/dist/chunk-7CT6SX4M.js.map +1 -0
  60. package/dist/{chunk-EZOAKKTB.js → chunk-ABU6A4Z5.js} +2 -2
  61. package/dist/{chunk-VKI2EB3N.js → chunk-AJFPAHMW.js} +3 -3
  62. package/dist/{chunk-DQESF6RP.js → chunk-APFFJN5T.js} +29 -16
  63. package/dist/chunk-APFFJN5T.js.map +1 -0
  64. package/dist/{chunk-2ODVB6LZ.js → chunk-B65CC6Z6.js} +2 -2
  65. package/dist/{chunk-MBMTND6D.js → chunk-BJH77UY2.js} +2 -2
  66. package/dist/{chunk-VAORSCSU.js → chunk-BMHQHH7Q.js} +2 -2
  67. package/dist/chunk-BMHQHH7Q.js.map +1 -0
  68. package/dist/{chunk-FFJFE4T7.js → chunk-BNFNQNEP.js} +2 -2
  69. package/dist/chunk-BU2ABHFW.js +74 -0
  70. package/dist/chunk-BU2ABHFW.js.map +1 -0
  71. package/dist/{chunk-5WWDGFOS.js → chunk-BUE7R3B5.js} +2 -2
  72. package/dist/{chunk-5FE75J4S.js → chunk-BVF3SXD7.js} +5 -5
  73. package/dist/{chunk-VFHCKG5M.js → chunk-BYHCKX73.js} +3 -3
  74. package/dist/{chunk-BVCUTXE3.js → chunk-C53ER7AG.js} +2 -2
  75. package/dist/{chunk-MILI22XQ.js → chunk-CAD7N6HQ.js} +3 -3
  76. package/dist/{chunk-5KC7QYEC.js → chunk-CB4467G3.js} +5 -5
  77. package/dist/{chunk-JIBUPZHA.js → chunk-D4V5JJAK.js} +4 -4
  78. package/dist/{chunk-DLD5LGDS.js → chunk-D5A3GCZ4.js} +3 -3
  79. package/dist/{chunk-FOEDQATO.js → chunk-DHU2AQ6T.js} +2 -2
  80. package/dist/{chunk-VHBKYN2J.js → chunk-DL6BZKP3.js} +2 -2
  81. package/dist/{chunk-NBQ3KK6X.js → chunk-EA4VDI5D.js} +4 -4
  82. package/dist/chunk-EA4VDI5D.js.map +1 -0
  83. package/dist/{chunk-E2N2T5ZO.js → chunk-ECGXA4LT.js} +2 -2
  84. package/dist/{chunk-PP3K67AJ.js → chunk-EMAWOGVH.js} +3 -3
  85. package/dist/{chunk-WXE4W2U6.js → chunk-EUD3HQM4.js} +4 -4
  86. package/dist/{chunk-MXOQ5JCG.js → chunk-FSQNGPHH.js} +171 -124
  87. package/dist/chunk-FSQNGPHH.js.map +1 -0
  88. package/dist/{chunk-LIOVX5TJ.js → chunk-FZXRLNJO.js} +3 -3
  89. package/dist/{chunk-WPOYWFSE.js → chunk-G46JSSVX.js} +7 -7
  90. package/dist/{chunk-JSMTXZR3.js → chunk-G5EDYVSE.js} +8 -6
  91. package/dist/chunk-G5EDYVSE.js.map +1 -0
  92. package/dist/chunk-G66YXUTY.js +60 -0
  93. package/dist/chunk-G66YXUTY.js.map +1 -0
  94. package/dist/{chunk-FFWI7UH7.js → chunk-GAGT3YZN.js} +1 -1
  95. package/dist/chunk-GAGT3YZN.js.map +1 -0
  96. package/dist/{chunk-AEQGFRU4.js → chunk-GCUMOKTN.js} +3 -3
  97. package/dist/{chunk-244QBK7Z.js → chunk-GETUTTZU.js} +4 -4
  98. package/dist/{chunk-244QBK7Z.js.map → chunk-GETUTTZU.js.map} +1 -1
  99. package/dist/{chunk-V3RWOOSO.js → chunk-GOJQ5DZA.js} +4 -4
  100. package/dist/{chunk-UEFOQH74.js → chunk-GRS2HIV6.js} +2 -2
  101. package/dist/{chunk-3L2NBKDR.js → chunk-H3YM66EI.js} +2 -2
  102. package/dist/{chunk-3A5DUZ56.js → chunk-IVMFIKNA.js} +6 -6
  103. package/dist/{chunk-3A5DUZ56.js.map → chunk-IVMFIKNA.js.map} +1 -1
  104. package/dist/{chunk-747G6CT3.js → chunk-J4KAPKBJ.js} +2 -2
  105. package/dist/{chunk-H23XHRTT.js → chunk-JA25QG5M.js} +211 -6
  106. package/dist/chunk-JA25QG5M.js.map +1 -0
  107. package/dist/{chunk-T7IR4N2S.js → chunk-JBMMWYOH.js} +3 -1
  108. package/dist/{chunk-T7IR4N2S.js.map → chunk-JBMMWYOH.js.map} +1 -1
  109. package/dist/{chunk-MXKI4ABF.js → chunk-JPSL5GIZ.js} +3 -3
  110. package/dist/{chunk-2GHDLTPE.js → chunk-JSWKVZCR.js} +2 -2
  111. package/dist/{chunk-BNWA3WG5.js → chunk-JZ4EDEIP.js} +3 -3
  112. package/dist/{chunk-GUZET4SG.js → chunk-K673OO6B.js} +4 -4
  113. package/dist/chunk-K673OO6B.js.map +1 -0
  114. package/dist/{chunk-5UMK7GRI.js → chunk-K7RW7FI4.js} +5 -5
  115. package/dist/{chunk-N7EVQD5S.js → chunk-L2F3CFCH.js} +4 -4
  116. package/dist/{chunk-2PVXF5CS.js → chunk-L5A3KR7R.js} +3 -3
  117. package/dist/{chunk-O46CHQT7.js → chunk-LGGIFKJP.js} +4 -4
  118. package/dist/{chunk-Y2RKVFKR.js → chunk-MQ7YWBQ5.js} +2 -2
  119. package/dist/{chunk-4CIQDWRB.js → chunk-MRJDLXI3.js} +14 -8
  120. package/dist/{chunk-4CIQDWRB.js.map → chunk-MRJDLXI3.js.map} +1 -1
  121. package/dist/{chunk-YRXFFWG4.js → chunk-NIXRB5BP.js} +2 -2
  122. package/dist/{chunk-RHVMZSUU.js → chunk-NV4OESHC.js} +1 -1
  123. package/dist/chunk-NV4OESHC.js.map +1 -0
  124. package/dist/{chunk-V7ADQF5O.js → chunk-NYJBYVBG.js} +4 -4
  125. package/dist/{chunk-23D6M6VM.js → chunk-NZULV7LK.js} +4 -4
  126. package/dist/{chunk-HW7CMKUG.js → chunk-OFD2HD6F.js} +1 -1
  127. package/dist/{chunk-HW7CMKUG.js.map → chunk-OFD2HD6F.js.map} +1 -1
  128. package/dist/{chunk-BPWYQ25R.js → chunk-OJU67C23.js} +4 -4
  129. package/dist/{chunk-BPWYQ25R.js.map → chunk-OJU67C23.js.map} +1 -1
  130. package/dist/{chunk-AUKKUPVB.js → chunk-OK57EATL.js} +2 -2
  131. package/dist/{chunk-42ALPZ2B.js → chunk-OM3SEDI4.js} +4 -4
  132. package/dist/{chunk-42ALPZ2B.js.map → chunk-OM3SEDI4.js.map} +1 -1
  133. package/dist/{chunk-OYW3I5M4.js → chunk-PCYPXLEX.js} +6 -6
  134. package/dist/{chunk-2MG3SW7Q.js → chunk-PFCTSXHU.js} +2 -2
  135. package/dist/{chunk-FVH5QYY2.js → chunk-PGC35KXE.js} +2 -2
  136. package/dist/{chunk-NCO25JZO.js → chunk-PT2YCQVK.js} +4 -4
  137. package/dist/{chunk-SYNY3VB5.js → chunk-PTJY5R3O.js} +2 -2
  138. package/dist/{chunk-QMWY2FDS.js → chunk-PUBI455O.js} +2 -2
  139. package/dist/{chunk-VMV5SBE4.js → chunk-QDHHHI5Q.js} +5 -5
  140. package/dist/{chunk-JQYKPKG6.js → chunk-QGFEBNHO.js} +4 -4
  141. package/dist/{chunk-52MGURXO.js → chunk-QGSNJD3B.js} +2 -2
  142. package/dist/chunk-QJNAHPVT.js +91 -0
  143. package/dist/chunk-QJNAHPVT.js.map +1 -0
  144. package/dist/{chunk-VVOLDVIR.js → chunk-QSHATAXJ.js} +2 -2
  145. package/dist/{chunk-G2MVBDFP.js → chunk-QXJXG7DN.js} +39 -9
  146. package/dist/chunk-QXJXG7DN.js.map +1 -0
  147. package/dist/{chunk-KZXDLBY6.js → chunk-RDOEOPOI.js} +5 -5
  148. package/dist/{chunk-FLPCETP6.js → chunk-RIZTZJX6.js} +2 -2
  149. package/dist/{chunk-H427H63K.js → chunk-RNACRT5H.js} +2 -2
  150. package/dist/chunk-RWFQVNXR.js +24 -0
  151. package/dist/chunk-RWFQVNXR.js.map +1 -0
  152. package/dist/{chunk-JOSPH3E5.js → chunk-SFCD6OU7.js} +2 -2
  153. package/dist/{chunk-IMQKWR46.js → chunk-SNM7LSYG.js} +4 -5
  154. package/dist/chunk-SNM7LSYG.js.map +1 -0
  155. package/dist/{chunk-Q2XRFWOI.js → chunk-SPPOUJLN.js} +2 -2
  156. package/dist/{chunk-EGVJ7TM4.js → chunk-SWXLZ4HX.js} +8 -9
  157. package/dist/chunk-SWXLZ4HX.js.map +1 -0
  158. package/dist/{chunk-H7JBY4P7.js → chunk-TFWFPZRU.js} +13 -13
  159. package/dist/chunk-TFWFPZRU.js.map +1 -0
  160. package/dist/{chunk-VQDZYB2B.js → chunk-TMIJAR2X.js} +3 -3
  161. package/dist/{chunk-VQDZYB2B.js.map → chunk-TMIJAR2X.js.map} +1 -1
  162. package/dist/{chunk-RB4DOPGZ.js → chunk-TZYTMZZY.js} +10 -10
  163. package/dist/{chunk-Q4UHJ5SN.js → chunk-UAKY6E4N.js} +2 -2
  164. package/dist/chunk-UHFGK6YA.js +40 -0
  165. package/dist/chunk-UHFGK6YA.js.map +1 -0
  166. package/dist/{chunk-DIZLQVAA.js → chunk-UNSQZSZP.js} +2 -2
  167. package/dist/{chunk-4T3SE27M.js → chunk-UOZOWN73.js} +2 -2
  168. package/dist/{chunk-OKSTSITU.js → chunk-V55JASXO.js} +3 -3
  169. package/dist/{chunk-37EPTBBR.js → chunk-VSUQI5Q6.js} +32 -4
  170. package/dist/chunk-VSUQI5Q6.js.map +1 -0
  171. package/dist/{chunk-XQRFSKYM.js → chunk-WFWFXDNS.js} +2 -2
  172. package/dist/{chunk-N7UDP5VU.js → chunk-WHOKGHJ3.js} +7 -7
  173. package/dist/{chunk-7R2Q7CPL.js → chunk-X2RP4TO5.js} +7 -7
  174. package/dist/{chunk-U2FZNEWJ.js → chunk-XA34THLF.js} +8 -6
  175. package/dist/{chunk-U2FZNEWJ.js.map → chunk-XA34THLF.js.map} +1 -1
  176. package/dist/{chunk-UIYESRD6.js → chunk-XITHENBI.js} +9 -9
  177. package/dist/{chunk-UIYESRD6.js.map → chunk-XITHENBI.js.map} +1 -1
  178. package/dist/{chunk-3XJQBBZD.js → chunk-XKBTJGFP.js} +2 -2
  179. package/dist/{chunk-SMV2HRDU.js → chunk-XXNWU5QZ.js} +2 -2
  180. package/dist/{chunk-TZZBXPZK.js → chunk-XXQ5XIYY.js} +2 -2
  181. package/dist/{chunk-3EWS67C7.js → chunk-YFFMPZPY.js} +2 -2
  182. package/dist/{chunk-M5B2W6YY.js → chunk-YKGJ44Z7.js} +3 -3
  183. package/dist/{chunk-5A4345TG.js → chunk-YQFBH5ZJ.js} +3 -3
  184. package/dist/{chunk-DHHGL42E.js → chunk-Z3ZXVB2Y.js} +22 -6
  185. package/dist/chunk-Z3ZXVB2Y.js.map +1 -0
  186. package/dist/{chunk-OIEO4WDL.js → chunk-ZBUAX4EF.js} +2 -2
  187. package/dist/chunk-ZBUAX4EF.js.map +1 -0
  188. package/dist/{chunk-HS554XAF.js → chunk-ZHQJAV6D.js} +2 -2
  189. package/dist/{chunk-IUT3GWP3.js → chunk-ZMVSKYTJ.js} +17 -93
  190. package/dist/chunk-ZMVSKYTJ.js.map +1 -0
  191. package/dist/{chunk-AL6ML4LA.js → chunk-ZVSKSUGI.js} +5 -5
  192. package/dist/{chunk-JDEYF3PJ.js → chunk-ZWF3EWZA.js} +2 -2
  193. package/dist/chunk-ZWF3EWZA.js.map +1 -0
  194. package/dist/classified/index.js +5 -5
  195. package/dist/{classified-marker-SIYKUU5L.js → classified-marker-KHDOYIJB.js} +3 -3
  196. package/dist/collection-facade-LZIF7GWD.js +41 -0
  197. package/dist/{computed-FAD7SED4.js → computed-XMFTHAXV.js} +3 -3
  198. package/dist/consent/index.js +8 -8
  199. package/dist/cover/index.js +8 -8
  200. package/dist/coverage/index.js +1 -1
  201. package/dist/custody/index.js +12 -11
  202. package/dist/{dead-filter-4F3LWYKH.js → dead-filter-CXV5NS67.js} +10 -10
  203. package/dist/debug/index.js +7 -7
  204. package/dist/{delegation-NANZDG4N.js → delegation-ONLM4JFI.js} +49 -25
  205. package/dist/delegation-ONLM4JFI.js.map +1 -0
  206. package/dist/derivations/index.js +24 -23
  207. package/dist/derive-3YSIS36W.js +20 -0
  208. package/dist/directory/index.js +9 -9
  209. package/dist/{dispatch-JDZNGEB3.js → dispatch-2MQFMEGY.js} +20 -20
  210. package/dist/{dispatch-H4HV32AM.js → dispatch-OFDA4WQV.js} +5 -5
  211. package/dist/executor-E6YDJ7YA.js +8 -0
  212. package/dist/executor-NJX3YQQ4.js +35 -0
  213. package/dist/executor-WWM3DD4P.js +8 -0
  214. package/dist/export-accessible-RLHU5G4W.js +22 -0
  215. package/dist/extract-partition-QII2EDCS.js +35 -0
  216. package/dist/{fanout-sidecar-L7NHPIOC.js → fanout-sidecar-BO67PCPO.js} +8 -8
  217. package/dist/find-6M7GYDUZ.js +10 -0
  218. package/dist/forget/index.js +25 -8
  219. package/dist/forget/index.js.map +1 -1
  220. package/dist/guards/index.js +4 -4
  221. package/dist/history/index.js +12 -12
  222. package/dist/i18n/index.js +13 -13
  223. package/dist/index.d.ts +8 -6
  224. package/dist/index.js +122 -110
  225. package/dist/index.js.map +1 -1
  226. package/dist/indexing/index.js +6 -6
  227. package/dist/introspection/index.js +15 -11
  228. package/dist/issue-LPEEEMPP.js +19 -0
  229. package/dist/kernel/cache/index.d.ts +1 -1
  230. package/dist/kernel/collection.d.ts +1 -0
  231. package/dist/kernel/errors.d.ts +33 -4
  232. package/dist/kernel/export-scope.d.ts +40 -0
  233. package/dist/kernel/noydb.d.ts +3 -1
  234. package/dist/kernel/put-many-atomic.d.ts +1 -1
  235. package/dist/kernel/query/live/live.d.ts +2 -1
  236. package/dist/kernel/query/sort-key.d.ts +0 -2
  237. package/dist/kernel/tx-write-gate.d.ts +2 -4
  238. package/dist/kernel/types.d.ts +93 -6
  239. package/dist/kernel/validation.d.ts +0 -10
  240. package/dist/kernel/vault.d.ts +4 -0
  241. package/dist/kernel/via/reconcile.d.ts +1 -42
  242. package/dist/{ledger-5ZMGE44K.js → ledger-MSJGWKGW.js} +10 -10
  243. package/dist/liberate-LEKDYKTC.js +25 -0
  244. package/dist/{link-set-MFXC24VK.js → link-set-QXXSPPHL.js} +10 -10
  245. package/dist/{managed-secret-MFTFT22X.js → managed-secret-VSK7ANQI.js} +9 -9
  246. package/dist/materialized-views/index.js +26 -26
  247. package/dist/{migrate-cek-DZRFFOHW.js → migrate-cek-GEBFYBDC.js} +2 -2
  248. package/dist/money/index.js +5 -5
  249. package/dist/noydb-F2AUF6KL.js +98 -0
  250. package/dist/on/index.js +25 -0
  251. package/dist/overlay-views/index.js +4 -4
  252. package/dist/periods/index.js +11 -11
  253. package/dist/pod/index.js +69 -67
  254. package/dist/{pod-handle-A3LET7NO.js → pod-handle-YE7CT66T.js} +8 -8
  255. package/dist/policy/index.js +9 -9
  256. package/dist/port/as/active.d.ts +4 -0
  257. package/dist/port/as/index.d.ts +1 -0
  258. package/dist/port/by/index.d.ts +14 -5
  259. package/dist/port/on/index.d.ts +26 -0
  260. package/dist/port/to/index.d.ts +1 -1
  261. package/dist/port/with/broker-strategy.d.ts +14 -0
  262. package/dist/port/with/coverage-strategy.d.ts +17 -1
  263. package/dist/port/with/formats-strategy.d.ts +34 -1
  264. package/dist/port/with/lookup-strategy.d.ts +85 -4
  265. package/dist/port/with/service-bus.d.ts +2 -1
  266. package/dist/portability/index.js +8 -8
  267. package/dist/{post-register-7ND27CF2.js → post-register-QC5TEAW3.js} +6 -6
  268. package/dist/query/all/index.js +16 -16
  269. package/dist/query/index.js +8 -8
  270. package/dist/query/live/index.js +7 -7
  271. package/dist/query/reduce/index.js +10 -10
  272. package/dist/query/relate/index.js +10 -10
  273. package/dist/reduce/index.js +8 -8
  274. package/dist/register-SN72QALV.js +30 -0
  275. package/dist/registry-253FF7C6.js +35 -0
  276. package/dist/registry-3AZWQTDT.js +23 -0
  277. package/dist/registry-7UEBTHWG.js +8 -0
  278. package/dist/registry-IVJ67NFQ.js +8 -0
  279. package/dist/request-withdrawal-UKVJZKX2.js +28 -0
  280. package/dist/{reveal-B2TLP4JQ.js → reveal-YQTRNQFH.js} +7 -7
  281. package/dist/revoke-G2KXJQA5.js +24 -0
  282. package/dist/satellites/index.js +1 -1
  283. package/dist/schema-update/index.js +2 -2
  284. package/dist/sealed-record/index.js +11 -11
  285. package/dist/search/index.js +4 -4
  286. package/dist/{seed-XNSE4U3S.js → seed-JMQTRKRE.js} +121 -27
  287. package/dist/seed-JMQTRKRE.js.map +1 -0
  288. package/dist/sequence/index.js +8 -8
  289. package/dist/session/index.js +8 -8
  290. package/dist/shadow/index.js +2 -2
  291. package/dist/signer-IUIYR3CX.js +23 -0
  292. package/dist/snapshots/index.js +9 -9
  293. package/dist/{stale-6GCFMOOR.js → stale-SKV33PBU.js} +9 -9
  294. package/dist/storage-NPBYP2SM.js +21 -0
  295. package/dist/{store-coordination-provider-C4BPT5XF.js → store-coordination-provider-Z6HKPOGM.js} +9 -9
  296. package/dist/sync/index.js +17 -11
  297. package/dist/sync/index.js.map +1 -1
  298. package/dist/team/index.js +17 -15
  299. package/dist/tiers/index.js +10 -10
  300. package/dist/to/index.js +2 -2
  301. package/dist/transactions/index.js +3 -3
  302. package/dist/util/index.js +1 -1
  303. package/dist/vault-head/index.js +8 -8
  304. package/dist/{verify-UKALW7C2.js → verify-KWQIWLGH.js} +7 -7
  305. package/dist/via/classified/presets.d.ts +29 -0
  306. package/dist/via/classified/resolve.d.ts +7 -0
  307. package/dist/via/geo/binding.d.ts +0 -4
  308. package/dist/via/lookup/index.d.ts +32 -0
  309. package/dist/via/money/binding.d.ts +0 -9
  310. package/dist/walk-F4OLXI5H.js +20 -0
  311. package/dist/with-audit/attestation/strategy.d.ts +2 -1
  312. package/dist/with-audit/attestation/vault-facade.d.ts +7 -0
  313. package/dist/with-audit/forget/completeness.d.ts +66 -0
  314. package/dist/with-audit/forget/index.d.ts +2 -0
  315. package/dist/with-audit/forget/strategy.d.ts +65 -0
  316. package/dist/with-audit/periods/periods.d.ts +0 -9
  317. package/dist/with-audit/periods/reserved-collections.d.ts +7 -0
  318. package/dist/with-audit/portability/request-withdrawal.d.ts +0 -1
  319. package/dist/with-audit/portability/withdraw-accessible.d.ts +0 -1
  320. package/dist/with-audit/tiers/index.d.ts +1 -1
  321. package/dist/with-audit/tiers/strategy.d.ts +19 -0
  322. package/dist/with-cargo/extract-partition.d.ts +0 -46
  323. package/dist/with-commit/numbering/index.d.ts +0 -2
  324. package/dist/with-commit/tx/transaction.d.ts +2 -24
  325. package/dist/with-commit/vault-head/strategy.d.ts +7 -0
  326. package/dist/with-fork/snapshots/noydb-facade.d.ts +7 -0
  327. package/dist/with-formula/derivations/trigger-match.d.ts +8 -5
  328. package/dist/with-formula/materialized-views/emit-memo.d.ts +0 -2
  329. package/dist/with-lookup/embeddings/index.d.ts +1 -2
  330. package/dist/with-lookup/indexing/collection-facade.d.ts +1 -15
  331. package/dist/with-lookup/indexing/eager-indexes.d.ts +2 -1
  332. package/dist/with-lookup/search/collection-facade.d.ts +0 -12
  333. package/dist/with-party/broker/index.d.ts +2 -2
  334. package/dist/with-party/broker/seed.d.ts +25 -10
  335. package/dist/with-party/policy/noydb-facade.d.ts +1 -31
  336. package/dist/with-party/team/delegation.d.ts +58 -2
  337. package/dist/with-party/team/echo-secret.d.ts +0 -2
  338. package/dist/with-party/team/keyring.d.ts +1 -21
  339. package/dist/with-party/team/magic-link-grant.d.ts +11 -1
  340. package/dist/with-party/team/noydb-facade.d.ts +5 -0
  341. package/dist/with-party/team/reserved-secret-collections.d.ts +10 -8
  342. package/dist/with-party/team/roster-tag.d.ts +42 -1
  343. package/dist/with-party/team/tiers.d.ts +36 -5
  344. package/dist/with-shape/blobs/blob-set.d.ts +23 -0
  345. package/dist/with-shape/blobs/legacy-sweep.d.ts +16 -0
  346. package/dist/with-shape/introspection/describe.d.ts +1 -2
  347. package/dist/with-shape/introspection/index.d.ts +1 -0
  348. package/dist/with-shape/introspection/types.d.ts +2 -1
  349. package/dist/with-shape/schema-update/fence.d.ts +7 -0
  350. package/dist/with-sync/engine.d.ts +30 -1
  351. package/dist/with-sync/reserved-mirror.d.ts +89 -0
  352. package/dist/with-sync/strategy.d.ts +7 -0
  353. package/dist/with-sync/tab-write-relay.d.ts +0 -10
  354. package/dist/withdraw-accessible-ZKPLZ66E.js +25 -0
  355. package/package.json +3 -3
  356. package/dist/api-OS747DS4.js +0 -18
  357. package/dist/chunk-2AFX33YA.js.map +0 -1
  358. package/dist/chunk-2RH777HH.js +0 -126
  359. package/dist/chunk-2RH777HH.js.map +0 -1
  360. package/dist/chunk-37EPTBBR.js.map +0 -1
  361. package/dist/chunk-7XMHMVTS.js +0 -20
  362. package/dist/chunk-7XMHMVTS.js.map +0 -1
  363. package/dist/chunk-A4XMIZT3.js.map +0 -1
  364. package/dist/chunk-DHHGL42E.js.map +0 -1
  365. package/dist/chunk-DQESF6RP.js.map +0 -1
  366. package/dist/chunk-EGVJ7TM4.js.map +0 -1
  367. package/dist/chunk-EYG2CY2X.js.map +0 -1
  368. package/dist/chunk-FFWI7UH7.js.map +0 -1
  369. package/dist/chunk-G2MVBDFP.js.map +0 -1
  370. package/dist/chunk-GUZET4SG.js.map +0 -1
  371. package/dist/chunk-H23XHRTT.js.map +0 -1
  372. package/dist/chunk-H7JBY4P7.js.map +0 -1
  373. package/dist/chunk-IMQKWR46.js.map +0 -1
  374. package/dist/chunk-IUBMZPHM.js.map +0 -1
  375. package/dist/chunk-IUT3GWP3.js.map +0 -1
  376. package/dist/chunk-JDEYF3PJ.js.map +0 -1
  377. package/dist/chunk-JSMTXZR3.js.map +0 -1
  378. package/dist/chunk-LGNDFRYC.js.map +0 -1
  379. package/dist/chunk-MXOQ5JCG.js.map +0 -1
  380. package/dist/chunk-NBQ3KK6X.js.map +0 -1
  381. package/dist/chunk-OIEO4WDL.js.map +0 -1
  382. package/dist/chunk-PD64727P.js.map +0 -1
  383. package/dist/chunk-RHVMZSUU.js.map +0 -1
  384. package/dist/chunk-SV2PM2OY.js.map +0 -1
  385. package/dist/chunk-UA372JHH.js.map +0 -1
  386. package/dist/chunk-UBSFPGVJ.js +0 -1
  387. package/dist/chunk-VAORSCSU.js.map +0 -1
  388. package/dist/chunk-XSPFDUDG.js.map +0 -1
  389. package/dist/chunk-Y3LPTBG7.js.map +0 -1
  390. package/dist/collection-facade-CS7CA2XO.js +0 -47
  391. package/dist/delegation-NANZDG4N.js.map +0 -1
  392. package/dist/derive-XLOJVXPU.js +0 -20
  393. package/dist/executor-FMPVN6DT.js +0 -35
  394. package/dist/executor-LBBBRTN5.js +0 -8
  395. package/dist/executor-OSRZST2U.js +0 -8
  396. package/dist/export-accessible-RAOJAAU5.js +0 -22
  397. package/dist/extract-partition-JD5CUSTG.js +0 -37
  398. package/dist/find-JRN4RNQ5.js +0 -10
  399. package/dist/issue-YIVBZUTH.js +0 -19
  400. package/dist/liberate-WZSZM2W6.js +0 -24
  401. package/dist/noydb-ITIGNKUF.js +0 -96
  402. package/dist/register-DT5HZ2LZ.js +0 -30
  403. package/dist/registry-BHRZGZHF.js +0 -8
  404. package/dist/registry-ET6ZFFWA.js +0 -34
  405. package/dist/registry-HXFGLGTG.js +0 -8
  406. package/dist/registry-THCPDEOD.js +0 -23
  407. package/dist/request-withdrawal-AV2MJJKY.js +0 -30
  408. package/dist/revoke-6DWIEOCV.js +0 -24
  409. package/dist/seed-XNSE4U3S.js.map +0 -1
  410. package/dist/signer-MHGW3OIL.js +0 -23
  411. package/dist/storage-BYN5LO6Z.js +0 -21
  412. package/dist/walk-4VPK7AS4.js +0 -20
  413. package/dist/withdraw-accessible-HL7GACUE.js +0 -27
  414. /package/dist/{api-OS747DS4.js.map → api-MSJXVYQG.js.map} +0 -0
  415. /package/dist/{backup-YE2VQ26S.js.map → backup-7RKNZMQO.js.map} +0 -0
  416. /package/dist/{capsule-VOLX3QRQ.js.map → capsule-57BDK7LG.js.map} +0 -0
  417. /package/dist/{chunk-LNSVGRHO.js.map → chunk-2A56DSRI.js.map} +0 -0
  418. /package/dist/{chunk-UBSFPGVJ.js.map → chunk-2DX4JCRI.js.map} +0 -0
  419. /package/dist/{chunk-6QVKPHBF.js.map → chunk-2WJKJZSO.js.map} +0 -0
  420. /package/dist/{chunk-TKVUE4JF.js.map → chunk-2ZFD2UJC.js.map} +0 -0
  421. /package/dist/{chunk-4JPMZTJY.js.map → chunk-3Y5JLSXS.js.map} +0 -0
  422. /package/dist/{chunk-O2IMQSNA.js.map → chunk-4UIP3QNW.js.map} +0 -0
  423. /package/dist/{chunk-EJLV62NI.js.map → chunk-55P6OBB7.js.map} +0 -0
  424. /package/dist/{chunk-TEHHROZL.js.map → chunk-5LMCVBMY.js.map} +0 -0
  425. /package/dist/{chunk-4V3Q35WG.js.map → chunk-5UUJE4FP.js.map} +0 -0
  426. /package/dist/{chunk-JWWYRR4Q.js.map → chunk-5XONHAFD.js.map} +0 -0
  427. /package/dist/{chunk-QBLT6POL.js.map → chunk-6WS35E6X.js.map} +0 -0
  428. /package/dist/{chunk-EZOAKKTB.js.map → chunk-ABU6A4Z5.js.map} +0 -0
  429. /package/dist/{chunk-VKI2EB3N.js.map → chunk-AJFPAHMW.js.map} +0 -0
  430. /package/dist/{chunk-2ODVB6LZ.js.map → chunk-B65CC6Z6.js.map} +0 -0
  431. /package/dist/{chunk-MBMTND6D.js.map → chunk-BJH77UY2.js.map} +0 -0
  432. /package/dist/{chunk-FFJFE4T7.js.map → chunk-BNFNQNEP.js.map} +0 -0
  433. /package/dist/{chunk-5WWDGFOS.js.map → chunk-BUE7R3B5.js.map} +0 -0
  434. /package/dist/{chunk-5FE75J4S.js.map → chunk-BVF3SXD7.js.map} +0 -0
  435. /package/dist/{chunk-VFHCKG5M.js.map → chunk-BYHCKX73.js.map} +0 -0
  436. /package/dist/{chunk-BVCUTXE3.js.map → chunk-C53ER7AG.js.map} +0 -0
  437. /package/dist/{chunk-MILI22XQ.js.map → chunk-CAD7N6HQ.js.map} +0 -0
  438. /package/dist/{chunk-5KC7QYEC.js.map → chunk-CB4467G3.js.map} +0 -0
  439. /package/dist/{chunk-JIBUPZHA.js.map → chunk-D4V5JJAK.js.map} +0 -0
  440. /package/dist/{chunk-DLD5LGDS.js.map → chunk-D5A3GCZ4.js.map} +0 -0
  441. /package/dist/{chunk-FOEDQATO.js.map → chunk-DHU2AQ6T.js.map} +0 -0
  442. /package/dist/{chunk-VHBKYN2J.js.map → chunk-DL6BZKP3.js.map} +0 -0
  443. /package/dist/{chunk-E2N2T5ZO.js.map → chunk-ECGXA4LT.js.map} +0 -0
  444. /package/dist/{chunk-PP3K67AJ.js.map → chunk-EMAWOGVH.js.map} +0 -0
  445. /package/dist/{chunk-WXE4W2U6.js.map → chunk-EUD3HQM4.js.map} +0 -0
  446. /package/dist/{chunk-LIOVX5TJ.js.map → chunk-FZXRLNJO.js.map} +0 -0
  447. /package/dist/{chunk-WPOYWFSE.js.map → chunk-G46JSSVX.js.map} +0 -0
  448. /package/dist/{chunk-AEQGFRU4.js.map → chunk-GCUMOKTN.js.map} +0 -0
  449. /package/dist/{chunk-V3RWOOSO.js.map → chunk-GOJQ5DZA.js.map} +0 -0
  450. /package/dist/{chunk-UEFOQH74.js.map → chunk-GRS2HIV6.js.map} +0 -0
  451. /package/dist/{chunk-3L2NBKDR.js.map → chunk-H3YM66EI.js.map} +0 -0
  452. /package/dist/{chunk-747G6CT3.js.map → chunk-J4KAPKBJ.js.map} +0 -0
  453. /package/dist/{chunk-MXKI4ABF.js.map → chunk-JPSL5GIZ.js.map} +0 -0
  454. /package/dist/{chunk-2GHDLTPE.js.map → chunk-JSWKVZCR.js.map} +0 -0
  455. /package/dist/{chunk-BNWA3WG5.js.map → chunk-JZ4EDEIP.js.map} +0 -0
  456. /package/dist/{chunk-5UMK7GRI.js.map → chunk-K7RW7FI4.js.map} +0 -0
  457. /package/dist/{chunk-N7EVQD5S.js.map → chunk-L2F3CFCH.js.map} +0 -0
  458. /package/dist/{chunk-2PVXF5CS.js.map → chunk-L5A3KR7R.js.map} +0 -0
  459. /package/dist/{chunk-O46CHQT7.js.map → chunk-LGGIFKJP.js.map} +0 -0
  460. /package/dist/{chunk-Y2RKVFKR.js.map → chunk-MQ7YWBQ5.js.map} +0 -0
  461. /package/dist/{chunk-YRXFFWG4.js.map → chunk-NIXRB5BP.js.map} +0 -0
  462. /package/dist/{chunk-V7ADQF5O.js.map → chunk-NYJBYVBG.js.map} +0 -0
  463. /package/dist/{chunk-23D6M6VM.js.map → chunk-NZULV7LK.js.map} +0 -0
  464. /package/dist/{chunk-AUKKUPVB.js.map → chunk-OK57EATL.js.map} +0 -0
  465. /package/dist/{chunk-OYW3I5M4.js.map → chunk-PCYPXLEX.js.map} +0 -0
  466. /package/dist/{chunk-2MG3SW7Q.js.map → chunk-PFCTSXHU.js.map} +0 -0
  467. /package/dist/{chunk-FVH5QYY2.js.map → chunk-PGC35KXE.js.map} +0 -0
  468. /package/dist/{chunk-NCO25JZO.js.map → chunk-PT2YCQVK.js.map} +0 -0
  469. /package/dist/{chunk-SYNY3VB5.js.map → chunk-PTJY5R3O.js.map} +0 -0
  470. /package/dist/{chunk-QMWY2FDS.js.map → chunk-PUBI455O.js.map} +0 -0
  471. /package/dist/{chunk-VMV5SBE4.js.map → chunk-QDHHHI5Q.js.map} +0 -0
  472. /package/dist/{chunk-JQYKPKG6.js.map → chunk-QGFEBNHO.js.map} +0 -0
  473. /package/dist/{chunk-52MGURXO.js.map → chunk-QGSNJD3B.js.map} +0 -0
  474. /package/dist/{chunk-VVOLDVIR.js.map → chunk-QSHATAXJ.js.map} +0 -0
  475. /package/dist/{chunk-KZXDLBY6.js.map → chunk-RDOEOPOI.js.map} +0 -0
  476. /package/dist/{chunk-FLPCETP6.js.map → chunk-RIZTZJX6.js.map} +0 -0
  477. /package/dist/{chunk-H427H63K.js.map → chunk-RNACRT5H.js.map} +0 -0
  478. /package/dist/{chunk-JOSPH3E5.js.map → chunk-SFCD6OU7.js.map} +0 -0
  479. /package/dist/{chunk-Q2XRFWOI.js.map → chunk-SPPOUJLN.js.map} +0 -0
  480. /package/dist/{chunk-RB4DOPGZ.js.map → chunk-TZYTMZZY.js.map} +0 -0
  481. /package/dist/{chunk-Q4UHJ5SN.js.map → chunk-UAKY6E4N.js.map} +0 -0
  482. /package/dist/{chunk-DIZLQVAA.js.map → chunk-UNSQZSZP.js.map} +0 -0
  483. /package/dist/{chunk-4T3SE27M.js.map → chunk-UOZOWN73.js.map} +0 -0
  484. /package/dist/{chunk-OKSTSITU.js.map → chunk-V55JASXO.js.map} +0 -0
  485. /package/dist/{chunk-XQRFSKYM.js.map → chunk-WFWFXDNS.js.map} +0 -0
  486. /package/dist/{chunk-N7UDP5VU.js.map → chunk-WHOKGHJ3.js.map} +0 -0
  487. /package/dist/{chunk-7R2Q7CPL.js.map → chunk-X2RP4TO5.js.map} +0 -0
  488. /package/dist/{chunk-3XJQBBZD.js.map → chunk-XKBTJGFP.js.map} +0 -0
  489. /package/dist/{chunk-SMV2HRDU.js.map → chunk-XXNWU5QZ.js.map} +0 -0
  490. /package/dist/{chunk-TZZBXPZK.js.map → chunk-XXQ5XIYY.js.map} +0 -0
  491. /package/dist/{chunk-3EWS67C7.js.map → chunk-YFFMPZPY.js.map} +0 -0
  492. /package/dist/{chunk-M5B2W6YY.js.map → chunk-YKGJ44Z7.js.map} +0 -0
  493. /package/dist/{chunk-5A4345TG.js.map → chunk-YQFBH5ZJ.js.map} +0 -0
  494. /package/dist/{chunk-HS554XAF.js.map → chunk-ZHQJAV6D.js.map} +0 -0
  495. /package/dist/{chunk-AL6ML4LA.js.map → chunk-ZVSKSUGI.js.map} +0 -0
  496. /package/dist/{classified-marker-SIYKUU5L.js.map → classified-marker-KHDOYIJB.js.map} +0 -0
  497. /package/dist/{collection-facade-CS7CA2XO.js.map → collection-facade-LZIF7GWD.js.map} +0 -0
  498. /package/dist/{computed-FAD7SED4.js.map → computed-XMFTHAXV.js.map} +0 -0
  499. /package/dist/{dead-filter-4F3LWYKH.js.map → dead-filter-CXV5NS67.js.map} +0 -0
  500. /package/dist/{derive-XLOJVXPU.js.map → derive-3YSIS36W.js.map} +0 -0
  501. /package/dist/{dispatch-JDZNGEB3.js.map → dispatch-2MQFMEGY.js.map} +0 -0
  502. /package/dist/{dispatch-H4HV32AM.js.map → dispatch-OFDA4WQV.js.map} +0 -0
  503. /package/dist/{executor-FMPVN6DT.js.map → executor-E6YDJ7YA.js.map} +0 -0
  504. /package/dist/{executor-LBBBRTN5.js.map → executor-NJX3YQQ4.js.map} +0 -0
  505. /package/dist/{executor-OSRZST2U.js.map → executor-WWM3DD4P.js.map} +0 -0
  506. /package/dist/{export-accessible-RAOJAAU5.js.map → export-accessible-RLHU5G4W.js.map} +0 -0
  507. /package/dist/{extract-partition-JD5CUSTG.js.map → extract-partition-QII2EDCS.js.map} +0 -0
  508. /package/dist/{fanout-sidecar-L7NHPIOC.js.map → fanout-sidecar-BO67PCPO.js.map} +0 -0
  509. /package/dist/{find-JRN4RNQ5.js.map → find-6M7GYDUZ.js.map} +0 -0
  510. /package/dist/{issue-YIVBZUTH.js.map → issue-LPEEEMPP.js.map} +0 -0
  511. /package/dist/{ledger-5ZMGE44K.js.map → ledger-MSJGWKGW.js.map} +0 -0
  512. /package/dist/{liberate-WZSZM2W6.js.map → liberate-LEKDYKTC.js.map} +0 -0
  513. /package/dist/{link-set-MFXC24VK.js.map → link-set-QXXSPPHL.js.map} +0 -0
  514. /package/dist/{managed-secret-MFTFT22X.js.map → managed-secret-VSK7ANQI.js.map} +0 -0
  515. /package/dist/{migrate-cek-DZRFFOHW.js.map → migrate-cek-GEBFYBDC.js.map} +0 -0
  516. /package/dist/{noydb-ITIGNKUF.js.map → noydb-F2AUF6KL.js.map} +0 -0
  517. /package/dist/{pod-handle-A3LET7NO.js.map → pod-handle-YE7CT66T.js.map} +0 -0
  518. /package/dist/{post-register-7ND27CF2.js.map → post-register-QC5TEAW3.js.map} +0 -0
  519. /package/dist/{register-DT5HZ2LZ.js.map → register-SN72QALV.js.map} +0 -0
  520. /package/dist/{registry-BHRZGZHF.js.map → registry-253FF7C6.js.map} +0 -0
  521. /package/dist/{registry-ET6ZFFWA.js.map → registry-3AZWQTDT.js.map} +0 -0
  522. /package/dist/{registry-HXFGLGTG.js.map → registry-7UEBTHWG.js.map} +0 -0
  523. /package/dist/{registry-THCPDEOD.js.map → registry-IVJ67NFQ.js.map} +0 -0
  524. /package/dist/{request-withdrawal-AV2MJJKY.js.map → request-withdrawal-UKVJZKX2.js.map} +0 -0
  525. /package/dist/{reveal-B2TLP4JQ.js.map → reveal-YQTRNQFH.js.map} +0 -0
  526. /package/dist/{revoke-6DWIEOCV.js.map → revoke-G2KXJQA5.js.map} +0 -0
  527. /package/dist/{signer-MHGW3OIL.js.map → signer-IUIYR3CX.js.map} +0 -0
  528. /package/dist/{stale-6GCFMOOR.js.map → stale-SKV33PBU.js.map} +0 -0
  529. /package/dist/{storage-BYN5LO6Z.js.map → storage-NPBYP2SM.js.map} +0 -0
  530. /package/dist/{store-coordination-provider-C4BPT5XF.js.map → store-coordination-provider-Z6HKPOGM.js.map} +0 -0
  531. /package/dist/{verify-UKALW7C2.js.map → verify-KWQIWLGH.js.map} +0 -0
  532. /package/dist/{walk-4VPK7AS4.js.map → walk-F4OLXI5H.js.map} +0 -0
  533. /package/dist/{withdraw-accessible-HL7GACUE.js.map → withdraw-accessible-ZKPLZ66E.js.map} +0 -0
@@ -1,20 +1,22 @@
1
1
  import {
2
2
  hopCollections,
3
3
  normalizeTriggerBy
4
- } from "./chunk-FFWI7UH7.js";
4
+ } from "./chunk-GAGT3YZN.js";
5
5
  import {
6
6
  ViaGraph,
7
- matchTargetFieldNames,
7
+ matchTargetFieldNames
8
+ } from "./chunk-ZMVSKYTJ.js";
9
+ import {
8
10
  schemaFieldKeys
9
- } from "./chunk-IUT3GWP3.js";
11
+ } from "./chunk-QJNAHPVT.js";
10
12
  import {
11
13
  sha256Hex
12
- } from "./chunk-EZGV6F47.js";
14
+ } from "./chunk-4J3MNVVX.js";
13
15
  import {
14
16
  DerivationCycleError,
15
17
  DuplicateBehaviorNameError,
16
18
  ValidationError
17
- } from "./chunk-37EPTBBR.js";
19
+ } from "./chunk-VSUQI5Q6.js";
18
20
 
19
21
  // src/with-formula/derivations/strategy-hash.ts
20
22
  async function computeStrategyHash(source, outputKeys, derive, sources) {
@@ -244,4 +246,4 @@ var DerivationRegistry = class {
244
246
  export {
245
247
  DerivationRegistry
246
248
  };
247
- //# sourceMappingURL=chunk-U2FZNEWJ.js.map
249
+ //# sourceMappingURL=chunk-XA34THLF.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/with-formula/derivations/strategy-hash.ts","../src/with-formula/derivations/registry.ts"],"sourcesContent":["/**\n * Deterministic hash of a derivation strategy's \"shape\": source\n * collection, declared sibling sources, output keys, derive function\n * source. Used to detect\n * strategy drift: a record whose `_derivedFrom.strategyHash` doesn't\n * match the current strategy is considered stale.\n *\n * Web Crypto SHA-256 — no extra deps.\n */\nimport { sha256Hex } from '../../capsule/index.js'\n\nexport async function computeStrategyHash(\n source: string,\n outputKeys: readonly string[],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n derive: (...args: any[]) => any,\n sources?: ReadonlyArray<string>,\n): Promise<string> {\n const canonical = JSON.stringify({\n source,\n outputs: [...outputKeys].sort(),\n derive: derive.toString(),\n // Declared sibling sources — adding/removing a trigger\n // collection invalidates cached derived records. Omitted when empty\n // so strategies without siblings keep their existing hash.\n ...(sources?.length ? { sources: [...sources].sort() } : {}),\n })\n const bytes = new TextEncoder().encode(canonical)\n return sha256Hex(bytes)\n}\n","import { matchTargetFieldNames } from '../../kernel/collection-config.js'\nimport { DerivationCycleError, DuplicateBehaviorNameError, ValidationError } from '../../kernel/errors.js'\nimport { ViaGraph, type FieldRef, type EdgeKind, type Grain } from '../../kernel/via/graph.js'\nimport { schemaFieldKeys } from '../../with-shape/introspection/describe.js'\nimport { computeStrategyHash } from './strategy-hash.js'\nimport { hopCollections, normalizeTriggerBy, type NormalizedTrigger } from './trigger-match.js'\nimport type { DerivationSpec } from './types.js'\n\n/**\n * Whole-record artifact-grain field marker (#638 Task 2). A derivation's\n * `derive()`/a rollup's `compute()` reads the WHOLE source record — there is\n * no single declared field to point at — so a trigger/output collection is\n * modelled as one artifact node per collection (`kernel/via/graph.ts`'s\n * \"Artifact-grain targets... modelled as a field node whose field is the\n * artifact key\" convention). MUST match `materialized-views/registry.ts`'s\n * and `vault.ts`'s overlay-edge marker so cross-registry edges (a derivation\n * feeding into / out of an MV or overlay collection) resolve to the SAME\n * graph node.\n */\nconst WHOLE_RECORD = '*'\n\n/** Strip this registry's `.${WHOLE_RECORD}` artifact suffix off a graph cycle\n * path entry, recovering the bare collection name — preserves the exact\n * pre-#638 `DerivationCycleError` message shape (behavior lock) for a pure\n * record-shape derivation cycle. A rollup's real-field target (not suffixed\n * `.${WHOLE_RECORD}`) is left untouched. */\nfunction stripArtifactSuffix(displayId: string): string {\n const suffix = `.${WHOLE_RECORD}`\n return displayId.endsWith(suffix) ? displayId.slice(0, -suffix.length) : displayId\n}\n\ninterface RegisteredStrategy {\n // Type-erased to allow the registry to hold heterogeneous strategies.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n spec: DerivationSpec<any, any>\n strategyHash: string\n readonly triggers: ReadonlyArray<NormalizedTrigger>\n}\n\n/**\n * Vault-internal registry of derivation strategies. Owned by `Vault`;\n * not exported.\n *\n * @internal\n */\nexport class DerivationRegistry {\n private readonly _bySource = new Map<string, RegisteredStrategy[]>()\n private readonly _byOutput = new Map<string, RegisteredStrategy[]>()\n private readonly _byName = new Map<string, RegisteredStrategy>()\n\n /**\n * Register a derivation strategy. If `spec.name` is given and already\n * registered by another derivation in this vault, throws\n * {@link DuplicateBehaviorNameError} before indexing.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n async register(spec: DerivationSpec<any, any>): Promise<void> {\n if (spec.name !== undefined && this._byName.has(spec.name)) {\n throw new DuplicateBehaviorNameError(spec.name, 'derivation')\n }\n\n const outputKeys = Object.keys(spec.outputs)\n const strategyHash = await computeStrategyHash(spec.source, outputKeys, spec.derive, spec.sources)\n const triggers = normalizeTriggerBy(spec.triggerBy)\n const reg: RegisteredStrategy = { spec, strategyHash, triggers }\n\n if (spec.name !== undefined) this._byName.set(spec.name, reg)\n\n const fromSource = this._bySource.get(spec.source)\n if (fromSource) fromSource.push(reg)\n else this._bySource.set(spec.source, [reg])\n\n // Declared sibling sources index the SAME `reg` under each\n // extra collection so `strategiesForSource(extra)` returns it and a\n // sibling write re-fires the derivation. Sibling keys also enter\n // `_bySource`, so `validate()`'s cycle DFS walks them automatically.\n for (const extra of spec.sources ?? []) {\n const fromExtra = this._bySource.get(extra)\n if (fromExtra) fromExtra.push(reg)\n else this._bySource.set(extra, [reg])\n }\n\n // FK triggers index the SAME `reg` under each parent collection so\n // a parent write re-fires the derivation (fanned out to matching source\n // records in `dispatchDerivations`). Like sources[], these keys enter\n // `_bySource` so the cycle DFS walks the trigger→output edge.\n // #1277 — the INTERMEDIATE of a declared hop is indexed too, so a write\n // that re-points it re-fires the derivation. Without this the hop's whole\n // correctness argument fails: nothing is written to the trigger or source\n // collection when an intermediate moves, so no other path can notice, and\n // every source it used to address is stranded silently. Entering `_bySource`\n // also puts the hop edge into `validate()`'s cycle DFS, which would\n // otherwise be blind to it.\n for (const t of triggers) {\n for (const hop of hopCollections(t.match)) {\n const fromHop = this._bySource.get(hop)\n if (fromHop) { if (!fromHop.includes(reg)) fromHop.push(reg) }\n else this._bySource.set(hop, [reg])\n }\n }\n for (const t of triggers) {\n const fromTrigger = this._bySource.get(t.collection)\n if (fromTrigger) fromTrigger.push(reg)\n else this._bySource.set(t.collection, [reg])\n }\n\n // Rollup: a write to the child `from` collection recomputes\n // the parent (= spec.source = into) at id child[key]. Index under `from`\n // so a child write fires it; spec.source (into) is already indexed above,\n // so a parent write also recomputes its own aggregate (covers the\n // parent-created-after-children case). The from→into edge enters the cycle\n // DFS automatically.\n if (spec.rollup) {\n const fromRollup = this._bySource.get(spec.rollup.from)\n if (fromRollup) fromRollup.push(reg)\n else this._bySource.set(spec.rollup.from, [reg])\n }\n\n for (const key of outputKeys) {\n const output = spec.outputs[key]\n if (!output) continue\n const outputCollection = output.collection\n const arr = this._byOutput.get(outputCollection)\n if (arr) arr.push(reg)\n else this._byOutput.set(outputCollection, [reg])\n }\n }\n\n strategiesForSource(source: string): ReadonlyArray<RegisteredStrategy> {\n return this._bySource.get(source) ?? []\n }\n\n strategiesProducingOutput(collection: string): ReadonlyArray<RegisteredStrategy> {\n return this._byOutput.get(collection) ?? []\n }\n\n /**\n * The #1253-pattern typo guard for match fields (#1249): a misspelt\n * `to`/`from` silently matches nothing forever, so validate against the\n * collection's enumerable field set at the earliest point it exists.\n * `schemaFieldKeys(schema) === undefined` (TS-generic collection,\n * unreadable validator) is DELIBERATELY silent — those fields are real\n * and unenumerable. `configKeys` folds in the collection's other\n * non-schema field declarations (fieldMeta/moneyFields/dictKeyFields/\n * refs/computed); `denormExempt` is derived here from this registry's\n * own strategies rather than taken as a parameter — a field this\n * collection's own derivations write via `denorm` is never a typo.\n */\n validateFieldsFor(\n collectionName: string,\n schema: unknown,\n configKeys: ReadonlyArray<string>,\n viaSources: {\n readonly computed?: Readonly<Record<string, unknown>> | undefined\n readonly viaFields?: Readonly<Record<string, unknown>> | undefined\n } | undefined = undefined,\n ): void {\n const targets = matchTargetFieldNames(viaSources ?? {})\n const virtual = new Set(targets.virtual)\n const shapeKeys = schemaFieldKeys(schema)\n // The two checks have DIFFERENT preconditions, which is why one loop runs\n // both rather than an early return covering both. The typo check needs a\n // readable field list and must stay silent without one — a false \"unknown\n // field\" on a TS-generic collection would be worse than no check. The\n // virtual check needs nothing but the declaration in hand: \"declared, and\n // never stored\" is provable from the declaration alone (#1266).\n if (shapeKeys === undefined && virtual.size === 0) return\n const keys = shapeKeys === undefined ? undefined\n : new Set([...shapeKeys, ...configKeys, ...targets.declared])\n const denormExempt = new Set<string>()\n const regs = new Set([...this._bySource.values()].flat())\n for (const reg of regs) {\n if (reg.spec.source !== collectionName) continue\n for (const out of Object.values(reg.spec.outputs) as Array<{ collection?: string; denorm?: readonly string[] }>) {\n if (out.collection === collectionName) for (const d of out.denorm ?? []) denormExempt.add(d)\n }\n }\n const unknown = (f: string): boolean =>\n keys !== undefined && !keys.has(f) && !denormExempt.has(f)\n for (const reg of regs) {\n const name = reg.spec.name ?? reg.spec.source\n for (const t of reg.triggers) {\n for (const p of t.match) {\n // `to` reads the SOURCE record; `from` reads the WRITTEN record.\n // Both are the stored shape, so both refuse a virtual target.\n if (reg.spec.source === collectionName) {\n if (virtual.has(p.to)) throw new ValidationError(this._virtualMatchMessage(name, collectionName, p.to, 'to'))\n if (unknown(p.to)) {\n throw new ValidationError(\n `derivation \"${name}\": triggerBy match names source field \"${p.to}\", which \"${collectionName}\" does not declare — a typo here silently matches nothing forever`)\n }\n }\n if (t.collection === collectionName && p.from !== 'id') {\n if (virtual.has(p.from)) throw new ValidationError(this._virtualMatchMessage(name, collectionName, p.from, 'from'))\n if (unknown(p.from)) {\n throw new ValidationError(\n `derivation \"${name}\": triggerBy match reads \"${p.from}\" from written \"${collectionName}\" records, which that collection does not declare — a typo here silently matches nothing forever`)\n }\n }\n }\n }\n }\n }\n\n /** #1266 — one message shape for both match sides; see {@link matchTargetFieldNames}. */\n private _virtualMatchMessage(name: string, collectionName: string, field: string, side: 'to' | 'from'): string {\n const where = side === 'to'\n ? `names source field \"${field}\", which \"${collectionName}\"`\n : `reads \"${field}\" from written \"${collectionName}\" records, which that collection`\n return `derivation \"${name}\": triggerBy match ${where} declares as a VIRTUAL computed field — virtual fields are evaluated on read and never stored, so the matcher would read every candidate record and match nothing, forever. Declare it as \\`mode: 'materialized'\\` (stored, indexable) or match on a stored field.`\n }\n\n /**\n * All registered strategies as a flat, deduplicated array.\n * Each strategy is indexed once per source (not once per output key),\n * so iterating `_bySource.values()` naturally yields each strategy\n * exactly once per source — deduplication is handled by flattening\n * the per-source arrays and collecting into a Set by identity.\n *\n * Used by `dumpSchema()` / `describeDerivations()` in the introspection\n * walker to populate the derivations map.\n */\n all(): ReadonlyArray<RegisteredStrategy> {\n const seen = new Set<RegisteredStrategy>()\n for (const strategies of this._bySource.values()) {\n for (const s of strategies) seen.add(s)\n }\n return [...seen]\n }\n\n /**\n * Graph edges for #638 Task 2: one `'derivation'`/`'record'` edge per\n * (non-self-write) output key — target = the output collection (a\n * `WHOLE_RECORD` artifact node), sources = every collection that can\n * trigger this strategy (`source`, `sources[]`, `triggerBy[].collection`,\n * and — for a rollup — `rollup.from`), mirroring EXACTLY the trigger keys\n * `register()` indexes under `_bySource`. The self-write reverse-denorm\n * output (`output.collection === source` with `denorm` declared) is\n * skipped — the SAME condition the old local DFS used; it is not a cycle\n * (see the comment `validate()` used to carry, now on this skip).\n * Rollups ADDITIONALLY get a dedicated `'rollup'`/`'aggregate'` edge\n * targeting the real `rollup.field` on the parent (`source`) — the\n * self-write output above only covers the cycle-DFS skip, not\n * dispatch/taint (Tasks 3/4/6), which need the real field.\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.all()) {\n const spec = reg.spec\n const triggerCollections = [\n spec.source,\n ...(spec.sources ?? []),\n ...(spec.triggerBy ?? []).map((t) => t.collection),\n ...(spec.rollup ? [spec.rollup.from] : []),\n ]\n const sources: FieldRef[] = triggerCollections.map((c) => ({ collection: c, field: WHOLE_RECORD }))\n for (const key of Object.keys(spec.outputs)) {\n const output = spec.outputs[key]\n if (!output) continue\n if (output.shape === 'record' && output.collection === spec.source && output.denorm !== undefined) continue\n out.push({ target: { collection: output.collection, field: WHOLE_RECORD }, sources, kind: 'derivation', grain: 'record' })\n }\n if (spec.rollup) {\n out.push({\n target: { collection: spec.source, field: spec.rollup.field },\n sources: [{ collection: spec.rollup.from, field: WHOLE_RECORD }],\n kind: 'rollup',\n grain: 'aggregate',\n })\n }\n }\n return out\n }\n\n /**\n * Cycle detection, delegated to `ViaGraph.assertAcyclic()` (#638 Task 2 —\n * retires the local DFS). Call after all `register()` calls complete (i.e.\n * at vault open). Throws `DerivationCycleError` on the first cycle found —\n * SAME class/timing as before; the message/path is byte-identical to the\n * pre-#638 shape for a pure record-shape derivation cycle (the\n * `WHOLE_RECORD` artifact suffix is stripped back to a bare collection\n * name before re-throwing).\n *\n * `graph` is the caller's shared per-vault graph, ALREADY carrying this\n * registry's `edges()` (the caller registers them — see `Vault._initDerivations`)\n * — omit it (e.g. this registry's own unit tests) to validate this\n * registry's edges in isolation against a throwaway graph.\n */\n validate(graph?: ViaGraph): void {\n const g = graph ?? new ViaGraph()\n if (!graph) {\n for (const edge of this.edges()) g.registerDerived(edge.target, edge.sources, edge.kind, edge.grain)\n }\n try {\n g.assertAcyclic()\n } catch (e) {\n if (e instanceof DerivationCycleError) throw new DerivationCycleError(e.path.map(stripArtifactSuffix))\n throw e\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAWA,eAAsB,oBACpB,QACA,YAEA,QACA,SACiB;AACjB,QAAM,YAAY,KAAK,UAAU;AAAA,IAC/B;AAAA,IACA,SAAS,CAAC,GAAG,UAAU,EAAE,KAAK;AAAA,IAC9B,QAAQ,OAAO,SAAS;AAAA;AAAA;AAAA;AAAA,IAIxB,GAAI,SAAS,SAAS,EAAE,SAAS,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;AAAA,EAC5D,CAAC;AACD,QAAM,QAAQ,IAAI,YAAY,EAAE,OAAO,SAAS;AAChD,SAAO,UAAU,KAAK;AACxB;;;ACVA,IAAM,eAAe;AAOrB,SAAS,oBAAoB,WAA2B;AACtD,QAAM,SAAS,IAAI,YAAY;AAC/B,SAAO,UAAU,SAAS,MAAM,IAAI,UAAU,MAAM,GAAG,CAAC,OAAO,MAAM,IAAI;AAC3E;AAgBO,IAAM,qBAAN,MAAyB;AAAA,EACb,YAAY,oBAAI,IAAkC;AAAA,EAClD,YAAY,oBAAI,IAAkC;AAAA,EAClD,UAAU,oBAAI,IAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ/D,MAAM,SAAS,MAA+C;AAC5D,QAAI,KAAK,SAAS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O;AAAA,QACT,CAAC;AAAA,MACH;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBA,SAAS,OAAwB;AAC/B,UAAM,IAAI,SAAS,IAAI,SAAS;AAChC,QAAI,CAAC,OAAO;AACV,iBAAW,QAAQ,KAAK,MAAM,EAAG,GAAE,gBAAgB,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM,KAAK,KAAK;AAAA,IACrG;AACA,QAAI;AACF,QAAE,cAAc;AAAA,IAClB,SAAS,GAAG;AACV,UAAI,aAAa,qBAAsB,OAAM,IAAI,qBAAqB,EAAE,KAAK,IAAI,mBAAmB,CAAC;AACrG,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/with-formula/derivations/strategy-hash.ts","../src/with-formula/derivations/registry.ts"],"sourcesContent":["/**\n * Deterministic hash of a derivation strategy's \"shape\": source\n * collection, declared sibling sources, output keys, derive function\n * source. Used to detect\n * strategy drift: a record whose `_derivedFrom.strategyHash` doesn't\n * match the current strategy is considered stale.\n *\n * Web Crypto SHA-256 — no extra deps.\n */\nimport { sha256Hex } from '../../capsule/index.js'\n\nexport async function computeStrategyHash(\n source: string,\n outputKeys: readonly string[],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n derive: (...args: any[]) => any,\n sources?: ReadonlyArray<string>,\n): Promise<string> {\n const canonical = JSON.stringify({\n source,\n outputs: [...outputKeys].sort(),\n derive: derive.toString(),\n // Declared sibling sources — adding/removing a trigger\n // collection invalidates cached derived records. Omitted when empty\n // so strategies without siblings keep their existing hash.\n ...(sources?.length ? { sources: [...sources].sort() } : {}),\n })\n const bytes = new TextEncoder().encode(canonical)\n return sha256Hex(bytes)\n}\n","import { matchTargetFieldNames } from '../../kernel/collection-config.js'\nimport { DerivationCycleError, DuplicateBehaviorNameError, ValidationError } from '../../kernel/errors.js'\nimport { ViaGraph, type FieldRef, type EdgeKind, type Grain } from '../../kernel/via/graph.js'\nimport { schemaFieldKeys } from '../../with-shape/introspection/describe.js'\nimport { computeStrategyHash } from './strategy-hash.js'\nimport { hopCollections, normalizeTriggerBy, type NormalizedTrigger } from './trigger-match.js'\nimport type { DerivationSpec } from './types.js'\n\n/**\n * Whole-record artifact-grain field marker (#638 Task 2). A derivation's\n * `derive()`/a rollup's `compute()` reads the WHOLE source record — there is\n * no single declared field to point at — so a trigger/output collection is\n * modelled as one artifact node per collection (`kernel/via/graph.ts`'s\n * \"Artifact-grain targets... modelled as a field node whose field is the\n * artifact key\" convention). MUST match `materialized-views/registry.ts`'s\n * and `vault.ts`'s overlay-edge marker so cross-registry edges (a derivation\n * feeding into / out of an MV or overlay collection) resolve to the SAME\n * graph node.\n */\nconst WHOLE_RECORD = '*'\n\n/** Strip this registry's `.${WHOLE_RECORD}` artifact suffix off a graph cycle\n * path entry, recovering the bare collection name — preserves the exact\n * pre-#638 `DerivationCycleError` message shape (behavior lock) for a pure\n * record-shape derivation cycle. A rollup's real-field target (not suffixed\n * `.${WHOLE_RECORD}`) is left untouched. */\nfunction stripArtifactSuffix(displayId: string): string {\n const suffix = `.${WHOLE_RECORD}`\n return displayId.endsWith(suffix) ? displayId.slice(0, -suffix.length) : displayId\n}\n\ninterface RegisteredStrategy {\n // Type-erased to allow the registry to hold heterogeneous strategies.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n spec: DerivationSpec<any, any>\n strategyHash: string\n readonly triggers: ReadonlyArray<NormalizedTrigger>\n}\n\n/**\n * Vault-internal registry of derivation strategies. Owned by `Vault`;\n * not exported.\n *\n * @internal\n */\nexport class DerivationRegistry {\n private readonly _bySource = new Map<string, RegisteredStrategy[]>()\n private readonly _byOutput = new Map<string, RegisteredStrategy[]>()\n private readonly _byName = new Map<string, RegisteredStrategy>()\n\n /**\n * Register a derivation strategy. If `spec.name` is given and already\n * registered by another derivation in this vault, throws\n * {@link DuplicateBehaviorNameError} before indexing.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n async register(spec: DerivationSpec<any, any>): Promise<void> {\n if (spec.name !== undefined && this._byName.has(spec.name)) {\n throw new DuplicateBehaviorNameError(spec.name, 'derivation')\n }\n\n const outputKeys = Object.keys(spec.outputs)\n const strategyHash = await computeStrategyHash(spec.source, outputKeys, spec.derive, spec.sources)\n const triggers = normalizeTriggerBy(spec.triggerBy)\n const reg: RegisteredStrategy = { spec, strategyHash, triggers }\n\n if (spec.name !== undefined) this._byName.set(spec.name, reg)\n\n const fromSource = this._bySource.get(spec.source)\n if (fromSource) fromSource.push(reg)\n else this._bySource.set(spec.source, [reg])\n\n // Declared sibling sources index the SAME `reg` under each\n // extra collection so `strategiesForSource(extra)` returns it and a\n // sibling write re-fires the derivation. Sibling keys also enter\n // `_bySource`, so `validate()`'s cycle DFS walks them automatically.\n for (const extra of spec.sources ?? []) {\n const fromExtra = this._bySource.get(extra)\n if (fromExtra) fromExtra.push(reg)\n else this._bySource.set(extra, [reg])\n }\n\n // FK triggers index the SAME `reg` under each parent collection so\n // a parent write re-fires the derivation (fanned out to matching source\n // records in `dispatchDerivations`). Like sources[], these keys enter\n // `_bySource` so the cycle DFS walks the trigger→output edge.\n // #1277 — the INTERMEDIATE of a declared hop is indexed too, so a write\n // that re-points it re-fires the derivation. Without this the hop's whole\n // correctness argument fails: nothing is written to the trigger or source\n // collection when an intermediate moves, so no other path can notice, and\n // every source it used to address is stranded silently. Entering `_bySource`\n // also puts the hop edge into `validate()`'s cycle DFS, which would\n // otherwise be blind to it.\n for (const t of triggers) {\n for (const hop of hopCollections(t.match)) {\n const fromHop = this._bySource.get(hop)\n if (fromHop) { if (!fromHop.includes(reg)) fromHop.push(reg) }\n else this._bySource.set(hop, [reg])\n }\n }\n for (const t of triggers) {\n const fromTrigger = this._bySource.get(t.collection)\n if (fromTrigger) fromTrigger.push(reg)\n else this._bySource.set(t.collection, [reg])\n }\n\n // Rollup: a write to the child `from` collection recomputes\n // the parent (= spec.source = into) at id child[key]. Index under `from`\n // so a child write fires it; spec.source (into) is already indexed above,\n // so a parent write also recomputes its own aggregate (covers the\n // parent-created-after-children case). The from→into edge enters the cycle\n // DFS automatically.\n if (spec.rollup) {\n const fromRollup = this._bySource.get(spec.rollup.from)\n if (fromRollup) fromRollup.push(reg)\n else this._bySource.set(spec.rollup.from, [reg])\n }\n\n for (const key of outputKeys) {\n const output = spec.outputs[key]\n if (!output) continue\n const outputCollection = output.collection\n const arr = this._byOutput.get(outputCollection)\n if (arr) arr.push(reg)\n else this._byOutput.set(outputCollection, [reg])\n }\n }\n\n strategiesForSource(source: string): ReadonlyArray<RegisteredStrategy> {\n return this._bySource.get(source) ?? []\n }\n\n strategiesProducingOutput(collection: string): ReadonlyArray<RegisteredStrategy> {\n return this._byOutput.get(collection) ?? []\n }\n\n /**\n * The #1253-pattern typo guard for match fields (#1249): a misspelt\n * `to`/`from` silently matches nothing forever, so validate against the\n * collection's enumerable field set at the earliest point it exists.\n * `schemaFieldKeys(schema) === undefined` (TS-generic collection,\n * unreadable validator) is DELIBERATELY silent — those fields are real\n * and unenumerable. `configKeys` folds in the collection's other\n * non-schema field declarations (fieldMeta/moneyFields/dictKeyFields/\n * refs/computed); `denormExempt` is derived here from this registry's\n * own strategies rather than taken as a parameter — a field this\n * collection's own derivations write via `denorm` is never a typo.\n */\n validateFieldsFor(\n collectionName: string,\n schema: unknown,\n configKeys: ReadonlyArray<string>,\n viaSources: {\n readonly computed?: Readonly<Record<string, unknown>> | undefined\n readonly viaFields?: Readonly<Record<string, unknown>> | undefined\n } | undefined = undefined,\n ): void {\n const targets = matchTargetFieldNames(viaSources ?? {})\n const virtual = new Set(targets.virtual)\n const shapeKeys = schemaFieldKeys(schema)\n // The two checks have DIFFERENT preconditions, which is why one loop runs\n // both rather than an early return covering both. The typo check needs a\n // readable field list and must stay silent without one — a false \"unknown\n // field\" on a TS-generic collection would be worse than no check. The\n // virtual check needs nothing but the declaration in hand: \"declared, and\n // never stored\" is provable from the declaration alone (#1266).\n if (shapeKeys === undefined && virtual.size === 0) return\n const keys = shapeKeys === undefined ? undefined\n : new Set([...shapeKeys, ...configKeys, ...targets.declared])\n const denormExempt = new Set<string>()\n const regs = new Set([...this._bySource.values()].flat())\n for (const reg of regs) {\n if (reg.spec.source !== collectionName) continue\n for (const out of Object.values(reg.spec.outputs) as Array<{ collection?: string; denorm?: readonly string[] }>) {\n if (out.collection === collectionName) for (const d of out.denorm ?? []) denormExempt.add(d)\n }\n }\n const unknown = (f: string): boolean =>\n keys !== undefined && !keys.has(f) && !denormExempt.has(f)\n for (const reg of regs) {\n const name = reg.spec.name ?? reg.spec.source\n for (const t of reg.triggers) {\n for (const p of t.match) {\n // `to` reads the SOURCE record; `from` reads the WRITTEN record.\n // Both are the stored shape, so both refuse a virtual target.\n if (reg.spec.source === collectionName) {\n if (virtual.has(p.to)) throw new ValidationError(this._virtualMatchMessage(name, collectionName, p.to, 'to'))\n if (unknown(p.to)) {\n throw new ValidationError(\n `derivation \"${name}\": triggerBy match names source field \"${p.to}\", which \"${collectionName}\" does not declare — a typo here silently matches nothing forever`)\n }\n }\n if (t.collection === collectionName && p.from !== 'id') {\n if (virtual.has(p.from)) throw new ValidationError(this._virtualMatchMessage(name, collectionName, p.from, 'from'))\n if (unknown(p.from)) {\n throw new ValidationError(\n `derivation \"${name}\": triggerBy match reads \"${p.from}\" from written \"${collectionName}\" records, which that collection does not declare — a typo here silently matches nothing forever`)\n }\n }\n }\n }\n }\n }\n\n /** #1266 — one message shape for both match sides; see {@link matchTargetFieldNames}. */\n private _virtualMatchMessage(name: string, collectionName: string, field: string, side: 'to' | 'from'): string {\n const where = side === 'to'\n ? `names source field \"${field}\", which \"${collectionName}\"`\n : `reads \"${field}\" from written \"${collectionName}\" records, which that collection`\n return `derivation \"${name}\": triggerBy match ${where} declares as a VIRTUAL computed field — virtual fields are evaluated on read and never stored, so the matcher would read every candidate record and match nothing, forever. Declare it as \\`mode: 'materialized'\\` (stored, indexable) or match on a stored field.`\n }\n\n /**\n * All registered strategies as a flat, deduplicated array.\n * Each strategy is indexed once per source (not once per output key),\n * so iterating `_bySource.values()` naturally yields each strategy\n * exactly once per source — deduplication is handled by flattening\n * the per-source arrays and collecting into a Set by identity.\n *\n * Used by `dumpSchema()` / `describeDerivations()` in the introspection\n * walker to populate the derivations map.\n */\n all(): ReadonlyArray<RegisteredStrategy> {\n const seen = new Set<RegisteredStrategy>()\n for (const strategies of this._bySource.values()) {\n for (const s of strategies) seen.add(s)\n }\n return [...seen]\n }\n\n /**\n * Graph edges for #638 Task 2: one `'derivation'`/`'record'` edge per\n * (non-self-write) output key — target = the output collection (a\n * `WHOLE_RECORD` artifact node), sources = every collection that can\n * trigger this strategy (`source`, `sources[]`, `triggerBy[].collection`,\n * and — for a rollup — `rollup.from`), mirroring EXACTLY the trigger keys\n * `register()` indexes under `_bySource`. The self-write reverse-denorm\n * output (`output.collection === source` with `denorm` declared) is\n * skipped — the SAME condition the old local DFS used; it is not a cycle\n * (see the comment `validate()` used to carry, now on this skip).\n * Rollups ADDITIONALLY get a dedicated `'rollup'`/`'aggregate'` edge\n * targeting the real `rollup.field` on the parent (`source`) — the\n * self-write output above only covers the cycle-DFS skip, not\n * dispatch/taint (Tasks 3/4/6), which need the real field.\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.all()) {\n const spec = reg.spec\n const triggerCollections = [\n spec.source,\n ...(spec.sources ?? []),\n ...(spec.triggerBy ?? []).map((t) => t.collection),\n ...(spec.rollup ? [spec.rollup.from] : []),\n ]\n const sources: FieldRef[] = triggerCollections.map((c) => ({ collection: c, field: WHOLE_RECORD }))\n for (const key of Object.keys(spec.outputs)) {\n const output = spec.outputs[key]\n if (!output) continue\n if (output.shape === 'record' && output.collection === spec.source && output.denorm !== undefined) continue\n out.push({ target: { collection: output.collection, field: WHOLE_RECORD }, sources, kind: 'derivation', grain: 'record' })\n }\n if (spec.rollup) {\n out.push({\n target: { collection: spec.source, field: spec.rollup.field },\n sources: [{ collection: spec.rollup.from, field: WHOLE_RECORD }],\n kind: 'rollup',\n grain: 'aggregate',\n })\n }\n }\n return out\n }\n\n /**\n * Cycle detection, delegated to `ViaGraph.assertAcyclic()` (#638 Task 2 —\n * retires the local DFS). Call after all `register()` calls complete (i.e.\n * at vault open). Throws `DerivationCycleError` on the first cycle found —\n * SAME class/timing as before; the message/path is byte-identical to the\n * pre-#638 shape for a pure record-shape derivation cycle (the\n * `WHOLE_RECORD` artifact suffix is stripped back to a bare collection\n * name before re-throwing).\n *\n * `graph` is the caller's shared per-vault graph, ALREADY carrying this\n * registry's `edges()` (the caller registers them — see `Vault._initDerivations`)\n * — omit it (e.g. this registry's own unit tests) to validate this\n * registry's edges in isolation against a throwaway graph.\n */\n validate(graph?: ViaGraph): void {\n const g = graph ?? new ViaGraph()\n if (!graph) {\n for (const edge of this.edges()) g.registerDerived(edge.target, edge.sources, edge.kind, edge.grain)\n }\n try {\n g.assertAcyclic()\n } catch (e) {\n if (e instanceof DerivationCycleError) throw new DerivationCycleError(e.path.map(stripArtifactSuffix))\n throw e\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAWA,eAAsB,oBACpB,QACA,YAEA,QACA,SACiB;AACjB,QAAM,YAAY,KAAK,UAAU;AAAA,IAC/B;AAAA,IACA,SAAS,CAAC,GAAG,UAAU,EAAE,KAAK;AAAA,IAC9B,QAAQ,OAAO,SAAS;AAAA;AAAA;AAAA;AAAA,IAIxB,GAAI,SAAS,SAAS,EAAE,SAAS,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;AAAA,EAC5D,CAAC;AACD,QAAM,QAAQ,IAAI,YAAY,EAAE,OAAO,SAAS;AAChD,SAAO,UAAU,KAAK;AACxB;;;ACVA,IAA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Ae,KAAK,UAAU,OAAO,WAAW,OAAW;AACnG,YAAI,KAAK,EAAE,QAAQ,EAAE,YAAY,OAAO,YAAY,OAAO,aAAa,GAAG,SAAS,MAAM,cAAc,OAAO,SAAS,CAAC;AAAA,MAC3H;AACA,UAAI,KAAK,QAAQ;AACf,YAAI,KAAK;AAAA,UACP,QAAQ,EAAE,YAAY,KAAK,QAAQ,OAAO,KAAK,OAAO,MAAM;AAAA,UAC5D,SAAS,CAAC,EAAE,YAAY,KAAK,OAAO,MAAM,OAAO,aAAa,CAAC;AAAA,UAC/D,MAAM;AAAA,UACN,OAAO;AAAA,QACT,CAAC;AAAA,MACH;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBA,SAAS,OAAwB;AAC/B,UAAM,IAAI,SAAS,IAAI,SAAS;AAChC,QAAI,CAAC,OAAO;AACV,iBAAW,QAAQ,KAAK,MAAM,EAAG,GAAE,gBAAgB,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM,KAAK,KAAK;AAAA,IACrG;AACA,QAAI;AACF,QAAE,cAAc;AAAA,IAClB,SAAS,GAAG;AACV,UAAI,aAAa,qBAAsB,OAAM,IAAI,qBAAqB,EAAE,KAAK,IAAI,mBAAmB,CAAC;AACrG,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":[]}
@@ -1,23 +1,23 @@
1
1
  import {
2
2
  freezeSnapshotOnly
3
- } from "./chunk-IMQKWR46.js";
3
+ } from "./chunk-SNM7LSYG.js";
4
4
  import {
5
5
  resolveManagedSecret
6
- } from "./chunk-3XJQBBZD.js";
6
+ } from "./chunk-XKBTJGFP.js";
7
7
  import {
8
8
  assertRosterTagValid,
9
9
  createOwnerKeyring,
10
10
  mintRosterTag,
11
- nextRosterEpoch,
12
- requireRosterKey
13
- } from "./chunk-XSPFDUDG.js";
11
+ requireRosterKey,
12
+ stampAuthority
13
+ } from "./chunk-45VHWE4C.js";
14
14
  import {
15
15
  buildRecordEnvelope,
16
16
  wrapKey
17
- } from "./chunk-EZGV6F47.js";
17
+ } from "./chunk-4J3MNVVX.js";
18
18
  import {
19
19
  PermissionDeniedError
20
- } from "./chunk-37EPTBBR.js";
20
+ } from "./chunk-VSUQI5Q6.js";
21
21
 
22
22
  // src/with-party/team/deed.ts
23
23
  var DEED_RECORD_ID = "deed";
@@ -106,7 +106,7 @@ async function liberateVault(vault, opts) {
106
106
  }
107
107
  const rosterKey = requireRosterKey(keyring, "liberateVault");
108
108
  const merged = { ...keyringFile, deks: mergedDeks };
109
- const withEpoch = { ...merged, roster_epoch: nextRosterEpoch(keyringFile.roster_epoch) };
109
+ const withEpoch = stampAuthority(merged, keyringFile.roster_epoch);
110
110
  const mergedFile = { ...withEpoch, roster_tag: await mintRosterTag(withEpoch, rosterKey) };
111
111
  await adapter.put(vaultName, "_keyring", opts.newOwnerId, { ...env, _data: JSON.stringify(mergedFile) });
112
112
  await vault._getLedgerOrNull()?.append({
@@ -135,4 +135,4 @@ export {
135
135
  isDeedVault,
136
136
  liberateVault
137
137
  };
138
- //# sourceMappingURL=chunk-UIYESRD6.js.map
138
+ //# sourceMappingURL=chunk-XITHENBI.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/with-party/team/deed.ts","../src/with-party/custody/liberate.ts"],"sourcesContent":["/**\n * FR-6 — Deed: sealed / hidden-owner provisioning.\n *\n * A **Deed** is a vault owned by a *latent* principal who never\n * authenticates. The owner credential (the random secret that\n * derives `KEK_owner`) is minted machine-side and sealed under a\n * **non-firm** {@link NoydbSealer} — that sealing boundary is\n * the cryptographic *inalienability anchor*: whoever holds the\n * provider (the client / their KMS) is the only party that can ever\n * re-derive `KEK_owner`. A firm-side custodian operates the vault\n * fully but can never reach the owner key — there is deliberately NO\n * firm-controlled fallback.\n *\n * Provisioning reuses the managed-mode seam:\n * - {@link resolveManagedSecret} mints + seals + persists the random\n * secret at `_meta/sealed-secret` (and unseals it on every\n * subsequent open through the same provider).\n * - {@link createOwnerKeyring} derives `KEK_owner` from that\n * secret and writes the `_keyring/<ownerUserId>` file.\n *\n * On top of that, a Deed writes a `_meta/deed` **marker**. The marker\n * is PLAINTEXT metadata — it records WHO the latent owner is and WHICH\n * sealing boundary protects them, so it must be readable without\n * unlocking the vault (a custodian or auditor inspecting the vault must\n * be able to see \"this is a Deed vault, owner = X, sealed under Y\"\n * without any key). The marker itself is therefore never sealed; only\n * the owner *credential* is.\n *\n * @module\n */\n\nimport { buildRecordEnvelope } from '../../capsule/index.js'\nimport type { NoydbStore } from '../../kernel/types.js'\nimport type { UnlockedKeyring } from './keyring.js'\nimport { createOwnerKeyring } from './keyring.js'\nimport type { NoydbSealer } from './managed-secret.js'\nimport { resolveManagedSecret } from './managed-secret.js'\n\n/** Reserved id for the Deed marker under `_meta`. */\nexport const DEED_RECORD_ID = 'deed' as const\n\n/**\n * Plaintext metadata recording a vault's latent-owner Deed. Persisted\n * at `_meta/deed`. Readable without unlocking the vault by design — it\n * carries no secret material, only the identity of the latent owner\n * and the sealing boundary that anchors inalienability.\n */\nexport interface DeedMarker {\n /** The latent owner principal — the user id of the `_keyring/<id>` owner file. */\n readonly ownerUserId: string\n /**\n * The `NoydbSealer.id` the owner credential is sealed under.\n * The inalienability anchor: only the holder of this (non-firm)\n * provider can re-derive `KEK_owner`. Audit metadata — never secret.\n */\n readonly sealedUnder: string\n /** Always `true` for a Deed — the owner never authenticates interactively. */\n readonly latent: true\n /** ISO-8601 timestamp the Deed was issued. */\n readonly issuedAt: string\n /**\n * ISO-8601 timestamp the vault was liberated (a new owner claimed it\n * via the audited Liberate ceremony), if any. Absent until liberation.\n */\n readonly liberatedAt?: string\n}\n\n/**\n * Wire-format payload stored inside the `_meta/deed` envelope. Carries\n * a magic marker for forensics + the {@link DeedMarker} fields. JSON,\n * AES-GCM bypassed (the marker is plaintext metadata by design).\n */\ninterface DeedEnvelopePayload extends DeedMarker {\n readonly _noydb_deed: 1\n}\n\n/**\n * Provision a Deed: a latent owner whose credential is sealed under\n * `sealing` (a NON-firm provider). Mints + seals the owner secret\n * via {@link resolveManagedSecret}, derives the owner keyring via\n * {@link createOwnerKeyring}, then writes the plaintext `_meta/deed`\n * marker. Returns the unlocked owner keyring.\n *\n * The returned keyring is the only in-memory window onto `KEK_owner`\n * for this call; the persistent re-entry point is the sealing provider\n * (re-run {@link resolveManagedSecret} with the same provider to\n * re-resolve the secret, then {@link createOwnerKeyring}/load to\n * unlock — no interactive secret is ever required).\n *\n * There is deliberately no firm-controlled fallback: the marker's\n * `sealedUnder` is the single cryptographic anchor of ownership.\n */\nexport async function createDeedOwner(\n store: NoydbStore,\n vault: string,\n ownerUserId: string,\n sealing: NoydbSealer,\n): Promise<UnlockedKeyring> {\n // 1. Mint + seal + persist the random owner secret under the\n // non-firm provider (writes _meta/sealed-secret).\n const secret = await resolveManagedSecret(store, vault, sealing)\n\n // 2. Derive KEK_owner from the (never-human-seen) secret and\n // write the owner keyring file.\n const keyring = await createOwnerKeyring(store, vault, { userId: ownerUserId, secret: secret })\n\n // 3. Write the plaintext Deed marker. NOT sealed — it is audit\n // metadata that must be readable without unlocking.\n await saveDeedMarker(store, vault, {\n ownerUserId,\n sealedUnder: sealing.id,\n latent: true,\n issuedAt: new Date().toISOString(),\n })\n\n return keyring\n}\n\n/**\n * Read the {@link DeedMarker} from `_meta/deed`, or `null` if the vault\n * has no Deed marker (i.e. it is not a Deed vault). Plaintext read — no\n * unlocking required.\n */\nexport async function loadDeedMarker(\n store: NoydbStore,\n vault: string,\n): Promise<DeedMarker | null> {\n const envelope = await store.get(vault, '_meta', DEED_RECORD_ID)\n if (!envelope) return null\n let payload: unknown\n try {\n payload = JSON.parse(envelope._data ?? '')\n } catch {\n return null\n }\n if (typeof payload !== 'object' || payload === null) return null\n const r = payload as Record<string, unknown>\n if (r._noydb_deed !== 1) return null\n if (\n typeof r.ownerUserId !== 'string'\n || typeof r.sealedUnder !== 'string'\n || r.latent !== true\n || typeof r.issuedAt !== 'string'\n ) {\n return null\n }\n const marker: DeedMarker = {\n ownerUserId: r.ownerUserId,\n sealedUnder: r.sealedUnder,\n latent: true,\n issuedAt: r.issuedAt,\n ...(typeof r.liberatedAt === 'string' ? { liberatedAt: r.liberatedAt } : {}),\n }\n return marker\n}\n\n/** Whether `vault` carries a Deed marker (a sealed/latent owner). */\nexport async function isDeedVault(\n store: NoydbStore,\n vault: string,\n): Promise<boolean> {\n return (await loadDeedMarker(store, vault)) !== null\n}\n\n/**\n * Persist a {@link DeedMarker} at `_meta/deed`. Mirrors\n * `saveSealedSecret`'s envelope shape: a standard\n * {@link EncryptedEnvelope} with AES-GCM bypassed (`_iv: ''`), the\n * payload stored as plaintext JSON in `_data`. The marker is metadata,\n * not a secret — sealing it would defeat its purpose (auditors /\n * custodians must read it without a key).\n *\n * @internal — used by `createDeedOwner` and (later) the Liberate\n * ceremony to stamp `liberatedAt`.\n */\nexport async function saveDeedMarker(\n store: NoydbStore,\n vault: string,\n marker: DeedMarker,\n): Promise<void> {\n const persisted: DeedEnvelopePayload = { _noydb_deed: 1, ...marker }\n const prior = await store.get(vault, '_meta', DEED_RECORD_ID)\n const env = buildRecordEnvelope(\n { collection: '_meta', id: DEED_RECORD_ID, version: (prior?._v ?? 0) + 1 },\n // AES-GCM bypassed — the marker is plaintext audit metadata.\n { iv: '', data: JSON.stringify(persisted) },\n )\n await store.put(vault, '_meta', DEED_RECORD_ID, env)\n}\n","/**\n * `liberateVault` — the audited claim of ownership over a\n * sealed-owner (Deed) vault. The inverse of withdrawal.\n *\n * A **Deed** vault's owner credential is sealed under a non-firm provider, so\n * the firm-side **custodian** (which holds every collection DEK and operates\n * the vault fully) can never reach `KEK_owner`. Liberation is the ONLY route\n * by which a custodian assumes ownership, and it is deliberately a manual,\n * audited ceremony:\n *\n * 1. gate `'liberate-vault'` (fail-closed)\n * 2. caller MUST be the `custodian` (the de-facto authority holding the DEKs)\n * 3. freeze a PRE-liberation EVIDENCE snapshot (hash-pinned in the ledger) —\n * but PRESERVE the live data for the new owner (see the freeze decision\n * below)\n * 4. mint a NEW owner keyring re-wrapping the incumbent DEKs under the new\n * owner's KEK\n * 5. lifecycle ledger `liberation-claimed:<newOwnerId>:<legalBasis>`\n * 6. stamp the `_meta/deed` marker with `liberatedAt`\n *\n * ## Security: the inalienability floor\n *\n * Liberation **mints a new owner from the custodian's DEKs** — it does NOT\n * unseal the original sealed owner. The old sealed-owner credential is left\n * untouched and ORPHANED (its `_keyring/<id>` file remains, its KEK is still\n * sealed under the non-firm provider), never impersonated. The new owner is a\n * DISTINCT principal under a fresh KEK derived from `newOwnerSecret`. This\n * preserves the inalienability floor: the act of claiming ownership is itself\n * auditable and produces a different principal, rather than silently assuming\n * the latent owner's identity.\n *\n * ## Freeze decision: snapshot-only, not freeze-and-delete\n *\n * `freezeAndDeleteClosure` (withdraw-accessible.ts) writes a hash-pinned\n * snapshot and THEN delete-closures the live records — correct for a\n * destructive withdrawal, WRONG for liberation. Liberation transfers\n * operational continuity; it must leave the live data intact for the new\n * owner. We therefore call the snapshot-only core `freezeSnapshotOnly`\n * (factored out of that module; the freeze-AND-delete withdrawal path is\n * unchanged) to pin the evidence snapshot while preserving the records.\n *\n * @module\n */\n\nimport type { Vault } from '../../kernel/vault.js'\nimport type { FactorProofBundle, KeyringFile } from '../../kernel/types.js'\nimport { PermissionDeniedError } from '../../kernel/errors.js'\nimport { wrapKey } from '../../capsule/index.js'\nimport { createOwnerKeyring, requireRosterKey } from '../team/keyring.js'\nimport { mintRosterTag, assertRosterTagValid } from '../team/roster-tag.js'\nimport { nextRosterEpoch } from '../team/roster-epoch.js'\nimport type { FrozenSnapshotRef } from '../../with-audit/portability/withdraw-accessible.js'\nimport { freezeSnapshotOnly } from '../../with-audit/portability/withdraw-accessible.js'\nimport { loadDeedMarker, saveDeedMarker } from '../team/deed.js'\n\nexport interface LiberateOptions {\n /** The id of the new owner principal the custodian mints by claiming ownership. */\n readonly newOwnerId: string\n /** The secret that derives the new owner's KEK (the DEKs are re-wrapped under it). */\n readonly newOwnerSecret: string\n /** Legal/contractual basis recorded in the audit (e.g. 'contractual-handover'). */\n readonly legalBasis: string\n readonly factors?: FactorProofBundle\n}\n\nexport interface LiberateResult {\n /** The hash-pinned pre-liberation evidence snapshot. */\n readonly snapshot: FrozenSnapshotRef\n}\n\n/**\n * Audited claim of ownership over a sealed-owner vault by its custodian. See\n * the module doc for the full ceremony + security rationale.\n */\nexport async function liberateVault(\n vault: Vault,\n opts: LiberateOptions,\n): Promise<LiberateResult> {\n // 1. gate — fail-closed `liberate-vault`.\n await vault.noydb.checkGate(vault.name, 'liberate-vault', opts.factors)\n\n // 2. caller must be the custodian (the de-facto authority holding the DEKs).\n const { name: vaultName, adapter, keyring } = vault._introspectState()\n if (keyring.role !== 'custodian') {\n throw new PermissionDeniedError(\n 'liberation is claimed only by the custodian (the de-facto authority holding the DEKs)',\n )\n }\n\n // Refuse to clobber an existing principal: the new owner must be a FRESH id.\n // (Checked before any side effect so a colliding id never leaves a half-run\n // ceremony — no orphan snapshot, no partial keyring overwrite.)\n const existing = await adapter.get(vaultName, '_keyring', opts.newOwnerId)\n if (existing) {\n throw new PermissionDeniedError(\n `liberateVault: newOwnerId \"${opts.newOwnerId}\" already exists as a principal; choose a fresh id (liberation mints a distinct owner, it never overwrites an existing keyring)`,\n )\n }\n\n // 3. Pre-liberation EVIDENCE snapshot of every operational collection —\n // snapshot-only (live data preserved for the new owner; liberation\n // transfers operational continuity, it does not erase).\n const collections = await listOperationalCollections(vault)\n const snapshot = await freezeSnapshotOnly(vault, collections, { actorUserId: keyring.userId })\n\n // 4. Mint a NEW owner keyring, re-wrapping the incumbent DEKs under the new\n // owner's fresh KEK. The old sealed owner is NOT unsealed — a DISTINCT\n // principal is minted and the original owner credential is left orphaned\n // (inalienability floor). Mirrors adopt-partition.ts's DEK re-wrap.\n const newOwner = await createOwnerKeyring(adapter, vaultName, { userId: opts.newOwnerId, secret: opts.newOwnerSecret })\n if (!newOwner.kek) {\n throw new PermissionDeniedError(\n `new owner keyring for \"${opts.newOwnerId}\" has no KEK to re-wrap the incumbent DEKs under`,\n )\n }\n const env = await adapter.get(vaultName, '_keyring', opts.newOwnerId)\n if (!env) {\n throw new PermissionDeniedError(`new owner keyring for \"${opts.newOwnerId}\" did not persist`)\n }\n const keyringFile = JSON.parse(env._data ?? '') as KeyringFile\n // #1096 — this is a read-BACK of the file `createOwnerKeyring` just wrote, and\n // it is about to be edited and restamped, so the store gets a window to alter\n // it in between. Verified against the NEW owner's own roster key, not the\n // incumbent's: at this instant the file is still stamped under the fresh key\n // minted above (the swap to the incumbent key happens below).\n const mintedRosterKey = requireRosterKey(newOwner, 'liberateVault')\n await assertRosterTagValid(keyringFile, mintedRosterKey, opts.newOwnerId)\n const mergedDeks: Record<string, string> = { ...keyringFile.deks }\n for (const [collection, dek] of keyring.deks) {\n mergedDeks[collection] = await wrapKey(dek, newOwner.kek)\n }\n // #1096 — liberation joins a new owner to an EXISTING vault, so the vault's\n // roster key must stay the incumbent one. `createOwnerKeyring` above minted a\n // fresh roster key (correct for a new vault, wrong here), and the merge loop\n // has just overwritten `_roster` with the incumbent's — so the tag it stamped\n // no longer matches the key in the file. Restamp under the key that actually\n // ends up persisted, or the new owner cannot open the vault they just claimed.\n //\n // Keeping the incumbent key is the substantive half: a fresh one would leave\n // the new owner unable to verify any co-member's roster, and every co-member\n // unable to verify theirs.\n const rosterKey = requireRosterKey(keyring, 'liberateVault')\n const merged: KeyringFile = { ...keyringFile, deks: mergedDeks }\n // #1097 — stamped BEFORE the tag is minted, so it lands inside the\n // authenticated canonical and a store can neither edit nor strip it.\n const withEpoch = { ...merged, roster_epoch: nextRosterEpoch(keyringFile.roster_epoch) }\n const mergedFile: KeyringFile = { ...withEpoch, roster_tag: await mintRosterTag(withEpoch, rosterKey) }\n await adapter.put(vaultName, '_keyring', opts.newOwnerId, { ...env, _data: JSON.stringify(mergedFile) })\n\n // 5. Lifecycle ledger audit (no-op if the history strategy is absent).\n await vault._getLedgerOrNull()?.append({\n op: 'lifecycle', collection: '', id: '', version: 0, actor: opts.newOwnerId, payloadHash: '',\n reason: `liberation-claimed:${opts.newOwnerId}:${opts.legalBasis}`,\n })\n\n // 6. Stamp the Deed marker with `liberatedAt` (if a marker exists).\n const marker = await loadDeedMarker(adapter, vaultName)\n if (marker) {\n await saveDeedMarker(adapter, vaultName, { ...marker, liberatedAt: new Date().toISOString() })\n }\n\n return { snapshot }\n}\n\n/**\n * Enumerate the vault's operational (user-facing) collections — those carried\n * by the caller's keyring DEK map, minus the reserved internal collections\n * (`_*`). These are the collections frozen into the evidence snapshot.\n */\nasync function listOperationalCollections(vault: Vault): Promise<readonly string[]> {\n const { keyring } = vault._introspectState()\n return [...keyring.deks.keys()].filter((c) => !c.startsWith('_'))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuCO,IAAM,iBAAiB;AAqD9B,eAAsB,gBACpB,OACA,OACA,aACA,SAC0B;AAG1B,QAAM,SAAS,MAAM,qBAAqB,OAAO,OAAO,OAAO;AAI/D,QAAM,UAAU,MAAM,mBAAmB,OAAO,OAAO,EAAE,QAAQ,aAAa,OAAe,CAAC;AAI9F,QAAM,eAAe,OAAO,OAAO;AAAA,IACjC;AAAA,IACA,aAAa,QAAQ;AAAA,IACrB,QAAQ;AAAA,IACR,WAAU,oBAAI,KAAK,GAAE,YAAY;AAAA,EACnC,CAAC;AAED,SAAO;AACT;AAOA,eAAsB,eACpB,OACA,OAC4B;AAC5B,QAAM,WAAW,MAAM,MAAM,IAAI,OAAO,SAAS,cAAc;AAC/D,MAAI,CAAC,SAAU,QAAO;AACtB,MAAI;AACJ,MAAI;AACF,cAAU,KAAK,MAAM,SAAS,SAAS,EAAE;AAAA,EAC3C,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MAAI,OAAO,YAAY,YAAY,YAAY,KAAM,QAAO;AAC5D,QAAM,IAAI;AACV,MAAI,EAAE,gBAAgB,EAAG,QAAO;A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B,KAAK,UAAU,IAAI,KAAK,UAAU;AAAA,EAClE,CAAC;AAGD,QAAM,SAAS,MAAM,eAAe,SAAS,SAAS;AACtD,MAAI,QAAQ;AACV,UAAM,eAAe,SAAS,WAAW,EAAE,GAAG,QAAQ,cAAa,oBAAI,KAAK,GAAE,YAAY,EAAE,CAAC;AAAA,EAC/F;AAEA,SAAO,EAAE,SAAS;AACpB;AAOA,eAAe,2BAA2B,OAA0C;AAClF,QAAM,EAAE,QAAQ,IAAI,MAAM,iBAAiB;AAC3C,SAAO,CAAC,GAAG,QAAQ,KAAK,KAAK,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,CAAC;AAClE;","names":[]}
1
+ {"version":3,"sources":["../src/with-party/team/deed.ts","../src/with-party/custody/liberate.ts"],"sourcesContent":["/**\n * FR-6 — Deed: sealed / hidden-owner provisioning.\n *\n * A **Deed** is a vault owned by a *latent* principal who never\n * authenticates. The owner credential (the random secret that\n * derives `KEK_owner`) is minted machine-side and sealed under a\n * **non-firm** {@link NoydbSealer} — that sealing boundary is\n * the cryptographic *inalienability anchor*: whoever holds the\n * provider (the client / their KMS) is the only party that can ever\n * re-derive `KEK_owner`. A firm-side custodian operates the vault\n * fully but can never reach the owner key — there is deliberately NO\n * firm-controlled fallback.\n *\n * Provisioning reuses the managed-mode seam:\n * - {@link resolveManagedSecret} mints + seals + persists the random\n * secret at `_meta/sealed-secret` (and unseals it on every\n * subsequent open through the same provider).\n * - {@link createOwnerKeyring} derives `KEK_owner` from that\n * secret and writes the `_keyring/<ownerUserId>` file.\n *\n * On top of that, a Deed writes a `_meta/deed` **marker**. The marker\n * is PLAINTEXT metadata — it records WHO the latent owner is and WHICH\n * sealing boundary protects them, so it must be readable without\n * unlocking the vault (a custodian or auditor inspecting the vault must\n * be able to see \"this is a Deed vault, owner = X, sealed under Y\"\n * without any key). The marker itself is therefore never sealed; only\n * the owner *credential* is.\n *\n * @module\n */\n\nimport { buildRecordEnvelope } from '../../capsule/index.js'\nimport type { NoydbStore } from '../../kernel/types.js'\nimport type { UnlockedKeyring } from './keyring.js'\nimport { createOwnerKeyring } from './keyring.js'\nimport type { NoydbSealer } from './managed-secret.js'\nimport { resolveManagedSecret } from './managed-secret.js'\n\n/** Reserved id for the Deed marker under `_meta`. */\nexport const DEED_RECORD_ID = 'deed' as const\n\n/**\n * Plaintext metadata recording a vault's latent-owner Deed. Persisted\n * at `_meta/deed`. Readable without unlocking the vault by design — it\n * carries no secret material, only the identity of the latent owner\n * and the sealing boundary that anchors inalienability.\n */\nexport interface DeedMarker {\n /** The latent owner principal — the user id of the `_keyring/<id>` owner file. */\n readonly ownerUserId: string\n /**\n * The `NoydbSealer.id` the owner credential is sealed under.\n * The inalienability anchor: only the holder of this (non-firm)\n * provider can re-derive `KEK_owner`. Audit metadata — never secret.\n */\n readonly sealedUnder: string\n /** Always `true` for a Deed — the owner never authenticates interactively. */\n readonly latent: true\n /** ISO-8601 timestamp the Deed was issued. */\n readonly issuedAt: string\n /**\n * ISO-8601 timestamp the vault was liberated (a new owner claimed it\n * via the audited Liberate ceremony), if any. Absent until liberation.\n */\n readonly liberatedAt?: string\n}\n\n/**\n * Wire-format payload stored inside the `_meta/deed` envelope. Carries\n * a magic marker for forensics + the {@link DeedMarker} fields. JSON,\n * AES-GCM bypassed (the marker is plaintext metadata by design).\n */\ninterface DeedEnvelopePayload extends DeedMarker {\n readonly _noydb_deed: 1\n}\n\n/**\n * Provision a Deed: a latent owner whose credential is sealed under\n * `sealing` (a NON-firm provider). Mints + seals the owner secret\n * via {@link resolveManagedSecret}, derives the owner keyring via\n * {@link createOwnerKeyring}, then writes the plaintext `_meta/deed`\n * marker. Returns the unlocked owner keyring.\n *\n * The returned keyring is the only in-memory window onto `KEK_owner`\n * for this call; the persistent re-entry point is the sealing provider\n * (re-run {@link resolveManagedSecret} with the same provider to\n * re-resolve the secret, then {@link createOwnerKeyring}/load to\n * unlock — no interactive secret is ever required).\n *\n * There is deliberately no firm-controlled fallback: the marker's\n * `sealedUnder` is the single cryptographic anchor of ownership.\n */\nexport async function createDeedOwner(\n store: NoydbStore,\n vault: string,\n ownerUserId: string,\n sealing: NoydbSealer,\n): Promise<UnlockedKeyring> {\n // 1. Mint + seal + persist the random owner secret under the\n // non-firm provider (writes _meta/sealed-secret).\n const secret = await resolveManagedSecret(store, vault, sealing)\n\n // 2. Derive KEK_owner from the (never-human-seen) secret and\n // write the owner keyring file.\n const keyring = await createOwnerKeyring(store, vault, { userId: ownerUserId, secret: secret })\n\n // 3. Write the plaintext Deed marker. NOT sealed — it is audit\n // metadata that must be readable without unlocking.\n await saveDeedMarker(store, vault, {\n ownerUserId,\n sealedUnder: sealing.id,\n latent: true,\n issuedAt: new Date().toISOString(),\n })\n\n return keyring\n}\n\n/**\n * Read the {@link DeedMarker} from `_meta/deed`, or `null` if the vault\n * has no Deed marker (i.e. it is not a Deed vault). Plaintext read — no\n * unlocking required.\n */\nexport async function loadDeedMarker(\n store: NoydbStore,\n vault: string,\n): Promise<DeedMarker | null> {\n const envelope = await store.get(vault, '_meta', DEED_RECORD_ID)\n if (!envelope) return null\n let payload: unknown\n try {\n payload = JSON.parse(envelope._data ?? '')\n } catch {\n return null\n }\n if (typeof payload !== 'object' || payload === null) return null\n const r = payload as Record<string, unknown>\n if (r._noydb_deed !== 1) return null\n if (\n typeof r.ownerUserId !== 'string'\n || typeof r.sealedUnder !== 'string'\n || r.latent !== true\n || typeof r.issuedAt !== 'string'\n ) {\n return null\n }\n const marker: DeedMarker = {\n ownerUserId: r.ownerUserId,\n sealedUnder: r.sealedUnder,\n latent: true,\n issuedAt: r.issuedAt,\n ...(typeof r.liberatedAt === 'string' ? { liberatedAt: r.liberatedAt } : {}),\n }\n return marker\n}\n\n/** Whether `vault` carries a Deed marker (a sealed/latent owner). */\nexport async function isDeedVault(\n store: NoydbStore,\n vault: string,\n): Promise<boolean> {\n return (await loadDeedMarker(store, vault)) !== null\n}\n\n/**\n * Persist a {@link DeedMarker} at `_meta/deed`. Mirrors\n * `saveSealedSecret`'s envelope shape: a standard\n * {@link EncryptedEnvelope} with AES-GCM bypassed (`_iv: ''`), the\n * payload stored as plaintext JSON in `_data`. The marker is metadata,\n * not a secret — sealing it would defeat its purpose (auditors /\n * custodians must read it without a key).\n *\n * @internal — used by `createDeedOwner` and (later) the Liberate\n * ceremony to stamp `liberatedAt`.\n */\nexport async function saveDeedMarker(\n store: NoydbStore,\n vault: string,\n marker: DeedMarker,\n): Promise<void> {\n const persisted: DeedEnvelopePayload = { _noydb_deed: 1, ...marker }\n const prior = await store.get(vault, '_meta', DEED_RECORD_ID)\n const env = buildRecordEnvelope(\n { collection: '_meta', id: DEED_RECORD_ID, version: (prior?._v ?? 0) + 1 },\n // AES-GCM bypassed — the marker is plaintext audit metadata.\n { iv: '', data: JSON.stringify(persisted) },\n )\n await store.put(vault, '_meta', DEED_RECORD_ID, env)\n}\n","/**\n * `liberateVault` — the audited claim of ownership over a\n * sealed-owner (Deed) vault. The inverse of withdrawal.\n *\n * A **Deed** vault's owner credential is sealed under a non-firm provider, so\n * the firm-side **custodian** (which holds every collection DEK and operates\n * the vault fully) can never reach `KEK_owner`. Liberation is the ONLY route\n * by which a custodian assumes ownership, and it is deliberately a manual,\n * audited ceremony:\n *\n * 1. gate `'liberate-vault'` (fail-closed)\n * 2. caller MUST be the `custodian` (the de-facto authority holding the DEKs)\n * 3. freeze a PRE-liberation EVIDENCE snapshot (hash-pinned in the ledger) —\n * but PRESERVE the live data for the new owner (see the freeze decision\n * below)\n * 4. mint a NEW owner keyring re-wrapping the incumbent DEKs under the new\n * owner's KEK\n * 5. lifecycle ledger `liberation-claimed:<newOwnerId>:<legalBasis>`\n * 6. stamp the `_meta/deed` marker with `liberatedAt`\n *\n * ## Security: the inalienability floor\n *\n * Liberation **mints a new owner from the custodian's DEKs** — it does NOT\n * unseal the original sealed owner. The old sealed-owner credential is left\n * untouched and ORPHANED (its `_keyring/<id>` file remains, its KEK is still\n * sealed under the non-firm provider), never impersonated. The new owner is a\n * DISTINCT principal under a fresh KEK derived from `newOwnerSecret`. This\n * preserves the inalienability floor: the act of claiming ownership is itself\n * auditable and produces a different principal, rather than silently assuming\n * the latent owner's identity.\n *\n * ## Freeze decision: snapshot-only, not freeze-and-delete\n *\n * `freezeAndDeleteClosure` (withdraw-accessible.ts) writes a hash-pinned\n * snapshot and THEN delete-closures the live records — correct for a\n * destructive withdrawal, WRONG for liberation. Liberation transfers\n * operational continuity; it must leave the live data intact for the new\n * owner. We therefore call the snapshot-only core `freezeSnapshotOnly`\n * (factored out of that module; the freeze-AND-delete withdrawal path is\n * unchanged) to pin the evidence snapshot while preserving the records.\n *\n * @module\n */\n\nimport type { Vault } from '../../kernel/vault.js'\nimport type { FactorProofBundle, KeyringFile } from '../../kernel/types.js'\nimport { PermissionDeniedError } from '../../kernel/errors.js'\nimport { wrapKey } from '../../capsule/index.js'\nimport { createOwnerKeyring, requireRosterKey } from '../team/keyring.js'\nimport { mintRosterTag, assertRosterTagValid } from '../team/roster-tag.js'\nimport { stampAuthority } from '../team/roster-tag.js'\nimport type { FrozenSnapshotRef } from '../../with-audit/portability/withdraw-accessible.js'\nimport { freezeSnapshotOnly } from '../../with-audit/portability/withdraw-accessible.js'\nimport { loadDeedMarker, saveDeedMarker } from '../team/deed.js'\n\nexport interface LiberateOptions {\n /** The id of the new owner principal the custodian mints by claiming ownership. */\n readonly newOwnerId: string\n /** The secret that derives the new owner's KEK (the DEKs are re-wrapped under it). */\n readonly newOwnerSecret: string\n /** Legal/contractual basis recorded in the audit (e.g. 'contractual-handover'). */\n readonly legalBasis: string\n readonly factors?: FactorProofBundle\n}\n\nexport interface LiberateResult {\n /** The hash-pinned pre-liberation evidence snapshot. */\n readonly snapshot: FrozenSnapshotRef\n}\n\n/**\n * Audited claim of ownership over a sealed-owner vault by its custodian. See\n * the module doc for the full ceremony + security rationale.\n */\nexport async function liberateVault(\n vault: Vault,\n opts: LiberateOptions,\n): Promise<LiberateResult> {\n // 1. gate — fail-closed `liberate-vault`.\n await vault.noydb.checkGate(vault.name, 'liberate-vault', opts.factors)\n\n // 2. caller must be the custodian (the de-facto authority holding the DEKs).\n const { name: vaultName, adapter, keyring } = vault._introspectState()\n if (keyring.role !== 'custodian') {\n throw new PermissionDeniedError(\n 'liberation is claimed only by the custodian (the de-facto authority holding the DEKs)',\n )\n }\n\n // Refuse to clobber an existing principal: the new owner must be a FRESH id.\n // (Checked before any side effect so a colliding id never leaves a half-run\n // ceremony — no orphan snapshot, no partial keyring overwrite.)\n const existing = await adapter.get(vaultName, '_keyring', opts.newOwnerId)\n if (existing) {\n throw new PermissionDeniedError(\n `liberateVault: newOwnerId \"${opts.newOwnerId}\" already exists as a principal; choose a fresh id (liberation mints a distinct owner, it never overwrites an existing keyring)`,\n )\n }\n\n // 3. Pre-liberation EVIDENCE snapshot of every operational collection —\n // snapshot-only (live data preserved for the new owner; liberation\n // transfers operational continuity, it does not erase).\n const collections = await listOperationalCollections(vault)\n const snapshot = await freezeSnapshotOnly(vault, collections, { actorUserId: keyring.userId })\n\n // 4. Mint a NEW owner keyring, re-wrapping the incumbent DEKs under the new\n // owner's fresh KEK. The old sealed owner is NOT unsealed — a DISTINCT\n // principal is minted and the original owner credential is left orphaned\n // (inalienability floor). Mirrors adopt-partition.ts's DEK re-wrap.\n const newOwner = await createOwnerKeyring(adapter, vaultName, { userId: opts.newOwnerId, secret: opts.newOwnerSecret })\n if (!newOwner.kek) {\n throw new PermissionDeniedError(\n `new owner keyring for \"${opts.newOwnerId}\" has no KEK to re-wrap the incumbent DEKs under`,\n )\n }\n const env = await adapter.get(vaultName, '_keyring', opts.newOwnerId)\n if (!env) {\n throw new PermissionDeniedError(`new owner keyring for \"${opts.newOwnerId}\" did not persist`)\n }\n const keyringFile = JSON.parse(env._data ?? '') as KeyringFile\n // #1096 — this is a read-BACK of the file `createOwnerKeyring` just wrote, and\n // it is about to be edited and restamped, so the store gets a window to alter\n // it in between. Verified against the NEW owner's own roster key, not the\n // incumbent's: at this instant the file is still stamped under the fresh key\n // minted above (the swap to the incumbent key happens below).\n const mintedRosterKey = requireRosterKey(newOwner, 'liberateVault')\n await assertRosterTagValid(keyringFile, mintedRosterKey, opts.newOwnerId)\n const mergedDeks: Record<string, string> = { ...keyringFile.deks }\n for (const [collection, dek] of keyring.deks) {\n mergedDeks[collection] = await wrapKey(dek, newOwner.kek)\n }\n // #1096 — liberation joins a new owner to an EXISTING vault, so the vault's\n // roster key must stay the incumbent one. `createOwnerKeyring` above minted a\n // fresh roster key (correct for a new vault, wrong here), and the merge loop\n // has just overwritten `_roster` with the incumbent's — so the tag it stamped\n // no longer matches the key in the file. Restamp under the key that actually\n // ends up persisted, or the new owner cannot open the vault they just claimed.\n //\n // Keeping the incumbent key is the substantive half: a fresh one would leave\n // the new owner unable to verify any co-member's roster, and every co-member\n // unable to verify theirs.\n const rosterKey = requireRosterKey(keyring, 'liberateVault')\n const merged: KeyringFile = { ...keyringFile, deks: mergedDeks }\n // #1097 — stamped BEFORE the tag is minted, so it lands inside the\n // authenticated canonical and a store can neither edit nor strip it.\n const withEpoch = stampAuthority(merged, keyringFile.roster_epoch)\n const mergedFile: KeyringFile = { ...withEpoch, roster_tag: await mintRosterTag(withEpoch, rosterKey) }\n await adapter.put(vaultName, '_keyring', opts.newOwnerId, { ...env, _data: JSON.stringify(mergedFile) })\n\n // 5. Lifecycle ledger audit (no-op if the history strategy is absent).\n await vault._getLedgerOrNull()?.append({\n op: 'lifecycle', collection: '', id: '', version: 0, actor: opts.newOwnerId, payloadHash: '',\n reason: `liberation-claimed:${opts.newOwnerId}:${opts.legalBasis}`,\n })\n\n // 6. Stamp the Deed marker with `liberatedAt` (if a marker exists).\n const marker = await loadDeedMarker(adapter, vaultName)\n if (marker) {\n await saveDeedMarker(adapter, vaultName, { ...marker, liberatedAt: new Date().toISOString() })\n }\n\n return { snapshot }\n}\n\n/**\n * Enumerate the vault's operational (user-facing) collections — those carried\n * by the caller's keyring DEK map, minus the reserved internal collections\n * (`_*`). These are the collections frozen into the evidence snapshot.\n */\nasync function listOperationalCollections(vault: Vault): Promise<readonly string[]> {\n const { keyring } = vault._introspectState()\n return [...keyring.deks.keys()].filter((c) => !c.startsWith('_'))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuCO,IAAM,iBAAiB;AAqD9B,eAAsB,gBACpB,OACA,OACA,aACA,SAC0B;AAG1B,QAAM,SAAS,MAAM,qBAAqB,OAAO,OAAO,OAAO;AAI/D,QAAM,UAAU,MAAM,mBAAmB,OAAO,OAAO,EAAE,QAAQ,aAAa,OAAe,CAAC;AAI9F,QAAM,eAAe,OAAO,OAAO;AAAA,IACjC;AAAA,IACA,aAAa,QAAQ;AAAA,IACrB,QAAQ;AAAA,IACR,WAAU,oBAAI,KAAK,GAAE,YAAY;AAAA,EACnC,CAAC;AAED,SAAO;AACT;AAOA,eAAsB,eACpB,OACA,OAC4B;AAC5B,QAAM,WAAW,MAAM,MAAM,IAAI,OAAO,SAAS,cAAc;AAC/D,MAAI,CAAC,SAAU,QAAO;AACtB,MAAI;AACJ,MAAI;AACF,cAAU,KAAK,MAAM,SAAS,SAAS,EAAE;AAAA,EAC3C,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MAAI,OAAO,YAAY,YAAY,YAAY,KAAM,QAAO;AAC5D,QAAM,IAAI;AACV,MAAI,EAAE,gBAAgB,EAAG,QAAO;AAChC,MACE,OAAO,EAAE,gBAAgB,YACtB,OAAO,EAAE,gBAAgB,YACzB,EAAE,WAAW,QACb,OAAO,EAAE,aAAa,UACzB;AACA,WAAO;AAAA,EACT;AACA,QAAM,SAAqB;AAAA,IACzB,aAAa,EAAE;AAAA,IACf,aAAa,EAAE;AAAA,IACf,QAAQ;AAAA,IACR,UAAU,EAAE;AAAA,IACZ,GAAI,OAAO,EAAE,gBAAgB,WAAW,EAAE,aAAa,EAAE,YAAY,IAAI,CAAC;AAAA,EAC5E;AACA,SAAO;AACT;AAGA,eAAsB,YACpB,OACA,OACkB;AAClB,SAA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WAAW,GAAG,CAAC;AAClE;","names":[]}
@@ -10,7 +10,7 @@ import {
10
10
  importTransferKey,
11
11
  recipientUnwrap,
12
12
  recipientWrap
13
- } from "./chunk-EZGV6F47.js";
13
+ } from "./chunk-4J3MNVVX.js";
14
14
 
15
15
  // src/with-party/team/managed-secret.ts
16
16
  var MemorySealer = class {
@@ -249,4 +249,4 @@ export {
249
249
  loadSealedSecret,
250
250
  resolveManagedSecret
251
251
  };
252
- //# sourceMappingURL=chunk-3XJQBBZD.js.map
252
+ //# sourceMappingURL=chunk-XKBTJGFP.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ValidationError
3
- } from "./chunk-37EPTBBR.js";
3
+ } from "./chunk-VSUQI5Q6.js";
4
4
 
5
5
  // src/with-formula/derivations/with-derivation.ts
6
6
  function withDerivation(spec) {
@@ -149,4 +149,4 @@ export {
149
149
  withDerivation,
150
150
  withRollup
151
151
  };
152
- //# sourceMappingURL=chunk-SMV2HRDU.js.map
152
+ //# sourceMappingURL=chunk-XXNWU5QZ.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ValidationError
3
- } from "./chunk-37EPTBBR.js";
3
+ } from "./chunk-VSUQI5Q6.js";
4
4
 
5
5
  // src/with-formula/overlay-views/with-overlayed-view.ts
6
6
  function withOverlayedView(spec) {
@@ -33,4 +33,4 @@ function withOverlayedView(spec) {
33
33
  export {
34
34
  withOverlayedView
35
35
  };
36
- //# sourceMappingURL=chunk-TZZBXPZK.js.map
36
+ //# sourceMappingURL=chunk-XXQ5XIYY.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  FieldNotQueryableError,
3
3
  ValidationError
4
- } from "./chunk-37EPTBBR.js";
4
+ } from "./chunk-VSUQI5Q6.js";
5
5
 
6
6
  // src/kernel/via/pipeline.ts
7
7
  var ViaPipeline = class _ViaPipeline {
@@ -458,4 +458,4 @@ export {
458
458
  EXPORT_REDACTION_MARKER,
459
459
  exportRedact
460
460
  };
461
- //# sourceMappingURL=chunk-3EWS67C7.js.map
461
+ //# sourceMappingURL=chunk-YFFMPZPY.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  getAtPath
3
- } from "./chunk-OKSTSITU.js";
3
+ } from "./chunk-V55JASXO.js";
4
4
  import {
5
5
  EmbeddingModelMismatchError
6
- } from "./chunk-37EPTBBR.js";
6
+ } from "./chunk-VSUQI5Q6.js";
7
7
 
8
8
  // src/with-lookup/embeddings/descriptor.ts
9
9
  function embeddingSourceText(record, source) {
@@ -290,4 +290,4 @@ export {
290
290
  isVecIdFor,
291
291
  deriveChunkVectors
292
292
  };
293
- //# sourceMappingURL=chunk-M5B2W6YY.js.map
293
+ //# sourceMappingURL=chunk-YKGJ44Z7.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  buildRecordEnvelope
3
- } from "./chunk-EZGV6F47.js";
3
+ } from "./chunk-4J3MNVVX.js";
4
4
  import {
5
5
  ValidationError
6
- } from "./chunk-37EPTBBR.js";
6
+ } from "./chunk-VSUQI5Q6.js";
7
7
 
8
8
  // src/with-party/directory/cover/custom.ts
9
9
  var CUSTOM_KEY_PATTERN = /^[a-z0-9]+([.-][a-z0-9]+)+$/i;
@@ -230,4 +230,4 @@ export {
230
230
  resolveLocale,
231
231
  pickLocale
232
232
  };
233
- //# sourceMappingURL=chunk-5A4345TG.js.map
233
+ //# sourceMappingURL=chunk-YQFBH5ZJ.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  assertTierAccess
3
- } from "./chunk-7XMHMVTS.js";
3
+ } from "./chunk-UHFGK6YA.js";
4
4
  import {
5
5
  dekKey
6
- } from "./chunk-FLPCETP6.js";
6
+ } from "./chunk-RIZTZJX6.js";
7
7
  import {
8
8
  applyRewrappedBody,
9
9
  buildRecordAad,
@@ -16,17 +16,17 @@ import {
16
16
  rewrapBodyToDek,
17
17
  sealedBodyArgs,
18
18
  unwrapCek
19
- } from "./chunk-EZGV6F47.js";
19
+ } from "./chunk-4J3MNVVX.js";
20
20
  import {
21
21
  NOYDB_FORMAT_VERSION
22
- } from "./chunk-SV2PM2OY.js";
22
+ } from "./chunk-2ELOCEXE.js";
23
23
  import {
24
24
  PersistedIndexCompensationError,
25
25
  TierDemoteDeniedError,
26
26
  TiersNotEnabledError,
27
27
  UniqueConstraintError,
28
28
  UnsupportedTierCompositionError
29
- } from "./chunk-37EPTBBR.js";
29
+ } from "./chunk-VSUQI5Q6.js";
30
30
 
31
31
  // src/with-audit/tiers/active.ts
32
32
  function withTiers() {
@@ -55,6 +55,14 @@ function withTiers() {
55
55
  if (!ctx.uniqueKeys) return;
56
56
  const { checkUniqueAcrossTiers: checkUniqueAcrossTiers2 } = await import("./tiers/index.js");
57
57
  return checkUniqueAcrossTiers2(ctx, id, record);
58
+ },
59
+ async refreshDelegations(ctx, now) {
60
+ const { loadActiveDelegations, DELEGATIONS_COLLECTION } = await import("./delegation-ONLM4JFI.js");
61
+ const ids = await ctx.adapter.list(ctx.vault, DELEGATIONS_COLLECTION);
62
+ if (ids.length === 0) return [];
63
+ const delegationsDek = ctx.keyring.deks.get(DELEGATIONS_COLLECTION);
64
+ if (!delegationsDek) return [];
65
+ return loadActiveDelegations(ctx.adapter, ctx.vault, ctx.keyring, delegationsDek, now);
58
66
  }
59
67
  };
60
68
  }
@@ -83,6 +91,14 @@ var NO_TIERS = {
83
91
  // to scan and the tier-0 mirror is already the whole truth. Throwing here
84
92
  // would break plain `put()` on such a collection for no gain.
85
93
  async checkUnique() {
94
+ },
95
+ // ⛔ ALSO not a throw, and for a different reason than `checkUnique` above.
96
+ // "Are there delegations for me?" is a legitimate question on a vault with no
97
+ // tier engine, and its honest answer is none — no engine means no tier DEK
98
+ // was ever minted, so no token could have been issued. Throwing would stop a
99
+ // caller who merely polls for delegations from running without `withTiers()`.
100
+ async refreshDelegations() {
101
+ return [];
86
102
  }
87
103
  };
88
104
 
@@ -480,4 +496,4 @@ export {
480
496
  demote,
481
497
  classifySealedShred
482
498
  };
483
- //# sourceMappingURL=chunk-DHHGL42E.js.map
499
+ //# sourceMappingURL=chunk-Z3ZXVB2Y.js.map