@moltzap/client 2026.519.0 → 2026.519.2

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 (66) hide show
  1. package/dist/index.d.ts +2 -2
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +4 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/notification/__tests__/filter-equivalence.test.d.ts +2 -0
  6. package/dist/notification/__tests__/filter-equivalence.test.d.ts.map +1 -0
  7. package/dist/notification/__tests__/filter-equivalence.test.js +123 -0
  8. package/dist/notification/__tests__/filter-equivalence.test.js.map +1 -0
  9. package/dist/notification/__tests__/snapshot-semantics.test.d.ts +2 -0
  10. package/dist/notification/__tests__/snapshot-semantics.test.d.ts.map +1 -0
  11. package/dist/notification/__tests__/snapshot-semantics.test.js +261 -0
  12. package/dist/notification/__tests__/snapshot-semantics.test.js.map +1 -0
  13. package/dist/notification/__tests__/snapshot-semantics.types-check.d.ts +3 -0
  14. package/dist/notification/__tests__/snapshot-semantics.types-check.d.ts.map +1 -0
  15. package/dist/notification/__tests__/snapshot-semantics.types-check.js +62 -0
  16. package/dist/notification/__tests__/snapshot-semantics.types-check.js.map +1 -0
  17. package/dist/notification/errors.d.ts +27 -0
  18. package/dist/notification/errors.d.ts.map +1 -0
  19. package/dist/notification/errors.js +24 -0
  20. package/dist/notification/errors.js.map +1 -0
  21. package/dist/notification/stream.d.ts +84 -0
  22. package/dist/notification/stream.d.ts.map +1 -0
  23. package/dist/notification/stream.js +106 -0
  24. package/dist/notification/stream.js.map +1 -0
  25. package/dist/runtime/errors.d.ts +0 -13
  26. package/dist/runtime/errors.d.ts.map +1 -1
  27. package/dist/runtime/errors.js +0 -10
  28. package/dist/runtime/errors.js.map +1 -1
  29. package/dist/runtime/index.d.ts +3 -4
  30. package/dist/runtime/index.d.ts.map +1 -1
  31. package/dist/runtime/index.js +3 -3
  32. package/dist/runtime/service-teardown.d.ts +5 -0
  33. package/dist/runtime/service-teardown.d.ts.map +1 -0
  34. package/dist/runtime/service-teardown.js +36 -0
  35. package/dist/runtime/service-teardown.js.map +1 -0
  36. package/dist/runtime/service-teardown.test.d.ts +2 -0
  37. package/dist/runtime/service-teardown.test.d.ts.map +1 -0
  38. package/dist/runtime/service-teardown.test.js +80 -0
  39. package/dist/runtime/service-teardown.test.js.map +1 -0
  40. package/dist/runtime/subscribers.d.ts +74 -136
  41. package/dist/runtime/subscribers.d.ts.map +1 -1
  42. package/dist/runtime/subscribers.js +187 -93
  43. package/dist/runtime/subscribers.js.map +1 -1
  44. package/dist/service.d.ts +10 -0
  45. package/dist/service.d.ts.map +1 -1
  46. package/dist/service.js +45 -12
  47. package/dist/service.js.map +1 -1
  48. package/dist/test-utils/conformance-adapter.d.ts +6 -16
  49. package/dist/test-utils/conformance-adapter.d.ts.map +1 -1
  50. package/dist/test-utils/conformance-adapter.js +100 -59
  51. package/dist/test-utils/conformance-adapter.js.map +1 -1
  52. package/dist/ws-client-test-support.d.ts +13 -10
  53. package/dist/ws-client-test-support.d.ts.map +1 -1
  54. package/dist/ws-client-test-support.js +44 -11
  55. package/dist/ws-client-test-support.js.map +1 -1
  56. package/dist/ws-client.d.ts +91 -104
  57. package/dist/ws-client.d.ts.map +1 -1
  58. package/dist/ws-client.js +78 -244
  59. package/dist/ws-client.js.map +1 -1
  60. package/dist/ws-client.test.js +33 -36
  61. package/dist/ws-client.test.js.map +1 -1
  62. package/package.json +3 -3
  63. package/dist/runtime/subscribers.test.d.ts +0 -2
  64. package/dist/runtime/subscribers.test.d.ts.map +0 -1
  65. package/dist/runtime/subscribers.test.js +0 -193
  66. package/dist/runtime/subscribers.test.js.map +0 -1
@@ -1,166 +1,104 @@
1
1
  /**
2
2
  * Per-subscription notification registry for `MoltZapWsClient`.
3
3
  *
4
- * Responsibility: own the list of live `subscribe()` handles and fan each
5
- * inbound JSON-RPC notification out to every subscription whose filter matches.
6
- * Implements spec #222 §5.3 (C4 + the `RealClientEventSubscriber.subscribe`
7
- * filter stub). Lives as an internal collaborator of `MoltZapWsClient`;
8
- * the public types (`SubscriptionFilter`, `NotificationSubscription`,
9
- * `SubscriptionId`) re-export from the package barrel.
4
+ * Responsibility: own the list of live subscriptions and fan each inbound
5
+ * JSON-RPC notification out to every subscription whose definition (and
6
+ * optional typed refinement predicate) matches. Implements spec #596
7
+ * (notification consumption consolidation) via the AD1 path-(a) Stream.async
8
+ * design (architect plan §3, §5.5).
10
9
  *
11
- * Dispatch ordering (Invariant 6 — notifications delivered in arrival order):
12
- * 1. Inbound frames are handed to the registry in arrival order.
13
- * 2. Within a single frame, subscriptions are notified in registration
14
- * order.
15
- * 3. There is no separate legacy `onNotification` fanout — spec #222 OQ-4 is
16
- * resolved by DELETING `MoltZapWsClientOptions.onNotification`. Callers
17
- * that want every notification register `subscribe({}, handler)` after
18
- * construction and before `connect()`.
10
+ * Storage shape (post-Spec B):
11
+ * - Subscriptions are records of typed `{onFrame, onClose}` callbacks
12
+ * (NOT queues / Take items / Stream.fromQueue). `notification/stream.ts`
13
+ * owns Stream construction via `Stream.async`; this module owns the
14
+ * register/dispatch/closeAll lifecycle.
15
+ * - The dispatch path snapshots `subsRef` at iteration start (AD1
16
+ * snapshot-semantic contract from spec #222 §5.3 OQ-3 / spec #596
17
+ * "Stream lifecycle contract" row).
18
+ * - `closeAll` invokes each live sub's `onClose(new NotConnectedError(...))`
19
+ * before clearing `subsRef` — deterministic typed-failure delivery
20
+ * replaces the deleted `failAllNotificationWaiters` semantic.
19
21
  *
20
- * Unsubscribe semantics (OQ-3 A): `unsubscribe` takes effect on the next
21
- * frame. The registry snapshots its live-subscription list at the start
22
- * of each `dispatch` call; in-flight dispatch of frame N is not
23
- * interrupted by an unsubscribe during frame N. Frame N+1 observes the
24
- * unsubscribed state.
25
- *
26
- * Error channel: handlers are invoked inside a defect-catcher; a throw is
27
- * logged through Effect logging and swallowed (matching the prior
28
- * `onNotification` contract at `ws-client.ts:650-655` pre-deletion). The
29
- * registry itself has no typed error surface — `register`, `dispatch`, and
30
- * `closeAll` are `Effect<T, never>`.
22
+ * Filter grammar (post-Spec B):
23
+ * - Subscription matches a frame iff `sub.definition === frame.definition`.
24
+ * - Optional `refinement` is a typed predicate over the frame's params
25
+ * (erased to the union type `ErasedNotificationRefinement` at the
26
+ * storage boundary; consumers receive the typed-narrowed shape via
27
+ * `Stream.async`'s typed `emit.single` callback inside
28
+ * `notification/stream.ts`).
29
+ * - The three-field `SubscriptionFilter` grammar is deleted (spec #596
30
+ * Goal #3 + §"Acceptance criteria" delete sweep). Multi-definition
31
+ * fan-out becomes `Stream.mergeAll([subscribe(d1), subscribe(d2)])`.
31
32
  */
32
33
  import { Brand, Effect } from "effect";
33
- import type { AnyNotificationDefinition, DecodedNotification } from "@moltzap/protocol";
34
- interface FilterableNotificationFrame {
35
- readonly method: string;
36
- readonly params?: unknown;
37
- }
34
+ import { NotConnectedError, type AnyNotificationDefinition, type DecodedNotification, type NotificationParamsOf } from "@moltzap/protocol";
38
35
  /** Branded identifier for a subscription handle. Minted by `register`. */
39
- export type SubscriptionId = string & Brand.Brand<"SubscriptionId">;
36
+ type SubscriptionId = string & Brand.Brand<"SubscriptionId">;
40
37
  /**
41
- * Filter grammar for `subscribe`. A notification is delivered to a subscription
42
- * iff it matches **every** field that is set on the filter. Unset fields
43
- * are wildcards; the empty filter `{}` matches every notification.
44
- *
45
- * OQ-2 resolution (A): exactly these three fields, no free-form
46
- * predicate, no schema-derived matcher. Matches the existing
47
- * `RealClientEventFilter` contract at
48
- * `packages/protocol/src/testing/conformance/client/runner.ts:104-116`
49
- * one-for-one.
50
- *
51
- * - `emissionTag` — exact match against the canonical payload key
52
- * `frame.params.__emissionTag`. (The adapter reads the same key at
53
- * `packages/client/src/test-utils/conformance-adapter.ts:77-79`;
54
- * `emitTaggedEventDefault` writes it at `runner.ts:343-357`. The
55
- * `__emissionId` string in the `runner.ts:108` doc comment is a
56
- * known doc-bug — architect files a follow-up issue against
57
- * protocol to correct the comment; it is not the canonical name.)
58
- * - `conversationId` — exact match against `frame.params.conversationId`
59
- * when set on the notification payload.
60
- * - `notificationNamePrefix` — `frame.method.startsWith(prefix)`.
38
+ * Per-subscription callback delivered each matching frame. Implemented in
39
+ * `notification/stream.ts` as `(frame) => Effect.sync(() => emit.single(frame))`.
40
+ * Returning `Effect<void, never>` keeps the dispatch path total — the
41
+ * Stream-side `emit.single` cannot fail synchronously.
61
42
  */
62
- export interface SubscriptionFilter {
63
- readonly emissionTag?: string;
64
- readonly conversationId?: string;
65
- readonly notificationNamePrefix?: string;
66
- }
43
+ type SubscriberFrameCallback = (frame: DecodedNotification<AnyNotificationDefinition>) => Effect.Effect<void, never>;
67
44
  /**
68
- * Handle returned by `register` / `MoltZapWsClient.subscribe`. Caller
69
- * holds the handle for its subscription's lifetime and runs
70
- * `unsubscribe` to stop delivery.
71
- *
72
- * `unsubscribe` is `Effect&lt;void, never>`: it is idempotent and total.
73
- * Calling `unsubscribe` a second time, or after `closeAll`, is a no-op.
45
+ * Per-subscription callback invoked exactly once when the client transitions
46
+ * to its terminal closed state. Implemented in `notification/stream.ts` as
47
+ * `(cause) => Effect.sync(() => emit.fail(cause))`.
74
48
  */
75
- export interface NotificationSubscription {
76
- readonly id: SubscriptionId;
77
- readonly unsubscribe: Effect.Effect<void, never>;
78
- }
49
+ type SubscriberCloseCallback = (cause: NotConnectedError) => Effect.Effect<void, never>;
79
50
  /**
80
- * Per-subscription handler signature. Runs inside the registry's
81
- * dispatch fiber. Must not throw — throws are caught by the registry, logged,
82
- * and swallowed.
83
- *
84
- * The frame is a known-descriptor `DecodedNotification` (post-S9
85
- * fail-close: malformed / unknown-method frames are rejected before
86
- * dispatch). Handlers receive validated `params` typed as
87
- * `NotificationParamsOf&lt;D>` for the matching definition.
88
- *
89
- * Returning an `Effect` (not a plain `void`) lets handlers compose with
90
- * Effect-native downstream code without an extra runSync shim. The
91
- * registry awaits each handler's effect before moving to the next
92
- * subscription for this frame — fairness over throughput, so a slow
93
- * handler on subscription A does not reorder frames seen by
94
- * subscription B across frames.
51
+ * Handle returned by `register`. `unregister` is `Effect<void, never>`: it
52
+ * is idempotent and total. Calling `unregister` a second time, or after
53
+ * `closeAll`, is a no-op.
95
54
  */
96
- export type SubscriberHandler = (frame: DecodedNotification<AnyNotificationDefinition>) => Effect.Effect<void, never>;
55
+ interface SubscriptionHandle {
56
+ readonly id: SubscriptionId;
57
+ readonly unregister: Effect.Effect<void, never>;
58
+ }
97
59
  /**
98
60
  * Subscriber registry. One instance per `MoltZapWsClient`, created at
99
- * construction time and owned by the client. Not exported from the
100
- * package barrel — consumers reach the registry only through
101
- * `MoltZapWsClient.subscribe`.
61
+ * construction time and owned by the client.
62
+ *
63
+ * `register<D>` accepts typed `onFrame` / `onClose` callbacks for the
64
+ * specific definition `D`; internally the registry erases them to the
65
+ * `Subscriber{Frame,Close}Callback` union shape so a single iteration
66
+ * can dispatch over heterogeneous subscriptions without per-`D`
67
+ * dispatch tables.
102
68
  */
103
69
  export interface SubscriberRegistry {
70
+ readonly register: <D extends AnyNotificationDefinition>(definition: D, refinement: ((params: NotificationParamsOf<D>) => boolean) | undefined, callbacks: {
71
+ readonly onFrame: (frame: DecodedNotification<D>) => Effect.Effect<void, never>;
72
+ readonly onClose: SubscriberCloseCallback;
73
+ }) => Effect.Effect<SubscriptionHandle, never>;
104
74
  /**
105
- * Add a subscription. Returns the handle immediately; delivery starts
106
- * with the next frame passed to `dispatch`. Does not await any
107
- * connection state — subscribe is legal pre-connect (spec §5.3 +
108
- * Assumption 1 deletion: post-delete of `onNotification`, subscribe is the
109
- * only pre-connect notification hook).
75
+ * `subscribeAll` surface (spec #596 Goal #2). Registers a broad-union
76
+ * subscription that fires for every inbound frame regardless of
77
+ * definition. The optional `refinement` predicate runs against the
78
+ * full `DecodedNotification<AnyNotificationDefinition>` shape.
79
+ *
80
+ * Stored in a sibling `subsAllRef` list — kept off `subsRef` so the
81
+ * per-definition dispatch loop in `dispatch` stays a simple
82
+ * `definition ===` check without a per-sub broad-union escape branch.
110
83
  */
111
- readonly register: (filter: SubscriptionFilter, handler: SubscriberHandler) => Effect.Effect<NotificationSubscription, never>;
84
+ readonly registerAll: (refinement: ((notification: DecodedNotification<AnyNotificationDefinition>) => boolean) | undefined, callbacks: {
85
+ readonly onFrame: SubscriberFrameCallback;
86
+ readonly onClose: SubscriberCloseCallback;
87
+ }) => Effect.Effect<SubscriptionHandle, never>;
112
88
  /**
113
- * Fan an inbound notification out to every matching subscription. Called by
114
- * `MoltZapWsClient.handleIncoming` at the existing notification-dispatch
115
- * point (`ws-client.ts:649-685`). Implementation snapshots the
116
- * live-subscription list at the start of dispatch so
117
- * unsubscribe-during-dispatch observes next-frame semantics (OQ-3 A).
118
- *
119
- * Frames are pre-validation (`DecodedNotification&lt;AnyNotificationDefinition>` union) — the
120
- * type-system contract that subscribers see RAW frames, not the lifted
121
- * `DecodedNotification&lt;D>` shape that typed handlers see.
122
- *
123
- * Dispatch order: registration order, iterated sequentially; slow
124
- * handlers block later subscriptions for this frame but never
125
- * reorder frame N relative to frame N+1.
89
+ * Fan an inbound notification out to every matching subscription. Called
90
+ * from `MoltZapWsClient.handleDecodedNotification`. Snapshot semantic:
91
+ * unsubscribes that commit mid-dispatch observe NEXT-frame semantics
92
+ * (AD1 path-(a) contract).
126
93
  */
127
94
  readonly dispatch: (frame: DecodedNotification<AnyNotificationDefinition>) => Effect.Effect<void, never>;
128
95
  /**
129
- * Drop every live subscription. Called from `MoltZapWsClient.close`
130
- * so handlers stop firing once the client is torn down. Idempotent.
96
+ * Terminal close. Invokes every live sub's `onClose` callback (which
97
+ * `emit.fail(cause)`s the corresponding consumer Stream), then clears
98
+ * both `subsRef` and `subsAllRef`. Idempotent.
131
99
  */
132
100
  readonly closeAll: Effect.Effect<void, never>;
133
101
  }
134
- /**
135
- * Construct an empty registry. Called once from the `MoltZapWsClient`
136
- * constructor.
137
- *
138
- * Implementation notes:
139
- * - Live subscriptions are stored in a `Ref&lt;ReadonlyArray&lt;…>>` keyed
140
- * by registration order. Append-on-register, filter-on-unsubscribe
141
- * keeps the dispatch path O(N) with N = live subscription count.
142
- * Bigger structures aren't justified at the expected sub count
143
- * (≤ ~10 per fixture).
144
- * - `dispatch` snapshots the array at start (OQ-3 A). An
145
- * `unsubscribe` mid-dispatch mutates the Ref but the in-flight
146
- * iteration walks the snapshot.
147
- * - Handler exceptions are caught with `Effect.catchAllDefect` after
148
- * the handler Effect. Sync `throw` from a `(frame) => …` body
149
- * surfaces as a defect; we log + swallow to match the pre-deletion
150
- * `onNotification` contract.
151
- */
152
102
  export declare function makeSubscriberRegistry(): Effect.Effect<SubscriberRegistry, never>;
153
- /**
154
- * Pure filter-match predicate. Exposed for unit testing so executable
155
- * client-side divergence proofs can force known-bad subscription
156
- * behavior without bypassing the production dispatch path.
157
- *
158
- * Returns `true` iff `frame` matches every set field on `filter`:
159
- * - `filter.emissionTag === frame.params.__emissionTag` (strict ===)
160
- * - `filter.conversationId === frame.params.conversationId` (strict ===)
161
- * - `frame.method.startsWith(filter.notificationNamePrefix)`
162
- * Unset filter fields are wildcards.
163
- */
164
- export declare function matchesFilter(filter: SubscriptionFilter, frame: FilterableNotificationFrame): boolean;
165
103
  export {};
166
104
  //# sourceMappingURL=subscribers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"subscribers.d.ts","sourceRoot":"","sources":["../../src/runtime/subscribers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAO,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EACV,yBAAyB,EACzB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B,UAAU,2BAA2B;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,0EAA0E;AAC1E,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,KAAK,CAAC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K,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAC1B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAChC,QAAQ,CAAC,OAAO,EAAE,uBAAuB,CAAC;KAC3C,KACE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;IAE9C;;;;;;;;;OASG;IACH,QAAQ,CAAC,WAAW,EAAE,CACpB,UAAU,EACN,CAAC,CACC,YAAY,EAAE,mBAAmB,CAAC,yBAAyB,CAAC,KACzD,OAAO,CAAC,GACb,SAAS,EACb,SAAS,EAAE;QACT,QAAQ,CAAC,OAAO,EAAE,uBAAuB,CAAC;QAC1C,QAAQ,CAAC,OAAO,EAAE,uBAAuB,CAAC;KAC3C,KACE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;IAE9C;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,CACjB,KAAK,EAAE,mBAAmB,CAAC,yBAAyB,CAAC,KAClD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAEhC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;CAC/C;AA8RD,wBAAgB,sBAAsB,IAAI,MAAM,CAAC,MAAM,CACrD,kBAAkB,EAClB,KAAK,CACN,CAcA"}
@@ -1,35 +1,38 @@
1
+ /* eslint-disable jsdoc/text-escaping -- JSDoc references to generic types like `NotificationParamsOf<D>` use the natural angle-bracket form (TS source style) inside backtick-fenced code spans; the lint rule's pre-render check fires false positives on these multi-line spans. Matches the precedent in filter-equivalence.test.ts. */
1
2
  /**
2
3
  * Per-subscription notification registry for `MoltZapWsClient`.
3
4
  *
4
- * Responsibility: own the list of live `subscribe()` handles and fan each
5
- * inbound JSON-RPC notification out to every subscription whose filter matches.
6
- * Implements spec #222 §5.3 (C4 + the `RealClientEventSubscriber.subscribe`
7
- * filter stub). Lives as an internal collaborator of `MoltZapWsClient`;
8
- * the public types (`SubscriptionFilter`, `NotificationSubscription`,
9
- * `SubscriptionId`) re-export from the package barrel.
5
+ * Responsibility: own the list of live subscriptions and fan each inbound
6
+ * JSON-RPC notification out to every subscription whose definition (and
7
+ * optional typed refinement predicate) matches. Implements spec #596
8
+ * (notification consumption consolidation) via the AD1 path-(a) Stream.async
9
+ * design (architect plan §3, §5.5).
10
10
  *
11
- * Dispatch ordering (Invariant 6 — notifications delivered in arrival order):
12
- * 1. Inbound frames are handed to the registry in arrival order.
13
- * 2. Within a single frame, subscriptions are notified in registration
14
- * order.
15
- * 3. There is no separate legacy `onNotification` fanout — spec #222 OQ-4 is
16
- * resolved by DELETING `MoltZapWsClientOptions.onNotification`. Callers
17
- * that want every notification register `subscribe({}, handler)` after
18
- * construction and before `connect()`.
11
+ * Storage shape (post-Spec B):
12
+ * - Subscriptions are records of typed `{onFrame, onClose}` callbacks
13
+ * (NOT queues / Take items / Stream.fromQueue). `notification/stream.ts`
14
+ * owns Stream construction via `Stream.async`; this module owns the
15
+ * register/dispatch/closeAll lifecycle.
16
+ * - The dispatch path snapshots `subsRef` at iteration start (AD1
17
+ * snapshot-semantic contract from spec #222 §5.3 OQ-3 / spec #596
18
+ * "Stream lifecycle contract" row).
19
+ * - `closeAll` invokes each live sub's `onClose(new NotConnectedError(...))`
20
+ * before clearing `subsRef` — deterministic typed-failure delivery
21
+ * replaces the deleted `failAllNotificationWaiters` semantic.
19
22
  *
20
- * Unsubscribe semantics (OQ-3 A): `unsubscribe` takes effect on the next
21
- * frame. The registry snapshots its live-subscription list at the start
22
- * of each `dispatch` call; in-flight dispatch of frame N is not
23
- * interrupted by an unsubscribe during frame N. Frame N+1 observes the
24
- * unsubscribed state.
25
- *
26
- * Error channel: handlers are invoked inside a defect-catcher; a throw is
27
- * logged through Effect logging and swallowed (matching the prior
28
- * `onNotification` contract at `ws-client.ts:650-655` pre-deletion). The
29
- * registry itself has no typed error surface — `register`, `dispatch`, and
30
- * `closeAll` are `Effect&lt;T, never>`.
23
+ * Filter grammar (post-Spec B):
24
+ * - Subscription matches a frame iff `sub.definition === frame.definition`.
25
+ * - Optional `refinement` is a typed predicate over the frame's params
26
+ * (erased to the union type `ErasedNotificationRefinement` at the
27
+ * storage boundary; consumers receive the typed-narrowed shape via
28
+ * `Stream.async`'s typed `emit.single` callback inside
29
+ * `notification/stream.ts`).
30
+ * - The three-field `SubscriptionFilter` grammar is deleted (spec #596
31
+ * Goal #3 + §"Acceptance criteria" delete sweep). Multi-definition
32
+ * fan-out becomes `Stream.mergeAll([subscribe(d1), subscribe(d2)])`.
31
33
  */
32
34
  import { Brand, Effect, Ref } from "effect";
35
+ import { NotConnectedError, } from "@moltzap/protocol";
33
36
  const SubscriptionIdBrand = Brand.nominal();
34
37
  function nextSubscriptionId(counterRef) {
35
38
  return Ref.updateAndGet(counterRef, (count) => count + 1).pipe(Effect.map((count) => SubscriptionIdBrand(`sub-${count}`)));
@@ -41,88 +44,179 @@ function removeSubscription(subsRef, id) {
41
44
  return Ref.update(subsRef, (subscriptions) => subscriptions.filter((subscription) => subscription.id !== id));
42
45
  }
43
46
  function dispatchToSubscriber(sub, frame) {
44
- return Effect.suspend(() => sub.handler(frame)).pipe(Effect.catchAllDefect((err) => Effect.logWarning("subscriber handler threw", err)));
47
+ return Effect.suspend(() => sub.onFrame(frame)).pipe(Effect.catchAllDefect((err) => Effect.logWarning("subscriber onFrame callback threw", err)));
45
48
  }
46
- function isNotificationParamsRecord(value) {
47
- return typeof value === "object" && value !== null && !Array.isArray(value);
49
+ function closeSubscriber(sub, cause) {
50
+ return Effect.suspend(() => sub.onClose(cause)).pipe(Effect.catchAllDefect((err) => Effect.logWarning("subscriber onClose callback threw", err)));
48
51
  }
49
52
  /**
50
53
  * Construct an empty registry. Called once from the `MoltZapWsClient`
51
54
  * constructor.
52
55
  *
53
56
  * Implementation notes:
54
- * - Live subscriptions are stored in a `Ref&lt;ReadonlyArray&lt;…>>` keyed
55
- * by registration order. Append-on-register, filter-on-unsubscribe
56
- * keeps the dispatch path O(N) with N = live subscription count.
57
- * Bigger structures aren't justified at the expected sub count
58
- * (≤ ~10 per fixture).
59
- * - `dispatch` snapshots the array at start (OQ-3 A). An
60
- * `unsubscribe` mid-dispatch mutates the Ref but the in-flight
61
- * iteration walks the snapshot.
62
- * - Handler exceptions are caught with `Effect.catchAllDefect` after
63
- * the handler Effect. Sync `throw` from a `(frame) => …` body
64
- * surfaces as a defect; we log + swallow to match the pre-deletion
65
- * `onNotification` contract.
57
+ * - `subsRef: Ref<ReadonlyArray<LiveSubscription>>` keyed by registration
58
+ * order. Append-on-register, filter-on-unregister keeps the dispatch
59
+ * path O(N) with N = live subscription count.
60
+ * - `dispatch` snapshots `subsRef` at iteration start. An unregister
61
+ * mid-dispatch mutates the Ref but the in-flight iteration walks the
62
+ * snapshot (AD1 path-(a) snapshot semantic).
63
+ * - `closeAll` invokes each live sub's `onClose` in iteration order
64
+ * before clearing the ref. `Stream.async`'s `emit.fail` is the
65
+ * deterministic in-Effect mechanism that propagates the typed
66
+ * failure to each consumer.
66
67
  */
67
- export function makeSubscriberRegistry() {
68
- return Effect.gen(function* () {
69
- const subsRef = yield* Ref.make([]);
70
- const counterRef = yield* Ref.make(0);
71
- const register = (filter, handler) => Effect.gen(function* () {
72
- const id = yield* nextSubscriptionId(counterRef);
73
- const live = { id, filter, handler };
74
- yield* appendSubscription(subsRef, live);
75
- const unsubscribe = removeSubscription(subsRef, id);
76
- return { id, unsubscribe };
77
- });
78
- const dispatch = (frame) => Effect.gen(function* () {
79
- // Snapshot at dispatch-start: OQ-3 A. Unsubscribes during this
80
- // frame mutate `subsRef` but our iteration walks `snapshot`.
81
- const snapshot = yield* Ref.get(subsRef);
82
- // Short-circuit the common pre-subscribe path (every inbound
83
- // frame before any `subscribe()` call) so hot-path dispatch
84
- // avoids even the `for…of` allocation.
85
- if (snapshot.length === 0)
86
- return;
87
- for (const sub of snapshot) {
88
- if (!matchesFilter(sub.filter, frame))
89
- continue;
90
- // Handlers must not throw; we catch defects defensively so
91
- // one buggy subscriber can't kill the dispatch loop or break
92
- // the reader fiber.
93
- yield* dispatchToSubscriber(sub, frame);
94
- }
95
- });
96
- const closeAll = Ref.set(subsRef, []);
97
- return { register, dispatch, closeAll };
98
- }).pipe(Effect.withSpan("makeSubscriberRegistry"));
68
+ function appendBroadSubscription(subsAllRef, live) {
69
+ return Ref.update(subsAllRef, (subscriptions) => [...subscriptions, live]);
70
+ }
71
+ function removeBroadSubscription(subsAllRef, id) {
72
+ return Ref.update(subsAllRef, (subscriptions) => subscriptions.filter((subscription) => subscription.id !== id));
73
+ }
74
+ function dispatchToBroadSubscriber(sub, frame) {
75
+ return Effect.suspend(() => sub.onFrame(frame)).pipe(Effect.catchAllDefect((err) => Effect.logWarning("subscribeAll onFrame callback threw", err)));
76
+ }
77
+ function closeBroadSubscriber(sub, cause) {
78
+ return Effect.suspend(() => sub.onClose(cause)).pipe(Effect.catchAllDefect((err) => Effect.logWarning("subscribeAll onClose callback threw", err)));
79
+ }
80
+ /**
81
+ * Single named typed→erased adapter for the refinement predicate. The
82
+ * `Stream.async` callback inside `notification/stream.ts` keeps the typed
83
+ * shape for the consumer's typed payload; storage in `LiveSubscription`
84
+ * uses the broad-union erased form. This is the only place the typed →
85
+ * erased boundary crosses, so the cast is acknowledged with an explicit
86
+ * lint suppression.
87
+ */
88
+ function eraseRefinement(refinement) {
89
+ if (refinement === undefined)
90
+ return undefined;
91
+ // The typed→erased boundary is by construction safe: the registry's
92
+ // `dispatch` loop only invokes the refinement with frames whose
93
+ // `definition === sub.definition`, so `frame.params` always satisfies
94
+ // `NotificationParamsOf<D>`.
95
+ // eslint-disable-next-line agent-code-guard/as-unknown-as -- documented typed→erased boundary, see comment above
96
+ return refinement; // #ignore-sloppy-code[as-unknown-as]: typed→erased boundary for heterogeneous registry storage; dispatch loop enforces definition identity before invocation
97
+ }
98
+ function buildRegister(subsRef, counterRef) {
99
+ return (definition, refinement, callbacks) => Effect.gen(function* () {
100
+ const id = yield* nextSubscriptionId(counterRef);
101
+ const erasedRefinement = eraseRefinement(refinement);
102
+ const live = {
103
+ id,
104
+ definition,
105
+ ...(erasedRefinement !== undefined
106
+ ? { refinement: erasedRefinement }
107
+ : {}),
108
+ onFrame: callbacks.onFrame,
109
+ onClose: callbacks.onClose,
110
+ };
111
+ yield* appendSubscription(subsRef, live);
112
+ const unregister = removeSubscription(subsRef, id);
113
+ return { id, unregister };
114
+ });
115
+ }
116
+ function buildRegisterAll(subsAllRef, counterRef) {
117
+ return (refinement, callbacks) => Effect.gen(function* () {
118
+ const id = yield* nextSubscriptionId(counterRef);
119
+ const live = {
120
+ id,
121
+ ...(refinement !== undefined ? { refinement } : {}),
122
+ onFrame: callbacks.onFrame,
123
+ onClose: callbacks.onClose,
124
+ };
125
+ yield* appendBroadSubscription(subsAllRef, live);
126
+ const unregister = removeBroadSubscription(subsAllRef, id);
127
+ return { id, unregister };
128
+ });
99
129
  }
100
130
  /**
101
- * Pure filter-match predicate. Exposed for unit testing so executable
102
- * client-side divergence proofs can force known-bad subscription
103
- * behavior without bypassing the production dispatch path.
131
+ * Run a user-supplied refinement predicate with throw isolation. A throw
132
+ * inside the predicate must NOT defect the dispatch Effect (which would
133
+ * starve sibling subscribers of the in-flight frame, AD1 path-(a) snapshot
134
+ * contract). Treat any throw as "predicate said false" — the frame is
135
+ * filtered out for this subscriber, the throw is logged, dispatch
136
+ * continues with the next subscription in the snapshot.
104
137
  *
105
- * Returns `true` iff `frame` matches every set field on `filter`:
106
- * - `filter.emissionTag === frame.params.__emissionTag` (strict ===)
107
- * - `filter.conversationId === frame.params.conversationId` (strict ===)
108
- * - `frame.method.startsWith(filter.notificationNamePrefix)`
109
- * Unset filter fields are wildcards.
138
+ * The warning is emitted via `Effect.runFork(Effect.logWarning(…))`
139
+ * (detached from the dispatch fiber's span/annotations) so the
140
+ * synchronous filter returned by `subAcceptsFrame` / `broadAcceptsFrame`
141
+ * stays synchronous — pulling logging into the surrounding `Effect.gen`
142
+ * would either (a) require the predicate to become an Effect (forcing
143
+ * every caller to `yield*`) or (b) accumulate warnings in a Ref and
144
+ * re-emit post-dispatch (extra state for a non-load-bearing log). The
145
+ * detached log is acceptable for predicate misuse — a noisy warning
146
+ * that names the call site (`subscribe` vs `subscribeAll`) is sufficient
147
+ * signal for the application author to find the throw in their
148
+ * refinement. Codex r2 P3-1 documented this trade-off rather than
149
+ * restructuring.
150
+ */
151
+ function safePredicate(predicate, params, context) {
152
+ try {
153
+ return predicate(params);
154
+ }
155
+ catch (err) {
156
+ Effect.runFork(Effect.logWarning(`${context} refinement predicate threw`, err));
157
+ return false;
158
+ }
159
+ }
160
+ /**
161
+ * Cognitive-complexity helper: decides whether a per-definition sub
162
+ * accepts a given frame. Predicate throws are caught (P2-1, codex r1):
163
+ * a throwing refinement returns `false` rather than defecting the
164
+ * dispatch Effect.
110
165
  */
111
- export function matchesFilter(filter, frame) {
112
- const methodPrefix = filter.notificationNamePrefix;
113
- if (methodPrefix !== undefined &&
114
- !matchesMethodPrefix(methodPrefix, frame.method))
166
+ function subAcceptsFrame(sub, frame) {
167
+ if (sub.definition !== frame.definition)
168
+ return false;
169
+ if (sub.refinement !== undefined &&
170
+ !safePredicate(sub.refinement, frame.params, "subscribe"))
115
171
  return false;
116
- const params = isNotificationParamsRecord(frame.params)
117
- ? frame.params
118
- : null;
119
- return (matchesPayloadValue(params, "__emissionTag", filter.emissionTag) &&
120
- matchesPayloadValue(params, "conversationId", filter.conversationId));
172
+ return true;
121
173
  }
122
- function matchesMethodPrefix(prefix, method) {
123
- return method.startsWith(prefix);
174
+ /** Same as `subAcceptsFrame`, but for broad-union subscriptions. */
175
+ function broadAcceptsFrame(sub, frame) {
176
+ return (sub.refinement === undefined ||
177
+ safePredicate(sub.refinement, frame, "subscribeAll"));
124
178
  }
125
- function matchesPayloadValue(params, key, expected) {
126
- return expected === undefined || params?.[key] === expected;
179
+ function buildDispatch(subsRef, subsAllRef) {
180
+ return (frame) => Effect.gen(function* () {
181
+ // Snapshot both lists at iteration start (AD1 path-(a) semantic).
182
+ const snapshot = yield* Ref.get(subsRef);
183
+ const broadSnapshot = yield* Ref.get(subsAllRef);
184
+ const matching = snapshot.filter((sub) => subAcceptsFrame(sub, frame));
185
+ for (const sub of matching) {
186
+ yield* dispatchToSubscriber(sub, frame);
187
+ }
188
+ const matchingBroad = broadSnapshot.filter((sub) => broadAcceptsFrame(sub, frame));
189
+ for (const sub of matchingBroad) {
190
+ yield* dispatchToBroadSubscriber(sub, frame);
191
+ }
192
+ });
193
+ }
194
+ function buildCloseAll(subsRef, subsAllRef) {
195
+ return Effect.gen(function* () {
196
+ const snapshot = yield* Ref.getAndSet(subsRef, []);
197
+ const broadSnapshot = yield* Ref.getAndSet(subsAllRef, []);
198
+ const cause = new NotConnectedError({
199
+ message: "WebSocket not connected",
200
+ });
201
+ for (const sub of snapshot) {
202
+ yield* closeSubscriber(sub, cause);
203
+ }
204
+ for (const sub of broadSnapshot) {
205
+ yield* closeBroadSubscriber(sub, cause);
206
+ }
207
+ });
208
+ }
209
+ export function makeSubscriberRegistry() {
210
+ return Effect.gen(function* () {
211
+ const subsRef = yield* Ref.make([]);
212
+ const subsAllRef = yield* Ref.make([]);
213
+ const counterRef = yield* Ref.make(0);
214
+ return {
215
+ register: buildRegister(subsRef, counterRef),
216
+ registerAll: buildRegisterAll(subsAllRef, counterRef),
217
+ dispatch: buildDispatch(subsRef, subsAllRef),
218
+ closeAll: buildCloseAll(subsRef, subsAllRef),
219
+ };
220
+ }).pipe(Effect.withSpan("makeSubscriberRegistry"));
127
221
  }
128
222
  //# sourceMappingURL=subscribers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"subscribers.js","sourceRoot":"","sources":["../../src/runtime/subscribers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,E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