@rotorsoft/act 1.10.2 → 1.11.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.
@@ -39,6 +39,7 @@ export declare const DEFAULT_MAX_SUBSCRIBED_STREAMS = 1000;
39
39
  * latency on the `"settled"` signal.
40
40
  */
41
41
  export declare const DEFAULT_SETTLE_DEBOUNCE_MS = 10;
42
+ export { type AutocloseConfig, DEFAULT_AUTOCLOSE_CYCLE_MS, DEFAULT_CLOSE_BATCH_SIZE, DEFAULT_CLOSE_YIELD_MS, resolveAutocloseConfig, } from "./internal/index.js";
42
43
  /**
43
44
  * Lifecycle events emitted by {@link Act}, mapped to their payload type.
44
45
  * Drives the typing of `emit` / `on` / `off` — the event-name argument
@@ -134,6 +135,48 @@ export type ActOptions<TLanes extends string = string> = {
134
135
  * lifecycle event so observability sidecars work).
135
136
  */
136
137
  readonly drain?: boolean;
138
+ /**
139
+ * Online close cycle cadence in ms (#837 / epic #802). The
140
+ * app-level autoclose controller ticks at this interval, iterates
141
+ * states with `.autocloses(...)` declared, and schedules
142
+ * truncate-and-seed for streams whose predicate returned `true`.
143
+ *
144
+ * Default {@link DEFAULT_AUTOCLOSE_CYCLE_MS} (60 s). Validated
145
+ * `[10_000, 3_600_000]` at `act().build()`; out-of-range throws.
146
+ *
147
+ * Zero-cost when no state declares `.autocloses(...)` — the
148
+ * controller is never constructed in that case.
149
+ */
150
+ readonly autocloseCycleMs?: number;
151
+ /**
152
+ * Max number of streams the autoclose cycle considers per tick per
153
+ * state (#837). Bounds memory + truncate fan-out so a misconfigured
154
+ * predicate that matches "everything" can't take down the writer.
155
+ *
156
+ * Default {@link DEFAULT_CLOSE_BATCH_SIZE} (64). Validated
157
+ * `[1, 1024]`. Above 1024, the builder throws — operators with
158
+ * genuine high-throughput needs opt out by passing a custom
159
+ * predicate that pre-filters.
160
+ */
161
+ readonly closeBatchSize?: number;
162
+ /**
163
+ * Microsecond yield delay between successive `Store.truncate`
164
+ * calls within one cycle tick (#837). Defaults to `0` (microtask
165
+ * yield only). SQLite operators set a positive value to let the
166
+ * writer lock release between rows; PG / InMemory adapters
167
+ * generally don't need it because they don't serialize writers
168
+ * globally.
169
+ *
170
+ * Validated `[0, 1000]`.
171
+ */
172
+ readonly closeYieldMs?: number;
173
+ /**
174
+ * Whether predicate exceptions should mark the stream as closed
175
+ * (#837). Default `false` — a thrown predicate is logged and the
176
+ * stream is skipped that cycle. Set `true` to close on error
177
+ * (defensive policy for "if I can't evaluate, assume terminal").
178
+ */
179
+ readonly closeOnError?: boolean;
137
180
  };
138
181
  export declare class Act<TSchemaReg extends SchemaRegister<TActions>, TEvents extends Schemas, TActions extends Schemas, TStateMap extends Record<string, Schema> = Record<string, never>, TActor extends Actor = Actor> implements IAct<TEvents, TActions, TActor> {
139
182
  private _emitter;
@@ -164,9 +207,25 @@ export declare class Act<TSchemaReg extends SchemaRegister<TActions>, TEvents ex
164
207
  */
165
208
  private readonly _notify_disposer;
166
209
  /** Public registry — kept as-is per the no-prefix-on-public convention. */
167
- readonly registry: Registry<TSchemaReg, TEvents, TActions>;
210
+ readonly registry: Registry<TSchemaReg, TEvents, TActions, keyof TStateMap & string>;
168
211
  /** Map of state name → state definition; populated by the builder. */
169
212
  private readonly _states;
213
+ /**
214
+ * Resolved autoclose configuration (#837 / epic #802). Frozen at
215
+ * `act().build()` via {@link resolveAutocloseConfig}.
216
+ *
217
+ * @internal
218
+ */
219
+ private readonly _autoclose_config;
220
+ /**
221
+ * App-level autoclose controller. `undefined` when no state declares
222
+ * `.autocloses(...)` — the controller is never constructed, so
223
+ * `start_correlations()` / `stop_correlations()` skip the autoclose
224
+ * lifecycle and the orchestrator pays zero per-tick cost.
225
+ *
226
+ * @internal
227
+ */
228
+ private readonly _autoclose;
170
229
  /**
171
230
  * Emit a lifecycle event. The payload type is inferred from the event name
172
231
  * via {@link ActLifecycleEvents}.
@@ -252,7 +311,7 @@ export declare class Act<TSchemaReg extends SchemaRegister<TActions>, TEvents ex
252
311
  * these from `.withLane(...)` calls. Slice 1 records them on the
253
312
  * instance; later slices fan out one `DrainController` per lane.
254
313
  */
255
- constructor(registry: Registry<TSchemaReg, TEvents, TActions>, states?: Map<string, State<any, any, any>>, batch_handlers?: Map<string, BatchHandler<any>>, options?: ActOptions, lanes?: ReadonlyArray<LaneConfig>);
314
+ constructor(registry: Registry<TSchemaReg, TEvents, TActions, keyof TStateMap & string>, states?: Map<string, State<any, any, any>>, batch_handlers?: Map<string, BatchHandler<any>>, options?: ActOptions, lanes?: ReadonlyArray<LaneConfig>);
256
315
  /** True after the first `shutdown()` call. Guards idempotency. */
257
316
  private _shutdown_promise;
258
317
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"act.d.ts","sourceRoot":"","sources":["../../src/act.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAuB,KAAK,MAAM,EAAiB,MAAM,YAAY,CAAC;AAC7E,OAAO,KAAK,EACV,KAAK,EACL,IAAI,EACJ,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,SAAS,EACT,UAAU,EACV,SAAS,EACT,KAAK,EACL,YAAY,EACZ,SAAS,EACT,WAAW,EACX,IAAI,EACJ,UAAU,EACV,KAAK,EACL,UAAU,EAEV,KAAK,EACL,QAAQ,EACR,WAAW,EACX,UAAU,EACV,MAAM,EACN,cAAc,EACd,OAAO,EACP,aAAa,EACb,QAAQ,EACR,KAAK,EAEL,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,MAAM,EACP,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,OAAO,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,CAC5B,UAAU,SAAS,cAAc,CAAC,QAAQ,CAAC,EAC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AAS,KAAK,GAAG,KAAK,KACzB,UAAU,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAgUhE"}
@@ -5,7 +5,7 @@
5
5
  * Fluent interface for defining a strongly-typed state machine using Zod schemas.
6
6
  */
7
7
  import type { ZodType } from "zod";
8
- import type { ActionHandler, ActionOptions, Actor, Committed, Invariant, PatchHandlers, Schema, Schemas, Snapshot, State, ZodTypes } from "../types/index.js";
8
+ import type { ActionHandler, ActionOptions, Actor, AutocloseArchiver, AutoclosePredicate, Committed, Invariant, PatchHandlers, Schema, Schemas, Snapshot, State, ZodTypes } from "../types/index.js";
9
9
  /**
10
10
  * Builder interface for defining a state with event sourcing.
11
11
  *
@@ -332,6 +332,93 @@ export type ActionBuilder<TState extends Schema, TEvents extends Schemas, TActio
332
332
  * ```
333
333
  */
334
334
  discloses: (disclose: (event: Committed<TEvents, keyof TEvents & string>, actor: Actor) => boolean) => ActionBuilder<TState, TEvents, TActions, TName>;
335
+ /**
336
+ * Declares the online close predicate for this state. The
337
+ * orchestrator's autoclose cycle iterates the state's streams once
338
+ * per tick and calls the predicate per candidate; truthy results are
339
+ * scheduled for atomic truncate-and-seed via `Store.truncate` on the
340
+ * next batch.
341
+ *
342
+ * One predicate per state. A second `.autocloses(...)` call replaces
343
+ * the first (same shape as `.snap` / `.discloses` — state-level, not
344
+ * per-event). Absent → the state opts out of online close entirely;
345
+ * the cycle skips it and pays zero per-tick cost for it.
346
+ *
347
+ * The predicate receives `head: Committed<TEvents, ...>` so reading
348
+ * `head.event.name` autocompletes to the state's declared event
349
+ * union — exactly the signature the policy factories from sub
350
+ * #839 (terminal-event), #838 (retention), and #840 (cardinality)
351
+ * produce.
352
+ *
353
+ * Custom policies that don't fit the three factories drop in as
354
+ * inline predicates — the factories return the same shape, so
355
+ * mixing is friction-free.
356
+ *
357
+ * @param predicate `(stream, head, count) => boolean`. `true`
358
+ * schedules the stream for the next truncate batch.
359
+ * @returns The ActionBuilder for chaining.
360
+ *
361
+ * @example Terminal-event close (a Ticket closes when it's resolved).
362
+ * ```typescript
363
+ * state({ Ticket: ticketSchema })
364
+ * .init(() => defaults)
365
+ * .emits({ TicketOpened, TicketResolved })
366
+ * // ...
367
+ * .autocloses((_stream, head) => head.name === "TicketResolved")
368
+ * ```
369
+ *
370
+ * @example Retention-window close (a Session closes when it's older
371
+ * than 24h).
372
+ * ```typescript
373
+ * .autocloses((_stream, head) =>
374
+ * Date.now() - head.created.getTime() > 24 * 60 * 60 * 1000)
375
+ * ```
376
+ *
377
+ * @example Cardinality-bound close (an audit log rotates after 10k
378
+ * events).
379
+ * ```typescript
380
+ * .autocloses((_stream, _head, count) => count >= 10_000)
381
+ * ```
382
+ */
383
+ autocloses: (predicate: AutoclosePredicate<TEvents>) => ActionBuilder<TState, TEvents, TActions, TName>;
384
+ /**
385
+ * Declares the archiver the online close cycle runs **before**
386
+ * truncating a stream this state's `.autocloses(...)` predicate
387
+ * accepted. Hosts use it to write events to durable storage (S3,
388
+ * an analytics warehouse, cold tier) before the tombstone lands,
389
+ * so the truncate doesn't lose history that the operator still
390
+ * needs.
391
+ *
392
+ * Threads into `CloseTarget.archive` via the same plumbing
393
+ * `app.close({ stream, archive })` already uses — the cycle holds
394
+ * the stream's guard while the archiver runs, and a thrown
395
+ * archiver leaves the stream guarded but un-truncated. No partial
396
+ * truncate state, no data loss; the cycle retries the candidate
397
+ * on the next tick.
398
+ *
399
+ * One archiver per state. A second `.archives(...)` call replaces
400
+ * the first (same shape as `.snap` / `.discloses` /
401
+ * `.autocloses`). Absent → the cycle truncates without an archive
402
+ * step.
403
+ *
404
+ * @param archive `(stream, head) => Promise<void>`. Runs while
405
+ * the stream is locked against new writes; the truncate runs
406
+ * immediately after a successful resolve.
407
+ * @returns The ActionBuilder for chaining.
408
+ *
409
+ * @example Archive to S3 before truncate.
410
+ * ```typescript
411
+ * state({ Ticket: ticketSchema })
412
+ * .emits({ TicketOpened, TicketResolved })
413
+ * // ...
414
+ * .autocloses((_stream, head) => head.name === "TicketResolved")
415
+ * .archives(async (stream) => {
416
+ * const events = await loadEvents(stream);
417
+ * await s3.upload(`tickets/${stream}.jsonl`, events);
418
+ * })
419
+ * ```
420
+ */
421
+ archives: (archive: AutocloseArchiver<TEvents>) => ActionBuilder<TState, TEvents, TActions, TName>;
335
422
  /**
336
423
  * Finalizes and builds the state definition.
337
424
  *
@@ -1 +1 @@
1
- {"version":3,"file":"state-builder.d.ts","sourceRoot":"","sources":["../../../src/builders/state-builder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,KAAK,EACL,SAAS,EAET,SAAS,EAET,aAAa,EACb,MAAM,EACN,OAAO,EACP,QAAQ,EACR,KAAK,EACL,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,YAAY,CACtB,MAAM,SAAS,MAAM,EACrB,KAAK,SAAS,MAAM,GAAG,MAAM,IAC3B;IACF;;;;;;;;;;;;;;;;;;OAkBG;IACH,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,QAAQ,CAAC,MAAM,CAAC,KAAK;QACtC;;;;;;;;;;;;;;;;;;WAkBG;QACH,KAAK,EAAE,CAAC,OAAO,SAAS,OAAO,EAC7B,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,KAEtB,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,CAAC,GAAG;YAC/C;;;;;;;;;;;;;;;;;;;eAmBG;YACH,KAAK,EAAE,CACL,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAE3C,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;SAChD,CAAC;KACH,CAAC;CACH,CAAC;AAEF,0EAA0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;;;;;;;;;;;;;;;;;;;;;;;;OA+CG;IACH,UAAU,EAAE,CACV,SAAS,EAAE,kBAAkB,CAAC,OAAO,CAAC,KACnC,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IACrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,QAAQ,EAAE,CACR,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,KAChC,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IACrD;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK,EAAE,MAAM,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;CACtD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoHG;AACH,wBAAgB,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,MAAM,SAAS,MAAM,EAC/D,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,GAC/B,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAmD7B"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * @module autoclose-config
3
+ * @category Internal
4
+ *
5
+ * Defaults, Zod schema, and resolver for the autoclose knobs on
6
+ * {@link ActOptions} (#837 / epic #802). Split out of `act.ts` so the
7
+ * orchestrator file stays focused on the `Act` class and the
8
+ * autoclose surface lives with the cycle + controller that consume
9
+ * it. The validation pattern matches the rest of the framework —
10
+ * Zod schema with `.min().max().default(...)` per field — so the
11
+ * upcoming policy-factory subs (#838 retention, #839 terminal,
12
+ * #840 cardinality) can `.extend(...)` it for their own
13
+ * per-policy options without reinventing range checks.
14
+ *
15
+ * @internal
16
+ */
17
+ import { z } from "zod";
18
+ import type { ActOptions } from "../act.js";
19
+ /**
20
+ * Default {@link ActOptions.autocloseCycleMs}: 60 s. Sized for typical
21
+ * business-app close cadences (close-when-resolved on tickets,
22
+ * close-when-stale on sessions) where same-second response is not the
23
+ * goal. Operators with tighter requirements override; the floor is
24
+ * 10 s (any tighter is the wrong primitive).
25
+ */
26
+ export declare const DEFAULT_AUTOCLOSE_CYCLE_MS = 60000;
27
+ /**
28
+ * Default {@link ActOptions.closeBatchSize}: 64. Bounds the
29
+ * `Store.query_streams` page size + the truncate fan-out per cycle
30
+ * tick so a "close everything" misconfiguration can't take down the
31
+ * writer.
32
+ */
33
+ export declare const DEFAULT_CLOSE_BATCH_SIZE = 64;
34
+ /**
35
+ * Default {@link ActOptions.closeYieldMs}: 0. The cycle yields a
36
+ * microtask between truncates by default; SQLite operators set a
37
+ * positive value to release the writer lock.
38
+ */
39
+ export declare const DEFAULT_CLOSE_YIELD_MS = 0;
40
+ /**
41
+ * Zod schema for the autoclose knobs on {@link ActOptions}. Same
42
+ * declarative-validation pattern the framework uses elsewhere
43
+ * (`libs/act/src/config.ts`, every event/action schema, every
44
+ * reaction-option shape). Defaults, ranges, and integer constraints
45
+ * live in one place — no parallel `DEFAULT_*` + `*_MIN` / `*_MAX`
46
+ * declarations to keep in sync. Out-of-range values throw `ZodError`
47
+ * at `act().build()` so misconfiguration surfaces at startup, not
48
+ * on the first cycle tick.
49
+ *
50
+ * @internal
51
+ */
52
+ declare const AutocloseOptionsSchema: z.ZodObject<{
53
+ autocloseCycleMs: z.ZodDefault<z.ZodNumber>;
54
+ closeBatchSize: z.ZodDefault<z.ZodNumber>;
55
+ closeYieldMs: z.ZodDefault<z.ZodNumber>;
56
+ closeOnError: z.ZodDefault<z.ZodBoolean>;
57
+ }, z.core.$strip>;
58
+ /**
59
+ * Resolved autoclose configuration after validation and default
60
+ * expansion. Reachable through the public root (`@rotorsoft/act`) so
61
+ * fields follow the public-camelCase convention and mirror the
62
+ * `ActOptions` knob names directly — no per-resolver renaming layer.
63
+ */
64
+ export type AutocloseConfig = z.infer<typeof AutocloseOptionsSchema>;
65
+ /**
66
+ * Validate and apply defaults for the autoclose knobs on
67
+ * {@link ActOptions}. Called from `act().build()`. Out-of-range
68
+ * values throw `ZodError` at startup, not on the first cycle tick.
69
+ */
70
+ export declare function resolveAutocloseConfig(options: ActOptions | undefined): AutocloseConfig;
71
+ export {};
72
+ //# sourceMappingURL=autoclose-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autoclose-config.d.ts","sourceRoot":"","sources":["../../../src/internal/autoclose-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,QAAS,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,sBAAsB;;;;;iBAc1B,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAErE;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,UAAU,GAAG,SAAS,GAC9B,eAAe,CAOjB"}
@@ -0,0 +1,171 @@
1
+ /**
2
+ * @module autoclose-cycle
3
+ * @category Internal
4
+ *
5
+ * The online close-the-books cycle (#837 / epic #802). Paginates the
6
+ * store's streams, applies each state's `.autocloses(predicate)` to
7
+ * the matching candidates, then hands the eligible streams to the
8
+ * existing {@link run_close_cycle} so the tombstone-guard +
9
+ * archive-while-guarded + atomic-truncate invariants carry over from
10
+ * the explicit `app.close(targets)` path.
11
+ *
12
+ * Pure orchestration. The caller (the app-level controller in slice
13
+ * 3) owns the cadence (`setInterval(...)`), the lifecycle events
14
+ * (`emit("closed", ...)`), and the per-tick correlation id.
15
+ *
16
+ * Zero-cost when no state declares `.autocloses(...)` — the caller
17
+ * never invokes this function in that case (the controller isn't
18
+ * constructed).
19
+ *
20
+ * @internal
21
+ */
22
+ import type { AutocloseConfig } from "../act.js";
23
+ import type { Actor, CloseResult, Correlator, Logger, State } from "../types/index.js";
24
+ import type { EsOps } from "./event-sourcing.js";
25
+ /**
26
+ * Dependencies the autoclose cycle needs. Decoupled from `Act` so
27
+ * the cycle can be exercised from tests in isolation against an
28
+ * `InMemoryStore` without spinning a full Act.
29
+ *
30
+ * @internal
31
+ */
32
+ export type AutocloseCycleDeps = {
33
+ /**
34
+ * Lookup of `.autocloses(predicate)` per state name. The cycle
35
+ * skips streams whose owning state returns `null` here, so opt-out
36
+ * states pay zero per-stream cost beyond the `event_to_state`
37
+ * lookup.
38
+ */
39
+ readonly autoclose_policy: (state_name: string) => ((stream: string, head: any, count: number) => boolean) | null;
40
+ /**
41
+ * Lookup of `.archives(fn)` per state name. When present, the
42
+ * cycle threads it into the corresponding {@link CloseTarget.archive}
43
+ * so the existing close-cycle's archive-while-guarded invariant
44
+ * applies — a thrown archiver leaves the stream guarded but
45
+ * un-truncated, and the cycle re-evaluates the candidate next
46
+ * tick.
47
+ */
48
+ readonly autoclose_archiver: (state_name: string) => ((stream: string, head: any) => Promise<void>) | null;
49
+ /** event-name → owning-state lookup (already computed at build). */
50
+ readonly event_to_state: ReadonlyMap<string, State<any, any, any>>;
51
+ /** Reactive-event count, forwarded to {@link run_close_cycle}. */
52
+ readonly reactive_events_size: number;
53
+ /** `EsOps.load`, forwarded to {@link run_close_cycle}. */
54
+ readonly load: EsOps["load"];
55
+ /** `EsOps.tombstone`, forwarded to {@link run_close_cycle}. */
56
+ readonly tombstone: EsOps["tombstone"];
57
+ readonly logger: Logger;
58
+ readonly config: AutocloseConfig;
59
+ /**
60
+ * Correlation id for this tick. The caller computes it via the
61
+ * configured {@link Correlator}; every truncate the cycle stages
62
+ * shares this id so close-cycle commits land under one correlation
63
+ * key (matching the existing `app.close(targets)` behavior).
64
+ */
65
+ readonly correlation: string;
66
+ };
67
+ /**
68
+ * Aggregated result of one autoclose tick. The caller forwards
69
+ * `close_result` to the `closed` lifecycle event; `inspected` /
70
+ * `evaluated` / `predicate_errors` feed observability sidecars.
71
+ *
72
+ * @internal
73
+ */
74
+ export type AutocloseCycleResult = {
75
+ /** Total streams the cycle paginated through this tick. */
76
+ readonly inspected: number;
77
+ /** Streams whose owning state had a policy and the predicate ran. */
78
+ readonly evaluated: number;
79
+ /** Predicate exceptions caught + classified per `closeOnError`. */
80
+ readonly predicate_errors: number;
81
+ /** Forwarded from {@link run_close_cycle} — truncated + skipped. */
82
+ readonly close_result: CloseResult;
83
+ };
84
+ /**
85
+ * Run one autoclose tick against the configured store. Returns
86
+ * after every stream has been paginated through and every eligible
87
+ * batch handed to {@link run_close_cycle}.
88
+ *
89
+ * The cycle never throws — predicate exceptions are caught and
90
+ * logged (counted in `predicate_errors`; `closeOnError` controls
91
+ * whether they count as "close this stream"). Store errors during
92
+ * pagination propagate to the caller (the controller logs them and
93
+ * skips to the next tick).
94
+ *
95
+ * @internal
96
+ */
97
+ export declare function run_autoclose_cycle(deps: AutocloseCycleDeps): Promise<AutocloseCycleResult>;
98
+ /**
99
+ * Dependencies the app-level autoclose controller needs. Same shape
100
+ * as {@link AutocloseCycleDeps} minus `correlation` (the controller
101
+ * computes one per tick from the supplied {@link Correlator}) and
102
+ * plus the lifecycle-event sink (`on_closed`) and the actor sentinel
103
+ * for the correlator (`close_actor`).
104
+ *
105
+ * @internal
106
+ */
107
+ export type AutocloseControllerDeps = Omit<AutocloseCycleDeps, "correlation"> & {
108
+ /**
109
+ * Correlator the controller invokes per tick to stamp the cycle's
110
+ * truncate commits. Reuses the orchestrator's configured
111
+ * correlator so close commits share the app's id scheme — same as
112
+ * the existing `app.close(targets)` path.
113
+ */
114
+ readonly correlator: Correlator;
115
+ /** Sentinel actor for the close correlation (matches `Act.close`). */
116
+ readonly close_actor: Actor;
117
+ /**
118
+ * Fan-out for the per-tick result. The controller calls this once
119
+ * per tick that closes at least one stream, with the cycle's
120
+ * {@link CloseResult}. The Act orchestrator wires this to
121
+ * `emit("closed", result)`.
122
+ */
123
+ readonly on_closed: (result: CloseResult) => void;
124
+ };
125
+ /**
126
+ * App-level autoclose controller. Owns the ticker (`setInterval`),
127
+ * the per-tick reentrancy guard (a slow tick doesn't pile on the
128
+ * next interval), and the lifecycle-event fan-out. Tests invoke
129
+ * {@link run_once} directly; the orchestrator's
130
+ * `start_correlations()` / `stop_correlations()` lifecycle starts +
131
+ * stops the ticker.
132
+ *
133
+ * @internal
134
+ */
135
+ export declare class AutocloseController {
136
+ readonly deps: AutocloseControllerDeps;
137
+ private _timer;
138
+ /**
139
+ * Reentrancy guard. The interval fires the next tick on cadence
140
+ * regardless of how long the previous one took; this flag drops
141
+ * overlapping ticks so the cycle stays sequential per controller.
142
+ */
143
+ private _running;
144
+ constructor(deps: AutocloseControllerDeps);
145
+ /**
146
+ * Start the cycle ticker. Returns `false` if already running so
147
+ * accidental double-start doesn't stack timers (matches
148
+ * `_correlate.start_polling` semantics).
149
+ */
150
+ start(): boolean;
151
+ /**
152
+ * Stop the cycle ticker. Idempotent.
153
+ */
154
+ stop(): void;
155
+ /**
156
+ * Whether the ticker is currently running.
157
+ */
158
+ get is_running(): boolean;
159
+ /**
160
+ * Run one cycle synchronously. The controller's interval callback
161
+ * delegates here; tests can invoke it directly to deterministically
162
+ * exercise the cycle without spinning real timers.
163
+ *
164
+ * Overlapping invocations short-circuit: if a previous tick is
165
+ * still running, this one drops and returns `null`. The orchestrator
166
+ * never sees a queue of pending ticks regardless of how slow the
167
+ * predicate / archive / truncate are.
168
+ */
169
+ run_once(): Promise<AutocloseCycleResult | null>;
170
+ }
171
+ //# sourceMappingURL=autoclose-cycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,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
20
+ export { type AutocloseConfig, DEFAULT_AUTOCLOSE_CYCLE_MS, DEFAULT_CLOSE_BATCH_SIZE, DEFAULT_CLOSE_YIELD_MS, resolveAutocloseConfig, } from "./autoclose-config.js";
21
+ export { AutocloseController, type AutocloseControllerDeps, type AutocloseCycleDeps, type AutocloseCycleResult, run_autoclose_cycle, } from "./autoclose-cycle.js";
20
22
  export type { EventLaneSet } from "./build-classify.js";
21
23
  export { ALL_LANES, classify_registry } from "./build-classify.js";
22
24
  export { run_close_cycle } from "./close-cycle.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/internal/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnD,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACxE,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EACL,eAAe,EACf,KAAK,MAAM,EACX,KAAK,WAAW,GACjB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EACL,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,MAAM,EACN,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE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OAAO,EACL,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,MAAM,EACN,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EACL,SAAS,EACT,UAAU,EACV,QAAQ,EACR,SAAS,EACT,SAAS,EACT,QAAQ,EACR,QAAQ,GACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
@@ -478,6 +478,46 @@ export type DoOptions<_TEvents extends Schemas = Schemas> = {
478
478
  readonly reactingTo?: Committed<Schemas, keyof Schemas>;
479
479
  readonly correlator?: Correlator;
480
480
  };
481
+ /**
482
+ * Predicate consulted by the online close cycle once per candidate
483
+ * stream of a state with `.autocloses(...)` declared. Returning `true`
484
+ * schedules the stream for atomic truncate-and-seed via
485
+ * {@link Store.truncate} on the next batch.
486
+ *
487
+ * The `head` argument is the latest committed (non-tombstone) event on
488
+ * the stream; predicates that gate on the last event name (e.g. the
489
+ * terminal-event policy from sub #839) read `head.name` directly and
490
+ * the type system autocompletes it to the state's event union.
491
+ * `count` is the stream's total event count.
492
+ *
493
+ * Predicates run in process per cycle tick; they MUST be pure and
494
+ * fast — slow predicates serialize behind the cycle's batch.
495
+ *
496
+ * @template TEvents Event schemas declared by the owning state via
497
+ * `.emits({...})`. `head.event.name` autocompletes to
498
+ * `keyof TEvents`.
499
+ */
500
+ export type AutoclosePredicate<TEvents extends Schemas> = (stream: string, head: Committed<TEvents, keyof TEvents>, count: number) => boolean;
501
+ /**
502
+ * Side-effect callback the online close cycle runs **before**
503
+ * truncating a stream that the state's `.autocloses(...)` predicate
504
+ * accepted. Hosts use it to write the stream's events somewhere
505
+ * durable (S3, cold storage, an analytics warehouse) before the
506
+ * tombstone lands. The cycle threads this into
507
+ * {@link CloseTarget.archive} so the existing close-cycle's
508
+ * archive-while-guarded invariant carries over: the stream is locked
509
+ * against new writes while the archiver runs, and a thrown archiver
510
+ * leaves the stream guarded but un-truncated (no data loss, the
511
+ * cycle retries the candidate next tick).
512
+ *
513
+ * State-level (one per state, last-write-wins). Hosts with per-stream
514
+ * archiving differences branch inside the function. Absent →
515
+ * truncate runs without an archive step (matches the explicit
516
+ * `app.close({ stream })` default).
517
+ *
518
+ * @template TEvents Event schemas declared by the owning state.
519
+ */
520
+ export type AutocloseArchiver<TEvents extends Schemas> = (stream: string, head: Committed<TEvents, keyof TEvents>) => Promise<void>;
481
521
  /**
482
522
  * The full state definition, including schemas, handlers, and optional invariants and snapshot logic.
483
523
  * @template TState - State schema.
@@ -509,6 +549,29 @@ export type State<TState extends Schema, TEvents extends Schemas, TActions exten
509
549
  * substituted with `"[REDACTED]"`). See #855 / epic #566.
510
550
  */
511
551
  disclose?(event: Committed<TEvents, keyof TEvents>, actor: Actor): boolean;
552
+ /**
553
+ * Online close predicate set by `.autocloses(predicate)`. The
554
+ * orchestrator's autoclose cycle iterates this state's streams once
555
+ * per tick and calls the predicate per candidate; truthy results are
556
+ * scheduled for atomic truncate-and-seed via {@link Store.truncate}.
557
+ * Absent → the state opts out of online close entirely (zero
558
+ * per-cycle cost).
559
+ *
560
+ * Bivariant method-shorthand for the same reason as `disclose` —
561
+ * keeps `State<specific>` assignable to `State<any, any, any>`. The
562
+ * `.autocloses()` builder method keeps the narrow signature.
563
+ */
564
+ autoclose?(stream: string, head: Committed<TEvents, keyof TEvents>, count: number): boolean;
565
+ /**
566
+ * Archiver set by `.archives(fn)`. The online close cycle threads
567
+ * this into {@link CloseTarget.archive} for every truncate it
568
+ * stages, so the existing close-cycle's archive-while-guarded
569
+ * invariant carries over to the autoclose path. Absent → the cycle
570
+ * truncates without an archive step. Bivariant method-shorthand
571
+ * for the same `State<specific>` → `State<any, any, any>` reason
572
+ * as `disclose` / `autoclose`.
573
+ */
574
+ archive?(stream: string, head: Committed<TEvents, keyof TEvents>): Promise<void>;
512
575
  /**
513
576
  * Build-time step delegates wired by `act().build()`. The orchestrator
514
577
  * calls these instead of branching on PII per event — for PII-aware