@rotorsoft/act 1.33.0 → 1.33.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -40,7 +40,7 @@
40
40
 
41
41
 
42
42
 
43
- var _chunkVE3MTY4Acjs = require('./chunk-VE3MTY4A.cjs');
43
+ var _chunkO6QIJQRNcjs = require('./chunk-O6QIJQRN.cjs');
44
44
 
45
45
 
46
46
 
@@ -70,24 +70,24 @@ var _chunkVE3MTY4Acjs = require('./chunk-VE3MTY4A.cjs');
70
70
 
71
71
 
72
72
 
73
- var _chunkHF433MAFcjs = require('./chunk-HF433MAF.cjs');
73
+ var _chunk7AHW7FCNcjs = require('./chunk-7AHW7FCN.cjs');
74
74
 
75
75
  // src/signals.ts
76
76
  process.once("SIGINT", async (arg) => {
77
- _chunkVE3MTY4Acjs.log.call(void 0, ).info(arg, "SIGINT");
78
- await _chunkVE3MTY4Acjs.disposeAndExit.call(void 0, "EXIT");
77
+ _chunkO6QIJQRNcjs.log.call(void 0, ).info(arg, "SIGINT");
78
+ await _chunkO6QIJQRNcjs.disposeAndExit.call(void 0, "EXIT");
79
79
  });
80
80
  process.once("SIGTERM", async (arg) => {
81
- _chunkVE3MTY4Acjs.log.call(void 0, ).info(arg, "SIGTERM");
82
- await _chunkVE3MTY4Acjs.disposeAndExit.call(void 0, "EXIT");
81
+ _chunkO6QIJQRNcjs.log.call(void 0, ).info(arg, "SIGTERM");
82
+ await _chunkO6QIJQRNcjs.disposeAndExit.call(void 0, "EXIT");
83
83
  });
84
84
  process.once("uncaughtException", async (arg) => {
85
- _chunkVE3MTY4Acjs.log.call(void 0, ).error(arg, "Uncaught Exception");
86
- await _chunkVE3MTY4Acjs.disposeAndExit.call(void 0, "ERROR");
85
+ _chunkO6QIJQRNcjs.log.call(void 0, ).error(arg, "Uncaught Exception");
86
+ await _chunkO6QIJQRNcjs.disposeAndExit.call(void 0, "ERROR");
87
87
  });
88
88
  process.once("unhandledRejection", async (arg) => {
89
- _chunkVE3MTY4Acjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
90
- await _chunkVE3MTY4Acjs.disposeAndExit.call(void 0, "ERROR");
89
+ _chunkO6QIJQRNcjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
90
+ await _chunkO6QIJQRNcjs.disposeAndExit.call(void 0, "ERROR");
91
91
  });
92
92
 
93
93
  // src/act.ts
@@ -195,7 +195,7 @@ async function* audit(deps, categories, options = {}) {
195
195
  if (need_stats) {
196
196
  const stats = await deps.store().query_stats(
197
197
  {},
198
- { count: true, names: true, exclude: [_chunkHF433MAFcjs.SNAP_EVENT] }
198
+ { count: true, names: true, exclude: [_chunk7AHW7FCNcjs.SNAP_EVENT] }
199
199
  );
200
200
  for (const [stream, s] of stats) {
201
201
  for (const p of passes) _optionalChain([p, 'access', _4 => _4.on_stat, 'optionalCall', _5 => _5(stream, s)]);
@@ -277,7 +277,7 @@ var make_schema_pass = (deps) => {
277
277
  return;
278
278
  }
279
279
  const schema = state2.events[name];
280
- const sensitive2 = _chunkHF433MAFcjs.pii_fields.call(void 0, schema);
280
+ const sensitive2 = _chunk7AHW7FCNcjs.pii_fields.call(void 0, schema);
281
281
  let parse_schema = schema;
282
282
  if (sensitive2.length > 0) {
283
283
  const omitter = schema.omit;
@@ -411,7 +411,7 @@ var make_restart_candidate_pass = (deps, options) => {
411
411
  {
412
412
  stream,
413
413
  stream_exact: true,
414
- names: [_chunkHF433MAFcjs.SNAP_EVENT],
414
+ names: [_chunk7AHW7FCNcjs.SNAP_EVENT],
415
415
  with_snaps: true
416
416
  }
417
417
  );
@@ -840,7 +840,7 @@ async function run_close_cycle(targets, deps) {
840
840
  deps,
841
841
  () => run_full_closes(full, target_map, deps, skipped)
842
842
  );
843
- const retired = [...truncated.entries()].filter(([, r]) => r.committed.name === _chunkHF433MAFcjs.TOMBSTONE_EVENT).map(([stream]) => stream);
843
+ const retired = [...truncated.entries()].filter(([, r]) => r.committed.name === _chunk7AHW7FCNcjs.TOMBSTONE_EVENT).map(([stream]) => stream);
844
844
  if (retired.length) _optionalChain([deps, 'access', _42 => _42.forget_subscribed, 'optionalCall', _43 => _43(retired)]);
845
845
  for (const [stream, entry] of windowed_result) truncated.set(stream, entry);
846
846
  return { truncated, skipped };
@@ -922,7 +922,7 @@ async function run_windowed_closes(windowed, deps, skipped) {
922
922
  if (!await windowed_prune_pending(t.stream, t.before, max_id))
923
923
  return void 0;
924
924
  if (t.archive) await t.archive();
925
- const result = await _chunkVE3MTY4Acjs.store.call(void 0, ).truncate([
925
+ const result = await _chunkO6QIJQRNcjs.store.call(void 0, ).truncate([
926
926
  { stream: t.stream, before: t.before, max_id }
927
927
  ]);
928
928
  return result.get(t.stream);
@@ -935,10 +935,10 @@ async function run_windowed_closes(windowed, deps, skipped) {
935
935
  async function windowed_prune_pending(stream, before, max_id) {
936
936
  let boundary_id;
937
937
  let min_id;
938
- await _chunkVE3MTY4Acjs.store.call(void 0, ).query(
938
+ await _chunkO6QIJQRNcjs.store.call(void 0, ).query(
939
939
  (event) => {
940
940
  if (min_id === void 0 || event.id < min_id) min_id = event.id;
941
- if (event.name === _chunkHF433MAFcjs.SNAP_EVENT && event.created < before && (max_id === void 0 || event.id <= max_id) && (boundary_id === void 0 || event.id > boundary_id))
941
+ if (event.name === _chunk7AHW7FCNcjs.SNAP_EVENT && event.created < before && (max_id === void 0 || event.id <= max_id) && (boundary_id === void 0 || event.id > boundary_id))
942
942
  boundary_id = event.id;
943
943
  },
944
944
  { stream, stream_exact: true, with_snaps: true, after: -1 }
@@ -949,7 +949,7 @@ async function probe_min_watermarks(streams, page_size, checkpoint) {
949
949
  const min_at = /* @__PURE__ */ new Map();
950
950
  const matches = source_matcher();
951
951
  await walk_streams(
952
- _chunkVE3MTY4Acjs.store.call(void 0, ),
952
+ _chunkO6QIJQRNcjs.store.call(void 0, ),
953
953
  (position) => {
954
954
  const pending = position.correlated_at === void 0 || position.at < position.correlated_at;
955
955
  const cap = pending ? position.at : Math.max(position.at, checkpoint);
@@ -977,17 +977,17 @@ function source_matcher() {
977
977
  };
978
978
  }
979
979
  async function scan_stream_heads(streams) {
980
- const stats = await _chunkVE3MTY4Acjs.store.call(void 0, ).query_stats(streams, {
981
- exclude: [_chunkHF433MAFcjs.SNAP_EVENT]
980
+ const stats = await _chunkO6QIJQRNcjs.store.call(void 0, ).query_stats(streams, {
981
+ exclude: [_chunk7AHW7FCNcjs.SNAP_EVENT]
982
982
  });
983
- const domain_heads = await _chunkVE3MTY4Acjs.store.call(void 0, ).query_stats(streams, {
984
- exclude: [_chunkHF433MAFcjs.SNAP_EVENT, _chunkHF433MAFcjs.TOMBSTONE_EVENT]
983
+ const domain_heads = await _chunkO6QIJQRNcjs.store.call(void 0, ).query_stats(streams, {
984
+ exclude: [_chunk7AHW7FCNcjs.SNAP_EVENT, _chunk7AHW7FCNcjs.TOMBSTONE_EVENT]
985
985
  });
986
- const true_heads = await _chunkVE3MTY4Acjs.store.call(void 0, ).query_stats(streams, {});
986
+ const true_heads = await _chunkO6QIJQRNcjs.store.call(void 0, ).query_stats(streams, {});
987
987
  const out = /* @__PURE__ */ new Map();
988
988
  for (const [stream, { head }] of domain_heads) {
989
989
  const marker_head = _optionalChain([stats, 'access', _45 => _45.get, 'call', _46 => _46(stream), 'optionalAccess', _47 => _47.head]);
990
- const interrupted = _optionalChain([marker_head, 'optionalAccess', _48 => _48.name]) === _chunkHF433MAFcjs.TOMBSTONE_EVENT;
990
+ const interrupted = _optionalChain([marker_head, 'optionalAccess', _48 => _48.name]) === _chunk7AHW7FCNcjs.TOMBSTONE_EVENT;
991
991
  out.set(stream, {
992
992
  max_id: head.id,
993
993
  version: true_heads.get(stream).head.version,
@@ -1011,7 +1011,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
1011
1011
  const matches = source_matcher();
1012
1012
  const targets = [...stream_info.keys()];
1013
1013
  await walk_streams(
1014
- _chunkVE3MTY4Acjs.store.call(void 0, ),
1014
+ _chunkO6QIJQRNcjs.store.call(void 0, ),
1015
1015
  (position) => {
1016
1016
  const has_work = position.correlated_at !== void 0 && position.at < position.correlated_at;
1017
1017
  if (!has_work) return;
@@ -1077,7 +1077,7 @@ async function run_archive_callbacks(guarded, target_map) {
1077
1077
  }
1078
1078
  }
1079
1079
  async function heads_still_guarded(guarded, guard_events, skipped) {
1080
- const heads = await _chunkVE3MTY4Acjs.store.call(void 0, ).query_stats(guarded, {});
1080
+ const heads = await _chunkO6QIJQRNcjs.store.call(void 0, ).query_stats(guarded, {});
1081
1081
  return guarded.filter((stream) => {
1082
1082
  if (_optionalChain([heads, 'access', _55 => _55.get, 'call', _56 => _56(stream), 'optionalAccess', _57 => _57.head, 'access', _58 => _58.id]) === guard_events.get(stream).id)
1083
1083
  return true;
@@ -1095,18 +1095,18 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
1095
1095
  meta: {
1096
1096
  correlation,
1097
1097
  causation: {
1098
- event: { id: guard.id, name: _chunkHF433MAFcjs.TOMBSTONE_EVENT, stream: guard.stream }
1098
+ event: { id: guard.id, name: _chunk7AHW7FCNcjs.TOMBSTONE_EVENT, stream: guard.stream }
1099
1099
  }
1100
1100
  }
1101
1101
  };
1102
1102
  });
1103
- const truncated = await _chunkVE3MTY4Acjs.store.call(void 0, ).truncate(trunc_targets);
1103
+ const truncated = await _chunkO6QIJQRNcjs.store.call(void 0, ).truncate(trunc_targets);
1104
1104
  await Promise.all(
1105
1105
  guarded.map(async (stream) => {
1106
1106
  const entry = truncated.get(stream);
1107
1107
  const state2 = seed_states.get(stream);
1108
1108
  if (state2 && entry) {
1109
- await _chunkVE3MTY4Acjs.cache.call(void 0, ).set(stream, {
1109
+ await _chunkO6QIJQRNcjs.cache.call(void 0, ).set(stream, {
1110
1110
  stream,
1111
1111
  state: state2,
1112
1112
  version: entry.committed.version,
@@ -1115,7 +1115,7 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
1115
1115
  snaps: 1
1116
1116
  });
1117
1117
  } else {
1118
- await _chunkVE3MTY4Acjs.cache.call(void 0, ).invalidate(stream);
1118
+ await _chunkO6QIJQRNcjs.cache.call(void 0, ).invalidate(stream);
1119
1119
  }
1120
1120
  })
1121
1121
  );
@@ -1129,7 +1129,7 @@ var _crypto = require('crypto');
1129
1129
  function report_once(seen, key, message) {
1130
1130
  if (seen.has(key)) return;
1131
1131
  seen.add(key);
1132
- _chunkVE3MTY4Acjs.log.call(void 0, ).error(new Error(message));
1132
+ _chunkO6QIJQRNcjs.log.call(void 0, ).error(new Error(message));
1133
1133
  }
1134
1134
 
1135
1135
  // src/internal/correlate-cycle.ts
@@ -1169,7 +1169,7 @@ var CorrelateCycle = (_class3 = class {
1169
1169
  // never drops their +Infinity floor.
1170
1170
 
1171
1171
  __init8() {this._static_subscriptions = /* @__PURE__ */ new Map()}
1172
- __init9() {this._patterns = new (0, _chunkVE3MTY4Acjs.LruMap)(PATTERN_CACHE_SIZE)}
1172
+ __init9() {this._patterns = new (0, _chunkO6QIJQRNcjs.LruMap)(PATTERN_CACHE_SIZE)}
1173
1173
 
1174
1174
 
1175
1175
 
@@ -1190,7 +1190,7 @@ var CorrelateCycle = (_class3 = class {
1190
1190
  on_init_async
1191
1191
  }) {;_class3.prototype.__init3.call(this);_class3.prototype.__init4.call(this);_class3.prototype.__init5.call(this);_class3.prototype.__init6.call(this);_class3.prototype.__init7.call(this);_class3.prototype.__init8.call(this);_class3.prototype.__init9.call(this);_class3.prototype.__init10.call(this);
1192
1192
  this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
1193
- this._dynamic_subscriptions = new (0, _chunkVE3MTY4Acjs.LruMap)(max_subscribed_streams);
1193
+ this._dynamic_subscriptions = new (0, _chunkO6QIJQRNcjs.LruMap)(max_subscribed_streams);
1194
1194
  this._registry = registry;
1195
1195
  this._declared_lanes = declared_lanes;
1196
1196
  this._static_targets = static_targets;
@@ -1247,7 +1247,7 @@ var CorrelateCycle = (_class3 = class {
1247
1247
  /** Would the target's own `fetch` (filtered by `source`) return this event? */
1248
1248
  _in_fetch_window(source, stream) {
1249
1249
  if (source === void 0 || source === stream) return true;
1250
- if (_chunkVE3MTY4Acjs.is_literal_source.call(void 0, source)) return false;
1250
+ if (_chunkO6QIJQRNcjs.is_literal_source.call(void 0, source)) return false;
1251
1251
  let pattern = this._patterns.get(source);
1252
1252
  if (!pattern) {
1253
1253
  pattern = new RegExp(source);
@@ -1285,7 +1285,7 @@ var CorrelateCycle = (_class3 = class {
1285
1285
  const correlated = /* @__PURE__ */ new Map();
1286
1286
  let last_id = after;
1287
1287
  let stopped = false;
1288
- const found = await _chunkVE3MTY4Acjs.store.call(void 0, ).query(
1288
+ const found = await _chunkO6QIJQRNcjs.store.call(void 0, ).query(
1289
1289
  (event) => {
1290
1290
  if (stopped) return;
1291
1291
  const register = this._registry.events[event.name];
@@ -1329,9 +1329,9 @@ var CorrelateCycle = (_class3 = class {
1329
1329
  correlated_at: void 0
1330
1330
  };
1331
1331
  const seen_in_scan = correlated.has(resolved.target);
1332
- const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _63 => _63.lane])), () => ( _chunkHF433MAFcjs.DEFAULT_LANE));
1332
+ const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _63 => _63.lane])), () => ( _chunk7AHW7FCNcjs.DEFAULT_LANE));
1333
1333
  const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess', _64 => _64.priority]);
1334
- const resolved_lane = _nullishCoalesce(lane, () => ( _chunkHF433MAFcjs.DEFAULT_LANE));
1334
+ const resolved_lane = _nullishCoalesce(lane, () => ( _chunk7AHW7FCNcjs.DEFAULT_LANE));
1335
1335
  if (held_priority === priority && held_lane !== resolved_lane)
1336
1336
  report_lane_conflict(
1337
1337
  this._reported,
@@ -1406,7 +1406,7 @@ var CorrelateCycle = (_class3 = class {
1406
1406
  await Promise.all(
1407
1407
  missed.map(async ([stream, entry]) => {
1408
1408
  let row;
1409
- await _chunkVE3MTY4Acjs.store.call(void 0, ).query_streams(
1409
+ await _chunkO6QIJQRNcjs.store.call(void 0, ).query_streams(
1410
1410
  (position) => {
1411
1411
  row = position;
1412
1412
  },
@@ -1419,8 +1419,8 @@ var CorrelateCycle = (_class3 = class {
1419
1419
  lane: row.lane
1420
1420
  });
1421
1421
  if (entry.priority > row.priority) return;
1422
- const held_lane = _nullishCoalesce(row.lane, () => ( _chunkHF433MAFcjs.DEFAULT_LANE));
1423
- const resolved_lane = _nullishCoalesce(entry.lane, () => ( _chunkHF433MAFcjs.DEFAULT_LANE));
1422
+ const held_lane = _nullishCoalesce(row.lane, () => ( _chunk7AHW7FCNcjs.DEFAULT_LANE));
1423
+ const resolved_lane = _nullishCoalesce(entry.lane, () => ( _chunk7AHW7FCNcjs.DEFAULT_LANE));
1424
1424
  if (entry.priority === row.priority && held_lane !== resolved_lane)
1425
1425
  report_lane_conflict(
1426
1426
  this._reported,
@@ -1445,7 +1445,7 @@ var CorrelateCycle = (_class3 = class {
1445
1445
  millis: 0
1446
1446
  });
1447
1447
  } catch (error) {
1448
- _chunkVE3MTY4Acjs.log.call(void 0, ).warn(
1448
+ _chunkO6QIJQRNcjs.log.call(void 0, ).warn(
1449
1449
  `Could not hand back the correlation lease during shutdown; it expires on its own within ${CORRELATION_LEASE_MS}ms and correlation resumes normally after that. On a single-writer store this usually means another connection holds the database. Cause: ${String(error)}`
1450
1450
  );
1451
1451
  }
@@ -1598,14 +1598,14 @@ function compute_lag_lead_ratio(handled, lagging, leading) {
1598
1598
  }
1599
1599
 
1600
1600
  // src/internal/drain-ops.ts
1601
- var claim = (lagging, leading, by, millis, lane) => _chunkVE3MTY4Acjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane);
1601
+ var claim = (lagging, leading, by, millis, lane) => _chunkO6QIJQRNcjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane);
1602
1602
  async function fetch(leased, eventLimit) {
1603
1603
  return Promise.all(
1604
1604
  leased.map(async ({ stream, source, at, lagging }) => {
1605
1605
  const events = [];
1606
- const stream_exact = source !== void 0 && _chunkVE3MTY4Acjs.is_literal_source.call(void 0, source) ? true : void 0;
1606
+ const stream_exact = source !== void 0 && _chunkO6QIJQRNcjs.is_literal_source.call(void 0, source) ? true : void 0;
1607
1607
  try {
1608
- await _chunkVE3MTY4Acjs.store.call(void 0, ).query((e) => events.push(e), {
1608
+ await _chunkO6QIJQRNcjs.store.call(void 0, ).query((e) => events.push(e), {
1609
1609
  stream: source,
1610
1610
  stream_exact,
1611
1611
  after: at,
@@ -1625,30 +1625,30 @@ async function fetch(leased, eventLimit) {
1625
1625
  })
1626
1626
  );
1627
1627
  }
1628
- var ack = (leases) => _chunkVE3MTY4Acjs.store.call(void 0, ).ack(leases);
1629
- var block = (leases) => _chunkVE3MTY4Acjs.store.call(void 0, ).block(leases);
1630
- var subscribe = (streams, correlated_at, correlator) => _chunkVE3MTY4Acjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator);
1628
+ var ack = (leases) => _chunkO6QIJQRNcjs.store.call(void 0, ).ack(leases);
1629
+ var block = (leases) => _chunkO6QIJQRNcjs.store.call(void 0, ).block(leases);
1630
+ var subscribe = (streams, correlated_at, correlator) => _chunkO6QIJQRNcjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator);
1631
1631
 
1632
1632
  // src/internal/event-sourcing.ts
1633
1633
  var _actpatch = require('@rotorsoft/act-patch');
1634
1634
  var bare_patch = (_me, state2, partial) => _actpatch.patch.call(void 0, state2, partial);
1635
1635
  var validating_patch = (me, state2, partial, event) => {
1636
1636
  const next = _actpatch.patch.call(void 0, state2, partial);
1637
- return _chunkVE3MTY4Acjs.validate.call(void 0,
1637
+ return _chunkO6QIJQRNcjs.validate.call(void 0,
1638
1638
  `${me.name}.${String(event.name)}#${event.id}`,
1639
1639
  next,
1640
1640
  me.state
1641
1641
  );
1642
1642
  };
1643
1643
  var DEFAULT_BATCH = 500;
1644
- var cache_put = (stream, entry) => _chunkVE3MTY4Acjs.cache.call(void 0, ).set(stream, entry).catch(
1645
- (err) => _chunkVE3MTY4Acjs.log.call(void 0, ).warn(
1644
+ var cache_put = (stream, entry) => _chunkO6QIJQRNcjs.cache.call(void 0, ).set(stream, entry).catch(
1645
+ (err) => _chunkO6QIJQRNcjs.log.call(void 0, ).warn(
1646
1646
  err,
1647
1647
  "cache set skipped; the next load re-folds from the store"
1648
1648
  )
1649
1649
  );
1650
- var cache_drop = (stream) => _chunkVE3MTY4Acjs.cache.call(void 0, ).invalidate(stream).catch(
1651
- (err) => _chunkVE3MTY4Acjs.log.call(void 0, ).warn(
1650
+ var cache_drop = (stream) => _chunkO6QIJQRNcjs.cache.call(void 0, ).invalidate(stream).catch(
1651
+ (err) => _chunkO6QIJQRNcjs.log.call(void 0, ).warn(
1652
1652
  err,
1653
1653
  "cache invalidate skipped; a stale checkpoint re-folds from its event_id"
1654
1654
  )
@@ -1656,9 +1656,9 @@ var cache_drop = (stream) => _chunkVE3MTY4Acjs.cache.call(void 0, ).invalidate(s
1656
1656
  async function snap(snapshot) {
1657
1657
  const { id, stream, name, meta, version } = snapshot.event;
1658
1658
  try {
1659
- const [committed] = await _chunkVE3MTY4Acjs.store.call(void 0, ).commit(
1659
+ const [committed] = await _chunkO6QIJQRNcjs.store.call(void 0, ).commit(
1660
1660
  stream,
1661
- [{ name: _chunkHF433MAFcjs.SNAP_EVENT, data: snapshot.state }],
1661
+ [{ name: _chunk7AHW7FCNcjs.SNAP_EVENT, data: snapshot.state }],
1662
1662
  {
1663
1663
  correlation: meta.correlation,
1664
1664
  causation: { event: { id, name, stream } }
@@ -1669,22 +1669,22 @@ async function snap(snapshot) {
1669
1669
  return committed;
1670
1670
  } catch (error) {
1671
1671
  const reason = error instanceof Error ? error.message : String(error);
1672
- _chunkVE3MTY4Acjs.log.call(void 0, ).warn(
1672
+ _chunkO6QIJQRNcjs.log.call(void 0, ).warn(
1673
1673
  `Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
1674
1674
  );
1675
1675
  }
1676
1676
  }
1677
1677
  async function tombstone(stream, expectedVersion, correlation) {
1678
1678
  try {
1679
- const [committed] = await _chunkVE3MTY4Acjs.store.call(void 0, ).commit(
1679
+ const [committed] = await _chunkO6QIJQRNcjs.store.call(void 0, ).commit(
1680
1680
  stream,
1681
- [{ name: _chunkHF433MAFcjs.TOMBSTONE_EVENT, data: {} }],
1681
+ [{ name: _chunk7AHW7FCNcjs.TOMBSTONE_EVENT, data: {} }],
1682
1682
  { correlation, causation: {} },
1683
1683
  expectedVersion
1684
1684
  );
1685
1685
  return committed;
1686
1686
  } catch (error) {
1687
- if (error instanceof _chunkHF433MAFcjs.ConcurrencyError) return void 0;
1687
+ if (error instanceof _chunk7AHW7FCNcjs.ConcurrencyError) return void 0;
1688
1688
  throw error;
1689
1689
  }
1690
1690
  }
@@ -1714,9 +1714,9 @@ async function scan(source, opts = {}, callback) {
1714
1714
  if (drop_closed_streams) {
1715
1715
  await source.query(
1716
1716
  (e) => {
1717
- if (e.name === _chunkHF433MAFcjs.TOMBSTONE_EVENT) closed_streams.add(e.stream);
1717
+ if (e.name === _chunk7AHW7FCNcjs.TOMBSTONE_EVENT) closed_streams.add(e.stream);
1718
1718
  },
1719
- { names: [_chunkHF433MAFcjs.TOMBSTONE_EVENT] }
1719
+ { names: [_chunk7AHW7FCNcjs.TOMBSTONE_EVENT] }
1720
1720
  );
1721
1721
  }
1722
1722
  let max_id;
@@ -1738,11 +1738,11 @@ async function scan(source, opts = {}, callback) {
1738
1738
  if (!is_valid(event))
1739
1739
  throw new Error(`Invalid event at index ${processed}`);
1740
1740
  if (on_progress) on_progress({ processed, id: event.id, max_id });
1741
- if (drop_snapshots && event.name === _chunkHF433MAFcjs.SNAP_EVENT) {
1741
+ if (drop_snapshots && event.name === _chunk7AHW7FCNcjs.SNAP_EVENT) {
1742
1742
  dropped_snaps++;
1743
1743
  return;
1744
1744
  }
1745
- if (closed_streams.has(event.stream) && event.name !== _chunkHF433MAFcjs.TOMBSTONE_EVENT) {
1745
+ if (closed_streams.has(event.stream) && event.name !== _chunk7AHW7FCNcjs.TOMBSTONE_EVENT) {
1746
1746
  dropped_closed++;
1747
1747
  return;
1748
1748
  }
@@ -1809,17 +1809,17 @@ async function scan(source, opts = {}, callback) {
1809
1809
  async function load(me, target, callback, patch_fn = bare_patch) {
1810
1810
  const { stream, actor, asOf } = target;
1811
1811
  const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
1812
- const cached = time_travel ? void 0 : await _chunkVE3MTY4Acjs.cache.call(void 0, ).get(stream);
1812
+ const cached = time_travel ? void 0 : await _chunkO6QIJQRNcjs.cache.call(void 0, ).get(stream);
1813
1813
  const cache_hit = !!cached;
1814
1814
  let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _74 => _74.state]), () => ( (me.init ? me.init() : {})));
1815
1815
  let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _75 => _75.patches]), () => ( 0));
1816
1816
  let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _76 => _76.snaps]), () => ( 0));
1817
1817
  let replayed = 0;
1818
1818
  let event;
1819
- await _chunkVE3MTY4Acjs.store.call(void 0, ).query(
1819
+ await _chunkO6QIJQRNcjs.store.call(void 0, ).query(
1820
1820
  (raw) => {
1821
1821
  event = me.view(raw, actor);
1822
- if (event.name === _chunkHF433MAFcjs.SNAP_EVENT) {
1822
+ if (event.name === _chunk7AHW7FCNcjs.SNAP_EVENT) {
1823
1823
  state2 = event.data;
1824
1824
  snaps++;
1825
1825
  patches = 0;
@@ -1828,8 +1828,8 @@ async function load(me, target, callback, patch_fn = bare_patch) {
1828
1828
  state2 = patch_fn(me, state2, me.patch[event.name](event, state2), event);
1829
1829
  patches++;
1830
1830
  replayed++;
1831
- } else if (event.name !== _chunkHF433MAFcjs.TOMBSTONE_EVENT) {
1832
- _chunkVE3MTY4Acjs.log.call(void 0, ).warn(
1831
+ } else if (event.name !== _chunk7AHW7FCNcjs.TOMBSTONE_EVENT) {
1832
+ _chunkO6QIJQRNcjs.log.call(void 0, ).warn(
1833
1833
  `Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
1834
1834
  );
1835
1835
  }
@@ -1853,7 +1853,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
1853
1853
  ...cached ? { after: cached.event_id, with_snaps: true } : { ...time_travel ? {} : { with_snaps: true }, ...asOf }
1854
1854
  }
1855
1855
  );
1856
- const head_is_tombstone = _optionalChain([event, 'optionalAccess', _78 => _78.name]) === _chunkHF433MAFcjs.TOMBSTONE_EVENT;
1856
+ const head_is_tombstone = _optionalChain([event, 'optionalAccess', _78 => _78.name]) === _chunk7AHW7FCNcjs.TOMBSTONE_EVENT;
1857
1857
  if (replayed > 0 && !time_travel && event && !me.pii_aware && !head_is_tombstone) {
1858
1858
  await cache_put(stream, {
1859
1859
  stream,
@@ -1881,7 +1881,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1881
1881
  if (!stream) throw new Error("Missing target stream");
1882
1882
  const reactingTo = _optionalChain([options, 'optionalAccess', _83 => _83.reactingTo]);
1883
1883
  const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _84 => _84.correlator]), () => ( default_correlator));
1884
- const validated = _chunkVE3MTY4Acjs.validate.call(void 0, action2, payload, me.actions[action2]);
1884
+ const validated = _chunkO6QIJQRNcjs.validate.call(void 0, action2, payload, me.actions[action2]);
1885
1885
  const opts = _optionalChain([me, 'access', _85 => _85.options, 'optionalAccess', _86 => _86[action2]]);
1886
1886
  const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _87 => _87.maxRetries]), () => ( 0));
1887
1887
  for (let attempt = 0; ; attempt++) {
@@ -1892,14 +1892,14 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1892
1892
  void 0,
1893
1893
  patch_fn
1894
1894
  );
1895
- if (_optionalChain([snapshot, 'access', _88 => _88.event, 'optionalAccess', _89 => _89.name]) === _chunkHF433MAFcjs.TOMBSTONE_EVENT)
1896
- throw new (0, _chunkHF433MAFcjs.StreamClosedError)(stream);
1895
+ if (_optionalChain([snapshot, 'access', _88 => _88.event, 'optionalAccess', _89 => _89.name]) === _chunk7AHW7FCNcjs.TOMBSTONE_EVENT)
1896
+ throw new (0, _chunk7AHW7FCNcjs.StreamClosedError)(stream);
1897
1897
  const expected = _nullishCoalesce(expectedVersion, () => ( (snapshot.version >= 0 ? snapshot.version : void 0)));
1898
1898
  if (me.given) {
1899
1899
  const invariants = me.given[action2] || [];
1900
1900
  invariants.forEach(({ valid: valid2, description }) => {
1901
1901
  if (!valid2(snapshot.state, actor))
1902
- throw new (0, _chunkHF433MAFcjs.InvariantError)(
1902
+ throw new (0, _chunk7AHW7FCNcjs.InvariantError)(
1903
1903
  action2,
1904
1904
  validated,
1905
1905
  target,
@@ -1916,7 +1916,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1916
1916
  const tuples = Array.isArray(result[0]) ? result : [result];
1917
1917
  const valid = tuples.map(([name, data]) => ({
1918
1918
  name,
1919
- data: _chunkVE3MTY4Acjs.validate.call(void 0, name, data, me.events[name])
1919
+ data: _chunkO6QIJQRNcjs.validate.call(void 0, name, data, me.events[name])
1920
1920
  }));
1921
1921
  const emitted = valid.map((e) => me.message(e));
1922
1922
  const meta = {
@@ -1941,7 +1941,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1941
1941
  };
1942
1942
  let committed;
1943
1943
  try {
1944
- committed = await _chunkVE3MTY4Acjs.store.call(void 0, ).commit(
1944
+ committed = await _chunkO6QIJQRNcjs.store.call(void 0, ).commit(
1945
1945
  stream,
1946
1946
  emitted,
1947
1947
  meta,
@@ -1950,7 +1950,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1950
1950
  reactingTo ? expectedVersion : expected
1951
1951
  );
1952
1952
  } catch (error) {
1953
- if (error instanceof _chunkHF433MAFcjs.ConcurrencyError) void cache_drop(stream);
1953
+ if (error instanceof _chunk7AHW7FCNcjs.ConcurrencyError) void cache_drop(stream);
1954
1954
  throw error;
1955
1955
  }
1956
1956
  let { state: state2, patches } = snapshot;
@@ -1989,19 +1989,19 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1989
1989
  }
1990
1990
  return snapshots;
1991
1991
  } catch (error) {
1992
- if (!(error instanceof _chunkHF433MAFcjs.ConcurrencyError)) throw error;
1992
+ if (!(error instanceof _chunk7AHW7FCNcjs.ConcurrencyError)) throw error;
1993
1993
  if (expectedVersion !== void 0) throw error;
1994
1994
  if (attempt >= max_retries) throw error;
1995
1995
  if (_optionalChain([opts, 'optionalAccess', _96 => _96.backoff])) {
1996
1996
  const delay_ms = compute_backoff_delay(attempt, opts.backoff);
1997
- if (delay_ms > 0) await _chunkVE3MTY4Acjs.sleep.call(void 0, delay_ms);
1997
+ if (delay_ms > 0) await _chunkO6QIJQRNcjs.sleep.call(void 0, delay_ms);
1998
1998
  }
1999
1999
  }
2000
2000
  }
2001
2001
  }
2002
2002
 
2003
2003
  // src/internal/tracing.ts
2004
- var PRETTY = _chunkVE3MTY4Acjs.config.call(void 0, ).env !== "production";
2004
+ var PRETTY = _chunkO6QIJQRNcjs.config.call(void 0, ).env !== "production";
2005
2005
  var C_BLUE = "\x1B[38;5;39m";
2006
2006
  var C_ORANGE = "\x1B[38;5;208m";
2007
2007
  var C_GREEN = "\x1B[38;5;42m";
@@ -2187,7 +2187,7 @@ function budget_exhausted(lease, options, store_failing) {
2187
2187
  if (store_failing || !_optionalChain([options, 'optionalAccess', _106 => _106.blockOnError]) || lease.retry <= options.maxRetries)
2188
2188
  return void 0;
2189
2189
  const error = `Blocking ${lease.stream} after ${lease.retry} claims with no acknowledged progress \u2014 the retry budget (${options.maxRetries}) was spent without the handler ever reporting an error. That means every attempt lost its lease before it could ack: move the reaction to a lane whose leaseMillis covers the handler, then unblock the stream.`;
2190
- _chunkVE3MTY4Acjs.log.call(void 0, ).error(error);
2190
+ _chunkO6QIJQRNcjs.log.call(void 0, ).error(error);
2191
2191
  return { lease, handled: 0, acked_at: lease.at, error, block: true };
2192
2192
  }
2193
2193
  function fetch_failure_policy(registry) {
@@ -2203,13 +2203,13 @@ function fetch_failure_policy(registry) {
2203
2203
  function finalize(lease, handled, at, error, options, logger, failed_at) {
2204
2204
  if (!error) return { lease, handled, acked_at: at };
2205
2205
  logger.error(error);
2206
- const non_retryable = error instanceof _chunkHF433MAFcjs.NonRetryableError;
2206
+ const non_retryable = error instanceof _chunk7AHW7FCNcjs.NonRetryableError;
2207
2207
  const block2 = options.blockOnError && (non_retryable || lease.retry >= options.maxRetries);
2208
2208
  if (block2)
2209
2209
  logger.error(
2210
2210
  non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
2211
2211
  );
2212
- const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkVE3MTY4Acjs.DEFAULT_BACKOFF)));
2212
+ const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkO6QIJQRNcjs.DEFAULT_BACKOFF)));
2213
2213
  return {
2214
2214
  lease,
2215
2215
  handled,
@@ -2338,7 +2338,7 @@ async function run_drain_cycle(deps, cycle) {
2338
2338
  const acked = await ops.ack(submitted);
2339
2339
  const expected = submitted.filter((l) => l.due === void 0).length;
2340
2340
  if (acked.length < expected)
2341
- _chunkVE3MTY4Acjs.log.call(void 0, ).warn(
2341
+ _chunkO6QIJQRNcjs.log.call(void 0, ).warn(
2342
2342
  `drain: ${expected - acked.length} of ${expected} acks were dropped \u2014 the lease was taken by another worker mid-handler. That work will be redelivered (at-least-once), but persistent drops mean leaseMillis is too short for this handler.`
2343
2343
  );
2344
2344
  const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
@@ -2424,9 +2424,9 @@ var DrainController = (_class5 = class {
2424
2424
  if (!this._armed) return EMPTY_DRAIN;
2425
2425
  if (this._locked) return EMPTY_DRAIN;
2426
2426
  const d = _nullishCoalesce(this._deps.defaults, () => ( {}));
2427
- const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkVE3MTY4Acjs.DEFAULT_STREAM_LIMIT));
2428
- const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkVE3MTY4Acjs.DEFAULT_EVENT_LIMIT));
2429
- const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkVE3MTY4Acjs.DEFAULT_LEASE_MILLIS));
2427
+ const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkO6QIJQRNcjs.DEFAULT_STREAM_LIMIT));
2428
+ const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkO6QIJQRNcjs.DEFAULT_EVENT_LIMIT));
2429
+ const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkO6QIJQRNcjs.DEFAULT_LEASE_MILLIS));
2430
2430
  if (this._deps.breaker.state(Date.now()) === "open")
2431
2431
  return EMPTY_DRAIN;
2432
2432
  try {
@@ -2498,7 +2498,7 @@ function pii_gate(event, fields, predicate, actor) {
2498
2498
  const { pii, ...rest } = event;
2499
2499
  if (pii == null) {
2500
2500
  const shredded = { ...data };
2501
- for (const f of fields) shredded[f] = _chunkHF433MAFcjs.SHREDDED;
2501
+ for (const f of fields) shredded[f] = _chunk7AHW7FCNcjs.SHREDDED;
2502
2502
  return { ...rest, data: shredded };
2503
2503
  }
2504
2504
  const allowed = !!actor && !!predicate && predicate(event, actor);
@@ -2509,7 +2509,7 @@ function pii_gate(event, fields, predicate, actor) {
2509
2509
  };
2510
2510
  }
2511
2511
  const redacted = { ...data };
2512
- for (const f of fields) redacted[f] = _chunkHF433MAFcjs.REDACTED;
2512
+ for (const f of fields) redacted[f] = _chunk7AHW7FCNcjs.REDACTED;
2513
2513
  return { ...rest, data: redacted };
2514
2514
  }
2515
2515
  var IDENTITY_GATE = (event) => event;
@@ -2646,7 +2646,7 @@ function make_deferred(handler, schedule) {
2646
2646
  const call = handler;
2647
2647
  const deferred = async (event, stream, app) => {
2648
2648
  const when = typeof schedule === "function" ? schedule(event) : schedule;
2649
- if (Date.now() < resolve_defer_at(when, event)) throw new (0, _chunkHF433MAFcjs.DeferSignal)(when);
2649
+ if (Date.now() < resolve_defer_at(when, event)) throw new (0, _chunk7AHW7FCNcjs.DeferSignal)(when);
2650
2650
  return call(event, stream, app);
2651
2651
  };
2652
2652
  Object.defineProperty(deferred, "name", { value: handler.name });
@@ -2715,7 +2715,7 @@ function build_handle(deps) {
2715
2715
  handled++;
2716
2716
  }
2717
2717
  } catch (error) {
2718
- if (error instanceof _chunkHF433MAFcjs.DeferSignal)
2718
+ if (error instanceof _chunk7AHW7FCNcjs.DeferSignal)
2719
2719
  return {
2720
2720
  lease,
2721
2721
  handled,
@@ -2848,7 +2848,7 @@ var SettleLoop = (_class6 = class {
2848
2848
  (async () => {
2849
2849
  await this._deps.init();
2850
2850
  let settled_drain;
2851
- for (let i = 0; i < maxPasses; i++) {
2851
+ for (let i = 0; i < maxPasses && !this._stopped; i++) {
2852
2852
  const after_before = this._deps.checkpoint();
2853
2853
  const { subscribed, last_id, scanned } = await this._deps.correlate({
2854
2854
  ...correlate_query,
@@ -2990,7 +2990,7 @@ var Act = (_class7 = class {
2990
2990
  /** Lanes to arm per event; `"all"` when a dynamic resolver hides the lane. */
2991
2991
 
2992
2992
 
2993
- __init25() {this._logger = _chunkVE3MTY4Acjs.log.call(void 0, )}
2993
+ __init25() {this._logger = _chunkO6QIJQRNcjs.log.call(void 0, )}
2994
2994
  /** This Act's ports: its own bag, or the singleton adapters. */
2995
2995
 
2996
2996
  /** Runs a body so internal `store()`/`cache()` calls resolve to `_ports`. */
@@ -3020,9 +3020,9 @@ var Act = (_class7 = class {
3020
3020
  this._lanes = lanes;
3021
3021
  this._declared_lanes = ["default", ...lanes.map((l) => l.name)];
3022
3022
  validate_only_lanes(options, lanes);
3023
- this._ports = _nullishCoalesce(options.scoped, () => ( _chunkVE3MTY4Acjs.default_scope.call(void 0, )));
3023
+ this._ports = _nullishCoalesce(options.scoped, () => ( _chunkO6QIJQRNcjs.default_scope.call(void 0, )));
3024
3024
  const ports = this._ports;
3025
- this._scoped = _chunkVE3MTY4Acjs.make_run_scoped.call(void 0, {
3025
+ this._scoped = _chunkO6QIJQRNcjs.make_run_scoped.call(void 0, {
3026
3026
  // Getters, not a spread: the singletons resolve lazily, so a later
3027
3027
  // `store(...)` / `cache(...)` still takes effect.
3028
3028
  get store() {
@@ -3032,14 +3032,14 @@ var Act = (_class7 = class {
3032
3032
  return ports.cache;
3033
3033
  },
3034
3034
  // Parsed per build, so a bad window throws on every build.
3035
- autoclose_window: _chunkVE3MTY4Acjs.resolveAutocloseConfig.call(void 0, options).autocloseWindow
3035
+ autoclose_window: _chunkO6QIJQRNcjs.resolveAutocloseConfig.call(void 0, options).autocloseWindow
3036
3036
  });
3037
3037
  this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
3038
3038
  this._es = build_es(this._logger, this._correlator, patch_fn);
3039
3039
  this._cd = build_drain(this._logger);
3040
3040
  this._handle = build_handle({
3041
3041
  logger: this._logger,
3042
- reaction_scope: _chunkVE3MTY4Acjs.make_reaction_scope.call(void 0, {
3042
+ reaction_scope: _chunkO6QIJQRNcjs.make_reaction_scope.call(void 0, {
3043
3043
  do: this._bound_do,
3044
3044
  load: this._bound_load,
3045
3045
  query: this._bound_query,
@@ -3062,12 +3062,12 @@ var Act = (_class7 = class {
3062
3062
  this._correlate = this._build_correlate(options, classification);
3063
3063
  this._settle = this._build_settle(options);
3064
3064
  this._notify_disposer = this._wire_notify(this._ports.store);
3065
- _chunkVE3MTY4Acjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
3065
+ _chunkO6QIJQRNcjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
3066
3066
  }
3067
3067
  /** Shared by drain, settle and autoclose; bad knobs throw at build. */
3068
3068
  _build_breaker(options) {
3069
3069
  return new CircuitBreaker(
3070
- _chunkVE3MTY4Acjs.resolveCircuitBreakerConfig.call(void 0, options.circuitBreaker),
3070
+ _chunkO6QIJQRNcjs.resolveCircuitBreakerConfig.call(void 0, options.circuitBreaker),
3071
3071
  {
3072
3072
  on_error: (error, circuit) => this._emit_error(error, circuit),
3073
3073
  // When the cooldown elapses, settle once: its scan or claim is the
@@ -3101,7 +3101,7 @@ var Act = (_class7 = class {
3101
3101
  try {
3102
3102
  await this._run_close(targets);
3103
3103
  } catch (error) {
3104
- if (error instanceof _chunkHF433MAFcjs.StoreError) throw error;
3104
+ if (error instanceof _chunk7AHW7FCNcjs.StoreError) throw error;
3105
3105
  this._logger.error(
3106
3106
  error,
3107
3107
  `Reaction-requested close of ${targets.map((t) => `"${t.stream}"`).join(", ")} failed and was not retried; close it with app.close(...) once the cause is fixed.`
@@ -3136,7 +3136,7 @@ var Act = (_class7 = class {
3136
3136
  /** Audit deps, built after the controllers so the lane set is final. */
3137
3137
  _build_audit_deps() {
3138
3138
  return {
3139
- store: _chunkVE3MTY4Acjs.store,
3139
+ store: _chunkO6QIJQRNcjs.store,
3140
3140
  event_to_state: this._event_to_state,
3141
3141
  // Declared lanes, not this process's controllers: a lane another
3142
3142
  // worker drains is not `unknown-lane`.
@@ -3149,7 +3149,7 @@ var Act = (_class7 = class {
3149
3149
  registry: this.registry,
3150
3150
  static_targets: classification.static_targets,
3151
3151
  cd: this._cd,
3152
- max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunkHF433MAFcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
3152
+ max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunk7AHW7FCNcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
3153
3153
  // Declared lanes (not active ones): a lane another process claims is
3154
3154
  // still a valid destination.
3155
3155
  declared_lanes: new Set(this._declared_lanes),
@@ -3163,7 +3163,7 @@ var Act = (_class7 = class {
3163
3163
  /** Cold start: an idle deferred stream still fires on time after a restart. */
3164
3164
  async _seed_persisted_defers() {
3165
3165
  const now = Date.now();
3166
- await walk_streams(_chunkVE3MTY4Acjs.store.call(void 0, ), (pos) => {
3166
+ await walk_streams(_chunkO6QIJQRNcjs.store.call(void 0, ), (pos) => {
3167
3167
  if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
3168
3168
  const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
3169
3169
  _optionalChain([controller, 'optionalAccess', _128 => _128.seed_defer, 'call', _129 => _129(pos.stream, pos.deferred_at)]);
@@ -3182,33 +3182,26 @@ var Act = (_class7 = class {
3182
3182
  on_settled: (drain) => this.emit("settled", drain),
3183
3183
  breaker: this._breaker
3184
3184
  },
3185
- _nullishCoalesce(options.settleDebounceMs, () => ( _chunkHF433MAFcjs.DEFAULT_SETTLE_DEBOUNCE_MS))
3185
+ _nullishCoalesce(options.settleDebounceMs, () => ( _chunk7AHW7FCNcjs.DEFAULT_SETTLE_DEBOUNCE_MS))
3186
3186
  );
3187
3187
  }
3188
3188
 
3189
3189
  /**
3190
- * Per-instance teardown: stop scheduling new work, give drain cycles
3191
- * already in flight a bounded chance to finish, then remove lifecycle
3192
- * listeners and tear down the cross-process notify subscription.
3190
+ * Per-instance teardown: stops scheduling, gives the cycles in flight up
3191
+ * to `graceMs` to reach their `ack` (an abandoned handler holds its lease
3192
+ * until it expires), then removes listeners and the notify subscription.
3193
+ * The budget is a ceiling, not a delay.
3193
3194
  *
3194
- * Scheduling stops first, then in-flight cycles get up to `graceMs` to
3195
- * reach their `ack` (an abandoned handler holds its lease until it
3196
- * expires). Listeners come off after the wait, so they still see work that
3197
- * finished during it. The budget is a ceiling, not a delay; when it runs
3198
- * out, teardown proceeds anyway.
3199
- *
3200
- * Idempotent — repeated calls return the same promise, and the first
3201
- * call's `graceMs` is the one that applies. Registered automatically with
3202
- * the global `dispose()` registry at construction, so process-wide
3203
- * `dispose()()` covers it; test helpers (or operators that mint
3204
- * short-lived Acts) call it explicitly for prompt cleanup.
3195
+ * Idempotent: repeated calls return the same promise, with the first
3196
+ * call's `graceMs`. Registered with the global `dispose()` registry, so
3197
+ * `dispose()()` covers it; call it directly for prompt cleanup.
3205
3198
  *
3206
3199
  * @param options - See {@link ShutdownOptions}. Defaults the grace budget
3207
3200
  * to the largest lane `leaseMillis` (capped at 30s).
3208
3201
  */
3209
3202
  shutdown(options) {
3210
3203
  if (!this._shutdown_promise) {
3211
- _chunkVE3MTY4Acjs.resolveShutdownConfig.call(void 0, options);
3204
+ _chunkO6QIJQRNcjs.resolveShutdownConfig.call(void 0, options);
3212
3205
  this._shutdown_promise = (async () => {
3213
3206
  this.stop_correlations();
3214
3207
  const disposer = await this._notify_disposer;
@@ -3228,10 +3221,10 @@ var Act = (_class7 = class {
3228
3221
  * default for none or 0, and for a running settle), capped.
3229
3222
  */
3230
3223
  _derive_grace_ms(running, settling) {
3231
- let max = settling ? _chunkVE3MTY4Acjs.DEFAULT_LEASE_MILLIS : 0;
3224
+ let max = settling ? _chunkO6QIJQRNcjs.DEFAULT_LEASE_MILLIS : 0;
3232
3225
  for (const c of running)
3233
- max = Math.max(max, c.lease_millis || _chunkVE3MTY4Acjs.DEFAULT_LEASE_MILLIS);
3234
- return Math.min(max, _chunkVE3MTY4Acjs.MAX_SHUTDOWN_GRACE_MS);
3226
+ max = Math.max(max, c.lease_millis || _chunkO6QIJQRNcjs.DEFAULT_LEASE_MILLIS);
3227
+ return Math.min(max, _chunkO6QIJQRNcjs.MAX_SHUTDOWN_GRACE_MS);
3235
3228
  }
3236
3229
  async _await_inflight(grace_ms) {
3237
3230
  const running = [...this._drain_controllers.values()].filter(
@@ -3279,15 +3272,10 @@ var Act = (_class7 = class {
3279
3272
  }
3280
3273
  }
3281
3274
  /**
3282
- * Executes an action on a state instance, committing resulting events.
3283
- *
3284
- * This is the primary method for modifying state. It:
3285
- * 1. Validates the action payload against the schema
3286
- * 2. Loads the current state snapshot
3287
- * 3. Checks invariants (business rules)
3288
- * 4. Executes the action handler to generate events
3289
- * 5. Applies events to create new state
3290
- * 6. Commits events to the store with optimistic concurrency control
3275
+ * Executes an action: validates the payload, loads the state, checks its
3276
+ * invariants, and commits the events its handler emits, with optimistic
3277
+ * concurrency on the stream. The reactions to those events settle on
3278
+ * their own (unless `autoSettle: false`).
3291
3279
  *
3292
3280
  * @template TKey - Action name from registered actions
3293
3281
  * @param action - The name of the action to execute
@@ -3321,7 +3309,7 @@ var Act = (_class7 = class {
3321
3309
  * @see {@link ValidationError}, {@link InvariantError}, {@link ConcurrencyError}
3322
3310
  */
3323
3311
  async do(action2, target, payload, options) {
3324
- const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _131 => _131.reactingTo]), () => ( _chunkVE3MTY4Acjs.current_reacting.call(void 0, )));
3312
+ const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _131 => _131.reactingTo]), () => ( _chunkO6QIJQRNcjs.current_reacting.call(void 0, )));
3325
3313
  const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _132 => _132.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
3326
3314
  return this._scoped(async () => {
3327
3315
  const snapshots = await this._es.action(
@@ -3366,9 +3354,7 @@ var Act = (_class7 = class {
3366
3354
  *
3367
3355
  * For small result sets, consider using {@link query_array} instead.
3368
3356
  *
3369
- * @param query - Filter criteria — see {@link Query} for available fields
3370
- * (`stream`, `name`, `after`, `before`, `created_after`, `created_before`,
3371
- * `limit`, `with_snaps`, `stream_exact`)
3357
+ * @param query - Filter criteria; see {@link Query} for the fields
3372
3358
  * @param callback - Optional callback invoked for each matching event
3373
3359
  * @returns Object with first event, last event, and total count
3374
3360
  *
@@ -3387,7 +3373,7 @@ var Act = (_class7 = class {
3387
3373
  return this._scoped(async () => {
3388
3374
  let first;
3389
3375
  let last;
3390
- const count = await _chunkVE3MTY4Acjs.store.call(void 0, ).query((e) => {
3376
+ const count = await _chunkO6QIJQRNcjs.store.call(void 0, ).query((e) => {
3391
3377
  const gated = this.registry.query_gate(e.name)(e);
3392
3378
  if (!first) first = gated;
3393
3379
  last = gated;
@@ -3417,7 +3403,7 @@ var Act = (_class7 = class {
3417
3403
  async query_array(query) {
3418
3404
  return this._scoped(async () => {
3419
3405
  const events = [];
3420
- await _chunkVE3MTY4Acjs.store.call(void 0, ).query((e) => {
3406
+ await _chunkO6QIJQRNcjs.store.call(void 0, ).query((e) => {
3421
3407
  events.push(this.registry.query_gate(e.name)(e));
3422
3408
  }, query);
3423
3409
  return events;
@@ -3437,14 +3423,14 @@ var Act = (_class7 = class {
3437
3423
  */
3438
3424
  async forget(stream) {
3439
3425
  return this._scoped(async () => {
3440
- const s = _chunkVE3MTY4Acjs.store.call(void 0, );
3426
+ const s = _chunkO6QIJQRNcjs.store.call(void 0, );
3441
3427
  if (!s.forget_pii) {
3442
3428
  throw new Error(
3443
3429
  `Store does not implement forget_pii \u2014 adapter cannot comply with sensitive-data erasure. Use an adapter that declares pii_isolation: true (e.g. @rotorsoft/act on the in-memory store).`
3444
3430
  );
3445
3431
  }
3446
3432
  const eventCount = await s.forget_pii(stream);
3447
- await _chunkVE3MTY4Acjs.cache.call(void 0, ).invalidate(stream);
3433
+ await _chunkO6QIJQRNcjs.cache.call(void 0, ).invalidate(stream);
3448
3434
  if (eventCount > 0) {
3449
3435
  this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
3450
3436
  }
@@ -3452,31 +3438,23 @@ var Act = (_class7 = class {
3452
3438
  });
3453
3439
  }
3454
3440
  /**
3455
- * Processes pending reactions by draining uncommitted events from the event store.
3456
- *
3457
- * Runs a single drain cycle:
3458
- * 1. Polls the store for streams with uncommitted events
3459
- * 2. Leases streams to prevent concurrent processing
3460
- * 3. Fetches events for each leased stream
3461
- * 4. Executes matching reaction handlers
3462
- * 5. Acknowledges successful reactions or blocks failing ones
3441
+ * Runs one drain cycle: claims streams with marked work (leasing them),
3442
+ * fetches their events, runs the matching reactions, and acks or blocks
3443
+ * each stream.
3463
3444
  *
3464
- * Drain uses a dual-frontier strategy to balance processing of new streams (lagging)
3465
- * vs active streams (leading). The ratio adapts based on event pressure.
3466
- *
3467
- * Call `correlate()` before `drain()`. It is not only how dynamic targets
3468
- * are discovered: a stream is claimable while `at < correlated_at`, and
3469
- * `correlate` is the only component that raises that mark, so a
3470
- * commit no correlate has seen is not drainable, static targets included. For a
3471
- * higher-level API that handles debouncing, correlation, and signaling
3472
- * automatically, use {@link settle}.
3445
+ * A stream is claimable only once `correlate()` has marked it, static
3446
+ * targets included, so a commit no correlate has seen is not drainable.
3447
+ * Apps rarely call this: each commit settles its reactions on its own.
3448
+ * With `autoSettle: false`, tests walk the pipeline with `correlate()`
3449
+ * then `drain()` (see the testing guide).
3473
3450
  *
3474
3451
  * @param options - Drain configuration — see {@link DrainOptions} for fields
3475
3452
  * (`streamLimit`, `eventLimit`, `leaseMillis`).
3476
3453
  * @returns Drain statistics with fetched, leased, acked, and blocked counts
3477
3454
  *
3478
- * @example In tests and scripts
3455
+ * @example Walking the pipeline in a test
3479
3456
  * ```typescript
3457
+ * const app = act().withState(User).withProjection(Users).build({ autoSettle: false });
3480
3458
  * await app.do("createUser", target, payload);
3481
3459
  * await app.correlate();
3482
3460
  * await app.drain();
@@ -3484,10 +3462,9 @@ var Act = (_class7 = class {
3484
3462
  *
3485
3463
  * @see {@link settle} for debounced correlate→drain with lifecycle events
3486
3464
  * @see {@link correlate} for dynamic stream discovery
3487
- * @see {@link start_correlations} for automatic correlation
3488
3465
  */
3489
3466
  async drain(options = {}) {
3490
- _chunkVE3MTY4Acjs.resolveDrainConfig.call(void 0, options);
3467
+ _chunkO6QIJQRNcjs.resolveDrainConfig.call(void 0, options);
3491
3468
  if (!this._drain)
3492
3469
  return { fetched: [], leased: [], acked: [], blocked: [] };
3493
3470
  return this._scoped(() => this._drain_all(options));
@@ -3551,32 +3528,20 @@ var Act = (_class7 = class {
3551
3528
  return { fetched, leased, acked, blocked };
3552
3529
  }
3553
3530
  /**
3554
- * Discovers and registers new streams dynamically based on reaction resolvers.
3555
- *
3556
- * Correlation enables "dynamic reactions" where target streams are determined at runtime
3557
- * based on event content. For example, you might create a stats stream for each user
3558
- * when they perform certain actions.
3559
- *
3560
- * This method scans events matching the query and identifies new target streams based
3561
- * on reaction resolvers. It then registers these streams so they'll be picked up by
3562
- * the next drain cycle.
3531
+ * Scans committed events from the correlation checkpoint, subscribes the
3532
+ * target streams their reactions resolve to (static or computed from
3533
+ * the event), and marks their work so the next drain can claim it.
3563
3534
  *
3564
3535
  * @param query - Scan filter — see {@link Query} for fields (typically
3565
- * `{ after: <event-id>, limit: <count> }`)
3536
+ * `{ limit: <count> }`; the scan starts at the checkpoint)
3566
3537
  * @returns The number of newly subscribed streams and the last scanned event id
3567
3538
  *
3568
3539
  * @example Manual correlation
3569
3540
  * ```typescript
3570
- * // Scan for new streams
3571
- * const { subscribed, last_id } = await app.correlate({ after: 0, limit: 100 });
3572
- * console.log(`Subscribed ${subscribed} new streams`);
3573
- *
3574
- * // Save last_id for next scan
3575
- * await saveCheckpoint(last_id);
3541
+ * const { subscribed } = await app.correlate({ limit: 100 });
3576
3542
  * ```
3577
3543
  *
3578
3544
  * @see {@link start_correlations} for automatic periodic correlation
3579
- * @see {@link stop_correlations} to stop automatic correlation
3580
3545
  */
3581
3546
  async correlate(query = { after: -1, limit: 10 }) {
3582
3547
  const { subscribed, last_id } = await this._correlate_scanned(query);
@@ -3594,7 +3559,7 @@ var Act = (_class7 = class {
3594
3559
  /**
3595
3560
  * Starts a background poll that settles on a timer: each tick looks for
3596
3561
  * new events, subscribes the streams their reactions target, and drains
3597
- * them.
3562
+ * them, along with any stream whose lease a dead worker let expire.
3598
3563
  *
3599
3564
  * Use it when this process can miss commits — another process writes to a
3600
3565
  * store without `notify`, or a notification is lost. It is the safety net
@@ -3623,7 +3588,7 @@ var Act = (_class7 = class {
3623
3588
  if (this._poll) return false;
3624
3589
  this._poll_limit = query.limit || void 0;
3625
3590
  this._poll = setInterval(() => {
3626
- this._correlate.arm();
3591
+ this._arm_all();
3627
3592
  this._schedule();
3628
3593
  }, frequency);
3629
3594
  return true;
@@ -3656,15 +3621,13 @@ var Act = (_class7 = class {
3656
3621
  * events through their reactions.
3657
3622
  *
3658
3623
  * Use this to replay events through projections (or other reaction targets)
3659
- * after changing handler logic. Equivalent to calling `store().reset(streams)`
3660
- * directly, but also raises the orchestrator's internal "needs drain" flag —
3661
- * `store().reset(...)` alone leaves the flag untouched, so a settled app
3662
- * would short-circuit and skip the replay.
3663
- *
3664
- * The reset schedules a settle on its own, which loops correlate→drain
3665
- * until the replay catches up. Call `app.settle(options)` right after to
3666
- * give that pass batch options, or
3667
- * `correlate()` / `drain()` to drive the replay by hand.
3624
+ * after changing handler logic. It rewinds the same watermarks as
3625
+ * `store().reset(streams)`, and also wakes the drain and schedules a
3626
+ * settle, which loops correlate→drain until the replay catches up;
3627
+ * `store().reset(...)` alone leaves a settled app idle. Call
3628
+ * `app.settle(options)` right after to give that pass batch options, or,
3629
+ * with `autoSettle: false`, `correlate()` / `drain()` to drive the replay
3630
+ * by hand.
3668
3631
  *
3669
3632
  * @param input - Reaction target streams (e.g., projection names) to reset, or a {@link StreamFilter} for bulk operations
3670
3633
  * @returns Count of streams that were actually reset
@@ -3680,7 +3643,7 @@ var Act = (_class7 = class {
3680
3643
  */
3681
3644
  async reset(input) {
3682
3645
  return this._scoped(async () => {
3683
- const count = await _chunkVE3MTY4Acjs.store.call(void 0, ).reset(input);
3646
+ const count = await _chunkO6QIJQRNcjs.store.call(void 0, ).reset(input);
3684
3647
  for (const handler of this._batch_handlers.values())
3685
3648
  _optionalChain([handler, 'access', _139 => _139[FOLD_RESET], 'optionalCall', _140 => _140()]);
3686
3649
  if (count > 0) {
@@ -3717,7 +3680,7 @@ var Act = (_class7 = class {
3717
3680
  */
3718
3681
  async unblock(input) {
3719
3682
  return this._scoped(async () => {
3720
- const count = await _chunkVE3MTY4Acjs.store.call(void 0, ).unblock(input);
3683
+ const count = await _chunkO6QIJQRNcjs.store.call(void 0, ).unblock(input);
3721
3684
  if (count > 0) {
3722
3685
  this._arm_all();
3723
3686
  this._settle_armed(this._reactive);
@@ -3767,7 +3730,7 @@ var Act = (_class7 = class {
3767
3730
  return { ...partial, duration_ms: Date.now() - started };
3768
3731
  }
3769
3732
  const target = _nullishCoalesce(sink, () => ( (() => {
3770
- const s = _chunkVE3MTY4Acjs.store.call(void 0, );
3733
+ const s = _chunkO6QIJQRNcjs.store.call(void 0, );
3771
3734
  if (!s.restore) throw new Error("adapter has no restore capability");
3772
3735
  return s;
3773
3736
  })()));
@@ -3813,7 +3776,7 @@ var Act = (_class7 = class {
3813
3776
  async blocked_streams(options) {
3814
3777
  return this._scoped(async () => {
3815
3778
  const positions = [];
3816
- await _chunkVE3MTY4Acjs.store.call(void 0, ).query_streams(
3779
+ await _chunkO6QIJQRNcjs.store.call(void 0, ).query_streams(
3817
3780
  (p) => {
3818
3781
  positions.push(p);
3819
3782
  },
@@ -3823,45 +3786,20 @@ var Act = (_class7 = class {
3823
3786
  });
3824
3787
  }
3825
3788
  /**
3826
- * Operator-driven store audit.
3827
- *
3828
- * Walks the connected store and yields per-category findings —
3829
- * each tagged with the remediation it suggests. Same operator-
3830
- * driven category as `app.close()` / `app.reset()` /
3831
- * `app.unblock()` / `app.blocked_streams()`: never auto-invoked by
3832
- * the framework; the operator decides when to run it (CI gate,
3833
- * scheduled job, ad-hoc forensics) and what to do with the
3834
- * findings.
3789
+ * Operator-driven store audit: walks the store and yields findings per
3790
+ * category, each with the remediation it suggests. Never run by the
3791
+ * framework. Pass a subset of categories to scope the work; the iterable
3792
+ * can be broken early, and findings stream without buffering the report.
3835
3793
  *
3836
- * Categories are independent — pass a subset to scope the work,
3837
- * or omit to run everything:
3794
+ * @param categories - Subset of categories to run (default: all).
3795
+ * @param options - Query window + per-category thresholds.
3796
+ * @returns Async iterable of {@link AuditFinding}.
3838
3797
  *
3798
+ * @example Schema drift since the last scan
3839
3799
  * ```typescript
3840
- * // Targeted: schema drift + deprecated-event load only
3841
- * for await (const f of app.audit(["schema", "deprecated-load"], {
3842
- * query: { created_after: lastScan },
3843
- * thresholds: { deprecatedLoadShareMin: 0.10 },
3844
- * })) {
3800
+ * for await (const f of app.audit(["schema"], { query: { created_after: lastScan } }))
3845
3801
  * await escalate(f);
3846
- * }
3847
- *
3848
- * // Full audit, default thresholds
3849
- * for await (const f of app.audit()) console.log(f);
3850
3802
  * ```
3851
- *
3852
- * Returns an `AsyncIterable` so callers can `break` early — the
3853
- * underlying store paginations respect the iterator protocol and
3854
- * stop cleanly. Each finding is emitted independently, so
3855
- * pipelining into Slack / persistence / further analysis works
3856
- * without buffering the full report in memory.
3857
- *
3858
- * Findings shape — see {@link AuditFinding}. The discriminated
3859
- * union carries enough context for the operator to act on each
3860
- * finding directly: stream id, event id, recommendation hints.
3861
- *
3862
- * @param categories - Subset of categories to run (default: all).
3863
- * @param options - Query window + per-category thresholds.
3864
- * @returns Async iterable of {@link AuditFinding}.
3865
3803
  */
3866
3804
  async *audit(categories, options) {
3867
3805
  const it = audit(this._audit_deps, categories, options)[Symbol.asyncIterator]();
@@ -3872,22 +3810,13 @@ var Act = (_class7 = class {
3872
3810
  }
3873
3811
  }
3874
3812
  /**
3875
- * Bulk-update scheduling priority for streams matching `filter`.
3876
- *
3877
- * Operator-grade override of the `claim()` lagging-frontier
3878
- * ordering. Useful when a long-running replay needs to
3879
- * jump ahead of other lagging streams, or when a no-longer-urgent
3880
- * job should yield slots back to the rest. Build-time priorities
3881
- * (set via the resolver's `priority` field) are subject to a
3882
- * `max()` invariant across reactions; this API ignores that and
3883
- * sets the priority outright on every matching row.
3884
- *
3885
- * Filter shape mirrors {@link query} / {@link Store.query_streams}:
3886
- * `stream` / `source` are regex by default, exact with the
3887
- * `*_exact` flags; `blocked` restricts to blocked or unblocked
3888
- * rows. **An empty filter (`{}`) updates every registered stream.**
3813
+ * Sets the scheduling priority of every stream matching `filter`, as-is:
3814
+ * unlike build-time priorities (the highest across reactions wins), this
3815
+ * overrides them. Useful to let a long replay jump ahead of other lagging
3816
+ * streams, or to yield slots back. **An empty filter (`{}`) updates every
3817
+ * registered stream.**
3889
3818
  *
3890
- * @param filter - Selection criteria (regex by default).
3819
+ * @param filter - Selection criteria (regex by default, like {@link query}).
3891
3820
  * @param priority - New priority value. Set as-is — no clamp.
3892
3821
  * @returns Count of streams whose priority changed.
3893
3822
  *
@@ -3897,10 +3826,9 @@ var Act = (_class7 = class {
3897
3826
  * ```
3898
3827
  *
3899
3828
  * @see {@link Store.prioritize} for the underlying primitive
3900
- * @see {@link claim} for how priority biases scheduling
3901
3829
  */
3902
3830
  async prioritize(filter, priority) {
3903
- return this._scoped(() => _chunkVE3MTY4Acjs.store.call(void 0, ).prioritize(filter, priority));
3831
+ return this._scoped(() => _chunkO6QIJQRNcjs.store.call(void 0, ).prioritize(filter, priority));
3904
3832
  }
3905
3833
  /** Shared by `close()` and reaction-requested closes. */
3906
3834
  async _run_close(targets) {
@@ -3924,30 +3852,12 @@ var Act = (_class7 = class {
3924
3852
  return result;
3925
3853
  }
3926
3854
  /**
3927
- * Close the books — guard, archive, truncate, and optionally restart streams.
3928
- *
3929
- * Safely removes historical events from the operational store:
3930
- *
3931
- * 1. **Correlate** — discover pending reaction targets
3932
- * 2. **Safety check** — skip streams with pending reactions (skipped when no reactive events)
3933
- * 3. **Guard** — commit `__tombstone__` with `expectedVersion` to block concurrent writes
3934
- * 4. **Load state** — for streams in `snapshots`, load final state while guarded (no races)
3935
- * 5. **Archive** — user callback per stream (abort-all on failure, streams are guarded)
3936
- * 6. **Truncate + seed** — atomic: delete all events, insert `__snapshot__` or `__tombstone__`
3937
- * 7. **Cache** — invalidate (tombstoned) or warm (restarted)
3938
- * 8. **Emit "closed"** — lifecycle event with results
3939
- *
3940
- * Targets carrying `before` take the **windowed** branch instead —
3941
- * close the books on a rolling window: probe the min consumer
3942
- * watermark (so the boundary never rises past a lagging reaction),
3943
- * run the archive callback against the cutoff, then prune the prefix
3944
- * below the closest safe `__snapshot__`. No tombstone guard (the
3945
- * pre-cutoff prefix is immutable), no seed, cache untouched — the
3946
- * stream stays live and keeps accepting actions. Requires the state
3947
- * to snapshot via `.snap(...)`; no qualifying snapshot ⇒ the stream
3948
- * lands in `skipped` (retry after the next snapshot). Windowed
3949
- * entries in the result echo `before` and carry the surviving
3950
- * boundary snapshot as `committed`.
3855
+ * Close the books: guard, archive, truncate, and optionally restart
3856
+ * streams. A stream with pending reactions is skipped; an archive
3857
+ * failure aborts the whole close while the streams are still guarded.
3858
+ * Targets carrying `before` prune a rolling window instead and leave the
3859
+ * stream live (needs `.snap(...)`). The phases and their failure
3860
+ * semantics are in the close-cycle architecture page.
3951
3861
  *
3952
3862
  * @param targets - Per-stream close options (stream, restart?, archive?, before?)
3953
3863
  * @returns `{ truncated: TruncateResult, skipped: string[] }`
@@ -3982,7 +3892,8 @@ var Act = (_class7 = class {
3982
3892
  * `debounceMs` (default 10), `correlate.limit` (default 100, or the
3983
3893
  * poll's limit while `start_correlations` runs; `after` is always the
3984
3894
  * checkpoint),
3985
- * `maxPasses` (default `Infinity` — kill-switch for runaway loops),
3895
+ * `maxPasses` (default `Infinity`; caps this settle's passes, not the
3896
+ * passes a reaction chain's own commits schedule),
3986
3897
  * `streamLimit` (default 10), `eventLimit` (default 10),
3987
3898
  * `leaseMillis` (default 10000).
3988
3899
  *
@@ -3999,7 +3910,7 @@ var Act = (_class7 = class {
3999
3910
  * @see {@link correlate} for manual correlation
4000
3911
  */
4001
3912
  settle(options) {
4002
- _chunkVE3MTY4Acjs.resolveSettleConfig.call(void 0, _nullishCoalesce(options, () => ( {})));
3913
+ _chunkO6QIJQRNcjs.resolveSettleConfig.call(void 0, _nullishCoalesce(options, () => ( {})));
4003
3914
  this._schedule(options);
4004
3915
  }
4005
3916
  }, _class7);
@@ -4155,16 +4066,16 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
4155
4066
  }),
4156
4067
  // Never block on autoclose: a transient query/store error should retry,
4157
4068
  // not quarantine the synthetic stream.
4158
- options: { blockOnError: false, maxRetries: _chunkVE3MTY4Acjs.DEFAULT_MAX_RETRIES },
4069
+ options: { blockOnError: false, maxRetries: _chunkO6QIJQRNcjs.DEFAULT_MAX_RETRIES },
4159
4070
  handler: async (event) => {
4160
4071
  const aggregate = event.stream;
4161
4072
  const window = read_window();
4162
4073
  if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
4163
- throw new (0, _chunkHF433MAFcjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
4164
- const stats = await _chunkVE3MTY4Acjs.store.call(void 0, ).query_stats([aggregate], {
4074
+ throw new (0, _chunk7AHW7FCNcjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
4075
+ const stats = await _chunkO6QIJQRNcjs.store.call(void 0, ).query_stats([aggregate], {
4165
4076
  count: true,
4166
4077
  tail: keep_days !== void 0 ? true : void 0,
4167
- exclude: [_chunkHF433MAFcjs.TOMBSTONE_EVENT, _chunkHF433MAFcjs.SNAP_EVENT]
4078
+ exclude: [_chunk7AHW7FCNcjs.TOMBSTONE_EVENT, _chunk7AHW7FCNcjs.SNAP_EVENT]
4168
4079
  });
4169
4080
  const entry = stats.get(aggregate);
4170
4081
  if (!entry) return;
@@ -4195,7 +4106,7 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
4195
4106
  dues.push(days_after(entry.tail.created, keep_days));
4196
4107
  const future = dues.map((d) => d.getTime()).filter((t) => t > Date.now());
4197
4108
  if (future.length)
4198
- throw new (0, _chunkHF433MAFcjs.DeferSignal)({ at: new Date(Math.min(...future)) });
4109
+ throw new (0, _chunk7AHW7FCNcjs.DeferSignal)({ at: new Date(Math.min(...future)) });
4199
4110
  }
4200
4111
  };
4201
4112
  const key = `__autoclose_${st.name}`;
@@ -4399,8 +4310,8 @@ var _this_ = ({ stream }) => ({
4399
4310
 
4400
4311
  // src/builders/builder-utils.ts
4401
4312
  function register_lane(config2, lanes) {
4402
- if (config2.name === _chunkHF433MAFcjs.DEFAULT_LANE)
4403
- throw new Error(`Lane "${_chunkHF433MAFcjs.DEFAULT_LANE}" is reserved`);
4313
+ if (config2.name === _chunk7AHW7FCNcjs.DEFAULT_LANE)
4314
+ throw new Error(`Lane "${_chunk7AHW7FCNcjs.DEFAULT_LANE}" is reserved`);
4404
4315
  if (lanes.some((l) => l.name === config2.name))
4405
4316
  throw new Error(`Lane "${config2.name}" was already declared`);
4406
4317
  lanes.push(config2);
@@ -4422,9 +4333,9 @@ function reaction_on(event, events, builder) {
4422
4333
  // Validate the whole bag at the declaration site so a bad
4423
4334
  // `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
4424
4335
  // not a NaN gate on the first retry.
4425
- options: _chunkVE3MTY4Acjs.resolveReactionConfig.call(void 0, {
4426
- blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _155 => _155.blockOnError]), () => ( _chunkVE3MTY4Acjs.DEFAULT_BLOCK_ON_ERROR)),
4427
- maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _156 => _156.maxRetries]), () => ( _chunkVE3MTY4Acjs.DEFAULT_MAX_RETRIES)),
4336
+ options: _chunkO6QIJQRNcjs.resolveReactionConfig.call(void 0, {
4337
+ blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _155 => _155.blockOnError]), () => ( _chunkO6QIJQRNcjs.DEFAULT_BLOCK_ON_ERROR)),
4338
+ maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _156 => _156.maxRetries]), () => ( _chunkO6QIJQRNcjs.DEFAULT_MAX_RETRIES)),
4428
4339
  backoff: _optionalChain([options, 'optionalAccess', _157 => _157.backoff])
4429
4340
  })
4430
4341
  };
@@ -4514,7 +4425,7 @@ function date_reviver_schema(schema) {
4514
4425
 
4515
4426
  // src/builders/event-builder.ts
4516
4427
  function event_tags(schema) {
4517
- const pii = _chunkHF433MAFcjs.pii_schemas.call(void 0, schema);
4428
+ const pii = _chunk7AHW7FCNcjs.pii_schemas.call(void 0, schema);
4518
4429
  const pii_dates = {};
4519
4430
  for (const [key, field] of Object.entries(pii)) {
4520
4431
  const dates = date_reviver_schema(field);
@@ -4551,7 +4462,7 @@ function make_event_reader(tags, disclosure, predicate = null) {
4551
4462
  });
4552
4463
  }
4553
4464
  function build_events(registry, states, lanes, owners) {
4554
- const declared = /* @__PURE__ */ new Set([_chunkHF433MAFcjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
4465
+ const declared = /* @__PURE__ */ new Set([_chunk7AHW7FCNcjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
4555
4466
  const lane_errors = [];
4556
4467
  const tags = /* @__PURE__ */ new Map();
4557
4468
  const sensitive2 = /* @__PURE__ */ new Map();
@@ -4615,7 +4526,7 @@ function build_events(registry, states, lanes, owners) {
4615
4526
  if (reader) readers.set(event_name, reader);
4616
4527
  }
4617
4528
  const snap2 = make_event_reader(event_tags(state2.state), "redact", null);
4618
- if (snap2) readers.set(_chunkHF433MAFcjs.SNAP_EVENT, snap2);
4529
+ if (snap2) readers.set(_chunk7AHW7FCNcjs.SNAP_EVENT, snap2);
4619
4530
  if (readers.size === 0) continue;
4620
4531
  state2.view = (event, actor) => (_nullishCoalesce(readers.get(event.name), () => ( IDENTITY_GATE)))(event, actor);
4621
4532
  }
@@ -4731,7 +4642,7 @@ function act() {
4731
4642
  const list = deprecation_summary.map(
4732
4643
  (d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
4733
4644
  ).join(", ");
4734
- _chunkVE3MTY4Acjs.log.call(void 0, ).info(
4645
+ _chunkO6QIJQRNcjs.log.call(void 0, ).info(
4735
4646
  `Act registered ${deprecation_summary.length} deprecated event(s): ${list}. These are legacy versions kept for the read path. Consider truncating closed streams via app.close() when feasible to reduce historical event load. See docs/docs/architecture/event-schema-evolution.md.`
4736
4647
  );
4737
4648
  }
@@ -4776,7 +4687,7 @@ function act() {
4776
4687
  withActor: () => builder,
4777
4688
  withLane: (config2) => {
4778
4689
  if (_built) closed("withLane");
4779
- register_lane(_chunkVE3MTY4Acjs.resolveLaneConfig.call(void 0, config2), lanes);
4690
+ register_lane(_chunkO6QIJQRNcjs.resolveLaneConfig.call(void 0, config2), lanes);
4780
4691
  return builder;
4781
4692
  },
4782
4693
  on: (event) => {
@@ -4784,7 +4695,7 @@ function act() {
4784
4695
  return reaction_on(event, registry.events, builder);
4785
4696
  },
4786
4697
  build: (options) => {
4787
- _chunkVE3MTY4Acjs.resolveActConfig.call(void 0, options);
4698
+ _chunkO6QIJQRNcjs.resolveActConfig.call(void 0, options);
4788
4699
  const patch_fn = _optionalChain([options, 'optionalAccess', _169 => _169.validateFoldedState]) === true ? validating_patch : bare_patch;
4789
4700
  if (!_built) {
4790
4701
  for (const proj of pending_projections) add_projection(proj);
@@ -4836,7 +4747,7 @@ function act() {
4836
4747
  synthesize_autoclose_reactions(
4837
4748
  registry,
4838
4749
  states,
4839
- _chunkVE3MTY4Acjs.current_autoclose_window
4750
+ _chunkO6QIJQRNcjs.current_autoclose_window
4840
4751
  );
4841
4752
  Object.freeze(registry.actions);
4842
4753
  Object.freeze(registry.events);
@@ -4879,8 +4790,8 @@ function _projection(target) {
4879
4790
  handler,
4880
4791
  resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
4881
4792
  options: {
4882
- blockOnError: _chunkVE3MTY4Acjs.DEFAULT_BLOCK_ON_ERROR,
4883
- maxRetries: _chunkVE3MTY4Acjs.DEFAULT_MAX_RETRIES
4793
+ blockOnError: _chunkO6QIJQRNcjs.DEFAULT_BLOCK_ON_ERROR,
4794
+ maxRetries: _chunkO6QIJQRNcjs.DEFAULT_MAX_RETRIES
4884
4795
  }
4885
4796
  };
4886
4797
  const register = events[event];
@@ -4936,7 +4847,7 @@ function _projection(target) {
4936
4847
  throw new Error(
4937
4848
  `Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
4938
4849
  );
4939
- const config2 = _chunkVE3MTY4Acjs.resolveFoldConfig.call(void 0, options);
4850
+ const config2 = _chunkO6QIJQRNcjs.resolveFoldConfig.call(void 0, options);
4940
4851
  const fold_events = {};
4941
4852
  for (const partial of partials)
4942
4853
  for (const [event_name, schema] of Object.entries(partial.events)) {
@@ -4954,8 +4865,8 @@ function _projection(target) {
4954
4865
  handler: noop,
4955
4866
  resolver: { target },
4956
4867
  options: {
4957
- blockOnError: _chunkVE3MTY4Acjs.DEFAULT_BLOCK_ON_ERROR,
4958
- maxRetries: _chunkVE3MTY4Acjs.DEFAULT_MAX_RETRIES
4868
+ blockOnError: _chunkO6QIJQRNcjs.DEFAULT_BLOCK_ON_ERROR,
4869
+ maxRetries: _chunkO6QIJQRNcjs.DEFAULT_MAX_RETRIES
4959
4870
  }
4960
4871
  }
4961
4872
  ]
@@ -4998,7 +4909,7 @@ function slice() {
4998
4909
  return builder;
4999
4910
  },
5000
4911
  withLane: (config2) => {
5001
- register_lane(_chunkVE3MTY4Acjs.resolveLaneConfig.call(void 0, config2), lanes);
4912
+ register_lane(_chunkO6QIJQRNcjs.resolveLaneConfig.call(void 0, config2), lanes);
5002
4913
  return builder;
5003
4914
  },
5004
4915
  on: (event) => reaction_on(event, events, builder),
@@ -5071,7 +4982,7 @@ function action_builder(state2) {
5071
4982
  throw new Error(`Duplicate action "${action2}"`);
5072
4983
  internal.actions[action2] = schema;
5073
4984
  if (options) {
5074
- _chunkVE3MTY4Acjs.resolveActionConfig.call(void 0, options);
4985
+ _chunkO6QIJQRNcjs.resolveActionConfig.call(void 0, options);
5075
4986
  internal.options ??= {};
5076
4987
  internal.options[action2] = options;
5077
4988
  }
@@ -5360,5 +5271,5 @@ function write_line(writer, line) {
5360
5271
 
5361
5272
 
5362
5273
 
5363
- exports.Act = Act; exports.ActorSchema = _chunkHF433MAFcjs.ActorSchema; exports.CausationEventSchema = _chunkHF433MAFcjs.CausationEventSchema; exports.CommittedMetaSchema = _chunkHF433MAFcjs.CommittedMetaSchema; exports.ConcurrencyError = _chunkHF433MAFcjs.ConcurrencyError; exports.ConsoleLogger = _chunkVE3MTY4Acjs.ConsoleLogger; exports.CsvFile = CsvFile; exports.DEFAULT_LANE = _chunkHF433MAFcjs.DEFAULT_LANE; exports.DEFAULT_MAX_SUBSCRIBED_STREAMS = _chunkHF433MAFcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS; exports.DEFAULT_SETTLE_DEBOUNCE_MS = _chunkHF433MAFcjs.DEFAULT_SETTLE_DEBOUNCE_MS; exports.DeferSignal = _chunkHF433MAFcjs.DeferSignal; exports.Environments = _chunkHF433MAFcjs.Environments; exports.Errors = _chunkHF433MAFcjs.Errors; exports.EventMetaSchema = _chunkHF433MAFcjs.EventMetaSchema; exports.ExitCodes = _chunkHF433MAFcjs.ExitCodes; exports.InMemoryCache = _chunkVE3MTY4Acjs.InMemoryCache; exports.InMemoryStore = _chunkVE3MTY4Acjs.InMemoryStore; exports.InvariantError = _chunkHF433MAFcjs.InvariantError; exports.LogLevels = _chunkHF433MAFcjs.LogLevels; exports.NonRetryableError = _chunkHF433MAFcjs.NonRetryableError; exports.PackageSchema = _chunkVE3MTY4Acjs.PackageSchema; exports.QuerySchema = _chunkHF433MAFcjs.QuerySchema; exports.REDACTED = _chunkHF433MAFcjs.REDACTED; exports.SHREDDED = _chunkHF433MAFcjs.SHREDDED; exports.SNAP_EVENT = _chunkHF433MAFcjs.SNAP_EVENT; exports.StoreError = _chunkHF433MAFcjs.StoreError; exports.StreamClosedError = _chunkHF433MAFcjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunkHF433MAFcjs.TOMBSTONE_EVENT; exports.TargetSchema = _chunkHF433MAFcjs.TargetSchema; exports.ValidationError = _chunkHF433MAFcjs.ValidationError; exports.ZodEmpty = _chunkHF433MAFcjs.ZodEmpty; exports.act = act; exports.cache = _chunkVE3MTY4Acjs.cache; exports.config = _chunkVE3MTY4Acjs.config; exports.dateReviver = _chunkVE3MTY4Acjs.dateReviver; exports.default_scope = _chunkVE3MTY4Acjs.default_scope; exports.dispose = _chunkVE3MTY4Acjs.dispose; exports.disposeAndExit = _chunkVE3MTY4Acjs.disposeAndExit; exports.extend = _chunkVE3MTY4Acjs.extend; exports.is_literal_source = _chunkVE3MTY4Acjs.is_literal_source; exports.log = _chunkVE3MTY4Acjs.log; exports.pii_fields = _chunkHF433MAFcjs.pii_fields; exports.port = _chunkVE3MTY4Acjs.port; exports.projection = projection; exports.resolveAutocloseConfig = _chunkVE3MTY4Acjs.resolveAutocloseConfig2; exports.sensitive = _chunkHF433MAFcjs.sensitive; exports.sleep = _chunkVE3MTY4Acjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkVE3MTY4Acjs.store; exports.validate = _chunkVE3MTY4Acjs.validate;
5274
+ exports.Act = Act; exports.ActorSchema = _chunk7AHW7FCNcjs.ActorSchema; exports.CausationEventSchema = _chunk7AHW7FCNcjs.CausationEventSchema; exports.CommittedMetaSchema = _chunk7AHW7FCNcjs.CommittedMetaSchema; exports.ConcurrencyError = _chunk7AHW7FCNcjs.ConcurrencyError; exports.ConsoleLogger = _chunkO6QIJQRNcjs.ConsoleLogger; exports.CsvFile = CsvFile; exports.DEFAULT_LANE = _chunk7AHW7FCNcjs.DEFAULT_LANE; exports.DEFAULT_MAX_SUBSCRIBED_STREAMS = _chunk7AHW7FCNcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS; exports.DEFAULT_SETTLE_DEBOUNCE_MS = _chunk7AHW7FCNcjs.DEFAULT_SETTLE_DEBOUNCE_MS; exports.DeferSignal = _chunk7AHW7FCNcjs.DeferSignal; exports.Environments = _chunk7AHW7FCNcjs.Environments; exports.Errors = _chunk7AHW7FCNcjs.Errors; exports.EventMetaSchema = _chunk7AHW7FCNcjs.EventMetaSchema; exports.ExitCodes = _chunk7AHW7FCNcjs.ExitCodes; exports.InMemoryCache = _chunkO6QIJQRNcjs.InMemoryCache; exports.InMemoryStore = _chunkO6QIJQRNcjs.InMemoryStore; exports.InvariantError = _chunk7AHW7FCNcjs.InvariantError; exports.LogLevels = _chunk7AHW7FCNcjs.LogLevels; exports.NonRetryableError = _chunk7AHW7FCNcjs.NonRetryableError; exports.PackageSchema = _chunkO6QIJQRNcjs.PackageSchema; exports.QuerySchema = _chunk7AHW7FCNcjs.QuerySchema; exports.REDACTED = _chunk7AHW7FCNcjs.REDACTED; exports.SHREDDED = _chunk7AHW7FCNcjs.SHREDDED; exports.SNAP_EVENT = _chunk7AHW7FCNcjs.SNAP_EVENT; exports.StoreError = _chunk7AHW7FCNcjs.StoreError; exports.StreamClosedError = _chunk7AHW7FCNcjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunk7AHW7FCNcjs.TOMBSTONE_EVENT; exports.TargetSchema = _chunk7AHW7FCNcjs.TargetSchema; exports.ValidationError = _chunk7AHW7FCNcjs.ValidationError; exports.ZodEmpty = _chunk7AHW7FCNcjs.ZodEmpty; exports.act = act; exports.cache = _chunkO6QIJQRNcjs.cache; exports.config = _chunkO6QIJQRNcjs.config; exports.dateReviver = _chunkO6QIJQRNcjs.dateReviver; exports.default_scope = _chunkO6QIJQRNcjs.default_scope; exports.dispose = _chunkO6QIJQRNcjs.dispose; exports.disposeAndExit = _chunkO6QIJQRNcjs.disposeAndExit; exports.extend = _chunkO6QIJQRNcjs.extend; exports.is_literal_source = _chunkO6QIJQRNcjs.is_literal_source; exports.log = _chunkO6QIJQRNcjs.log; exports.pii_fields = _chunk7AHW7FCNcjs.pii_fields; exports.port = _chunkO6QIJQRNcjs.port; exports.projection = projection; exports.resolveAutocloseConfig = _chunkO6QIJQRNcjs.resolveAutocloseConfig2; exports.sensitive = _chunk7AHW7FCNcjs.sensitive; exports.sleep = _chunkO6QIJQRNcjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkO6QIJQRNcjs.store; exports.validate = _chunkO6QIJQRNcjs.validate;
5364
5275
  //# sourceMappingURL=index.cjs.map