@noy-db/hub 0.6.0-pre.2 → 0.6.0-pre.21

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 (499) hide show
  1. package/CHANGELOG.md +5234 -0
  2. package/codemods/0.4.0-pre.json +699 -0
  3. package/codemods/0.6.0-pre.json +211 -0
  4. package/dist/api-EYNT6KGS.js +20 -0
  5. package/dist/attestation/index.js +19 -19
  6. package/dist/{backup-YYBE5RPC.js → backup-FSC36VWC.js} +36 -18
  7. package/dist/backup-FSC36VWC.js.map +1 -0
  8. package/dist/blobs/index.js +13 -13
  9. package/dist/broker/index.js +12 -12
  10. package/dist/cargo/index.js +33 -33
  11. package/dist/{chunk-35EBKWQU.js → chunk-2LFOMUEA.js} +4 -4
  12. package/dist/{chunk-OF3L2SD6.js → chunk-32B7VCKU.js} +2 -2
  13. package/dist/{chunk-MSWYQLMQ.js → chunk-3B6S6RSI.js} +2 -2
  14. package/dist/{chunk-PJNTR2NV.js → chunk-3ENNPCIW.js} +7 -10
  15. package/dist/chunk-3ENNPCIW.js.map +1 -0
  16. package/dist/{chunk-7F4DBNSP.js → chunk-3O72ZD2E.js} +3 -3
  17. package/dist/{chunk-FNSMZQS4.js → chunk-3PMFMUFX.js} +2 -2
  18. package/dist/{chunk-WQDTCJ6W.js → chunk-45YHJ3GV.js} +11 -3
  19. package/dist/{chunk-WQDTCJ6W.js.map → chunk-45YHJ3GV.js.map} +1 -1
  20. package/dist/{chunk-NIVEDYJZ.js → chunk-4A34KWOU.js} +31 -49
  21. package/dist/chunk-4A34KWOU.js.map +1 -0
  22. package/dist/{chunk-ZJADGNYF.js → chunk-4AOERLTV.js} +1 -1
  23. package/dist/chunk-4AOERLTV.js.map +1 -0
  24. package/dist/{chunk-EDXAQ6JI.js → chunk-4N5Q23KV.js} +87 -34
  25. package/dist/chunk-4N5Q23KV.js.map +1 -0
  26. package/dist/{chunk-VV4NSB7P.js → chunk-4OQZNXQG.js} +15 -24
  27. package/dist/chunk-4OQZNXQG.js.map +1 -0
  28. package/dist/{chunk-FAXZQ5UF.js → chunk-4RAS6HN6.js} +2 -2
  29. package/dist/{chunk-C2OOEM57.js → chunk-4YL2LMXK.js} +92 -35
  30. package/dist/chunk-4YL2LMXK.js.map +1 -0
  31. package/dist/{chunk-EP7VPR7Y.js → chunk-5Q7AJ7DN.js} +11 -8
  32. package/dist/chunk-5Q7AJ7DN.js.map +1 -0
  33. package/dist/{chunk-VMCCGUQB.js → chunk-6JPGVL7X.js} +2 -2
  34. package/dist/{chunk-PRDRGL73.js → chunk-6KTVJ5ZZ.js} +17 -14
  35. package/dist/chunk-6KTVJ5ZZ.js.map +1 -0
  36. package/dist/{chunk-4MC5JRRX.js → chunk-6WO62AJW.js} +14 -15
  37. package/dist/chunk-6WO62AJW.js.map +1 -0
  38. package/dist/{chunk-WLYIROCJ.js → chunk-6YD5SYQS.js} +2 -2
  39. package/dist/{chunk-YAWK6AWF.js → chunk-7KAE7CQ2.js} +2 -2
  40. package/dist/{chunk-MWKDOHEF.js → chunk-7LNE2N2V.js} +17 -10
  41. package/dist/chunk-7LNE2N2V.js.map +1 -0
  42. package/dist/{chunk-5PR33AC4.js → chunk-7PJ3BKHS.js} +20 -17
  43. package/dist/chunk-7PJ3BKHS.js.map +1 -0
  44. package/dist/{chunk-JXIDGFKS.js → chunk-A4TOGAUW.js} +4 -2
  45. package/dist/chunk-A4TOGAUW.js.map +1 -0
  46. package/dist/{chunk-VCETL77O.js → chunk-AU3AUJIZ.js} +27 -7
  47. package/dist/chunk-AU3AUJIZ.js.map +1 -0
  48. package/dist/{chunk-NKH7GSIH.js → chunk-AUPSEJ7O.js} +4 -4
  49. package/dist/{chunk-CCZJJ4I2.js → chunk-B6IYATME.js} +4 -4
  50. package/dist/{chunk-WYZ5MYUA.js → chunk-BAHOV5I5.js} +44 -42
  51. package/dist/chunk-BAHOV5I5.js.map +1 -0
  52. package/dist/{chunk-G5APARUV.js → chunk-BEZDLIDG.js} +13 -15
  53. package/dist/chunk-BEZDLIDG.js.map +1 -0
  54. package/dist/{chunk-ERB6NDDW.js → chunk-CAGI4LLJ.js} +427 -72
  55. package/dist/chunk-CAGI4LLJ.js.map +1 -0
  56. package/dist/{chunk-4UVDI4XE.js → chunk-CLAHBPOI.js} +4 -4
  57. package/dist/{chunk-HNGSV2YC.js → chunk-CWM4GQD2.js} +39 -10
  58. package/dist/chunk-CWM4GQD2.js.map +1 -0
  59. package/dist/{chunk-HVQGCKY4.js → chunk-D3R7Q4QK.js} +2 -2
  60. package/dist/{chunk-I4F6PKUK.js → chunk-DIZ6HM7Q.js} +16 -17
  61. package/dist/chunk-DIZ6HM7Q.js.map +1 -0
  62. package/dist/{chunk-ZNACADFG.js → chunk-DVRZYAGT.js} +4 -4
  63. package/dist/chunk-DVRZYAGT.js.map +1 -0
  64. package/dist/{chunk-P7OG2ETF.js → chunk-DXKLLKME.js} +3 -3
  65. package/dist/{chunk-TDJPS3T2.js → chunk-E5SC6ENM.js} +24 -19
  66. package/dist/chunk-E5SC6ENM.js.map +1 -0
  67. package/dist/{chunk-26JMGSSC.js → chunk-EES37S2V.js} +4 -4
  68. package/dist/chunk-EES37S2V.js.map +1 -0
  69. package/dist/{chunk-JIUVJ4M7.js → chunk-EKEIEJL6.js} +2 -2
  70. package/dist/{chunk-GASWQ3XG.js → chunk-ESKIAXO2.js} +15 -16
  71. package/dist/chunk-ESKIAXO2.js.map +1 -0
  72. package/dist/{chunk-TOAIYQJR.js → chunk-FFSQFH6D.js} +7 -10
  73. package/dist/chunk-FFSQFH6D.js.map +1 -0
  74. package/dist/{chunk-DG27IUVI.js → chunk-FS7NTGCJ.js} +2 -2
  75. package/dist/{chunk-V5KYPBUR.js → chunk-FW7NGYLT.js} +11 -14
  76. package/dist/chunk-FW7NGYLT.js.map +1 -0
  77. package/dist/{chunk-52QYGZHH.js → chunk-GBBDFE6C.js} +2 -2
  78. package/dist/chunk-GBBDFE6C.js.map +1 -0
  79. package/dist/{chunk-HXGUIPQB.js → chunk-GQXFOAYZ.js} +3 -3
  80. package/dist/{chunk-BTVYJWSN.js → chunk-GTHVPVAR.js} +10 -10
  81. package/dist/{chunk-DMQCLZ4Z.js → chunk-GWO2IDAB.js} +2 -2
  82. package/dist/{chunk-6HFM7EIT.js → chunk-H3G4I3PN.js} +2 -2
  83. package/dist/chunk-HK67PX4J.js +27 -0
  84. package/dist/chunk-HK67PX4J.js.map +1 -0
  85. package/dist/{chunk-E7OBCBXS.js → chunk-HQSPF5IY.js} +22 -18
  86. package/dist/chunk-HQSPF5IY.js.map +1 -0
  87. package/dist/{chunk-VJFMXYKP.js → chunk-HR5R5JOM.js} +2 -2
  88. package/dist/{chunk-FDX7OWWI.js → chunk-HYYVT2KZ.js} +2 -2
  89. package/dist/{chunk-JRCYZEHU.js → chunk-I6QKB7MT.js} +2 -2
  90. package/dist/{chunk-MZ5ZFO2D.js → chunk-ICDHUUMQ.js} +84 -112
  91. package/dist/chunk-ICDHUUMQ.js.map +1 -0
  92. package/dist/{chunk-W5W6KHN2.js → chunk-IGNJOJEP.js} +1 -1
  93. package/dist/chunk-IGNJOJEP.js.map +1 -0
  94. package/dist/{chunk-KUDZVJKQ.js → chunk-IJ46VCWD.js} +2 -2
  95. package/dist/{chunk-4HDYQL3J.js → chunk-INMHEMXX.js} +2 -2
  96. package/dist/{chunk-66W5OOCX.js → chunk-JLYQQNY4.js} +52 -65
  97. package/dist/chunk-JLYQQNY4.js.map +1 -0
  98. package/dist/{chunk-UHXCLPGC.js → chunk-JNMTN5D5.js} +2 -2
  99. package/dist/chunk-JNMTN5D5.js.map +1 -0
  100. package/dist/{chunk-I4ZAO7F7.js → chunk-JWMBG5S3.js} +7 -11
  101. package/dist/chunk-JWMBG5S3.js.map +1 -0
  102. package/dist/chunk-KRVS7YWY.js +123 -0
  103. package/dist/chunk-KRVS7YWY.js.map +1 -0
  104. package/dist/{chunk-AR2JDFAE.js → chunk-KV6JM2IA.js} +2 -2
  105. package/dist/{chunk-PVU7LW5L.js → chunk-KX57HODD.js} +6 -6
  106. package/dist/{chunk-PY7CI6L5.js → chunk-LGFTOU27.js} +553 -275
  107. package/dist/chunk-LGFTOU27.js.map +1 -0
  108. package/dist/chunk-LN7P6MZB.js +190 -0
  109. package/dist/chunk-LN7P6MZB.js.map +1 -0
  110. package/dist/{chunk-UIBGXRDD.js → chunk-LX46B56Q.js} +25 -31
  111. package/dist/chunk-LX46B56Q.js.map +1 -0
  112. package/dist/{chunk-CEJWMBXO.js → chunk-LXECF2ZR.js} +2 -2
  113. package/dist/{chunk-7VHY5E3X.js → chunk-MSLPDFK2.js} +7 -7
  114. package/dist/{chunk-I6SDX7WX.js → chunk-MZTUTEHP.js} +16 -22
  115. package/dist/chunk-MZTUTEHP.js.map +1 -0
  116. package/dist/{chunk-VRA4Q7DA.js → chunk-NCCEDL2K.js} +55 -48
  117. package/dist/chunk-NCCEDL2K.js.map +1 -0
  118. package/dist/{chunk-HNHCQ556.js → chunk-NR2SUJ3H.js} +2 -2
  119. package/dist/{chunk-AHLJSVRL.js → chunk-NW4TY6VC.js} +5 -7
  120. package/dist/chunk-NW4TY6VC.js.map +1 -0
  121. package/dist/{chunk-RKKORO4M.js → chunk-O742QBZZ.js} +10 -10
  122. package/dist/chunk-O742QBZZ.js.map +1 -0
  123. package/dist/{chunk-VN45YLWM.js → chunk-OHOKBMTM.js} +343 -132
  124. package/dist/chunk-OHOKBMTM.js.map +1 -0
  125. package/dist/{chunk-W3TVWF6N.js → chunk-OIBEJN5H.js} +2 -2
  126. package/dist/{chunk-QD724WDJ.js → chunk-OMYCSTXL.js} +4 -4
  127. package/dist/{chunk-Z45YRGFO.js → chunk-ONVD6GBY.js} +2 -2
  128. package/dist/{chunk-TAGFGKHP.js → chunk-OTHHO3KI.js} +7 -10
  129. package/dist/chunk-OTHHO3KI.js.map +1 -0
  130. package/dist/{chunk-3737A6EA.js → chunk-P2MR5UNE.js} +75 -18
  131. package/dist/chunk-P2MR5UNE.js.map +1 -0
  132. package/dist/chunk-PENPHA45.js +66 -0
  133. package/dist/chunk-PENPHA45.js.map +1 -0
  134. package/dist/{chunk-3FSX6LDG.js → chunk-PPCOKVFA.js} +8 -3
  135. package/dist/{chunk-3FSX6LDG.js.map → chunk-PPCOKVFA.js.map} +1 -1
  136. package/dist/{chunk-VOQW5LAM.js → chunk-QSIEL6TL.js} +102 -71
  137. package/dist/chunk-QSIEL6TL.js.map +1 -0
  138. package/dist/chunk-RFO4UXKQ.js +201 -0
  139. package/dist/chunk-RFO4UXKQ.js.map +1 -0
  140. package/dist/{chunk-KCQX65FU.js → chunk-RKCRPPNB.js} +3 -3
  141. package/dist/{chunk-7TSYBD3E.js → chunk-RSXQNFGO.js} +2 -2
  142. package/dist/{chunk-SZ2K3MHL.js → chunk-S56VYR4Q.js} +8 -11
  143. package/dist/{chunk-SZ2K3MHL.js.map → chunk-S56VYR4Q.js.map} +1 -1
  144. package/dist/{chunk-7NXHMW6Y.js → chunk-SYS46BL7.js} +2 -2
  145. package/dist/{chunk-55LKVALY.js → chunk-T7IR4N2S.js} +1 -3
  146. package/dist/chunk-T7IR4N2S.js.map +1 -0
  147. package/dist/{chunk-A67356IR.js → chunk-T7JGWTES.js} +33 -8
  148. package/dist/chunk-T7JGWTES.js.map +1 -0
  149. package/dist/{chunk-WHJKIZS7.js → chunk-TDSN2O2V.js} +27 -149
  150. package/dist/chunk-TDSN2O2V.js.map +1 -0
  151. package/dist/{chunk-747LRSOO.js → chunk-TMBSPLUG.js} +2 -2
  152. package/dist/{chunk-LWSJG3LI.js → chunk-TQPASLY4.js} +7 -3
  153. package/dist/chunk-TQPASLY4.js.map +1 -0
  154. package/dist/{chunk-WKPJXWKR.js → chunk-TX5MKAHA.js} +3 -3
  155. package/dist/{chunk-HFQ6LGIO.js → chunk-U27Y4DJZ.js} +12 -10
  156. package/dist/{chunk-HFQ6LGIO.js.map → chunk-U27Y4DJZ.js.map} +1 -1
  157. package/dist/{chunk-E6427JU2.js → chunk-VVSOPRUE.js} +18 -2
  158. package/dist/chunk-VVSOPRUE.js.map +1 -0
  159. package/dist/{chunk-7G6VDWXB.js → chunk-WVE6YKMX.js} +3 -3
  160. package/dist/chunk-WVE6YKMX.js.map +1 -0
  161. package/dist/{chunk-GLKDWWNO.js → chunk-YALD3SST.js} +16 -14
  162. package/dist/chunk-YALD3SST.js.map +1 -0
  163. package/dist/{chunk-NJDQ4YSV.js → chunk-YKXZHUOW.js} +4 -4
  164. package/dist/{chunk-VW6ZZGCG.js → chunk-ZLHHE5XZ.js} +3 -3
  165. package/dist/{chunk-FUHKW252.js → chunk-ZZXLB6AS.js} +2 -2
  166. package/dist/classified/index.js +5 -5
  167. package/dist/{classified-marker-FTOX7Q5L.js → classified-marker-NA6HUV33.js} +3 -3
  168. package/dist/collection-facade-VBM35WAH.js +45 -0
  169. package/dist/{computed-6G5M3UPH.js → computed-GSTLWSY5.js} +3 -3
  170. package/dist/consent/index.js +10 -10
  171. package/dist/cover/index.js +10 -3
  172. package/dist/custody/index.js +11 -11
  173. package/dist/{dead-filter-ENRIOQIE.js → dead-filter-UALP5DJX.js} +2 -2
  174. package/dist/debug/index.js +1 -1
  175. package/dist/{delegation-SSEPLXXO.js → delegation-JLNXM7KH.js} +24 -23
  176. package/dist/delegation-JLNXM7KH.js.map +1 -0
  177. package/dist/derivations/index.js +12 -12
  178. package/dist/derive-YUO3TQYN.js +22 -0
  179. package/dist/directory/index.js +10 -10
  180. package/dist/{dispatch-RE74SH6L.js → dispatch-4ZHLSFZQ.js} +5 -5
  181. package/dist/{dispatch-BDVGYC6X.js → dispatch-77CB75KB.js} +18 -18
  182. package/dist/{enclave-52VUXNRL.js → enclave-O4NOROCJ.js} +27 -9
  183. package/dist/executor-CZDXBXKE.js +29 -0
  184. package/dist/executor-DVJAWN3B.js +9 -0
  185. package/dist/executor-VRLG4TQJ.js +9 -0
  186. package/dist/export-accessible-UXSMG7AB.js +23 -0
  187. package/dist/extract-partition-TVY7AMKH.js +38 -0
  188. package/dist/{fanout-sidecar-DTBIDOWF.js → fanout-sidecar-NLQ7QAYW.js} +18 -27
  189. package/dist/fanout-sidecar-NLQ7QAYW.js.map +1 -0
  190. package/dist/find-WSARMJBW.js +11 -0
  191. package/dist/forget/index.js +9 -9
  192. package/dist/guards/index.js +7 -7
  193. package/dist/history/index.js +23 -20
  194. package/dist/history/index.js.map +1 -1
  195. package/dist/i18n/index.js +14 -14
  196. package/dist/index.d.ts +33 -15
  197. package/dist/index.js +187 -191
  198. package/dist/index.js.map +1 -1
  199. package/dist/indexing/index.js +2 -2
  200. package/dist/introspection/index.js +11 -11
  201. package/dist/issue-3JNJNPT3.js +19 -0
  202. package/dist/kernel/constants.d.ts +18 -0
  203. package/dist/kernel/enclave/crypto.d.ts +24 -4
  204. package/dist/kernel/enclave/index.d.ts +9 -2
  205. package/dist/kernel/enclave/record-aad.d.ts +131 -0
  206. package/dist/kernel/enclave/record-envelope.d.ts +76 -0
  207. package/dist/kernel/enclave/record-keys/envelope-body.d.ts +34 -2
  208. package/dist/kernel/enclave/record-keys/lifecycle.d.ts +22 -5
  209. package/dist/kernel/enclave/record-keys/record-codec.d.ts +47 -14
  210. package/dist/kernel/enclave/record-keys/rekey-blob.d.ts +88 -0
  211. package/dist/kernel/enclave/record-keys/rekey.d.ts +68 -0
  212. package/dist/kernel/enclave/record-keys/tombstone.d.ts +3 -2
  213. package/dist/kernel/errors.d.ts +71 -12
  214. package/dist/kernel/merge-authority.d.ts +25 -0
  215. package/dist/kernel/noydb.d.ts +27 -4
  216. package/dist/kernel/query/builder.d.ts +15 -2
  217. package/dist/kernel/query/join.d.ts +27 -0
  218. package/dist/kernel/sync-policy.d.ts +0 -2
  219. package/dist/kernel/tier-visibility.d.ts +15 -0
  220. package/dist/kernel/types.d.ts +145 -12
  221. package/dist/kernel/vault.d.ts +22 -18
  222. package/dist/kernel/via/index.d.ts +11 -2
  223. package/dist/{ledger-4WJL66BW.js → ledger-MVPNG5OS.js} +11 -11
  224. package/dist/liberate-4LOJOLDT.js +24 -0
  225. package/dist/{link-set-N4ZPV6E6.js → link-set-3POMQR3I.js} +11 -11
  226. package/dist/{managed-secret-OTHS64IF.js → managed-secret-IARIJJ7Q.js} +11 -3
  227. package/dist/materialized-views/index.js +22 -21
  228. package/dist/migrate-cek-XM2ETTZW.js +19 -0
  229. package/dist/migrate-cek-XM2ETTZW.js.map +1 -0
  230. package/dist/money/index.js +12 -8
  231. package/dist/noydb-IRILUDED.js +84 -0
  232. package/dist/overlay-views/index.js +4 -4
  233. package/dist/periods/index.js +22 -12
  234. package/dist/pod/index.js +75 -86
  235. package/dist/pod-handle-MELERCKU.js +41 -0
  236. package/dist/pod-handle-MELERCKU.js.map +1 -0
  237. package/dist/policy/index.js +11 -4
  238. package/dist/port/to/index.d.ts +4 -4
  239. package/dist/port/to/locator.d.ts +54 -8
  240. package/dist/port/with/i18n-strategy.d.ts +4 -1
  241. package/dist/port/with/lookup-strategy.d.ts +4 -1
  242. package/dist/port/with/merge-authority.d.ts +52 -0
  243. package/dist/port/with/service-bus.d.ts +0 -4
  244. package/dist/port/with/strategies.d.ts +2 -0
  245. package/dist/port/with/team-strategy.d.ts +5 -1
  246. package/dist/portability/index.js +8 -8
  247. package/dist/{post-register-ZAG2CAIY.js → post-register-Z5T7FY45.js} +6 -6
  248. package/dist/query/index.js +3 -3
  249. package/dist/reduce/index.js +4 -4
  250. package/dist/register-UZ37QPDB.js +32 -0
  251. package/dist/registry-ETJNA7PO.js +9 -0
  252. package/dist/registry-F7U6KSLX.js +9 -0
  253. package/dist/registry-L4ELKX6C.js +18 -0
  254. package/dist/registry-SDT5LIGO.js +19 -0
  255. package/dist/request-withdrawal-PVFEYX57.js +31 -0
  256. package/dist/{reveal-CMOJY4VO.js → reveal-DQ2E3QAZ.js} +6 -6
  257. package/dist/revoke-YXY6SHUH.js +24 -0
  258. package/dist/satellites/index.js +1 -1
  259. package/dist/schema-update/index.js +2 -2
  260. package/dist/sealed-record/index.js +20 -13
  261. package/dist/sealed-record/index.js.map +1 -1
  262. package/dist/search/index.js +4 -4
  263. package/dist/{seed-UK4QRIUN.js → seed-DZ4ORU5N.js} +19 -22
  264. package/dist/seed-DZ4ORU5N.js.map +1 -0
  265. package/dist/sequence/index.js +9 -9
  266. package/dist/session/index.js +10 -10
  267. package/dist/shadow/index.js +2 -2
  268. package/dist/share-link/index.js +1 -1
  269. package/dist/signer-Q7XQBMPA.js +25 -0
  270. package/dist/snapshots/index.js +10 -10
  271. package/dist/snapshots/index.js.map +1 -1
  272. package/dist/{stale-ZWXSOWJI.js → stale-NI7SAXAZ.js} +10 -10
  273. package/dist/storage-3VNGSHXS.js +23 -0
  274. package/dist/{store-coordination-provider-PB6QZ57W.js → store-coordination-provider-TYKNR3OU.js} +18 -12
  275. package/dist/store-coordination-provider-TYKNR3OU.js.map +1 -0
  276. package/dist/sync/index.js +11 -11
  277. package/dist/team/index.js +15 -14
  278. package/dist/tiers/index.js +11 -10
  279. package/dist/to/index.js +17 -9
  280. package/dist/to/index.js.map +1 -1
  281. package/dist/transactions/index.js +4 -4
  282. package/dist/{ulid-PTAIMDG4.js → ulid-VQW6ERQN.js} +2 -2
  283. package/dist/util/index.js +1 -1
  284. package/dist/vault-head/index.js +115 -0
  285. package/dist/vault-head/index.js.map +1 -0
  286. package/dist/{verify-RO5RTZOJ.js → verify-6J2YLKSO.js} +5 -5
  287. package/dist/via/lookup/handle.d.ts +4 -1
  288. package/dist/via/money/exact.d.ts +44 -0
  289. package/dist/via/money/index.d.ts +2 -0
  290. package/dist/via/money/normalize.d.ts +20 -0
  291. package/dist/walk-WRA7RAPY.js +21 -0
  292. package/dist/with-audit/guards/immutable-guard.d.ts +14 -0
  293. package/dist/with-audit/periods/active.d.ts +28 -1
  294. package/dist/with-audit/periods/index.d.ts +4 -2
  295. package/dist/with-audit/periods/periods.d.ts +161 -6
  296. package/dist/with-audit/periods/strategy.d.ts +14 -5
  297. package/dist/with-audit/periods/vault-facade.d.ts +89 -10
  298. package/dist/with-audit/periods/window.d.ts +10 -0
  299. package/dist/with-audit/sealed-record/index.d.ts +13 -0
  300. package/dist/with-audit/tiers/index.d.ts +17 -2
  301. package/dist/with-cargo/adopt-partition.d.ts +1 -1
  302. package/dist/with-cargo/extract-partition.d.ts +1 -1
  303. package/dist/with-cargo/index.d.ts +2 -2
  304. package/dist/with-commit/history/history.d.ts +26 -0
  305. package/dist/with-commit/history/index.d.ts +2 -1
  306. package/dist/with-commit/history/ledger/store.d.ts +7 -1
  307. package/dist/with-commit/history/strategy.d.ts +11 -1
  308. package/dist/with-commit/numbering/index.d.ts +0 -5
  309. package/dist/with-commit/vault-head/active.d.ts +2 -0
  310. package/dist/with-commit/vault-head/head.d.ts +28 -0
  311. package/dist/with-commit/vault-head/index.d.ts +10 -0
  312. package/dist/with-commit/vault-head/strategy.d.ts +127 -0
  313. package/dist/with-commit/vault-head/verify.d.ts +90 -0
  314. package/dist/with-formula/materialized-views/types.d.ts +52 -0
  315. package/dist/with-party/directory/cover/storage.d.ts +0 -8
  316. package/dist/with-party/directory/storage.d.ts +0 -11
  317. package/dist/with-party/directory/visibility.d.ts +0 -21
  318. package/dist/with-party/policy/storage.d.ts +0 -10
  319. package/dist/with-party/team/index.d.ts +1 -1
  320. package/dist/with-party/team/keyring.d.ts +149 -3
  321. package/dist/with-party/team/noydb-facade.d.ts +5 -1
  322. package/dist/with-party/team/roster-tag.d.ts +101 -0
  323. package/dist/with-party/team/tiers.d.ts +2 -1
  324. package/dist/with-pod/format.d.ts +10 -12
  325. package/dist/with-pod/index.d.ts +10 -10
  326. package/dist/with-pod/open.d.ts +2 -2
  327. package/dist/with-pod/pod-handle.d.ts +19 -0
  328. package/dist/with-pod/pod-store.d.ts +0 -8
  329. package/dist/with-pod/{bundle.d.ts → pod.d.ts} +26 -19
  330. package/dist/with-pod/ulid.d.ts +1 -1
  331. package/dist/with-shape/blobs/blob-set.d.ts +2 -2
  332. package/dist/with-shape/introspection/index.d.ts +1 -0
  333. package/dist/with-sync/engine.d.ts +54 -5
  334. package/dist/with-sync/strategy.d.ts +3 -0
  335. package/dist/withdraw-accessible-4JTDFRFZ.js +28 -0
  336. package/package.json +13 -5
  337. package/dist/api-WVY3H3YH.js +0 -20
  338. package/dist/backup-YYBE5RPC.js.map +0 -1
  339. package/dist/bundle-handle-JEUWU2SJ.js +0 -36
  340. package/dist/bundle-handle-JEUWU2SJ.js.map +0 -1
  341. package/dist/chunk-26JMGSSC.js.map +0 -1
  342. package/dist/chunk-3737A6EA.js.map +0 -1
  343. package/dist/chunk-4MC5JRRX.js.map +0 -1
  344. package/dist/chunk-52QYGZHH.js.map +0 -1
  345. package/dist/chunk-55LKVALY.js.map +0 -1
  346. package/dist/chunk-5PR33AC4.js.map +0 -1
  347. package/dist/chunk-66W5OOCX.js.map +0 -1
  348. package/dist/chunk-7G6VDWXB.js.map +0 -1
  349. package/dist/chunk-A67356IR.js.map +0 -1
  350. package/dist/chunk-AFHQATY4.js +0 -47
  351. package/dist/chunk-AFHQATY4.js.map +0 -1
  352. package/dist/chunk-AHLJSVRL.js.map +0 -1
  353. package/dist/chunk-C2OOEM57.js.map +0 -1
  354. package/dist/chunk-DIMKRG2E.js +0 -131
  355. package/dist/chunk-DIMKRG2E.js.map +0 -1
  356. package/dist/chunk-E6427JU2.js.map +0 -1
  357. package/dist/chunk-E7OBCBXS.js.map +0 -1
  358. package/dist/chunk-EDXAQ6JI.js.map +0 -1
  359. package/dist/chunk-EP7VPR7Y.js.map +0 -1
  360. package/dist/chunk-ERB6NDDW.js.map +0 -1
  361. package/dist/chunk-G5APARUV.js.map +0 -1
  362. package/dist/chunk-GASWQ3XG.js.map +0 -1
  363. package/dist/chunk-GLKDWWNO.js.map +0 -1
  364. package/dist/chunk-HNGSV2YC.js.map +0 -1
  365. package/dist/chunk-I4F6PKUK.js.map +0 -1
  366. package/dist/chunk-I4ZAO7F7.js.map +0 -1
  367. package/dist/chunk-I6SDX7WX.js.map +0 -1
  368. package/dist/chunk-JXIDGFKS.js.map +0 -1
  369. package/dist/chunk-LWSJG3LI.js.map +0 -1
  370. package/dist/chunk-MWKDOHEF.js.map +0 -1
  371. package/dist/chunk-MZ5ZFO2D.js.map +0 -1
  372. package/dist/chunk-NIVEDYJZ.js.map +0 -1
  373. package/dist/chunk-NWCGDAV6.js +0 -45
  374. package/dist/chunk-NWCGDAV6.js.map +0 -1
  375. package/dist/chunk-PJNTR2NV.js.map +0 -1
  376. package/dist/chunk-PRDRGL73.js.map +0 -1
  377. package/dist/chunk-PY7CI6L5.js.map +0 -1
  378. package/dist/chunk-RKKORO4M.js.map +0 -1
  379. package/dist/chunk-TAGFGKHP.js.map +0 -1
  380. package/dist/chunk-TDJPS3T2.js.map +0 -1
  381. package/dist/chunk-TOAIYQJR.js.map +0 -1
  382. package/dist/chunk-UHXCLPGC.js.map +0 -1
  383. package/dist/chunk-UIBGXRDD.js.map +0 -1
  384. package/dist/chunk-V5KYPBUR.js.map +0 -1
  385. package/dist/chunk-VCETL77O.js.map +0 -1
  386. package/dist/chunk-VN45YLWM.js.map +0 -1
  387. package/dist/chunk-VOQW5LAM.js.map +0 -1
  388. package/dist/chunk-VRA4Q7DA.js.map +0 -1
  389. package/dist/chunk-VV4NSB7P.js.map +0 -1
  390. package/dist/chunk-W5W6KHN2.js.map +0 -1
  391. package/dist/chunk-WHJKIZS7.js.map +0 -1
  392. package/dist/chunk-WYZ5MYUA.js.map +0 -1
  393. package/dist/chunk-ZJADGNYF.js.map +0 -1
  394. package/dist/chunk-ZNACADFG.js.map +0 -1
  395. package/dist/collection-facade-QN5ULWYC.js +0 -45
  396. package/dist/delegation-SSEPLXXO.js.map +0 -1
  397. package/dist/derive-6V3PIZF7.js +0 -22
  398. package/dist/executor-CYJQLKKI.js +0 -9
  399. package/dist/executor-FHHLXO4Y.js +0 -28
  400. package/dist/executor-S4QIKEHW.js +0 -9
  401. package/dist/export-accessible-PE5AYKZR.js +0 -23
  402. package/dist/extract-partition-X2L26O6A.js +0 -38
  403. package/dist/fanout-sidecar-DTBIDOWF.js.map +0 -1
  404. package/dist/find-RBBYKXI7.js +0 -11
  405. package/dist/issue-RNU55YOF.js +0 -19
  406. package/dist/liberate-PX4CAT5V.js +0 -24
  407. package/dist/noydb-YPSEGK32.js +0 -83
  408. package/dist/register-TMD6YRCX.js +0 -32
  409. package/dist/registry-CZVINVQH.js +0 -9
  410. package/dist/registry-FVLDWQKT.js +0 -18
  411. package/dist/registry-IKUR2MXD.js +0 -9
  412. package/dist/registry-JET4HBLY.js +0 -19
  413. package/dist/request-withdrawal-RH55LNZL.js +0 -31
  414. package/dist/revoke-R5TBYVA6.js +0 -24
  415. package/dist/seed-UK4QRIUN.js.map +0 -1
  416. package/dist/signer-AGALOXOO.js +0 -25
  417. package/dist/storage-N7LB275C.js +0 -23
  418. package/dist/store-coordination-provider-PB6QZ57W.js.map +0 -1
  419. package/dist/walk-OCUHCYJ6.js +0 -21
  420. package/dist/with-pod/bundle-handle.d.ts +0 -9
  421. package/dist/withdraw-accessible-QQNWM5BO.js +0 -28
  422. /package/dist/{api-WVY3H3YH.js.map → api-EYNT6KGS.js.map} +0 -0
  423. /package/dist/{chunk-35EBKWQU.js.map → chunk-2LFOMUEA.js.map} +0 -0
  424. /package/dist/{chunk-OF3L2SD6.js.map → chunk-32B7VCKU.js.map} +0 -0
  425. /package/dist/{chunk-MSWYQLMQ.js.map → chunk-3B6S6RSI.js.map} +0 -0
  426. /package/dist/{chunk-7F4DBNSP.js.map → chunk-3O72ZD2E.js.map} +0 -0
  427. /package/dist/{chunk-FNSMZQS4.js.map → chunk-3PMFMUFX.js.map} +0 -0
  428. /package/dist/{chunk-FAXZQ5UF.js.map → chunk-4RAS6HN6.js.map} +0 -0
  429. /package/dist/{chunk-VMCCGUQB.js.map → chunk-6JPGVL7X.js.map} +0 -0
  430. /package/dist/{chunk-WLYIROCJ.js.map → chunk-6YD5SYQS.js.map} +0 -0
  431. /package/dist/{chunk-YAWK6AWF.js.map → chunk-7KAE7CQ2.js.map} +0 -0
  432. /package/dist/{chunk-NKH7GSIH.js.map → chunk-AUPSEJ7O.js.map} +0 -0
  433. /package/dist/{chunk-CCZJJ4I2.js.map → chunk-B6IYATME.js.map} +0 -0
  434. /package/dist/{chunk-4UVDI4XE.js.map → chunk-CLAHBPOI.js.map} +0 -0
  435. /package/dist/{chunk-HVQGCKY4.js.map → chunk-D3R7Q4QK.js.map} +0 -0
  436. /package/dist/{chunk-P7OG2ETF.js.map → chunk-DXKLLKME.js.map} +0 -0
  437. /package/dist/{chunk-JIUVJ4M7.js.map → chunk-EKEIEJL6.js.map} +0 -0
  438. /package/dist/{chunk-DG27IUVI.js.map → chunk-FS7NTGCJ.js.map} +0 -0
  439. /package/dist/{chunk-HXGUIPQB.js.map → chunk-GQXFOAYZ.js.map} +0 -0
  440. /package/dist/{chunk-BTVYJWSN.js.map → chunk-GTHVPVAR.js.map} +0 -0
  441. /package/dist/{chunk-DMQCLZ4Z.js.map → chunk-GWO2IDAB.js.map} +0 -0
  442. /package/dist/{chunk-6HFM7EIT.js.map → chunk-H3G4I3PN.js.map} +0 -0
  443. /package/dist/{chunk-VJFMXYKP.js.map → chunk-HR5R5JOM.js.map} +0 -0
  444. /package/dist/{chunk-FDX7OWWI.js.map → chunk-HYYVT2KZ.js.map} +0 -0
  445. /package/dist/{chunk-JRCYZEHU.js.map → chunk-I6QKB7MT.js.map} +0 -0
  446. /package/dist/{chunk-KUDZVJKQ.js.map → chunk-IJ46VCWD.js.map} +0 -0
  447. /package/dist/{chunk-4HDYQL3J.js.map → chunk-INMHEMXX.js.map} +0 -0
  448. /package/dist/{chunk-AR2JDFAE.js.map → chunk-KV6JM2IA.js.map} +0 -0
  449. /package/dist/{chunk-PVU7LW5L.js.map → chunk-KX57HODD.js.map} +0 -0
  450. /package/dist/{chunk-CEJWMBXO.js.map → chunk-LXECF2ZR.js.map} +0 -0
  451. /package/dist/{chunk-7VHY5E3X.js.map → chunk-MSLPDFK2.js.map} +0 -0
  452. /package/dist/{chunk-HNHCQ556.js.map → chunk-NR2SUJ3H.js.map} +0 -0
  453. /package/dist/{chunk-W3TVWF6N.js.map → chunk-OIBEJN5H.js.map} +0 -0
  454. /package/dist/{chunk-QD724WDJ.js.map → chunk-OMYCSTXL.js.map} +0 -0
  455. /package/dist/{chunk-Z45YRGFO.js.map → chunk-ONVD6GBY.js.map} +0 -0
  456. /package/dist/{chunk-KCQX65FU.js.map → chunk-RKCRPPNB.js.map} +0 -0
  457. /package/dist/{chunk-7TSYBD3E.js.map → chunk-RSXQNFGO.js.map} +0 -0
  458. /package/dist/{chunk-7NXHMW6Y.js.map → chunk-SYS46BL7.js.map} +0 -0
  459. /package/dist/{chunk-747LRSOO.js.map → chunk-TMBSPLUG.js.map} +0 -0
  460. /package/dist/{chunk-WKPJXWKR.js.map → chunk-TX5MKAHA.js.map} +0 -0
  461. /package/dist/{chunk-NJDQ4YSV.js.map → chunk-YKXZHUOW.js.map} +0 -0
  462. /package/dist/{chunk-VW6ZZGCG.js.map → chunk-ZLHHE5XZ.js.map} +0 -0
  463. /package/dist/{chunk-FUHKW252.js.map → chunk-ZZXLB6AS.js.map} +0 -0
  464. /package/dist/{classified-marker-FTOX7Q5L.js.map → classified-marker-NA6HUV33.js.map} +0 -0
  465. /package/dist/{collection-facade-QN5ULWYC.js.map → collection-facade-VBM35WAH.js.map} +0 -0
  466. /package/dist/{computed-6G5M3UPH.js.map → computed-GSTLWSY5.js.map} +0 -0
  467. /package/dist/{dead-filter-ENRIOQIE.js.map → dead-filter-UALP5DJX.js.map} +0 -0
  468. /package/dist/{derive-6V3PIZF7.js.map → derive-YUO3TQYN.js.map} +0 -0
  469. /package/dist/{dispatch-RE74SH6L.js.map → dispatch-4ZHLSFZQ.js.map} +0 -0
  470. /package/dist/{dispatch-BDVGYC6X.js.map → dispatch-77CB75KB.js.map} +0 -0
  471. /package/dist/{enclave-52VUXNRL.js.map → enclave-O4NOROCJ.js.map} +0 -0
  472. /package/dist/{executor-CYJQLKKI.js.map → executor-CZDXBXKE.js.map} +0 -0
  473. /package/dist/{executor-FHHLXO4Y.js.map → executor-DVJAWN3B.js.map} +0 -0
  474. /package/dist/{executor-S4QIKEHW.js.map → executor-VRLG4TQJ.js.map} +0 -0
  475. /package/dist/{export-accessible-PE5AYKZR.js.map → export-accessible-UXSMG7AB.js.map} +0 -0
  476. /package/dist/{extract-partition-X2L26O6A.js.map → extract-partition-TVY7AMKH.js.map} +0 -0
  477. /package/dist/{find-RBBYKXI7.js.map → find-WSARMJBW.js.map} +0 -0
  478. /package/dist/{issue-RNU55YOF.js.map → issue-3JNJNPT3.js.map} +0 -0
  479. /package/dist/{ledger-4WJL66BW.js.map → ledger-MVPNG5OS.js.map} +0 -0
  480. /package/dist/{liberate-PX4CAT5V.js.map → liberate-4LOJOLDT.js.map} +0 -0
  481. /package/dist/{link-set-N4ZPV6E6.js.map → link-set-3POMQR3I.js.map} +0 -0
  482. /package/dist/{managed-secret-OTHS64IF.js.map → managed-secret-IARIJJ7Q.js.map} +0 -0
  483. /package/dist/{noydb-YPSEGK32.js.map → noydb-IRILUDED.js.map} +0 -0
  484. /package/dist/{post-register-ZAG2CAIY.js.map → post-register-Z5T7FY45.js.map} +0 -0
  485. /package/dist/{register-TMD6YRCX.js.map → register-UZ37QPDB.js.map} +0 -0
  486. /package/dist/{registry-CZVINVQH.js.map → registry-ETJNA7PO.js.map} +0 -0
  487. /package/dist/{registry-FVLDWQKT.js.map → registry-F7U6KSLX.js.map} +0 -0
  488. /package/dist/{registry-IKUR2MXD.js.map → registry-L4ELKX6C.js.map} +0 -0
  489. /package/dist/{registry-JET4HBLY.js.map → registry-SDT5LIGO.js.map} +0 -0
  490. /package/dist/{request-withdrawal-RH55LNZL.js.map → request-withdrawal-PVFEYX57.js.map} +0 -0
  491. /package/dist/{reveal-CMOJY4VO.js.map → reveal-DQ2E3QAZ.js.map} +0 -0
  492. /package/dist/{revoke-R5TBYVA6.js.map → revoke-YXY6SHUH.js.map} +0 -0
  493. /package/dist/{signer-AGALOXOO.js.map → signer-Q7XQBMPA.js.map} +0 -0
  494. /package/dist/{stale-ZWXSOWJI.js.map → stale-NI7SAXAZ.js.map} +0 -0
  495. /package/dist/{storage-N7LB275C.js.map → storage-3VNGSHXS.js.map} +0 -0
  496. /package/dist/{ulid-PTAIMDG4.js.map → ulid-VQW6ERQN.js.map} +0 -0
  497. /package/dist/{verify-RO5RTZOJ.js.map → verify-6J2YLKSO.js.map} +0 -0
  498. /package/dist/{walk-OCUHCYJ6.js.map → walk-WRA7RAPY.js.map} +0 -0
  499. /package/dist/{withdraw-accessible-QQNWM5BO.js.map → withdraw-accessible-4JTDFRFZ.js.map} +0 -0
@@ -146,7 +146,7 @@
146
146
  */
147
147
  import type { NoydbStore, EncryptedEnvelope } from '../../kernel/types.js';
148
148
  import type { LedgerStore } from '../../with-commit/history/ledger/index.js';
149
- export { PERIODS_COLLECTION, PERIOD_FREEZES_COLLECTION, PERIOD_ARCHIVES_COLLECTION, PERIOD_TARGET_PURGES_COLLECTION, periodExclusiveUpperBound, } from './window.js';
149
+ export { PERIODS_COLLECTION, PERIOD_FREEZES_COLLECTION, PERIOD_ARCHIVES_COLLECTION, PERIOD_TARGET_PURGES_COLLECTION, PERIOD_REOPENS_COLLECTION, periodExclusiveUpperBound, } from './window.js';
150
150
  /**
151
151
  * Companion record recording that a closed period was frozen (its delete
152
152
  * markers physically purged). Stored in {@link PERIOD_FREEZES_COLLECTION},
@@ -177,6 +177,73 @@ export interface TargetPurgeCount {
177
177
  readonly role: 'backup' | 'archive';
178
178
  readonly purgedCount: number;
179
179
  }
180
+ /**
181
+ * One entry in a period's append-only reopen/reclose log (#1022).
182
+ *
183
+ * Real accounting close is a three-state lifecycle — open / closed / reopened
184
+ * — not a one-way door. A month gets closed, a missing invoice arrives or a
185
+ * filing is rejected, the month is reopened, corrected, and reclosed. The audit
186
+ * value is not the ability to write again; it is the chain being able to say
187
+ * *closed at T1, reopened at T2 by U, reclosed at T3*.
188
+ */
189
+ export interface PeriodReopenEvent {
190
+ readonly op: 'reopen' | 'reclose';
191
+ /** ISO timestamp the event was recorded. */
192
+ readonly at: string;
193
+ /** userId of the keyring that performed it. */
194
+ readonly by: string;
195
+ /**
196
+ * `reopen` only — ISO instant after which the period re-seals on its own,
197
+ * with nobody acting. Absent means the window stays open until an explicit
198
+ * `reclosePeriod`.
199
+ */
200
+ readonly until?: string;
201
+ /** Free-text justification, carried verbatim into the audit trail. */
202
+ readonly reason?: string;
203
+ }
204
+ /**
205
+ * Companion holding a period's reopen/reclose history (#1022). Stored in
206
+ * {@link PERIOD_REOPENS_COLLECTION}, keyed by the period's storage key — kept
207
+ * OFF the hash-chained `_periods/<name>` record for the same reason freeze and
208
+ * archive are: reopening must never rewrite the close, or the chain that proves
209
+ * the close happened is the very thing the reopen destroys.
210
+ *
211
+ * `events` is APPEND-ONLY. Where the other companions are single-shot and
212
+ * idempotent, this one accumulates, because the cycle repeats.
213
+ */
214
+ export interface PeriodReopenRecord {
215
+ readonly period: string;
216
+ readonly partition?: PeriodPartition;
217
+ readonly events: readonly PeriodReopenEvent[];
218
+ }
219
+ /**
220
+ * Collapse an append-only reopen log into the return-only fields merged onto a
221
+ * {@link PeriodRecord} on read.
222
+ *
223
+ * Expiry is deliberately NOT resolved here: `reopenedUntil` is carried through
224
+ * verbatim and compared against the clock at write-guard time, so a bounded
225
+ * window re-seals on its own without anything having to run.
226
+ *
227
+ * @internal
228
+ */
229
+ export declare function resolveReopenState(events: readonly PeriodReopenEvent[]): {
230
+ reopenedAt?: string;
231
+ reopenedBy?: string;
232
+ reopenedUntil?: string;
233
+ reopenReason?: string;
234
+ reclosedAt?: string;
235
+ reopenCount: number;
236
+ };
237
+ /**
238
+ * Is this period writable right now on account of a reopen? (#1022)
239
+ *
240
+ * Three ways to be sealed again: never reopened, explicitly reclosed after the
241
+ * last reopen, or a bounded window that has elapsed. The clock is read by the
242
+ * caller and passed in, so the guard and any diagnostic agree on one instant.
243
+ *
244
+ * @internal
245
+ */
246
+ export declare function isEffectivelyReopened(period: PeriodRecord, nowIso: string): boolean;
180
247
  /**
181
248
  * Companion record noting that a closed+frozen period's delete markers were
182
249
  * swept off the vault's push-only sync targets (#615). Stored in
@@ -189,6 +256,46 @@ export interface PeriodTargetPurgeRecord {
189
256
  readonly purgedBy: string;
190
257
  readonly targets: readonly TargetPurgeCount[];
191
258
  }
259
+ /**
260
+ * Scope tuple for a period timeline (#1005).
261
+ *
262
+ * Identical in shape and semantics to `SequenceOptions.partition`: a
263
+ * partitioned timeline is always disjoint from any unpartitioned one, and from
264
+ * every other tuple. `['acme', 'vat']` and `['acme', 'wht']` are two
265
+ * independent close calendars for the same subject — which is the whole point,
266
+ * since sub-ledgers for one legal entity and one month routinely close on
267
+ * different statutory deadlines.
268
+ */
269
+ export type PeriodPartition = readonly (string | number)[];
270
+ /**
271
+ * Resolve the `_periods` storage key for a (name, partition) pair.
272
+ *
273
+ * Deliberately the same encoding as `resolveSequenceKey`: `name` verbatim when
274
+ * unpartitioned, else `${name}\x00${parts}` with each component
275
+ * `encodeURIComponent`d and `'/'`-joined. The null-byte separator cannot occur
276
+ * in a period name, so a partitioned key never collides with an unpartitioned
277
+ * one; URI-encoding keeps `['a/b']` distinct from `['a','b']`.
278
+ *
279
+ * @throws {ValidationError} on an empty component or a non-finite number.
280
+ * @internal
281
+ */
282
+ export declare function resolvePeriodKey(name: string, partition?: PeriodPartition): string;
283
+ /**
284
+ * Do two partitions denote the same timeline? Absent and empty both mean "the
285
+ * unpartitioned timeline", so they compare equal.
286
+ *
287
+ * @internal
288
+ */
289
+ export declare function samePartition(a?: PeriodPartition, b?: PeriodPartition): boolean;
290
+ /**
291
+ * Resolves a record to the timeline that governs it. Supplied by
292
+ * `withPeriods({ subjects })`; returns `undefined` for any collection with no
293
+ * mapping, which is what keeps an unconfigured vault on the single vault-wide
294
+ * timeline it has always had.
295
+ *
296
+ * @internal
297
+ */
298
+ export type PartitionResolver = (collection: string, record: Record<string, unknown>) => PeriodPartition | undefined;
192
299
  /**
193
300
  * Stored record for one closed or opened accounting period. One entry
194
301
  * per period, keyed by `name` in the reserved `_periods` collection.
@@ -199,8 +306,19 @@ export interface PeriodTargetPurgeRecord {
199
306
  * into the next one, the same way the ledger's `prevHash` works.
200
307
  */
201
308
  export interface PeriodRecord {
202
- /** Human-readable name (e.g., `'FY2026-Q1'`). Unique per vault. */
309
+ /**
310
+ * Human-readable name (e.g., `'FY2026-Q1'`). Unique per PARTITION — two
311
+ * timelines may each carry a `'2026-06'`, which is the normal case when one
312
+ * vault serves several subjects (#1005). Unique per vault when unpartitioned.
313
+ */
203
314
  readonly name: string;
315
+ /**
316
+ * The timeline this period belongs to. Absent = the vault-wide timeline.
317
+ * Two periods with the same `name` and different `partition` are unrelated:
318
+ * separate hash chains, separate close state, and the write guard applies
319
+ * each only to records that resolve to its own tuple.
320
+ */
321
+ readonly partition?: PeriodPartition;
204
322
  /**
205
323
  * Role discriminator. A period is `'closed'` from the moment its
206
324
  * `closedAt` is recorded; `'opened'` marks a period whose opening
@@ -261,6 +379,19 @@ export interface PeriodRecord {
261
379
  readonly targetsPurgedAt?: string;
262
380
  readonly targetsPurgedBy?: string;
263
381
  readonly targetsPurged?: readonly TargetPurgeCount[];
382
+ /** #1022 return-only — collapsed from the `_period_reopens/<key>` append-only
383
+ * log on read; NEVER written into the stored `_periods/<name>` record, so a
384
+ * reopen cannot disturb the inter-period hash chain. Absent = never reopened.
385
+ * `reclosedAt` present (and >= `reopenedAt`) means the window was closed
386
+ * again explicitly; `reopenedUntil` in the past means it lapsed on its own.
387
+ * Use {@link isEffectivelyReopened} rather than reading these directly. */
388
+ readonly reopenedAt?: string;
389
+ readonly reopenedBy?: string;
390
+ readonly reopenedUntil?: string;
391
+ readonly reopenReason?: string;
392
+ readonly reclosedAt?: string;
393
+ /** How many times this period has been reopened, ever. */
394
+ readonly reopenCount?: number;
264
395
  }
265
396
  /** Options for `vault.closePeriod()`. */
266
397
  export interface ClosePeriodOptions {
@@ -283,11 +414,32 @@ export interface ClosePeriodOptions {
283
414
  * an explicit `dateField`.
284
415
  */
285
416
  readonly dateField?: string;
417
+ /**
418
+ * Close only this timeline (#1005). Omit for the vault-wide timeline.
419
+ *
420
+ * ```ts
421
+ * vault.closePeriod({
422
+ * name: '2026-06', endDate: '2026-06-30', dateField: 'issuedAt',
423
+ * partition: [clientId, 'vat'],
424
+ * })
425
+ * ```
426
+ *
427
+ * Which records the resulting seal applies to is decided by the
428
+ * `subjects` map passed to `withPeriods()` — without one, no record ever
429
+ * resolves to a partition and a partitioned close seals nothing.
430
+ */
431
+ readonly partition?: PeriodPartition;
286
432
  }
287
433
  /** Options for `vault.openPeriod()`. */
288
434
  export interface OpenPeriodOptions<TCollections = Record<string, Record<string, unknown>>> {
289
435
  /** Human-readable name for the new period. Must be unique. */
290
436
  readonly name: string;
437
+ /**
438
+ * The timeline to open in. Must match the partition of `fromPeriod` — a
439
+ * period cannot chain across timelines, since each carries its own hash
440
+ * chain (#1005).
441
+ */
442
+ readonly partition?: PeriodPartition;
291
443
  /** ISO lower bound of the new period (usually prior `endDate + 1 day`). */
292
444
  readonly startDate: string;
293
445
  /**
@@ -349,7 +501,7 @@ export interface ReadOnlyCollection<T> {
349
501
  * @internal — called by Vault methods that need the closed-period
350
502
  * cache. Not part of the public API surface.
351
503
  */
352
- export declare function loadPeriods(adapter: NoydbStore, vault: string, decrypt: (envelope: EncryptedEnvelope) => Promise<PeriodRecord>): Promise<PeriodRecord[]>;
504
+ export declare function loadPeriods(adapter: NoydbStore, vault: string, decrypt: (id: string, envelope: EncryptedEnvelope) => Promise<PeriodRecord>): Promise<PeriodRecord[]>;
353
505
  /**
354
506
  * Given the current ordered period list, pick the last entry that
355
507
  * belongs to the hash chain — used as the `priorPeriodHash` anchor
@@ -357,7 +509,7 @@ export declare function loadPeriods(adapter: NoydbStore, vault: string, decrypt:
357
509
  *
358
510
  * @internal
359
511
  */
360
- export declare function chainAnchor(records: readonly PeriodRecord[]): Promise<{
512
+ export declare function chainAnchor(records: readonly PeriodRecord[], partition?: PeriodPartition): Promise<{
361
513
  priorPeriodName?: string;
362
514
  priorPeriodHash: string;
363
515
  }>;
@@ -382,7 +534,10 @@ export declare function chainAnchor(records: readonly PeriodRecord[]): Promise<{
382
534
  export declare function assertTsWritable(existing: {
383
535
  ts: string | null;
384
536
  record: Record<string, unknown> | null;
385
- } | null, incomingRecord: Record<string, unknown> | null, closedPeriods: readonly PeriodRecord[]): void;
537
+ } | null, incomingRecord: Record<string, unknown> | null, closedPeriods: readonly PeriodRecord[], scope?: {
538
+ collection: string;
539
+ resolve?: PartitionResolver;
540
+ }): void;
386
541
  /**
387
542
  * Sanity-check a proposed period name + endDate against existing
388
543
  * records. Shared by closePeriod / openPeriod so the two pathways
@@ -390,7 +545,7 @@ export declare function assertTsWritable(existing: {
390
545
  *
391
546
  * @internal
392
547
  */
393
- export declare function validatePeriodName(name: string, existing: readonly PeriodRecord[]): void;
548
+ export declare function validatePeriodName(name: string, existing: readonly PeriodRecord[], partition?: PeriodPartition): void;
394
549
  /**
395
550
  * Wire a reserved-collection ledger append for a period record. The
396
551
  * period itself is stored via the adapter as an encrypted envelope;
@@ -12,21 +12,30 @@
12
12
  */
13
13
  import type { EncryptedEnvelope, NoydbStore } from '../../kernel/types.js';
14
14
  import type { LedgerStore } from '../../with-commit/history/ledger/store.js';
15
- import type { PeriodRecord } from './periods.js';
15
+ import type { PeriodRecord, PeriodPartition, PartitionResolver } from './periods.js';
16
16
  /**
17
17
  * @internal
18
18
  */
19
19
  export interface PeriodsStrategy {
20
- loadPeriods(adapter: NoydbStore, vault: string, decrypt: (envelope: EncryptedEnvelope) => Promise<PeriodRecord>): Promise<PeriodRecord[]>;
21
- chainAnchor(records: readonly PeriodRecord[]): Promise<{
20
+ loadPeriods(adapter: NoydbStore, vault: string, decrypt: (id: string, envelope: EncryptedEnvelope) => Promise<PeriodRecord>): Promise<PeriodRecord[]>;
21
+ chainAnchor(records: readonly PeriodRecord[], partition?: PeriodPartition): Promise<{
22
22
  priorPeriodName?: string;
23
23
  priorPeriodHash: string;
24
24
  }>;
25
25
  assertTsWritable(existing: {
26
26
  ts: string | null;
27
27
  record: Record<string, unknown> | null;
28
- } | null, incoming: Record<string, unknown> | null, periods: readonly PeriodRecord[]): void;
29
- validatePeriodName(name: string, existing: readonly PeriodRecord[]): void;
28
+ } | null, incoming: Record<string, unknown> | null, periods: readonly PeriodRecord[], scope?: {
29
+ collection: string;
30
+ resolve?: PartitionResolver;
31
+ }): void;
32
+ validatePeriodName(name: string, existing: readonly PeriodRecord[], partition?: PeriodPartition): void;
33
+ /**
34
+ * Record → timeline resolver built from `withPeriods({ subjects })` (#1005).
35
+ * `undefined` when the caller configured no subjects, which keeps every
36
+ * record on the vault-wide timeline.
37
+ */
38
+ readonly partitionOf?: PartitionResolver;
30
39
  appendPeriodLedgerEntry(ledger: LedgerStore | null, actor: string, envelope: EncryptedEnvelope, periodName: string, collection?: string): Promise<void>;
31
40
  }
32
41
  export declare const NO_PERIODS: PeriodsStrategy;
@@ -3,7 +3,31 @@ import type { NoydbStore } from '../../kernel/types.js';
3
3
  import type { LedgerStore } from '../../with-commit/history/ledger/store.js';
4
4
  import type { Collection } from '../../kernel/collection.js';
5
5
  import type { PeriodsStrategy } from './strategy.js';
6
- import { type PeriodRecord, type TargetPurgeCount, type ClosePeriodOptions, type OpenPeriodOptions } from './periods.js';
6
+ import { type PeriodRecord, type TargetPurgeCount, type ClosePeriodOptions, type OpenPeriodOptions, type PeriodPartition, type PeriodReopenEvent } from './periods.js';
7
+ /** Selects one period timeline. Omit — or pass an empty tuple — for the vault-wide one (#1005). */
8
+ export interface PeriodScope {
9
+ readonly partition?: PeriodPartition;
10
+ }
11
+ /** A scoped operation that also records a free-text justification in the audit trail. */
12
+ export interface PeriodScopeWithReason extends PeriodScope {
13
+ readonly reason?: string;
14
+ }
15
+ /** Options for `vault.reopenPeriod()` (#1022). */
16
+ export interface ReopenPeriodOptions extends PeriodScopeWithReason {
17
+ /**
18
+ * ISO instant after which the period re-seals BY ITSELF, with nobody acting.
19
+ * Omit for a window that stays open until an explicit `reclosePeriod()`.
20
+ *
21
+ * Expiry is evaluated against the clock on every write check, so a lapsed
22
+ * window needs no sweep, no timer and no cache invalidation to take effect.
23
+ */
24
+ readonly until?: string;
25
+ }
26
+ /** The persisted side of a write, as the period write-guard sees it. */
27
+ export interface PeriodGuardPrior {
28
+ readonly ts: string | null;
29
+ readonly record: Record<string, unknown> | null;
30
+ }
7
31
  /** Everything the moving period methods touched on the vault's `this.*`. */
8
32
  export interface VaultPeriodsDeps {
9
33
  /** Resolved periods strategy (NO_PERIODS when not configured). */
@@ -56,7 +80,7 @@ export declare class VaultPeriods {
56
80
  * read only. Idempotent: a second call is a no-op that returns the
57
81
  * same merged record without re-purging or re-appending a ledger entry.
58
82
  */
59
- freezePeriod(name: string): Promise<PeriodRecord>;
83
+ freezePeriod(name: string, options?: PeriodScope): Promise<PeriodRecord>;
60
84
  /**
61
85
  * Archive a closed period (#613): physically relocates its in-window
62
86
  * records (those with `_ts < periodExclusiveUpperBound(endDate)`) from the
@@ -66,7 +90,7 @@ export declare class VaultPeriods {
66
90
  * through to cold) and idempotent: a second call is a no-op returning the
67
91
  * same merged record.
68
92
  */
69
- archivePeriod(name: string): Promise<PeriodRecord>;
93
+ archivePeriod(name: string, options?: PeriodScope): Promise<PeriodRecord>;
70
94
  /**
71
95
  * Target-purge a closed period (#615): sweeps delete markers off the vault's
72
96
  * PUSH-ONLY sync targets (`backup`/`archive`) via `purgeTargets`, recording a
@@ -76,22 +100,77 @@ export declare class VaultPeriods {
76
100
  * Idempotent once run; with no push-only targets it writes no companion and
77
101
  * is re-runnable.
78
102
  */
79
- purgePeriodTargets(name: string): Promise<PeriodRecord>;
103
+ purgePeriodTargets(name: string, options?: PeriodScope): Promise<PeriodRecord>;
80
104
  /** Merge target-purge companion fields into a fresh `PeriodRecord` copy — never mutates `periodCache`. */
81
105
  private mergeTargetPurge;
82
106
  /** Merge archive companion fields into a fresh `PeriodRecord` copy — never mutates `periodCache`. */
83
107
  private mergeArchive;
84
108
  /** Merge freeze companion fields into a fresh `PeriodRecord` copy — never mutates `periodCache`. */
85
109
  private mergeFreeze;
86
- /** Return every closed / opened period in `closedAt` order, merged with any freeze + archive companions. */
87
- listPeriods(): Promise<readonly PeriodRecord[]>;
88
- /** Look up a single period by name, merged with its freeze + archive + target-purge companions if any. Returns `null` if not found. */
89
- getPeriod(name: string): Promise<PeriodRecord | null>;
90
- /** Called by the gate bus before put/delete. */
110
+ /**
111
+ * Return every closed / opened period in `closedAt` order, merged with any
112
+ * freeze + archive companions.
113
+ *
114
+ * With no argument this spans EVERY timeline — the pre-#1005 behaviour, and
115
+ * the right default for an audit sweep. Pass `{ partition }` to scope to one
116
+ * timeline; `{ partition: [] }` (or omitting it) means the vault-wide one.
117
+ */
118
+ listPeriods(options?: PeriodScope): Promise<readonly PeriodRecord[]>;
119
+ /**
120
+ * Look up a single period by name within one timeline, merged with its
121
+ * freeze + archive + target-purge companions if any. Returns `null` if not
122
+ * found.
123
+ *
124
+ * Names are only unique per partition (#1005), so this resolves against the
125
+ * VAULT-WIDE timeline unless `{ partition }` says otherwise — matching how
126
+ * every pre-partition period is stored.
127
+ */
128
+ getPeriod(name: string, options?: PeriodScope): Promise<PeriodRecord | null>;
129
+ /**
130
+ * The full append-only reopen/reclose log for one period (#1022) — the record
131
+ * an audit actually asks for, in order. `[]` when never reopened.
132
+ */
133
+ listPeriodReopens(name: string, options?: PeriodScope): Promise<readonly PeriodReopenEvent[]>;
134
+ /**
135
+ * Return a closed period to a writable state (#1022).
136
+ *
137
+ * Close is a three-state lifecycle in practice — open / closed / reopened —
138
+ * because a month gets closed and then a missing invoice arrives, or a filing
139
+ * is rejected and must be amended. That is routine, and it is supposed to
140
+ * leave a trail.
141
+ *
142
+ * The `_periods/<key>` record is NOT touched: the reopen is appended to a
143
+ * companion log, so the inter-period hash chain that proves the close
144
+ * happened survives the reopen intact. The chain reads *closed at T1,
145
+ * reopened at T2 by U, reclosed at T3*.
146
+ *
147
+ * A reopen withdraws the PERIOD's veto and nothing else. Record-level rules —
148
+ * an `immutableGuard` on a sent receipt, a frozen field — are separate gate
149
+ * handlers registered ahead of the period gate, so a reopened month cannot
150
+ * resurrect a document that is independently locked. Period state can only
151
+ * ever widen what the record-level rule already permits.
152
+ *
153
+ * Reopening an already-open window is allowed and appends another event: that
154
+ * is how a window gets extended, and the log keeps both.
155
+ */
156
+ reopenPeriod(name: string, options?: ReopenPeriodOptions): Promise<PeriodRecord>;
157
+ /**
158
+ * Seal a reopened period again (#1022), ending the window explicitly rather
159
+ * than waiting for an `until` to lapse. Appends to the same log, so the
160
+ * close → reopen → reclose sequence is recoverable in order.
161
+ */
162
+ reclosePeriod(name: string, options?: PeriodScopeWithReason): Promise<PeriodRecord>;
163
+ /** Append one entry to a period's reopen log, ledger it, and invalidate the guard's view. */
164
+ private appendReopenEvent;
165
+ /** Merge each period's reopen log onto it. One adapter listing, not one per period. */
166
+ private mergeReopenState;
167
+ /** Resolve one period within the timeline named by `options` (vault-wide when absent). */
168
+ private findPeriod;
169
+ /** Called by the gate bus before put/delete. `collection` selects the subject mapping (#1005). */
91
170
  assertTsWritable(existing: {
92
171
  ts: string | null;
93
172
  record: Record<string, unknown> | null;
94
- } | null, incoming: Record<string, unknown> | null): Promise<void>;
173
+ } | null, incoming: Record<string, unknown> | null, collection?: string): Promise<void>;
95
174
  private loadPeriodsCache;
96
175
  /** Generic reserved-collection writer — serves `_periods` and `_period_freezes` alike. */
97
176
  private writeReserved;
@@ -6,6 +6,16 @@ export declare const PERIOD_FREEZES_COLLECTION = "_period_freezes";
6
6
  export declare const PERIOD_ARCHIVES_COLLECTION = "_period_archives";
7
7
  /** Sibling of {@link PERIODS_COLLECTION} holding target-purge companions (#615). */
8
8
  export declare const PERIOD_TARGET_PURGES_COLLECTION = "_period_target_purges";
9
+ /**
10
+ * Sibling of {@link PERIODS_COLLECTION} holding reopen/reclose companions (#1022).
11
+ *
12
+ * Unlike the freeze / archive / target-purge companions — each a single,
13
+ * idempotent, once-only record — this one holds an APPEND-ONLY EVENT LIST,
14
+ * because reopening is a repeating cycle: a month can be closed, reopened,
15
+ * reclosed, and reopened again. The audit value is the sequence, not the
16
+ * latest state.
17
+ */
18
+ export declare const PERIOD_REOPENS_COLLECTION = "_period_reopens";
9
19
  /**
10
20
  * Exclusive upper bound for a period's delete-marker purge window (#604).
11
21
  * Markers carry no business date (empty body), only write-time `_ts`, so freeze
@@ -46,10 +46,23 @@ export { SealedRecordNotEnabledError } from '../../kernel/errors.js';
46
46
  * @param expectedCollection Collection the caller believes `recordEnvelope` is in.
47
47
  * @param expectedId Record id the caller believes `recordEnvelope` is.
48
48
  * @returns The decrypted record body as a JSON string.
49
+ *
50
+ * ⚠️ **`recordEnvelope` must carry `_tier` and `_by`, not just the body**
51
+ * (#1041). They are plaintext metadata rather than secrets, but they are bound
52
+ * into the record's AAD, so a host handed only `{_iv, _data}` cannot
53
+ * reconstruct the identity the body was sealed against.
54
+ *
55
+ * That is a feature, not a tax: it means a host cannot be fed a body with its
56
+ * tags stripped or rewritten — a re-tiered or re-authored envelope no longer
57
+ * opens, even with a valid sealed CEK.
49
58
  */
50
59
  export declare function openSealedRecord(sealedCekEnvelope: SealedCekDeliveryEnvelope, recordEnvelope: {
51
60
  readonly _iv: string;
52
61
  readonly _data: string;
62
+ /** Bound into the AAD since #1093 — a rewound body no longer opens. */
63
+ readonly _v: number;
64
+ readonly _tier?: number | undefined;
65
+ readonly _by?: string | undefined;
53
66
  }, recipientSealer: {
54
67
  unseal(bytes: Uint8Array): Promise<Uint8Array>;
55
68
  }, expectedCollection: string, expectedId: string): Promise<string>;
@@ -23,7 +23,7 @@
23
23
  export { withTiers } from './active.js';
24
24
  export { NO_TIERS, type TiersStrategy } from './strategy.js';
25
25
  export { TiersNotEnabledError } from '../../kernel/errors.js';
26
- import { type RecordCodec, type EnclaveKey, type SealedShredSlot } from '../../kernel/enclave/index.js';
26
+ import { type RecordIdentity, type RecordCodec, type EnclaveKey, type SealedShredSlot } from '../../kernel/enclave/index.js';
27
27
  import type { UnlockedKeyring } from '../../with-party/team/keyring.js';
28
28
  import type { Lru } from '../../kernel/cache/index.js';
29
29
  import type { BlobFieldsConfig } from '../../with-shape/blobs/blob-compaction.js';
@@ -123,7 +123,22 @@ export interface TiersContext<T> {
123
123
  * pre-move body whenever `fromTier > 0`. No-op when history is disabled
124
124
  * (folds the `historyConfig.enabled` gate so `tiers/index.ts` stays simple).
125
125
  */
126
- saveHistorySnapshot(id: string, envelope: EncryptedEnvelope): Promise<void>;
126
+ /**
127
+ * Persist a `_history` snapshot of `version`, sealed against the address it
128
+ * will be STORED at (#1041).
129
+ *
130
+ * Takes a **sealer**, not a finished envelope, because the destination
131
+ * identity is not knowable here: only the history strategy owns the
132
+ * `_history` layout. It hands the address in; the caller seals to it.
133
+ *
134
+ * ⚠️ The identity passed to `rewrapBodyToDek` must be what a READER will
135
+ * recompute — `recordAadFor(address, finalEnvelope)`. A tier-move snapshot
136
+ * strips `_tier`/`_elevatedBy` but KEEPS `_by`, so the destination is
137
+ * `{...address, by: envelope._by}` with no tier. Sealing against the bare
138
+ * address would produce history nothing can open, and the failure would
139
+ * surface only when someone reads it.
140
+ */
141
+ saveHistorySnapshot(id: string, version: number, seal: (address: RecordIdentity) => Promise<EncryptedEnvelope>): Promise<void>;
127
142
  /**
128
143
  * `true` iff a real history strategy is wired (not `NO_HISTORY`) AND not
129
144
  * explicitly disabled via `historyConfig.enabled`. `putAtTier` checks this
@@ -12,7 +12,7 @@ import type { NoydbStore } from '../kernel/types.js';
12
12
  import type { SealingKeyProvider } from '../with-party/team/managed-secret.js';
13
13
  import type { ShamirRecoveryProvider } from '../with-party/team/shamir-recovery-provider.js';
14
14
  import type { RecoveryEnrollmentInput } from '../with-party/team/rotate-recover.js';
15
- import type { TransferSealPayload } from '../with-pod/bundle.js';
15
+ import type { TransferSealPayload } from '../with-pod/pod.js';
16
16
  /**
17
17
  * Reverse of `sealDeks`. Imports the transfer key, decrypts the
18
18
  * sealed `{ collection: base64(rawDEK) }` map (layout iv(12)‖ct‖tag), and
@@ -10,7 +10,7 @@ import type { Vault } from '../kernel/vault.js';
10
10
  import type { EncryptedEnvelope } from '../kernel/types.js';
11
11
  import { type EnclaveKey } from '../kernel/enclave/index.js';
12
12
  import { type WalkClosureOptions, type DanglingRefNotice } from './walk-closure.js';
13
- import { type TransferSealPayload } from '../with-pod/bundle.js';
13
+ import { type TransferSealPayload } from '../with-pod/pod.js';
14
14
  /** Re-keyed collections snapshot + the fresh DEKs used. */
15
15
  export interface ReKeyResult {
16
16
  readonly collections: Record<string, Record<string, EncryptedEnvelope>>;
@@ -37,10 +37,10 @@ export type { ExtractPartitionResult } from './extract-partition.js';
37
37
  export { adoptPartition, unsealDeks, createOwnerOnAdoptedPartition } from './adopt-partition.js';
38
38
  export type { AdoptPartitionOptions, AdoptPartitionResult, CreateOwnerResult, CreateOwnerOptions, CreateOwnerStandardOptions, CreateOwnerManagedOptions, } from './adopt-partition.js';
39
39
  export { TransferSealError, AdoptionStateError, PartitionExtractionError } from '../kernel/errors.js';
40
- export type { WriteHook } from '../port/with/write-hooks.js';
40
+ export type { WriteHook, WriteEvent } from '../port/with/write-hooks.js';
41
41
  export type { WriteQueue } from '../kernel/write-queue.js';
42
42
  export type { WriteConflict } from '../kernel/types.js';
43
43
  export type { AccessibleVault } from '../kernel/types.js';
44
44
  export type { Unsubscribe } from '../kernel/types.js';
45
45
  export type { ExtractPartitionOptions } from './extract-partition.js';
46
- export type { TransferSealPayload } from '../with-pod/bundle.js';
46
+ export type { TransferSealPayload } from '../with-pod/pod.js';
@@ -1,5 +1,31 @@
1
+ import type { RecordIdentity } from '../../kernel/enclave/index.js';
1
2
  import type { NoydbStore, EncryptedEnvelope, HistoryOptions, PruneOptions } from '../../kernel/types.js';
2
3
  import { type EnclaveKey } from '../../kernel/enclave/index.js';
4
+ /**
5
+ * The identity a history snapshot is **sealed against** — its STORAGE location,
6
+ * not the live record it is a copy of (#1041).
7
+ *
8
+ * ## Why storage, and why this is a decision rather than a detail
9
+ *
10
+ * A snapshot is a copy, so two identities are available: the live record
11
+ * (`collection`/`recordId`) or where the bytes actually land
12
+ * (`_history`/`historyId(...)`). They are not equivalent under attack.
13
+ *
14
+ * Binding the LIVE identity makes a snapshot's AAD **indistinguishable from the
15
+ * live record's at the same version** — so an untrusted store could serve a
16
+ * history entry *as the current record* and the client would accept it. It also
17
+ * leaves entries relocatable within `_history`.
18
+ *
19
+ * Binding STORAGE identity closes both. The cost is that the id must be known
20
+ * *before* the envelope is sealed, where `saveHistory` previously derived it
21
+ * *after* (from `envelope._v`) — which is precisely the restructure this
22
+ * function exists to make possible.
23
+ *
24
+ * `saveHistory` uses this too, so the sealed identity and the put location have
25
+ * **one definition** and cannot drift apart. Changing the layout here changes
26
+ * both at once, by construction.
27
+ */
28
+ export declare function historyIdentity(collection: string, recordId: string, version: number): RecordIdentity;
3
29
  /** Save a history entry (a complete encrypted envelope snapshot). */
4
30
  export declare function saveHistory(adapter: NoydbStore, vault: string, collection: string, recordId: string, envelope: EncryptedEnvelope): Promise<void>;
5
31
  /** Get history entries for a record, sorted newest-first. */
@@ -17,7 +17,7 @@
17
17
  */
18
18
  export { withHistory } from './active.js';
19
19
  export type { HistoryStrategy } from './strategy.js';
20
- export { saveHistory, getHistory, getVersionEnvelope, pruneHistory, clearHistory, } from './history.js';
20
+ export { saveHistory, historyIdentity, getHistory, getVersionEnvelope, pruneHistory, clearHistory, } from './history.js';
21
21
  export { diff, formatDiff } from './diff.js';
22
22
  export type { ChangeType, DiffEntry } from './diff.js';
23
23
  export { LedgerStore, LEDGER_COLLECTION, LEDGER_DELTAS_COLLECTION, envelopePayloadHash, } from './ledger/store.js';
@@ -30,3 +30,4 @@ export { VaultInstant, CollectionInstant } from './time-machine.js';
30
30
  export type { VaultEngine } from './time-machine.js';
31
31
  /** The un-opted-in stub for this service — exported so callers can compare against it (#844). */
32
32
  export { NO_HISTORY } from './strategy.js';
33
+ export type { RecordIdentity } from '../../kernel/enclave/index.js';
@@ -237,7 +237,13 @@ export declare class LedgerStore {
237
237
  * version/timestamp/actor) fully intact for audit purposes.
238
238
  */
239
239
  purgeRecordDeltas(collection: string, id: string): Promise<number>;
240
- /** Encrypt a JSON Patch into an envelope for storage. Mirrors encryptEntry. */
240
+ /**
241
+ * Encrypt a JSON Patch into an envelope for storage. Mirrors encryptEntry.
242
+ *
243
+ * `index` is the ledger index this delta will be stored under — the caller
244
+ * knows it before the entry exists, and it is what makes the envelope's
245
+ * identity bindable (#1051).
246
+ */
241
247
  private encryptDelta;
242
248
  /**
243
249
  * Read all entries in ascending-index order. Used internally by
@@ -33,7 +33,7 @@ import type { LedgerStore } from './ledger/store.js';
33
33
  import type { JsonPatch } from './ledger/patch.js';
34
34
  import type { DiffEntry } from './diff.js';
35
35
  import type { VaultInstant, VaultEngine } from './time-machine.js';
36
- import type { EnclaveKey } from '../../kernel/enclave/index.js';
36
+ import type { EnclaveKey, RecordIdentity } from '../../kernel/enclave/index.js';
37
37
  /**
38
38
  * Options accepted by `HistoryStrategy.buildLedger`. Mirrors the
39
39
  * `LedgerStore` constructor verbatim — kept in this file so `core`
@@ -58,6 +58,16 @@ export interface HistoryStrategy {
58
58
  * `NO_HISTORY`.
59
59
  */
60
60
  saveHistory(adapter: NoydbStore, vault: string, collection: string, recordId: string, envelope: EncryptedEnvelope): Promise<void>;
61
+ /**
62
+ * The identity a snapshot of `collection/recordId@version` must be **sealed
63
+ * against** — its `_history` storage location (#1041).
64
+ *
65
+ * On the port because the kernel writes history snapshots but must not import
66
+ * `with-commit` to learn its layout. Exposing it here keeps the derivation in
67
+ * the module that owns the layout, and `saveHistory` uses the same function,
68
+ * so the sealed identity and the put location cannot drift.
69
+ */
70
+ historyIdentity(collection: string, recordId: string, version: number): RecordIdentity;
61
71
  /**
62
72
  * List history envelopes for a record, newest first. Throws under
63
73
  * `NO_HISTORY` — callers reach this via `collection.history()` /
@@ -1,8 +1,3 @@
1
- /**
2
- * @category capability
3
- * Deferred numbering engine — store-clock-ordered, gap-free serials assigned
4
- * at an explicit numbering pass. See the design spec.
5
- */
6
1
  import type { NoydbStore } from '../../kernel/types.js';
7
2
  import { type EnclaveKey } from '../../kernel/enclave/index.js';
8
3
  import type { DeferredNumberingConfig } from './descriptor.js';
@@ -0,0 +1,2 @@
1
+ import { type VaultHeadStrategy, type WithVaultHeadOptions } from './strategy.js';
2
+ export declare function withVaultHead(opts?: WithVaultHeadOptions): VaultHeadStrategy;