keri-ts 2.1.0 → 2.2.1

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 (300) hide show
  1. package/README.md +30 -2
  2. package/esm/keri/npm/src/acdc/authoring.js +195 -0
  3. package/esm/keri/npm/src/acdc/custody.js +187 -0
  4. package/esm/keri/npm/src/acdc/dhking.js +244 -32
  5. package/esm/keri/npm/src/acdc/regbasing.js +10 -0
  6. package/esm/keri/npm/src/acdc/salting.js +16 -1
  7. package/esm/keri/npm/src/acdc/scheming.js +93 -54
  8. package/esm/keri/npm/src/acdc/unblinding.js +118 -95
  9. package/esm/keri/npm/src/app/bootstrap/authenticating.js +4 -6
  10. package/esm/keri/npm/src/app/bootstrap/oobi-resolving.js +41 -0
  11. package/esm/keri/npm/src/app/bootstrap/oobiery.js +4 -6
  12. package/esm/keri/npm/src/app/credentials/credential-revoking.js +1 -0
  13. package/esm/keri/npm/src/app/credentials/credential-workflows.js +2 -0
  14. package/esm/keri/npm/src/app/credentials/registry-settling.js +44 -0
  15. package/esm/keri/npm/src/app/credentials/root-replicating.js +68 -60
  16. package/esm/keri/npm/src/app/credentials/root-replicator.js +198 -0
  17. package/esm/keri/npm/src/app/credentials/tel-completion.js +36 -0
  18. package/esm/keri/npm/src/app/delivery/forwarding.js +16 -3
  19. package/esm/keri/npm/src/app/exchanges/exchanging.js +14 -4
  20. package/esm/keri/npm/src/app/identity/challenging.js +50 -0
  21. package/esm/keri/npm/src/app/identity/delegating.js +77 -77
  22. package/esm/keri/npm/src/app/identity/delegation-approval.js +333 -0
  23. package/esm/keri/npm/src/app/identity/event-completion.js +154 -0
  24. package/esm/keri/npm/src/app/identity/habbing.js +129 -6
  25. package/esm/keri/npm/src/app/identity/keeping.js +77 -4
  26. package/esm/keri/npm/src/app/ipex/group-ipex.js +341 -0
  27. package/esm/keri/npm/src/app/ipex/group-issuance.js +905 -0
  28. package/esm/keri/npm/src/app/ipex/ipex-admitting.js +120 -0
  29. package/esm/keri/npm/src/app/ipex/ipex-conversation.js +197 -0
  30. package/esm/keri/npm/src/app/ipex/ipex-discloser.js +591 -0
  31. package/esm/keri/npm/src/app/ipex/ipex-granting.js +93 -0
  32. package/esm/keri/npm/src/app/ipex/ipex-grouping.js +50 -19
  33. package/esm/keri/npm/src/app/ipex/ipex-node-authentication.js +42 -18
  34. package/esm/keri/npm/src/app/ipex/issuance.js +896 -0
  35. package/esm/keri/npm/src/app/ipex/pending-presentations.js +46 -0
  36. package/esm/keri/npm/src/app/ipex/presentation-files.js +200 -0
  37. package/esm/keri/npm/src/app/ipex/presenting.js +408 -0
  38. package/esm/keri/npm/src/app/ipex/receive-issuance.js +86 -0
  39. package/esm/keri/npm/src/app/ipex/unblinding-workflow.js +667 -0
  40. package/esm/keri/npm/src/app/mailbox/ipex-arrival.js +103 -0
  41. package/esm/keri/npm/src/app/mailbox/kel-publisher.js +322 -0
  42. package/esm/keri/npm/src/app/mailbox/kel-publishing.js +65 -0
  43. package/esm/keri/npm/src/app/mailbox/kel-submission.js +24 -0
  44. package/esm/keri/npm/src/app/mailbox/mailbox-admin.js +208 -0
  45. package/esm/keri/npm/src/app/mailbox/mailbox-poller.js +212 -47
  46. package/esm/keri/npm/src/app/mailbox/mailboxing.js +10 -5
  47. package/esm/keri/npm/src/app/multisig/counseling.js +488 -0
  48. package/esm/keri/npm/src/app/multisig/group-members.js +18 -0
  49. package/esm/keri/npm/src/app/multisig/multisig-messaging.js +33 -6
  50. package/esm/keri/npm/src/app/multisig/multisig-workflows.js +98 -147
  51. package/esm/keri/npm/src/app/multisig/proposals.js +281 -0
  52. package/esm/keri/npm/src/app/multisig/proposing.js +122 -0
  53. package/esm/keri/npm/src/app/notifications/signaling.js +5 -5
  54. package/esm/keri/npm/src/app/protocol/parsering.js +26 -1
  55. package/esm/keri/npm/src/app/protocol/protocol-processing.js +9 -3
  56. package/esm/keri/npm/src/app/queries/query-workflows.js +98 -0
  57. package/esm/keri/npm/src/app/runtime/agent-runtime.js +106 -55
  58. package/esm/keri/npm/src/app/runtime/cue-runtime.js +3 -6
  59. package/esm/keri/npm/src/app/runtime/delivery-outbox.js +87 -0
  60. package/esm/keri/npm/src/app/runtime/doing.js +17 -0
  61. package/esm/keri/npm/src/app/runtime/ipex-auxiliaries.js +207 -0
  62. package/esm/keri/npm/src/app/runtime/operation-owners.js +151 -0
  63. package/esm/keri/npm/src/app/runtime/retry-backoff.js +93 -0
  64. package/esm/keri/npm/src/app/runtime/workflow-contract.js +80 -0
  65. package/esm/keri/npm/src/app/transport/http-client.js +25 -6
  66. package/esm/keri/npm/src/app/witness/http-endpoints.js +4 -4
  67. package/esm/keri/npm/src/cli/common/event-completion.js +49 -0
  68. package/esm/keri/npm/src/cli/common/runtime-workers.js +23 -0
  69. package/esm/keri/npm/src/cli/credentials/ipex.js +164 -191
  70. package/esm/keri/npm/src/cli/credentials/vc.js +53 -72
  71. package/esm/keri/npm/src/cli/endpoints/did.js +12 -3
  72. package/esm/keri/npm/src/cli/endpoints/oobi.js +10 -13
  73. package/esm/keri/npm/src/cli/identity/challenge.js +8 -34
  74. package/esm/keri/npm/src/cli/identity/delegate.js +81 -258
  75. package/esm/keri/npm/src/cli/identity/incept.js +15 -32
  76. package/esm/keri/npm/src/cli/identity/interact.js +5 -17
  77. package/esm/keri/npm/src/cli/identity/rotate.js +8 -36
  78. package/esm/keri/npm/src/cli/index.js +3 -1
  79. package/esm/keri/npm/src/cli/messaging/group-join.js +83 -0
  80. package/esm/keri/npm/src/cli/messaging/group-wait.js +88 -0
  81. package/esm/keri/npm/src/cli/messaging/multisig.js +190 -285
  82. package/esm/keri/npm/src/cli/messaging/root-copy-lines.js +31 -0
  83. package/esm/keri/npm/src/core/kel/eventing.js +66 -10
  84. package/esm/keri/npm/src/core/mailbox/kram-policy.js +39 -6
  85. package/esm/keri/npm/src/core/mailbox/kraming.js +2 -0
  86. package/esm/keri/npm/src/core/records.js +23 -0
  87. package/esm/keri/npm/src/core/routing.js +13 -0
  88. package/esm/keri/npm/src/db/basing.js +34 -2
  89. package/esm/keri/npm/src/db/core/indexeddb-persistence.js +221 -0
  90. package/esm/keri/npm/src/db/indexeddb.js +98 -0
  91. package/esm/keri/npm/src/db/keeping.js +11 -2
  92. package/esm/keri/npm/src/db/store-lock.js +150 -0
  93. package/esm/keri/npm/src/npm/db-indexeddb.browser.js +2 -0
  94. package/esm/keri/npm/src/npm/db-indexeddb.js +3 -0
  95. package/esm/keri/npm/src/npm/db.browser.js +2 -0
  96. package/esm/keri/npm/src/npm/index.browser.js +9 -0
  97. package/esm/keri/npm/src/npm/runtime-web.browser.js +2 -0
  98. package/esm/keri/npm/src/npm/runtime-web.js +3 -0
  99. package/esm/keri/npm/src/npm/runtime.browser.js +2 -0
  100. package/esm/keri/npm/src/runtime/index.js +51 -4
  101. package/esm/keri/npm/src/runtime/web/output-barrier.js +47 -0
  102. package/esm/keri/npm/src/runtime/web/persistent-storage.js +37 -0
  103. package/esm/keri/npm/src/runtime/web.js +10 -0
  104. package/esm/keri/npm/src/vdr/tel-publication.js +16 -0
  105. package/esm/keri/npm/src/version.js +2 -2
  106. package/package.json +15 -2
  107. package/types/acdc/authoring.d.ts +54 -0
  108. package/types/acdc/authoring.d.ts.map +1 -0
  109. package/types/acdc/custody.d.ts +84 -0
  110. package/types/acdc/custody.d.ts.map +1 -0
  111. package/types/acdc/dhking.d.ts +94 -3
  112. package/types/acdc/dhking.d.ts.map +1 -1
  113. package/types/acdc/regbasing.d.ts +4 -0
  114. package/types/acdc/regbasing.d.ts.map +1 -1
  115. package/types/acdc/salting.d.ts +6 -1
  116. package/types/acdc/salting.d.ts.map +1 -1
  117. package/types/acdc/scheming.d.ts +2 -0
  118. package/types/acdc/scheming.d.ts.map +1 -1
  119. package/types/acdc/unblinding.d.ts +58 -19
  120. package/types/acdc/unblinding.d.ts.map +1 -1
  121. package/types/app/bootstrap/authenticating.d.ts +3 -1
  122. package/types/app/bootstrap/authenticating.d.ts.map +1 -1
  123. package/types/app/bootstrap/oobi-resolving.d.ts +92 -0
  124. package/types/app/bootstrap/oobi-resolving.d.ts.map +1 -0
  125. package/types/app/bootstrap/oobiery.d.ts +3 -1
  126. package/types/app/bootstrap/oobiery.d.ts.map +1 -1
  127. package/types/app/credentials/credential-revoking.d.ts +3 -0
  128. package/types/app/credentials/credential-revoking.d.ts.map +1 -1
  129. package/types/app/credentials/credential-workflows.d.ts +5 -0
  130. package/types/app/credentials/credential-workflows.d.ts.map +1 -1
  131. package/types/app/credentials/registry-settling.d.ts +85 -0
  132. package/types/app/credentials/registry-settling.d.ts.map +1 -0
  133. package/types/app/credentials/root-replicating.d.ts +56 -44
  134. package/types/app/credentials/root-replicating.d.ts.map +1 -1
  135. package/types/app/credentials/root-replicator.d.ts +105 -0
  136. package/types/app/credentials/root-replicator.d.ts.map +1 -0
  137. package/types/app/credentials/tel-completion.d.ts +55 -0
  138. package/types/app/credentials/tel-completion.d.ts.map +1 -0
  139. package/types/app/delivery/forwarding.d.ts +6 -0
  140. package/types/app/delivery/forwarding.d.ts.map +1 -1
  141. package/types/app/exchanges/exchanging.d.ts.map +1 -1
  142. package/types/app/identity/challenging.d.ts +54 -0
  143. package/types/app/identity/challenging.d.ts.map +1 -1
  144. package/types/app/identity/delegating.d.ts +21 -4
  145. package/types/app/identity/delegating.d.ts.map +1 -1
  146. package/types/app/identity/delegation-approval.d.ts +228 -0
  147. package/types/app/identity/delegation-approval.d.ts.map +1 -0
  148. package/types/app/identity/event-completion.d.ts +151 -0
  149. package/types/app/identity/event-completion.d.ts.map +1 -0
  150. package/types/app/identity/habbing.d.ts +67 -2
  151. package/types/app/identity/habbing.d.ts.map +1 -1
  152. package/types/app/identity/keeping.d.ts +49 -3
  153. package/types/app/identity/keeping.d.ts.map +1 -1
  154. package/types/app/ipex/group-ipex.d.ts +254 -0
  155. package/types/app/ipex/group-ipex.d.ts.map +1 -0
  156. package/types/app/ipex/group-issuance.d.ts +281 -0
  157. package/types/app/ipex/group-issuance.d.ts.map +1 -0
  158. package/types/app/ipex/ipex-admitting.d.ts +47 -0
  159. package/types/app/ipex/ipex-admitting.d.ts.map +1 -0
  160. package/types/app/ipex/ipex-conversation.d.ts +195 -0
  161. package/types/app/ipex/ipex-conversation.d.ts.map +1 -0
  162. package/types/app/ipex/ipex-discloser.d.ts +156 -0
  163. package/types/app/ipex/ipex-discloser.d.ts.map +1 -0
  164. package/types/app/ipex/ipex-granting.d.ts +145 -0
  165. package/types/app/ipex/ipex-granting.d.ts.map +1 -0
  166. package/types/app/ipex/ipex-grouping.d.ts +18 -0
  167. package/types/app/ipex/ipex-grouping.d.ts.map +1 -1
  168. package/types/app/ipex/ipex-node-authentication.d.ts +9 -1
  169. package/types/app/ipex/ipex-node-authentication.d.ts.map +1 -1
  170. package/types/app/ipex/issuance.d.ts +445 -0
  171. package/types/app/ipex/issuance.d.ts.map +1 -0
  172. package/types/app/ipex/pending-presentations.d.ts +25 -0
  173. package/types/app/ipex/pending-presentations.d.ts.map +1 -0
  174. package/types/app/ipex/presentation-files.d.ts +47 -0
  175. package/types/app/ipex/presentation-files.d.ts.map +1 -0
  176. package/types/app/ipex/presenting.d.ts +300 -0
  177. package/types/app/ipex/presenting.d.ts.map +1 -0
  178. package/types/app/ipex/receive-issuance.d.ts +99 -0
  179. package/types/app/ipex/receive-issuance.d.ts.map +1 -0
  180. package/types/app/ipex/unblinding-workflow.d.ts +257 -0
  181. package/types/app/ipex/unblinding-workflow.d.ts.map +1 -0
  182. package/types/app/mailbox/ipex-arrival.d.ts +104 -0
  183. package/types/app/mailbox/ipex-arrival.d.ts.map +1 -0
  184. package/types/app/mailbox/kel-publisher.d.ts +141 -0
  185. package/types/app/mailbox/kel-publisher.d.ts.map +1 -0
  186. package/types/app/mailbox/kel-publishing.d.ts +70 -0
  187. package/types/app/mailbox/kel-publishing.d.ts.map +1 -0
  188. package/types/app/mailbox/kel-submission.d.ts +18 -0
  189. package/types/app/mailbox/kel-submission.d.ts.map +1 -0
  190. package/types/app/mailbox/mailbox-admin.d.ts +113 -0
  191. package/types/app/mailbox/mailbox-admin.d.ts.map +1 -0
  192. package/types/app/mailbox/mailbox-poller.d.ts +92 -3
  193. package/types/app/mailbox/mailbox-poller.d.ts.map +1 -1
  194. package/types/app/mailbox/mailboxing.d.ts +3 -0
  195. package/types/app/mailbox/mailboxing.d.ts.map +1 -1
  196. package/types/app/multisig/counseling.d.ts +196 -0
  197. package/types/app/multisig/counseling.d.ts.map +1 -0
  198. package/types/app/multisig/group-members.d.ts +11 -0
  199. package/types/app/multisig/group-members.d.ts.map +1 -1
  200. package/types/app/multisig/grouping.d.ts +39 -20
  201. package/types/app/multisig/grouping.d.ts.map +1 -1
  202. package/types/app/multisig/multisig-messaging.d.ts +23 -6
  203. package/types/app/multisig/multisig-messaging.d.ts.map +1 -1
  204. package/types/app/multisig/multisig-workflows.d.ts +91 -22
  205. package/types/app/multisig/multisig-workflows.d.ts.map +1 -1
  206. package/types/app/multisig/proposals.d.ts +129 -0
  207. package/types/app/multisig/proposals.d.ts.map +1 -0
  208. package/types/app/multisig/proposing.d.ts +125 -0
  209. package/types/app/multisig/proposing.d.ts.map +1 -0
  210. package/types/app/notifications/signaling.d.ts +3 -1
  211. package/types/app/notifications/signaling.d.ts.map +1 -1
  212. package/types/app/protocol/parsering.d.ts +13 -0
  213. package/types/app/protocol/parsering.d.ts.map +1 -1
  214. package/types/app/protocol/protocol-processing.d.ts +7 -1
  215. package/types/app/protocol/protocol-processing.d.ts.map +1 -1
  216. package/types/app/queries/query-workflows.d.ts +98 -0
  217. package/types/app/queries/query-workflows.d.ts.map +1 -0
  218. package/types/app/runtime/agent-runtime.d.ts +72 -25
  219. package/types/app/runtime/agent-runtime.d.ts.map +1 -1
  220. package/types/app/runtime/cue-runtime.d.ts +2 -1
  221. package/types/app/runtime/cue-runtime.d.ts.map +1 -1
  222. package/types/app/runtime/delivery-outbox.d.ts +68 -0
  223. package/types/app/runtime/delivery-outbox.d.ts.map +1 -0
  224. package/types/app/runtime/doing.d.ts +27 -0
  225. package/types/app/runtime/doing.d.ts.map +1 -0
  226. package/types/app/runtime/ipex-auxiliaries.d.ts +74 -0
  227. package/types/app/runtime/ipex-auxiliaries.d.ts.map +1 -0
  228. package/types/app/runtime/operation-owners.d.ts +137 -0
  229. package/types/app/runtime/operation-owners.d.ts.map +1 -0
  230. package/types/app/runtime/retry-backoff.d.ts +49 -0
  231. package/types/app/runtime/retry-backoff.d.ts.map +1 -0
  232. package/types/app/runtime/workflow-contract.d.ts +79 -0
  233. package/types/app/runtime/workflow-contract.d.ts.map +1 -0
  234. package/types/app/transport/http-client.d.ts.map +1 -1
  235. package/types/cli/common/event-completion.d.ts +26 -0
  236. package/types/cli/common/event-completion.d.ts.map +1 -0
  237. package/types/cli/common/runtime-workers.d.ts +23 -0
  238. package/types/cli/common/runtime-workers.d.ts.map +1 -0
  239. package/types/cli/credentials/ipex.d.ts.map +1 -1
  240. package/types/cli/credentials/vc.d.ts +1 -1
  241. package/types/cli/credentials/vc.d.ts.map +1 -1
  242. package/types/cli/endpoints/did.d.ts.map +1 -1
  243. package/types/cli/endpoints/oobi.d.ts +3 -1
  244. package/types/cli/endpoints/oobi.d.ts.map +1 -1
  245. package/types/cli/identity/challenge.d.ts +1 -1
  246. package/types/cli/identity/challenge.d.ts.map +1 -1
  247. package/types/cli/identity/delegate.d.ts +14 -1
  248. package/types/cli/identity/delegate.d.ts.map +1 -1
  249. package/types/cli/identity/incept.d.ts.map +1 -1
  250. package/types/cli/identity/interact.d.ts.map +1 -1
  251. package/types/cli/identity/rotate.d.ts.map +1 -1
  252. package/types/cli/index.d.ts +3 -1
  253. package/types/cli/index.d.ts.map +1 -1
  254. package/types/cli/messaging/group-join.d.ts +56 -0
  255. package/types/cli/messaging/group-join.d.ts.map +1 -0
  256. package/types/cli/messaging/group-wait.d.ts +34 -0
  257. package/types/cli/messaging/group-wait.d.ts.map +1 -0
  258. package/types/cli/messaging/multisig.d.ts +29 -5
  259. package/types/cli/messaging/multisig.d.ts.map +1 -1
  260. package/types/cli/messaging/root-copy-lines.d.ts +39 -0
  261. package/types/cli/messaging/root-copy-lines.d.ts.map +1 -0
  262. package/types/core/cues.d.ts +11 -0
  263. package/types/core/cues.d.ts.map +1 -1
  264. package/types/core/kel/eventing.d.ts.map +1 -1
  265. package/types/core/mailbox/kram-policy.d.ts +14 -0
  266. package/types/core/mailbox/kram-policy.d.ts.map +1 -1
  267. package/types/core/mailbox/kraming.d.ts +1 -1
  268. package/types/core/mailbox/kraming.d.ts.map +1 -1
  269. package/types/core/records.d.ts +61 -0
  270. package/types/core/records.d.ts.map +1 -1
  271. package/types/core/routing.d.ts +6 -0
  272. package/types/core/routing.d.ts.map +1 -1
  273. package/types/db/basing.d.ts +8 -2
  274. package/types/db/basing.d.ts.map +1 -1
  275. package/types/db/core/indexeddb-persistence.d.ts +59 -0
  276. package/types/db/core/indexeddb-persistence.d.ts.map +1 -0
  277. package/types/db/indexeddb.d.ts +37 -0
  278. package/types/db/indexeddb.d.ts.map +1 -0
  279. package/types/db/keeping.d.ts +5 -2
  280. package/types/db/keeping.d.ts.map +1 -1
  281. package/types/db/store-lock.d.ts +72 -0
  282. package/types/db/store-lock.d.ts.map +1 -0
  283. package/types/npm/db-indexeddb.d.ts +4 -0
  284. package/types/npm/db-indexeddb.d.ts.map +1 -0
  285. package/types/npm/runtime-web.d.ts +4 -0
  286. package/types/npm/runtime-web.d.ts.map +1 -0
  287. package/types/runtime/index.d.ts +42 -7
  288. package/types/runtime/index.d.ts.map +1 -1
  289. package/types/runtime/web/output-barrier.d.ts +30 -0
  290. package/types/runtime/web/output-barrier.d.ts.map +1 -0
  291. package/types/runtime/web/persistent-storage.d.ts +36 -0
  292. package/types/runtime/web/persistent-storage.d.ts.map +1 -0
  293. package/types/runtime/web.d.ts +11 -0
  294. package/types/runtime/web.d.ts.map +1 -0
  295. package/types/vdr/tel-publication.d.ts +6 -0
  296. package/types/vdr/tel-publication.d.ts.map +1 -1
  297. package/types/version.d.ts +2 -2
  298. package/esm/keri/npm/src/cli/common/tel-completion.js +0 -24
  299. package/types/cli/common/tel-completion.d.ts +0 -8
  300. package/types/cli/common/tel-completion.d.ts.map +0 -1
@@ -0,0 +1,151 @@
1
+ import { BaserDerivedUpdateStore } from "../../acdc/custody.js";
2
+ import { RootReplicator } from "../credentials/root-replicator.js";
3
+ import { GroupIpexOperations } from "../ipex/group-ipex.js";
4
+ import { IssuanceOperations, posterDelivery } from "../ipex/issuance.js";
5
+ import { PresentationOperations } from "../ipex/presenting.js";
6
+ import { UnblindingOperations } from "../ipex/unblinding-workflow.js";
7
+ import { doEvery } from "./doing.js";
8
+ /** Milliseconds between owner passes; the cadence of the CLI drivers the loop replaced. */
9
+ export const OWNER_TOCK_MS = 50;
10
+ /** Tocks between the replicator's full rotation checks: 1200 tocks of 50 ms is a minute. */
11
+ export const OWNER_SWEEP_TOCKS = 1200;
12
+ /** The production pacing of the owner loop. */
13
+ export const OWNER_PACING = Object.freeze({
14
+ tockMs: OWNER_TOCK_MS,
15
+ sweepTocks: OWNER_SWEEP_TOCKS,
16
+ });
17
+ /**
18
+ * Failures of the owner loop itself. A failure of one operation (a delivery that throws, an unreadable stored
19
+ * Grant) ends that operation as `failed` and is never recorded here; this records only what escaped an owner
20
+ * pass, which the loop survives so that the other owners keep running. `faults` counts them and `last` keeps
21
+ * the latest. Nothing clears it: a host reads it and decides.
22
+ */
23
+ export class OwnerHealth {
24
+ constructor() {
25
+ Object.defineProperty(this, "faults", {
26
+ enumerable: true,
27
+ configurable: true,
28
+ writable: true,
29
+ value: 0
30
+ });
31
+ Object.defineProperty(this, "last", {
32
+ enumerable: true,
33
+ configurable: true,
34
+ writable: true,
35
+ value: null
36
+ });
37
+ }
38
+ }
39
+ /** Construct the owners over their in-memory tables; the derivation store defaults to the registry database. */
40
+ export function composeOwners(parts, stores = {}) {
41
+ const { hby, acdc, exc, protocol, reactor, postman, receiptor, ipex, clock, registryRoot, mux, counselor } = parts;
42
+ const changes = stores.changes ?? parts.changes, delivery = posterDelivery(postman);
43
+ const issuance = {
44
+ hby,
45
+ rgy: acdc,
46
+ exc,
47
+ receiptor,
48
+ dhkes: ipex,
49
+ reactor,
50
+ protocol,
51
+ delivery,
52
+ derived: stores.derived ?? new BaserDerivedUpdateStore(acdc.store.baser),
53
+ clock,
54
+ changes,
55
+ retry: parts.retry,
56
+ queryResendMs: parts.queryResendMs,
57
+ group: { mux, registry: { hby, protocol, postman, counselor, registryStore: acdc.store } },
58
+ };
59
+ const operations = {
60
+ issuance: new IssuanceOperations(issuance),
61
+ groupIpex: new GroupIpexOperations({
62
+ hby,
63
+ rgy: acdc,
64
+ exc,
65
+ protocol,
66
+ postman,
67
+ clock,
68
+ registry: { hby, protocol, postman, counselor, registryStore: acdc.store },
69
+ changes,
70
+ }),
71
+ presentation: new PresentationOperations({
72
+ hby,
73
+ rgy: acdc,
74
+ exc,
75
+ receiptor,
76
+ reactor,
77
+ protocol,
78
+ delivery,
79
+ clock,
80
+ derived: issuance.derived,
81
+ views: stores.views,
82
+ retry: parts.retry,
83
+ changes,
84
+ }),
85
+ health: new OwnerHealth(),
86
+ unblinding: new UnblindingOperations({
87
+ hby,
88
+ exc,
89
+ unblinds: ipex,
90
+ group: { mux, protocol },
91
+ delivery,
92
+ clock,
93
+ retry: parts.retry,
94
+ changes,
95
+ }),
96
+ };
97
+ const rootReplicator = registryRoot ? new RootReplicator({ root: registryRoot, postman, clock, changes }) : null;
98
+ return { operations, rootReplicator };
99
+ }
100
+ /**
101
+ * Run every owner on one fiber until halted, as a fixed-tock doer (`./doing.ts`): each tock runs an owner that
102
+ * has live work, then the replicator (after prompting it with the live DH owners' `replicated` cues), and then
103
+ * the loop waits one tock. Work begun between tocks is seen on the next one; nothing wakes the loop early.
104
+ *
105
+ * Idle cost, per tock: four constant-time table checks, one in-memory walk of the Unblind owners for an owed
106
+ * reply, one drain of each DH owner's cue deck, and the replicator's emptiness checks. The replicator's
107
+ * rotation check (the establishment SAID of each local group, one keyed read per local identifier) runs on
108
+ * tock 0 and every `pacing.sweepTocks`. No owner reads a protocol store. Only the first pass, once, scans the
109
+ * pending exchange escrow for resumable Grants.
110
+ *
111
+ * A failure that escapes an owner pass is recorded in `operations.health` and the loop keeps running, so
112
+ * one owner's fault never stops the others. The owners run one after another, so a delivery that does not return holds the others up until it fails or
113
+ * its Grant deadline passes; operations already bound each delivery by that deadline.
114
+ */
115
+ export function* operationOwnersDo(owners, pacing = OWNER_PACING) {
116
+ const { operations, rootReplicator, ipex, clock } = owners, { health } = operations;
117
+ const guarded = function* (owner, pass) {
118
+ try {
119
+ yield* pass();
120
+ }
121
+ catch (error) {
122
+ health.faults++;
123
+ health.last = {
124
+ owner,
125
+ error: error instanceof Error ? error.message : String(error),
126
+ at: new Date(clock.now()).toISOString(),
127
+ };
128
+ }
129
+ };
130
+ return yield* doEvery(clock, pacing.tockMs, function* (tock) {
131
+ if (operations.issuance.active())
132
+ yield* guarded("issuance", () => operations.issuance.processOnce());
133
+ if (operations.groupIpex.active())
134
+ yield* guarded("groupIpex", () => operations.groupIpex.processOnce());
135
+ if (operations.presentation.active())
136
+ yield* guarded("presentation", () => operations.presentation.processOnce());
137
+ if (operations.unblinding.active())
138
+ yield* guarded("unblinding", () => operations.unblinding.processOnce());
139
+ if (rootReplicator) {
140
+ yield* guarded("replicator", function* () {
141
+ for (const dh of ipex.dhkeOwners()) {
142
+ while (dh.replicated.length)
143
+ rootReplicator.replicate(dh.replicated.pull());
144
+ }
145
+ if (tock % pacing.sweepTocks === 0)
146
+ rootReplicator.sweep();
147
+ yield* rootReplicator.processDue();
148
+ });
149
+ }
150
+ });
151
+ }
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Retry state for a transient delivery failure inside a live operation.
3
+ *
4
+ * A member that is briefly offline is normal, so an owner keeps the unsent work, waits with a doubling delay and
5
+ * tries again on a later pass instead of ending the operation at the first error. The owner decides when retrying
6
+ * stops: an operation with a deadline ends at the deadline, and one without ends once failures have lasted the
7
+ * bound it states.
8
+ */
9
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
11
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
12
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
13
+ };
14
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
15
+ if (kind === "m") throw new TypeError("Private method is not writable");
16
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
17
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
18
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
19
+ };
20
+ var _RetryBackoff_next;
21
+ /** Delay after the first failure; it doubles per consecutive failure up to {@link RETRY_MAX_MS}. */
22
+ export const RETRY_BASE_MS = 1_000;
23
+ /** Longest delay between attempts. */
24
+ export const RETRY_MAX_MS = 30_000;
25
+ /** How long failures may last before an owner with no deadline of its own gives up. */
26
+ export const RETRY_BOUND_MS = 600_000;
27
+ /** The production delays of delivery retries. */
28
+ export const DEFAULT_RETRY_POLICY = Object.freeze({
29
+ baseMs: RETRY_BASE_MS,
30
+ maxMs: RETRY_MAX_MS,
31
+ boundMs: RETRY_BOUND_MS,
32
+ });
33
+ /** Consecutive-failure counter with a next-attempt time; memory only. */
34
+ export class RetryBackoff {
35
+ constructor(policy = DEFAULT_RETRY_POLICY) {
36
+ Object.defineProperty(this, "policy", {
37
+ enumerable: true,
38
+ configurable: true,
39
+ writable: true,
40
+ value: policy
41
+ });
42
+ /** Consecutive failures since the last success. */
43
+ Object.defineProperty(this, "attempts", {
44
+ enumerable: true,
45
+ configurable: true,
46
+ writable: true,
47
+ value: 0
48
+ });
49
+ /** Time of the first failure of the current run (host clock, ms); 0 when none. */
50
+ Object.defineProperty(this, "since", {
51
+ enumerable: true,
52
+ configurable: true,
53
+ writable: true,
54
+ value: 0
55
+ });
56
+ /** Error of the latest failure. */
57
+ Object.defineProperty(this, "last", {
58
+ enumerable: true,
59
+ configurable: true,
60
+ writable: true,
61
+ value: null
62
+ });
63
+ _RetryBackoff_next.set(this, 0);
64
+ }
65
+ /** Host-clock time (ms) of the next attempt. */
66
+ get next() {
67
+ return __classPrivateFieldGet(this, _RetryBackoff_next, "f");
68
+ }
69
+ /** Whether an attempt may be made at `now`. */
70
+ due(now) {
71
+ return now >= __classPrivateFieldGet(this, _RetryBackoff_next, "f");
72
+ }
73
+ /** Record a failure at `now` and schedule the next attempt. */
74
+ failed(now, error) {
75
+ if (this.attempts === 0)
76
+ this.since = now;
77
+ this.attempts++;
78
+ this.last = error;
79
+ __classPrivateFieldSet(this, _RetryBackoff_next, now + Math.min(this.policy.baseMs * 2 ** (this.attempts - 1), this.policy.maxMs), "f");
80
+ }
81
+ /** Whether failures have lasted at least `boundMs` by `now`. */
82
+ exhausted(now, boundMs) {
83
+ return this.attempts > 0 && now - this.since >= boundMs;
84
+ }
85
+ /** Forget failures after a success. */
86
+ succeeded() {
87
+ this.attempts = 0;
88
+ this.since = 0;
89
+ this.last = null;
90
+ __classPrivateFieldSet(this, _RetryBackoff_next, 0, "f");
91
+ }
92
+ }
93
+ _RetryBackoff_next = new WeakMap();
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Shared pieces of the library workflow contract.
3
+ *
4
+ * Library workflows follow one shape: `begin*` is an explicit operation that
5
+ * returns after local commit, `*Status` is a pure synchronous read, and
6
+ * `waitFor*` only observes. A wait never starts runtime workers: a host that
7
+ * already runs a runtime must not get a second poller and escrow loop. One-shot
8
+ * hosts such as the CLI run the runtime around the wait themselves
9
+ * (`cli/common/runtime-workers.ts`). Remote and time-driven outcomes, including
10
+ * an expired wait, are returned values; only caller-contract, invariant and
11
+ * infrastructure failures throw.
12
+ */
13
+ import { action, sleep } from "effection";
14
+ import { systemClock } from "./runtime-clock.js";
15
+ import { runtimeTurn } from "./runtime-turn.js";
16
+ /** In-memory sink that records changes in order. */
17
+ export class MemoryChangeSink {
18
+ constructor() {
19
+ Object.defineProperty(this, "changes", {
20
+ enumerable: true,
21
+ configurable: true,
22
+ writable: true,
23
+ value: []
24
+ });
25
+ }
26
+ push(change) {
27
+ this.changes.push({ kind: change.kind, id: change.id });
28
+ }
29
+ }
30
+ /**
31
+ * Back a sink with the host's transient `Signaler`. Publishing needs no polling:
32
+ * `push` is a synchronous append that collapses repeats of one workflow into a
33
+ * single signal (collapse key `kind:id`). Delivery is pull-based, though: the
34
+ * Signaler has no subscriber hook, so the consumer must read `signaler.list()`.
35
+ * A closed or failing Signaler drops the change instead of throwing: a hint must
36
+ * never break the workflow that published it.
37
+ */
38
+ export function signalerChangeSink(signaler) {
39
+ return {
40
+ push: ({ kind, id }) => {
41
+ try {
42
+ signaler.push({ id }, `/workflow/${kind}`, { ckey: `${kind}:${id}` });
43
+ }
44
+ catch {
45
+ // Dropped on purpose; consumers re-read status and tolerate a missed hint.
46
+ }
47
+ },
48
+ };
49
+ }
50
+ /**
51
+ * Observe-only wait: poll `done`, yielding to the scheduler between checks,
52
+ * until it holds or the deadline passes. Starts no worker and has no effects of
53
+ * its own.
54
+ *
55
+ * @param done Synchronous status read; checked before the first yield.
56
+ * @param pollMs Elapsed milliseconds between checks. Omitted: yield one scheduler turn.
57
+ * @returns True when `done` held, false when `timeoutMs` elapsed first.
58
+ */
59
+ export function* observeUntil(done, { timeoutMs, clock = systemClock, pollMs }) {
60
+ const deadline = clock.now() + timeoutMs;
61
+ while (!done()) {
62
+ const remaining = deadline - clock.now();
63
+ if (remaining <= 0)
64
+ return false;
65
+ if (pollMs === undefined)
66
+ yield* runtimeTurn();
67
+ else
68
+ yield* sleep(Math.min(pollMs, remaining));
69
+ }
70
+ return true;
71
+ }
72
+ /**
73
+ * Wait `milliseconds` on the host's clock, so a fake clock drives it and cancellation releases the timer.
74
+ */
75
+ export function* waitOnClock(clock, milliseconds) {
76
+ yield* action((resolve) => {
77
+ const timer = clock.setTimeout(resolve, milliseconds);
78
+ return () => clock.clearTimeout(timer);
79
+ });
80
+ }
@@ -4,6 +4,21 @@ import { ValidationError } from "../../core/errors.js";
4
4
  import { abortable } from "../runtime/abortable.js";
5
5
  import { collectBytes } from "./byte-source.js";
6
6
  import { TransportError } from "./transport-error.js";
7
+ /**
8
+ * Native requests and signals that a pending `fetch` still needs. WebKit links an in-flight fetch to
9
+ * its abort signal only weakly: once the `Request`, or an `AbortSignal.any` composite, is garbage
10
+ * collected, `abort()` neither rejects the fetch nor closes the connection, so a halted caller waits
11
+ * forever on a request that WebKit will never settle. A strong reference until the request scope
12
+ * ends keeps the link alive; engines that hold it themselves are unaffected.
13
+ */
14
+ const inFlight = new Set();
15
+ /**
16
+ * Whether `cause` is the rejection an abort of `signal` produces. Chromium rejects with `signal.reason`;
17
+ * Node 20 and WebKit reject with a fresh native `AbortError`, which is the same cancellation.
18
+ */
19
+ function isAbort(cause, signal) {
20
+ return cause === signal.reason || (cause instanceof DOMException && cause.name === "AbortError");
21
+ }
7
22
  /**
8
23
  * Own the native Request, fetch and response reader for one attempt.
9
24
  * Construction errors remain outside network classification. Native fetch/read
@@ -44,6 +59,7 @@ export class FetchHttpClient {
44
59
  const controller = new AbortController();
45
60
  const signal = init.signal ? AbortSignal.any([controller.signal, init.signal]) : controller.signal;
46
61
  // These handles let scope teardown join native work before releasing the reader.
62
+ let request;
47
63
  let fetching;
48
64
  let reader;
49
65
  let reading;
@@ -57,7 +73,9 @@ export class FetchHttpClient {
57
73
  * @param message Operation detail to combine with the endpoint URL.
58
74
  * @returns Original cancellation reason or a TransportError retaining cause.
59
75
  */
60
- const transportFailure = (cause, message) => signal.aborted && cause === signal.reason ? cause : new TransportError(`${message} for ${url}`, { cause });
76
+ const transportFailure = (cause, message) => signal.aborted && isAbort(cause, signal)
77
+ ? signal.reason
78
+ : new TransportError(`${message} for ${url}`, { cause });
61
79
  try {
62
80
  signal.throwIfAborted();
63
81
  const endpoint = new URL(url);
@@ -65,7 +83,8 @@ export class FetchHttpClient {
65
83
  throw new ValidationError("HTTP output requires an HTTP(S) URL without credentials");
66
84
  }
67
85
  // Construction errors are caller errors, before native network classification.
68
- const request = new Request(url, { ...init, signal, body: init.body });
86
+ request = new Request(url, { ...init, signal, body: init.body });
87
+ inFlight.add(request).add(signal);
69
88
  fetching = fetch(request).catch((cause) => {
70
89
  throw transportFailure(cause, "HTTP request failed");
71
90
  });
@@ -99,9 +118,6 @@ export class FetchHttpClient {
99
118
  signal.throwIfAborted();
100
119
  reading = reader.read().catch((cause) => {
101
120
  // Node 20 Fetch replaces the supplied reason with a native AbortError during body reads.
102
- if (signal.aborted && cause instanceof DOMException && cause.name === "AbortError") {
103
- throw signal.reason;
104
- }
105
121
  throw transportFailure(cause, "HTTP response body failed");
106
122
  });
107
123
  let result;
@@ -144,7 +160,7 @@ export class FetchHttpClient {
144
160
  await pending;
145
161
  }
146
162
  catch (error) {
147
- if (error !== signal.reason && error !== failure?.error)
163
+ if (!isAbort(error, signal) && error !== failure?.error)
148
164
  cleanup.push(error);
149
165
  }
150
166
  }
@@ -156,6 +172,9 @@ export class FetchHttpClient {
156
172
  }
157
173
  bodySignal?.removeEventListener("abort", abortBody);
158
174
  });
175
+ if (request)
176
+ inFlight.delete(request);
177
+ inFlight.delete(signal);
159
178
  // Throw outside the Promise leaf so Effection teardown preserves genuine cleanup failures.
160
179
  if (cleanup.length) {
161
180
  if (failure && failure.error !== signal.reason)
@@ -1,5 +1,5 @@
1
1
  /** Witness HTTP semantic policies for receipts, log queries and endorsed key state; adapters format decisions. */
2
- import { Ilks, Vrsn_2_0 } from "cesr-ts";
2
+ import { Ilks } from "cesr-ts";
3
3
  import { receipt as receiptEvent, reply as replyEvent } from "../../core/protocol-eventing.js";
4
4
  import { dgKey } from "../../db/core/keys.js";
5
5
  import { inspectCesrRequest } from "../transport/cesr-http.js";
@@ -178,8 +178,8 @@ export function witnessKeyStateGet(serviceHab, query) {
178
178
  status: 200,
179
179
  body: serviceHab.endorse(replyEvent(`/ksn/${serviceHab.pre}`, kever.state().asDict(), {
180
180
  pre: serviceHab.pre,
181
- pvrsn: Vrsn_2_0,
182
- gvrsn: Vrsn_2_0,
183
- }), { gvrsn: Vrsn_2_0 }),
181
+ pvrsn: serviceHab.kelVersion,
182
+ gvrsn: serviceHab.kelVersion,
183
+ }), { gvrsn: serviceHab.kelVersion }),
184
184
  };
185
185
  }
@@ -0,0 +1,49 @@
1
+ import { completeEvent } from "../../app/identity/event-completion.js";
2
+ import { KelPublisher } from "../../app/mailbox/kel-publisher.js";
3
+ import { createProtocolProcessor } from "../../app/protocol/protocol-processing.js";
4
+ import { createAgentRuntime } from "../../app/runtime/agent-runtime.js";
5
+ import { systemClock } from "../../app/runtime/runtime-clock.js";
6
+ import { withRuntimeWorkers } from "./runtime-workers.js";
7
+ /**
8
+ * Compose event-completion dependencies for one CLI command.
9
+ *
10
+ * A short-lived runtime is created only when a delegated event needs workers.
11
+ * It is lent to the library for that one scope with its workers running around
12
+ * the library's observe-only wait, and closed on every exit path.
13
+ */
14
+ export function cliEventCompletionDeps(hby, http) {
15
+ // A command has no running runtime, so it carries the publisher whose pass `completeEventOrThrow` runs.
16
+ const publisher = new KelPublisher({ hby, http, clock: systemClock });
17
+ return {
18
+ hby,
19
+ publisher,
20
+ rotated: publisher.rotated,
21
+ protocol: createProtocolProcessor(hby),
22
+ http,
23
+ clock: systemClock,
24
+ *withDelegation(hab, use) {
25
+ const runtime = yield* createAgentRuntime(hby, http, systemClock);
26
+ try {
27
+ return yield* withRuntimeWorkers(runtime, { hab, pollMailbox: true }, () => use({ anchorer: runtime.delegating }));
28
+ }
29
+ finally {
30
+ yield* runtime.close();
31
+ }
32
+ },
33
+ };
34
+ }
35
+ /**
36
+ * `completeEvent` for commands: an expired delegation wait fails the command with
37
+ * the text the CLI has always printed, then the caller sees the usual result.
38
+ */
39
+ export function* completeEventOrThrow(deps, ...args) {
40
+ const completion = yield* completeEvent(deps, ...args);
41
+ if (completion.outcome === "timed-out") {
42
+ throw new Error(`Runtime did not converge within ${completion.timeoutMs}ms.`);
43
+ }
44
+ // No fiber runs the publisher in a one-shot command: tell the mailboxes of a completed rotation now. A
45
+ // mailbox that cannot be reached stays owed in the marker and the poller repairs it.
46
+ if (!deps.publisher.rotated.empty)
47
+ yield* deps.publisher.processOnce();
48
+ return completion;
49
+ }
@@ -0,0 +1,23 @@
1
+ import { spawn } from "effection";
2
+ import { runAgentRuntime } from "../../app/runtime/agent-runtime.js";
3
+ /**
4
+ * Run the runtime workers around one observe-only library call.
5
+ *
6
+ * Library workflows only observe (see `app/runtime/workflow-contract.ts`); a
7
+ * one-shot CLI command has no running runtime, so it supplies the workers here.
8
+ * The worker is halted and joined on success, failure and cancellation before
9
+ * the caller can release stores.
10
+ *
11
+ * @param runtime Borrowed composed runtime; the command owns its lifetime.
12
+ * @param options Signer, mailbox polling and command-owned query cue Deck.
13
+ * @param use Observe-only operation that depends on the workers' progress.
14
+ */
15
+ export function* withRuntimeWorkers(runtime, options, use) {
16
+ const worker = yield* spawn(() => runAgentRuntime(runtime, options));
17
+ try {
18
+ return yield* use();
19
+ }
20
+ finally {
21
+ yield* worker.halt();
22
+ }
23
+ }