@optimystic/db-core 0.13.5 → 0.14.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 (447) hide show
  1. package/dist/src/cluster/structs.d.ts +13 -0
  2. package/dist/src/cluster/structs.d.ts.map +1 -1
  3. package/dist/src/cohort-topic/addressing.d.ts +53 -0
  4. package/dist/src/cohort-topic/addressing.d.ts.map +1 -0
  5. package/dist/src/cohort-topic/addressing.js +95 -0
  6. package/dist/src/cohort-topic/addressing.js.map +1 -0
  7. package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.d.ts +105 -0
  8. package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.d.ts.map +1 -0
  9. package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.js +197 -0
  10. package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.js.map +1 -0
  11. package/dist/src/cohort-topic/antidos/bootstrap-evidence.d.ts +50 -0
  12. package/dist/src/cohort-topic/antidos/bootstrap-evidence.d.ts.map +1 -0
  13. package/dist/src/cohort-topic/antidos/bootstrap-evidence.js +62 -0
  14. package/dist/src/cohort-topic/antidos/bootstrap-evidence.js.map +1 -0
  15. package/dist/src/cohort-topic/antidos/index.d.ts +6 -0
  16. package/dist/src/cohort-topic/antidos/index.d.ts.map +1 -0
  17. package/dist/src/cohort-topic/antidos/index.js +6 -0
  18. package/dist/src/cohort-topic/antidos/index.js.map +1 -0
  19. package/dist/src/cohort-topic/antidos/rate-limiter.d.ts +95 -0
  20. package/dist/src/cohort-topic/antidos/rate-limiter.d.ts.map +1 -0
  21. package/dist/src/cohort-topic/antidos/rate-limiter.js +146 -0
  22. package/dist/src/cohort-topic/antidos/rate-limiter.js.map +1 -0
  23. package/dist/src/cohort-topic/antidos/replay-guard.d.ts +37 -0
  24. package/dist/src/cohort-topic/antidos/replay-guard.d.ts.map +1 -0
  25. package/dist/src/cohort-topic/antidos/replay-guard.js +78 -0
  26. package/dist/src/cohort-topic/antidos/replay-guard.js.map +1 -0
  27. package/dist/src/cohort-topic/antidos/topic-budget.d.ts +50 -0
  28. package/dist/src/cohort-topic/antidos/topic-budget.d.ts.map +1 -0
  29. package/dist/src/cohort-topic/antidos/topic-budget.js +95 -0
  30. package/dist/src/cohort-topic/antidos/topic-budget.js.map +1 -0
  31. package/dist/src/cohort-topic/antiflood/index.d.ts +3 -0
  32. package/dist/src/cohort-topic/antiflood/index.d.ts.map +1 -0
  33. package/dist/src/cohort-topic/antiflood/index.js +3 -0
  34. package/dist/src/cohort-topic/antiflood/index.js.map +1 -0
  35. package/dist/src/cohort-topic/antiflood/invariants.d.ts +70 -0
  36. package/dist/src/cohort-topic/antiflood/invariants.d.ts.map +1 -0
  37. package/dist/src/cohort-topic/antiflood/invariants.js +86 -0
  38. package/dist/src/cohort-topic/antiflood/invariants.js.map +1 -0
  39. package/dist/src/cohort-topic/antiflood/jitter.d.ts +65 -0
  40. package/dist/src/cohort-topic/antiflood/jitter.d.ts.map +1 -0
  41. package/dist/src/cohort-topic/antiflood/jitter.js +75 -0
  42. package/dist/src/cohort-topic/antiflood/jitter.js.map +1 -0
  43. package/dist/src/cohort-topic/coldstart.d.ts +117 -0
  44. package/dist/src/cohort-topic/coldstart.d.ts.map +1 -0
  45. package/dist/src/cohort-topic/coldstart.js +127 -0
  46. package/dist/src/cohort-topic/coldstart.js.map +1 -0
  47. package/dist/src/cohort-topic/dmax.d.ts +44 -0
  48. package/dist/src/cohort-topic/dmax.d.ts.map +1 -0
  49. package/dist/src/cohort-topic/dmax.js +70 -0
  50. package/dist/src/cohort-topic/dmax.js.map +1 -0
  51. package/dist/src/cohort-topic/gossip/bus.d.ts +85 -0
  52. package/dist/src/cohort-topic/gossip/bus.d.ts.map +1 -0
  53. package/dist/src/cohort-topic/gossip/bus.js +146 -0
  54. package/dist/src/cohort-topic/gossip/bus.js.map +1 -0
  55. package/dist/src/cohort-topic/gossip/index.d.ts +4 -0
  56. package/dist/src/cohort-topic/gossip/index.d.ts.map +1 -0
  57. package/dist/src/cohort-topic/gossip/index.js +4 -0
  58. package/dist/src/cohort-topic/gossip/index.js.map +1 -0
  59. package/dist/src/cohort-topic/gossip/records.d.ts +12 -0
  60. package/dist/src/cohort-topic/gossip/records.d.ts.map +1 -0
  61. package/dist/src/cohort-topic/gossip/records.js +41 -0
  62. package/dist/src/cohort-topic/gossip/records.js.map +1 -0
  63. package/dist/src/cohort-topic/gossip/view.d.ts +39 -0
  64. package/dist/src/cohort-topic/gossip/view.d.ts.map +1 -0
  65. package/dist/src/cohort-topic/gossip/view.js +30 -0
  66. package/dist/src/cohort-topic/gossip/view.js.map +1 -0
  67. package/dist/src/cohort-topic/index.d.ts +21 -0
  68. package/dist/src/cohort-topic/index.d.ts.map +1 -0
  69. package/dist/src/cohort-topic/index.js +21 -0
  70. package/dist/src/cohort-topic/index.js.map +1 -0
  71. package/dist/src/cohort-topic/load/barometer.d.ts +78 -0
  72. package/dist/src/cohort-topic/load/barometer.d.ts.map +1 -0
  73. package/dist/src/cohort-topic/load/barometer.js +93 -0
  74. package/dist/src/cohort-topic/load/barometer.js.map +1 -0
  75. package/dist/src/cohort-topic/load/index.d.ts +2 -0
  76. package/dist/src/cohort-topic/load/index.d.ts.map +1 -0
  77. package/dist/src/cohort-topic/load/index.js +2 -0
  78. package/dist/src/cohort-topic/load/index.js.map +1 -0
  79. package/dist/src/cohort-topic/member-engine.d.ts +134 -0
  80. package/dist/src/cohort-topic/member-engine.d.ts.map +1 -0
  81. package/dist/src/cohort-topic/member-engine.js +264 -0
  82. package/dist/src/cohort-topic/member-engine.js.map +1 -0
  83. package/dist/src/cohort-topic/membership/index.d.ts +4 -0
  84. package/dist/src/cohort-topic/membership/index.d.ts.map +1 -0
  85. package/dist/src/cohort-topic/membership/index.js +4 -0
  86. package/dist/src/cohort-topic/membership/index.js.map +1 -0
  87. package/dist/src/cohort-topic/membership/publisher.d.ts +82 -0
  88. package/dist/src/cohort-topic/membership/publisher.d.ts.map +1 -0
  89. package/dist/src/cohort-topic/membership/publisher.js +107 -0
  90. package/dist/src/cohort-topic/membership/publisher.js.map +1 -0
  91. package/dist/src/cohort-topic/membership/source.d.ts +31 -0
  92. package/dist/src/cohort-topic/membership/source.d.ts.map +1 -0
  93. package/dist/src/cohort-topic/membership/source.js +32 -0
  94. package/dist/src/cohort-topic/membership/source.js.map +1 -0
  95. package/dist/src/cohort-topic/membership/verifier.d.ts +96 -0
  96. package/dist/src/cohort-topic/membership/verifier.d.ts.map +1 -0
  97. package/dist/src/cohort-topic/membership/verifier.js +250 -0
  98. package/dist/src/cohort-topic/membership/verifier.js.map +1 -0
  99. package/dist/src/cohort-topic/ports.d.ts +149 -0
  100. package/dist/src/cohort-topic/ports.d.ts.map +1 -0
  101. package/dist/src/cohort-topic/ports.js +25 -0
  102. package/dist/src/cohort-topic/ports.js.map +1 -0
  103. package/dist/src/cohort-topic/promotion.d.ts +135 -0
  104. package/dist/src/cohort-topic/promotion.d.ts.map +1 -0
  105. package/dist/src/cohort-topic/promotion.js +269 -0
  106. package/dist/src/cohort-topic/promotion.js.map +1 -0
  107. package/dist/src/cohort-topic/registration/bytes.d.ts +16 -0
  108. package/dist/src/cohort-topic/registration/bytes.d.ts.map +1 -0
  109. package/dist/src/cohort-topic/registration/bytes.js +32 -0
  110. package/dist/src/cohort-topic/registration/bytes.js.map +1 -0
  111. package/dist/src/cohort-topic/registration/handoff.d.ts +69 -0
  112. package/dist/src/cohort-topic/registration/handoff.d.ts.map +1 -0
  113. package/dist/src/cohort-topic/registration/handoff.js +98 -0
  114. package/dist/src/cohort-topic/registration/handoff.js.map +1 -0
  115. package/dist/src/cohort-topic/registration/index.d.ts +7 -0
  116. package/dist/src/cohort-topic/registration/index.d.ts.map +1 -0
  117. package/dist/src/cohort-topic/registration/index.js +7 -0
  118. package/dist/src/cohort-topic/registration/index.js.map +1 -0
  119. package/dist/src/cohort-topic/registration/renewal.d.ts +115 -0
  120. package/dist/src/cohort-topic/registration/renewal.d.ts.map +1 -0
  121. package/dist/src/cohort-topic/registration/renewal.js +306 -0
  122. package/dist/src/cohort-topic/registration/renewal.js.map +1 -0
  123. package/dist/src/cohort-topic/registration/sharding.d.ts +31 -0
  124. package/dist/src/cohort-topic/registration/sharding.d.ts.map +1 -0
  125. package/dist/src/cohort-topic/registration/sharding.js +48 -0
  126. package/dist/src/cohort-topic/registration/sharding.js.map +1 -0
  127. package/dist/src/cohort-topic/registration/store.d.ts +13 -0
  128. package/dist/src/cohort-topic/registration/store.d.ts.map +1 -0
  129. package/dist/src/cohort-topic/registration/store.js +72 -0
  130. package/dist/src/cohort-topic/registration/store.js.map +1 -0
  131. package/dist/src/cohort-topic/registration/types.d.ts +71 -0
  132. package/dist/src/cohort-topic/registration/types.d.ts.map +1 -0
  133. package/dist/src/cohort-topic/registration/types.js +27 -0
  134. package/dist/src/cohort-topic/registration/types.js.map +1 -0
  135. package/dist/src/cohort-topic/ring-hash.d.ts +27 -0
  136. package/dist/src/cohort-topic/ring-hash.d.ts.map +1 -0
  137. package/dist/src/cohort-topic/ring-hash.js +45 -0
  138. package/dist/src/cohort-topic/ring-hash.js.map +1 -0
  139. package/dist/src/cohort-topic/service.d.ts +157 -0
  140. package/dist/src/cohort-topic/service.d.ts.map +1 -0
  141. package/dist/src/cohort-topic/service.js +237 -0
  142. package/dist/src/cohort-topic/service.js.map +1 -0
  143. package/dist/src/cohort-topic/sig/index.d.ts +3 -0
  144. package/dist/src/cohort-topic/sig/index.d.ts.map +1 -0
  145. package/dist/src/cohort-topic/sig/index.js +3 -0
  146. package/dist/src/cohort-topic/sig/index.js.map +1 -0
  147. package/dist/src/cohort-topic/sig/payloads.d.ts +25 -0
  148. package/dist/src/cohort-topic/sig/payloads.d.ts.map +1 -0
  149. package/dist/src/cohort-topic/sig/payloads.js +25 -0
  150. package/dist/src/cohort-topic/sig/payloads.js.map +1 -0
  151. package/dist/src/cohort-topic/sig/threshold.d.ts +33 -0
  152. package/dist/src/cohort-topic/sig/threshold.d.ts.map +1 -0
  153. package/dist/src/cohort-topic/sig/threshold.js +51 -0
  154. package/dist/src/cohort-topic/sig/threshold.js.map +1 -0
  155. package/dist/src/cohort-topic/tiers.d.ts +58 -0
  156. package/dist/src/cohort-topic/tiers.d.ts.map +1 -0
  157. package/dist/src/cohort-topic/tiers.js +49 -0
  158. package/dist/src/cohort-topic/tiers.js.map +1 -0
  159. package/dist/src/cohort-topic/traffic.d.ts +90 -0
  160. package/dist/src/cohort-topic/traffic.d.ts.map +1 -0
  161. package/dist/src/cohort-topic/traffic.js +146 -0
  162. package/dist/src/cohort-topic/traffic.js.map +1 -0
  163. package/dist/src/cohort-topic/walk.d.ts +123 -0
  164. package/dist/src/cohort-topic/walk.d.ts.map +1 -0
  165. package/dist/src/cohort-topic/walk.js +150 -0
  166. package/dist/src/cohort-topic/walk.js.map +1 -0
  167. package/dist/src/cohort-topic/willingness.d.ts +123 -0
  168. package/dist/src/cohort-topic/willingness.d.ts.map +1 -0
  169. package/dist/src/cohort-topic/willingness.js +143 -0
  170. package/dist/src/cohort-topic/willingness.js.map +1 -0
  171. package/dist/src/cohort-topic/wire/codec.d.ts +42 -0
  172. package/dist/src/cohort-topic/wire/codec.d.ts.map +1 -0
  173. package/dist/src/cohort-topic/wire/codec.js +163 -0
  174. package/dist/src/cohort-topic/wire/codec.js.map +1 -0
  175. package/dist/src/cohort-topic/wire/index.d.ts +6 -0
  176. package/dist/src/cohort-topic/wire/index.d.ts.map +1 -0
  177. package/dist/src/cohort-topic/wire/index.js +6 -0
  178. package/dist/src/cohort-topic/wire/index.js.map +1 -0
  179. package/dist/src/cohort-topic/wire/payloads.d.ts +38 -0
  180. package/dist/src/cohort-topic/wire/payloads.d.ts.map +1 -0
  181. package/dist/src/cohort-topic/wire/payloads.js +102 -0
  182. package/dist/src/cohort-topic/wire/payloads.js.map +1 -0
  183. package/dist/src/cohort-topic/wire/types.d.ts +304 -0
  184. package/dist/src/cohort-topic/wire/types.d.ts.map +1 -0
  185. package/dist/src/cohort-topic/wire/types.js +16 -0
  186. package/dist/src/cohort-topic/wire/types.js.map +1 -0
  187. package/dist/src/cohort-topic/wire/validate.d.ts +25 -0
  188. package/dist/src/cohort-topic/wire/validate.d.ts.map +1 -0
  189. package/dist/src/cohort-topic/wire/validate.js +427 -0
  190. package/dist/src/cohort-topic/wire/validate.js.map +1 -0
  191. package/dist/src/collection/collection.d.ts +58 -1
  192. package/dist/src/collection/collection.d.ts.map +1 -1
  193. package/dist/src/collection/collection.js +76 -0
  194. package/dist/src/collection/collection.js.map +1 -1
  195. package/dist/src/collections/tree/tree.d.ts +58 -2
  196. package/dist/src/collections/tree/tree.d.ts.map +1 -1
  197. package/dist/src/collections/tree/tree.js +59 -2
  198. package/dist/src/collections/tree/tree.js.map +1 -1
  199. package/dist/src/index.d.ts +3 -0
  200. package/dist/src/index.d.ts.map +1 -1
  201. package/dist/src/index.js +3 -0
  202. package/dist/src/index.js.map +1 -1
  203. package/dist/src/log/log.d.ts +42 -4
  204. package/dist/src/log/log.d.ts.map +1 -1
  205. package/dist/src/log/log.js +71 -3
  206. package/dist/src/log/log.js.map +1 -1
  207. package/dist/src/log/struct.d.ts +122 -2
  208. package/dist/src/log/struct.d.ts.map +1 -1
  209. package/dist/src/log/struct.js.map +1 -1
  210. package/dist/src/matchmaking/capability-filter.d.ts +24 -0
  211. package/dist/src/matchmaking/capability-filter.d.ts.map +1 -0
  212. package/dist/src/matchmaking/capability-filter.js +37 -0
  213. package/dist/src/matchmaking/capability-filter.js.map +1 -0
  214. package/dist/src/matchmaking/config.d.ts +77 -0
  215. package/dist/src/matchmaking/config.d.ts.map +1 -0
  216. package/dist/src/matchmaking/config.js +69 -0
  217. package/dist/src/matchmaking/config.js.map +1 -0
  218. package/dist/src/matchmaking/index.d.ts +21 -0
  219. package/dist/src/matchmaking/index.d.ts.map +1 -0
  220. package/dist/src/matchmaking/index.js +21 -0
  221. package/dist/src/matchmaking/index.js.map +1 -0
  222. package/dist/src/matchmaking/multi-cohort-seeker.d.ts +133 -0
  223. package/dist/src/matchmaking/multi-cohort-seeker.d.ts.map +1 -0
  224. package/dist/src/matchmaking/multi-cohort-seeker.js +142 -0
  225. package/dist/src/matchmaking/multi-cohort-seeker.js.map +1 -0
  226. package/dist/src/matchmaking/provider.d.ts +70 -0
  227. package/dist/src/matchmaking/provider.d.ts.map +1 -0
  228. package/dist/src/matchmaking/provider.js +93 -0
  229. package/dist/src/matchmaking/provider.js.map +1 -0
  230. package/dist/src/matchmaking/query-eval.d.ts +53 -0
  231. package/dist/src/matchmaking/query-eval.d.ts.map +1 -0
  232. package/dist/src/matchmaking/query-eval.js +69 -0
  233. package/dist/src/matchmaking/query-eval.js.map +1 -0
  234. package/dist/src/matchmaking/seeker-walk.d.ts +95 -0
  235. package/dist/src/matchmaking/seeker-walk.d.ts.map +1 -0
  236. package/dist/src/matchmaking/seeker-walk.js +75 -0
  237. package/dist/src/matchmaking/seeker-walk.js.map +1 -0
  238. package/dist/src/matchmaking/seeker.d.ts +51 -0
  239. package/dist/src/matchmaking/seeker.d.ts.map +1 -0
  240. package/dist/src/matchmaking/seeker.js +62 -0
  241. package/dist/src/matchmaking/seeker.js.map +1 -0
  242. package/dist/src/matchmaking/topic-anchor.d.ts +54 -0
  243. package/dist/src/matchmaking/topic-anchor.d.ts.map +1 -0
  244. package/dist/src/matchmaking/topic-anchor.js +67 -0
  245. package/dist/src/matchmaking/topic-anchor.js.map +1 -0
  246. package/dist/src/matchmaking/voting-quorum.d.ts +233 -0
  247. package/dist/src/matchmaking/voting-quorum.d.ts.map +1 -0
  248. package/dist/src/matchmaking/voting-quorum.js +238 -0
  249. package/dist/src/matchmaking/voting-quorum.js.map +1 -0
  250. package/dist/src/matchmaking/wire.d.ts +259 -0
  251. package/dist/src/matchmaking/wire.d.ts.map +1 -0
  252. package/dist/src/matchmaking/wire.js +484 -0
  253. package/dist/src/matchmaking/wire.js.map +1 -0
  254. package/dist/src/network/i-repo.d.ts +9 -0
  255. package/dist/src/network/i-repo.d.ts.map +1 -1
  256. package/dist/src/network/repo-protocol.d.ts +3 -1
  257. package/dist/src/network/repo-protocol.d.ts.map +1 -1
  258. package/dist/src/network/struct.d.ts +23 -1
  259. package/dist/src/network/struct.d.ts.map +1 -1
  260. package/dist/src/reactivity/backfill.d.ts +118 -0
  261. package/dist/src/reactivity/backfill.d.ts.map +1 -0
  262. package/dist/src/reactivity/backfill.js +137 -0
  263. package/dist/src/reactivity/backfill.js.map +1 -0
  264. package/dist/src/reactivity/backpressure.d.ts +99 -0
  265. package/dist/src/reactivity/backpressure.d.ts.map +1 -0
  266. package/dist/src/reactivity/backpressure.js +153 -0
  267. package/dist/src/reactivity/backpressure.js.map +1 -0
  268. package/dist/src/reactivity/checkpoint.d.ts +165 -0
  269. package/dist/src/reactivity/checkpoint.d.ts.map +1 -0
  270. package/dist/src/reactivity/checkpoint.js +232 -0
  271. package/dist/src/reactivity/checkpoint.js.map +1 -0
  272. package/dist/src/reactivity/config.d.ts +131 -0
  273. package/dist/src/reactivity/config.d.ts.map +1 -0
  274. package/dist/src/reactivity/config.js +135 -0
  275. package/dist/src/reactivity/config.js.map +1 -0
  276. package/dist/src/reactivity/dedupe.d.ts +51 -0
  277. package/dist/src/reactivity/dedupe.d.ts.map +1 -0
  278. package/dist/src/reactivity/dedupe.js +90 -0
  279. package/dist/src/reactivity/dedupe.js.map +1 -0
  280. package/dist/src/reactivity/forwarder.d.ts +50 -0
  281. package/dist/src/reactivity/forwarder.d.ts.map +1 -0
  282. package/dist/src/reactivity/forwarder.js +52 -0
  283. package/dist/src/reactivity/forwarder.js.map +1 -0
  284. package/dist/src/reactivity/index.d.ts +34 -0
  285. package/dist/src/reactivity/index.d.ts.map +1 -0
  286. package/dist/src/reactivity/index.js +34 -0
  287. package/dist/src/reactivity/index.js.map +1 -0
  288. package/dist/src/reactivity/notification.d.ts +72 -0
  289. package/dist/src/reactivity/notification.d.ts.map +1 -0
  290. package/dist/src/reactivity/notification.js +92 -0
  291. package/dist/src/reactivity/notification.js.map +1 -0
  292. package/dist/src/reactivity/policy.d.ts +59 -0
  293. package/dist/src/reactivity/policy.d.ts.map +1 -0
  294. package/dist/src/reactivity/policy.js +64 -0
  295. package/dist/src/reactivity/policy.js.map +1 -0
  296. package/dist/src/reactivity/push-state.d.ts +140 -0
  297. package/dist/src/reactivity/push-state.d.ts.map +1 -0
  298. package/dist/src/reactivity/push-state.js +270 -0
  299. package/dist/src/reactivity/push-state.js.map +1 -0
  300. package/dist/src/reactivity/recover.d.ts +75 -0
  301. package/dist/src/reactivity/recover.d.ts.map +1 -0
  302. package/dist/src/reactivity/recover.js +105 -0
  303. package/dist/src/reactivity/recover.js.map +1 -0
  304. package/dist/src/reactivity/replay-buffer.d.ts +57 -0
  305. package/dist/src/reactivity/replay-buffer.d.ts.map +1 -0
  306. package/dist/src/reactivity/replay-buffer.js +88 -0
  307. package/dist/src/reactivity/replay-buffer.js.map +1 -0
  308. package/dist/src/reactivity/resume.d.ts +214 -0
  309. package/dist/src/reactivity/resume.d.ts.map +1 -0
  310. package/dist/src/reactivity/resume.js +358 -0
  311. package/dist/src/reactivity/resume.js.map +1 -0
  312. package/dist/src/reactivity/rotation.d.ts +283 -0
  313. package/dist/src/reactivity/rotation.d.ts.map +1 -0
  314. package/dist/src/reactivity/rotation.js +265 -0
  315. package/dist/src/reactivity/rotation.js.map +1 -0
  316. package/dist/src/reactivity/subscriber.d.ts +66 -0
  317. package/dist/src/reactivity/subscriber.d.ts.map +1 -0
  318. package/dist/src/reactivity/subscriber.js +75 -0
  319. package/dist/src/reactivity/subscriber.js.map +1 -0
  320. package/dist/src/reactivity/subscription.d.ts +52 -0
  321. package/dist/src/reactivity/subscription.d.ts.map +1 -0
  322. package/dist/src/reactivity/subscription.js +28 -0
  323. package/dist/src/reactivity/subscription.js.map +1 -0
  324. package/dist/src/reactivity/topic-anchor.d.ts +46 -0
  325. package/dist/src/reactivity/topic-anchor.d.ts.map +1 -0
  326. package/dist/src/reactivity/topic-anchor.js +61 -0
  327. package/dist/src/reactivity/topic-anchor.js.map +1 -0
  328. package/dist/src/reactivity/verify.d.ts +41 -0
  329. package/dist/src/reactivity/verify.d.ts.map +1 -0
  330. package/dist/src/reactivity/verify.js +48 -0
  331. package/dist/src/reactivity/verify.js.map +1 -0
  332. package/dist/src/reactivity/wire-validate.d.ts +28 -0
  333. package/dist/src/reactivity/wire-validate.d.ts.map +1 -0
  334. package/dist/src/reactivity/wire-validate.js +79 -0
  335. package/dist/src/reactivity/wire-validate.js.map +1 -0
  336. package/dist/src/reactivity/wire.d.ts +102 -0
  337. package/dist/src/reactivity/wire.d.ts.map +1 -0
  338. package/dist/src/reactivity/wire.js +129 -0
  339. package/dist/src/reactivity/wire.js.map +1 -0
  340. package/dist/src/transaction/coordinator.d.ts +9 -5
  341. package/dist/src/transaction/coordinator.d.ts.map +1 -1
  342. package/dist/src/transaction/coordinator.js +48 -25
  343. package/dist/src/transaction/coordinator.js.map +1 -1
  344. package/dist/src/transactor/change-notifier.d.ts +74 -0
  345. package/dist/src/transactor/change-notifier.d.ts.map +1 -0
  346. package/dist/src/transactor/change-notifier.js +4 -0
  347. package/dist/src/transactor/change-notifier.js.map +1 -0
  348. package/dist/src/transactor/index.d.ts +1 -0
  349. package/dist/src/transactor/index.d.ts.map +1 -1
  350. package/dist/src/transactor/index.js +1 -0
  351. package/dist/src/transactor/index.js.map +1 -1
  352. package/dist/src/transactor/network-transactor.d.ts +34 -2
  353. package/dist/src/transactor/network-transactor.d.ts.map +1 -1
  354. package/dist/src/transactor/network-transactor.js +113 -13
  355. package/dist/src/transactor/network-transactor.js.map +1 -1
  356. package/package.json +2 -2
  357. package/src/cluster/structs.ts +13 -0
  358. package/src/cohort-topic/addressing.ts +112 -0
  359. package/src/cohort-topic/antidos/bootstrap-evidence-envelope.ts +253 -0
  360. package/src/cohort-topic/antidos/bootstrap-evidence.ts +94 -0
  361. package/src/cohort-topic/antidos/index.ts +5 -0
  362. package/src/cohort-topic/antidos/rate-limiter.ts +210 -0
  363. package/src/cohort-topic/antidos/replay-guard.ts +109 -0
  364. package/src/cohort-topic/antidos/topic-budget.ts +145 -0
  365. package/src/cohort-topic/antiflood/index.ts +2 -0
  366. package/src/cohort-topic/antiflood/invariants.ts +108 -0
  367. package/src/cohort-topic/antiflood/jitter.ts +117 -0
  368. package/src/cohort-topic/coldstart.ts +204 -0
  369. package/src/cohort-topic/dmax.ts +88 -0
  370. package/src/cohort-topic/gossip/bus.ts +217 -0
  371. package/src/cohort-topic/gossip/index.ts +3 -0
  372. package/src/cohort-topic/gossip/records.ts +45 -0
  373. package/src/cohort-topic/gossip/view.ts +66 -0
  374. package/src/cohort-topic/index.ts +20 -0
  375. package/src/cohort-topic/load/barometer.ts +134 -0
  376. package/src/cohort-topic/load/index.ts +1 -0
  377. package/src/cohort-topic/member-engine.ts +409 -0
  378. package/src/cohort-topic/membership/index.ts +3 -0
  379. package/src/cohort-topic/membership/publisher.ts +171 -0
  380. package/src/cohort-topic/membership/source.ts +41 -0
  381. package/src/cohort-topic/membership/verifier.ts +345 -0
  382. package/src/cohort-topic/ports.ts +157 -0
  383. package/src/cohort-topic/promotion.ts +384 -0
  384. package/src/cohort-topic/registration/bytes.ts +37 -0
  385. package/src/cohort-topic/registration/handoff.ts +154 -0
  386. package/src/cohort-topic/registration/index.ts +6 -0
  387. package/src/cohort-topic/registration/renewal.ts +423 -0
  388. package/src/cohort-topic/registration/sharding.ts +61 -0
  389. package/src/cohort-topic/registration/store.ts +81 -0
  390. package/src/cohort-topic/registration/types.ts +76 -0
  391. package/src/cohort-topic/ring-hash.ts +50 -0
  392. package/src/cohort-topic/service.ts +390 -0
  393. package/src/cohort-topic/sig/index.ts +2 -0
  394. package/src/cohort-topic/sig/payloads.ts +39 -0
  395. package/src/cohort-topic/sig/threshold.ts +64 -0
  396. package/src/cohort-topic/tiers.ts +74 -0
  397. package/src/cohort-topic/traffic.ts +211 -0
  398. package/src/cohort-topic/walk.ts +255 -0
  399. package/src/cohort-topic/willingness.ts +237 -0
  400. package/src/cohort-topic/wire/codec.ts +204 -0
  401. package/src/cohort-topic/wire/index.ts +16 -0
  402. package/src/cohort-topic/wire/payloads.ts +117 -0
  403. package/src/cohort-topic/wire/types.ts +343 -0
  404. package/src/cohort-topic/wire/validate.ts +478 -0
  405. package/src/collection/collection.ts +93 -1
  406. package/src/collections/tree/tree.ts +84 -3
  407. package/src/index.ts +3 -0
  408. package/src/log/log.ts +86 -7
  409. package/src/log/struct.ts +126 -2
  410. package/src/matchmaking/capability-filter.ts +45 -0
  411. package/src/matchmaking/config.ts +98 -0
  412. package/src/matchmaking/index.ts +21 -0
  413. package/src/matchmaking/multi-cohort-seeker.ts +234 -0
  414. package/src/matchmaking/provider.ts +123 -0
  415. package/src/matchmaking/query-eval.ts +105 -0
  416. package/src/matchmaking/seeker-walk.ts +127 -0
  417. package/src/matchmaking/seeker.ts +86 -0
  418. package/src/matchmaking/topic-anchor.ts +90 -0
  419. package/src/matchmaking/voting-quorum.ts +394 -0
  420. package/src/matchmaking/wire.ts +680 -0
  421. package/src/network/i-repo.ts +9 -0
  422. package/src/network/repo-protocol.ts +3 -2
  423. package/src/network/struct.ts +24 -1
  424. package/src/reactivity/backfill.ts +220 -0
  425. package/src/reactivity/backpressure.ts +191 -0
  426. package/src/reactivity/checkpoint.ts +308 -0
  427. package/src/reactivity/config.ts +172 -0
  428. package/src/reactivity/dedupe.ts +132 -0
  429. package/src/reactivity/forwarder.ts +87 -0
  430. package/src/reactivity/index.ts +34 -0
  431. package/src/reactivity/notification.ts +123 -0
  432. package/src/reactivity/policy.ts +79 -0
  433. package/src/reactivity/push-state.ts +343 -0
  434. package/src/reactivity/recover.ts +153 -0
  435. package/src/reactivity/replay-buffer.ts +141 -0
  436. package/src/reactivity/resume.ts +549 -0
  437. package/src/reactivity/rotation.ts +415 -0
  438. package/src/reactivity/subscriber.ts +132 -0
  439. package/src/reactivity/subscription.ts +66 -0
  440. package/src/reactivity/topic-anchor.ts +71 -0
  441. package/src/reactivity/verify.ts +73 -0
  442. package/src/reactivity/wire-validate.ts +87 -0
  443. package/src/reactivity/wire.ts +224 -0
  444. package/src/transaction/coordinator.ts +53 -27
  445. package/src/transactor/change-notifier.ts +80 -0
  446. package/src/transactor/index.ts +1 -0
  447. package/src/transactor/network-transactor.ts +133 -15
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Reactivity — parent checkpoint summaries (`docs/reactivity.md` §Parent checkpoint summaries).
3
+ *
4
+ * A `W`-revision replay buffer is too shallow for a phone asleep overnight. To extend recoverable range
5
+ * without ballooning replay memory, every parent forwarder cohort (and the tail cohort) maintains a
6
+ * rolling {@link CheckpointSummary} over the `W_checkpoint` revisions sitting **immediately below** the
7
+ * replay ring's low edge — the two windows *stack*, so a single round trip recovers `W + W_checkpoint`
8
+ * revisions (the authoritative stacked semantics, `docs/reactivity.md` §Replay window). As revisions
9
+ * retire from the ring, the forwarder feeds them to {@link RollingCheckpoint.retire}; the checkpoint
10
+ * rolls its `toRevision` forward and trims its low edge to span `W_checkpoint`.
11
+ *
12
+ * The checkpoint is a **hint summary, not a chain replacement**. Two design questions the ticket asks to
13
+ * resolve, decided here:
14
+ *
15
+ * - **`mergedDigest` semantics (resolved → system-level deterministic fold, per-collection override).**
16
+ * `NotificationV1.digest` carries the commit-vote signed payload `utf8(commitHash + ":approve")` —
17
+ * the exact bytes the commit threshold signature was computed over (see
18
+ * `packages/db-core/src/reactivity/notification.ts`). It is per-revision deterministic and identical
19
+ * across cohort members, so the default `mergedDigest` — a deterministic running fold over the
20
+ * per-revision digests in revision order ({@link defaultDigestFold}) — converges under gossip and the
21
+ * application can compare it against its own expectation. A collection MAY override the fold
22
+ * ({@link RollingCheckpointInit.fold}, e.g. a KV collection folding changed-key sets). The merged
23
+ * digest is **not** cryptographically verified — it is a hint; the cryptographic anchor is the
24
+ * bracketing endpoints (below).
25
+ *
26
+ * - **`mergedDelta` vs `delta_max` (resolved → omit when oversize, never split).** The per-revision
27
+ * deltas are coalesced ({@link RollingCheckpointInit.coalesceDeltas}, default concatenation) only when
28
+ * the coalesced result fits within `delta_max`; otherwise `mergedDelta` is omitted entirely and the
29
+ * subscriber relies on `mergedDigest` + the resume's `recentEntries`, or falls back to a chain read. No
30
+ * multi-frame splitting — a checkpoint is a bounded hint.
31
+ *
32
+ * The **bracketing endpoints** are carried as the two full endpoint {@link NotificationV1}s
33
+ * ({@link CheckpointSummary.bracketingEntries}). A bare signature is not independently verifiable — to
34
+ * verify an endpoint is a real committed revision a subscriber needs the signed payload (the commit
35
+ * digest) and the signers, which the full notification carries. {@link verifyCheckpointEndpoints} runs
36
+ * the standard {@link NotificationVerifier} over both endpoints (proving they are real committed
37
+ * revisions) and checks their revisions equal `fromRevision`/`toRevision`; a forged endpoint is rejected.
38
+ */
39
+ import type { IRingHash } from "../cohort-topic/ports.js";
40
+ import type { VerifyResult } from "../cohort-topic/membership/verifier.js";
41
+ import type { RevisionEntry } from "./replay-buffer.js";
42
+ import type { NotificationVerifier } from "./verify.js";
43
+ import { type NotificationV1 } from "./wire.js";
44
+ /**
45
+ * A parent checkpoint summary over `[fromRevision, toRevision]` (`docs/reactivity.md`
46
+ * §Parent checkpoint summaries). All byte fields base64url; `bracketingEntries` is exactly the two
47
+ * endpoint notifications, the verifiable anchor.
48
+ */
49
+ export interface CheckpointSummary {
50
+ /** Collection id, base64url. */
51
+ readonly collectionId: string;
52
+ /** Inclusive low edge of the summarized range. */
53
+ readonly fromRevision: number;
54
+ /** Inclusive high edge of the summarized range (`toRevision - fromRevision + 1 ≈ W_checkpoint`). */
55
+ readonly toRevision: number;
56
+ /** Deterministic fold of the per-revision commit digests across the range, base64url (a hint). */
57
+ readonly mergedDigest: string;
58
+ /** Optional coalesced delta, base64url; omitted when the coalesced size exceeds `delta_max`. */
59
+ readonly mergedDelta?: string;
60
+ /** The two endpoint notifications (at `fromRevision` and `toRevision`) — the verifiable proof. */
61
+ readonly bracketingEntries: readonly [NotificationV1, NotificationV1];
62
+ }
63
+ /** A fold of per-revision commit digests into one summary digest (`docs/reactivity.md` `mergedDigest`). */
64
+ export type DigestFold = (perRevisionDigests: readonly Uint8Array[]) => Uint8Array;
65
+ /** Coalesce per-revision deltas into one bounded delta (`docs/reactivity.md` `mergedDelta`). */
66
+ export type DeltaCoalesce = (perRevisionDeltas: readonly Uint8Array[]) => Uint8Array;
67
+ /**
68
+ * The default system-level `mergedDigest` fold: a deterministic running hash
69
+ * `acc₀ = H(∅); accᵢ = H(accᵢ₋₁ ‖ digestᵢ)` over the per-revision commit digests in revision order.
70
+ * Order-dependent and reproducible, so every cohort member folds to identical bytes (gossip converges).
71
+ */
72
+ export declare function defaultDigestFold(hash?: IRingHash): DigestFold;
73
+ /** The default delta coalescer: ordered concatenation of the per-revision delta bytes. */
74
+ export declare function defaultDeltaCoalesce(deltas: readonly Uint8Array[]): Uint8Array;
75
+ /** The fold/coalesce knobs shared by the rolling checkpoint and the rotation handoff. */
76
+ export interface CheckpointFoldOptions {
77
+ /** Collection id the summarized entries belong to, base64url. */
78
+ readonly collectionId: string;
79
+ /** `mergedDigest` fold over the per-revision commit digests. */
80
+ readonly fold: DigestFold;
81
+ /** `mergedDelta` coalescer over the per-revision deltas. */
82
+ readonly coalesceDeltas: DeltaCoalesce;
83
+ /** `delta_max`: omit `mergedDelta` when the coalesced size exceeds this. `0` ⇒ never emit a delta. */
84
+ readonly deltaMaxBytes: number;
85
+ }
86
+ /**
87
+ * Coalesce the per-revision deltas of `ordered`, returning the base64url result only when it fits within
88
+ * `deltaMaxBytes`. Omitted (`undefined`) when no entry carries a delta, when `deltaMaxBytes <= 0`, or when
89
+ * the coalesced size would exceed `deltaMaxBytes` (the resolved omit-when-oversize policy — never split).
90
+ */
91
+ export declare function coalesceMergedDelta(ordered: readonly RevisionEntry[], coalesceDeltas: DeltaCoalesce, deltaMaxBytes: number): string | undefined;
92
+ /**
93
+ * Build a {@link CheckpointSummary} over `orderedEntries` (ascending by revision) — the shared fold the
94
+ * rolling checkpoint and the rotation buffer-to-checkpoint handoff both use. Returns `undefined` for an
95
+ * empty range. The two endpoints are carried as the full notifications (the verifiable anchor); the merged
96
+ * digest is the deterministic fold over the per-revision commit digests; the coalesced delta is included
97
+ * only when it fits within `deltaMaxBytes`.
98
+ */
99
+ export declare function buildCheckpointSummary(orderedEntries: readonly RevisionEntry[], opts: CheckpointFoldOptions): CheckpointSummary | undefined;
100
+ /** Construction inputs for a {@link RollingCheckpoint}. */
101
+ export interface RollingCheckpointInit {
102
+ /** Collection id, base64url (must match the entries retired into it). */
103
+ readonly collectionId: string;
104
+ /** Checkpoint span `W_checkpoint` (default {@link W_CHECKPOINT_DEFAULT}). */
105
+ readonly span?: number;
106
+ /** Ring hash for the default digest fold. Default db-core SHA-256. */
107
+ readonly hash?: IRingHash;
108
+ /** `mergedDigest` fold (default {@link defaultDigestFold} over the injected hash). */
109
+ readonly fold?: DigestFold;
110
+ /** `mergedDelta` coalescer (default {@link defaultDeltaCoalesce}). */
111
+ readonly coalesceDeltas?: DeltaCoalesce;
112
+ /** `delta_max`: omit `mergedDelta` when the coalesced size exceeds this. `0` ⇒ never emit a delta. */
113
+ readonly deltaMaxBytes?: number;
114
+ }
115
+ /**
116
+ * The rolling `W_checkpoint`-span parent checkpoint. Retains up to `span` retired {@link RevisionEntry}s
117
+ * (the documented per-cohort checkpoint memory cost) so it can fold a real `mergedDigest`, coalesce a
118
+ * `mergedDelta`, and carry the two endpoint notifications. It always covers the `span` revisions just
119
+ * below the replay ring's low edge.
120
+ */
121
+ export declare class RollingCheckpoint {
122
+ readonly collectionId: string;
123
+ readonly span: number;
124
+ private readonly hash;
125
+ private readonly fold;
126
+ private readonly coalesceDeltas;
127
+ private readonly deltaMaxBytes;
128
+ /** revision → retired entry; trimmed to the highest `span` revisions. */
129
+ private readonly byRevision;
130
+ constructor(init: RollingCheckpointInit);
131
+ /** Number of retired revisions currently summarized. */
132
+ get size(): number;
133
+ /** Lowest summarized revision, or `undefined` when empty. */
134
+ get fromRevision(): number | undefined;
135
+ /** Highest summarized revision, or `undefined` when empty. */
136
+ get toRevision(): number | undefined;
137
+ /** True iff `revision` is within the checkpoint's covered range. */
138
+ covers(revision: number): boolean;
139
+ /**
140
+ * Fold one revision retired from the replay ring into the checkpoint. Entries arrive as the ring
141
+ * evicts its low edge; the checkpoint trims to its highest `span` revisions so it tracks the window
142
+ * immediately below the ring. A retransmit at an already-summarized revision replaces in place.
143
+ */
144
+ retire(entry: RevisionEntry): void;
145
+ /** The retired entries, ascending by revision. */
146
+ private orderedEntries;
147
+ /** The fold/coalesce knobs this checkpoint applies — reused by the rotation handoff for an identical fold. */
148
+ get foldOptions(): CheckpointFoldOptions;
149
+ /** Build the {@link CheckpointSummary} over the currently-summarized range, or `undefined` if empty. */
150
+ summary(): CheckpointSummary | undefined;
151
+ }
152
+ /**
153
+ * Verify a checkpoint's bracketing endpoints are real committed revisions: run the standard
154
+ * {@link NotificationVerifier} over both endpoint notifications and confirm their revisions equal
155
+ * `fromRevision`/`toRevision` and their collection matches. Returns `"verified"` only if **both**
156
+ * endpoints verify and align; a forged or tampered endpoint yields `"untrusted"`.
157
+ */
158
+ export declare function verifyCheckpointEndpoints(summary: CheckpointSummary, verifier: NotificationVerifier): Promise<VerifyResult>;
159
+ /**
160
+ * Narrow an already-parsed value to {@link CheckpointSummary}, throwing on any defect. Used by the resume
161
+ * codec to validate a checkpoint embedded in a `checkpoint_window` reply. The two `bracketingEntries` are
162
+ * validated as full {@link NotificationV1}s (the verifiable anchor); `mergedDelta` is optional.
163
+ */
164
+ export declare function validateCheckpointSummary(value: unknown, what?: string): CheckpointSummary;
165
+ //# sourceMappingURL=checkpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkpoint.d.ts","sourceRoot":"","sources":["../../../src/reactivity/checkpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,YA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D;IAC7D,IAAI,YAAY,IAAI,MAAM,GAAG,SAAS,CAErC;IAED,8DAA8D;IAC9D,IAAI,UAAU,IAAI,MAAM,GAAG,SAAS,CAEnC;IAED,oEAAoE;IACpE,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAMjC;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;IAUlC,kDAAkD;IAClD,OAAO,CAAC,cAAc;IAItB,8GAA8G;IAC9G,IAAI,WAAW,IAAI,qBAAqB,CAEvC;IAED,wGAAwG;IACxG,OAAO,IAAI,iBAAiB,GAAG,SAAS;CAGxC;AAED;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAAC,YAAY,CAAC,CAYjI;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,SAAsB,GAAG,iBAAiB,CAmBvG"}
@@ -0,0 +1,232 @@
1
+ /**
2
+ * Reactivity — parent checkpoint summaries (`docs/reactivity.md` §Parent checkpoint summaries).
3
+ *
4
+ * A `W`-revision replay buffer is too shallow for a phone asleep overnight. To extend recoverable range
5
+ * without ballooning replay memory, every parent forwarder cohort (and the tail cohort) maintains a
6
+ * rolling {@link CheckpointSummary} over the `W_checkpoint` revisions sitting **immediately below** the
7
+ * replay ring's low edge — the two windows *stack*, so a single round trip recovers `W + W_checkpoint`
8
+ * revisions (the authoritative stacked semantics, `docs/reactivity.md` §Replay window). As revisions
9
+ * retire from the ring, the forwarder feeds them to {@link RollingCheckpoint.retire}; the checkpoint
10
+ * rolls its `toRevision` forward and trims its low edge to span `W_checkpoint`.
11
+ *
12
+ * The checkpoint is a **hint summary, not a chain replacement**. Two design questions the ticket asks to
13
+ * resolve, decided here:
14
+ *
15
+ * - **`mergedDigest` semantics (resolved → system-level deterministic fold, per-collection override).**
16
+ * `NotificationV1.digest` carries the commit-vote signed payload `utf8(commitHash + ":approve")` —
17
+ * the exact bytes the commit threshold signature was computed over (see
18
+ * `packages/db-core/src/reactivity/notification.ts`). It is per-revision deterministic and identical
19
+ * across cohort members, so the default `mergedDigest` — a deterministic running fold over the
20
+ * per-revision digests in revision order ({@link defaultDigestFold}) — converges under gossip and the
21
+ * application can compare it against its own expectation. A collection MAY override the fold
22
+ * ({@link RollingCheckpointInit.fold}, e.g. a KV collection folding changed-key sets). The merged
23
+ * digest is **not** cryptographically verified — it is a hint; the cryptographic anchor is the
24
+ * bracketing endpoints (below).
25
+ *
26
+ * - **`mergedDelta` vs `delta_max` (resolved → omit when oversize, never split).** The per-revision
27
+ * deltas are coalesced ({@link RollingCheckpointInit.coalesceDeltas}, default concatenation) only when
28
+ * the coalesced result fits within `delta_max`; otherwise `mergedDelta` is omitted entirely and the
29
+ * subscriber relies on `mergedDigest` + the resume's `recentEntries`, or falls back to a chain read. No
30
+ * multi-frame splitting — a checkpoint is a bounded hint.
31
+ *
32
+ * The **bracketing endpoints** are carried as the two full endpoint {@link NotificationV1}s
33
+ * ({@link CheckpointSummary.bracketingEntries}). A bare signature is not independently verifiable — to
34
+ * verify an endpoint is a real committed revision a subscriber needs the signed payload (the commit
35
+ * digest) and the signers, which the full notification carries. {@link verifyCheckpointEndpoints} runs
36
+ * the standard {@link NotificationVerifier} over both endpoints (proving they are real committed
37
+ * revisions) and checks their revisions equal `fromRevision`/`toRevision`; a forged endpoint is rejected.
38
+ */
39
+ import { createRingHash } from "../cohort-topic/ring-hash.js";
40
+ import { bytesToB64url, b64urlToBytes } from "../cohort-topic/wire/codec.js";
41
+ import { W_CHECKPOINT_DEFAULT } from "./config.js";
42
+ import { asObject, b64urlField, failWire, reqIntInRange, reqString } from "./wire-validate.js";
43
+ import { validateNotificationV1 } from "./wire.js";
44
+ /**
45
+ * The default system-level `mergedDigest` fold: a deterministic running hash
46
+ * `acc₀ = H(∅); accᵢ = H(accᵢ₋₁ ‖ digestᵢ)` over the per-revision commit digests in revision order.
47
+ * Order-dependent and reproducible, so every cohort member folds to identical bytes (gossip converges).
48
+ */
49
+ export function defaultDigestFold(hash = createRingHash()) {
50
+ return (digests) => {
51
+ let acc = hash.H(new Uint8Array(0));
52
+ for (const digest of digests) {
53
+ const input = new Uint8Array(acc.length + digest.length);
54
+ input.set(acc, 0);
55
+ input.set(digest, acc.length);
56
+ acc = hash.H(input);
57
+ }
58
+ return acc;
59
+ };
60
+ }
61
+ /** The default delta coalescer: ordered concatenation of the per-revision delta bytes. */
62
+ export function defaultDeltaCoalesce(deltas) {
63
+ const total = deltas.reduce((n, d) => n + d.length, 0);
64
+ const out = new Uint8Array(total);
65
+ let offset = 0;
66
+ for (const d of deltas) {
67
+ out.set(d, offset);
68
+ offset += d.length;
69
+ }
70
+ return out;
71
+ }
72
+ /**
73
+ * Coalesce the per-revision deltas of `ordered`, returning the base64url result only when it fits within
74
+ * `deltaMaxBytes`. Omitted (`undefined`) when no entry carries a delta, when `deltaMaxBytes <= 0`, or when
75
+ * the coalesced size would exceed `deltaMaxBytes` (the resolved omit-when-oversize policy — never split).
76
+ */
77
+ export function coalesceMergedDelta(ordered, coalesceDeltas, deltaMaxBytes) {
78
+ if (deltaMaxBytes <= 0) {
79
+ return undefined;
80
+ }
81
+ const deltas = [];
82
+ for (const e of ordered) {
83
+ if (e.payload.delta !== undefined) {
84
+ deltas.push(b64urlToBytes(e.payload.delta));
85
+ }
86
+ }
87
+ if (deltas.length === 0) {
88
+ return undefined;
89
+ }
90
+ const coalesced = coalesceDeltas(deltas);
91
+ return coalesced.length > deltaMaxBytes ? undefined : bytesToB64url(coalesced);
92
+ }
93
+ /**
94
+ * Build a {@link CheckpointSummary} over `orderedEntries` (ascending by revision) — the shared fold the
95
+ * rolling checkpoint and the rotation buffer-to-checkpoint handoff both use. Returns `undefined` for an
96
+ * empty range. The two endpoints are carried as the full notifications (the verifiable anchor); the merged
97
+ * digest is the deterministic fold over the per-revision commit digests; the coalesced delta is included
98
+ * only when it fits within `deltaMaxBytes`.
99
+ */
100
+ export function buildCheckpointSummary(orderedEntries, opts) {
101
+ if (orderedEntries.length === 0) {
102
+ return undefined;
103
+ }
104
+ const digests = orderedEntries.map((e) => b64urlToBytes(e.payload.digest));
105
+ const mergedDigest = bytesToB64url(opts.fold(digests));
106
+ const first = orderedEntries[0].payload;
107
+ const last = orderedEntries[orderedEntries.length - 1].payload;
108
+ const summary = {
109
+ collectionId: opts.collectionId,
110
+ fromRevision: first.revision,
111
+ toRevision: last.revision,
112
+ mergedDigest,
113
+ bracketingEntries: [first, last],
114
+ };
115
+ const mergedDelta = coalesceMergedDelta(orderedEntries, opts.coalesceDeltas, opts.deltaMaxBytes);
116
+ return mergedDelta !== undefined ? { ...summary, mergedDelta } : summary;
117
+ }
118
+ /**
119
+ * The rolling `W_checkpoint`-span parent checkpoint. Retains up to `span` retired {@link RevisionEntry}s
120
+ * (the documented per-cohort checkpoint memory cost) so it can fold a real `mergedDigest`, coalesce a
121
+ * `mergedDelta`, and carry the two endpoint notifications. It always covers the `span` revisions just
122
+ * below the replay ring's low edge.
123
+ */
124
+ export class RollingCheckpoint {
125
+ collectionId;
126
+ span;
127
+ hash;
128
+ fold;
129
+ coalesceDeltas;
130
+ deltaMaxBytes;
131
+ /** revision → retired entry; trimmed to the highest `span` revisions. */
132
+ byRevision = new Map();
133
+ constructor(init) {
134
+ const span = init.span ?? W_CHECKPOINT_DEFAULT;
135
+ if (!Number.isInteger(span) || span < 1) {
136
+ throw new RangeError(`reactivity checkpoint: span must be an integer >= 1, got ${span}`);
137
+ }
138
+ this.collectionId = init.collectionId;
139
+ this.span = span;
140
+ this.hash = init.hash ?? createRingHash();
141
+ this.fold = init.fold ?? defaultDigestFold(this.hash);
142
+ this.coalesceDeltas = init.coalesceDeltas ?? defaultDeltaCoalesce;
143
+ this.deltaMaxBytes = init.deltaMaxBytes ?? 0;
144
+ }
145
+ /** Number of retired revisions currently summarized. */
146
+ get size() {
147
+ return this.byRevision.size;
148
+ }
149
+ /** Lowest summarized revision, or `undefined` when empty. */
150
+ get fromRevision() {
151
+ return this.size === 0 ? undefined : Math.min(...this.byRevision.keys());
152
+ }
153
+ /** Highest summarized revision, or `undefined` when empty. */
154
+ get toRevision() {
155
+ return this.size === 0 ? undefined : Math.max(...this.byRevision.keys());
156
+ }
157
+ /** True iff `revision` is within the checkpoint's covered range. */
158
+ covers(revision) {
159
+ const from = this.fromRevision;
160
+ const to = this.toRevision;
161
+ return from !== undefined && to !== undefined && revision >= from && revision <= to;
162
+ }
163
+ /**
164
+ * Fold one revision retired from the replay ring into the checkpoint. Entries arrive as the ring
165
+ * evicts its low edge; the checkpoint trims to its highest `span` revisions so it tracks the window
166
+ * immediately below the ring. A retransmit at an already-summarized revision replaces in place.
167
+ */
168
+ retire(entry) {
169
+ if (entry.payload.collectionId !== this.collectionId) {
170
+ return; // an entry for a different collection is not ours to summarize
171
+ }
172
+ this.byRevision.set(entry.revision, entry);
173
+ while (this.byRevision.size > this.span) {
174
+ this.byRevision.delete(Math.min(...this.byRevision.keys()));
175
+ }
176
+ }
177
+ /** The retired entries, ascending by revision. */
178
+ orderedEntries() {
179
+ return [...this.byRevision.values()].sort((a, b) => a.revision - b.revision);
180
+ }
181
+ /** The fold/coalesce knobs this checkpoint applies — reused by the rotation handoff for an identical fold. */
182
+ get foldOptions() {
183
+ return { collectionId: this.collectionId, fold: this.fold, coalesceDeltas: this.coalesceDeltas, deltaMaxBytes: this.deltaMaxBytes };
184
+ }
185
+ /** Build the {@link CheckpointSummary} over the currently-summarized range, or `undefined` if empty. */
186
+ summary() {
187
+ return buildCheckpointSummary(this.orderedEntries(), this.foldOptions);
188
+ }
189
+ }
190
+ /**
191
+ * Verify a checkpoint's bracketing endpoints are real committed revisions: run the standard
192
+ * {@link NotificationVerifier} over both endpoint notifications and confirm their revisions equal
193
+ * `fromRevision`/`toRevision` and their collection matches. Returns `"verified"` only if **both**
194
+ * endpoints verify and align; a forged or tampered endpoint yields `"untrusted"`.
195
+ */
196
+ export async function verifyCheckpointEndpoints(summary, verifier) {
197
+ const [from, to] = summary.bracketingEntries;
198
+ if (from.collectionId !== summary.collectionId ||
199
+ to.collectionId !== summary.collectionId ||
200
+ from.revision !== summary.fromRevision ||
201
+ to.revision !== summary.toRevision) {
202
+ return "untrusted";
203
+ }
204
+ const [fromVerdict, toVerdict] = await Promise.all([verifier.verify(from), verifier.verify(to)]);
205
+ return fromVerdict === "verified" && toVerdict === "verified" ? "verified" : "untrusted";
206
+ }
207
+ /**
208
+ * Narrow an already-parsed value to {@link CheckpointSummary}, throwing on any defect. Used by the resume
209
+ * codec to validate a checkpoint embedded in a `checkpoint_window` reply. The two `bracketingEntries` are
210
+ * validated as full {@link NotificationV1}s (the verifiable anchor); `mergedDelta` is optional.
211
+ */
212
+ export function validateCheckpointSummary(value, what = "CheckpointSummary") {
213
+ const obj = asObject(value, what);
214
+ const fromRevision = reqIntInRange(obj, "fromRevision", what, 0);
215
+ const toRevision = reqIntInRange(obj, "toRevision", what, fromRevision);
216
+ const bracketing = obj["bracketingEntries"];
217
+ if (!Array.isArray(bracketing) || bracketing.length !== 2) {
218
+ failWire(`${what}: field "bracketingEntries" must be a length-2 array`);
219
+ }
220
+ const summary = {
221
+ collectionId: b64urlField(reqString(obj, "collectionId", what), "collectionId", what),
222
+ fromRevision,
223
+ toRevision,
224
+ mergedDigest: b64urlField(reqString(obj, "mergedDigest", what), "mergedDigest", what),
225
+ bracketingEntries: [validateNotificationV1(bracketing[0]), validateNotificationV1(bracketing[1])],
226
+ };
227
+ if (obj["mergedDelta"] !== undefined) {
228
+ return { ...summary, mergedDelta: b64urlField(reqString(obj, "mergedDelta", what), "mergedDelta", what) };
229
+ }
230
+ return summary;
231
+ }
232
+ //# sourceMappingURL=checkpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkpoint.js","sourceRoot":"","sources":["../../../src/reactivity/checkpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC,CAAC,CAAC,CAAC,CAAC;KACjG,CAAC;IACF,IAAI,GAAG,CAAC,aAAa,CAAC,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,EAAE,GAAG,OAAO,EAAE,WAAW,EAAE,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,CAAC;IAC3G,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC"}
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Reactivity — configuration defaults (single source for the hot path).
3
+ *
4
+ * Transcribed from `docs/reactivity.md` §Configuration. Every tunable the reactivity hot path reads
5
+ * is sourced from {@link DEFAULT_REACTIVITY_CONFIG} — never hard-coded at a call site — so the
6
+ * simulator fold-back ([fold-simulator-findings-into-design-docs]) can retune `W` / `dedupe_window`
7
+ * without touching origination, forwarding, the replay buffer, or delivery.
8
+ *
9
+ * **Simulator-validated-pending.** `W` (replay buffer depth), `dedupe_window`, `T_drain`, `queue_max`,
10
+ * and `block_fill_size` are *provisional* pending the design simulator ([simulator-reactivity-replay],
11
+ * folded back by [fold-simulator-findings-into-design-docs]). The simulator's REVISED guidance is that `W`
12
+ * SHOULD become adaptive per measured commit-rate on hot collections (`W ≈ ⌈min_coverage × cps⌉`); the
13
+ * static `W = 256` is kept as the Edge/low-rate default. {@link resolveW} exposes that hook; the
14
+ * simulator's tail-rotation scenario also confirms the re-registration burst stays inside
15
+ * `cap_promote_fast` within `T_drain`, and flags whether `queue_max` should scale with cohort size/tier
16
+ * ({@link resolveQueueMax} is the parallel hook for that fold-back). Sourcing every tunable from this
17
+ * single table is what lets the fold-back revise the values without touching the protocol code.
18
+ *
19
+ * Ownership: `W` / `dedupe_window` ← [reactivity-origination-replay-delivery]; `W_checkpoint` ←
20
+ * [reactivity-backfill-resume-checkpoints]; `queue_max` / `delta_max` / `T_drain` / `warm_threshold` /
21
+ * `block_fill_size` ← [reactivity-rotation-backpressure-policy] (this ticket). `T_rejoin_jitter`, TTL, and
22
+ * ping are inherited from the cohort-topic defaults.
23
+ */
24
+ import type { NodeProfile } from "../cohort-topic/tiers.js";
25
+ /** Replay buffer depth (revisions per cohort, per collection). Simulator-validated-pending. */
26
+ export declare const W_DEFAULT = 256;
27
+ /** Sliding dedupe-window size (revisions). Simulator-validated-pending. */
28
+ export declare const DEDUPE_WINDOW_DEFAULT = 64;
29
+ /** Parent-checkpoint span (revisions). Owned by the backfill/resume ticket; default carried here. */
30
+ export declare const W_CHECKPOINT_DEFAULT = 4096;
31
+ /** Per-subscriber bounded queue depth at a forwarder. Simulator-validated-pending (may scale with cohort/tier). */
32
+ export declare const QUEUE_MAX_DEFAULT = 32;
33
+ /** Max delta payload size on a Core node (bytes). */
34
+ export declare const DELTA_MAX_CORE_BYTES = 4096;
35
+ /** Max delta payload size on an Edge node (bytes) — Edge declines deltas (`0` ⇒ omit `delta`). */
36
+ export declare const DELTA_MAX_EDGE_BYTES = 0;
37
+ /** Subscriber registration TTL on a Core node (ms), inherited from cohort-topic. */
38
+ export declare const SUBSCRIBER_TTL_CORE_MS = 90000;
39
+ /** Subscriber registration TTL on an Edge node (ms), inherited from cohort-topic. */
40
+ export declare const SUBSCRIBER_TTL_EDGE_MS = 60000;
41
+ /** Transactions per block — drives tail rotation. Simulator-validated-pending. */
42
+ export declare const BLOCK_FILL_SIZE_DEFAULT = 64;
43
+ /** Old-tail drain time after rotation (ms). Simulator-validated-pending. */
44
+ export declare const T_DRAIN_MS = 60000;
45
+ /** Transactions remaining in tail before anticipatory warm-up. Owned by the rotation ticket. */
46
+ export declare const WARM_THRESHOLD_DEFAULT = 8;
47
+ /** Subscriber re-registration jitter span after a rotation hint (ms). Inherited from cohort-topic `T_rejoin_jitter`. */
48
+ export declare const T_REJOIN_JITTER_MS = 30000;
49
+ /** The full reactivity config, with the documented defaults. */
50
+ export interface ReactivityConfig {
51
+ /** Replay buffer depth `W`. Simulator-validated-pending. */
52
+ readonly w: number;
53
+ /** Sliding dedupe-window size. Simulator-validated-pending. */
54
+ readonly dedupeWindow: number;
55
+ /** Parent-checkpoint span (reserved; backfill/resume ticket). */
56
+ readonly wCheckpoint: number;
57
+ /** Per-subscriber bounded queue depth (reserved; backpressure ticket). */
58
+ readonly queueMax: number;
59
+ /** Max delta payload size on a Core node (bytes). */
60
+ readonly deltaMaxCoreBytes: number;
61
+ /** Max delta payload size on an Edge node (bytes). */
62
+ readonly deltaMaxEdgeBytes: number;
63
+ /** Subscriber TTL on a Core node (ms). */
64
+ readonly subscriberTtlCoreMs: number;
65
+ /** Subscriber TTL on an Edge node (ms). */
66
+ readonly subscriberTtlEdgeMs: number;
67
+ /** Transactions per block — drives tail rotation. Simulator-validated-pending. */
68
+ readonly blockFillSize: number;
69
+ /** Old-tail drain time after rotation (ms). Simulator-validated-pending. */
70
+ readonly tDrainMs: number;
71
+ /** Transactions remaining before anticipatory warm-up. */
72
+ readonly warmThreshold: number;
73
+ /** Subscriber re-registration jitter span after a rotation (ms); inherited from cohort-topic. */
74
+ readonly tRejoinJitterMs: number;
75
+ }
76
+ /** The default reactivity config (`docs/reactivity.md` §Configuration). */
77
+ export declare const DEFAULT_REACTIVITY_CONFIG: ReactivityConfig;
78
+ /** `delta_max` for a node profile: Core admits deltas up to `delta_max`, Edge declines them (`0`). */
79
+ export declare function deltaMaxForProfile(profile: NodeProfile, config?: ReactivityConfig): number;
80
+ /** Subscriber TTL for a node profile (`docs/reactivity.md` §Subscription): Core 90 s / Edge 60 s. */
81
+ export declare function subscriberTtlForProfile(profile: NodeProfile, config?: ReactivityConfig): number;
82
+ /**
83
+ * Resolve the replay-buffer depth `W` for a collection.
84
+ *
85
+ * Static default (no `cps`): returns the configured `config.w` unchanged — the simulator-confirmed
86
+ * Edge/low-rate default. Adaptive (a measured `cps` and `minCoverageSeconds`): returns
87
+ * `⌈minCoverageSeconds × cps⌉` clamped to `[config.w, maxW]`, the simulator's REVISED guidance for hot
88
+ * collections. This is the single hook the backfill/resume ticket extends; the hot path here only ever
89
+ * calls the static form, so behavior is unchanged until a `cps` is wired through.
90
+ */
91
+ export declare function resolveW(opts?: {
92
+ cps?: number;
93
+ minCoverageSeconds?: number;
94
+ maxW?: number;
95
+ config?: ReactivityConfig;
96
+ }): number;
97
+ /** Default `W_checkpoint`-to-`W` ratio (`docs/reactivity.md` §Parent checkpoint summaries: 16×). */
98
+ export declare const W_CHECKPOINT_RATIO = 16;
99
+ /**
100
+ * Resolve the parent-checkpoint span `W_checkpoint` for a collection.
101
+ *
102
+ * Static default (no `cps`): the configured `config.wCheckpoint` (4096). Adaptive: `W_checkpoint`
103
+ * "scales the same way and may stay a fixed 16× multiple of the resolved `W`" (`docs/reactivity.md`
104
+ * §Configuration), so when a `cps` is supplied it tracks `W_CHECKPOINT_RATIO × resolveW(opts)`. This is
105
+ * the single hook the simulator fold-back ([fold-simulator-findings-into-design-docs]) retunes; the
106
+ * resume classifier reads it so a hot collection's stacked recovery range scales with the replay depth.
107
+ */
108
+ export declare function resolveWCheckpoint(opts?: {
109
+ cps?: number;
110
+ minCoverageSeconds?: number;
111
+ maxW?: number;
112
+ ratio?: number;
113
+ config?: ReactivityConfig;
114
+ }): number;
115
+ /**
116
+ * Resolve the per-subscriber bounded-queue depth `queue_max` for a cohort.
117
+ *
118
+ * Static default (no scaling input): the configured `config.queueMax` (32). The simulator flags whether
119
+ * `queue_max` should scale with cohort size / tier on hot collections; this is the single hook the
120
+ * fold-back ([fold-simulator-findings-into-design-docs]) retunes. When a `cohortSubscribers` count is
121
+ * supplied, the depth scales as `⌈queue_max × subscribers / scaleBaseline⌉` clamped to `[queueMax, maxQueue]`
122
+ * — never below the static default, optionally capped at a per-cohort memory budget. With no scaling input
123
+ * the hot path is unchanged (constant `queue_max`).
124
+ */
125
+ export declare function resolveQueueMax(opts?: {
126
+ cohortSubscribers?: number;
127
+ scaleBaseline?: number;
128
+ maxQueue?: number;
129
+ config?: ReactivityConfig;
130
+ }): number;
131
+ //# sourceMappingURL=config.d.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