@rotorsoft/act 0.43.0 → 0.45.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.
- package/README.md +87 -379
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/act.d.ts +43 -5
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/adapters/console-logger.d.ts.map +1 -1
- package/dist/@types/adapters/in-memory-store.d.ts +22 -2
- package/dist/@types/adapters/in-memory-store.d.ts.map +1 -1
- package/dist/@types/builders/act-builder.d.ts +33 -9
- package/dist/@types/builders/act-builder.d.ts.map +1 -1
- package/dist/@types/builders/slice-builder.d.ts +23 -8
- package/dist/@types/builders/slice-builder.d.ts.map +1 -1
- package/dist/@types/internal/build-classify.d.ts +20 -0
- package/dist/@types/internal/build-classify.d.ts.map +1 -1
- package/dist/@types/internal/correlate-cycle.d.ts +1 -0
- package/dist/@types/internal/correlate-cycle.d.ts.map +1 -1
- package/dist/@types/internal/drain-cycle.d.ts +43 -3
- package/dist/@types/internal/drain-cycle.d.ts.map +1 -1
- package/dist/@types/internal/drain.d.ts +3 -1
- package/dist/@types/internal/drain.d.ts.map +1 -1
- package/dist/@types/internal/index.d.ts +3 -2
- package/dist/@types/internal/index.d.ts.map +1 -1
- package/dist/@types/internal/reactions.d.ts.map +1 -1
- package/dist/@types/internal/tracing.d.ts +51 -0
- package/dist/@types/internal/tracing.d.ts.map +1 -1
- package/dist/@types/ports.d.ts +10 -0
- package/dist/@types/ports.d.ts.map +1 -1
- package/dist/@types/test/sandbox.d.ts +1 -1
- package/dist/@types/test/sandbox.d.ts.map +1 -1
- package/dist/@types/types/ports.d.ts +203 -2
- package/dist/@types/types/ports.d.ts.map +1 -1
- package/dist/@types/types/reaction.d.ts +20 -2
- package/dist/@types/types/reaction.d.ts.map +1 -1
- package/dist/{chunk-QAB4SDOS.js → chunk-PGTC7VOC.js} +117 -11
- package/dist/chunk-PGTC7VOC.js.map +1 -0
- package/dist/index.cjs +1217 -897
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1108 -893
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs +116 -11
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.js +3 -3
- package/dist/test/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-QAB4SDOS.js.map +0 -1
|
@@ -27,13 +27,15 @@ export interface DrainOps<TEvents extends Schemas> {
|
|
|
27
27
|
block: typeof block;
|
|
28
28
|
subscribe: typeof subscribe;
|
|
29
29
|
}
|
|
30
|
-
export declare const claim: (lagging: number, leading: number, by: string, millis: number) => Promise<Lease[]>;
|
|
30
|
+
export declare const claim: (lagging: number, leading: number, by: string, millis: number, lane?: string) => Promise<Lease[]>;
|
|
31
31
|
export declare function fetch<TEvents extends Schemas>(leased: Lease[], eventLimit: number): Promise<Fetch<TEvents>>;
|
|
32
32
|
export declare const ack: (leases: Lease[]) => Promise<Lease[]>;
|
|
33
33
|
export declare const block: (leases: BlockedLease[]) => Promise<BlockedLease[]>;
|
|
34
34
|
export declare const subscribe: (streams: Array<{
|
|
35
35
|
stream: string;
|
|
36
36
|
source?: string;
|
|
37
|
+
priority?: number;
|
|
38
|
+
lane?: string;
|
|
37
39
|
}>) => Promise<{
|
|
38
40
|
subscribed: number;
|
|
39
41
|
watermark: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drain.d.ts","sourceRoot":"","sources":["../../../src/internal/drain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EACV,YAAY,EAEZ,KAAK,EACL,KAAK,EACL,OAAO,EACR,MAAM,mBAAmB,CAAC;AAE3B,gBAAgB;AAChB,MAAM,WAAW,QAAQ,CAAC,OAAO,SAAS,OAAO;IAC/C,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,KAAK,EAAE,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7B,GAAG,EAAE,OAAO,GAAG,CAAC;I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AC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC,KACD,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CACxB,CAAC"}
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
19
|
-
export {
|
|
19
|
+
export type { EventLaneSet } from "./build-classify.js";
|
|
20
|
+
export { ALL_LANES, classifyRegistry } from "./build-classify.js";
|
|
20
21
|
export { runCloseCycle } from "./close-cycle.js";
|
|
21
22
|
export { CorrelateCycle } from "./correlate-cycle.js";
|
|
22
23
|
export { closeCorrelation, defaultCorrelator } from "./correlator.js";
|
|
@@ -27,5 +28,5 @@ export { currentVersionOf, deprecatedEventNames, } from "./event-versions.js";
|
|
|
27
28
|
export { _this_, mergeEventRegister, mergeProjection, registerState, } from "./merge.js";
|
|
28
29
|
export { buildHandle, buildHandleBatch } from "./reactions.js";
|
|
29
30
|
export { SettleLoop } from "./settle.js";
|
|
30
|
-
export { buildDrain, buildEs } from "./tracing.js";
|
|
31
|
+
export { buildDrain, buildEs, traceCycle } from "./tracing.js";
|
|
31
32
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/internal/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/internal/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,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aAAa,CAAC,CAAC;CAC1E,CAAC;AAmDF;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,OAAO,SAAS,OAAO,EACvB,QAAQ,SAAS,OAAO,EACxB,MAAM,SAAS,KAAK,GAAG,KAAK,EAC5B,IAAI,EAAE,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAqDhE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,OAAO,EACtD,MAAM,EAAE,MAAM,GACb,WAAW,CAAC,OAAO,CAAC,CA2BtB"}
|
|
@@ -42,4 +42,55 @@ export declare function buildEs(logger: Logger, correlator?: Correlator): EsOps;
|
|
|
42
42
|
* @internal
|
|
43
43
|
*/
|
|
44
44
|
export declare function buildDrain<TEvents extends Schemas>(logger: Logger): DrainOps<TEvents>;
|
|
45
|
+
/**
|
|
46
|
+
* Emit one cycle-level drain trace summarizing what happened in a
|
|
47
|
+
* single `runDrainCycle` pass. Per-stream rendering shape — outcome +
|
|
48
|
+
* post-state anchored on the right:
|
|
49
|
+
*
|
|
50
|
+
* stream<-source [events] ✓ @<acked-at> — full success
|
|
51
|
+
* stream<-source [events] ✗ @<failed-at>/<retry> (error) — total failure → blocked
|
|
52
|
+
* stream<-source [events] ⚠ @<failed-at>/<retry> (error) — total failure → retrying
|
|
53
|
+
* stream<-source [events] ✓ @<acked-at> ✗ @<failed-at>/<retry> (error) — partial then blocked
|
|
54
|
+
* stream<-source [events] ✓ @<acked-at> ⚠ @<failed-at>/<retry> (error) — partial then retrying
|
|
55
|
+
* stream<-source ⊘ @<at>/<retry> — deferred (backoff)
|
|
56
|
+
*
|
|
57
|
+
* Partial-success-then-failure is the dual-outcome case: events
|
|
58
|
+
* 1..K succeeded (watermark advanced to K), event K+1 threw. The
|
|
59
|
+
* trace renders both the lime `✓ @K` and the red/amber `✗`/`⚠ @K+1`
|
|
60
|
+
* on the same line so an operator sees "we made progress *and* then
|
|
61
|
+
* something broke" at a glance.
|
|
62
|
+
*
|
|
63
|
+
* Lane prefixes the caption in lilac when non-default. The outcome
|
|
64
|
+
* marker and its adjacent post-state share the marker's color so the
|
|
65
|
+
* eye reads "outcome + where it landed" as one unit. Per-stream
|
|
66
|
+
* `[events]` and `(error)` stay dim — secondary context.
|
|
67
|
+
*
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
export declare function traceCycle<TEvents extends Schemas>(logger: Logger, leased: ReadonlyArray<{
|
|
71
|
+
readonly stream: string;
|
|
72
|
+
readonly at: number;
|
|
73
|
+
readonly retry: number;
|
|
74
|
+
readonly lane?: string;
|
|
75
|
+
}>, fetched: ReadonlyArray<{
|
|
76
|
+
readonly stream: string;
|
|
77
|
+
readonly source?: string;
|
|
78
|
+
readonly events: ReadonlyArray<{
|
|
79
|
+
readonly id: number;
|
|
80
|
+
readonly name: keyof TEvents;
|
|
81
|
+
}>;
|
|
82
|
+
}>, handled: ReadonlyArray<{
|
|
83
|
+
readonly lease: {
|
|
84
|
+
readonly stream: string;
|
|
85
|
+
};
|
|
86
|
+
readonly error?: string;
|
|
87
|
+
readonly block?: boolean;
|
|
88
|
+
readonly failed_at?: number;
|
|
89
|
+
}>, acked: ReadonlyArray<{
|
|
90
|
+
readonly stream: string;
|
|
91
|
+
readonly at: number;
|
|
92
|
+
}>, blocked: ReadonlyArray<{
|
|
93
|
+
readonly stream: string;
|
|
94
|
+
readonly error: string;
|
|
95
|
+
}>): void;
|
|
45
96
|
//# sourceMappingURL=tracing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../../src/internal/tracing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,KAAK,EAAQ,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE3E,OAAO,KAAK,EAAE,QAAQ,EAA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C;CACJ,CAAC,EACF,OAAO,EAAE,aAAa,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC,EACF,KAAK,EAAE,aAAa,CAAC;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,EACtE,OAAO,EAAE,aAAa,CAAC;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GAC1E,IAAI,CAyDN"}
|
package/dist/@types/ports.d.ts
CHANGED
|
@@ -151,5 +151,15 @@ export declare const SNAP_EVENT = "__snapshot__";
|
|
|
151
151
|
* @see {@link Act.close} for the close-the-books API
|
|
152
152
|
*/
|
|
153
153
|
export declare const TOMBSTONE_EVENT = "__tombstone__";
|
|
154
|
+
/**
|
|
155
|
+
* Name of the implicit lane every reaction lands in unless its `.to({lane})`
|
|
156
|
+
* declaration says otherwise (ACT-1103). Acts that don't call
|
|
157
|
+
* `.withLane(...)` see only this lane, and behavior is identical to
|
|
158
|
+
* pre-1103 single-controller drain.
|
|
159
|
+
*
|
|
160
|
+
* Persisted on `streams.lane` and threaded as the strict-typed default in
|
|
161
|
+
* builder generics — `lane?: TLanes` always includes `"default"`.
|
|
162
|
+
*/
|
|
163
|
+
export declare const DEFAULT_LANE = "default";
|
|
154
164
|
export {};
|
|
155
165
|
//# sourceMappingURL=ports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/ports.ts"],"names":[],"mappings":"AA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,eAAO,MAAM,GAAG,0EASd,CAAC;AA4CH,eAAO,MAAM,KAAK,EAEZ,CAAC,OAAO,CAAC,EAAE,KAAK,KAAK,KAAK,CAAC;AAmBjC,eAAO,MAAM,KAAK,EAEZ,CAAC,OAAO,CAAC,EAAE,KAAK,KAAK,KAAK,CAAC;AASjC;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAAC,IAAI,GAAE,QAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB3E;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,OAAO,CACrB,QAAQ,CAAC,EAAE,QAAQ,GAClB,CAAC,IAAI,CAAC,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAGpC;AAMD;;;;GAIG;AACH,eAAO,MAAM,UAAU,iBAAiB,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,kBAAkB,CAAC;AAE/C;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,YAAY,CAAC"}
|
|
@@ -7,7 +7,7 @@ import type { Cache, Store } from "../types/index.js";
|
|
|
7
7
|
* generic when called across package boundaries.
|
|
8
8
|
*/
|
|
9
9
|
type AnyActBuilder<TApp> = {
|
|
10
|
-
build: (options?: ActOptions) => TApp;
|
|
10
|
+
build: (options?: ActOptions<any>) => TApp;
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* Options for {@link sandbox} / {@link fixture}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../../src/test/sandbox.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAO,UAAU,EAAE,MAAM,WAAW,CAAC;AAGjD,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;;;;GAKG;AACH,KAAK,aAAa,CAAC,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"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AAO,CAAC,IAAI,EAC1B,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC,EAC5B,QAAQ,GAAE,cAAmB;;GAgB9B"}
|
|
@@ -101,6 +101,7 @@ export type NotifyDisposer = () => void | Promise<void>;
|
|
|
101
101
|
* @property leased_until - Lease expiration timestamp (when leased)
|
|
102
102
|
* @property priority - Scheduling priority (default 0). Biases the
|
|
103
103
|
* lagging-frontier `claim()` ordering — see {@link Store.prioritize}.
|
|
104
|
+
* @property lane - Drain lane bound to the stream (ACT-1103)
|
|
104
105
|
*/
|
|
105
106
|
export type StreamPosition = {
|
|
106
107
|
readonly stream: string;
|
|
@@ -112,6 +113,7 @@ export type StreamPosition = {
|
|
|
112
113
|
readonly priority: number;
|
|
113
114
|
readonly leased_by?: string;
|
|
114
115
|
readonly leased_until?: Date;
|
|
116
|
+
readonly lane?: string;
|
|
115
117
|
};
|
|
116
118
|
/**
|
|
117
119
|
* Filter options for {@link Store.query_streams}.
|
|
@@ -143,6 +145,7 @@ export type StreamPosition = {
|
|
|
143
145
|
* `source`.
|
|
144
146
|
* @property blocked - Restrict to blocked (`true`) or unblocked (`false`)
|
|
145
147
|
* streams. Omit for all.
|
|
148
|
+
* @property lane - Restrict to streams in this drain lane (ACT-1103). Exact match.
|
|
146
149
|
* @property after - Keyset pagination cursor: returns only streams with
|
|
147
150
|
* `stream > after` (lexicographic). Pass the last seen `stream` to fetch
|
|
148
151
|
* the next page.
|
|
@@ -154,6 +157,7 @@ export type QueryStreams = {
|
|
|
154
157
|
readonly source?: string;
|
|
155
158
|
readonly source_exact?: boolean;
|
|
156
159
|
readonly blocked?: boolean;
|
|
160
|
+
readonly lane?: string;
|
|
157
161
|
readonly after?: string;
|
|
158
162
|
readonly limit?: number;
|
|
159
163
|
};
|
|
@@ -187,13 +191,103 @@ export type QueryStreamsResult = {
|
|
|
187
191
|
* @property blocked - Restrict to blocked / unblocked streams. Omit
|
|
188
192
|
* for both.
|
|
189
193
|
*/
|
|
190
|
-
export type StreamFilter = Pick<QueryStreams, "stream" | "stream_exact" | "source" | "source_exact" | "blocked">;
|
|
194
|
+
export type StreamFilter = Pick<QueryStreams, "stream" | "stream_exact" | "source" | "source_exact" | "blocked" | "lane">;
|
|
191
195
|
/**
|
|
192
196
|
* Alias of {@link StreamFilter}. Retained for backward compatibility
|
|
193
197
|
* with code that imports the filter by its prioritize-specific name.
|
|
194
198
|
* Prefer `StreamFilter` for new code.
|
|
195
199
|
*/
|
|
196
200
|
export type PrioritizeFilter = StreamFilter;
|
|
201
|
+
/**
|
|
202
|
+
* Framework-internal event names — written by the runtime, not by user
|
|
203
|
+
* code. Snapshots are seeded by `truncate()`; tombstones by `close()`.
|
|
204
|
+
*
|
|
205
|
+
* Kept as a literal-string union here (rather than re-exported from
|
|
206
|
+
* `../ports.js` where the runtime constants live) so {@link QueryStatsOptions.exclude}
|
|
207
|
+
* can be type-checked without inducing a `types/` → `ports.ts` cycle.
|
|
208
|
+
* The runtime constants {@link "../ports.js".SNAP_EVENT | SNAP_EVENT} and
|
|
209
|
+
* {@link "../ports.js".TOMBSTONE_EVENT | TOMBSTONE_EVENT} (exported from
|
|
210
|
+
* `@rotorsoft/act`) are the typed source of truth; this union mirrors
|
|
211
|
+
* them at the type level.
|
|
212
|
+
*/
|
|
213
|
+
export type FrameworkEventName = "__snapshot__" | "__tombstone__";
|
|
214
|
+
/**
|
|
215
|
+
* Union of all event names valid for a given schema set: user-declared
|
|
216
|
+
* event names plus the framework-internal markers. Used by
|
|
217
|
+
* {@link QueryStatsOptions.exclude} so callers can mix domain events and
|
|
218
|
+
* framework markers in the same filter list without `as string` casts
|
|
219
|
+
* or stringly-typed mistakes (e.g. `"__tombsotne__"` typos fail at
|
|
220
|
+
* compile time).
|
|
221
|
+
*
|
|
222
|
+
* @template E - Event schemas; defaults to {@link Schemas}.
|
|
223
|
+
*/
|
|
224
|
+
export type EventName<E extends Schemas = Schemas> = (keyof E & string) | FrameworkEventName;
|
|
225
|
+
/**
|
|
226
|
+
* Per-stream aggregated stats returned by {@link Store.query_stats}.
|
|
227
|
+
*
|
|
228
|
+
* `head` and `tail` follow the **git-log convention**, not the Unix
|
|
229
|
+
* `head`/`tail` convention:
|
|
230
|
+
* - `head` — the **latest** event (highest id), always present.
|
|
231
|
+
* - `tail` — the **earliest** event (lowest id), opt-in via
|
|
232
|
+
* {@link QueryStatsOptions.tail}.
|
|
233
|
+
*
|
|
234
|
+
* @template E - Event schemas; defaults to {@link Schemas} when the caller
|
|
235
|
+
* does not narrow.
|
|
236
|
+
* @property head - Latest non-excluded event for the stream.
|
|
237
|
+
* @property tail - Earliest non-excluded event for the stream, when
|
|
238
|
+
* `options.tail` is true.
|
|
239
|
+
* @property count - Total non-excluded event count for the stream, when
|
|
240
|
+
* `options.count` is true.
|
|
241
|
+
* @property names - Sparse map of event name → count of events with
|
|
242
|
+
* that name, when `options.names` is true. Keys are typed as
|
|
243
|
+
* {@link EventName | EventName<E>} so typos on lookup
|
|
244
|
+
* (e.g. `stats.names?.["TicktOpened"]`) fail at compile time when the
|
|
245
|
+
* caller narrows `E`. Empty object never returned — a stream with no
|
|
246
|
+
* matching events is absent from the result map entirely.
|
|
247
|
+
*/
|
|
248
|
+
export type StreamStats<E extends Schemas = Schemas> = {
|
|
249
|
+
readonly head: Committed<E, keyof E>;
|
|
250
|
+
readonly tail?: Committed<E, keyof E>;
|
|
251
|
+
readonly count?: number;
|
|
252
|
+
readonly names?: Readonly<Partial<Record<EventName<E>, number>>>;
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* Options for {@link Store.query_stats}. All stat fields default to
|
|
256
|
+
* `false` except `head`, which is always returned.
|
|
257
|
+
*
|
|
258
|
+
* **Cost model:** With no opt-in flags (or `tail` alone), each requested
|
|
259
|
+
* stat resolves via an index-backed lookup — O(K) cost where K is the
|
|
260
|
+
* number of matched streams. Setting `count` and/or `names` triggers a
|
|
261
|
+
* full event scan over the matched streams (O(N) where N is total events);
|
|
262
|
+
* both share the same scan and so requesting one is the same cost as
|
|
263
|
+
* requesting both.
|
|
264
|
+
*
|
|
265
|
+
* @template E - Event schemas; defaults to {@link Schemas}. When the caller
|
|
266
|
+
* narrows `E`, `exclude` is type-checked against the schema's event names
|
|
267
|
+
* — typos like `["TOMBSTON_EVENT"]` fail at compile time.
|
|
268
|
+
* @property tail - Include the earliest non-excluded event per stream.
|
|
269
|
+
* Cheap when alone (indexed); free when `count`/`names` also set
|
|
270
|
+
* (already scanning).
|
|
271
|
+
* @property count - Include the total non-excluded event count per stream.
|
|
272
|
+
* Triggers full scan.
|
|
273
|
+
* @property names - Include a `name → count` map per stream. Triggers
|
|
274
|
+
* full scan (shares cost with `count`).
|
|
275
|
+
* @property exclude - Event names to skip — e.g.
|
|
276
|
+
* `[TOMBSTONE_EVENT, SNAP_EVENT]` to ignore framework markers. Applies
|
|
277
|
+
* to all returned stats (head, tail, count, names) consistently.
|
|
278
|
+
* @property before - Time-travel cutoff: only consider events with
|
|
279
|
+
* `id < before`. Omitted = current state. Useful for "what did this
|
|
280
|
+
* stream look like at event N?" historical queries without changing
|
|
281
|
+
* the call shape. Cheap on both code paths (cheap-heads path narrows
|
|
282
|
+
* the index scan; full-scan path adds a `WHERE id < ?` predicate).
|
|
283
|
+
*/
|
|
284
|
+
export type QueryStatsOptions<E extends Schemas = Schemas> = {
|
|
285
|
+
readonly tail?: boolean;
|
|
286
|
+
readonly count?: boolean;
|
|
287
|
+
readonly names?: boolean;
|
|
288
|
+
readonly exclude?: ReadonlyArray<EventName<E>>;
|
|
289
|
+
readonly before?: number;
|
|
290
|
+
};
|
|
197
291
|
/**
|
|
198
292
|
* Interface for event store implementations.
|
|
199
293
|
*
|
|
@@ -334,6 +428,7 @@ export interface Store extends Disposable {
|
|
|
334
428
|
* @param leading - Max streams from the leading frontier (descending watermark)
|
|
335
429
|
* @param by - Unique lease holder identifier (UUID)
|
|
336
430
|
* @param millis - Lease duration in milliseconds
|
|
431
|
+
* @param lane - Optional lane filter (ACT-1103)
|
|
337
432
|
* @returns Array of successfully leased streams with metadata
|
|
338
433
|
*
|
|
339
434
|
* @example
|
|
@@ -348,7 +443,7 @@ export interface Store extends Disposable {
|
|
|
348
443
|
* @see {@link ack} for acknowledging completion
|
|
349
444
|
* @see {@link block} for blocking failed streams
|
|
350
445
|
*/
|
|
351
|
-
claim: (lagging: number, leading: number, by: string, millis: number) => Promise<Lease[]>;
|
|
446
|
+
claim: (lagging: number, leading: number, by: string, millis: number, lane?: string) => Promise<Lease[]>;
|
|
352
447
|
/**
|
|
353
448
|
* Registers streams for event processing.
|
|
354
449
|
*
|
|
@@ -384,6 +479,8 @@ export interface Store extends Disposable {
|
|
|
384
479
|
* overrides that ignore this max — operator-driven changes.
|
|
385
480
|
*/
|
|
386
481
|
priority?: number;
|
|
482
|
+
/** Drain lane (ACT-1103). Adapter UPSERTs on every subscribe. */
|
|
483
|
+
lane?: string;
|
|
387
484
|
}>) => Promise<{
|
|
388
485
|
subscribed: number;
|
|
389
486
|
watermark: number;
|
|
@@ -632,6 +729,110 @@ export interface Store extends Disposable {
|
|
|
632
729
|
* ```
|
|
633
730
|
*/
|
|
634
731
|
query_streams: (callback: (position: StreamPosition) => void, query?: QueryStreams) => Promise<QueryStreamsResult>;
|
|
732
|
+
/**
|
|
733
|
+
* Per-stream aggregated stats — single round trip per adapter.
|
|
734
|
+
*
|
|
735
|
+
* Returns the latest event (`head`) plus opt-in extras (`tail`, `count`,
|
|
736
|
+
* `names`) for each stream selected by `input`. Streams with no
|
|
737
|
+
* qualifying events are absent from the result map.
|
|
738
|
+
*
|
|
739
|
+
* **Cost model.** With no opt-in flags, the call uses an index-backed
|
|
740
|
+
* head lookup per stream — O(K) where K is the number of matched
|
|
741
|
+
* streams. `tail` alone stays in the cheap tier. Setting `count` and/or
|
|
742
|
+
* `names` triggers a full event scan over the matched streams (O(N)
|
|
743
|
+
* where N is total events); both stats share that scan, so requesting
|
|
744
|
+
* one or both is the same cost.
|
|
745
|
+
*
|
|
746
|
+
* **`input`.** Either an explicit `string[]` of stream names, or a
|
|
747
|
+
* narrow event-stream selector `{ stream?, stream_exact? }` for
|
|
748
|
+
* pattern-based or exact-name matching. **Subscription-level filters
|
|
749
|
+
* (`source`, `blocked`) are intentionally not accepted here** — they
|
|
750
|
+
* describe subscriptions, not events, and conflating the two would
|
|
751
|
+
* silently exclude unsubscribed event streams. For
|
|
752
|
+
* "stats for all blocked subscriptions" compose explicitly:
|
|
753
|
+
* `query_streams({blocked: true})` → collect names → `query_stats(names)`.
|
|
754
|
+
*
|
|
755
|
+
* **`head` vs `tail` naming.** Follows the git-log convention: `head`
|
|
756
|
+
* is the latest event (highest id), `tail` is the earliest (lowest id).
|
|
757
|
+
* This is the **opposite** of the Unix `head`/`tail` commands.
|
|
758
|
+
*
|
|
759
|
+
* **Framework markers.** Snapshots (`__snapshot__`) and tombstones
|
|
760
|
+
* (`__tombstone__`) are real events and are included by default —
|
|
761
|
+
* intentional, so schema-evolution tooling can count them. To exclude
|
|
762
|
+
* them, pass them in `options.exclude` (typed against {@link EventName})
|
|
763
|
+
* so typos are compile-time errors.
|
|
764
|
+
*
|
|
765
|
+
* **Snapshot counts come from `names`.** When `names: true` and snapshots
|
|
766
|
+
* are not in `exclude`, `result.names["__snapshot__"]` is the snapshot
|
|
767
|
+
* count for that stream — no separate field needed. Validates snapshot
|
|
768
|
+
* policy at scale: `names["__snapshot__"] / count` should match the
|
|
769
|
+
* configured snap predicate's expected ratio.
|
|
770
|
+
*
|
|
771
|
+
* **Time travel.** `options.before` narrows to events with `id < before`,
|
|
772
|
+
* answering "what did this stream look like at event N?" without
|
|
773
|
+
* special call shape.
|
|
774
|
+
*
|
|
775
|
+
* @example Cheap heads — close-cycle pattern (one round trip, no scan)
|
|
776
|
+
* ```typescript
|
|
777
|
+
* const stats = await store().query_stats(streams, {
|
|
778
|
+
* exclude: [TOMBSTONE_EVENT],
|
|
779
|
+
* });
|
|
780
|
+
* for (const [stream, { head }] of stats) {
|
|
781
|
+
* // head.id, head.version, head.name
|
|
782
|
+
* }
|
|
783
|
+
* ```
|
|
784
|
+
*
|
|
785
|
+
* @example Full stats — inspector / admin dashboard (one full scan)
|
|
786
|
+
* ```typescript
|
|
787
|
+
* const stats = await store().query_stats<MyEvents>(
|
|
788
|
+
* { stream: "^orders-" },
|
|
789
|
+
* { count: true, tail: true, names: true,
|
|
790
|
+
* exclude: [TOMBSTONE_EVENT] }
|
|
791
|
+
* );
|
|
792
|
+
* for (const [stream, s] of stats) {
|
|
793
|
+
* const snaps = s.names?.[SNAP_EVENT] ?? 0;
|
|
794
|
+
* const domain = (s.count ?? 0) - snaps;
|
|
795
|
+
* console.log(stream, { snaps, domain, tail: s.tail?.created });
|
|
796
|
+
* }
|
|
797
|
+
* ```
|
|
798
|
+
*
|
|
799
|
+
* @example Schema-evolution — surface deprecated events per stream
|
|
800
|
+
* ```typescript
|
|
801
|
+
* const stats = await store().query_stats<TicketEvents>(
|
|
802
|
+
* { stream: "^ticket-" },
|
|
803
|
+
* { names: true }
|
|
804
|
+
* );
|
|
805
|
+
* for (const [stream, { names = {} }] of stats) {
|
|
806
|
+
* if ((names["TicketOpened"] ?? 0) > 0) {
|
|
807
|
+
* console.log(`${stream}: ${names["TicketOpened"]} legacy events`);
|
|
808
|
+
* }
|
|
809
|
+
* }
|
|
810
|
+
* ```
|
|
811
|
+
*
|
|
812
|
+
* @example Time travel — stream state at a historical cutoff
|
|
813
|
+
* ```typescript
|
|
814
|
+
* const stats = await store().query_stats(["order-42"], {
|
|
815
|
+
* before: 100_000, // events up to (not including) id 100000
|
|
816
|
+
* tail: true,
|
|
817
|
+
* });
|
|
818
|
+
* const { head, tail } = stats.get("order-42") ?? {};
|
|
819
|
+
* // head = latest event with id < 100_000; tail = earliest in range
|
|
820
|
+
* ```
|
|
821
|
+
*
|
|
822
|
+
* @template E - Event schemas. Narrow at the call site to type-check
|
|
823
|
+
* `exclude` against your event names (typos fail at compile time).
|
|
824
|
+
*
|
|
825
|
+
* @param input - Stream names or a filter selecting the streams to stat.
|
|
826
|
+
* @param options - Opt-in stat fields, event-name exclusions, and
|
|
827
|
+
* time-travel cutoff. See {@link QueryStatsOptions}.
|
|
828
|
+
* @returns Map keyed by stream name. Streams with no qualifying events
|
|
829
|
+
* (after `exclude` and `before` are applied) are absent.
|
|
830
|
+
*
|
|
831
|
+
* @see {@link QueryStatsOptions} for the cost-aware option surface
|
|
832
|
+
* @see {@link StreamStats} for the per-stream result shape
|
|
833
|
+
* @see {@link EventName} for the typed exclude entries
|
|
834
|
+
*/
|
|
835
|
+
query_stats: <E extends Schemas>(input: string[] | Pick<StreamFilter, "stream" | "stream_exact">, options?: QueryStatsOptions<E>) => Promise<Map<string, StreamStats<E>>>;
|
|
635
836
|
/**
|
|
636
837
|
* Optional cross-process commit notifications.
|
|
637
838
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../../src/types/ports.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,OAAO,EACP,KAAK,EACL,MAAM,EACN,OAAO,EACR,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEzD;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;AAE3C;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;AAM/C;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,MAAO,SAAQ,UAAU;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAA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AAiB,CAAC,CAAC,CAAC,KAC3B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,MAAM,CAAC,EAAE,CACP,OAAO,EAAE,CAAC,YAAY,EAAE,iBAAiB,KAAK,IAAI,KAC/C,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAC/C;AAMD;;;;GAIG;AACH,MAAM,WAAW,UAAU,CAAC,MAAM,SAAS,MAAM;IAC/C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,KAAM,SAAQ,UAAU;IACvC,GAAG,CAAC,MAAM,SAAS,MAAM,EACvB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC;IAC3C,GAAG,CAAC,MAAM,SAAS,MAAM,EACvB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,GACxB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
|
|
@@ -93,7 +93,7 @@ export type ReactionHandler<TEvents extends Schemas, TKey extends keyof TEvents,
|
|
|
93
93
|
* @see {@link Reaction} for complete reaction configuration
|
|
94
94
|
* @see {@link Resolved} for the resolved-target shape
|
|
95
95
|
*/
|
|
96
|
-
export type ReactionResolver<TEvents extends Schemas, TKey extends keyof TEvents> = Resolved | ((event: Committed<TEvents, TKey>) => Resolved | undefined);
|
|
96
|
+
export type ReactionResolver<TEvents extends Schemas, TKey extends keyof TEvents, TLane extends string = string> = Resolved<TLane> | ((event: Committed<TEvents, TKey>) => Resolved<TLane> | undefined);
|
|
97
97
|
/**
|
|
98
98
|
* Resolver output shape — what `.to(...)` returns for a static or dynamic
|
|
99
99
|
* resolver.
|
|
@@ -108,11 +108,27 @@ export type ReactionResolver<TEvents extends Schemas, TKey extends keyof TEvents
|
|
|
108
108
|
* than the worker can claim per cycle); idle systems are unaffected.
|
|
109
109
|
* See `libs/act-pg/PERFORMANCE.md` for the benchmark that motivated this
|
|
110
110
|
* knob.
|
|
111
|
+
* @property lane - Optional drain lane (ACT-1103). Defaults to `"default"`.
|
|
111
112
|
*/
|
|
112
|
-
export type Resolved = {
|
|
113
|
+
export type Resolved<TLane extends string = string> = {
|
|
113
114
|
readonly target: string;
|
|
114
115
|
readonly source?: string;
|
|
115
116
|
readonly priority?: number;
|
|
117
|
+
readonly lane?: TLane;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Build-time configuration for a drain lane (ACT-1103).
|
|
121
|
+
*
|
|
122
|
+
* @property name - Lane name (`"default"` is reserved for the implicit lane)
|
|
123
|
+
* @property leaseMillis - Lease window for `claim()` calls in this lane
|
|
124
|
+
* @property streamLimit - Max streams claimed per cycle in this lane
|
|
125
|
+
* @property cycleMs - Cycle frequency for this lane's controller
|
|
126
|
+
*/
|
|
127
|
+
export type LaneConfig<TName extends string = string> = {
|
|
128
|
+
readonly name: TName;
|
|
129
|
+
readonly leaseMillis?: number;
|
|
130
|
+
readonly streamLimit?: number;
|
|
131
|
+
readonly cycleMs?: number;
|
|
116
132
|
};
|
|
117
133
|
/**
|
|
118
134
|
* Backoff strategy for delaying the next retry attempt after a reaction
|
|
@@ -278,6 +294,7 @@ export type Fetch<TEvents extends Schemas> = Array<{
|
|
|
278
294
|
* @property by - Unique identifier of the lease holder (UUID)
|
|
279
295
|
* @property retry - Number of retry attempts (0 = first attempt)
|
|
280
296
|
* @property lagging - Whether this stream is behind (lagging frontier)
|
|
297
|
+
* @property lane - Drain lane the stream is bound to (ACT-1103)
|
|
281
298
|
*
|
|
282
299
|
* @example
|
|
283
300
|
* ```typescript
|
|
@@ -303,6 +320,7 @@ export type Lease = {
|
|
|
303
320
|
readonly by: string;
|
|
304
321
|
readonly retry: number;
|
|
305
322
|
readonly lagging: boolean;
|
|
323
|
+
readonly lane?: string;
|
|
306
324
|
};
|
|
307
325
|
/**
|
|
308
326
|
* A {@link Lease} augmented with the failure reason that pushed it past
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reaction.d.ts","sourceRoot":"","sources":["../../../src/types/reaction.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EACV,KAAK,EACL,SAAS,EACT,IAAI,EACJ,KAAK,EACL,MAAM,EACN,OAAO,EACP,QAAQ,EACT,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,MAAM,eAAe,CACzB,OAAO,SAAS,OAAO,EACvB,IAAI,SAAS,MAAM,OAAO,EAC1B,QAAQ,SAAS,OAAO,GAAG,OAAO,EAClC,MAAM,SAAS,KAAK,GAAG,KAAK,IAC1B,CACF,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EAC/B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,KACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,MAAM,gBAAgB,CAC1B,OAAO,SAAS,OAAO,EACvB,IAAI,SAAS,MAAM,OAAO,
|
|
1
|
+
{"version":3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