@moltzap/client 2026.1004.0 → 2026.1005.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. package/NOTICE +1 -6
  2. package/dist/delivery/history-export.d.ts +2 -3
  3. package/dist/delivery/history-export.d.ts.map +1 -1
  4. package/dist/delivery/inbox.d.ts +2 -1
  5. package/dist/delivery/inbox.d.ts.map +1 -1
  6. package/dist/delivery/inbox.js +2 -1
  7. package/dist/delivery/inbox.js.map +1 -1
  8. package/dist/delivery/operations.d.ts +8 -10
  9. package/dist/delivery/operations.d.ts.map +1 -1
  10. package/dist/endpoint/harness-endpoint/events.js +1 -1
  11. package/dist/endpoint/harness-endpoint/events.js.map +1 -1
  12. package/dist/endpoint/harness-endpoint/index.js +1 -1
  13. package/dist/endpoint/harness-endpoint/index.js.map +1 -1
  14. package/dist/endpoint/mcp/events.d.ts.map +1 -1
  15. package/dist/endpoint/mcp/events.js +14 -2
  16. package/dist/endpoint/mcp/events.js.map +1 -1
  17. package/dist/endpoint/mcp/names.d.ts +18 -0
  18. package/dist/endpoint/mcp/names.d.ts.map +1 -0
  19. package/dist/endpoint/mcp/names.js +18 -0
  20. package/dist/endpoint/mcp/names.js.map +1 -0
  21. package/dist/endpoint/mcp/owner-tools.d.ts.map +1 -1
  22. package/dist/endpoint/mcp/owner-tools.js +1 -2
  23. package/dist/endpoint/mcp/owner-tools.js.map +1 -1
  24. package/dist/endpoint/mcp/schemas.d.ts +1 -19
  25. package/dist/endpoint/mcp/schemas.d.ts.map +1 -1
  26. package/dist/endpoint/mcp/schemas.js +2 -29
  27. package/dist/endpoint/mcp/schemas.js.map +1 -1
  28. package/dist/endpoint/mcp/tools.d.ts.map +1 -1
  29. package/dist/endpoint/mcp/tools.js +2 -1
  30. package/dist/endpoint/mcp/tools.js.map +1 -1
  31. package/dist/endpoint/mcp/webhook.js +1 -1
  32. package/dist/endpoint/mcp/webhook.js.map +1 -1
  33. package/dist/index.d.ts +3 -1
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +3 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/index.types-check.d.ts +4 -3
  38. package/dist/index.types-check.d.ts.map +1 -1
  39. package/dist/index.types-check.js +2 -2
  40. package/dist/service/{activation.d.ts → activation/index.d.ts} +11 -10
  41. package/dist/service/activation/index.d.ts.map +1 -0
  42. package/dist/service/{activation.js → activation/index.js} +4 -4
  43. package/dist/service/activation/index.js.map +1 -0
  44. package/dist/service/bootstrap.d.ts +50 -0
  45. package/dist/service/bootstrap.d.ts.map +1 -0
  46. package/dist/service/bootstrap.js +6 -0
  47. package/dist/service/bootstrap.js.map +1 -0
  48. package/dist/service/configuration.d.ts +3 -49
  49. package/dist/service/configuration.d.ts.map +1 -1
  50. package/dist/service/configuration.js +4 -6
  51. package/dist/service/configuration.js.map +1 -1
  52. package/dist/service/controller.d.ts +2 -2
  53. package/dist/service/controller.d.ts.map +1 -1
  54. package/dist/service/controller.js +1 -1
  55. package/dist/service/controller.js.map +1 -1
  56. package/dist/service/index.js +1 -1
  57. package/dist/service/index.js.map +1 -1
  58. package/dist/service/lifecycle.d.ts +2 -2
  59. package/dist/service/lifecycle.d.ts.map +1 -1
  60. package/dist/service/lifecycle.js +1 -1
  61. package/dist/service/lifecycle.js.map +1 -1
  62. package/dist/service/management.d.ts +1 -1
  63. package/dist/service/management.d.ts.map +1 -1
  64. package/dist/service/management.js +3 -2
  65. package/dist/service/management.js.map +1 -1
  66. package/dist/service/{registration.d.ts → registration/index.d.ts} +3 -3
  67. package/dist/service/registration/index.d.ts.map +1 -0
  68. package/dist/service/{registration.js → registration/index.js} +2 -2
  69. package/dist/service/registration/index.js.map +1 -0
  70. package/dist/service/supervision.d.ts +2 -2
  71. package/dist/service/supervision.d.ts.map +1 -1
  72. package/dist/service/supervision.js +3 -3
  73. package/dist/service/supervision.js.map +1 -1
  74. package/dist/store/{deliveries.d.ts → queues/deliveries.d.ts} +1 -1
  75. package/dist/store/queues/deliveries.d.ts.map +1 -0
  76. package/dist/store/{deliveries.js → queues/deliveries.js} +3 -3
  77. package/dist/store/queues/deliveries.js.map +1 -0
  78. package/dist/store/{dissemination.d.ts → queues/dissemination.d.ts} +4 -2
  79. package/dist/store/queues/dissemination.d.ts.map +1 -0
  80. package/dist/store/{dissemination.js → queues/dissemination.js} +5 -4
  81. package/dist/store/queues/dissemination.js.map +1 -0
  82. package/dist/store/queues/index.d.ts +5 -0
  83. package/dist/store/queues/index.d.ts.map +1 -0
  84. package/dist/store/queues/index.js +7 -0
  85. package/dist/store/queues/index.js.map +1 -0
  86. package/dist/store/{outbound.d.ts → queues/outbound.d.ts} +1 -1
  87. package/dist/store/queues/outbound.d.ts.map +1 -0
  88. package/dist/store/{outbound.js → queues/outbound.js} +1 -1
  89. package/dist/store/queues/outbound.js.map +1 -0
  90. package/dist/store/reads.d.ts.map +1 -1
  91. package/dist/store/reads.js +1 -3
  92. package/dist/store/reads.js.map +1 -1
  93. package/dist/store/records.d.ts.map +1 -1
  94. package/dist/store/records.js +1 -2
  95. package/dist/store/records.js.map +1 -1
  96. package/dist/store/store.d.ts.map +1 -1
  97. package/dist/store/store.js +2 -4
  98. package/dist/store/store.js.map +1 -1
  99. package/dist/transport/collectives/failures.d.ts +1 -1
  100. package/dist/transport/collectives/failures.d.ts.map +1 -1
  101. package/dist/transport/collectives/forms.d.ts +38 -2
  102. package/dist/transport/collectives/forms.d.ts.map +1 -1
  103. package/dist/transport/collectives/forms.js +51 -20
  104. package/dist/transport/collectives/forms.js.map +1 -1
  105. package/dist/transport/collectives/inbound.d.ts +2 -3
  106. package/dist/transport/collectives/inbound.d.ts.map +1 -1
  107. package/dist/transport/collectives/inbound.js +8 -7
  108. package/dist/transport/collectives/inbound.js.map +1 -1
  109. package/dist/transport/collectives/index.d.ts +1 -1
  110. package/dist/transport/collectives/index.d.ts.map +1 -1
  111. package/dist/transport/collectives/index.js +1 -1
  112. package/dist/transport/collectives/index.js.map +1 -1
  113. package/dist/transport/collectives/message-text.d.ts +5 -2
  114. package/dist/transport/collectives/message-text.d.ts.map +1 -1
  115. package/dist/transport/collectives/message-text.js +20 -42
  116. package/dist/transport/collectives/message-text.js.map +1 -1
  117. package/dist/transport/collectives/operation.d.ts +20 -15
  118. package/dist/transport/collectives/operation.d.ts.map +1 -1
  119. package/dist/transport/collectives/operation.js +53 -60
  120. package/dist/transport/collectives/operation.js.map +1 -1
  121. package/dist/transport/collectives/{form-grammar.d.ts → part/grammar.d.ts} +1 -1
  122. package/dist/transport/collectives/part/grammar.d.ts.map +1 -0
  123. package/dist/transport/collectives/{form-grammar.js → part/grammar.js} +6 -10
  124. package/dist/transport/collectives/part/grammar.js.map +1 -0
  125. package/dist/transport/collectives/{wire.d.ts → part/index.d.ts} +32 -50
  126. package/dist/transport/collectives/part/index.d.ts.map +1 -0
  127. package/dist/transport/collectives/{wire.js → part/index.js} +14 -28
  128. package/dist/transport/collectives/part/index.js.map +1 -0
  129. package/dist/transport/collectives/received-request.d.ts +1 -1
  130. package/dist/transport/collectives/received-request.d.ts.map +1 -1
  131. package/dist/transport/collectives/render.d.ts +40 -0
  132. package/dist/transport/collectives/render.d.ts.map +1 -0
  133. package/dist/transport/collectives/render.js +74 -0
  134. package/dist/transport/collectives/render.js.map +1 -0
  135. package/dist/transport/collectives/request-sends.d.ts +1 -1
  136. package/dist/transport/collectives/request-sends.d.ts.map +1 -1
  137. package/dist/transport/collectives/shared-answers.d.ts +2 -2
  138. package/dist/transport/collectives/shared-answers.d.ts.map +1 -1
  139. package/dist/transport/collectives/validation.d.ts +8 -24
  140. package/dist/transport/collectives/validation.d.ts.map +1 -1
  141. package/dist/transport/collectives/validation.js +167 -16
  142. package/dist/transport/collectives/validation.js.map +1 -1
  143. package/dist/transport/messaging/address.d.ts +2 -32
  144. package/dist/transport/messaging/address.d.ts.map +1 -1
  145. package/dist/transport/messaging/address.js +1 -76
  146. package/dist/transport/messaging/address.js.map +1 -1
  147. package/dist/transport/messaging/certification.d.ts +1 -1
  148. package/dist/transport/messaging/certification.d.ts.map +1 -1
  149. package/dist/transport/messaging/certification.js +10 -7
  150. package/dist/transport/messaging/certification.js.map +1 -1
  151. package/dist/transport/messaging/dissemination.d.ts +1 -1
  152. package/dist/transport/messaging/dissemination.d.ts.map +1 -1
  153. package/dist/transport/messaging/dissemination.js +4 -3
  154. package/dist/transport/messaging/dissemination.js.map +1 -1
  155. package/dist/transport/messaging/evidence.d.ts +1 -1
  156. package/dist/transport/messaging/evidence.d.ts.map +1 -1
  157. package/dist/transport/messaging/index.d.ts +3 -3
  158. package/dist/transport/messaging/index.d.ts.map +1 -1
  159. package/dist/transport/messaging/index.js +15 -4
  160. package/dist/transport/messaging/index.js.map +1 -1
  161. package/dist/transport/messaging/message.d.ts.map +1 -1
  162. package/dist/transport/messaging/message.js +1 -2
  163. package/dist/transport/messaging/message.js.map +1 -1
  164. package/dist/transport/messaging/{recovery/reanchor-empty.d.ts → reanchor/empty.d.ts} +3 -3
  165. package/dist/transport/messaging/reanchor/empty.d.ts.map +1 -0
  166. package/dist/transport/messaging/{recovery/reanchor-empty.js → reanchor/empty.js} +2 -2
  167. package/dist/transport/messaging/reanchor/empty.js.map +1 -0
  168. package/dist/transport/messaging/{recovery/reanchor.d.ts → reanchor/index.d.ts} +2 -2
  169. package/dist/transport/messaging/reanchor/index.d.ts.map +1 -0
  170. package/dist/transport/messaging/{recovery/reanchor.js → reanchor/index.js} +4 -4
  171. package/dist/transport/messaging/reanchor/index.js.map +1 -0
  172. package/dist/transport/messaging/{durability.d.ts → records/index.d.ts} +9 -6
  173. package/dist/transport/messaging/records/index.d.ts.map +1 -0
  174. package/dist/transport/messaging/{durability.js → records/index.js} +9 -6
  175. package/dist/transport/messaging/records/index.js.map +1 -0
  176. package/dist/transport/messaging/recovery/barrier.d.ts +1 -1
  177. package/dist/transport/messaging/recovery/barrier.d.ts.map +1 -1
  178. package/dist/transport/messaging/recovery/evidence.d.ts +1 -1
  179. package/dist/transport/messaging/recovery/evidence.d.ts.map +1 -1
  180. package/dist/transport/messaging/recovery/index.d.ts +1 -1
  181. package/dist/transport/messaging/recovery/index.d.ts.map +1 -1
  182. package/dist/transport/messaging/recovery/index.js +16 -11
  183. package/dist/transport/messaging/recovery/index.js.map +1 -1
  184. package/dist/transport/messaging/recovery/persistence.d.ts +1 -1
  185. package/dist/transport/messaging/recovery/persistence.d.ts.map +1 -1
  186. package/dist/transport/messaging/{recovery/state.d.ts → recovery-session/index.d.ts} +2 -2
  187. package/dist/transport/messaging/recovery-session/index.d.ts.map +1 -0
  188. package/dist/transport/messaging/{recovery/state.js → recovery-session/index.js} +1 -1
  189. package/dist/transport/messaging/recovery-session/index.js.map +1 -0
  190. package/dist/transport/messaging/{types.d.ts → runtime/index.d.ts} +22 -7
  191. package/dist/transport/messaging/runtime/index.d.ts.map +1 -0
  192. package/dist/transport/messaging/{types.js → runtime/index.js} +1 -1
  193. package/dist/transport/messaging/runtime/index.js.map +1 -0
  194. package/dist/transport/messaging/send.d.ts +2 -2
  195. package/dist/transport/messaging/send.d.ts.map +1 -1
  196. package/dist/transport/messaging/send.js.map +1 -1
  197. package/dist/transport/router/types.d.ts +2 -3
  198. package/dist/transport/router/types.d.ts.map +1 -1
  199. package/dist/transport/router/types.js.map +1 -1
  200. package/dist/transport/wire/{canonical.d.ts → encoding/canonical.d.ts} +0 -1
  201. package/dist/transport/wire/encoding/canonical.d.ts.map +1 -0
  202. package/dist/transport/wire/{canonical.js → encoding/canonical.js} +1 -1
  203. package/dist/transport/wire/encoding/canonical.js.map +1 -0
  204. package/dist/transport/wire/{codec.d.ts → encoding/codec.d.ts} +2 -5
  205. package/dist/transport/wire/encoding/codec.d.ts.map +1 -0
  206. package/dist/transport/wire/{codec.js → encoding/codec.js} +4 -5
  207. package/dist/transport/wire/encoding/codec.js.map +1 -0
  208. package/dist/transport/wire/encoding/index.d.ts +4 -0
  209. package/dist/transport/wire/encoding/index.d.ts.map +1 -0
  210. package/dist/transport/wire/encoding/index.js +6 -0
  211. package/dist/transport/wire/encoding/index.js.map +1 -0
  212. package/dist/transport/wire/index.d.ts +2 -3
  213. package/dist/transport/wire/index.d.ts.map +1 -1
  214. package/dist/transport/wire/index.js +2 -3
  215. package/dist/transport/wire/index.js.map +1 -1
  216. package/dist/transport/wire/values.d.ts +37 -2
  217. package/dist/transport/wire/values.d.ts.map +1 -1
  218. package/dist/transport/wire/values.js +78 -1
  219. package/dist/transport/wire/values.js.map +1 -1
  220. package/dist/transport/wire/verification.d.ts +1 -2
  221. package/dist/transport/wire/verification.d.ts.map +1 -1
  222. package/dist/transport/wire/verification.js +1 -2
  223. package/dist/transport/wire/verification.js.map +1 -1
  224. package/package.json +3 -3
  225. package/dist/service/activation.d.ts.map +0 -1
  226. package/dist/service/activation.js.map +0 -1
  227. package/dist/service/registration.d.ts.map +0 -1
  228. package/dist/service/registration.js.map +0 -1
  229. package/dist/store/deliveries.d.ts.map +0 -1
  230. package/dist/store/deliveries.js.map +0 -1
  231. package/dist/store/dissemination.d.ts.map +0 -1
  232. package/dist/store/dissemination.js.map +0 -1
  233. package/dist/store/outbound.d.ts.map +0 -1
  234. package/dist/store/outbound.js.map +0 -1
  235. package/dist/transport/collectives/answer-check.d.ts +0 -22
  236. package/dist/transport/collectives/answer-check.d.ts.map +0 -1
  237. package/dist/transport/collectives/answer-check.js +0 -166
  238. package/dist/transport/collectives/answer-check.js.map +0 -1
  239. package/dist/transport/collectives/form-grammar.d.ts.map +0 -1
  240. package/dist/transport/collectives/form-grammar.js.map +0 -1
  241. package/dist/transport/collectives/wire.d.ts.map +0 -1
  242. package/dist/transport/collectives/wire.js.map +0 -1
  243. package/dist/transport/messaging/durability.d.ts.map +0 -1
  244. package/dist/transport/messaging/durability.js.map +0 -1
  245. package/dist/transport/messaging/recovery/reanchor-empty.d.ts.map +0 -1
  246. package/dist/transport/messaging/recovery/reanchor-empty.js.map +0 -1
  247. package/dist/transport/messaging/recovery/reanchor.d.ts.map +0 -1
  248. package/dist/transport/messaging/recovery/reanchor.js.map +0 -1
  249. package/dist/transport/messaging/recovery/state.d.ts.map +0 -1
  250. package/dist/transport/messaging/recovery/state.js.map +0 -1
  251. package/dist/transport/messaging/types.d.ts.map +0 -1
  252. package/dist/transport/messaging/types.js.map +0 -1
  253. package/dist/transport/wire/canonical.d.ts.map +0 -1
  254. package/dist/transport/wire/canonical.js.map +0 -1
  255. package/dist/transport/wire/codec.d.ts.map +0 -1
  256. package/dist/transport/wire/codec.js.map +0 -1
@@ -1,8 +1,7 @@
1
1
  /** @file The items an endpoint delivers to its host: messages and collective requests, results and failures. */
2
2
  import { Schema } from "effect";
3
- import { AgentAddress, MessageAddressInput } from "../messaging/address.js";
4
3
  import { InboundMessage } from "../messaging/message.js";
5
- import { exactStruct, PostId, wellFormedString } from "../wire/values.js";
4
+ import { AgentAddress, exactStruct, MessageAddressInput, PostId, wellFormedString, } from "../wire/values.js";
6
5
  import { AnswerContent, CollectiveId, RequestedSchema } from "./forms.js";
7
6
  /* eslint-disable @typescript-eslint/naming-convention, @typescript-eslint/no-redeclare -- Effect Schemas share their domain names with the nominal values they decode. */
8
7
  /**
@@ -15,6 +14,8 @@ const multicastItem = exactStruct({
15
14
  });
16
15
  /** Absolute epoch milliseconds; endpoints assume zero clock skew. */
17
16
  const epochMillis = Schema.Number.pipe(Schema.int(), Schema.positive());
17
+ /** Which collecting operation an item belongs to. */
18
+ const collectingOp = Schema.Literal("gather", "all_gather");
18
19
  /**
19
20
  * A question another agent asked this one. `postId` is the certified request
20
21
  * post's and `to` the conversation it arrived in: the requester's `agent:`
@@ -23,6 +24,7 @@ const epochMillis = Schema.Number.pipe(Schema.int(), Schema.positive());
23
24
  */
24
25
  const collectiveRequestItem = exactStruct({
25
26
  kind: Schema.Literal("collectiveRequest"),
27
+ op: collectingOp,
26
28
  id: CollectiveId,
27
29
  postId: PostId,
28
30
  from: AgentAddress,
@@ -41,18 +43,17 @@ const memberOutcome = Schema.Union(exactStruct({ kind: Schema.Literal("answered"
41
43
  /**
42
44
  * The result of a gather this endpoint started, or of an all_gather this
43
45
  * endpoint started or was asked: exactly one outcome per member, in member
44
- * order. `to` is the address the operation named. An all_gather's result
45
- * names its certified close post in `closePostId`; every member's result is
46
- * built from exactly the answers that close lists, so each endpoint's result
47
- * is the same.
46
+ * order. `to` is the address the operation named. Every member's all_gather
47
+ * result is built from exactly the answers the requester's close lists, so
48
+ * each endpoint's result is the same.
48
49
  */
49
50
  const collectiveResultItem = exactStruct({
50
51
  kind: Schema.Literal("collectiveResult"),
52
+ op: collectingOp,
51
53
  id: CollectiveId,
52
54
  to: MessageAddressInput,
53
55
  question: wellFormedString,
54
56
  outcomes: Schema.NonEmptyArray(exactStruct({ member: AgentAddress, outcome: memberOutcome })),
55
- closePostId: Schema.optionalWith(PostId, { exact: true }),
56
57
  });
57
58
  /**
58
59
  * A collective send that failed after the host's tool had returned, or an
@@ -1 +1 @@
1
- {"version":3,"file":"inbound.js","sourceRoot":"","sources":["../../../src/transport/collectives/inbound.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAEhH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE1E,0KAA0K;AAE1K;;;GAGG;AACH,MAAM,aAAa,GAAG,WAAW,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC;IACjC,OAAO,EAAE,cAAc;CACxB,CAAC,CAAC;AAEH,qEAAqE;AACrE,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE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EAAE,YAAY;IAChB,EAAE,EAAE,mBAAmB;IACvB,KAAK,EAAE,MAAM,CAAC,MAAM;CACrB,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CACrC,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,CACpB,CAAC,WAAW,CAAC;IACZ,UAAU,EAAE,aAAa;CAC1B,CAAC,CAAC;AAIH,0JAA0J"}
@@ -6,5 +6,5 @@ export { CollectiveEmitError } from "./forms.js";
6
6
  /** The items those operations emit. */
7
7
  export type { InboundItem } from "./inbound.js";
8
8
  /** The collective part carried in a post's content. */
9
- export { collectiveIdOf, readCollectiveValue } from "./wire.js";
9
+ export { collectiveIdOf, readCollectiveValue } from "./part/index.js";
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transport/collectives/index.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAEnE,8DAA8D;AAC9D,OAAO,EACL,KAAK,oBAAoB,EACzB,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AACxB,6EAA6E;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,uCAAuC;AACvC,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,uDAAuD;AACvD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transport/collectives/index.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAEnE,8DAA8D;AAC9D,OAAO,EACL,KAAK,oBAAoB,EACzB,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AACxB,6EAA6E;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,uCAAuC;AACvC,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,uDAAuD;AACvD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -4,5 +4,5 @@ export { makeCollectiveOperations, } from "./operation.js";
4
4
  /** The failure an emit port returns when the service cannot keep an item. */
5
5
  export { CollectiveEmitError } from "./forms.js";
6
6
  /** The collective part carried in a post's content. */
7
- export { collectiveIdOf, readCollectiveValue } from "./wire.js";
7
+ export { collectiveIdOf, readCollectiveValue } from "./part/index.js";
8
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transport/collectives/index.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAEnE,8DAA8D;AAC9D,OAAO,EAEL,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AACxB,6EAA6E;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGjD,uDAAuD;AACvD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transport/collectives/index.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAEnE,8DAA8D;AAC9D,OAAO,EAEL,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AACxB,6EAA6E;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGjD,uDAAuD;AACvD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -20,10 +20,13 @@
20
20
  * the operation and the error names the field to fix.
21
21
  */
22
22
  import { Either } from "effect";
23
- import type { MessageAddressInput } from "../messaging/address.js";
23
+ import { type MessageAddressInput } from "../wire/values.js";
24
24
  import { SendInput } from "./forms.js";
25
+ /** The operations that ask a question, in the order their keys are read. */
26
+ declare const COLLECTING_OPERATIONS: readonly ["gather", "all_gather"];
27
+ type CollectingOperation = (typeof COLLECTING_OPERATIONS)[number];
25
28
  /** Which operation a refused text stated. */
26
- type StatedOperation = "message" | "gather" | "all_gather" | "answer";
29
+ type StatedOperation = "message" | CollectingOperation | "answer";
27
30
  declare const MessageTextError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
28
31
  readonly _tag: "MessageTextError";
29
32
  } & Readonly<A>;
@@ -1 +1 @@
1
- {"version":3,"file":"message-text.d.ts","sourceRoot":"","sources":["../../../src/transport/collectives/message-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAQ,MAAM,EAA0C,MAAM,QAAQ,CAAC;AAC9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAKL,SAAS,EACV,MAAM,YAAY,CAAC;AAIpB,6CAA6C;AAC7C,KAAK,eAAe,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,GAAG,QAAQ,CAAC;;;;AAEtE;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,sBAAqC;IACzE,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;IACA,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF;AAoCD;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,OACvB,mBAAmB,QACjB,MAAM,KACX,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,gBAAgB,CAKxC,CAAC"}
1
+ {"version":3,"file":"message-text.d.ts","sourceRoot":"","sources":["../../../src/transport/collectives/message-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAQ,MAAM,EAA6B,MAAM,QAAQ,CAAC;AACjE,OAAO,EAAe,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAOL,SAAS,EACV,MAAM,YAAY,CAAC;AAIpB,4EAA4E;AAC5E,QAAA,MAAM,qBAAqB,YAAI,QAAQ,EAAE,YAAY,CAAU,CAAC;AAEhE,KAAK,mBAAmB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElE,6CAA6C;AAC7C,KAAK,eAAe,GAAG,SAAS,GAAG,mBAAmB,GAAG,QAAQ,CAAC;;;;AAElE;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,sBAAqC;IACzE,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;IACA,IAAa,OAAO,IAAI,MAAM,CAG7B;CACF;AA0BD;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,OACvB,mBAAmB,QACjB,MAAM,KACX,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,gBAAgB,CAKxC,CAAC"}
@@ -19,9 +19,12 @@
19
19
  * fails validation is refused, never sent as text, because the model meant
20
20
  * the operation and the error names the field to fix.
21
21
  */
22
- import { Data, Either, Option, ParseResult, Predicate, Schema } from "effect";
22
+ import { Data, Either, Option, Predicate, Schema } from "effect";
23
23
  import { exactStruct } from "../wire/values.js";
24
- import { AnswerContent, DeadlineSeconds, RequestedSchema, SendInput, } from "./forms.js";
24
+ import { AcceptResponse, DeadlineSeconds, DeclineResponse, describeIssues, RequestedSchema, SendInput, } from "./forms.js";
25
+ /* eslint-disable @typescript-eslint/naming-convention -- Effect Schemas are named for the text shapes they decode. */
26
+ /** The operations that ask a question, in the order their keys are read. */
27
+ const COLLECTING_OPERATIONS = ["gather", "all_gather"];
25
28
  /**
26
29
  * A message text states an operation it does not validly carry, or is plain
27
30
  * text that is not well-formed Unicode. The message names each failing field
@@ -29,26 +32,19 @@ import { AnswerContent, DeadlineSeconds, RequestedSchema, SendInput, } from "./f
29
32
  */
30
33
  export class MessageTextError extends Data.TaggedError("MessageTextError") {
31
34
  get message() {
32
- return `${this.operation} not sent: ${this.detail}`;
35
+ const action = this.operation === "answer" ? "reply" : "send";
36
+ return `${action} failed: invalid ${this.operation}: ${this.detail}`;
33
37
  }
34
38
  }
35
- const GatherText = exactStruct({
36
- gather: Schema.String,
37
- deadline: DeadlineSeconds,
38
- requestedSchema: RequestedSchema,
39
- });
40
- const AllGatherText = exactStruct({
41
- all_gather: Schema.String,
39
+ /**
40
+ * A gather or all_gather, its question under the operation's own key, read
41
+ * as `question` so both share one decode.
42
+ */
43
+ const collectingText = (op) => exactStruct({
44
+ question: Schema.propertySignature(Schema.String).pipe(Schema.fromKey(op)),
42
45
  deadline: DeadlineSeconds,
43
46
  requestedSchema: RequestedSchema,
44
47
  });
45
- const AcceptText = exactStruct({
46
- action: Schema.Literal("accept"),
47
- content: AnswerContent,
48
- });
49
- const DeclineText = exactStruct({
50
- action: Schema.Literal("decline"),
51
- });
52
48
  /** The `action` key alone, so an unknown action is named as that field. */
53
49
  const AnswerAction = Schema.Struct({
54
50
  action: Schema.Literal("accept", "decline"),
@@ -74,30 +70,21 @@ export const parseMessageText = (to, text) => Option.match(jsonObject(text), {
74
70
  * none of `gather`, `all_gather` and `action` and so is plain text.
75
71
  */
76
72
  function statedOperation(to, value) {
77
- if (Object.hasOwn(value, "gather")) {
78
- return decodeText("gather", GatherText, value).pipe(Either.flatMap((stated) => sendInput("gather", {
73
+ const op = COLLECTING_OPERATIONS.find((key) => Object.hasOwn(value, key));
74
+ if (op !== undefined) {
75
+ return decodeText(op, collectingText(op), value).pipe(Either.flatMap(({ question, ...collective }) => sendInput(op, {
79
76
  to,
80
- text: stated.gather,
81
- collective: { ...collecting(stated), op: "gather" },
82
- })));
83
- }
84
- if (Object.hasOwn(value, "all_gather")) {
85
- return decodeText("all_gather", AllGatherText, value).pipe(Either.flatMap((stated) => sendInput("all_gather", {
86
- to,
87
- text: stated.all_gather,
88
- collective: { ...collecting(stated), op: "all_gather" },
77
+ text: question,
78
+ collective: { ...collective, op },
89
79
  })));
90
80
  }
91
81
  return Object.hasOwn(value, "action") ? answer(to, value) : undefined;
92
82
  }
93
- function collecting(stated) {
94
- return { deadline: stated.deadline, requestedSchema: stated.requestedSchema };
95
- }
96
83
  /** An answer: `action` decides which shape the rest must have. */
97
84
  function answer(to, value) {
98
85
  return decodeText("answer", AnswerAction, value).pipe(Either.flatMap(({ action }) => action === "accept"
99
- ? decodeText("answer", AcceptText, value)
100
- : decodeText("answer", DeclineText, value)), Either.flatMap((collectiveResponse) => sendInput("answer", { to, collectiveResponse })));
86
+ ? decodeText("answer", AcceptResponse, value)
87
+ : decodeText("answer", DeclineResponse, value)), Either.flatMap((collectiveResponse) => sendInput("answer", { to, collectiveResponse })));
101
88
  }
102
89
  function sendInput(operation, value) {
103
90
  return decodeText(operation, SendInput, value);
@@ -105,14 +92,5 @@ function sendInput(operation, value) {
105
92
  function decodeText(operation, schema, value) {
106
93
  return Schema.decodeUnknownEither(schema, { errors: "all" })(value).pipe(Either.mapLeft((error) => new MessageTextError({ operation, detail: describeIssues(error) })));
107
94
  }
108
- /**
109
- * One line per issue, each led by its field path, such as
110
- * `requestedSchema.type: Expected "object", actual "obj"`.
111
- */
112
- function describeIssues(error) {
113
- return ParseResult.ArrayFormatter.formatErrorSync(error)
114
- .map(({ path, message }) => path.length === 0 ? message : `${path.map(String).join(".")}: ${message}`)
115
- .join("; ");
116
- }
117
95
  /* eslint-enable @typescript-eslint/naming-convention -- Restore the package naming rules after the text Schemas. */
118
96
  //# sourceMappingURL=message-text.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"message-text.js","sourceRoot":"","sources":["../../../src/transport/collectives/message-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9E,OAAO,EAAE,WAAW,EAAE,MAAM,mBA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AAED,SAAS,SAAS,CAChB,SAA0B,EAC1B,KAAc;IAEd,OAAO,UAAU,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;AACjD,CAAC;AAED,SAAS,UAAU,CACjB,SAA0B,EAC1B,MAA2B,EAC3B,KAAc;IAEd,OAAO,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CACtE,MAAM,CAAC,OAAO,CACZ,CAAC,KAAK,EAAE,EAAE,CACR,IAAI,gBAAgB,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,CACrE,CACF,CAAC;AACJ,CAAC;AAED,oHAAoH"}
@@ -19,13 +19,14 @@
19
19
  * participant ME as Member endpoint
20
20
  * participant MM as Member host
21
21
  * RM->>RE: send gather to, question, deadline, schema
22
- * RE->>RE: validate schema, mint id&lt;br>deadline = now + duration
23
- * RE->>ME: one request post per member
24
- * alt no request post is accepted
25
- * RE-->>RM: error naming each unreachable member
26
- * else some request post accepted
22
+ * RE->>RE: validate schema, resolve every member&lt;br>refuse an address error before any post
23
+ * RE->>RE: mint id&lt;br>deadline = now + duration
24
+ * RE->>ME: one request post in each member's direct conversation
25
+ * alt every request post is refused
26
+ * RE-->>RM: error naming each member and its reason
27
+ * else otherwise, after at most 20 s
27
28
  * RE-->>RM: operation id
28
- * RE->>RE: record each refused or uncertified member as no-answer
29
+ * RE->>RE: a refused member is no-answer&lt;br>a pending one settles later, no-answer at the deadline
29
30
  * end
30
31
  * ME->>MM: collectiveRequest item
31
32
  * MM->>ME: send collectiveResponse to the requester, action, content
@@ -48,9 +49,10 @@
48
49
  * participant ME as Member endpoints
49
50
  * participant MM as Member hosts
50
51
  * RM->>RE: send all_gather to group, question, deadline, schema
51
- * RE->>ME: one request post to the group
52
+ * RE->>RE: validate schema, resolve every member&lt;br>refuse an address error before any post
53
+ * RE->>ME: one request post in the group conversation
52
54
  * alt the group post is refused or not certified in time
53
- * RE-->>RM: error naming each unreachable member
55
+ * RE-->>RM: error naming every member with the post's reason
54
56
  * else request post certified
55
57
  * RE-->>RM: operation id
56
58
  * end
@@ -61,18 +63,21 @@
61
63
  * ME->>ME: peer response posts, consumed and recorded by record hash
62
64
  * Note over RE: complete when every member has an outcome&lt;br>or at the deadline
63
65
  * RE->>ME: close post listing the counted answers' record hashes
64
- * RE->>RM: collectiveResult item once the close is certified
65
- * ME->>ME: build the result from exactly the listed answers
66
- * ME->>MM: collectiveResult item, the same outcomes
66
+ * alt the close is not certified
67
+ * RE->>RM: operationFailed item, and members get no result
68
+ * else close certified
69
+ * RE->>RM: collectiveResult item
70
+ * ME->>ME: build the result from exactly the listed answers
71
+ * ME->>MM: collectiveResult item, the same outcomes
72
+ * end
67
73
  * ```
68
74
  */
69
75
  import { Duration, Effect, Option, type Scope } from "effect";
70
76
  import type { EngineSendInput, EngineSentPost } from "../messaging/index.js";
71
77
  import type { InboundMessage } from "../messaging/message.js";
72
- import type { RecordHash } from "../wire/index.js";
73
78
  import type { InboundItem } from "./inbound.js";
74
- import { AgentAddress } from "../messaging/address.js";
75
79
  import { SendError } from "../messaging/errors.js";
80
+ import { AgentAddress, type RecordHash } from "../wire/index.js";
76
81
  import { type CollectiveSendOutcome } from "./failures.js";
77
82
  import { type CollectiveEmitError, CollectiveError, type FailureDelivery, type SendInput } from "./forms.js";
78
83
  /** What the collective layer needs from the daemon around it. */
@@ -80,8 +85,8 @@ export interface CollectivePorts {
80
85
  /** The local agent: a group gather or all_gather asks every member but this one. */
81
86
  readonly self: AgentAddress;
82
87
  /**
83
- * Resolve one member's Registry card without sending. A refused all_gather
84
- * group post names only the members that fail this lookup.
88
+ * Resolve one member's Registry card without sending, so a collecting
89
+ * operation refuses an address error before any post.
85
90
  */
86
91
  readonly lookupMember: (member: AgentAddress) => Effect.Effect<void, SendError>;
87
92
  /** Certify one post and complete once it is stored locally. */
@@ -1 +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AE,SAAS,GAAG,eAAe,CAAC,CAAC;IACvE;;;;;;;OAOG;IACH,QAAQ,CAAC,QAAQ,EAAE,CACjB,IAAI,EAAE,aAAa,KAChB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,mBAAmB,CAAC,CAAC;CACrE;AA2DD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,UAC5B,eAAe,KACrB,oBAiBF,CAAC"}
@@ -19,13 +19,14 @@
19
19
  * participant ME as Member endpoint
20
20
  * participant MM as Member host
21
21
  * RM->>RE: send gather to, question, deadline, schema
22
- * RE->>RE: validate schema, mint id&lt;br>deadline = now + duration
23
- * RE->>ME: one request post per member
24
- * alt no request post is accepted
25
- * RE-->>RM: error naming each unreachable member
26
- * else some request post accepted
22
+ * RE->>RE: validate schema, resolve every member&lt;br>refuse an address error before any post
23
+ * RE->>RE: mint id&lt;br>deadline = now + duration
24
+ * RE->>ME: one request post in each member's direct conversation
25
+ * alt every request post is refused
26
+ * RE-->>RM: error naming each member and its reason
27
+ * else otherwise, after at most 20 s
27
28
  * RE-->>RM: operation id
28
- * RE->>RE: record each refused or uncertified member as no-answer
29
+ * RE->>RE: a refused member is no-answer&lt;br>a pending one settles later, no-answer at the deadline
29
30
  * end
30
31
  * ME->>MM: collectiveRequest item
31
32
  * MM->>ME: send collectiveResponse to the requester, action, content
@@ -48,9 +49,10 @@
48
49
  * participant ME as Member endpoints
49
50
  * participant MM as Member hosts
50
51
  * RM->>RE: send all_gather to group, question, deadline, schema
51
- * RE->>ME: one request post to the group
52
+ * RE->>RE: validate schema, resolve every member&lt;br>refuse an address error before any post
53
+ * RE->>ME: one request post in the group conversation
52
54
  * alt the group post is refused or not certified in time
53
- * RE-->>RM: error naming each unreachable member
55
+ * RE-->>RM: error naming every member with the post's reason
54
56
  * else request post certified
55
57
  * RE-->>RM: operation id
56
58
  * end
@@ -61,21 +63,26 @@
61
63
  * ME->>ME: peer response posts, consumed and recorded by record hash
62
64
  * Note over RE: complete when every member has an outcome&lt;br>or at the deadline
63
65
  * RE->>ME: close post listing the counted answers' record hashes
64
- * RE->>RM: collectiveResult item once the close is certified
65
- * ME->>ME: build the result from exactly the listed answers
66
- * ME->>MM: collectiveResult item, the same outcomes
66
+ * alt the close is not certified
67
+ * RE->>RM: operationFailed item, and members get no result
68
+ * else close certified
69
+ * RE->>RM: collectiveResult item
70
+ * ME->>ME: build the result from exactly the listed answers
71
+ * ME->>MM: collectiveResult item, the same outcomes
72
+ * end
67
73
  * ```
68
74
  */
69
- import { Clock, Duration, Effect, Array as EffectArray, Fiber, Option, ParseResult, Schema, } from "effect";
70
- import { AgentAddress, canonicalMessageAddress, } from "../messaging/address.js";
75
+ import { Clock, Duration, Effect, Array as EffectArray, Fiber, Option, Schema, } from "effect";
76
+ import { canonicalMessageAddress } from "../messaging/address.js";
71
77
  import { SendError } from "../messaging/errors.js";
78
+ import { AgentAddress, } from "../wire/index.js";
72
79
  import { emitFailureAsSendError, refusedAs, reportFailure, } from "./failures.js";
73
- import { CollectiveError, MAXIMUM_DEADLINE_SECONDS, RequestedSchema, } from "./forms.js";
80
+ import { closeFailureText, CollectiveError, describeIssues, MAXIMUM_DEADLINE_SECONDS, } from "./forms.js";
81
+ import { collectiveIdOf, encodeCollectiveContent, FormModeSchema, mintCollectiveId, readCollectiveValue, withoutCollectivePart, } from "./part/index.js";
74
82
  import { matchOpenRequest, } from "./received-request.js";
75
83
  import { isAddressRefusal, lookupRefusals, requestsSoFar, } from "./request-sends.js";
76
84
  import { keepFirstAnswer, listedAnswers, memberOutcomes, } from "./shared-answers.js";
77
85
  import { outcomeOfResponse, validateAnswer } from "./validation.js";
78
- import { collectiveIdOf, encodeCollectiveContent, FormModeSchema, mintCollectiveId, readCollectiveValue, withoutCollectivePart, } from "./wire.js";
79
86
  /**
80
87
  * How long a collecting operation's send waits for its request posts before
81
88
  * returning. A gather's request still uncertified then is left running: its
@@ -108,7 +115,6 @@ const RECEIVED_DEADLINE_ALLOWANCE = Duration.hours(1);
108
115
  /** The furthest past `now` a received request's deadline may lie. */
109
116
  const RECEIVED_DEADLINE_HORIZON = Duration.toMillis(Duration.sum(Duration.seconds(MAXIMUM_DEADLINE_SECONDS), RECEIVED_DEADLINE_ALLOWANCE));
110
117
  const decodeAgentAddress = Schema.decodeUnknownOption(AgentAddress);
111
- const decodeRequestedSchema = Schema.decodeUnknownOption(RequestedSchema);
112
118
  const contentInvalid = () => new SendError({ reason: "content-invalid" });
113
119
  const collectiveFailure = (id, failure) => new CollectiveError({ id, failure });
114
120
  /**
@@ -186,11 +192,7 @@ function gatherAddress(to, self, op) {
186
192
  function formModeSchema(id, requestedSchema) {
187
193
  return Schema.decodeUnknown(FormModeSchema)(requestedSchema).pipe(Effect.mapError((error) => collectiveFailure(id, {
188
194
  kind: "schema-invalid",
189
- detail: ParseResult.ArrayFormatter.formatErrorSync(error)
190
- .map(({ path, message }) => path.length === 0
191
- ? message
192
- : `${path.map(String).join(".")}: ${message}`)
193
- .join("; "),
195
+ detail: describeIssues(error),
194
196
  })));
195
197
  }
196
198
  /**
@@ -332,8 +334,11 @@ function updateGather(state, id, change) {
332
334
  * Send an all_gather's one request post to the group and wait for it, never
333
335
  * past the deadline. A refused post, or one still uncertified when the wait
334
336
  * ends, abandons the all_gather: the group's GENESIS needs every member. The
335
- * operation is dropped before its unreachable members are looked up, so a
336
- * deadline that passes during the lookups cannot close it.
337
+ * deadline timer is forked just before the wait starts, so it can complete
338
+ * the all_gather first; its result then stands and the send succeeds, so an
339
+ * operation ends in exactly one refusal or one result. A group post succeeds
340
+ * or fails as a whole, so the refusal names every member with its reason;
341
+ * members whose address resolution fails were refused before the post.
337
342
  */
338
343
  function sendGroupRequest(state, prepared) {
339
344
  return state.ports
@@ -341,24 +346,12 @@ function sendGroupRequest(state, prepared) {
341
346
  .pipe(Effect.timeoutFail({
342
347
  duration: requestWait(state, prepared),
343
348
  onTimeout: () => new SendError({ reason: "certification-unavailable" }),
344
- }), Effect.map((post) => [post.postId]), Effect.catchAll((error) => forgetGather(state, prepared.id).pipe(Effect.zipRight(unreachableMembers(state, prepared.open.members, error.reason)), Effect.flatMap((members) => Effect.fail(collectiveFailure(prepared.id, {
345
- kind: "members-unreachable",
346
- members,
347
- }))))));
348
- }
349
- /**
350
- * The members to name for a refused group post. A group post succeeds or
351
- * fails as a whole, so each member is looked up on its own: the members whose
352
- * lookup fails are named with their own reason, and when every lookup
353
- * succeeds each member is named with the group post's reason.
354
- */
355
- function unreachableMembers(state, members, groupReason) {
356
- return lookupRefusals(members, state.ports.lookupMember).pipe(Effect.map(([first, ...rest]) => first === undefined
357
- ? EffectArray.map(members, (member) => ({
358
- member,
359
- reason: groupReason,
360
- }))
361
- : [first, ...rest]));
349
+ }), Effect.map((post) => [post.postId]), Effect.catchAll((error) => Effect.suspend(() => state.gathers.has(prepared.id)
350
+ ? forgetGather(state, prepared.id).pipe(Effect.zipRight(Effect.fail(collectiveFailure(prepared.id, {
351
+ kind: "members-unreachable",
352
+ members: EffectArray.map(prepared.open.members, (member) => ({ member, reason: error.reason })),
353
+ }))))
354
+ : Effect.succeed([]))));
362
355
  }
363
356
  /** How long a send waits for request posts: the bound, never past the deadline. */
364
357
  function requestWait(state, prepared) {
@@ -388,6 +381,7 @@ function completeGather(state, id) {
388
381
  state.gathers.delete(id);
389
382
  const result = {
390
383
  kind: "collectiveResult",
384
+ op: open.op,
391
385
  id,
392
386
  to: open.to,
393
387
  question: open.question,
@@ -407,8 +401,7 @@ function completeGather(state, id) {
407
401
  }
408
402
  /**
409
403
  * Post an all_gather's close, listing the certified record of every answer
410
- * its result counts, and emit the result once the close is certified, naming
411
- * the close post. A close that cannot be certified ends the operation as an
404
+ * its result counts, and emit the result once the close is certified. A close that cannot be certified ends the operation as an
412
405
  * `operationFailed` item, since members then have no result to agree on.
413
406
  */
414
407
  function closeAllGather(state, open, result) {
@@ -422,9 +415,9 @@ function closeAllGather(state, open, result) {
422
415
  kind: "operationFailed",
423
416
  id: result.id,
424
417
  to: open.to,
425
- error: `all_gather ${result.id} failed: its close was not certified (${error.reason})`,
418
+ error: closeFailureText(error.reason),
426
419
  }),
427
- onSuccess: (post) => state.ports.emit({ ...result, closePostId: post.postId }),
420
+ onSuccess: () => state.ports.emit(result),
428
421
  }));
429
422
  }
430
423
  /**
@@ -465,10 +458,7 @@ function openRequest(state, to) {
465
458
  */
466
459
  function responseContent(request, response) {
467
460
  const validated = response.action === "accept"
468
- ? validateAnswer(request.requestedSchema, response.content).pipe(Effect.mapError((error) => collectiveFailure(response.id, {
469
- kind: "answer-invalid",
470
- fields: error.failures,
471
- })))
461
+ ? validateAnswer(request.requestedSchema, response.content).pipe(Effect.mapError((fields) => collectiveFailure(response.id, { kind: "answer-invalid", fields })))
472
462
  : Effect.void;
473
463
  return validated.pipe(Effect.zipRight(encodeCollectiveContent(response).pipe(Effect.mapError(contentInvalid))));
474
464
  }
@@ -627,16 +617,19 @@ function requestItem(state, message, value) {
627
617
  forgetExpiredRequests(state, now);
628
618
  state.requests.set(value.id, received.value);
629
619
  }
630
- return decodeRequestedSchema(value.requestedSchema).pipe(Option.filter(() => now < value.deadlineAt), Option.map((requestedSchema) => ({
631
- kind: "collectiveRequest",
632
- id: value.id,
633
- postId: message.postId,
634
- from: message.sender,
635
- to: received.value.to,
636
- question: questionText(message.content),
637
- requestedSchema,
638
- deadlineAt: value.deadlineAt,
639
- })));
620
+ return now < value.deadlineAt
621
+ ? Option.some({
622
+ kind: "collectiveRequest",
623
+ op: value.op,
624
+ id: value.id,
625
+ postId: message.postId,
626
+ from: message.sender,
627
+ to: received.value.to,
628
+ question: questionText(message.content),
629
+ requestedSchema: value.requestedSchema,
630
+ deadlineAt: value.deadlineAt,
631
+ })
632
+ : Option.none();
640
633
  }));
641
634
  }
642
635
  /** Forget every request past the time `retainedUntil` gives it. */
@@ -766,11 +759,11 @@ function applyClose(state, asked, close) {
766
759
  }
767
760
  return Effect.forEach(answers, (answer) => outcomeOfResponse(request.requestedSchema, answer.response).pipe(Effect.map((outcome) => [answer.member, outcome])), { concurrency: 1 }).pipe(Effect.flatMap((outcomes) => state.ports.emit({
768
761
  kind: "collectiveResult",
762
+ op: "all_gather",
769
763
  id,
770
764
  to: request.to,
771
765
  question: shared.question,
772
766
  outcomes: memberOutcomes(shared.members, new Map(outcomes)),
773
- closePostId: close.postId,
774
767
  })));
775
768
  }
776
769
  //# sourceMappingURL=operation.js.map