@cello-protocol/daemon 0.0.227 → 0.0.228

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 (895) hide show
  1. package/dist/agent-admin-handlers.d.ts +56 -0
  2. package/dist/agent-admin-handlers.d.ts.map +1 -0
  3. package/dist/agent-admin-handlers.js +73 -0
  4. package/dist/agent-admin-handlers.js.map +1 -0
  5. package/dist/agent-handlers.d.ts +72 -0
  6. package/dist/agent-handlers.d.ts.map +1 -0
  7. package/dist/agent-handlers.js +604 -0
  8. package/dist/agent-handlers.js.map +1 -0
  9. package/dist/agent-id-migration.d.ts +70 -0
  10. package/dist/agent-id-migration.d.ts.map +1 -0
  11. package/dist/agent-id-migration.js +468 -0
  12. package/dist/agent-id-migration.js.map +1 -0
  13. package/dist/agent-loader.d.ts +37 -0
  14. package/dist/agent-loader.d.ts.map +1 -0
  15. package/dist/agent-loader.js +37 -0
  16. package/dist/agent-loader.js.map +1 -0
  17. package/dist/agent-selection-root.d.ts +29 -0
  18. package/dist/agent-selection-root.d.ts.map +1 -0
  19. package/dist/agent-selection-root.js +126 -0
  20. package/dist/agent-selection-root.js.map +1 -0
  21. package/dist/agent-selection.d.ts +73 -0
  22. package/dist/agent-selection.d.ts.map +1 -0
  23. package/dist/agent-selection.js +80 -0
  24. package/dist/agent-selection.js.map +1 -0
  25. package/dist/agent-settings-keys.d.ts +52 -0
  26. package/dist/agent-settings-keys.d.ts.map +1 -0
  27. package/dist/agent-settings-keys.js +114 -0
  28. package/dist/agent-settings-keys.js.map +1 -0
  29. package/dist/agent-state.d.ts +67 -0
  30. package/dist/agent-state.d.ts.map +1 -0
  31. package/dist/agent-state.js +66 -0
  32. package/dist/agent-state.js.map +1 -0
  33. package/dist/assignment-verify.d.ts +90 -0
  34. package/dist/assignment-verify.d.ts.map +1 -0
  35. package/dist/assignment-verify.js +301 -0
  36. package/dist/assignment-verify.js.map +1 -0
  37. package/dist/attendance-wiring.d.ts +23 -0
  38. package/dist/attendance-wiring.d.ts.map +1 -0
  39. package/dist/attendance-wiring.js +248 -0
  40. package/dist/attendance-wiring.js.map +1 -0
  41. package/dist/attestation-body.d.ts +47 -0
  42. package/dist/attestation-body.d.ts.map +1 -0
  43. package/dist/attestation-body.js +71 -0
  44. package/dist/attestation-body.js.map +1 -0
  45. package/dist/authorship-verification.d.ts +91 -0
  46. package/dist/authorship-verification.d.ts.map +1 -0
  47. package/dist/authorship-verification.js +532 -0
  48. package/dist/authorship-verification.js.map +1 -0
  49. package/dist/away-detection.d.ts +139 -0
  50. package/dist/away-detection.d.ts.map +1 -0
  51. package/dist/away-detection.js +186 -0
  52. package/dist/away-detection.js.map +1 -0
  53. package/dist/away-inbox-oneshot.d.ts +40 -0
  54. package/dist/away-inbox-oneshot.d.ts.map +1 -0
  55. package/dist/away-inbox-oneshot.js +311 -0
  56. package/dist/away-inbox-oneshot.js.map +1 -0
  57. package/dist/backup-restore-handlers.d.ts +10 -0
  58. package/dist/backup-restore-handlers.d.ts.map +1 -0
  59. package/dist/backup-restore-handlers.js +82 -0
  60. package/dist/backup-restore-handlers.js.map +1 -0
  61. package/dist/backup-restore.d.ts +102 -0
  62. package/dist/backup-restore.d.ts.map +1 -0
  63. package/dist/backup-restore.js +341 -0
  64. package/dist/backup-restore.js.map +1 -0
  65. package/dist/bin/cello-daemon.d.ts +13 -0
  66. package/dist/bin/cello-daemon.d.ts.map +1 -0
  67. package/dist/bin/cello-daemon.js.map +1 -0
  68. package/dist/boot-agents.d.ts +64 -0
  69. package/dist/boot-agents.d.ts.map +1 -0
  70. package/dist/boot-agents.js +241 -0
  71. package/dist/boot-agents.js.map +1 -0
  72. package/dist/boot-connection-state.d.ts +38 -0
  73. package/dist/boot-connection-state.d.ts.map +1 -0
  74. package/dist/boot-connection-state.js +95 -0
  75. package/dist/boot-connection-state.js.map +1 -0
  76. package/dist/boot-core.d.ts +36 -0
  77. package/dist/boot-core.d.ts.map +1 -0
  78. package/dist/boot-core.js +293 -0
  79. package/dist/boot-core.js.map +1 -0
  80. package/dist/boot-parked-content.d.ts +34 -0
  81. package/dist/boot-parked-content.d.ts.map +1 -0
  82. package/dist/boot-parked-content.js +528 -0
  83. package/dist/boot-parked-content.js.map +1 -0
  84. package/dist/boot-sweeps.d.ts +22 -0
  85. package/dist/boot-sweeps.d.ts.map +1 -0
  86. package/dist/boot-sweeps.js +51 -0
  87. package/dist/boot-sweeps.js.map +1 -0
  88. package/dist/bundled-consortium-manifest.d.ts +47 -0
  89. package/dist/bundled-consortium-manifest.d.ts.map +1 -0
  90. package/dist/bundled-consortium-manifest.js +116 -0
  91. package/dist/bundled-consortium-manifest.js.map +1 -0
  92. package/dist/cbor-blob-migration.d.ts +8 -0
  93. package/dist/cbor-blob-migration.d.ts.map +1 -0
  94. package/dist/cbor-blob-migration.js +116 -0
  95. package/dist/cbor-blob-migration.js.map +1 -0
  96. package/dist/challenge-verifier.d.ts +12 -0
  97. package/dist/challenge-verifier.d.ts.map +1 -0
  98. package/dist/challenge-verifier.js +11 -0
  99. package/dist/challenge-verifier.js.map +1 -0
  100. package/dist/channel-log-store.d.ts +80 -0
  101. package/dist/channel-log-store.d.ts.map +1 -0
  102. package/dist/channel-log-store.js +290 -0
  103. package/dist/channel-log-store.js.map +1 -0
  104. package/dist/close-commitment.d.ts +67 -0
  105. package/dist/close-commitment.d.ts.map +1 -0
  106. package/dist/close-commitment.js +78 -0
  107. package/dist/close-commitment.js.map +1 -0
  108. package/dist/close-session-handler.d.ts +94 -0
  109. package/dist/close-session-handler.d.ts.map +1 -0
  110. package/dist/close-session-handler.js +1418 -0
  111. package/dist/close-session-handler.js.map +1 -0
  112. package/dist/co-attendance.d.ts +29 -0
  113. package/dist/co-attendance.d.ts.map +1 -0
  114. package/dist/co-attendance.js +32 -0
  115. package/dist/co-attendance.js.map +1 -0
  116. package/dist/column-birth.d.ts +40 -0
  117. package/dist/column-birth.d.ts.map +1 -0
  118. package/dist/column-birth.js +61 -0
  119. package/dist/column-birth.js.map +1 -0
  120. package/dist/connect-or-start.d.ts +25 -0
  121. package/dist/connect-or-start.d.ts.map +1 -0
  122. package/dist/connect-or-start.js +175 -0
  123. package/dist/connect-or-start.js.map +1 -0
  124. package/dist/connection-agents.d.ts +16 -0
  125. package/dist/connection-agents.d.ts.map +1 -0
  126. package/dist/connection-agents.js +68 -0
  127. package/dist/connection-agents.js.map +1 -0
  128. package/dist/consent-migration.d.ts +49 -0
  129. package/dist/consent-migration.d.ts.map +1 -0
  130. package/dist/consent-migration.js +128 -0
  131. package/dist/consent-migration.js.map +1 -0
  132. package/dist/consortium-bootstrap.d.ts +138 -0
  133. package/dist/consortium-bootstrap.d.ts.map +1 -0
  134. package/dist/consortium-bootstrap.js +339 -0
  135. package/dist/consortium-bootstrap.js.map +1 -0
  136. package/dist/consortium-fingerprint.d.ts +115 -0
  137. package/dist/consortium-fingerprint.d.ts.map +1 -0
  138. package/dist/consortium-fingerprint.js +175 -0
  139. package/dist/consortium-fingerprint.js.map +1 -0
  140. package/dist/contact-handlers.d.ts +59 -0
  141. package/dist/contact-handlers.d.ts.map +1 -0
  142. package/dist/contact-handlers.js +343 -0
  143. package/dist/contact-handlers.js.map +1 -0
  144. package/dist/contact-pubkey-case.d.ts +65 -0
  145. package/dist/contact-pubkey-case.d.ts.map +1 -0
  146. package/dist/contact-pubkey-case.js +136 -0
  147. package/dist/contact-pubkey-case.js.map +1 -0
  148. package/dist/contacts-tier-migration.d.ts +90 -0
  149. package/dist/contacts-tier-migration.d.ts.map +1 -0
  150. package/dist/contacts-tier-migration.js +150 -0
  151. package/dist/contacts-tier-migration.js.map +1 -0
  152. package/dist/content-encryption-status.d.ts +111 -0
  153. package/dist/content-encryption-status.d.ts.map +1 -0
  154. package/dist/content-encryption-status.js +158 -0
  155. package/dist/content-encryption-status.js.map +1 -0
  156. package/dist/content-park-client.d.ts +90 -0
  157. package/dist/content-park-client.d.ts.map +1 -0
  158. package/dist/content-park-client.js +362 -0
  159. package/dist/content-park-client.js.map +1 -0
  160. package/dist/content-park.d.ts +52 -0
  161. package/dist/content-park.d.ts.map +1 -0
  162. package/dist/content-park.js +1309 -0
  163. package/dist/content-park.js.map +1 -0
  164. package/dist/cross-node-negotiation.d.ts +44 -0
  165. package/dist/cross-node-negotiation.d.ts.map +1 -0
  166. package/dist/cross-node-negotiation.js +34 -0
  167. package/dist/cross-node-negotiation.js.map +1 -0
  168. package/dist/daemon-handle.d.ts +57 -0
  169. package/dist/daemon-handle.d.ts.map +1 -0
  170. package/dist/daemon-handle.js +2 -0
  171. package/dist/daemon-handle.js.map +1 -0
  172. package/dist/daemon-status-report.d.ts +50 -0
  173. package/dist/daemon-status-report.d.ts.map +1 -0
  174. package/dist/daemon-status-report.js +81 -0
  175. package/dist/daemon-status-report.js.map +1 -0
  176. package/dist/daemon.d.ts +45 -0
  177. package/dist/daemon.d.ts.map +1 -0
  178. package/dist/daemon.js +1177 -0
  179. package/dist/daemon.js.map +1 -0
  180. package/dist/db-identity-store.d.ts +159 -0
  181. package/dist/db-identity-store.d.ts.map +1 -0
  182. package/dist/db-identity-store.js +502 -0
  183. package/dist/db-identity-store.js.map +1 -0
  184. package/dist/delivery-open-registry.d.ts +92 -0
  185. package/dist/delivery-open-registry.d.ts.map +1 -0
  186. package/dist/delivery-open-registry.js +121 -0
  187. package/dist/delivery-open-registry.js.map +1 -0
  188. package/dist/delivery-session-suspects.d.ts +56 -0
  189. package/dist/delivery-session-suspects.d.ts.map +1 -0
  190. package/dist/delivery-session-suspects.js +94 -0
  191. package/dist/delivery-session-suspects.js.map +1 -0
  192. package/dist/directory-auth-posture.d.ts +87 -0
  193. package/dist/directory-auth-posture.d.ts.map +1 -0
  194. package/dist/directory-auth-posture.js +134 -0
  195. package/dist/directory-auth-posture.js.map +1 -0
  196. package/dist/directory-bootstrap.d.ts +310 -0
  197. package/dist/directory-bootstrap.d.ts.map +1 -0
  198. package/dist/directory-bootstrap.js +557 -0
  199. package/dist/directory-bootstrap.js.map +1 -0
  200. package/dist/directory-connect.d.ts +27 -0
  201. package/dist/directory-connect.d.ts.map +1 -0
  202. package/dist/directory-connect.js +106 -0
  203. package/dist/directory-connect.js.map +1 -0
  204. package/dist/disconnect-cleanup.d.ts +51 -0
  205. package/dist/disconnect-cleanup.d.ts.map +1 -0
  206. package/dist/disconnect-cleanup.js +72 -0
  207. package/dist/disconnect-cleanup.js.map +1 -0
  208. package/dist/document-amendment-store.d.ts +120 -0
  209. package/dist/document-amendment-store.d.ts.map +1 -0
  210. package/dist/document-amendment-store.js +266 -0
  211. package/dist/document-amendment-store.js.map +1 -0
  212. package/dist/document-delivery-transport.d.ts +168 -0
  213. package/dist/document-delivery-transport.d.ts.map +1 -0
  214. package/dist/document-delivery-transport.js +206 -0
  215. package/dist/document-delivery-transport.js.map +1 -0
  216. package/dist/document-engine.d.ts +134 -0
  217. package/dist/document-engine.d.ts.map +1 -0
  218. package/dist/document-engine.js +282 -0
  219. package/dist/document-engine.js.map +1 -0
  220. package/dist/document-flag.d.ts +58 -0
  221. package/dist/document-flag.d.ts.map +1 -0
  222. package/dist/document-flag.js +70 -0
  223. package/dist/document-flag.js.map +1 -0
  224. package/dist/document-frame-router.d.ts +245 -0
  225. package/dist/document-frame-router.d.ts.map +1 -0
  226. package/dist/document-frame-router.js +397 -0
  227. package/dist/document-frame-router.js.map +1 -0
  228. package/dist/document-gate-wiring.d.ts +61 -0
  229. package/dist/document-gate-wiring.d.ts.map +1 -0
  230. package/dist/document-gate-wiring.js +125 -0
  231. package/dist/document-gate-wiring.js.map +1 -0
  232. package/dist/document-gate.d.ts +149 -0
  233. package/dist/document-gate.d.ts.map +1 -0
  234. package/dist/document-gate.js +509 -0
  235. package/dist/document-gate.js.map +1 -0
  236. package/dist/document-handlers.d.ts +47 -0
  237. package/dist/document-handlers.d.ts.map +1 -0
  238. package/dist/document-handlers.js +2203 -0
  239. package/dist/document-handlers.js.map +1 -0
  240. package/dist/document-handshake.d.ts +176 -0
  241. package/dist/document-handshake.d.ts.map +1 -0
  242. package/dist/document-handshake.js +452 -0
  243. package/dist/document-handshake.js.map +1 -0
  244. package/dist/document-inbound.d.ts +162 -0
  245. package/dist/document-inbound.d.ts.map +1 -0
  246. package/dist/document-inbound.js +530 -0
  247. package/dist/document-inbound.js.map +1 -0
  248. package/dist/document-json.d.ts +120 -0
  249. package/dist/document-json.d.ts.map +1 -0
  250. package/dist/document-json.js +191 -0
  251. package/dist/document-json.js.map +1 -0
  252. package/dist/document-layer.d.ts +215 -0
  253. package/dist/document-layer.d.ts.map +1 -0
  254. package/dist/document-layer.js +1025 -0
  255. package/dist/document-layer.js.map +1 -0
  256. package/dist/document-lifecycle.d.ts +52 -0
  257. package/dist/document-lifecycle.d.ts.map +1 -0
  258. package/dist/document-lifecycle.js +134 -0
  259. package/dist/document-lifecycle.js.map +1 -0
  260. package/dist/document-live-docs.d.ts +58 -0
  261. package/dist/document-live-docs.d.ts.map +1 -0
  262. package/dist/document-live-docs.js +126 -0
  263. package/dist/document-live-docs.js.map +1 -0
  264. package/dist/document-notify.d.ts +228 -0
  265. package/dist/document-notify.d.ts.map +1 -0
  266. package/dist/document-notify.js +580 -0
  267. package/dist/document-notify.js.map +1 -0
  268. package/dist/document-profile.d.ts +61 -0
  269. package/dist/document-profile.d.ts.map +1 -0
  270. package/dist/document-profile.js +112 -0
  271. package/dist/document-profile.js.map +1 -0
  272. package/dist/document-publish.d.ts +87 -0
  273. package/dist/document-publish.d.ts.map +1 -0
  274. package/dist/document-publish.js +173 -0
  275. package/dist/document-publish.js.map +1 -0
  276. package/dist/document-reachability.d.ts +42 -0
  277. package/dist/document-reachability.d.ts.map +1 -0
  278. package/dist/document-reachability.js +80 -0
  279. package/dist/document-reachability.js.map +1 -0
  280. package/dist/document-reconcile-engine.d.ts +66 -0
  281. package/dist/document-reconcile-engine.d.ts.map +1 -0
  282. package/dist/document-reconcile-engine.js +225 -0
  283. package/dist/document-reconcile-engine.js.map +1 -0
  284. package/dist/document-reconcile-scheduler.d.ts +163 -0
  285. package/dist/document-reconcile-scheduler.d.ts.map +1 -0
  286. package/dist/document-reconcile-scheduler.js +303 -0
  287. package/dist/document-reconcile-scheduler.js.map +1 -0
  288. package/dist/document-rejection.d.ts +251 -0
  289. package/dist/document-rejection.d.ts.map +1 -0
  290. package/dist/document-rejection.js +435 -0
  291. package/dist/document-rejection.js.map +1 -0
  292. package/dist/document-screen.d.ts +114 -0
  293. package/dist/document-screen.d.ts.map +1 -0
  294. package/dist/document-screen.js +223 -0
  295. package/dist/document-screen.js.map +1 -0
  296. package/dist/document-store.d.ts +372 -0
  297. package/dist/document-store.d.ts.map +1 -0
  298. package/dist/document-store.js +931 -0
  299. package/dist/document-store.js.map +1 -0
  300. package/dist/document-surface.d.ts +32 -0
  301. package/dist/document-surface.d.ts.map +1 -0
  302. package/dist/document-surface.js +151 -0
  303. package/dist/document-surface.js.map +1 -0
  304. package/dist/document-types.d.ts +94 -0
  305. package/dist/document-types.d.ts.map +1 -0
  306. package/dist/document-types.js +90 -0
  307. package/dist/document-types.js.map +1 -0
  308. package/dist/document-watch.d.ts +69 -0
  309. package/dist/document-watch.d.ts.map +1 -0
  310. package/dist/document-watch.js +108 -0
  311. package/dist/document-watch.js.map +1 -0
  312. package/dist/document-wiring.d.ts +53 -0
  313. package/dist/document-wiring.d.ts.map +1 -0
  314. package/dist/document-wiring.js +323 -0
  315. package/dist/document-wiring.js.map +1 -0
  316. package/dist/document-write-guard.d.ts +66 -0
  317. package/dist/document-write-guard.d.ts.map +1 -0
  318. package/dist/document-write-guard.js +98 -0
  319. package/dist/document-write-guard.js.map +1 -0
  320. package/dist/document-write-path.d.ts +94 -0
  321. package/dist/document-write-path.d.ts.map +1 -0
  322. package/dist/document-write-path.js +530 -0
  323. package/dist/document-write-path.js.map +1 -0
  324. package/dist/error-message.d.ts +7 -0
  325. package/dist/error-message.d.ts.map +1 -0
  326. package/dist/error-message.js +19 -0
  327. package/dist/error-message.js.map +1 -0
  328. package/dist/file-manifest-provider.d.ts +37 -0
  329. package/dist/file-manifest-provider.d.ts.map +1 -0
  330. package/dist/file-manifest-provider.js +105 -0
  331. package/dist/file-manifest-provider.js.map +1 -0
  332. package/dist/frame-values.d.ts +3 -0
  333. package/dist/frame-values.d.ts.map +1 -0
  334. package/dist/frame-values.js +84 -0
  335. package/dist/frame-values.js.map +1 -0
  336. package/dist/frontier-mismatch.d.ts +73 -0
  337. package/dist/frontier-mismatch.d.ts.map +1 -0
  338. package/dist/frontier-mismatch.js +89 -0
  339. package/dist/frontier-mismatch.js.map +1 -0
  340. package/dist/gateway-config-handlers.d.ts +26 -0
  341. package/dist/gateway-config-handlers.d.ts.map +1 -0
  342. package/dist/gateway-config-handlers.js +429 -0
  343. package/dist/gateway-config-handlers.js.map +1 -0
  344. package/dist/held-content.d.ts +145 -0
  345. package/dist/held-content.d.ts.map +1 -0
  346. package/dist/held-content.js +389 -0
  347. package/dist/held-content.js.map +1 -0
  348. package/dist/http-manifest-poll.d.ts +67 -0
  349. package/dist/http-manifest-poll.d.ts.map +1 -0
  350. package/dist/http-manifest-poll.js +150 -0
  351. package/dist/http-manifest-poll.js.map +1 -0
  352. package/dist/identity-migration.d.ts +40 -0
  353. package/dist/identity-migration.d.ts.map +1 -0
  354. package/dist/identity-migration.js +461 -0
  355. package/dist/identity-migration.js.map +1 -0
  356. package/dist/inbound-refusals.d.ts +283 -0
  357. package/dist/inbound-refusals.d.ts.map +1 -0
  358. package/dist/inbound-refusals.js +919 -0
  359. package/dist/inbound-refusals.js.map +1 -0
  360. package/dist/inbound-seal-request.d.ts +32 -0
  361. package/dist/inbound-seal-request.d.ts.map +1 -0
  362. package/dist/inbound-seal-request.js +228 -0
  363. package/dist/inbound-seal-request.js.map +1 -0
  364. package/dist/inbound-sessions.d.ts +291 -0
  365. package/dist/inbound-sessions.d.ts.map +1 -0
  366. package/dist/inbound-sessions.js +1609 -0
  367. package/dist/inbound-sessions.js.map +1 -0
  368. package/dist/inclusion-proof-handlers.d.ts +43 -0
  369. package/dist/inclusion-proof-handlers.d.ts.map +1 -0
  370. package/dist/inclusion-proof-handlers.js +565 -0
  371. package/dist/inclusion-proof-handlers.js.map +1 -0
  372. package/dist/inclusion-proof.d.ts +151 -0
  373. package/dist/inclusion-proof.d.ts.map +1 -0
  374. package/dist/inclusion-proof.js +228 -0
  375. package/dist/inclusion-proof.js.map +1 -0
  376. package/dist/index.d.ts +32 -0
  377. package/dist/index.d.ts.map +1 -0
  378. package/dist/index.js.map +1 -0
  379. package/dist/initiate-session-handler.d.ts +55 -0
  380. package/dist/initiate-session-handler.d.ts.map +1 -0
  381. package/dist/initiate-session-handler.js +310 -0
  382. package/dist/initiate-session-handler.js.map +1 -0
  383. package/dist/ipc-client.d.ts +31 -0
  384. package/dist/ipc-client.d.ts.map +1 -0
  385. package/dist/ipc-client.js +113 -0
  386. package/dist/ipc-client.js.map +1 -0
  387. package/dist/ipc-server.d.ts +63 -0
  388. package/dist/ipc-server.d.ts.map +1 -0
  389. package/dist/ipc-server.js +429 -0
  390. package/dist/ipc-server.js.map +1 -0
  391. package/dist/ipc-surface.d.ts +44 -0
  392. package/dist/ipc-surface.d.ts.map +1 -0
  393. package/dist/ipc-surface.js +107 -0
  394. package/dist/ipc-surface.js.map +1 -0
  395. package/dist/line-lcs.d.ts +51 -0
  396. package/dist/line-lcs.d.ts.map +1 -0
  397. package/dist/line-lcs.js +71 -0
  398. package/dist/line-lcs.js.map +1 -0
  399. package/dist/lock-file.d.ts +39 -0
  400. package/dist/lock-file.d.ts.map +1 -0
  401. package/dist/lock-file.js +120 -0
  402. package/dist/lock-file.js.map +1 -0
  403. package/dist/log-collapse.d.ts +66 -0
  404. package/dist/log-collapse.d.ts.map +1 -0
  405. package/dist/log-collapse.js +244 -0
  406. package/dist/log-collapse.js.map +1 -0
  407. package/dist/log-rotate.d.ts +67 -0
  408. package/dist/log-rotate.d.ts.map +1 -0
  409. package/dist/log-rotate.js +134 -0
  410. package/dist/log-rotate.js.map +1 -0
  411. package/dist/manifest-deps.d.ts +25 -0
  412. package/dist/manifest-deps.d.ts.map +1 -0
  413. package/dist/manifest-deps.js +151 -0
  414. package/dist/manifest-deps.js.map +1 -0
  415. package/dist/manifest-poll-scheduler.d.ts +31 -0
  416. package/dist/manifest-poll-scheduler.d.ts.map +1 -0
  417. package/dist/manifest-poll-scheduler.js +59 -0
  418. package/dist/manifest-poll-scheduler.js.map +1 -0
  419. package/dist/manifest-validity.d.ts +153 -0
  420. package/dist/manifest-validity.d.ts.map +1 -0
  421. package/dist/manifest-validity.js +268 -0
  422. package/dist/manifest-validity.js.map +1 -0
  423. package/dist/manifest-version-store-db.d.ts +24 -0
  424. package/dist/manifest-version-store-db.d.ts.map +1 -0
  425. package/dist/manifest-version-store-db.js +58 -0
  426. package/dist/manifest-version-store-db.js.map +1 -0
  427. package/dist/manifest-version-store.d.ts +16 -0
  428. package/dist/manifest-version-store.d.ts.map +1 -0
  429. package/dist/manifest-version-store.js +15 -0
  430. package/dist/manifest-version-store.js.map +1 -0
  431. package/dist/network-directory-node.d.ts +136 -0
  432. package/dist/network-directory-node.d.ts.map +1 -0
  433. package/dist/network-directory-node.js +810 -0
  434. package/dist/network-directory-node.js.map +1 -0
  435. package/dist/nonce-dedup.d.ts +68 -0
  436. package/dist/nonce-dedup.d.ts.map +1 -0
  437. package/dist/nonce-dedup.js +205 -0
  438. package/dist/nonce-dedup.js.map +1 -0
  439. package/dist/notification-dispatcher.d.ts +92 -0
  440. package/dist/notification-dispatcher.d.ts.map +1 -0
  441. package/dist/notification-dispatcher.js +210 -0
  442. package/dist/notification-dispatcher.js.map +1 -0
  443. package/dist/notification-handlers.d.ts +53 -0
  444. package/dist/notification-handlers.d.ts.map +1 -0
  445. package/dist/notification-handlers.js +461 -0
  446. package/dist/notification-handlers.js.map +1 -0
  447. package/dist/onboarding-guidance.d.ts +79 -0
  448. package/dist/onboarding-guidance.d.ts.map +1 -0
  449. package/dist/onboarding-guidance.js +95 -0
  450. package/dist/onboarding-guidance.js.map +1 -0
  451. package/dist/operator-guidance.d.ts +25 -0
  452. package/dist/operator-guidance.d.ts.map +1 -0
  453. package/dist/operator-guidance.js +50 -0
  454. package/dist/operator-guidance.js.map +1 -0
  455. package/dist/orphan-triage.d.ts +130 -0
  456. package/dist/orphan-triage.d.ts.map +1 -0
  457. package/dist/orphan-triage.js +207 -0
  458. package/dist/orphan-triage.js.map +1 -0
  459. package/dist/outbound-sessions.d.ts +126 -0
  460. package/dist/outbound-sessions.d.ts.map +1 -0
  461. package/dist/outbound-sessions.js +1052 -0
  462. package/dist/outbound-sessions.js.map +1 -0
  463. package/dist/park-envelope.d.ts +329 -0
  464. package/dist/park-envelope.d.ts.map +1 -0
  465. package/dist/park-envelope.js +509 -0
  466. package/dist/park-envelope.js.map +1 -0
  467. package/dist/park-recovery.d.ts +273 -0
  468. package/dist/park-recovery.d.ts.map +1 -0
  469. package/dist/park-recovery.js +717 -0
  470. package/dist/park-recovery.js.map +1 -0
  471. package/dist/park-refusals.d.ts +147 -0
  472. package/dist/park-refusals.d.ts.map +1 -0
  473. package/dist/park-refusals.js +331 -0
  474. package/dist/park-refusals.js.map +1 -0
  475. package/dist/quarantine-framing.d.ts +92 -0
  476. package/dist/quarantine-framing.d.ts.map +1 -0
  477. package/dist/quarantine-framing.js +111 -0
  478. package/dist/quarantine-framing.js.map +1 -0
  479. package/dist/reconnect-drain.d.ts +22 -0
  480. package/dist/reconnect-drain.d.ts.map +1 -0
  481. package/dist/reconnect-drain.js +65 -0
  482. package/dist/reconnect-drain.js.map +1 -0
  483. package/dist/recovered-position.d.ts +14 -0
  484. package/dist/recovered-position.d.ts.map +1 -0
  485. package/dist/recovered-position.js +59 -0
  486. package/dist/recovered-position.js.map +1 -0
  487. package/dist/refusal-notices.d.ts +196 -0
  488. package/dist/refusal-notices.d.ts.map +1 -0
  489. package/dist/refusal-notices.js +516 -0
  490. package/dist/refusal-notices.js.map +1 -0
  491. package/dist/refusal-reasons.d.ts +245 -0
  492. package/dist/refusal-reasons.d.ts.map +1 -0
  493. package/dist/refusal-reasons.js +363 -0
  494. package/dist/refusal-reasons.js.map +1 -0
  495. package/dist/register-handler.d.ts +36 -0
  496. package/dist/register-handler.d.ts.map +1 -0
  497. package/dist/register-handler.js +285 -0
  498. package/dist/register-handler.js.map +1 -0
  499. package/dist/registration-context.d.ts +72 -0
  500. package/dist/registration-context.d.ts.map +1 -0
  501. package/dist/registration-context.js +126 -0
  502. package/dist/registration-context.js.map +1 -0
  503. package/dist/registration-manager.d.ts +94 -0
  504. package/dist/registration-manager.d.ts.map +1 -0
  505. package/dist/registration-manager.js +585 -0
  506. package/dist/registration-manager.js.map +1 -0
  507. package/dist/registration-persistence.d.ts +183 -0
  508. package/dist/registration-persistence.d.ts.map +1 -0
  509. package/dist/registration-persistence.js +263 -0
  510. package/dist/registration-persistence.js.map +1 -0
  511. package/dist/registry-poll.d.ts +52 -0
  512. package/dist/registry-poll.d.ts.map +1 -0
  513. package/dist/registry-poll.js +140 -0
  514. package/dist/registry-poll.js.map +1 -0
  515. package/dist/registry-version-store-db.d.ts +22 -0
  516. package/dist/registry-version-store-db.d.ts.map +1 -0
  517. package/dist/registry-version-store-db.js +50 -0
  518. package/dist/registry-version-store-db.js.map +1 -0
  519. package/dist/relay-endpoints.d.ts +18 -0
  520. package/dist/relay-endpoints.d.ts.map +1 -0
  521. package/dist/relay-endpoints.js +9 -0
  522. package/dist/relay-endpoints.js.map +1 -0
  523. package/dist/relay-only.d.ts +140 -0
  524. package/dist/relay-only.d.ts.map +1 -0
  525. package/dist/relay-only.js +193 -0
  526. package/dist/relay-only.js.map +1 -0
  527. package/dist/relay-receipt-store.d.ts +155 -0
  528. package/dist/relay-receipt-store.d.ts.map +1 -0
  529. package/dist/relay-receipt-store.js +284 -0
  530. package/dist/relay-receipt-store.js.map +1 -0
  531. package/dist/relay-reconnect.d.ts +32 -0
  532. package/dist/relay-reconnect.d.ts.map +1 -0
  533. package/dist/relay-reconnect.js +29 -0
  534. package/dist/relay-reconnect.js.map +1 -0
  535. package/dist/reply-lag.d.ts +11 -0
  536. package/dist/reply-lag.d.ts.map +1 -0
  537. package/dist/reply-lag.js +46 -0
  538. package/dist/reply-lag.js.map +1 -0
  539. package/dist/resolve-named-agent.d.ts +49 -0
  540. package/dist/resolve-named-agent.d.ts.map +1 -0
  541. package/dist/resolve-named-agent.js +77 -0
  542. package/dist/resolve-named-agent.js.map +1 -0
  543. package/dist/restart-seal-resolver.d.ts +110 -0
  544. package/dist/restart-seal-resolver.d.ts.map +1 -0
  545. package/dist/restart-seal-resolver.js +353 -0
  546. package/dist/restart-seal-resolver.js.map +1 -0
  547. package/dist/resume-last-seen.d.ts +15 -0
  548. package/dist/resume-last-seen.d.ts.map +1 -0
  549. package/dist/resume-last-seen.js +44 -0
  550. package/dist/resume-last-seen.js.map +1 -0
  551. package/dist/retry-queue.d.ts +203 -0
  552. package/dist/retry-queue.d.ts.map +1 -0
  553. package/dist/retry-queue.js +701 -0
  554. package/dist/retry-queue.js.map +1 -0
  555. package/dist/roster-freshness.d.ts +160 -0
  556. package/dist/roster-freshness.d.ts.map +1 -0
  557. package/dist/roster-freshness.js +250 -0
  558. package/dist/roster-freshness.js.map +1 -0
  559. package/dist/screening-status.d.ts +15 -0
  560. package/dist/screening-status.d.ts.map +1 -0
  561. package/dist/screening-status.js +65 -0
  562. package/dist/screening-status.js.map +1 -0
  563. package/dist/seal-carried-close.d.ts +37 -0
  564. package/dist/seal-carried-close.d.ts.map +1 -0
  565. package/dist/seal-carried-close.js +179 -0
  566. package/dist/seal-carried-close.js.map +1 -0
  567. package/dist/seal-certificate-pull.d.ts +79 -0
  568. package/dist/seal-certificate-pull.d.ts.map +1 -0
  569. package/dist/seal-certificate-pull.js +186 -0
  570. package/dist/seal-certificate-pull.js.map +1 -0
  571. package/dist/seal-certified-root-check.d.ts +37 -0
  572. package/dist/seal-certified-root-check.d.ts.map +1 -0
  573. package/dist/seal-certified-root-check.js +127 -0
  574. package/dist/seal-certified-root-check.js.map +1 -0
  575. package/dist/seal-coordinator.d.ts +118 -0
  576. package/dist/seal-coordinator.d.ts.map +1 -0
  577. package/dist/seal-coordinator.js +927 -0
  578. package/dist/seal-coordinator.js.map +1 -0
  579. package/dist/seal-escalation.d.ts +80 -0
  580. package/dist/seal-escalation.d.ts.map +1 -0
  581. package/dist/seal-escalation.js +283 -0
  582. package/dist/seal-escalation.js.map +1 -0
  583. package/dist/seal-evidence-root-check.d.ts +70 -0
  584. package/dist/seal-evidence-root-check.d.ts.map +1 -0
  585. package/dist/seal-evidence-root-check.js +199 -0
  586. package/dist/seal-evidence-root-check.js.map +1 -0
  587. package/dist/seal-failure-store.d.ts +139 -0
  588. package/dist/seal-failure-store.d.ts.map +1 -0
  589. package/dist/seal-failure-store.js +207 -0
  590. package/dist/seal-failure-store.js.map +1 -0
  591. package/dist/seal-flows.d.ts +107 -0
  592. package/dist/seal-flows.d.ts.map +1 -0
  593. package/dist/seal-flows.js +638 -0
  594. package/dist/seal-flows.js.map +1 -0
  595. package/dist/seal-frontier-verify.d.ts +103 -0
  596. package/dist/seal-frontier-verify.d.ts.map +1 -0
  597. package/dist/seal-frontier-verify.js +143 -0
  598. package/dist/seal-frontier-verify.js.map +1 -0
  599. package/dist/seal-leaf.d.ts +58 -0
  600. package/dist/seal-leaf.d.ts.map +1 -0
  601. package/dist/seal-leaf.js +112 -0
  602. package/dist/seal-leaf.js.map +1 -0
  603. package/dist/seal-legibility-tbs.d.ts +25 -0
  604. package/dist/seal-legibility-tbs.d.ts.map +1 -0
  605. package/dist/seal-legibility-tbs.js +77 -0
  606. package/dist/seal-legibility-tbs.js.map +1 -0
  607. package/dist/seal-local-terminus.d.ts +41 -0
  608. package/dist/seal-local-terminus.d.ts.map +1 -0
  609. package/dist/seal-local-terminus.js +170 -0
  610. package/dist/seal-local-terminus.js.map +1 -0
  611. package/dist/seal-receipt-upgrade.d.ts +30 -0
  612. package/dist/seal-receipt-upgrade.d.ts.map +1 -0
  613. package/dist/seal-receipt-upgrade.js +49 -0
  614. package/dist/seal-receipt-upgrade.js.map +1 -0
  615. package/dist/seal-relay-silence.d.ts +51 -0
  616. package/dist/seal-relay-silence.d.ts.map +1 -0
  617. package/dist/seal-relay-silence.js +76 -0
  618. package/dist/seal-relay-silence.js.map +1 -0
  619. package/dist/seal-settle.d.ts +38 -0
  620. package/dist/seal-settle.d.ts.map +1 -0
  621. package/dist/seal-settle.js +33 -0
  622. package/dist/seal-settle.js.map +1 -0
  623. package/dist/seal-upgrade.d.ts +107 -0
  624. package/dist/seal-upgrade.d.ts.map +1 -0
  625. package/dist/seal-upgrade.js +200 -0
  626. package/dist/seal-upgrade.js.map +1 -0
  627. package/dist/sealed-conversation.d.ts +36 -0
  628. package/dist/sealed-conversation.d.ts.map +1 -0
  629. package/dist/sealed-conversation.js +171 -0
  630. package/dist/sealed-conversation.js.map +1 -0
  631. package/dist/sealed-leaf-set.d.ts +92 -0
  632. package/dist/sealed-leaf-set.d.ts.map +1 -0
  633. package/dist/sealed-leaf-set.js +122 -0
  634. package/dist/sealed-leaf-set.js.map +1 -0
  635. package/dist/send-claims.d.ts +56 -0
  636. package/dist/send-claims.d.ts.map +1 -0
  637. package/dist/send-claims.js +50 -0
  638. package/dist/send-claims.js.map +1 -0
  639. package/dist/session-assignment-parser.d.ts +104 -0
  640. package/dist/session-assignment-parser.d.ts.map +1 -0
  641. package/dist/session-assignment-parser.js +345 -0
  642. package/dist/session-assignment-parser.js.map +1 -0
  643. package/dist/session-category.d.ts +19 -0
  644. package/dist/session-category.d.ts.map +1 -0
  645. package/dist/session-category.js +14 -0
  646. package/dist/session-category.js.map +1 -0
  647. package/dist/session-ceremony.d.ts +297 -0
  648. package/dist/session-ceremony.d.ts.map +1 -0
  649. package/dist/session-ceremony.js +964 -0
  650. package/dist/session-ceremony.js.map +1 -0
  651. package/dist/session-closed.d.ts +79 -0
  652. package/dist/session-closed.d.ts.map +1 -0
  653. package/dist/session-closed.js +189 -0
  654. package/dist/session-closed.js.map +1 -0
  655. package/dist/session-connection-gater.d.ts +148 -0
  656. package/dist/session-connection-gater.d.ts.map +1 -0
  657. package/dist/session-connection-gater.js +332 -0
  658. package/dist/session-connection-gater.js.map +1 -0
  659. package/dist/session-content-context.d.ts +162 -0
  660. package/dist/session-content-context.d.ts.map +1 -0
  661. package/dist/session-content-context.js +2 -0
  662. package/dist/session-content-context.js.map +1 -0
  663. package/dist/session-content-handlers.d.ts +82 -0
  664. package/dist/session-content-handlers.d.ts.map +1 -0
  665. package/dist/session-content-handlers.js +1382 -0
  666. package/dist/session-content-handlers.js.map +1 -0
  667. package/dist/session-content-ingest.d.ts +206 -0
  668. package/dist/session-content-ingest.d.ts.map +1 -0
  669. package/dist/session-content-ingest.js +2167 -0
  670. package/dist/session-content-ingest.js.map +1 -0
  671. package/dist/session-content-send.d.ts +191 -0
  672. package/dist/session-content-send.d.ts.map +1 -0
  673. package/dist/session-content-send.js +1360 -0
  674. package/dist/session-content-send.js.map +1 -0
  675. package/dist/session-delivery-acks.d.ts +169 -0
  676. package/dist/session-delivery-acks.d.ts.map +1 -0
  677. package/dist/session-delivery-acks.js +569 -0
  678. package/dist/session-delivery-acks.js.map +1 -0
  679. package/dist/session-ephemerals.d.ts +279 -0
  680. package/dist/session-ephemerals.d.ts.map +1 -0
  681. package/dist/session-ephemerals.js +591 -0
  682. package/dist/session-ephemerals.js.map +1 -0
  683. package/dist/session-leaf-records.d.ts +159 -0
  684. package/dist/session-leaf-records.d.ts.map +1 -0
  685. package/dist/session-leaf-records.js +408 -0
  686. package/dist/session-leaf-records.js.map +1 -0
  687. package/dist/session-lifecycle.d.ts +303 -0
  688. package/dist/session-lifecycle.d.ts.map +1 -0
  689. package/dist/session-lifecycle.js +1679 -0
  690. package/dist/session-lifecycle.js.map +1 -0
  691. package/dist/session-liveness.d.ts +135 -0
  692. package/dist/session-liveness.d.ts.map +1 -0
  693. package/dist/session-liveness.js +347 -0
  694. package/dist/session-liveness.js.map +1 -0
  695. package/dist/session-name.d.ts +35 -0
  696. package/dist/session-name.d.ts.map +1 -0
  697. package/dist/session-name.js +60 -0
  698. package/dist/session-name.js.map +1 -0
  699. package/dist/session-node-factory.d.ts +18 -0
  700. package/dist/session-node-factory.d.ts.map +1 -0
  701. package/dist/session-node-factory.js +182 -0
  702. package/dist/session-node-factory.js.map +1 -0
  703. package/dist/session-node-manager.d.ts +877 -0
  704. package/dist/session-node-manager.d.ts.map +1 -0
  705. package/dist/session-node-manager.js +2998 -0
  706. package/dist/session-node-manager.js.map +1 -0
  707. package/dist/session-node-types.d.ts +1057 -0
  708. package/dist/session-node-types.d.ts.map +1 -0
  709. package/dist/session-node-types.js +657 -0
  710. package/dist/session-node-types.js.map +1 -0
  711. package/dist/session-notify.d.ts +46 -0
  712. package/dist/session-notify.d.ts.map +1 -0
  713. package/dist/session-notify.js +116 -0
  714. package/dist/session-notify.js.map +1 -0
  715. package/dist/session-own-chain-store.d.ts +65 -0
  716. package/dist/session-own-chain-store.d.ts.map +1 -0
  717. package/dist/session-own-chain-store.js +75 -0
  718. package/dist/session-own-chain-store.js.map +1 -0
  719. package/dist/session-queries.d.ts +476 -0
  720. package/dist/session-queries.d.ts.map +1 -0
  721. package/dist/session-queries.js +1007 -0
  722. package/dist/session-queries.js.map +1 -0
  723. package/dist/session-read-handlers.d.ts +87 -0
  724. package/dist/session-read-handlers.d.ts.map +1 -0
  725. package/dist/session-read-handlers.js +689 -0
  726. package/dist/session-read-handlers.js.map +1 -0
  727. package/dist/session-records.d.ts +341 -0
  728. package/dist/session-records.d.ts.map +1 -0
  729. package/dist/session-records.js +858 -0
  730. package/dist/session-records.js.map +1 -0
  731. package/dist/session-relay-client.d.ts +659 -0
  732. package/dist/session-relay-client.d.ts.map +1 -0
  733. package/dist/session-relay-client.js +2876 -0
  734. package/dist/session-relay-client.js.map +1 -0
  735. package/dist/session-relay.d.ts +397 -0
  736. package/dist/session-relay.d.ts.map +1 -0
  737. package/dist/session-relay.js +1636 -0
  738. package/dist/session-relay.js.map +1 -0
  739. package/dist/session-salt-agreement.d.ts +331 -0
  740. package/dist/session-salt-agreement.d.ts.map +1 -0
  741. package/dist/session-salt-agreement.js +472 -0
  742. package/dist/session-salt-agreement.js.map +1 -0
  743. package/dist/session-salts.d.ts +432 -0
  744. package/dist/session-salts.d.ts.map +1 -0
  745. package/dist/session-salts.js +1540 -0
  746. package/dist/session-salts.js.map +1 -0
  747. package/dist/session-schema.d.ts +30 -0
  748. package/dist/session-schema.d.ts.map +1 -0
  749. package/dist/session-schema.js +877 -0
  750. package/dist/session-schema.js.map +1 -0
  751. package/dist/session-seal-leaf-store.d.ts +70 -0
  752. package/dist/session-seal-leaf-store.d.ts.map +1 -0
  753. package/dist/session-seal-leaf-store.js +105 -0
  754. package/dist/session-seal-leaf-store.js.map +1 -0
  755. package/dist/session-seal.d.ts +334 -0
  756. package/dist/session-seal.d.ts.map +1 -0
  757. package/dist/session-seal.js +1017 -0
  758. package/dist/session-seal.js.map +1 -0
  759. package/dist/session-terminal-refusal.d.ts +65 -0
  760. package/dist/session-terminal-refusal.d.ts.map +1 -0
  761. package/dist/session-terminal-refusal.js +87 -0
  762. package/dist/session-terminal-refusal.js.map +1 -0
  763. package/dist/session-tree.d.ts +110 -0
  764. package/dist/session-tree.d.ts.map +1 -0
  765. package/dist/session-tree.js +144 -0
  766. package/dist/session-tree.js.map +1 -0
  767. package/dist/session-views.d.ts +47 -0
  768. package/dist/session-views.d.ts.map +1 -0
  769. package/dist/session-views.js +278 -0
  770. package/dist/session-views.js.map +1 -0
  771. package/dist/signal-handlers.d.ts +63 -0
  772. package/dist/signal-handlers.d.ts.map +1 -0
  773. package/dist/signal-handlers.js +980 -0
  774. package/dist/signal-handlers.js.map +1 -0
  775. package/dist/signal-requirement-policy.d.ts +51 -0
  776. package/dist/signal-requirement-policy.d.ts.map +1 -0
  777. package/dist/signal-requirement-policy.js +89 -0
  778. package/dist/signal-requirement-policy.js.map +1 -0
  779. package/dist/signal-revocability.d.ts +49 -0
  780. package/dist/signal-revocability.d.ts.map +1 -0
  781. package/dist/signal-revocability.js +93 -0
  782. package/dist/signal-revocability.js.map +1 -0
  783. package/dist/signal-submission.d.ts +181 -0
  784. package/dist/signal-submission.d.ts.map +1 -0
  785. package/dist/signal-submission.js +368 -0
  786. package/dist/signal-submission.js.map +1 -0
  787. package/dist/signaling-connect.d.ts +118 -0
  788. package/dist/signaling-connect.d.ts.map +1 -0
  789. package/dist/signaling-connect.js +538 -0
  790. package/dist/signaling-connect.js.map +1 -0
  791. package/dist/signaling-wiring.d.ts +105 -0
  792. package/dist/signaling-wiring.d.ts.map +1 -0
  793. package/dist/signaling-wiring.js +393 -0
  794. package/dist/signaling-wiring.js.map +1 -0
  795. package/dist/singleton-lock.d.ts +85 -0
  796. package/dist/singleton-lock.d.ts.map +1 -0
  797. package/dist/singleton-lock.js +219 -0
  798. package/dist/singleton-lock.js.map +1 -0
  799. package/dist/sqlcipher-db.d.ts +139 -0
  800. package/dist/sqlcipher-db.d.ts.map +1 -0
  801. package/dist/sqlcipher-db.js +357 -0
  802. package/dist/sqlcipher-db.js.map +1 -0
  803. package/dist/standing-receivers.d.ts +319 -0
  804. package/dist/standing-receivers.d.ts.map +1 -0
  805. package/dist/standing-receivers.js +1295 -0
  806. package/dist/standing-receivers.js.map +1 -0
  807. package/dist/start-agent.d.ts +64 -0
  808. package/dist/start-agent.d.ts.map +1 -0
  809. package/dist/start-agent.js +136 -0
  810. package/dist/start-agent.js.map +1 -0
  811. package/dist/status-handler.d.ts +54 -0
  812. package/dist/status-handler.d.ts.map +1 -0
  813. package/dist/status-handler.js +61 -0
  814. package/dist/status-handler.js.map +1 -0
  815. package/dist/submission-retry.d.ts +208 -0
  816. package/dist/submission-retry.d.ts.map +1 -0
  817. package/dist/submission-retry.js +506 -0
  818. package/dist/submission-retry.js.map +1 -0
  819. package/dist/telegram-bot-client.d.ts +34 -0
  820. package/dist/telegram-bot-client.d.ts.map +1 -0
  821. package/dist/telegram-bot-client.js +36 -0
  822. package/dist/telegram-bot-client.js.map +1 -0
  823. package/dist/telegram-doorbell.d.ts +38 -0
  824. package/dist/telegram-doorbell.d.ts.map +1 -0
  825. package/dist/telegram-doorbell.js +140 -0
  826. package/dist/telegram-doorbell.js.map +1 -0
  827. package/dist/test-handlers.d.ts +62 -0
  828. package/dist/test-handlers.d.ts.map +1 -0
  829. package/dist/test-handlers.js +240 -0
  830. package/dist/test-handlers.js.map +1 -0
  831. package/dist/testing.d.ts +10 -0
  832. package/dist/testing.d.ts.map +1 -0
  833. package/dist/testing.js +10 -0
  834. package/dist/testing.js.map +1 -0
  835. package/dist/transport-composition.d.ts +31 -0
  836. package/dist/transport-composition.d.ts.map +1 -0
  837. package/dist/transport-composition.js +55 -0
  838. package/dist/transport-composition.js.map +1 -0
  839. package/dist/transport-selector.d.ts +202 -0
  840. package/dist/transport-selector.d.ts.map +1 -0
  841. package/dist/transport-selector.js +196 -0
  842. package/dist/transport-selector.js.map +1 -0
  843. package/dist/trust-signal-pickup-listener.d.ts +43 -0
  844. package/dist/trust-signal-pickup-listener.d.ts.map +1 -0
  845. package/dist/trust-signal-pickup-listener.js +48 -0
  846. package/dist/trust-signal-pickup-listener.js.map +1 -0
  847. package/dist/trust-signal-store.d.ts +406 -0
  848. package/dist/trust-signal-store.d.ts.map +1 -0
  849. package/dist/trust-signal-store.js +939 -0
  850. package/dist/trust-signal-store.js.map +1 -0
  851. package/dist/trust-signal-sweep-tick.d.ts +60 -0
  852. package/dist/trust-signal-sweep-tick.d.ts.map +1 -0
  853. package/dist/trust-signal-sweep-tick.js +101 -0
  854. package/dist/trust-signal-sweep-tick.js.map +1 -0
  855. package/dist/trust-signal-sweep.d.ts +94 -0
  856. package/dist/trust-signal-sweep.d.ts.map +1 -0
  857. package/dist/trust-signal-sweep.js +147 -0
  858. package/dist/trust-signal-sweep.js.map +1 -0
  859. package/dist/type-registry.d.ts +42 -0
  860. package/dist/type-registry.d.ts.map +1 -0
  861. package/dist/type-registry.js +37 -0
  862. package/dist/type-registry.js.map +1 -0
  863. package/dist/types.d.ts +746 -0
  864. package/dist/types.d.ts.map +1 -0
  865. package/dist/types.js +20 -0
  866. package/dist/types.js.map +1 -0
  867. package/dist/unresolved-nodes-report.d.ts +14 -0
  868. package/dist/unresolved-nodes-report.d.ts.map +1 -0
  869. package/dist/unresolved-nodes-report.js +96 -0
  870. package/dist/unresolved-nodes-report.js.map +1 -0
  871. package/dist/vocabulary.d.ts +150 -0
  872. package/dist/vocabulary.d.ts.map +1 -0
  873. package/dist/vocabulary.js +386 -0
  874. package/dist/vocabulary.js.map +1 -0
  875. package/dist/who-label.d.ts +28 -0
  876. package/dist/who-label.d.ts.map +1 -0
  877. package/dist/who-label.js +31 -0
  878. package/dist/who-label.js.map +1 -0
  879. package/dist/who-resolver.d.ts +15 -0
  880. package/dist/who-resolver.d.ts.map +1 -0
  881. package/dist/who-resolver.js +47 -0
  882. package/dist/who-resolver.js.map +1 -0
  883. package/dist/wire-content-hash.d.ts +93 -0
  884. package/dist/wire-content-hash.d.ts.map +1 -0
  885. package/dist/wire-content-hash.js +116 -0
  886. package/dist/wire-content-hash.js.map +1 -0
  887. package/dist/withheld-content.d.ts +13 -0
  888. package/dist/withheld-content.d.ts.map +1 -0
  889. package/dist/withheld-content.js +46 -0
  890. package/dist/withheld-content.js.map +1 -0
  891. package/dist/witness-alerts.d.ts +40 -0
  892. package/dist/witness-alerts.d.ts.map +1 -0
  893. package/dist/witness-alerts.js +102 -0
  894. package/dist/witness-alerts.js.map +1 -0
  895. package/package.json +5 -5
@@ -0,0 +1,931 @@
1
+ /**
2
+ * DOD-DOC-STORE-1 — the daemon's three document tables (§16.7-12).
3
+ *
4
+ * TWO LAYERS, NOT ONE (§14). Storing only a merged Yjs binary would discard the signed envelope
5
+ * chain that makes a seal verifiable, so both are kept:
6
+ *
7
+ * `document_envelopes` — the IMMUTABLE log: signatures, provenance, the per-document chain.
8
+ * This is the truth.
9
+ * `document_snapshots` — a MATERIALIZATION for fast start. Disposable by construction:
10
+ * delete it and it rebuilds from the log, byte-identical.
11
+ *
12
+ * The distinction is load-bearing rather than stylistic. Live Yjs state deliberately does NOT
13
+ * survive a daemon restart — CELLO's invariant is daemon-up-is-CELLO-on — and that is only safe
14
+ * because the log makes rebuilding a lookup rather than an archaeology exercise.
15
+ *
16
+ * THIS MODULE PERSISTS; IT DOES NOT APPLY. Replay is INJECTED (`rebuildSnapshot`), so the store
17
+ * owns *what to replay and in what order* while the engine (DOD-DOC-ENGINE-1) owns *how to
18
+ * apply*. That keeps `yjs` out of this file's imports entirely and keeps the P0/P1 boundary
19
+ * honest — a store that quietly grew a Y.Doc would be the engine wearing a store's name.
20
+ *
21
+ * WHAT IS NEVER STORED HERE: a Yjs clientID. §14's one-line rule is "let Yjs mint its own per
22
+ * live Y.Doc; never derive it from agent identity, never persist and restore one." DOD-DOC-FUZZ-1
23
+ * measured the cost of getting this wrong — two live docs sharing a clientID means the colliding
24
+ * writer silently wins, the honest client's update is accepted-and-dropped, and the result is a
25
+ * splice of two authors with an EMPTY pending set and no error on any path. So the snapshot
26
+ * stores a binary and a state vector, and nothing that could be restored into a live document as
27
+ * an identity.
28
+ *
29
+ * KEYED ON STABLE IDS ONLY. `agent_id` and `document_id`, never `agent_name` — it is a mutable
30
+ * display label and reusable after retirement. The M7 session tables join on `agent_name`; that
31
+ * is a known defect (`DOD-AGENT-ID-JOINKEY-1`), not a precedent to copy.
32
+ */
33
+ import { DOCUMENT_ENTRIES_CREATE_SQL, dropLegacyEpochColumn, dropLegacyColumns, } from "./document-amendment-store.js";
34
+ import { extractErrorMessage } from "./error-message.js";
35
+ /** Thrown when a read path refuses to materialize over a chain that does not verify. */
36
+ export class DocumentChainError extends Error {
37
+ reason;
38
+ detail;
39
+ constructor(reason, detail) {
40
+ super(`${reason}: ${detail}`);
41
+ this.name = "DocumentChainError";
42
+ this.reason = reason;
43
+ this.detail = detail;
44
+ }
45
+ }
46
+ const CREATE_DOCUMENTS_SQL = `
47
+ CREATE TABLE IF NOT EXISTS documents (
48
+ owner_agent_id TEXT NOT NULL,
49
+ document_id TEXT NOT NULL,
50
+ peer_agent_id TEXT NOT NULL,
51
+ document_type TEXT NOT NULL,
52
+ properties TEXT NOT NULL,
53
+ status TEXT NOT NULL CHECK (status IN ('active', 'closed', 'killed', 'stalled')),
54
+ created_at INTEGER NOT NULL,
55
+ PRIMARY KEY (owner_agent_id, document_id)
56
+ );
57
+ `;
58
+ const CREATE_ENVELOPES_SQL = `
59
+ CREATE TABLE IF NOT EXISTS document_envelopes (
60
+ owner_agent_id TEXT NOT NULL,
61
+ document_id TEXT NOT NULL,
62
+ envelope_hash TEXT NOT NULL,
63
+ sender_agent_id TEXT NOT NULL,
64
+ doc_prev_hash TEXT,
65
+ signature BLOB NOT NULL,
66
+ state_vector BLOB NOT NULL,
67
+ payload BLOB,
68
+ -- SYNC-G1: the author's governance frontier at authoring (JSON array of entry hashes) —
69
+ -- content's causal link to the governance that made it admissible. Inside the signed TBS.
70
+ governance_parents TEXT NOT NULL DEFAULT '[]',
71
+ kind TEXT NOT NULL CHECK (kind IN ('update', 'withdrawal', 'rejection')),
72
+ -- The Yjs clientID the sender SIGNED for (ENVELOPE-1 puts it inside the TBS). Recorded so the
73
+ -- gate's authorship rule has a binding derived from authenticated data rather than from a seam
74
+ -- somebody has to remember to implement. §14 forbids persisting a clientID for REUSE — this is
75
+ -- the opposite: a record of which ones a peer has actually signed for.
76
+ sender_client_id INTEGER,
77
+ references_hash TEXT,
78
+ created_at INTEGER NOT NULL,
79
+ log_index INTEGER NOT NULL,
80
+ PRIMARY KEY (owner_agent_id, document_id, envelope_hash),
81
+ -- A duplicate index would make ORDER BY log_index non-deterministic, and this log's entire
82
+ -- value is deterministic replay. Two daemons on one DB file (the orphan-process case this
83
+ -- repo has been bitten by) would otherwise each compute the same next index and both insert.
84
+ UNIQUE (owner_agent_id, document_id, log_index),
85
+ -- An audit record carries no content, and replay SKIPS payload-free non-update rows on that
86
+ -- basis. Enforce it here rather than relying on the convention: if a withdrawal ever carried
87
+ -- a payload and were later purged, replay would skip it and rebuild SHORT — the exact
88
+ -- divergence the purged-update refusal exists to prevent.
89
+ CHECK (kind = 'update' OR payload IS NULL),
90
+ -- Rows cannot exist for a document that was never created. The reference store makes the
91
+ -- same call in writing: an unscoped row must be impossible to write, not merely discouraged
92
+ -- by a query convention every future caller has to remember.
93
+ FOREIGN KEY (owner_agent_id, document_id) REFERENCES documents (owner_agent_id, document_id)
94
+ );
95
+ `;
96
+ /**
97
+ * Quarantined updates (DOD-DOC-REJECT-1). A separate table, deliberately:
98
+ *
99
+ * `document_envelopes` cannot hold them — its CHECK forbids a payload on a non-update row — and
100
+ * putting the refused bytes in as an `update` row would be worse, because `replay` applies every
101
+ * payload in order and does not honour references. The refused content would come back on every
102
+ * rebuild, which is the opposite of quarantine.
103
+ *
104
+ * So the log stays clean and replay is untouched, while the bytes a `0x05` leaf references
105
+ * actually survive a restart — which is the whole point of "held, never discarded" (§3.2).
106
+ */
107
+ const CREATE_QUARANTINE_SQL = `
108
+ CREATE TABLE IF NOT EXISTS document_quarantine (
109
+ owner_agent_id TEXT NOT NULL,
110
+ document_id TEXT NOT NULL,
111
+ rejected_envelope_hash TEXT NOT NULL,
112
+ -- The 0x05 leaf THIS row belongs to. It is the PK because one refused envelope can be refused
113
+ -- MORE THAN ONCE, for different reasons, across retry rounds — the rejection protocol's normal
114
+ -- path. Keyed on the REFUSED envelope instead, the second round's bytes, reason, rule and limit
115
+ -- were dropped by ON CONFLICT DO NOTHING with no log line, and the stall message then told the
116
+ -- operator "the most recent reason was" and printed the OLDEST. One 0x05 leaf, one row.
117
+ rejection_envelope_hash TEXT NOT NULL,
118
+ -- The refused envelope's OWN chain link and author, so verifyChainLinkage can bridge across
119
+ -- it. The refused payload is deliberately never written to the log (see the header), which
120
+ -- would otherwise leave the peer's supersession chaining onto a hash that is nowhere.
121
+ rejected_sender_agent_id TEXT NOT NULL,
122
+ rejected_doc_prev_hash TEXT,
123
+ payload BLOB NOT NULL,
124
+ reason TEXT NOT NULL,
125
+ detail TEXT,
126
+ rule TEXT,
127
+ limit_name TEXT,
128
+ limit_value INTEGER,
129
+ limit_actual INTEGER,
130
+ -- SYNC-R35: the EXACT signed refusal frame, so the refusal can travel by the ordinary
131
+ -- exchange (re-encoding from columns cannot reproduce the signed bytes). Nullable: rows
132
+ -- born before R35 hold no wire, and the exchange simply has nothing to attach for them.
133
+ rejection_wire BLOB,
134
+ created_at INTEGER NOT NULL,
135
+ PRIMARY KEY (owner_agent_id, document_id, rejection_envelope_hash),
136
+ FOREIGN KEY (owner_agent_id, document_id) REFERENCES documents (owner_agent_id, document_id)
137
+ );
138
+ `;
139
+ /**
140
+ * Rejections we RECEIVED (§3.2 "both sides"). A separate table from `document_quarantine` because
141
+ * the two hold different facts: quarantine holds bytes WE refused, this holds the peer's refusal of
142
+ * bytes we authored — we hold no payload of theirs to quarantine.
143
+ *
144
+ * It is durable rather than a log line because everything an operator needs on the publishing side
145
+ * depends on it surviving a restart: why their work was refused, and how many rounds remain before
146
+ * the document stalls. Without a row, the sending side counted its OWN rejections — which on a pure
147
+ * publisher is zero forever — so the retry bound existed only on the side that never loops.
148
+ */
149
+ const CREATE_REJECTIONS_RECEIVED_SQL = `
150
+ CREATE TABLE IF NOT EXISTS document_rejections_received (
151
+ owner_agent_id TEXT NOT NULL,
152
+ document_id TEXT NOT NULL,
153
+ rejection_envelope_hash TEXT NOT NULL,
154
+ rejected_envelope_hash TEXT NOT NULL,
155
+ from_agent_id TEXT NOT NULL,
156
+ reason TEXT NOT NULL,
157
+ detail TEXT,
158
+ created_at INTEGER NOT NULL,
159
+ PRIMARY KEY (owner_agent_id, document_id, rejection_envelope_hash),
160
+ FOREIGN KEY (owner_agent_id, document_id) REFERENCES documents (owner_agent_id, document_id)
161
+ );
162
+ `;
163
+ const CREATE_SNAPSHOTS_SQL = `
164
+ CREATE TABLE IF NOT EXISTS document_snapshots (
165
+ owner_agent_id TEXT NOT NULL,
166
+ document_id TEXT NOT NULL,
167
+ binary BLOB NOT NULL,
168
+ state_vector BLOB NOT NULL,
169
+ last_applied_index INTEGER NOT NULL,
170
+ PRIMARY KEY (owner_agent_id, document_id),
171
+ FOREIGN KEY (owner_agent_id, document_id) REFERENCES documents (owner_agent_id, document_id)
172
+ );
173
+ `;
174
+ export class DocumentStore {
175
+ #db;
176
+ #logger;
177
+ /**
178
+ * The underlying handle, for modules that own their OWN tables alongside this one
179
+ * (DocumentLifecycle). Deliberately not a licence to query this store's tables from outside —
180
+ * every one of them has a method here, and a second query path is a second set of rules about
181
+ * scoping that nobody remembers to keep in step.
182
+ */
183
+ get rawDb() {
184
+ return this.#db;
185
+ }
186
+ constructor(db, logger) {
187
+ this.#db = db;
188
+ this.#logger = logger;
189
+ this.#db.exec(CREATE_DOCUMENTS_SQL);
190
+ // SYNC-G1 birth-gated column (the consent-migration precedent): a database created before
191
+ // the causal-anchor column exists gains it here, defaulted to the empty frontier — CREATE
192
+ // IF NOT EXISTS cannot add columns, and a client-side migration that fails is unrecoverable
193
+ // on an operator machine, so the ALTER is guarded by the actual table shape.
194
+ const envelopeColumns = this.#db
195
+ .prepare(`PRAGMA table_info(document_envelopes)`)
196
+ .all();
197
+ if (envelopeColumns.length > 0 &&
198
+ !envelopeColumns.some((c) => c.name === "governance_parents")) {
199
+ this.#db.exec(`ALTER TABLE document_envelopes ADD COLUMN governance_parents TEXT NOT NULL DEFAULT '[]'`);
200
+ }
201
+ // M14B / DOD-MP-AMEND-1 — the amendments table this store READS (currentDocumentEpoch);
202
+ // DocumentAmendmentStore owns writes. Shared definition, whichever constructs first wins.
203
+ this.#db.exec(`DROP TABLE IF EXISTS document_amendments`);
204
+ this.#db.exec(DOCUMENT_ENTRIES_CREATE_SQL);
205
+ dropLegacyEpochColumn(this.#db, "document_entries");
206
+ this.#db.exec(CREATE_ENVELOPES_SQL);
207
+ dropLegacyEpochColumn(this.#db, "document_envelopes");
208
+ // SYNC-AC3 residue. P4 deleted the delivery worker and its ledgers but left DELIVERY-1's
209
+ // bookkeeping columns standing on the envelope log — no writer, no reader, and exactly the
210
+ // per-recipient DEBT the pivot exists to abolish ("X still owes Y this envelope"). Dead
211
+ // columns are not harmless here: the next author to see `next_attempt_at` in the schema
212
+ // reasonably concludes retry state belongs on the row and rebuilds the machine. Dropped on
213
+ // open, birth-gated like the epoch column beside it.
214
+ dropLegacyColumns(this.#db, "document_envelopes", [
215
+ "delivered_at", "acked_at", "abandoned_at", "attempts", "next_attempt_at",
216
+ ]);
217
+ this.#db.exec(CREATE_QUARANTINE_SQL);
218
+ // SYNC-R35, birth-gated like the epoch drops: a database born earlier lacks the column.
219
+ {
220
+ const cols = this.#db.prepare(`PRAGMA table_info(document_quarantine)`).all();
221
+ if (!cols.some((c) => c.name === "rejection_wire")) {
222
+ this.#db.exec(`ALTER TABLE document_quarantine ADD COLUMN rejection_wire BLOB`);
223
+ }
224
+ }
225
+ this.#db.exec(CREATE_REJECTIONS_RECEIVED_SQL);
226
+ // D9 residue sweep (review F5): withdrawals have no reader or writer left.
227
+ this.#db.exec(`DROP TABLE IF EXISTS document_withdrawals`);
228
+ // SYNC-P5 (spec §9): the per-party DISPLAY CACHE — last successful exchange and the
229
+ // position that party last claimed. Non-authoritative by construction: no correctness
230
+ // decision reads it (R44); it exists so `cello_doc_list` can say in_sync|behind|unseen
231
+ // without initiating an exchange per row.
232
+ this.#db.exec(`
233
+ CREATE TABLE IF NOT EXISTS document_party_view (
234
+ owner_agent_id TEXT NOT NULL,
235
+ document_id TEXT NOT NULL,
236
+ party_agent_id TEXT NOT NULL,
237
+ last_exchange_ms INTEGER NOT NULL,
238
+ gov_seqs TEXT NOT NULL,
239
+ content_counts TEXT NOT NULL,
240
+ refused TEXT NOT NULL,
241
+ PRIMARY KEY (owner_agent_id, document_id, party_agent_id)
242
+ );
243
+ `);
244
+ this.#db.exec(CREATE_SNAPSHOTS_SQL);
245
+ // Reading the log in arrival order is the only access pattern that matters.
246
+ this.#db.exec("CREATE INDEX IF NOT EXISTS idx_document_envelopes_order ON document_envelopes (owner_agent_id, document_id, log_index)");
247
+ }
248
+ // ─── documents ────────────────────────────────────────────────────────────
249
+ createDocument(row) {
250
+ this.#db
251
+ .prepare(
252
+ // Scoped to the identity conflict only — a bare OR IGNORE would also swallow the status
253
+ // CHECK, leaving the caller believing a document exists that was never stored, and the
254
+ // failure would surface later as a foreign-key error on the first append.
255
+ `INSERT INTO documents
256
+ (owner_agent_id, document_id, peer_agent_id, document_type, properties, status, created_at)
257
+ VALUES (?, ?, ?, ?, ?, ?, ?)
258
+ ON CONFLICT (owner_agent_id, document_id) DO NOTHING`)
259
+ .run(row.ownerAgentId, row.documentId, row.peerAgentId, row.documentType, JSON.stringify(row.properties), row.status, row.createdAtMs);
260
+ }
261
+ getDocument(ownerAgentId, documentId) {
262
+ const r = this.#db
263
+ .prepare("SELECT * FROM documents WHERE owner_agent_id = ? AND document_id = ?")
264
+ .get(ownerAgentId, documentId);
265
+ return r ? toDocumentRow(r) : null;
266
+ }
267
+ listDocuments(ownerAgentId) {
268
+ const rows = this.#db
269
+ .prepare("SELECT * FROM documents WHERE owner_agent_id = ? ORDER BY created_at ASC")
270
+ .all(ownerAgentId);
271
+ return rows.map(toDocumentRow);
272
+ }
273
+ setDocumentStatus(ownerAgentId, documentId, status) {
274
+ this.#db
275
+ .prepare("UPDATE documents SET status = ? WHERE owner_agent_id = ? AND document_id = ?")
276
+ .run(status, ownerAgentId, documentId);
277
+ }
278
+ // ─── the append-only envelope log ─────────────────────────────────────────
279
+ /**
280
+ * Append an envelope at the next log position.
281
+ *
282
+ * IMMUTABLE AT A HASH: the conflict clause is scoped to the envelope hash ALONE, so a
283
+ * re-delivery — or a peer replaying the same hash with different bytes — cannot overwrite what
284
+ * was recorded. Returns whether a new row was written, so the caller can tell a genuine append
285
+ * from a duplicate rather than inferring it.
286
+ *
287
+ * Scoped deliberately, not written as a bare `OR IGNORE`: that form suppresses CHECK, UNIQUE
288
+ * and NOT NULL as well, which on an append-only log means a malformed `kind` or a colliding
289
+ * `log_index` would be DROPPED and reported to the caller as an already-seen duplicate. Every
290
+ * constraint except the hash conflict must throw, or `false` means three different things the
291
+ * caller cannot tell apart.
292
+ */
293
+ appendEnvelope(ownerAgentId, envelope) {
294
+ // The log index is computed INSIDE the insert, not read first and passed in. A read-then-write
295
+ // is safe within one process (this API is synchronous throughout), but two daemons on one DB
296
+ // file — the orphan-process case this repo has hit before — would each read the same MAX and
297
+ // each insert it. A duplicate index makes ORDER BY log_index non-deterministic, and
298
+ // deterministic replay is this log's entire purpose. The UNIQUE constraint is the backstop.
299
+ let info;
300
+ try {
301
+ info = this.#db
302
+ .prepare(`INSERT INTO document_envelopes
303
+ (owner_agent_id, document_id, envelope_hash, sender_agent_id, doc_prev_hash,
304
+ signature, state_vector, payload, governance_parents, kind, references_hash,
305
+ sender_client_id, created_at, log_index)
306
+ SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
307
+ COALESCE((SELECT MAX(log_index) + 1 FROM document_envelopes
308
+ WHERE owner_agent_id = ? AND document_id = ?), 0)
309
+ ON CONFLICT (owner_agent_id, document_id, envelope_hash) DO NOTHING`)
310
+ .run(ownerAgentId, envelope.documentId, envelope.envelopeHash, envelope.senderAgentId, envelope.docPrevHash, Buffer.from(envelope.signature), Buffer.from(envelope.stateVector), envelope.payload === null ? null : Buffer.from(envelope.payload), JSON.stringify(envelope.governanceParents ?? []), envelope.kind, envelope.referencesEnvelopeHash ?? null, envelope.senderClientId ?? null, envelope.createdAtMs, ownerAgentId, envelope.documentId);
311
+ }
312
+ catch (err) {
313
+ const message = extractErrorMessage(err);
314
+ // SQLite says "FOREIGN KEY constraint failed" and nothing else — not which document, not
315
+ // which owner, not that a `documents` row is missing. That is the message an operator meets
316
+ // when an envelope arrives before its document exists, so it has to name its own cause.
317
+ if (message.includes("FOREIGN KEY")) {
318
+ throw new Error(`document_envelope_unscoped: no document ${envelope.documentId.slice(0, 16)}… exists for ` +
319
+ `owner ${ownerAgentId.slice(0, 16)}… — create the document before appending to its log`);
320
+ }
321
+ throw err;
322
+ }
323
+ return Number(info.changes) > 0;
324
+ }
325
+ /**
326
+ * Envelopes at or after `fromIndex`, in log order. This is what makes `lastAppliedIndex` the
327
+ * lookup §14 asks for: resume an incremental rebuild at `lastAppliedIndex + 1` without reading
328
+ * the whole log.
329
+ */
330
+ getEnvelopesSince(ownerAgentId, documentId, fromIndex) {
331
+ const rows = this.#db
332
+ .prepare(`SELECT * FROM document_envelopes
333
+ WHERE owner_agent_id = ? AND document_id = ? AND log_index >= ?
334
+ ORDER BY log_index ASC`)
335
+ .all(ownerAgentId, documentId, fromIndex);
336
+ return rows.map(toEnvelopeRow);
337
+ }
338
+ getEnvelopeLog(ownerAgentId, documentId) {
339
+ const rows = this.#db
340
+ .prepare(`SELECT * FROM document_envelopes
341
+ WHERE owner_agent_id = ? AND document_id = ? ORDER BY log_index ASC`)
342
+ .all(ownerAgentId, documentId);
343
+ return rows.map(toEnvelopeRow);
344
+ }
345
+ /**
346
+ * Verify each sender's `doc_prev_hash` chain independently.
347
+ *
348
+ * The log interleaves both parties' envelopes, so there is no single total order to check —
349
+ * §16.7-5 defines replay set-based per epoch for exactly this reason. What must hold is that
350
+ * every sender's own links form one unbroken chain from a single genesis.
351
+ *
352
+ * A break REFUSES and names the sender and the missing predecessor. Skipping the leaf and
353
+ * carrying on would leave a document that reads as complete while missing operations, which is
354
+ * the silent-divergence failure the chain exists to prevent.
355
+ *
356
+ * LINKAGE ONLY — the name says so deliberately. This verifies no signature and does not check
357
+ * that `envelope_hash` hashes the content; neither is possible here (no key, no encoder). A
358
+ * caller must not read `ok: true` as authenticity — that belongs to the engine.
359
+ */
360
+ verifyChainLinkage(ownerAgentId, documentId) {
361
+ const log = this.getEnvelopeLog(ownerAgentId, documentId);
362
+ // BRIDGE THE REFUSED ENVELOPES. A refused update's payload is never written to the log — that
363
+ // is what makes the refusal real across a restart — but the peer does not know it was refused
364
+ // when it authors the next envelope, so its supersession chains onto a hash the log does not
365
+ // contain. Without the bridge that reads as `document_chain_broken`, the document refuses to
366
+ // rebuild, and the operator is sent to debug the chain layer for a rejection-protocol event.
367
+ //
368
+ // These stubs exist ONLY for verification. They carry no payload and are never returned by
369
+ // `getEnvelopeLog`, so replay cannot see them and the refused content cannot come back.
370
+ const stubs = this.listQuarantined(ownerAgentId, documentId).map((q) => ({
371
+ envelopeHash: q.rejectedEnvelopeHash,
372
+ documentId: q.documentId,
373
+ senderAgentId: q.rejectedSenderAgentId,
374
+ docPrevHash: q.rejectedDocPrevHash,
375
+ governanceParents: [],
376
+ // EXEMPT from current-epoch stamping (M14B Entry 5): a stub is a SYNTHETIC verification
377
+ // node — never on the wire, never replayed — and the chain walk checks hash linkage only.
378
+ signature: new Uint8Array(0),
379
+ stateVector: new Uint8Array(0),
380
+ payload: null,
381
+ kind: "rejection",
382
+ referencesEnvelopeHash: null,
383
+ createdAtMs: q.createdAtMs,
384
+ }));
385
+ // One refused envelope can carry several quarantine rows (one per retry round), and the chain
386
+ // has exactly one node for it.
387
+ const seenStub = new Set();
388
+ const bySender = new Map();
389
+ for (const stub of stubs) {
390
+ if (seenStub.has(stub.envelopeHash))
391
+ continue;
392
+ seenStub.add(stub.envelopeHash);
393
+ const list = bySender.get(stub.senderAgentId);
394
+ if (list)
395
+ list.push(stub);
396
+ else
397
+ bySender.set(stub.senderAgentId, [stub]);
398
+ }
399
+ for (const e of log) {
400
+ const list = bySender.get(e.senderAgentId);
401
+ if (list)
402
+ list.push(e);
403
+ else
404
+ bySender.set(e.senderAgentId, [e]);
405
+ }
406
+ for (const [sender, envelopes] of bySender) {
407
+ const present = new Set(envelopes.map((e) => e.envelopeHash));
408
+ const genesis = envelopes.filter((e) => e.docPrevHash === null);
409
+ if (genesis.length !== 1) {
410
+ return {
411
+ ok: false,
412
+ reason: "document_chain_forked",
413
+ detail: `sender ${sender.slice(0, 16)}… has ${genesis.length} genesis envelopes for document ` +
414
+ `${documentId.slice(0, 16)}… — a chain has exactly one`,
415
+ };
416
+ }
417
+ // Every link must resolve. Checked first so a missing predecessor reports as BROKEN rather
418
+ // than as the unreachability it would also cause.
419
+ for (const e of envelopes) {
420
+ if (e.docPrevHash !== null && !present.has(e.docPrevHash)) {
421
+ return {
422
+ ok: false,
423
+ reason: "document_chain_broken",
424
+ detail: `sender ${sender.slice(0, 16)}… envelope ${e.envelopeHash.slice(0, 16)}… links to ` +
425
+ `${e.docPrevHash.slice(0, 16)}…, which is absent from the log and is not among this ` +
426
+ `document's refused envelopes either — so this is a gap in the chain itself, not a ` +
427
+ `rejection`,
428
+ };
429
+ }
430
+ }
431
+ // REACHABILITY, not structural heuristics. Walk forward from the one genesis and require
432
+ // the walk to cover every envelope this sender authored. That single check subsumes the
433
+ // duplicate-genesis case, the duplicate-predecessor fork, AND every cycle shape — including
434
+ // a disjoint cycle sitting alongside a perfectly good genesis chain, which counting roots
435
+ // and predecessors cannot see. `doc_prev_hash` is peer-controlled, so this is a hostile
436
+ // input path and the verifier is the only thing between a crafted log and a persisted
437
+ // snapshot.
438
+ const childOf = new Map();
439
+ for (const e of envelopes) {
440
+ if (e.docPrevHash === null)
441
+ continue;
442
+ const siblings = childOf.get(e.docPrevHash);
443
+ if (siblings)
444
+ siblings.push(e);
445
+ else
446
+ childOf.set(e.docPrevHash, [e]);
447
+ }
448
+ const reached = new Set();
449
+ let cursor = genesis[0];
450
+ while (cursor) {
451
+ if (reached.has(cursor.envelopeHash))
452
+ break; // defensive; a cycle cannot include genesis
453
+ reached.add(cursor.envelopeHash);
454
+ const children = childOf.get(cursor.envelopeHash) ?? [];
455
+ if (children.length > 1) {
456
+ return {
457
+ ok: false,
458
+ reason: "document_chain_forked",
459
+ detail: `sender ${sender.slice(0, 16)}… has ${children.length} envelopes claiming predecessor ` +
460
+ `${cursor.envelopeHash.slice(0, 16)}… — a chain branches nowhere`,
461
+ };
462
+ }
463
+ cursor = children[0];
464
+ }
465
+ if (reached.size !== envelopes.length) {
466
+ return {
467
+ ok: false,
468
+ reason: "document_chain_forked",
469
+ detail: `sender ${sender.slice(0, 16)}… has ${envelopes.length - reached.size} envelopes ` +
470
+ `unreachable from its genesis for document ${documentId.slice(0, 16)}… — a detached ` +
471
+ `cycle or branch, not a chain`,
472
+ };
473
+ }
474
+ }
475
+ return { ok: true };
476
+ }
477
+ // ─── quarantine (held, never discarded) ───────────────────────────────────
478
+ /**
479
+ * Hold a refused update's bytes. Idempotent per REJECTION (per 0x05 leaf), not per refused
480
+ * envelope — one envelope may be refused across several retry rounds and each round's reason,
481
+ * rule and limit are distinct facts an operator needs.
482
+ *
483
+ * Returns whether a row was written, so a caller never has to infer it. The previous signature
484
+ * returned void and the conflict clause silently dropped every round after the first.
485
+ */
486
+ holdQuarantined(ownerAgentId, row) {
487
+ const info = this.#db
488
+ .prepare(`INSERT INTO document_quarantine
489
+ (owner_agent_id, document_id, rejection_envelope_hash, rejected_envelope_hash,
490
+ rejected_sender_agent_id, rejected_doc_prev_hash, payload, reason, detail,
491
+ rule, limit_name, limit_value, limit_actual, rejection_wire, created_at)
492
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
493
+ ON CONFLICT (owner_agent_id, document_id, rejection_envelope_hash) DO NOTHING`)
494
+ .run(ownerAgentId, row.documentId, row.rejectionEnvelopeHash, row.rejectedEnvelopeHash, row.rejectedSenderAgentId, row.rejectedDocPrevHash, Buffer.from(row.payload), row.reason, row.detail ?? null, row.rule ?? null, row.limitName ?? null, row.limitValue ?? null, row.limitActual ?? null, row.rejectionWire ? Buffer.from(row.rejectionWire) : null, row.createdAtMs);
495
+ return Number(info.changes) > 0;
496
+ }
497
+ listQuarantined(ownerAgentId, documentId) {
498
+ const rows = this.#db
499
+ .prepare(
500
+ // rowid breaks the tie. Several rounds can land inside one millisecond, and `created_at`
501
+ // alone then leaves the order to SQLite — which is what an operator is shown as "the most
502
+ // recent reason". Insertion order is the real answer and rowid is it.
503
+ `SELECT * FROM document_quarantine
504
+ WHERE owner_agent_id = ? AND document_id = ?
505
+ ORDER BY created_at ASC, rowid ASC`)
506
+ .all(ownerAgentId, documentId);
507
+ return rows.map((r) => ({
508
+ documentId: r["document_id"],
509
+ rejectionEnvelopeHash: r["rejection_envelope_hash"],
510
+ rejectedEnvelopeHash: r["rejected_envelope_hash"],
511
+ rejectedSenderAgentId: r["rejected_sender_agent_id"],
512
+ rejectedDocPrevHash: r["rejected_doc_prev_hash"] ?? null,
513
+ payload: toU8(r["payload"]),
514
+ reason: r["reason"],
515
+ detail: r["detail"] ?? undefined,
516
+ rule: r["rule"] ?? undefined,
517
+ limitName: r["limit_name"] ?? undefined,
518
+ limitValue: r["limit_value"] ?? undefined,
519
+ limitActual: r["limit_actual"] ?? undefined,
520
+ rejectionWire: r["rejection_wire"] == null ? undefined : toU8(r["rejection_wire"]),
521
+ createdAtMs: r["created_at"],
522
+ }));
523
+ }
524
+ /**
525
+ * Release every entry for a refused envelope once its superseding update has been admitted.
526
+ * Returns whether anything was released. Keyed by the REFUSED envelope rather than the rejection
527
+ * leaf, because admitting the supersession resolves all of that envelope's rounds at once.
528
+ */
529
+ releaseQuarantined(ownerAgentId, documentId, rejectedEnvelopeHash) {
530
+ const info = this.#db
531
+ .prepare(`DELETE FROM document_quarantine
532
+ WHERE owner_agent_id = ? AND document_id = ? AND rejected_envelope_hash = ?`)
533
+ .run(ownerAgentId, documentId, rejectedEnvelopeHash);
534
+ return Number(info.changes) > 0;
535
+ }
536
+ /**
537
+ * Every envelope hash we hold from one sender. Hash-only on purpose: the caller needs a set for a
538
+ * membership test, and `getEnvelopeLog` selects `*` — including every payload BLOB — so building
539
+ * that set from it materialized the whole document's content on every inbound update.
540
+ */
541
+ knownEnvelopeHashesBySender(ownerAgentId, documentId, senderAgentId) {
542
+ const rows = this.#db
543
+ .prepare(
544
+ // THE QUARANTINE COUNTS AS KNOWN, and it has to.
545
+ //
546
+ // A refused envelope is deliberately never written to `document_envelopes` — that is the
547
+ // point of refusing it. But the sender's chain does not rewind: their next envelope links
548
+ // to the one we refused. Without the second half of this union that link resolves to
549
+ // nothing and the supersession is rejected as `document_chain_broken` — so ONE gate refusal
550
+ // permanently broke the document, and the supersede-then-converge protocol §3.2 describes
551
+ // could never run at all. Measured live.
552
+ //
553
+ // The bridge was already designed for exactly this: the quarantine records the refused
554
+ // envelope's own author and prev-hash so a later link can span it. It had only ever been
555
+ // applied to `verifyChainLinkage`, the LOCAL replay check — never to inbound admission,
556
+ // which is the path a peer's supersession actually arrives on.
557
+ //
558
+ // Scoped by the refused envelope's own sender, so one peer's quarantine can never make
559
+ // another peer's broken chain resolve.
560
+ `SELECT envelope_hash FROM document_envelopes
561
+ WHERE owner_agent_id = ? AND document_id = ? AND sender_agent_id = ?
562
+ UNION ALL
563
+ SELECT rejected_envelope_hash AS envelope_hash FROM document_quarantine
564
+ WHERE owner_agent_id = ? AND document_id = ? AND rejected_sender_agent_id = ?`)
565
+ .all(ownerAgentId, documentId, senderAgentId, ownerAgentId, documentId, senderAgentId);
566
+ return new Set(rows.map((r) => r.envelope_hash));
567
+ }
568
+ /** The clientIDs one sender has signed for on this document. Also hash-free — see above. */
569
+ senderClientIdsFor(ownerAgentId, documentId, senderAgentId) {
570
+ const rows = this.#db
571
+ .prepare(`SELECT DISTINCT sender_client_id FROM document_envelopes
572
+ WHERE owner_agent_id = ? AND document_id = ? AND sender_agent_id = ?
573
+ AND sender_client_id IS NOT NULL`)
574
+ .all(ownerAgentId, documentId, senderAgentId);
575
+ return rows.map((r) => r.sender_client_id);
576
+ }
577
+ /**
578
+ * The state vector the PEER last told us they had — from their most recent envelope.
579
+ *
580
+ * This is what a publish diffs against (§3.2 step 3, §7): an update computed against what they
581
+ * have already seen carries exactly the operations they lack. Diffing against OUR OWN snapshot
582
+ * instead publishes what we have not yet snapshotted, which is a different question with an
583
+ * answer that happens to look plausible.
584
+ */
585
+ peerStateVector(ownerAgentId, documentId, peerAgentId) {
586
+ const r = this.#db
587
+ .prepare(`SELECT state_vector FROM document_envelopes
588
+ WHERE owner_agent_id = ? AND document_id = ? AND sender_agent_id = ? AND kind = 'update'
589
+ ORDER BY log_index DESC LIMIT 1`)
590
+ .get(ownerAgentId, documentId, peerAgentId);
591
+ return r?.state_vector === undefined ? null : toU8(r.state_vector);
592
+ }
593
+ /**
594
+ * The state vector OUR last published envelope carried — what we had when we last spoke.
595
+ *
596
+ * Distinct from `peerStateVector`, and the distinction is the point: that one answers "what does
597
+ * the peer lack" (what to send), this one answers "has anything changed since I last published"
598
+ * (whether to send at all). Conflating them meant a republish with no edits still produced a
599
+ * non-empty update, because before the peer has ever published the diff is the whole document.
600
+ */
601
+ lastPublishedStateVector(ownerAgentId, documentId, senderAgentId) {
602
+ const r = this.#db
603
+ .prepare(`SELECT state_vector FROM document_envelopes
604
+ WHERE owner_agent_id = ? AND document_id = ? AND sender_agent_id = ? AND kind = 'update'
605
+ ORDER BY log_index DESC LIMIT 1`)
606
+ .get(ownerAgentId, documentId, senderAgentId);
607
+ return r?.state_vector === undefined ? null : toU8(r.state_vector);
608
+ }
609
+ /** The rejecting agent's most recent envelope for this document, for chain linkage. */
610
+ /**
611
+ * The head of a sender's chain AS WE SEE IT — including envelopes we REFUSED.
612
+ *
613
+ * A refused envelope is never written to `document_envelopes`, but the sender's chain does not
614
+ * rewind: their supersession links to the envelope we just refused. Taking the head from the log
615
+ * alone meant that link never matched, so the supersession was refused as `document_chain_broken`
616
+ * — and so was everything after it, forever. Measured against two real daemons: the gate fired
617
+ * ONCE and the next three envelopes never reached it, so the retry round stuck at 1 and the
618
+ * document could never reach the stall the protocol defines.
619
+ *
620
+ * That is the bridge the quarantine was built for — it stores the refused envelope's own author
621
+ * and prev-hash saying exactly this — and it had only ever been applied to `verifyChainLinkage`,
622
+ * the local replay check. An earlier attempt added the quarantine to the KNOWN-hash set, which
623
+ * was not enough and is worth recording: `known` answers "have I seen this before" (duplicate
624
+ * detection), while the forward link is checked against the HEAD. Bridging the wrong one looks
625
+ * right and changes nothing.
626
+ *
627
+ * `log_index` and the quarantine's `created_at` are different clocks, so they are not merged into
628
+ * one ORDER BY. Whichever is newer by arrival is the head: a refusal always happens after the
629
+ * envelope it refuses, so a quarantine row newer than the last admitted envelope IS the head.
630
+ */
631
+ lastEnvelopeHashBySender(ownerAgentId, documentId, senderAgentId) {
632
+ const admitted = this.#db
633
+ .prepare(`SELECT envelope_hash, created_at FROM document_envelopes
634
+ WHERE owner_agent_id = ? AND document_id = ? AND sender_agent_id = ?
635
+ ORDER BY log_index DESC LIMIT 1`)
636
+ .get(ownerAgentId, documentId, senderAgentId);
637
+ const refused = this.#db
638
+ .prepare(`SELECT rejected_envelope_hash AS envelope_hash, created_at FROM document_quarantine
639
+ WHERE owner_agent_id = ? AND document_id = ? AND rejected_sender_agent_id = ?
640
+ ORDER BY created_at DESC LIMIT 1`)
641
+ .get(ownerAgentId, documentId, senderAgentId);
642
+ if (!refused?.envelope_hash)
643
+ return admitted?.envelope_hash ?? null;
644
+ if (!admitted?.envelope_hash)
645
+ return refused.envelope_hash;
646
+ return (refused.created_at ?? 0) >= (admitted.created_at ?? 0)
647
+ ? refused.envelope_hash
648
+ : admitted.envelope_hash;
649
+ }
650
+ // ─── delivery (DELIVERY-1) ────────────────────────────────────────────────
651
+ /**
652
+ * Envelopes this agent authored that the peer has not acknowledged, and whose next attempt is
653
+ * due. DERIVED — there is no queue. Survives a restart because the log does.
654
+ *
655
+ * Scoped to `senderAgentId = ownerAgentId`: an envelope we RECEIVED is not ours to deliver, and
656
+ * without the scope a receiver would helpfully re-send the sender's own updates back at it.
657
+ */
658
+ /**
659
+ * The document's CURRENT epoch: the head of its recorded amendment chain, 0 at genesis.
660
+ * Trustworthy for stamping because every append site rules on admissibility before
661
+ * recording — a row in document_amendments is post-validation by invariant (M14B Entry 5).
662
+ */
663
+ /** SYNC-P5 (review F6) — per-sender envelope counts without hauling payload blobs. */
664
+ envelopeCountsBySender(ownerAgentId, documentId) {
665
+ const rows = this.#db
666
+ .prepare(`SELECT sender_agent_id, COUNT(*) AS n FROM document_envelopes
667
+ WHERE owner_agent_id = ? AND document_id = ?
668
+ GROUP BY sender_agent_id`)
669
+ .all(ownerAgentId, documentId);
670
+ return new Map(rows.map((r) => [r.sender_agent_id, r.n]));
671
+ }
672
+ /** SYNC-P5 — record what a party's exchange just showed us (display cache; see the table). */
673
+ recordPartyView(ownerAgentId, documentId, partyAgentId, view, nowMs) {
674
+ this.#db
675
+ .prepare(`INSERT INTO document_party_view
676
+ (owner_agent_id, document_id, party_agent_id, last_exchange_ms, gov_seqs,
677
+ content_counts, refused)
678
+ VALUES (?, ?, ?, ?, ?, ?, ?)
679
+ ON CONFLICT (owner_agent_id, document_id, party_agent_id) DO UPDATE SET
680
+ last_exchange_ms = excluded.last_exchange_ms,
681
+ gov_seqs = excluded.gov_seqs,
682
+ content_counts = excluded.content_counts,
683
+ refused = excluded.refused`)
684
+ .run(ownerAgentId, documentId, partyAgentId, nowMs, JSON.stringify(view.govSeqs), JSON.stringify(view.contentCounts), JSON.stringify(view.refused));
685
+ }
686
+ partyView(ownerAgentId, documentId, partyAgentId) {
687
+ const r = this.#db
688
+ .prepare(`SELECT last_exchange_ms, gov_seqs, content_counts, refused FROM document_party_view
689
+ WHERE owner_agent_id = ? AND document_id = ? AND party_agent_id = ?`)
690
+ .get(ownerAgentId, documentId, partyAgentId);
691
+ if (!r)
692
+ return null;
693
+ return {
694
+ lastExchangeMs: r.last_exchange_ms,
695
+ govSeqs: JSON.parse(r.gov_seqs),
696
+ contentCounts: JSON.parse(r.content_counts),
697
+ refused: JSON.parse(r.refused),
698
+ };
699
+ }
700
+ /** Record a rejection the PEER sent us. Returns whether a row was written (idempotent by leaf). */
701
+ recordRejectionReceived(ownerAgentId, row) {
702
+ const info = this.#db
703
+ .prepare(`INSERT INTO document_rejections_received
704
+ (owner_agent_id, document_id, rejection_envelope_hash, rejected_envelope_hash,
705
+ from_agent_id, reason, detail, created_at)
706
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
707
+ ON CONFLICT (owner_agent_id, document_id, rejection_envelope_hash) DO NOTHING`)
708
+ .run(ownerAgentId, row.documentId, row.rejectionEnvelopeHash, row.rejectedEnvelopeHash, row.fromAgentId, row.reason, row.detail ?? null, row.createdAtMs);
709
+ return Number(info.changes) > 0;
710
+ }
711
+ /**
712
+ * DOD-DOC-SCREEN-1 (§16.7-16) — SENDER ADOPTS THE RECEIVER'S RULE.
713
+ *
714
+ * The codepoints this peer has actually refused for this document, learned from their own signed
715
+ * refusals rather than assumed. Rules compose toward STRICT: once they have said no to a
716
+ * character, we stop emitting it, so the same refusal cannot be spent twice — and three refusals
717
+ * stall the document, which makes every avoidable one expensive.
718
+ *
719
+ * Scoped to (owner, document), never global. A rule adopted for one document must not silently
720
+ * narrow what an operator may write everywhere else — the peer refused it HERE, under the profile
721
+ * agreed HERE, and another peer may accept it happily.
722
+ *
723
+ * Stored as the refusal's own machine-readable codepoints, which is why the refusal was made
724
+ * machine-readable in the first place: prose cannot be adopted.
725
+ */
726
+ adoptedRefusedCodepoints(ownerAgentId, documentId) {
727
+ const rows = this.#db
728
+ .prepare(`SELECT detail FROM document_rejections_received
729
+ WHERE owner_agent_id = ? AND document_id = ? AND detail IS NOT NULL`)
730
+ .all(ownerAgentId, documentId);
731
+ const out = new Set();
732
+ for (const r of rows) {
733
+ if (typeof r.detail !== "string")
734
+ continue;
735
+ try {
736
+ const parsed = JSON.parse(r.detail);
737
+ // ONLY the structured form. A refusal whose detail is prose carries no rule to adopt, and
738
+ // guessing one out of English is how a sender ends up refusing text nobody objected to.
739
+ if (Array.isArray(parsed.codepoints)) {
740
+ for (const c of parsed.codepoints)
741
+ if (typeof c === "string")
742
+ out.add(c);
743
+ }
744
+ }
745
+ catch {
746
+ /* prose detail — nothing to adopt, and that is not an error */
747
+ }
748
+ }
749
+ return out;
750
+ }
751
+ /**
752
+ * How many ROUNDS this document has been through — DISTINCT refused envelopes, not rows.
753
+ *
754
+ * ONE REFUSED ENVELOPE IS ONE ROUND, however many times the refusal is announced. A peer's refusal
755
+ * arrives TWICE by design: once as the signed `document_rejection` frame, and once as the ack that
756
+ * settles the delivery (`admitted: false`). Both are recorded — correctly, they are two real
757
+ * events — but the table is keyed on the ANNOUNCEMENT's hash, so the two land as separate rows.
758
+ *
759
+ * Counting rows therefore advanced the round by two per refusal, and `MAX_REJECTED_ROUNDS` is 3 —
760
+ * so a document stalled after TWO refusals instead of three, cutting the supersede-and-retry
761
+ * budget the protocol grants an operator by a third. Measured: the stall enforcer's sender was
762
+ * refused at attempt 2 with `document_stalled`.
763
+ *
764
+ * Counted rather than deduplicated on write, deliberately. Both announcements genuinely happened
765
+ * and the audit record should say so; what was wrong is the arithmetic built on top of it. And a
766
+ * UNIQUE index on the refused hash would fail to create on any database that already holds the
767
+ * duplicate rows this fix is about.
768
+ *
769
+ * Same principle as `ackRecordHash` one layer down — that one collapsed repeated ACKS of one
770
+ * envelope; this collapses the two KINDS of announcement of one refusal.
771
+ */
772
+ countRejectionsReceived(ownerAgentId, documentId) {
773
+ const r = this.#db
774
+ .prepare(`SELECT COUNT(DISTINCT rejected_envelope_hash) AS n FROM document_rejections_received
775
+ WHERE owner_agent_id = ? AND document_id = ?`)
776
+ .get(ownerAgentId, documentId);
777
+ return r?.n ?? 0;
778
+ }
779
+ /**
780
+ * Was a rejection received for THIS envelope? Envelope-scoped on purpose: the document-scoped
781
+ * reader below answers a different question, and using it to decide whether one envelope was
782
+ * refused makes a rejection of any OTHER envelope in the document look like a rejection of this
783
+ * one.
784
+ */
785
+ rejectionReceivedFor(ownerAgentId, documentId, envelopeHash) {
786
+ const r = this.#db
787
+ .prepare(`SELECT 1 AS present FROM document_rejections_received
788
+ WHERE owner_agent_id = ? AND document_id = ? AND rejected_envelope_hash = ? LIMIT 1`)
789
+ .get(ownerAgentId, documentId, envelopeHash);
790
+ return r?.present === 1;
791
+ }
792
+ /** The most recently received rejection, for the reason an operator is shown on a stall. */
793
+ latestRejectionReceived(ownerAgentId, documentId) {
794
+ const r = this.#db
795
+ .prepare(`SELECT reason, detail, from_agent_id FROM document_rejections_received
796
+ WHERE owner_agent_id = ? AND document_id = ? ORDER BY created_at DESC, rowid DESC LIMIT 1`)
797
+ .get(ownerAgentId, documentId);
798
+ if (!r)
799
+ return null;
800
+ return {
801
+ reason: r["reason"],
802
+ detail: r["detail"] ?? undefined,
803
+ fromAgentId: r["from_agent_id"],
804
+ };
805
+ }
806
+ /**
807
+ * How many rejection records this document carries, PER REJECTING AGENT — the retry round.
808
+ *
809
+ * Scoped by author, because a mutual exchange puts both directions' 0x05 leaves in one document
810
+ * log. Counting across senders conflated them, so two peers each rejecting once read as round 2
811
+ * and the document stalled at half the intended rounds.
812
+ */
813
+ countRejections(ownerAgentId, documentId, rejectingAgentId) {
814
+ const r = this.#db
815
+ .prepare(`SELECT COUNT(*) AS n FROM document_envelopes
816
+ WHERE owner_agent_id = ? AND document_id = ? AND kind = 'rejection'
817
+ AND sender_agent_id = ?`)
818
+ .get(ownerAgentId, documentId, rejectingAgentId);
819
+ return r?.n ?? 0;
820
+ }
821
+ // ─── the snapshot (disposable) ────────────────────────────────────────────
822
+ getSnapshot(ownerAgentId, documentId) {
823
+ const r = this.#db
824
+ .prepare("SELECT * FROM document_snapshots WHERE owner_agent_id = ? AND document_id = ?")
825
+ .get(ownerAgentId, documentId);
826
+ if (!r)
827
+ return null;
828
+ return {
829
+ binary: toU8(r["binary"]),
830
+ stateVector: toU8(r["state_vector"]),
831
+ lastAppliedIndex: r["last_applied_index"],
832
+ };
833
+ }
834
+ /** REPLACES — a snapshot is a cache of the log, not a second log. */
835
+ putSnapshot(ownerAgentId, documentId, snapshot) {
836
+ this.#db
837
+ .prepare(`INSERT OR REPLACE INTO document_snapshots
838
+ (owner_agent_id, document_id, binary, state_vector, last_applied_index)
839
+ VALUES (?, ?, ?, ?, ?)`)
840
+ .run(ownerAgentId, documentId, Buffer.from(snapshot.binary), Buffer.from(snapshot.stateVector), snapshot.lastAppliedIndex);
841
+ }
842
+ deleteSnapshot(ownerAgentId, documentId) {
843
+ this.#db
844
+ .prepare("DELETE FROM document_snapshots WHERE owner_agent_id = ? AND document_id = ?")
845
+ .run(ownerAgentId, documentId);
846
+ }
847
+ /**
848
+ * Rebuild a snapshot from the envelope log alone, using the caller's replay function.
849
+ *
850
+ * Payload-stripped envelopes (purged, or withdrawal/rejection records that carry none)
851
+ * contribute nothing to replay but STILL COUNT toward `lastAppliedIndex` — otherwise the next
852
+ * incremental rebuild would start behind them and replay them forever.
853
+ */
854
+ rebuildSnapshot(ownerAgentId, documentId, replay) {
855
+ // VERIFY BEFORE REPLAY. Rebuilding over an unverified chain is the exact silent divergence
856
+ // the chain exists to prevent: a log with a missing predecessor folds into a state that is
857
+ // quietly short of operations, and putSnapshot would then persist it as authoritative.
858
+ // Refusing is loud; a short document is not.
859
+ const verdict = this.verifyChainLinkage(ownerAgentId, documentId);
860
+ if (!verdict.ok) {
861
+ this.#logger.warn("document.chain.broken", {
862
+ documentId,
863
+ reason: verdict.reason,
864
+ detail: verdict.detail,
865
+ });
866
+ throw new DocumentChainError(verdict.reason, verdict.detail);
867
+ }
868
+ const log = this.getEnvelopeLog(ownerAgentId, documentId);
869
+ // The WHOLE log, in order — including withdrawal and rejection records, which carry no
870
+ // payload. The engine needs those rows to tell an expected payload-free AUDIT record from a
871
+ // PURGED update whose bytes are gone; filtering here would hide that distinction and make the
872
+ // row-shaped signature pointless. The store decides ORDER; the engine decides WHAT COUNTS.
873
+ const { binary, stateVector } = replay(log);
874
+ this.#logger.info("document.snapshot.rebuilt", {
875
+ documentId,
876
+ envelopes: log.length,
877
+ withPayload: log.filter((e) => e.payload !== null).length,
878
+ });
879
+ // The LAST ROW'S log_index, not the array length. They coincide only while indices are dense,
880
+ // which is an accident of how they are assigned rather than a guarantee.
881
+ return { binary, stateVector, lastAppliedIndex: log.at(-1)?.logIndex ?? -1 };
882
+ }
883
+ }
884
+ function toDocumentRow(r) {
885
+ return {
886
+ documentId: r["document_id"],
887
+ ownerAgentId: r["owner_agent_id"],
888
+ peerAgentId: r["peer_agent_id"],
889
+ documentType: r["document_type"],
890
+ properties: JSON.parse(r["properties"]),
891
+ status: r["status"],
892
+ createdAtMs: r["created_at"],
893
+ };
894
+ }
895
+ function toEnvelopeRow(r) {
896
+ const payload = r["payload"];
897
+ return {
898
+ envelopeHash: r["envelope_hash"],
899
+ documentId: r["document_id"],
900
+ senderAgentId: r["sender_agent_id"],
901
+ docPrevHash: r["doc_prev_hash"] ?? null,
902
+ signature: toU8(r["signature"]),
903
+ stateVector: toU8(r["state_vector"]),
904
+ payload: payload === null || payload === undefined ? null : toU8(payload),
905
+ governanceParents: JSON.parse(r["governance_parents"] ?? "[]"),
906
+ kind: r["kind"],
907
+ senderClientId: r["sender_client_id"] ?? null,
908
+ referencesEnvelopeHash: r["references_hash"] ?? null,
909
+ createdAtMs: r["created_at"],
910
+ logIndex: r["log_index"],
911
+ };
912
+ }
913
+ /**
914
+ * Normalize a SQLite BLOB (Buffer / Uint8Array / ArrayBuffer) to a Uint8Array.
915
+ *
916
+ * REFUSES anything else rather than substituting an empty array. This is the read path for
917
+ * `signature`, `state_vector` and `payload`: returning `new Uint8Array()` for an unexpected type
918
+ * would hand back a ZERO-LENGTH SIGNATURE as if it were the stored one, and the failure would
919
+ * surface downstream as "signature invalid" — sending an operator to the crypto layer for what
920
+ * is a storage-read defect. Nothing legitimate reaches this branch; `null` is handled by callers.
921
+ */
922
+ function toU8(v) {
923
+ if (v instanceof Uint8Array)
924
+ return v;
925
+ if (Buffer.isBuffer(v))
926
+ return new Uint8Array(v);
927
+ if (v instanceof ArrayBuffer)
928
+ return new Uint8Array(v);
929
+ throw new Error(`document_store_blob_decode_failed: expected a BLOB, got ${v === null ? "null" : typeof v}`);
930
+ }
931
+ //# sourceMappingURL=document-store.js.map