@moltzap/router 2026.902.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 (49) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +19 -0
  3. package/README.md +31 -0
  4. package/bin/moltzap-router +9 -0
  5. package/dist/index.d.ts +16 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +16 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/router/contract.d.ts +209 -0
  10. package/dist/router/contract.d.ts.map +1 -0
  11. package/dist/router/contract.js +347 -0
  12. package/dist/router/contract.js.map +1 -0
  13. package/dist/router/feed.d.ts +89 -0
  14. package/dist/router/feed.d.ts.map +1 -0
  15. package/dist/router/feed.js +157 -0
  16. package/dist/router/feed.js.map +1 -0
  17. package/dist/router/http.d.ts +30 -0
  18. package/dist/router/http.d.ts.map +1 -0
  19. package/dist/router/http.js +219 -0
  20. package/dist/router/http.js.map +1 -0
  21. package/dist/router/poll-cursor.d.ts +50 -0
  22. package/dist/router/poll-cursor.d.ts.map +1 -0
  23. package/dist/router/poll-cursor.js +142 -0
  24. package/dist/router/poll-cursor.js.map +1 -0
  25. package/dist/router/poll-waiters.d.ts +24 -0
  26. package/dist/router/poll-waiters.d.ts.map +1 -0
  27. package/dist/router/poll-waiters.js +66 -0
  28. package/dist/router/poll-waiters.js.map +1 -0
  29. package/dist/router/poll.d.ts +38 -0
  30. package/dist/router/poll.d.ts.map +1 -0
  31. package/dist/router/poll.js +118 -0
  32. package/dist/router/poll.js.map +1 -0
  33. package/dist/router/rpc.d.ts +37 -0
  34. package/dist/router/rpc.d.ts.map +1 -0
  35. package/dist/router/rpc.js +75 -0
  36. package/dist/router/rpc.js.map +1 -0
  37. package/dist/router/send.d.ts +27 -0
  38. package/dist/router/send.d.ts.map +1 -0
  39. package/dist/router/send.js +91 -0
  40. package/dist/router/send.js.map +1 -0
  41. package/dist/router.d.ts +60 -0
  42. package/dist/router.d.ts.map +1 -0
  43. package/dist/router.js +177 -0
  44. package/dist/router.js.map +1 -0
  45. package/dist/server.d.ts +29 -0
  46. package/dist/server.d.ts.map +1 -0
  47. package/dist/server.js +112 -0
  48. package/dist/server.js.map +1 -0
  49. package/package.json +128 -0
@@ -0,0 +1,347 @@
1
+ /** @file Closed Router wire values, requests, results, bounds, and client failures. */
2
+ import { AuthenticationFailedError, InternalServerError, MalformedRequestError, MethodNotAllowedError, OverloadedError, PayloadTooLargeError, RouteNotFoundError, SignedMessage, UnavailableError, UnsupportedMediaTypeError, VersionMismatchError, } from "@moltzap/identity";
3
+ import canonicalize from "canonicalize";
4
+ import { Data, Effect, Either, Encoding, Option, Schema } from "effect";
5
+ /** Exact Router send target. */
6
+ export const routerSendPath = "/v1/messages:send";
7
+ /** Exact Router poll target. */
8
+ export const routerPollPath = "/v1/messages:poll";
9
+ /** Exact Router health target. */
10
+ export const routerHealthPath = "/healthz";
11
+ /** Effect HTTP Router pattern for the exact send target. */
12
+ export const routerSendRoutePattern = "/v1/messages::send";
13
+ /** Effect HTTP Router pattern for the exact poll target. */
14
+ export const routerPollRoutePattern = "/v1/messages::poll";
15
+ /** Exact media type for Router-owned JSON representations. */
16
+ export const routerJsonContentType = "application/json";
17
+ const INSTANCE_BYTE_LENGTH = 16;
18
+ const DIGEST_BYTE_LENGTH = 32;
19
+ const MAXIMUM_CURSOR_LENGTH = 348;
20
+ /** Exact protected header carried by every PollCursor. */
21
+ export const pollCursorProtectedHeader = Object.freeze({
22
+ alg: "dir",
23
+ enc: "A256GCM",
24
+ typ: "application/vnd.moltzap.poll-cursor+jwe",
25
+ });
26
+ /** Canonical protected-header JSON carried by every PollCursor. */
27
+ const pollCursorProtectedHeaderJson = '{"alg":"dir","enc":"A256GCM","typ":"application/vnd.moltzap.poll-cursor+jwe"}';
28
+ /** Canonical encoded protected header carried by every PollCursor. */
29
+ export const encodedPollCursorProtectedHeader = Encoding.encodeBase64Url(new TextEncoder().encode(pollCursorProtectedHeaderJson));
30
+ const encodedPollCursorProtectedHeaderLength = Math.ceil((new TextEncoder().encode(pollCursorProtectedHeaderJson).byteLength * 8) / 6);
31
+ /** Prefix separating PollCursor values from unrefined compact JWE text. */
32
+ export const pollCursorPrefix = "plc_";
33
+ /* eslint-disable @typescript-eslint/naming-convention, @typescript-eslint/no-redeclare --
34
+ * Named Effect Schemas share their domain names with the types they decode.
35
+ */
36
+ /** Identifies one volatile Router process instance. */
37
+ export const RouterInstanceId = canonicalValue("RouterInstanceId", "rti_", INSTANCE_BYTE_LENGTH);
38
+ /** Equality receipt for one complete retained SignedMessage. */
39
+ export const SignedMessageDigest = canonicalValue("SignedMessageDigest", "smd_", DIGEST_BYTE_LENGTH);
40
+ /** Opaque, authenticated continuation for one caller and Router instance. */
41
+ export const PollCursor = Schema.String.pipe(Schema.filter(hasCanonicalCursorShape, {
42
+ identifier: "PollCursor",
43
+ description: "Canonical opaque Router poll continuation",
44
+ }), Schema.brand("PollCursor"), Schema.annotations({
45
+ identifier: "PollCursor",
46
+ description: "Canonical opaque Router poll continuation",
47
+ }));
48
+ const exact = {
49
+ exact: true,
50
+ onExcessProperty: "error",
51
+ };
52
+ const closedStruct = (fields) => Schema.Struct(fields).annotations({ parseOptions: exact });
53
+ /** Exact private send shape that preserves instance-fence precedence. */
54
+ export const RawRouterSendRequest = closedStruct({
55
+ expectedRouterInstanceId: RouterInstanceId,
56
+ mode: Schema.Literal("initial", "retry"),
57
+ signedMessage: Schema.Unknown,
58
+ }).annotations({ identifier: "RawRouterSendRequest" });
59
+ /** Exact Schema for one send request. */
60
+ export const RouterSendRequest = closedStruct({
61
+ expectedRouterInstanceId: RouterInstanceId,
62
+ mode: Schema.Literal("initial", "retry"),
63
+ signedMessage: SignedMessage,
64
+ }).annotations({ identifier: "RouterSendRequest" });
65
+ const accepted = closedStruct({
66
+ kind: Schema.Literal("accepted"),
67
+ routerInstanceId: RouterInstanceId,
68
+ signedMessageDigest: SignedMessageDigest,
69
+ });
70
+ const routerRestarted = closedStruct({
71
+ kind: Schema.Literal("router_restarted"),
72
+ routerInstanceId: RouterInstanceId,
73
+ });
74
+ const messageInvalid = closedStruct({
75
+ kind: Schema.Literal("message_invalid"),
76
+ });
77
+ const idempotencyConflict = closedStruct({
78
+ kind: Schema.Literal("idempotency_conflict"),
79
+ });
80
+ const retryIdentityUnknown = closedStruct({
81
+ kind: Schema.Literal("retry_identity_unknown"),
82
+ });
83
+ /** Exact Schema for every closed send outcome. */
84
+ export const RouterSendResult = Schema.Union(accepted, routerRestarted, messageInvalid, idempotencyConflict, retryIdentityUnknown).annotations({ identifier: "RouterSendResult" });
85
+ /** Exact Schema for one endpoint-wide poll request. */
86
+ export const RouterPollRequest = closedStruct({
87
+ pollCursor: Schema.optional(PollCursor),
88
+ }).annotations({ identifier: "RouterPollRequest" });
89
+ const batch = closedStruct({
90
+ kind: Schema.Literal("batch"),
91
+ routerInstanceId: RouterInstanceId,
92
+ signedMessages: Schema.Array(SignedMessage),
93
+ pollCursor: PollCursor,
94
+ });
95
+ const feedGap = closedStruct({
96
+ kind: Schema.Literal("feed_gap"),
97
+ routerInstanceId: RouterInstanceId,
98
+ });
99
+ const cursorInvalid = closedStruct({
100
+ kind: Schema.Literal("cursor_invalid"),
101
+ });
102
+ /** Exact Schema for every closed poll outcome. */
103
+ export const RouterPollResult = Schema.Union(batch, feedGap, cursorInvalid).annotations({
104
+ identifier: "RouterPollResult",
105
+ });
106
+ /* eslint-enable @typescript-eslint/naming-convention, @typescript-eslint/no-redeclare -- restore the shared project rules */
107
+ /** The Router connection could not be established or used. */
108
+ export class RouterConnectionError extends Data.TaggedError("RouterConnectionError") {
109
+ }
110
+ /** The configured complete Router call deadline expired. */
111
+ export class RouterRequestTimeoutError extends Data.TaggedError("RouterRequestTimeoutError") {
112
+ }
113
+ /** A Router response did not match the selected operation contract. */
114
+ export class RouterInvalidResponseError extends Data.TaggedError("RouterInvalidResponseError") {
115
+ }
116
+ const routerHttpErrors = Object.freeze({
117
+ MalformedRequestError: {
118
+ status: 400,
119
+ body: '{"error":"malformed"}',
120
+ make: () => new MalformedRequestError(),
121
+ },
122
+ AuthenticationFailedError: {
123
+ status: 401,
124
+ body: '{"error":"authentication_failed"}',
125
+ make: () => new AuthenticationFailedError(),
126
+ },
127
+ RouteNotFoundError: {
128
+ status: 404,
129
+ body: '{"error":"not_found"}',
130
+ make: () => new RouteNotFoundError(),
131
+ },
132
+ MethodNotAllowedError: {
133
+ status: 405,
134
+ body: '{"error":"method_not_allowed"}',
135
+ make: () => new MethodNotAllowedError(),
136
+ },
137
+ VersionMismatchError: {
138
+ status: 412,
139
+ body: '{"error":"version_mismatch"}',
140
+ make: () => new VersionMismatchError(),
141
+ },
142
+ PayloadTooLargeError: {
143
+ status: 413,
144
+ body: '{"error":"payload_too_large"}',
145
+ make: () => new PayloadTooLargeError(),
146
+ },
147
+ UnsupportedMediaTypeError: {
148
+ status: 415,
149
+ body: '{"error":"unsupported_media_type"}',
150
+ make: () => new UnsupportedMediaTypeError(),
151
+ },
152
+ OverloadedError: {
153
+ status: 429,
154
+ body: '{"error":"overloaded"}',
155
+ make: () => new OverloadedError(),
156
+ },
157
+ UnavailableError: {
158
+ status: 503,
159
+ body: '{"error":"unavailable"}',
160
+ make: () => new UnavailableError(),
161
+ },
162
+ InternalServerError: {
163
+ status: 500,
164
+ body: '{"error":"internal"}',
165
+ make: () => new InternalServerError(),
166
+ },
167
+ });
168
+ const isRouterHttpErrorTag = (tag) => Object.hasOwn(routerHttpErrors, tag);
169
+ /**
170
+ * Finds the exact status and body for one recognized Router failure tag.
171
+ *
172
+ * @param tag Candidate typed failure tag.
173
+ * @returns Its exact envelope or `undefined` when the tag is not recognized.
174
+ */
175
+ export const routerHttpErrorEnvelope = (tag) => isRouterHttpErrorTag(tag) ? routerHttpErrors[tag] : undefined;
176
+ /**
177
+ * Decodes one exact status and body pair into its typed Router failure.
178
+ *
179
+ * @param status Candidate HTTP status.
180
+ * @param body Candidate exact body text.
181
+ * @returns The matching typed failure, when the pair is declared.
182
+ */
183
+ export const routerHttpErrorFromResponse = (status, body) => {
184
+ const representation = Object.values(routerHttpErrors).find((candidate) => candidate.status === status && candidate.body === body);
185
+ return representation === undefined
186
+ ? Option.none()
187
+ : Option.some(representation.make());
188
+ };
189
+ /** A Router enclosing representation cannot be measured safely. */
190
+ export class RouterRepresentationLengthError extends Data.TaggedError("RouterRepresentationLengthError") {
191
+ }
192
+ const utf8Encoder = new TextEncoder();
193
+ const signedMessagePlaceholder = "__signed_message__";
194
+ const signedMessagePlaceholderByteLength = utf8Encoder.encode(JSON.stringify(signedMessagePlaceholder)).byteLength;
195
+ const maximumAgentId = "agt_AAAAAAAAAAAAAAAAAAAAAA";
196
+ const maximumRouterInstanceId = "rti_AAAAAAAAAAAAAAAAAAAAAA";
197
+ const canonicalByteLength = (value) => {
198
+ const encoded = canonicalize(value);
199
+ if (encoded === undefined) {
200
+ return Effect.fail(new RouterRepresentationLengthError());
201
+ }
202
+ return Effect.succeed(utf8Encoder.encode(encoded).byteLength);
203
+ };
204
+ const supportedLength = (value) => Number.isSafeInteger(value) && value >= 0;
205
+ const checkedAdd = (left, right) => {
206
+ const result = left + right;
207
+ if (!supportedLength(left) ||
208
+ !supportedLength(right) ||
209
+ !supportedLength(result)) {
210
+ return Effect.fail(new RouterRepresentationLengthError());
211
+ }
212
+ return Effect.succeed(result);
213
+ };
214
+ const maximumSendBody = {
215
+ callerAgentId: maximumAgentId,
216
+ request: {
217
+ expectedRouterInstanceId: maximumRouterInstanceId,
218
+ mode: "initial",
219
+ signedMessage: signedMessagePlaceholder,
220
+ },
221
+ };
222
+ const maximumPollBody = {
223
+ callerAgentId: maximumAgentId,
224
+ request: {
225
+ pollCursor: "A".repeat(MAXIMUM_CURSOR_LENGTH),
226
+ },
227
+ };
228
+ const maximumOneMessageBatch = {
229
+ kind: "batch",
230
+ pollCursor: "A".repeat(MAXIMUM_CURSOR_LENGTH),
231
+ routerInstanceId: maximumRouterInstanceId,
232
+ signedMessages: [signedMessagePlaceholder],
233
+ };
234
+ /**
235
+ * Calculates exact enclosing limits while treating SignedMessage as an
236
+ * identity-owned byte sequence.
237
+ *
238
+ * @param maximumSignedMessageByteLength Identity-owned complete message limit.
239
+ * @returns Exact maximum Router request and one-message result byte lengths.
240
+ */
241
+ export const calculateRouterRepresentationLimits = (maximumSignedMessageByteLength) => Effect.gen(function* () {
242
+ const sendTemplateBytes = yield* canonicalByteLength(maximumSendBody);
243
+ const pollRequestBodyBytes = yield* canonicalByteLength(maximumPollBody);
244
+ const batchTemplateBytes = yield* canonicalByteLength(maximumOneMessageBatch);
245
+ const sendFixedBytes = sendTemplateBytes - signedMessagePlaceholderByteLength;
246
+ const batchFixedBytes = batchTemplateBytes - signedMessagePlaceholderByteLength;
247
+ return Object.freeze({
248
+ sendRequestBodyBytes: yield* checkedAdd(sendFixedBytes, maximumSignedMessageByteLength),
249
+ pollRequestBodyBytes,
250
+ oneMessageBatchBytes: yield* checkedAdd(batchFixedBytes, maximumSignedMessageByteLength),
251
+ });
252
+ }).pipe(Effect.withSpan("calculateRouterRepresentationLimits"));
253
+ /** Exact limits derived from the current closed Router representations. */
254
+ export const routerRepresentationLimits = Effect.runSync(calculateRouterRepresentationLimits(SignedMessage.maximumEncodedByteLength));
255
+ const base64UrlLength = (byteLength) => Math.ceil((byteLength * 8) / 6);
256
+ /**
257
+ * Computes exact cursor length for a caller, instance, and order width.
258
+ *
259
+ * @param input Plaintext cursor members.
260
+ * @param input.agentId Caller bound into the encrypted continuation.
261
+ * @param input.routerInstanceId Process bound into the continuation.
262
+ * @param input.lastScannedOrder Private order bound into the continuation.
263
+ * @returns The complete prefixed Compact JWE length.
264
+ */
265
+ export const pollCursorEncodedLength = (input) => {
266
+ const plaintext = canonicalize({
267
+ agentId: input.agentId,
268
+ routerInstanceId: input.routerInstanceId,
269
+ lastScannedOrder: input.lastScannedOrder.toString(10),
270
+ });
271
+ if (plaintext === undefined) {
272
+ return Number.POSITIVE_INFINITY;
273
+ }
274
+ const plaintextLength = utf8Encoder.encode(plaintext).byteLength;
275
+ return (pollCursorPrefix.length +
276
+ encodedPollCursorProtectedHeaderLength +
277
+ 1 +
278
+ 1 +
279
+ 16 +
280
+ 1 +
281
+ base64UrlLength(plaintextLength) +
282
+ 1 +
283
+ 22);
284
+ };
285
+ /** Maximum ASCII characters in a valid PollCursor. */
286
+ export const maximumPollCursorLength = MAXIMUM_CURSOR_LENGTH;
287
+ /** Encoded byte width of a RouterInstanceId payload. */
288
+ export const routerInstanceIdByteLength = INSTANCE_BYTE_LENGTH;
289
+ const cursorSegmentsPattern = new RegExp(`^(?=[\\s\\S]{0,${MAXIMUM_CURSOR_LENGTH}}$)${pollCursorPrefix}([^.]*?)\\.([^.]*?)\\.([^.]*?)\\.([^.]*?)\\.([^.]*?)$`);
290
+ function hasCanonicalCursorShape(value) {
291
+ const segments = extractCursorSegments(value);
292
+ if (segments === undefined || segments.encryptedKey !== "") {
293
+ return false;
294
+ }
295
+ if (segments.encodedHeader !== encodedPollCursorProtectedHeader ||
296
+ !hasCanonicalBase64UrlLength(segments.iv, 12)) {
297
+ return false;
298
+ }
299
+ return (hasCanonicalBase64UrlLength(segments.tag, 16) &&
300
+ hasCanonicalCiphertext(segments.ciphertext));
301
+ }
302
+ function extractCursorSegments(value) {
303
+ const match = cursorSegmentsPattern.exec(value);
304
+ let result;
305
+ if (match !== null) {
306
+ result = {
307
+ encodedHeader: segmentAt(match, 1),
308
+ encryptedKey: segmentAt(match, 2),
309
+ iv: segmentAt(match, 3),
310
+ ciphertext: segmentAt(match, 4),
311
+ tag: segmentAt(match, 5),
312
+ };
313
+ }
314
+ return result;
315
+ }
316
+ function segmentAt(segments, index) {
317
+ return segments[index] ?? "";
318
+ }
319
+ function hasCanonicalBase64UrlLength(value, byteLength) {
320
+ return Either.match(Encoding.decodeBase64Url(value), {
321
+ onLeft: () => false,
322
+ onRight: (decoded) => decoded.byteLength === byteLength &&
323
+ Encoding.encodeBase64Url(decoded) === value,
324
+ });
325
+ }
326
+ function hasCanonicalCiphertext(ciphertext) {
327
+ return Either.match(Encoding.decodeBase64Url(ciphertext), {
328
+ onLeft: () => false,
329
+ onRight: (decoded) => decoded.byteLength > 0 &&
330
+ Encoding.encodeBase64Url(decoded) === ciphertext,
331
+ });
332
+ }
333
+ function canonicalValue(name, prefix, byteLength) {
334
+ return Schema.String.pipe(Schema.filter((value) => {
335
+ const text = value;
336
+ const expectedPrefix = prefix;
337
+ return (text.startsWith(expectedPrefix) &&
338
+ hasCanonicalBase64UrlLength(text.slice(expectedPrefix.length), byteLength));
339
+ }, {
340
+ identifier: name,
341
+ description: `${name} canonical representation`,
342
+ }), Schema.brand(name), Schema.annotations({
343
+ identifier: name,
344
+ description: `${name} canonical representation`,
345
+ }));
346
+ }
347
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/router/contract.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,OAAO,EAGL,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EAEb,gBAAgB,EAChB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExE,gCAAgC;AAChC,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAClD,gCAAgC;AAChC,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAClD,kCAAkC;AAClC,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAE3C,4DAA4D;AAC5D,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAC3D,4DAA4D;AAC5D,MAAM,CAAC,MA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,CAAC"}
@@ -0,0 +1,89 @@
1
+ /** @file Volatile globally ordered Router feed with bounded retention and retry identity. */
2
+ import type { AgentId, MessageId, SignedMessage } from "@moltzap/identity";
3
+ import { Effect } from "effect";
4
+ import type { RouterInstanceId, RouterSendResult, SignedMessageDigest } from "./contract.js";
5
+ /** Greatest private feed order representable by this Router process. */
6
+ export declare const maximumPrivateOrder: bigint;
7
+ /** Stable view used for one poll scan. */
8
+ export interface FeedSnapshot {
9
+ readonly entries: readonly FeedEntry[];
10
+ readonly tailOrder: bigint;
11
+ readonly greatestEvictedOrder: bigint;
12
+ }
13
+ /** Sole capability owning volatile order, retention, and retry identity. */
14
+ export interface RouterFeed {
15
+ readonly accept: (input: FeedCandidate) => Effect.Effect<FeedAcceptResult>;
16
+ readonly snapshot: Effect.Effect<FeedSnapshot>;
17
+ readonly freshAppendReady: Effect.Effect<boolean>;
18
+ }
19
+ interface RouterFeedInput {
20
+ readonly routerInstanceId: RouterInstanceId;
21
+ readonly retainedMessageCapacity: number;
22
+ readonly retainedMessageByteCapacity: number;
23
+ }
24
+ declare const FeedOrderOutOfRangeError_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 & {
25
+ readonly _tag: "FeedOrderOutOfRangeError";
26
+ } & Readonly<A>;
27
+ /** An initial private order is outside the closed unsigned range. */
28
+ export declare class FeedOrderOutOfRangeError extends FeedOrderOutOfRangeError_base {
29
+ }
30
+ /**
31
+ * Creates the sole owner of Router private order, retention, and retry state.
32
+ *
33
+ * @param input Process identity and finite retention bounds.
34
+ * @param input.routerInstanceId Current volatile process identity.
35
+ * @param input.retainedMessageCapacity Maximum retained message count.
36
+ * @param input.retainedMessageByteCapacity Maximum retained message bytes.
37
+ * @returns A scoped state capability for send and poll.
38
+ */
39
+ export declare const makeRouterFeed: (input: RouterFeedInput) => Effect.Effect<RouterFeed>;
40
+ /**
41
+ * Creates a feed over an already-consumed private-order prefix.
42
+ *
43
+ * The prefix is treated as evicted history and must fit the unsigned
44
+ * private-order range.
45
+ *
46
+ * @param input Process identity, finite retention bounds, and consumed order.
47
+ * @returns A scoped state capability for send and poll.
48
+ */
49
+ export declare const makeRouterFeedAtOrder: (input: RouterFeedInput & Readonly<{
50
+ initialTailOrder: bigint;
51
+ }>) => Effect.Effect<RouterFeed, FeedOrderOutOfRangeError>;
52
+ /**
53
+ * Restricts one stable feed snapshot to entries after a private order.
54
+ *
55
+ * @param snapshot Stable feed state for one scan.
56
+ * @param order Exclusive lower private-order bound.
57
+ * @returns Entries with a greater private order.
58
+ */
59
+ export declare const entriesAfter: (snapshot: FeedSnapshot, order: bigint) => readonly FeedEntry[];
60
+ interface FeedEntry {
61
+ readonly order: bigint;
62
+ readonly signedMessage: SignedMessage;
63
+ readonly encodedMessageJcs: string;
64
+ readonly encodedByteLength: number;
65
+ readonly recipients: ReadonlySet<AgentId>;
66
+ readonly senderAgentId: AgentId;
67
+ readonly messageId: MessageId;
68
+ readonly signedMessageDigest: SignedMessageDigest;
69
+ }
70
+ /** Result of one atomic feed acceptance attempt. */
71
+ type FeedAcceptResult = Readonly<{
72
+ kind: "result";
73
+ result: RouterSendResult;
74
+ acceptedRecipients?: ReadonlySet<AgentId>;
75
+ }> | Readonly<{
76
+ kind: "overloaded";
77
+ }>;
78
+ interface FeedCandidate {
79
+ readonly mode: "initial" | "retry";
80
+ readonly signedMessage: SignedMessage;
81
+ readonly encodedMessageJcs: string;
82
+ readonly encodedByteLength: number;
83
+ readonly recipients: ReadonlySet<AgentId>;
84
+ readonly senderAgentId: AgentId;
85
+ readonly messageId: MessageId;
86
+ readonly signedMessageDigest: SignedMessageDigest;
87
+ }
88
+ export {};
89
+ //# sourceMappingURL=feed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feed.d.ts","sourceRoot":"","sources":["../../src/router/feed.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,OAAO,KAA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effect, Ref } from "effect";
2
+ /** Greatest private feed order representable by this Router process. */
3
+ export const maximumPrivateOrder = (1n << 128n) - 1n;
4
+ /** An initial private order is outside the closed unsigned range. */
5
+ export class FeedOrderOutOfRangeError extends Data.TaggedError("FeedOrderOutOfRangeError") {
6
+ }
7
+ /**
8
+ * Creates the sole owner of Router private order, retention, and retry state.
9
+ *
10
+ * @param input Process identity and finite retention bounds.
11
+ * @param input.routerInstanceId Current volatile process identity.
12
+ * @param input.retainedMessageCapacity Maximum retained message count.
13
+ * @param input.retainedMessageByteCapacity Maximum retained message bytes.
14
+ * @returns A scoped state capability for send and poll.
15
+ */
16
+ export const makeRouterFeed = (input) => makeFeed(input, 0n);
17
+ /**
18
+ * Creates a feed over an already-consumed private-order prefix.
19
+ *
20
+ * The prefix is treated as evicted history and must fit the unsigned
21
+ * private-order range.
22
+ *
23
+ * @param input Process identity, finite retention bounds, and consumed order.
24
+ * @returns A scoped state capability for send and poll.
25
+ */
26
+ export const makeRouterFeedAtOrder = (input) => {
27
+ if (input.initialTailOrder < 0n ||
28
+ input.initialTailOrder > maximumPrivateOrder) {
29
+ return Effect.fail(new FeedOrderOutOfRangeError());
30
+ }
31
+ return makeFeed(input, input.initialTailOrder);
32
+ };
33
+ /**
34
+ * Restricts one stable feed snapshot to entries after a private order.
35
+ *
36
+ * @param snapshot Stable feed state for one scan.
37
+ * @param order Exclusive lower private-order bound.
38
+ * @returns Entries with a greater private order.
39
+ */
40
+ export const entriesAfter = (snapshot, order) => snapshot.entries.filter((entry) => entry.order > order);
41
+ const retryKey = (senderAgentId, messageId) => `${senderAgentId}\u0000${messageId}`;
42
+ const makeInitialState = (tailOrder) => ({
43
+ entries: [],
44
+ retryIndex: new Map(),
45
+ retainedBytes: 0,
46
+ tailOrder,
47
+ greatestEvictedOrder: tailOrder,
48
+ });
49
+ const acceptedResult = (routerInstanceId, entry) => ({
50
+ kind: "accepted",
51
+ routerInstanceId,
52
+ signedMessageDigest: entry.signedMessageDigest,
53
+ });
54
+ const retryResult = (routerInstanceId, candidate, retryIndex, key) => {
55
+ const retained = retryIndex.get(key);
56
+ let result;
57
+ if (retained === undefined) {
58
+ result = { kind: "retry_identity_unknown" };
59
+ }
60
+ else if (retained.encodedMessageJcs !== candidate.encodedMessageJcs) {
61
+ result = { kind: "idempotency_conflict" };
62
+ }
63
+ else {
64
+ result = acceptedResult(routerInstanceId, retained);
65
+ }
66
+ return { kind: "result", result };
67
+ };
68
+ const evictUntilWithinBounds = (input) => {
69
+ let retainedBytes = input.initialBytes;
70
+ let greatestEvictedOrder;
71
+ while (input.entries.length > input.countCapacity ||
72
+ retainedBytes > input.byteCapacity) {
73
+ const evicted = input.entries.shift();
74
+ if (evicted === undefined) {
75
+ break;
76
+ }
77
+ retainedBytes -= evicted.encodedByteLength;
78
+ greatestEvictedOrder = evicted.order;
79
+ const key = retryKey(evicted.senderAgentId, evicted.messageId);
80
+ if (input.retryIndex.get(key) === evicted) {
81
+ input.retryIndex.delete(key);
82
+ }
83
+ }
84
+ return greatestEvictedOrder === undefined
85
+ ? { retainedBytes }
86
+ : { retainedBytes, greatestEvictedOrder };
87
+ };
88
+ const appendCandidate = (current, candidate, key, input) => {
89
+ const entry = {
90
+ ...candidate,
91
+ order: current.tailOrder + 1n,
92
+ };
93
+ const entries = [...current.entries, entry];
94
+ const retryIndex = new Map(current.retryIndex);
95
+ retryIndex.set(key, entry);
96
+ const eviction = evictUntilWithinBounds({
97
+ entries,
98
+ retryIndex,
99
+ initialBytes: current.retainedBytes + candidate.encodedByteLength,
100
+ countCapacity: input.retainedMessageCapacity,
101
+ byteCapacity: input.retainedMessageByteCapacity,
102
+ });
103
+ const next = {
104
+ entries,
105
+ retryIndex,
106
+ retainedBytes: eviction.retainedBytes,
107
+ tailOrder: entry.order,
108
+ greatestEvictedOrder: eviction.greatestEvictedOrder ?? current.greatestEvictedOrder,
109
+ };
110
+ return [
111
+ {
112
+ kind: "result",
113
+ result: acceptedResult(input.routerInstanceId, entry),
114
+ acceptedRecipients: entry.recipients,
115
+ },
116
+ next,
117
+ ];
118
+ };
119
+ const modifyFeed = (current, candidate, input) => {
120
+ const key = retryKey(candidate.senderAgentId, candidate.messageId);
121
+ const retained = current.retryIndex.get(key);
122
+ if (candidate.mode === "retry") {
123
+ return [
124
+ retryResult(input.routerInstanceId, candidate, current.retryIndex, key),
125
+ current,
126
+ ];
127
+ }
128
+ if (retained !== undefined) {
129
+ return [
130
+ {
131
+ kind: "result",
132
+ result: { kind: "idempotency_conflict" },
133
+ },
134
+ current,
135
+ ];
136
+ }
137
+ if (current.tailOrder === maximumPrivateOrder) {
138
+ return [{ kind: "overloaded" }, current];
139
+ }
140
+ return appendCandidate(current, candidate, key, input);
141
+ };
142
+ function makeFeed(input, initialTailOrder) {
143
+ return Effect.gen(function* () {
144
+ const state = yield* Ref.make(makeInitialState(initialTailOrder));
145
+ const service = {
146
+ accept: (candidate) => Ref.modify(state, (current) => modifyFeed(current, candidate, input)),
147
+ snapshot: Ref.get(state).pipe(Effect.map((current) => ({
148
+ entries: current.entries,
149
+ tailOrder: current.tailOrder,
150
+ greatestEvictedOrder: current.greatestEvictedOrder,
151
+ }))),
152
+ freshAppendReady: Ref.get(state).pipe(Effect.map((current) => current.tailOrder < maximumPrivateOrder)),
153
+ };
154
+ return Object.freeze(service);
155
+ }).pipe(Effect.withSpan("makeRouterFeed"));
156
+ }
157
+ //# sourceMappingURL=feed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feed.js","sourceRoot":"","sources":["../../src/router/feed.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAO3C,wEAAwE;AACxE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;AAsBrD,qEAAqE;AACrE,MAAM,OAAO,wBAAyB,SAAQ,IAAI,CAAC,WAAW,CAC5D,0BAA0B,CAC3B;CAAG;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GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAC3B,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;gBACvB,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;aACnD,CAAC,CAAC,CACJ;YACD,gBAAgB,EAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CACnC,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,GAAG,mBAAmB,CAAC,CACjE;SACF,CAAC;QACF,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,30 @@
1
+ /** @file Authenticated Router HTTP routes and exact envelope projection. */
2
+ import { HttpRouter, HttpServerResponse } from "@effect/platform";
3
+ import { AuthenticatedHttp } from "@moltzap/identity";
4
+ import { Effect } from "effect";
5
+ import type { RouterFeed } from "./feed.js";
6
+ import { type RouterRpcClient } from "./rpc.js";
7
+ interface RouterHttpInput {
8
+ readonly client: RouterRpcClient;
9
+ readonly feed: RouterFeed;
10
+ readonly requestSemaphore: Effect.Semaphore;
11
+ }
12
+ /**
13
+ * Builds the complete Router HTTP application over private capabilities.
14
+ *
15
+ * @param input Correlated operations, readiness, and admission capability.
16
+ * @param input.client Private correlated operations.
17
+ * @param input.feed Feed readiness state.
18
+ * @param input.requestSemaphore Immediate active-request admission.
19
+ * @returns The complete named-route HTTP application.
20
+ */
21
+ export declare const makeRouterHttpApp: (input: RouterHttpInput) => HttpRouter.HttpRouter<never, AuthenticatedHttp>;
22
+ /**
23
+ * Reports local readiness without exposing feed state.
24
+ *
25
+ * @param feed Current process feed.
26
+ * @returns An empty 204 or 503 response.
27
+ */
28
+ export declare const routerHealthResponse: (feed: RouterFeed) => Effect.Effect<HttpServerResponse.HttpServerResponse>;
29
+ export {};
30
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/router/http.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,OAAO,EACL,UAAU,EAEV,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,iBAAiB,EAQlB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAS,MAAM,EAAkB,MAAM,QAAQ,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAgB5C,OAAO,EAAE,KAAK,eAAe,EAA6B,MAAM,UAAU,CAAC;AAE3E,UAAU,eAAe;IACvB,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC,SAAS,CAAC;CAC7C;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,UAAW,eAAe,oDAMrD,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,SACzB,UAAU,KACf,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,kBAAkB,CAKnD,CAAC"}