@rotorsoft/act 1.37.3 → 1.37.4

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 _chunkBYTYS2LBcjs = require('./chunk-BYTYS2LB.cjs');
43
+ var _chunkUPKDCTS2cjs = require('./chunk-UPKDCTS2.cjs');
44
44
 
45
45
 
46
46
 
@@ -71,24 +71,26 @@ var _chunkBYTYS2LBcjs = require('./chunk-BYTYS2LB.cjs');
71
71
 
72
72
 
73
73
 
74
- var _chunkTCADE3WYcjs = require('./chunk-TCADE3WY.cjs');
74
+
75
+
76
+ var _chunkPN5GNW6Ecjs = require('./chunk-PN5GNW6E.cjs');
75
77
 
76
78
  // src/signals.ts
77
79
  process.once("SIGINT", async (arg) => {
78
- _chunkBYTYS2LBcjs.log.call(void 0, ).info(arg, "SIGINT");
79
- await _chunkBYTYS2LBcjs.disposeAndExit.call(void 0, "EXIT");
80
+ _chunkUPKDCTS2cjs.log.call(void 0, ).info(arg, "SIGINT");
81
+ await _chunkUPKDCTS2cjs.disposeAndExit.call(void 0, "EXIT");
80
82
  });
81
83
  process.once("SIGTERM", async (arg) => {
82
- _chunkBYTYS2LBcjs.log.call(void 0, ).info(arg, "SIGTERM");
83
- await _chunkBYTYS2LBcjs.disposeAndExit.call(void 0, "EXIT");
84
+ _chunkUPKDCTS2cjs.log.call(void 0, ).info(arg, "SIGTERM");
85
+ await _chunkUPKDCTS2cjs.disposeAndExit.call(void 0, "EXIT");
84
86
  });
85
87
  process.once("uncaughtException", async (arg) => {
86
- _chunkBYTYS2LBcjs.log.call(void 0, ).error(arg, "Uncaught Exception");
87
- await _chunkBYTYS2LBcjs.disposeAndExit.call(void 0, "ERROR");
88
+ _chunkUPKDCTS2cjs.log.call(void 0, ).error(arg, "Uncaught Exception");
89
+ await _chunkUPKDCTS2cjs.disposeAndExit.call(void 0, "ERROR");
88
90
  });
89
91
  process.once("unhandledRejection", async (arg) => {
90
- _chunkBYTYS2LBcjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
91
- await _chunkBYTYS2LBcjs.disposeAndExit.call(void 0, "ERROR");
92
+ _chunkUPKDCTS2cjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
93
+ await _chunkUPKDCTS2cjs.disposeAndExit.call(void 0, "ERROR");
92
94
  });
93
95
 
94
96
  // src/act.ts
@@ -196,7 +198,7 @@ async function* audit(deps, categories, options = {}) {
196
198
  if (need_stats) {
197
199
  const stats = await deps.store().query_stats(
198
200
  {},
199
- { count: true, names: true, exclude: [_chunkTCADE3WYcjs.SNAP_EVENT] }
201
+ { count: true, names: true, exclude: [_chunkPN5GNW6Ecjs.SNAP_EVENT] }
200
202
  );
201
203
  for (const [stream, s] of stats) {
202
204
  for (const p of passes) _optionalChain([p, 'access', _4 => _4.on_stat, 'optionalCall', _5 => _5(stream, s)]);
@@ -278,7 +280,7 @@ var make_schema_pass = (deps) => {
278
280
  return;
279
281
  }
280
282
  const schema = state2.events[name];
281
- const sensitive2 = _chunkTCADE3WYcjs.pii_fields.call(void 0, schema);
283
+ const sensitive2 = _chunkPN5GNW6Ecjs.pii_fields.call(void 0, schema);
282
284
  let parse_schema = schema;
283
285
  if (sensitive2.length > 0) {
284
286
  const omitter = schema.omit;
@@ -412,7 +414,7 @@ var make_restart_candidate_pass = (deps, options) => {
412
414
  {
413
415
  stream,
414
416
  stream_exact: true,
415
- names: [_chunkTCADE3WYcjs.SNAP_EVENT],
417
+ names: [_chunkPN5GNW6Ecjs.SNAP_EVENT],
416
418
  with_snaps: true
417
419
  }
418
420
  );
@@ -839,7 +841,7 @@ async function run_close_cycle(targets, deps) {
839
841
  deps,
840
842
  () => run_full_closes(full, target_map, deps, skipped)
841
843
  );
842
- const retired = [...truncated.entries()].filter(([, r]) => r.committed.name === _chunkTCADE3WYcjs.TOMBSTONE_EVENT).map(([stream]) => stream);
844
+ const retired = [...truncated.entries()].filter(([, r]) => r.committed.name === _chunkPN5GNW6Ecjs.TOMBSTONE_EVENT).map(([stream]) => stream);
843
845
  if (retired.length) _optionalChain([deps, 'access', _42 => _42.forget_subscribed, 'optionalCall', _43 => _43(retired)]);
844
846
  for (const [stream, entry] of windowed_result) truncated.set(stream, entry);
845
847
  return { truncated, skipped };
@@ -921,7 +923,7 @@ async function run_windowed_closes(windowed, deps, skipped) {
921
923
  if (!await windowed_prune_pending(t.stream, t.before, max_id))
922
924
  return void 0;
923
925
  if (t.archive) await t.archive();
924
- const result = await _chunkBYTYS2LBcjs.store.call(void 0, ).truncate([
926
+ const result = await _chunkUPKDCTS2cjs.store.call(void 0, ).truncate([
925
927
  { stream: t.stream, before: t.before, max_id }
926
928
  ]);
927
929
  return result.get(t.stream);
@@ -934,10 +936,10 @@ async function run_windowed_closes(windowed, deps, skipped) {
934
936
  async function windowed_prune_pending(stream, before, max_id) {
935
937
  let boundary_id;
936
938
  let min_id;
937
- await _chunkBYTYS2LBcjs.store.call(void 0, ).query(
939
+ await _chunkUPKDCTS2cjs.store.call(void 0, ).query(
938
940
  (event) => {
939
941
  if (min_id === void 0 || event.id < min_id) min_id = event.id;
940
- if (event.name === _chunkTCADE3WYcjs.SNAP_EVENT && event.created < before && (max_id === void 0 || event.id <= max_id) && (boundary_id === void 0 || event.id > boundary_id))
942
+ if (event.name === _chunkPN5GNW6Ecjs.SNAP_EVENT && event.created < before && (max_id === void 0 || event.id <= max_id) && (boundary_id === void 0 || event.id > boundary_id))
941
943
  boundary_id = event.id;
942
944
  },
943
945
  { stream, stream_exact: true, with_snaps: true, after: -1 }
@@ -948,7 +950,7 @@ async function probe_min_watermarks(streams, page_size, checkpoint) {
948
950
  const min_at = /* @__PURE__ */ new Map();
949
951
  const matches = source_matcher();
950
952
  await walk_streams(
951
- _chunkBYTYS2LBcjs.store.call(void 0, ),
953
+ _chunkUPKDCTS2cjs.store.call(void 0, ),
952
954
  (position) => {
953
955
  const pending = position.correlated_at === void 0 || position.at < position.correlated_at;
954
956
  const cap = pending ? position.at : Math.max(position.at, checkpoint);
@@ -976,17 +978,17 @@ function source_matcher() {
976
978
  };
977
979
  }
978
980
  async function scan_stream_heads(streams) {
979
- const stats = await _chunkBYTYS2LBcjs.store.call(void 0, ).query_stats(streams, {
980
- exclude: [_chunkTCADE3WYcjs.SNAP_EVENT]
981
+ const stats = await _chunkUPKDCTS2cjs.store.call(void 0, ).query_stats(streams, {
982
+ exclude: [_chunkPN5GNW6Ecjs.SNAP_EVENT]
981
983
  });
982
- const domain_heads = await _chunkBYTYS2LBcjs.store.call(void 0, ).query_stats(streams, {
983
- exclude: [_chunkTCADE3WYcjs.SNAP_EVENT, _chunkTCADE3WYcjs.TOMBSTONE_EVENT]
984
+ const domain_heads = await _chunkUPKDCTS2cjs.store.call(void 0, ).query_stats(streams, {
985
+ exclude: [_chunkPN5GNW6Ecjs.SNAP_EVENT, _chunkPN5GNW6Ecjs.TOMBSTONE_EVENT]
984
986
  });
985
- const true_heads = await _chunkBYTYS2LBcjs.store.call(void 0, ).query_stats(streams, {});
987
+ const true_heads = await _chunkUPKDCTS2cjs.store.call(void 0, ).query_stats(streams, {});
986
988
  const out = /* @__PURE__ */ new Map();
987
989
  for (const [stream, { head }] of domain_heads) {
988
990
  const marker_head = _optionalChain([stats, 'access', _45 => _45.get, 'call', _46 => _46(stream), 'optionalAccess', _47 => _47.head]);
989
- const interrupted = _optionalChain([marker_head, 'optionalAccess', _48 => _48.name]) === _chunkTCADE3WYcjs.TOMBSTONE_EVENT;
991
+ const interrupted = _optionalChain([marker_head, 'optionalAccess', _48 => _48.name]) === _chunkPN5GNW6Ecjs.TOMBSTONE_EVENT;
990
992
  out.set(stream, {
991
993
  max_id: head.id,
992
994
  version: true_heads.get(stream).head.version,
@@ -1010,7 +1012,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
1010
1012
  const matches = source_matcher();
1011
1013
  const targets = [...stream_info.keys()];
1012
1014
  await walk_streams(
1013
- _chunkBYTYS2LBcjs.store.call(void 0, ),
1015
+ _chunkUPKDCTS2cjs.store.call(void 0, ),
1014
1016
  (position) => {
1015
1017
  const has_work = position.correlated_at !== void 0 && position.at < position.correlated_at;
1016
1018
  if (!has_work) return;
@@ -1076,7 +1078,7 @@ async function run_archive_callbacks(guarded, target_map) {
1076
1078
  }
1077
1079
  }
1078
1080
  async function heads_still_guarded(guarded, guard_events, skipped) {
1079
- const heads = await _chunkBYTYS2LBcjs.store.call(void 0, ).query_stats(guarded, {});
1081
+ const heads = await _chunkUPKDCTS2cjs.store.call(void 0, ).query_stats(guarded, {});
1080
1082
  return guarded.filter((stream) => {
1081
1083
  if (_optionalChain([heads, 'access', _55 => _55.get, 'call', _56 => _56(stream), 'optionalAccess', _57 => _57.head, 'access', _58 => _58.id]) === guard_events.get(stream).id)
1082
1084
  return true;
@@ -1094,18 +1096,18 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
1094
1096
  meta: {
1095
1097
  correlation,
1096
1098
  causation: {
1097
- event: { id: guard.id, name: _chunkTCADE3WYcjs.TOMBSTONE_EVENT, stream: guard.stream }
1099
+ event: { id: guard.id, name: _chunkPN5GNW6Ecjs.TOMBSTONE_EVENT, stream: guard.stream }
1098
1100
  }
1099
1101
  }
1100
1102
  };
1101
1103
  });
1102
- const truncated = await _chunkBYTYS2LBcjs.store.call(void 0, ).truncate(trunc_targets);
1104
+ const truncated = await _chunkUPKDCTS2cjs.store.call(void 0, ).truncate(trunc_targets);
1103
1105
  await Promise.all(
1104
1106
  guarded.map(async (stream) => {
1105
1107
  const entry = truncated.get(stream);
1106
1108
  const state2 = seed_states.get(stream);
1107
1109
  if (state2 && entry) {
1108
- await _chunkBYTYS2LBcjs.cache.call(void 0, ).set(stream, {
1110
+ await _chunkUPKDCTS2cjs.cache.call(void 0, ).set(stream, {
1109
1111
  stream,
1110
1112
  state: state2,
1111
1113
  version: entry.committed.version,
@@ -1114,7 +1116,7 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
1114
1116
  snaps: 1
1115
1117
  });
1116
1118
  } else {
1117
- await _chunkBYTYS2LBcjs.cache.call(void 0, ).invalidate(stream);
1119
+ await _chunkUPKDCTS2cjs.cache.call(void 0, ).invalidate(stream);
1118
1120
  }
1119
1121
  })
1120
1122
  );
@@ -1128,7 +1130,7 @@ var _crypto = require('crypto');
1128
1130
  function report_once(seen, key, message) {
1129
1131
  if (seen.has(key)) return;
1130
1132
  seen.add(key);
1131
- _chunkBYTYS2LBcjs.log.call(void 0, ).error(new Error(message));
1133
+ _chunkUPKDCTS2cjs.log.call(void 0, ).error(new Error(message));
1132
1134
  }
1133
1135
 
1134
1136
  // src/internal/correlate-cycle.ts
@@ -1175,7 +1177,7 @@ var CorrelateCycle = (_class3 = class {
1175
1177
  // never lets a resolution re-lane them.
1176
1178
 
1177
1179
  __init11() {this._static_subscriptions = /* @__PURE__ */ new Map()}
1178
- __init12() {this._patterns = new (0, _chunkBYTYS2LBcjs.LruMap)(PATTERN_CACHE_SIZE)}
1180
+ __init12() {this._patterns = new (0, _chunkUPKDCTS2cjs.LruMap)(PATTERN_CACHE_SIZE)}
1179
1181
 
1180
1182
 
1181
1183
 
@@ -1193,7 +1195,7 @@ var CorrelateCycle = (_class3 = class {
1193
1195
  on_init
1194
1196
  }) {;_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);_class3.prototype.__init11.call(this);_class3.prototype.__init12.call(this);_class3.prototype.__init13.call(this);
1195
1197
  this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
1196
- this._dynamic_subscriptions = new (0, _chunkBYTYS2LBcjs.LruMap)(max_subscribed_streams);
1198
+ this._dynamic_subscriptions = new (0, _chunkUPKDCTS2cjs.LruMap)(max_subscribed_streams);
1197
1199
  this._registry = registry;
1198
1200
  this._declared_lanes = declared_lanes;
1199
1201
  this._static_targets = static_targets;
@@ -1251,7 +1253,7 @@ var CorrelateCycle = (_class3 = class {
1251
1253
  // Would the target's own `fetch` (filtered by `source`) return this event?
1252
1254
  _in_fetch_window(source, stream) {
1253
1255
  if (source === void 0 || source === stream) return true;
1254
- if (_chunkBYTYS2LBcjs.is_literal_source.call(void 0, source)) return false;
1256
+ if (_chunkUPKDCTS2cjs.is_literal_source.call(void 0, source)) return false;
1255
1257
  let pattern = this._patterns.get(source);
1256
1258
  if (!pattern) {
1257
1259
  pattern = new RegExp(source);
@@ -1294,7 +1296,7 @@ var CorrelateCycle = (_class3 = class {
1294
1296
  const correlated = /* @__PURE__ */ new Map();
1295
1297
  let last_id = after;
1296
1298
  let stopped = false;
1297
- const found = await _chunkBYTYS2LBcjs.store.call(void 0, ).query(
1299
+ const found = await _chunkUPKDCTS2cjs.store.call(void 0, ).query(
1298
1300
  (event) => {
1299
1301
  if (stopped) return;
1300
1302
  const register = this._registry.events[event.name];
@@ -1339,9 +1341,9 @@ var CorrelateCycle = (_class3 = class {
1339
1341
  correlated_at: void 0
1340
1342
  };
1341
1343
  const seen_in_scan = correlated.has(resolved.target);
1342
- const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _61 => _61.lane])), () => ( _chunkTCADE3WYcjs.DEFAULT_LANE));
1344
+ const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _61 => _61.lane])), () => ( _chunkPN5GNW6Ecjs.DEFAULT_LANE));
1343
1345
  const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess', _62 => _62.priority]);
1344
- const resolved_lane = _nullishCoalesce(lane, () => ( _chunkTCADE3WYcjs.DEFAULT_LANE));
1346
+ const resolved_lane = _nullishCoalesce(lane, () => ( _chunkPN5GNW6Ecjs.DEFAULT_LANE));
1345
1347
  if (held_priority === priority && held_lane !== resolved_lane)
1346
1348
  report_lane_conflict(
1347
1349
  this._reported,
@@ -1415,7 +1417,7 @@ var CorrelateCycle = (_class3 = class {
1415
1417
  await Promise.all(
1416
1418
  missed.map(async ([stream, entry]) => {
1417
1419
  let row;
1418
- await _chunkBYTYS2LBcjs.store.call(void 0, ).query_streams(
1420
+ await _chunkUPKDCTS2cjs.store.call(void 0, ).query_streams(
1419
1421
  (position) => {
1420
1422
  row = position;
1421
1423
  },
@@ -1427,8 +1429,8 @@ var CorrelateCycle = (_class3 = class {
1427
1429
  lane: row.lane
1428
1430
  });
1429
1431
  if (entry.priority > row.priority) return;
1430
- const held_lane = _nullishCoalesce(row.lane, () => ( _chunkTCADE3WYcjs.DEFAULT_LANE));
1431
- const resolved_lane = _nullishCoalesce(entry.lane, () => ( _chunkTCADE3WYcjs.DEFAULT_LANE));
1432
+ const held_lane = _nullishCoalesce(row.lane, () => ( _chunkPN5GNW6Ecjs.DEFAULT_LANE));
1433
+ const resolved_lane = _nullishCoalesce(entry.lane, () => ( _chunkPN5GNW6Ecjs.DEFAULT_LANE));
1432
1434
  if (entry.priority === row.priority && held_lane !== resolved_lane)
1433
1435
  report_lane_conflict(
1434
1436
  this._reported,
@@ -1454,7 +1456,7 @@ var CorrelateCycle = (_class3 = class {
1454
1456
  millis: 0
1455
1457
  });
1456
1458
  } catch (error) {
1457
- _chunkBYTYS2LBcjs.log.call(void 0, ).warn(
1459
+ _chunkUPKDCTS2cjs.log.call(void 0, ).warn(
1458
1460
  `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)}`
1459
1461
  );
1460
1462
  }
@@ -1607,14 +1609,14 @@ function compute_lag_lead_ratio(handled, lagging, leading) {
1607
1609
  }
1608
1610
 
1609
1611
  // src/internal/drain-ops.ts
1610
- var claim = (lagging, leading, by, millis, lane) => _chunkBYTYS2LBcjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane);
1612
+ var claim = (lagging, leading, by, millis, lane) => _chunkUPKDCTS2cjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane);
1611
1613
  async function fetch(leased, eventLimit) {
1612
1614
  return Promise.all(
1613
1615
  leased.map(async ({ stream, source, at, lagging }) => {
1614
1616
  const events = [];
1615
- const stream_exact = source !== void 0 && _chunkBYTYS2LBcjs.is_literal_source.call(void 0, source) ? true : void 0;
1617
+ const stream_exact = source !== void 0 && _chunkUPKDCTS2cjs.is_literal_source.call(void 0, source) ? true : void 0;
1616
1618
  try {
1617
- await _chunkBYTYS2LBcjs.store.call(void 0, ).query((e) => events.push(e), {
1619
+ await _chunkUPKDCTS2cjs.store.call(void 0, ).query((e) => events.push(e), {
1618
1620
  stream: source,
1619
1621
  stream_exact,
1620
1622
  after: at,
@@ -1634,13 +1636,13 @@ async function fetch(leased, eventLimit) {
1634
1636
  })
1635
1637
  );
1636
1638
  }
1637
- var ack = (leases) => _chunkBYTYS2LBcjs.store.call(void 0, ).ack(leases);
1638
- var block = (leases) => _chunkBYTYS2LBcjs.store.call(void 0, ).block(leases);
1639
- var subscribe = (streams, correlated_at, correlator) => _chunkBYTYS2LBcjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator);
1639
+ var ack = (leases) => _chunkUPKDCTS2cjs.store.call(void 0, ).ack(leases);
1640
+ var block = (leases) => _chunkUPKDCTS2cjs.store.call(void 0, ).block(leases);
1641
+ var subscribe = (streams, correlated_at, correlator) => _chunkUPKDCTS2cjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator);
1640
1642
 
1641
1643
  // src/internal/event-sourcing.ts
1642
1644
  var _actpatch = require('@rotorsoft/act-patch');
1643
- var _zod2 = require('zod');
1645
+ var _zod = require('zod');
1644
1646
  var bare_patch = (_me, state2, partial) => _actpatch.patch.call(void 0, state2, partial);
1645
1647
  var value_at = (value, path) => path.reduce(
1646
1648
  (at, key) => _optionalChain([at, 'optionalAccess', _67 => _67[key]]),
@@ -1651,29 +1653,29 @@ var check_invariants = (target, state2, schema, pii_aware) => {
1651
1653
  try {
1652
1654
  result = schema.safeParse(state2);
1653
1655
  } catch (error) {
1654
- throw new (0, _chunkTCADE3WYcjs.ValidationError)(target, state2, error);
1656
+ throw new (0, _chunkPN5GNW6Ecjs.ValidationError)(target, state2, error);
1655
1657
  }
1656
1658
  if (result.success) return;
1657
1659
  const issues = pii_aware ? result.error.issues.filter((issue) => {
1658
1660
  const value = value_at(state2, issue.path);
1659
- return value !== _chunkTCADE3WYcjs.REDACTED && value !== _chunkTCADE3WYcjs.SHREDDED;
1661
+ return value !== _chunkPN5GNW6Ecjs.REDACTED && value !== _chunkPN5GNW6Ecjs.SHREDDED;
1660
1662
  }) : result.error.issues;
1661
1663
  if (issues.length)
1662
- throw new (0, _chunkTCADE3WYcjs.ValidationError)(
1664
+ throw new (0, _chunkPN5GNW6Ecjs.ValidationError)(
1663
1665
  target,
1664
1666
  state2,
1665
- _zod2.prettifyError.call(void 0, new (0, _zod2.ZodError)(issues))
1667
+ _zod.prettifyError.call(void 0, new (0, _zod.ZodError)(issues))
1666
1668
  );
1667
1669
  };
1668
1670
  var DEFAULT_BATCH = 500;
1669
- var cache_put = (stream, entry) => _chunkBYTYS2LBcjs.cache.call(void 0, ).set(stream, entry).catch(
1670
- (err) => _chunkBYTYS2LBcjs.log.call(void 0, ).warn(
1671
+ var cache_put = (stream, entry) => _chunkUPKDCTS2cjs.cache.call(void 0, ).set(stream, entry).catch(
1672
+ (err) => _chunkUPKDCTS2cjs.log.call(void 0, ).warn(
1671
1673
  err,
1672
1674
  "cache set skipped; the next load re-folds from the store"
1673
1675
  )
1674
1676
  );
1675
- var cache_drop = (stream) => _chunkBYTYS2LBcjs.cache.call(void 0, ).invalidate(stream).catch(
1676
- (err) => _chunkBYTYS2LBcjs.log.call(void 0, ).warn(
1677
+ var cache_drop = (stream) => _chunkUPKDCTS2cjs.cache.call(void 0, ).invalidate(stream).catch(
1678
+ (err) => _chunkUPKDCTS2cjs.log.call(void 0, ).warn(
1677
1679
  err,
1678
1680
  "cache invalidate skipped; a stale checkpoint re-folds from its event_id"
1679
1681
  )
@@ -1681,9 +1683,9 @@ var cache_drop = (stream) => _chunkBYTYS2LBcjs.cache.call(void 0, ).invalidate(s
1681
1683
  async function snap(snapshot) {
1682
1684
  const { id, stream, name, meta, version } = snapshot.event;
1683
1685
  try {
1684
- const [committed] = await _chunkBYTYS2LBcjs.store.call(void 0, ).commit(
1686
+ const [committed] = await _chunkUPKDCTS2cjs.store.call(void 0, ).commit(
1685
1687
  stream,
1686
- [{ name: _chunkTCADE3WYcjs.SNAP_EVENT, data: snapshot.state }],
1688
+ [{ name: _chunkPN5GNW6Ecjs.SNAP_EVENT, data: snapshot.state }],
1687
1689
  {
1688
1690
  correlation: meta.correlation,
1689
1691
  causation: { event: { id, name, stream } }
@@ -1694,22 +1696,22 @@ async function snap(snapshot) {
1694
1696
  return committed;
1695
1697
  } catch (error) {
1696
1698
  const reason = error instanceof Error ? error.message : String(error);
1697
- _chunkBYTYS2LBcjs.log.call(void 0, ).warn(
1699
+ _chunkUPKDCTS2cjs.log.call(void 0, ).warn(
1698
1700
  `Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
1699
1701
  );
1700
1702
  }
1701
1703
  }
1702
1704
  async function tombstone(stream, expectedVersion, correlation) {
1703
1705
  try {
1704
- const [committed] = await _chunkBYTYS2LBcjs.store.call(void 0, ).commit(
1706
+ const [committed] = await _chunkUPKDCTS2cjs.store.call(void 0, ).commit(
1705
1707
  stream,
1706
- [{ name: _chunkTCADE3WYcjs.TOMBSTONE_EVENT, data: {} }],
1708
+ [{ name: _chunkPN5GNW6Ecjs.TOMBSTONE_EVENT, data: {} }],
1707
1709
  { correlation, causation: {} },
1708
1710
  expectedVersion
1709
1711
  );
1710
1712
  return committed;
1711
1713
  } catch (error) {
1712
- if (error instanceof _chunkTCADE3WYcjs.ConcurrencyError) return void 0;
1714
+ if (error instanceof _chunkPN5GNW6Ecjs.ConcurrencyError) return void 0;
1713
1715
  throw error;
1714
1716
  }
1715
1717
  }
@@ -1739,9 +1741,9 @@ async function scan(source, opts = {}, callback) {
1739
1741
  if (drop_closed_streams) {
1740
1742
  await source.query(
1741
1743
  (e) => {
1742
- if (e.name === _chunkTCADE3WYcjs.TOMBSTONE_EVENT) closed_streams.add(e.stream);
1744
+ if (e.name === _chunkPN5GNW6Ecjs.TOMBSTONE_EVENT) closed_streams.add(e.stream);
1743
1745
  },
1744
- { names: [_chunkTCADE3WYcjs.TOMBSTONE_EVENT] }
1746
+ { names: [_chunkPN5GNW6Ecjs.TOMBSTONE_EVENT] }
1745
1747
  );
1746
1748
  }
1747
1749
  let max_id;
@@ -1763,11 +1765,11 @@ async function scan(source, opts = {}, callback) {
1763
1765
  if (!is_valid(event))
1764
1766
  throw new Error(`Invalid event at index ${processed}`);
1765
1767
  if (on_progress) on_progress({ processed, id: event.id, max_id });
1766
- if (drop_snapshots && event.name === _chunkTCADE3WYcjs.SNAP_EVENT) {
1768
+ if (drop_snapshots && event.name === _chunkPN5GNW6Ecjs.SNAP_EVENT) {
1767
1769
  dropped_snaps++;
1768
1770
  return;
1769
1771
  }
1770
- if (closed_streams.has(event.stream) && event.name !== _chunkTCADE3WYcjs.TOMBSTONE_EVENT) {
1772
+ if (closed_streams.has(event.stream) && event.name !== _chunkPN5GNW6Ecjs.TOMBSTONE_EVENT) {
1771
1773
  dropped_closed++;
1772
1774
  return;
1773
1775
  }
@@ -1834,17 +1836,17 @@ async function scan(source, opts = {}, callback) {
1834
1836
  async function load(me, target, callback, patch_fn = bare_patch) {
1835
1837
  const { stream, actor, asOf } = target;
1836
1838
  const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
1837
- const cached = time_travel ? void 0 : await _chunkBYTYS2LBcjs.cache.call(void 0, ).get(stream);
1839
+ const cached = time_travel ? void 0 : await _chunkUPKDCTS2cjs.cache.call(void 0, ).get(stream);
1838
1840
  const cache_hit = !!cached;
1839
1841
  let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _73 => _73.state]), () => ( (me.init ? me.init() : {})));
1840
1842
  let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _74 => _74.patches]), () => ( 0));
1841
1843
  let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _75 => _75.snaps]), () => ( 0));
1842
1844
  let replayed = 0;
1843
1845
  let event;
1844
- await _chunkBYTYS2LBcjs.store.call(void 0, ).query(
1846
+ await _chunkUPKDCTS2cjs.store.call(void 0, ).query(
1845
1847
  (raw) => {
1846
1848
  event = me.view(raw, actor);
1847
- if (event.name === _chunkTCADE3WYcjs.SNAP_EVENT) {
1849
+ if (event.name === _chunkPN5GNW6Ecjs.SNAP_EVENT) {
1848
1850
  state2 = event.data;
1849
1851
  snaps++;
1850
1852
  patches = 0;
@@ -1853,8 +1855,8 @@ async function load(me, target, callback, patch_fn = bare_patch) {
1853
1855
  state2 = patch_fn(me, state2, me.patch[event.name](event, state2), event);
1854
1856
  patches++;
1855
1857
  replayed++;
1856
- } else if (event.name !== _chunkTCADE3WYcjs.TOMBSTONE_EVENT) {
1857
- _chunkBYTYS2LBcjs.log.call(void 0, ).warn(
1858
+ } else if (event.name !== _chunkPN5GNW6Ecjs.TOMBSTONE_EVENT) {
1859
+ _chunkUPKDCTS2cjs.log.call(void 0, ).warn(
1858
1860
  `Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
1859
1861
  );
1860
1862
  }
@@ -1878,7 +1880,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
1878
1880
  ...cached ? { after: cached.event_id, with_snaps: true } : { ...time_travel ? {} : { with_snaps: true }, ...asOf }
1879
1881
  }
1880
1882
  );
1881
- const head_is_tombstone = _optionalChain([event, 'optionalAccess', _77 => _77.name]) === _chunkTCADE3WYcjs.TOMBSTONE_EVENT;
1883
+ const head_is_tombstone = _optionalChain([event, 'optionalAccess', _77 => _77.name]) === _chunkPN5GNW6Ecjs.TOMBSTONE_EVENT;
1882
1884
  if (replayed > 0 && !time_travel && event && !me.pii_aware && !head_is_tombstone) {
1883
1885
  await cache_put(stream, {
1884
1886
  stream,
@@ -1906,7 +1908,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1906
1908
  if (!stream) throw new Error("Missing target stream");
1907
1909
  const reactingTo = _optionalChain([options, 'optionalAccess', _82 => _82.reactingTo]);
1908
1910
  const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _83 => _83.correlator]), () => ( default_correlator));
1909
- const validated = _chunkBYTYS2LBcjs.validate.call(void 0, action2, payload, me.actions[action2]);
1911
+ const validated = _chunkUPKDCTS2cjs.validate.call(void 0, action2, payload, me.actions[action2]);
1910
1912
  const opts = _optionalChain([me, 'access', _84 => _84.options, 'optionalAccess', _85 => _85[action2]]);
1911
1913
  const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _86 => _86.maxRetries]), () => ( 0));
1912
1914
  for (let attempt = 0; ; attempt++) {
@@ -1917,12 +1919,12 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1917
1919
  void 0,
1918
1920
  patch_fn
1919
1921
  );
1920
- if (_optionalChain([snapshot, 'access', _87 => _87.event, 'optionalAccess', _88 => _88.name]) === _chunkTCADE3WYcjs.TOMBSTONE_EVENT)
1921
- throw new (0, _chunkTCADE3WYcjs.StreamClosedError)(stream);
1922
+ if (_optionalChain([snapshot, 'access', _87 => _87.event, 'optionalAccess', _88 => _88.name]) === _chunkPN5GNW6Ecjs.TOMBSTONE_EVENT)
1923
+ throw new (0, _chunkPN5GNW6Ecjs.StreamClosedError)(stream);
1922
1924
  const expected = _nullishCoalesce(expectedVersion, () => ( snapshot.version));
1923
1925
  for (const { valid, description } of _nullishCoalesce(_optionalChain([me, 'access', _89 => _89.given, 'optionalAccess', _90 => _90[action2]]), () => ( [])))
1924
1926
  if (!valid(snapshot.state, actor))
1925
- throw new (0, _chunkTCADE3WYcjs.InvariantError)(
1927
+ throw new (0, _chunkPN5GNW6Ecjs.InvariantError)(
1926
1928
  action2,
1927
1929
  validated,
1928
1930
  target,
@@ -1931,7 +1933,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1931
1933
  );
1932
1934
  for (const { holds, description } of _nullishCoalesce(_optionalChain([me, 'access', _91 => _91.requires, 'optionalAccess', _92 => _92[action2]]), () => ( [])))
1933
1935
  if (!holds(validated, snapshot.state, actor))
1934
- throw new (0, _chunkTCADE3WYcjs.PreconditionError)(
1936
+ throw new (0, _chunkPN5GNW6Ecjs.PreconditionError)(
1935
1937
  action2,
1936
1938
  validated,
1937
1939
  target,
@@ -1944,7 +1946,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1944
1946
  const tuples = Array.isArray(result[0]) ? result : [result];
1945
1947
  const events = tuples.map(([name, data]) => ({
1946
1948
  name,
1947
- data: _chunkBYTYS2LBcjs.validate.call(void 0, name, data, me.events[name])
1949
+ data: _chunkUPKDCTS2cjs.validate.call(void 0, name, data, me.events[name])
1948
1950
  }));
1949
1951
  const emitted = events.map((e) => me.message(e));
1950
1952
  const meta = {
@@ -1991,9 +1993,9 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1991
1993
  );
1992
1994
  let committed;
1993
1995
  try {
1994
- committed = await _chunkBYTYS2LBcjs.store.call(void 0, ).commit(stream, emitted, meta, expected);
1996
+ committed = await _chunkUPKDCTS2cjs.store.call(void 0, ).commit(stream, emitted, meta, expected);
1995
1997
  } catch (error) {
1996
- if (error instanceof _chunkTCADE3WYcjs.ConcurrencyError) void cache_drop(stream);
1998
+ if (error instanceof _chunkPN5GNW6Ecjs.ConcurrencyError) void cache_drop(stream);
1997
1999
  throw error;
1998
2000
  }
1999
2001
  const snapshots = committed.map((row, i) => ({
@@ -2020,19 +2022,19 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
2020
2022
  });
2021
2023
  return snapshots;
2022
2024
  } catch (error) {
2023
- if (!(error instanceof _chunkTCADE3WYcjs.ConcurrencyError)) throw error;
2025
+ if (!(error instanceof _chunkPN5GNW6Ecjs.ConcurrencyError)) throw error;
2024
2026
  if (expectedVersion !== void 0) throw error;
2025
2027
  if (attempt >= max_retries) throw error;
2026
2028
  if (_optionalChain([opts, 'optionalAccess', _99 => _99.backoff])) {
2027
2029
  const delay_ms = compute_backoff_delay(attempt, opts.backoff);
2028
- if (delay_ms > 0) await _chunkBYTYS2LBcjs.sleep.call(void 0, delay_ms);
2030
+ if (delay_ms > 0) await _chunkUPKDCTS2cjs.sleep.call(void 0, delay_ms);
2029
2031
  }
2030
2032
  }
2031
2033
  }
2032
2034
  }
2033
2035
 
2034
2036
  // src/internal/tracing.ts
2035
- var PRETTY = _chunkBYTYS2LBcjs.config.call(void 0, ).env !== "production";
2037
+ var PRETTY = _chunkUPKDCTS2cjs.config.call(void 0, ).env !== "production";
2036
2038
  var C_BLUE = "\x1B[38;5;39m";
2037
2039
  var C_ORANGE = "\x1B[38;5;208m";
2038
2040
  var C_GREEN = "\x1B[38;5;42m";
@@ -2216,7 +2218,7 @@ function budget_exhausted(lease, options, store_failing) {
2216
2218
  if (store_failing || !_optionalChain([options, 'optionalAccess', _110 => _110.blockOnError]) || lease.retry <= options.maxRetries)
2217
2219
  return void 0;
2218
2220
  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.`;
2219
- _chunkBYTYS2LBcjs.log.call(void 0, ).error(error);
2221
+ _chunkUPKDCTS2cjs.log.call(void 0, ).error(error);
2220
2222
  return { lease, handled: 0, acked_at: lease.at, error, block: true };
2221
2223
  }
2222
2224
  function fetch_failure_policy(registry) {
@@ -2232,13 +2234,13 @@ function fetch_failure_policy(registry) {
2232
2234
  function finalize(lease, handled, at, error, options, logger, failed_at) {
2233
2235
  if (!error) return { lease, handled, acked_at: at };
2234
2236
  logger.error(error);
2235
- const non_retryable = error instanceof _chunkTCADE3WYcjs.NonRetryableError;
2237
+ const non_retryable = error instanceof _chunkPN5GNW6Ecjs.NonRetryableError;
2236
2238
  const block2 = options.blockOnError && (non_retryable || lease.retry >= options.maxRetries);
2237
2239
  if (block2)
2238
2240
  logger.error(
2239
2241
  non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
2240
2242
  );
2241
- const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkBYTYS2LBcjs.DEFAULT_BACKOFF)));
2243
+ const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkUPKDCTS2cjs.DEFAULT_BACKOFF)));
2242
2244
  return {
2243
2245
  lease,
2244
2246
  handled,
@@ -2366,7 +2368,7 @@ async function run_drain_cycle(deps, cycle) {
2366
2368
  const acked = submitted.length ? await ops.ack(submitted) : [];
2367
2369
  const expected = submitted.filter((l) => l.due === void 0).length;
2368
2370
  if (acked.length < expected)
2369
- _chunkBYTYS2LBcjs.log.call(void 0, ).warn(
2371
+ _chunkUPKDCTS2cjs.log.call(void 0, ).warn(
2370
2372
  `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.`
2371
2373
  );
2372
2374
  const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
@@ -2462,9 +2464,9 @@ var DrainController = (_class5 = class {
2462
2464
  if (!this.armed || this._stopped || this._inflight)
2463
2465
  return EMPTY_DRAIN;
2464
2466
  const d = _nullishCoalesce(this._deps.defaults, () => ( {}));
2465
- const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkBYTYS2LBcjs.DEFAULT_STREAM_LIMIT));
2466
- const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkBYTYS2LBcjs.DEFAULT_EVENT_LIMIT));
2467
- const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkBYTYS2LBcjs.DEFAULT_LEASE_MILLIS));
2467
+ const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkUPKDCTS2cjs.DEFAULT_STREAM_LIMIT));
2468
+ const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkUPKDCTS2cjs.DEFAULT_EVENT_LIMIT));
2469
+ const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkUPKDCTS2cjs.DEFAULT_LEASE_MILLIS));
2468
2470
  if (this._deps.breaker.state(Date.now()) === "open")
2469
2471
  return EMPTY_DRAIN;
2470
2472
  const pass = this._pass(streamLimit, eventLimit, leaseMillis).finally(
@@ -2539,7 +2541,7 @@ function pii_gate(event, fields, predicate, actor) {
2539
2541
  const { pii, ...rest } = event;
2540
2542
  if (pii == null) {
2541
2543
  const shredded = { ...data };
2542
- for (const f of fields) shredded[f] = _chunkTCADE3WYcjs.SHREDDED;
2544
+ for (const f of fields) shredded[f] = _chunkPN5GNW6Ecjs.SHREDDED;
2543
2545
  return { ...rest, data: shredded };
2544
2546
  }
2545
2547
  const allowed = !!actor && !!predicate && predicate(event, actor);
@@ -2550,7 +2552,7 @@ function pii_gate(event, fields, predicate, actor) {
2550
2552
  };
2551
2553
  }
2552
2554
  const redacted = { ...data };
2553
- for (const f of fields) redacted[f] = _chunkTCADE3WYcjs.REDACTED;
2555
+ for (const f of fields) redacted[f] = _chunkPN5GNW6Ecjs.REDACTED;
2554
2556
  return { ...rest, data: redacted };
2555
2557
  }
2556
2558
  var IDENTITY_GATE = (event) => event;
@@ -2659,16 +2661,16 @@ function make_fold_handler(me, flush, config2, sensitive_fields) {
2659
2661
 
2660
2662
  // src/internal/defer-config.ts
2661
2663
 
2662
- var DeferDurationSchema = _zod2.z.object({
2663
- days: _zod2.z.number().positive().optional(),
2664
- hours: _zod2.z.number().positive().optional(),
2665
- minutes: _zod2.z.number().positive().optional()
2664
+ var DeferDurationSchema = _zod.z.object({
2665
+ days: _zod.z.number().positive().optional(),
2666
+ hours: _zod.z.number().positive().optional(),
2667
+ minutes: _zod.z.number().positive().optional()
2666
2668
  }).strict().refine((d) => d.days != null || d.hours != null || d.minutes != null, {
2667
2669
  message: "defer: a duration needs at least one of days, hours, or minutes"
2668
2670
  });
2669
- var DeferWhenSchema = _zod2.z.object({
2671
+ var DeferWhenSchema = _zod.z.object({
2670
2672
  after: DeferDurationSchema.optional(),
2671
- at: _zod2.z.date().optional()
2673
+ at: _zod.z.date().optional()
2672
2674
  }).strict().refine((w) => w.after === void 0 !== (w.at === void 0), {
2673
2675
  message: "defer: specify exactly one of `after` or `at`"
2674
2676
  });
@@ -2687,7 +2689,7 @@ function make_deferred(handler, schedule) {
2687
2689
  const call = handler;
2688
2690
  const deferred = async (event, stream, app) => {
2689
2691
  const when = typeof schedule === "function" ? schedule(event) : schedule;
2690
- if (Date.now() < resolve_defer_at(when, event)) throw new (0, _chunkTCADE3WYcjs.DeferSignal)(when);
2692
+ if (Date.now() < resolve_defer_at(when, event)) throw new (0, _chunkPN5GNW6Ecjs.DeferSignal)(when);
2691
2693
  return call(event, stream, app);
2692
2694
  };
2693
2695
  Object.defineProperty(deferred, "name", { value: handler.name });
@@ -2756,7 +2758,7 @@ function build_handle(deps) {
2756
2758
  handled++;
2757
2759
  }
2758
2760
  } catch (error) {
2759
- if (error instanceof _chunkTCADE3WYcjs.DeferSignal) {
2761
+ if (error instanceof _chunkPN5GNW6Ecjs.DeferSignal) {
2760
2762
  let defer;
2761
2763
  try {
2762
2764
  defer = resolve_defer_at(error.when, event);
@@ -3028,7 +3030,7 @@ var Act = (_class7 = class {
3028
3030
  // Lanes to arm per event; `"all"` when a dynamic resolver hides the lane.
3029
3031
 
3030
3032
 
3031
- __init27() {this._logger = _chunkBYTYS2LBcjs.log.call(void 0, )}
3033
+ __init27() {this._logger = _chunkUPKDCTS2cjs.log.call(void 0, )}
3032
3034
  // This Act's ports: its own bag, or the singleton adapters.
3033
3035
 
3034
3036
  // Runs a body so internal `store()`/`cache()` calls resolve to `_ports`.
@@ -3050,9 +3052,9 @@ var Act = (_class7 = class {
3050
3052
  this._lanes = lanes;
3051
3053
  this._declared_lanes = ["default", ...lanes.map((l) => l.name)];
3052
3054
  validate_only_lanes(options.onlyLanes, this._declared_lanes);
3053
- this._ports = _nullishCoalesce(options.scoped, () => ( _chunkBYTYS2LBcjs.default_scope.call(void 0, )));
3055
+ this._ports = _nullishCoalesce(options.scoped, () => ( _chunkUPKDCTS2cjs.default_scope.call(void 0, )));
3054
3056
  const ports = this._ports;
3055
- this._scoped = _chunkBYTYS2LBcjs.make_run_scoped.call(void 0, {
3057
+ this._scoped = _chunkUPKDCTS2cjs.make_run_scoped.call(void 0, {
3056
3058
  // Getters, not a spread: the singletons resolve lazily, so a later
3057
3059
  // `store(...)` / `cache(...)` still takes effect.
3058
3060
  get store() {
@@ -3062,14 +3064,14 @@ var Act = (_class7 = class {
3062
3064
  return ports.cache;
3063
3065
  },
3064
3066
  // Parsed per build, so a bad window throws on every build.
3065
- autoclose_window: _chunkBYTYS2LBcjs.resolveAutocloseConfig.call(void 0, options).autocloseWindow
3067
+ autoclose_window: _chunkUPKDCTS2cjs.resolveAutocloseConfig.call(void 0, options).autocloseWindow
3066
3068
  });
3067
3069
  this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
3068
3070
  this._es = build_es(this._logger, this._correlator, patch_fn);
3069
3071
  this._cd = build_drain(this._logger);
3070
3072
  const handle = build_handle({
3071
3073
  logger: this._logger,
3072
- reaction_scope: _chunkBYTYS2LBcjs.make_reaction_scope.call(void 0, {
3074
+ reaction_scope: _chunkUPKDCTS2cjs.make_reaction_scope.call(void 0, {
3073
3075
  do: this.do.bind(this),
3074
3076
  load: this.load.bind(this),
3075
3077
  query: this.query.bind(this),
@@ -3099,12 +3101,12 @@ var Act = (_class7 = class {
3099
3101
  this._ports.store,
3100
3102
  options.listen !== false
3101
3103
  );
3102
- _chunkBYTYS2LBcjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
3104
+ _chunkUPKDCTS2cjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
3103
3105
  }
3104
3106
  // Shared by drain, settle and autoclose; bad knobs throw at build.
3105
3107
  _build_breaker(options) {
3106
3108
  return new CircuitBreaker(
3107
- _chunkBYTYS2LBcjs.resolveCircuitBreakerConfig.call(void 0, options.circuitBreaker),
3109
+ _chunkUPKDCTS2cjs.resolveCircuitBreakerConfig.call(void 0, options.circuitBreaker),
3108
3110
  {
3109
3111
  on_error: (error, circuit) => this._emit_error(error, circuit),
3110
3112
  // When the cooldown elapses, settle once: its scan or claim is the
@@ -3138,7 +3140,7 @@ var Act = (_class7 = class {
3138
3140
  try {
3139
3141
  await this._run_close(targets);
3140
3142
  } catch (error) {
3141
- if (error instanceof _chunkTCADE3WYcjs.StoreError) throw error;
3143
+ if (error instanceof _chunkPN5GNW6Ecjs.StoreError) throw error;
3142
3144
  this._logger.error(
3143
3145
  error,
3144
3146
  `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.`
@@ -3172,7 +3174,7 @@ var Act = (_class7 = class {
3172
3174
  // Audit deps, built after the controllers so the lane set is final.
3173
3175
  _build_audit_deps() {
3174
3176
  return {
3175
- store: _chunkBYTYS2LBcjs.store,
3177
+ store: _chunkUPKDCTS2cjs.store,
3176
3178
  event_to_state: this._event_to_state,
3177
3179
  // Declared lanes, not this process's controllers: a lane another
3178
3180
  // worker drains is not `unknown-lane`.
@@ -3185,7 +3187,7 @@ var Act = (_class7 = class {
3185
3187
  registry: this.registry,
3186
3188
  static_targets: classification.static_targets,
3187
3189
  cd: this._cd,
3188
- max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunkTCADE3WYcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
3190
+ max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunkPN5GNW6Ecjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
3189
3191
  // Declared lanes (not active ones): a lane another process claims is
3190
3192
  // still a valid destination.
3191
3193
  declared_lanes: new Set(this._declared_lanes),
@@ -3201,7 +3203,7 @@ var Act = (_class7 = class {
3201
3203
  // Cold start: an idle deferred stream still fires on time after a restart.
3202
3204
  async _seed_persisted_defers() {
3203
3205
  const now = Date.now();
3204
- await walk_streams(_chunkBYTYS2LBcjs.store.call(void 0, ), (pos) => {
3206
+ await walk_streams(_chunkUPKDCTS2cjs.store.call(void 0, ), (pos) => {
3205
3207
  if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
3206
3208
  const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
3207
3209
  _optionalChain([controller, 'optionalAccess', _132 => _132.seed_defer, 'call', _133 => _133(pos.stream, pos.deferred_at)]);
@@ -3217,7 +3219,7 @@ var Act = (_class7 = class {
3217
3219
  on_settled: (drain) => this.emit("settled", drain),
3218
3220
  breaker: this._breaker
3219
3221
  },
3220
- _nullishCoalesce(options.settleDebounceMs, () => ( _chunkTCADE3WYcjs.DEFAULT_SETTLE_DEBOUNCE_MS))
3222
+ _nullishCoalesce(options.settleDebounceMs, () => ( _chunkPN5GNW6Ecjs.DEFAULT_SETTLE_DEBOUNCE_MS))
3221
3223
  );
3222
3224
  }
3223
3225
 
@@ -3237,7 +3239,7 @@ var Act = (_class7 = class {
3237
3239
  */
3238
3240
  shutdown(options) {
3239
3241
  if (!this._shutdown_promise) {
3240
- _chunkBYTYS2LBcjs.resolveShutdownConfig.call(void 0, options);
3242
+ _chunkUPKDCTS2cjs.resolveShutdownConfig.call(void 0, options);
3241
3243
  this._shutdown_promise = (async () => {
3242
3244
  this.stop_correlations();
3243
3245
  this._settle.stop(true);
@@ -3255,10 +3257,10 @@ var Act = (_class7 = class {
3255
3257
  // The largest `leaseMillis` among lanes with a cycle in flight (the
3256
3258
  // default for none or 0, and for a running settle), capped.
3257
3259
  _derive_grace_ms(running, settling) {
3258
- let max = settling ? _chunkBYTYS2LBcjs.DEFAULT_LEASE_MILLIS : 0;
3260
+ let max = settling ? _chunkUPKDCTS2cjs.DEFAULT_LEASE_MILLIS : 0;
3259
3261
  for (const c of running)
3260
- max = Math.max(max, c.lease_millis || _chunkBYTYS2LBcjs.DEFAULT_LEASE_MILLIS);
3261
- return Math.min(max, _chunkBYTYS2LBcjs.MAX_SHUTDOWN_GRACE_MS);
3262
+ max = Math.max(max, c.lease_millis || _chunkUPKDCTS2cjs.DEFAULT_LEASE_MILLIS);
3263
+ return Math.min(max, _chunkUPKDCTS2cjs.MAX_SHUTDOWN_GRACE_MS);
3262
3264
  }
3263
3265
  async _await_inflight(grace_ms) {
3264
3266
  const running = [...this._drain_controllers.values()].filter(
@@ -3341,7 +3343,7 @@ var Act = (_class7 = class {
3341
3343
  * @see {@link ValidationError}, {@link PreconditionError}, {@link ConcurrencyError}
3342
3344
  */
3343
3345
  async do(action2, target, payload, options) {
3344
- const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _135 => _135.reactingTo]), () => ( _chunkBYTYS2LBcjs.current_reacting.call(void 0, )));
3346
+ const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _135 => _135.reactingTo]), () => ( _chunkUPKDCTS2cjs.current_reacting.call(void 0, )));
3345
3347
  const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _136 => _136.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
3346
3348
  return this._scoped(async () => {
3347
3349
  const snapshots = await this._es.action(
@@ -3407,7 +3409,7 @@ var Act = (_class7 = class {
3407
3409
  return this._scoped(async () => {
3408
3410
  let first;
3409
3411
  let last;
3410
- const count = await _chunkBYTYS2LBcjs.store.call(void 0, ).query((e) => {
3412
+ const count = await _chunkUPKDCTS2cjs.store.call(void 0, ).query((e) => {
3411
3413
  const gated = this.registry.query_gate(e.name)(e);
3412
3414
  if (!first) first = gated;
3413
3415
  last = gated;
@@ -3437,7 +3439,7 @@ var Act = (_class7 = class {
3437
3439
  async query_array(query) {
3438
3440
  return this._scoped(async () => {
3439
3441
  const events = [];
3440
- await _chunkBYTYS2LBcjs.store.call(void 0, ).query((e) => {
3442
+ await _chunkUPKDCTS2cjs.store.call(void 0, ).query((e) => {
3441
3443
  events.push(this.registry.query_gate(e.name)(e));
3442
3444
  }, query);
3443
3445
  return events;
@@ -3457,14 +3459,14 @@ var Act = (_class7 = class {
3457
3459
  */
3458
3460
  async forget(stream) {
3459
3461
  return this._scoped(async () => {
3460
- const s = _chunkBYTYS2LBcjs.store.call(void 0, );
3462
+ const s = _chunkUPKDCTS2cjs.store.call(void 0, );
3461
3463
  if (!s.forget_pii) {
3462
3464
  throw new Error(
3463
3465
  `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).`
3464
3466
  );
3465
3467
  }
3466
3468
  const eventCount = await s.forget_pii(stream);
3467
- await _chunkBYTYS2LBcjs.cache.call(void 0, ).invalidate(stream);
3469
+ await _chunkUPKDCTS2cjs.cache.call(void 0, ).invalidate(stream);
3468
3470
  if (eventCount > 0) {
3469
3471
  this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
3470
3472
  }
@@ -3498,7 +3500,7 @@ var Act = (_class7 = class {
3498
3500
  * @see {@link correlate} for dynamic stream discovery
3499
3501
  */
3500
3502
  async drain(options = {}) {
3501
- _chunkBYTYS2LBcjs.resolveDrainConfig.call(void 0, options);
3503
+ _chunkUPKDCTS2cjs.resolveDrainConfig.call(void 0, options);
3502
3504
  if (!this._drain)
3503
3505
  return { fetched: [], leased: [], acked: [], blocked: [] };
3504
3506
  return this._scoped(() => this._drain_all(options));
@@ -3678,7 +3680,7 @@ var Act = (_class7 = class {
3678
3680
  */
3679
3681
  async reset(input) {
3680
3682
  return this._scoped(async () => {
3681
- const count = await _chunkBYTYS2LBcjs.store.call(void 0, ).reset(input);
3683
+ const count = await _chunkUPKDCTS2cjs.store.call(void 0, ).reset(input);
3682
3684
  for (const handler of this._batch_handlers.values())
3683
3685
  _optionalChain([handler, 'access', _143 => _143[FOLD_RESET], 'optionalCall', _144 => _144()]);
3684
3686
  if (count > 0) {
@@ -3714,7 +3716,7 @@ var Act = (_class7 = class {
3714
3716
  */
3715
3717
  async unblock(input) {
3716
3718
  return this._scoped(async () => {
3717
- const count = await _chunkBYTYS2LBcjs.store.call(void 0, ).unblock(input);
3719
+ const count = await _chunkUPKDCTS2cjs.store.call(void 0, ).unblock(input);
3718
3720
  if (count > 0) {
3719
3721
  this._wake();
3720
3722
  }
@@ -3769,7 +3771,7 @@ var Act = (_class7 = class {
3769
3771
  return { ...partial, duration_ms: Date.now() - started };
3770
3772
  }
3771
3773
  const target = _nullishCoalesce(sink, () => ( (() => {
3772
- const s = _chunkBYTYS2LBcjs.store.call(void 0, );
3774
+ const s = _chunkUPKDCTS2cjs.store.call(void 0, );
3773
3775
  if (!s.restore) throw new Error("adapter has no restore capability");
3774
3776
  return s;
3775
3777
  })()));
@@ -3815,7 +3817,7 @@ var Act = (_class7 = class {
3815
3817
  async blocked_streams(options) {
3816
3818
  return this._scoped(async () => {
3817
3819
  const positions = [];
3818
- await _chunkBYTYS2LBcjs.store.call(void 0, ).query_streams(
3820
+ await _chunkUPKDCTS2cjs.store.call(void 0, ).query_streams(
3819
3821
  (p) => {
3820
3822
  positions.push(p);
3821
3823
  },
@@ -3867,7 +3869,7 @@ var Act = (_class7 = class {
3867
3869
  * @see {@link Store.prioritize} for the underlying primitive
3868
3870
  */
3869
3871
  async prioritize(filter, priority) {
3870
- return this._scoped(() => _chunkBYTYS2LBcjs.store.call(void 0, ).prioritize(filter, priority));
3872
+ return this._scoped(() => _chunkUPKDCTS2cjs.store.call(void 0, ).prioritize(filter, priority));
3871
3873
  }
3872
3874
  // Shared by `close()` and reaction-requested closes.
3873
3875
  async _run_close(targets) {
@@ -3947,7 +3949,7 @@ var Act = (_class7 = class {
3947
3949
  * @see {@link correlate} for manual correlation
3948
3950
  */
3949
3951
  settle(options) {
3950
- _chunkBYTYS2LBcjs.resolveSettleConfig.call(void 0, _nullishCoalesce(options, () => ( {})));
3952
+ _chunkUPKDCTS2cjs.resolveSettleConfig.call(void 0, _nullishCoalesce(options, () => ( {})));
3951
3953
  this._schedule(options);
3952
3954
  }
3953
3955
  }, _class7);
@@ -3963,21 +3965,21 @@ function days_after(date, days) {
3963
3965
  function days_before_now(days) {
3964
3966
  return new Date(Date.now() - days * DAY_MS);
3965
3967
  }
3966
- var window_schema = (field, min_days, floor) => _zod2.z.object({
3967
- days: _zod2.z.number({ message: `autocloses: ${field}.days must be a number` }).positive(`autocloses: ${field}.days must be > 0`)
3968
+ var window_schema = (field, min_days, floor) => _zod.z.object({
3969
+ days: _zod.z.number({ message: `autocloses: ${field}.days must be a number` }).positive(`autocloses: ${field}.days must be > 0`)
3968
3970
  }).refine((o) => o.days >= min_days, {
3969
3971
  message: `autocloses: ${field} resolves to < ${floor}, which is too short to be a meaningful retention window`
3970
3972
  });
3971
3973
  var AfterSchema = window_schema("after", MIN_AFTER_DAYS, "one minute");
3972
3974
  var KeepSchema = window_schema("keep", MIN_KEEP_DAYS, "one day");
3973
- var IsSchema = _zod2.z.union([
3974
- _zod2.z.string().min(1, "autocloses: is must be a non-empty event name"),
3975
- _zod2.z.array(
3976
- _zod2.z.string().min(1, "autocloses: is entries must be non-empty event names")
3975
+ var IsSchema = _zod.z.union([
3976
+ _zod.z.string().min(1, "autocloses: is must be a non-empty event name"),
3977
+ _zod.z.array(
3978
+ _zod.z.string().min(1, "autocloses: is entries must be non-empty event names")
3977
3979
  ).min(1, "autocloses: is must include at least one event name").readonly()
3978
3980
  ]);
3979
- var ReachesSchema = _zod2.z.number({ message: "autocloses: reaches must be a number" }).int("autocloses: reaches must be an integer").min(1, "autocloses: reaches must be >= 1");
3980
- var OrBlockSchema = _zod2.z.object({
3981
+ var ReachesSchema = _zod.z.number({ message: "autocloses: reaches must be a number" }).int("autocloses: reaches must be an integer").min(1, "autocloses: reaches must be >= 1");
3982
+ var OrBlockSchema = _zod.z.object({
3981
3983
  after: AfterSchema.optional(),
3982
3984
  is: IsSchema.optional(),
3983
3985
  reaches: ReachesSchema.optional()
@@ -3987,7 +3989,7 @@ var OrBlockSchema = _zod2.z.object({
3987
3989
  message: "autocloses: `or` block must include at least one of after / is / reaches"
3988
3990
  }
3989
3991
  );
3990
- var AutoclosePolicySchema = _zod2.z.object({
3992
+ var AutoclosePolicySchema = _zod.z.object({
3991
3993
  after: AfterSchema.optional(),
3992
3994
  is: IsSchema.optional(),
3993
3995
  reaches: ReachesSchema.optional(),
@@ -4103,16 +4105,16 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
4103
4105
  }),
4104
4106
  // Never block on autoclose: a transient query/store error should retry,
4105
4107
  // not quarantine the synthetic stream.
4106
- options: { blockOnError: false, maxRetries: _chunkBYTYS2LBcjs.DEFAULT_MAX_RETRIES },
4108
+ options: { blockOnError: false, maxRetries: _chunkUPKDCTS2cjs.DEFAULT_MAX_RETRIES },
4107
4109
  handler: async (event) => {
4108
4110
  const aggregate = event.stream;
4109
4111
  const window = read_window();
4110
4112
  if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
4111
- throw new (0, _chunkTCADE3WYcjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
4112
- const stats = await _chunkBYTYS2LBcjs.store.call(void 0, ).query_stats([aggregate], {
4113
+ throw new (0, _chunkPN5GNW6Ecjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
4114
+ const stats = await _chunkUPKDCTS2cjs.store.call(void 0, ).query_stats([aggregate], {
4113
4115
  count: true,
4114
4116
  tail: keep_days !== void 0 ? true : void 0,
4115
- exclude: [_chunkTCADE3WYcjs.TOMBSTONE_EVENT, _chunkTCADE3WYcjs.SNAP_EVENT]
4117
+ exclude: [_chunkPN5GNW6Ecjs.TOMBSTONE_EVENT, _chunkPN5GNW6Ecjs.SNAP_EVENT]
4116
4118
  });
4117
4119
  const entry = stats.get(aggregate);
4118
4120
  if (!entry) return;
@@ -4143,7 +4145,7 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
4143
4145
  dues.push(days_after(entry.tail.created, keep_days));
4144
4146
  const future = dues.map((d) => d.getTime()).filter((t) => t > Date.now());
4145
4147
  if (future.length)
4146
- throw new (0, _chunkTCADE3WYcjs.DeferSignal)({ at: new Date(Math.min(...future)) });
4148
+ throw new (0, _chunkPN5GNW6Ecjs.DeferSignal)({ at: new Date(Math.min(...future)) });
4147
4149
  }
4148
4150
  };
4149
4151
  const key = `__autoclose_${st.name}`;
@@ -4185,7 +4187,7 @@ function merge_schemas(existing, incoming, state_name) {
4185
4187
  return existing_object.extend(incoming_shape);
4186
4188
  }
4187
4189
  function as_object(schema, side, state_name) {
4188
- if (schema instanceof _zod2.ZodObject) return schema;
4190
+ if (schema instanceof _zod.ZodObject) return schema;
4189
4191
  throw new Error(
4190
4192
  `Cannot merge state schemas for "${state_name}": the ${side} partial's schema is a ${schema.constructor.name}, not a z.object. Partials of the same state are merged by extending their shapes, so declare every partial's state as a plain z.object({ ... }).`
4191
4193
  );
@@ -4348,9 +4350,9 @@ var _this_ = ({ stream }) => ({
4348
4350
 
4349
4351
  // src/builders/builder-utils.ts
4350
4352
  function register_lane(config2, lanes) {
4351
- _chunkBYTYS2LBcjs.resolveLaneConfig.call(void 0, config2);
4352
- if (config2.name === _chunkTCADE3WYcjs.DEFAULT_LANE)
4353
- throw new Error(`Lane "${_chunkTCADE3WYcjs.DEFAULT_LANE}" is reserved`);
4353
+ _chunkUPKDCTS2cjs.resolveLaneConfig.call(void 0, config2);
4354
+ if (config2.name === _chunkPN5GNW6Ecjs.DEFAULT_LANE)
4355
+ throw new Error(`Lane "${_chunkPN5GNW6Ecjs.DEFAULT_LANE}" is reserved`);
4354
4356
  const existing = lanes.find((l) => l.name === config2.name);
4355
4357
  if (!existing) return void lanes.push(config2);
4356
4358
  if (existing.leaseMillis !== config2.leaseMillis || existing.streamLimit !== config2.streamLimit || existing.cycleMs !== config2.cycleMs)
@@ -4392,9 +4394,9 @@ function reaction_on(event, events, builder) {
4392
4394
  // Validate the whole bag at the declaration site so a bad
4393
4395
  // `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
4394
4396
  // not a NaN gate on the first retry.
4395
- options: _chunkBYTYS2LBcjs.resolveReactionConfig.call(void 0, {
4396
- blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _159 => _159.blockOnError]), () => ( _chunkBYTYS2LBcjs.DEFAULT_BLOCK_ON_ERROR)),
4397
- maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _160 => _160.maxRetries]), () => ( _chunkBYTYS2LBcjs.DEFAULT_MAX_RETRIES)),
4397
+ options: _chunkUPKDCTS2cjs.resolveReactionConfig.call(void 0, {
4398
+ blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _159 => _159.blockOnError]), () => ( _chunkUPKDCTS2cjs.DEFAULT_BLOCK_ON_ERROR)),
4399
+ maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _160 => _160.maxRetries]), () => ( _chunkUPKDCTS2cjs.DEFAULT_MAX_RETRIES)),
4398
4400
  backoff: _optionalChain([options, 'optionalAccess', _161 => _161.backoff])
4399
4401
  })
4400
4402
  };
@@ -4414,9 +4416,8 @@ function reaction_on(event, events, builder) {
4414
4416
 
4415
4417
  // src/internal/date-reviver.ts
4416
4418
 
4417
- var def_of = (schema) => _nullishCoalesce(_optionalChain([schema, 'access', _162 => _162._zod, 'optionalAccess', _163 => _163.def]), () => ( schema.def));
4418
4419
  function variant_schema(schema) {
4419
- const shape = _optionalChain([def_of, 'call', _164 => _164(schema), 'optionalAccess', _165 => _165.shape]);
4420
+ const shape = _optionalChain([_chunkPN5GNW6Ecjs.def_of.call(void 0, schema), 'optionalAccess', _162 => _162.shape]);
4420
4421
  if (!shape) {
4421
4422
  const dates = date_reviver_schema(schema);
4422
4423
  return { schema: _nullishCoalesce(dates, () => ( schema)), dated: !!dates };
@@ -4428,15 +4429,15 @@ function variant_schema(schema) {
4428
4429
  if (dates) dated = true;
4429
4430
  next[key] = (_nullishCoalesce(dates, () => ( field))).optional();
4430
4431
  }
4431
- return { schema: _zod2.z.looseObject(next), dated };
4432
+ return { schema: _zod.z.looseObject(next), dated };
4432
4433
  }
4433
4434
  function date_reviver_schema(schema) {
4434
- const def = def_of(schema);
4435
+ const def = _chunkPN5GNW6Ecjs.def_of.call(void 0, schema);
4435
4436
  if (!def) return void 0;
4436
4437
  const inner = () => date_reviver_schema(def.innerType);
4437
4438
  switch (def.type) {
4438
4439
  case "date":
4439
- return _zod2.z.coerce.date();
4440
+ return _zod.z.coerce.date();
4440
4441
  case "object": {
4441
4442
  const shape = def.shape;
4442
4443
  if (!shape) return void 0;
@@ -4445,26 +4446,28 @@ function date_reviver_schema(schema) {
4445
4446
  const dates = date_reviver_schema(field);
4446
4447
  if (dates) dated[key] = dates.optional();
4447
4448
  }
4448
- return Object.keys(dated).length ? _zod2.z.looseObject(dated) : void 0;
4449
+ return Object.keys(dated).length ? _zod.z.looseObject(dated) : void 0;
4449
4450
  }
4450
4451
  case "array": {
4451
4452
  const element = date_reviver_schema(def.element);
4452
- return element && _zod2.z.array(element);
4453
+ return element && _zod.z.array(element);
4453
4454
  }
4454
4455
  case "tuple": {
4455
4456
  const items = def.items.map((i) => date_reviver_schema(i));
4456
- return items.some(Boolean) ? _zod2.z.tuple(items.map((i) => _nullishCoalesce(i, () => ( _zod2.z.unknown())))) : void 0;
4457
+ return items.some(Boolean) ? _zod.z.tuple(items.map((i) => _nullishCoalesce(i, () => ( _zod.z.unknown())))) : void 0;
4457
4458
  }
4458
4459
  case "record": {
4459
4460
  const value = date_reviver_schema(def.valueType);
4460
- return value && _zod2.z.record(_zod2.z.string(), value);
4461
+ return value && _zod.z.record(_zod.z.string(), value);
4461
4462
  }
4462
4463
  case "union": {
4463
4464
  const variants = def.options.map(variant_schema);
4464
- return variants.some((v) => v.dated) ? _zod2.z.union(variants.map((v) => v.schema)) : void 0;
4465
+ return variants.some((v) => v.dated) ? _zod.z.union(variants.map((v) => v.schema)) : void 0;
4465
4466
  }
4466
4467
  case "nullable":
4467
- return _optionalChain([inner, 'call', _166 => _166(), 'optionalAccess', _167 => _167.nullable, 'call', _168 => _168()]);
4468
+ return _optionalChain([inner, 'call', _163 => _163(), 'optionalAccess', _164 => _164.nullable, 'call', _165 => _165()]);
4469
+ case "pipe":
4470
+ return date_reviver_schema(def.out);
4468
4471
  case "optional":
4469
4472
  case "nonoptional":
4470
4473
  case "readonly":
@@ -4479,7 +4482,7 @@ function date_reviver_schema(schema) {
4479
4482
 
4480
4483
  // src/builders/event-builder.ts
4481
4484
  function event_tags(schema) {
4482
- const pii = _chunkTCADE3WYcjs.pii_schemas.call(void 0, schema);
4485
+ const pii = _chunkPN5GNW6Ecjs.pii_schemas.call(void 0, schema);
4483
4486
  const pii_dates = {};
4484
4487
  for (const [key, field] of Object.entries(pii)) {
4485
4488
  const dates = date_reviver_schema(field);
@@ -4492,13 +4495,14 @@ function event_tags(schema) {
4492
4495
  };
4493
4496
  const dated_pii = Object.keys(pii_dates).length > 0;
4494
4497
  return {
4495
- sensitive: Object.keys(pii),
4498
+ sensitive: pii,
4496
4499
  date_reviver: data_reviver_schema && revive(data_reviver_schema),
4497
- pii_date_reviver: dated_pii ? revive(_zod2.z.looseObject(pii_dates)) : void 0
4500
+ pii_date_reviver: dated_pii ? revive(_zod.z.looseObject(pii_dates)) : void 0
4498
4501
  };
4499
4502
  }
4500
4503
  function make_event_reader(tags, disclosure, predicate = null) {
4501
- const { sensitive: sensitive2, date_reviver, pii_date_reviver } = tags;
4504
+ const { date_reviver, pii_date_reviver } = tags;
4505
+ const sensitive2 = Object.keys(tags.sensitive);
4502
4506
  if (!date_reviver && sensitive2.length === 0) return void 0;
4503
4507
  const gate = sensitive2.length === 0 ? IDENTITY_GATE : disclosure === "strip" ? ((event) => pii_strip(event, sensitive2)) : make_gate(sensitive2, predicate);
4504
4508
  if (!date_reviver) return gate;
@@ -4516,7 +4520,7 @@ function make_event_reader(tags, disclosure, predicate = null) {
4516
4520
  });
4517
4521
  }
4518
4522
  function build_events(registry, states, lanes, owners) {
4519
- const declared = /* @__PURE__ */ new Set([_chunkTCADE3WYcjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
4523
+ const declared = /* @__PURE__ */ new Set([_chunkPN5GNW6Ecjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
4520
4524
  const lane_errors = [];
4521
4525
  const tags = /* @__PURE__ */ new Map();
4522
4526
  const sensitive2 = /* @__PURE__ */ new Map();
@@ -4540,7 +4544,8 @@ function build_events(registry, states, lanes, owners) {
4540
4544
  }
4541
4545
  const event = event_tags(def.schema);
4542
4546
  tags.set(event_name, event);
4543
- if (event.sensitive.length > 0) sensitive2.set(event_name, event.sensitive);
4547
+ const fields = Object.keys(event.sensitive);
4548
+ if (fields.length > 0) sensitive2.set(event_name, fields);
4544
4549
  const query_reader = make_event_reader(event, "redact", null);
4545
4550
  if (query_reader) query_readers.set(event_name, query_reader);
4546
4551
  const handler_reader = make_event_reader(event, "strip");
@@ -4556,11 +4561,21 @@ function build_events(registry, states, lanes, owners) {
4556
4561
  }
4557
4562
  }
4558
4563
  if (lane_errors.length > 0) throw new Error(lane_errors[0]);
4564
+ const advised = /* @__PURE__ */ new Set();
4559
4565
  for (const state2 of states.values()) {
4566
+ const shape = _nullishCoalesce(state2.state.shape, () => ( {}));
4560
4567
  const state_fields = /* @__PURE__ */ new Map();
4561
4568
  for (const event_name of Object.keys(state2.events)) {
4562
4569
  const fields = sensitive2.get(event_name);
4563
- if (fields) state_fields.set(event_name, fields);
4570
+ if (!fields) continue;
4571
+ state_fields.set(event_name, fields);
4572
+ const event = tags.get(event_name);
4573
+ for (const field of fields) {
4574
+ if (!reads_as_string(event.sensitive[field]))
4575
+ advised.add(`${event_name}.${field}`);
4576
+ if (shape[field] && !reads_as_string(shape[field]))
4577
+ advised.add(`${state2.name}.${field}`);
4578
+ }
4564
4579
  }
4565
4580
  if (state_fields.size > 0) {
4566
4581
  if (state2.snap)
@@ -4580,11 +4595,16 @@ function build_events(registry, states, lanes, owners) {
4580
4595
  if (reader) readers.set(event_name, reader);
4581
4596
  }
4582
4597
  const snap2 = make_event_reader(event_tags(state2.state), "redact", null);
4583
- if (snap2) readers.set(_chunkTCADE3WYcjs.SNAP_EVENT, snap2);
4598
+ if (snap2) readers.set(_chunkPN5GNW6Ecjs.SNAP_EVENT, snap2);
4584
4599
  if (readers.size === 0) continue;
4585
4600
  state2.view = (event, actor) => (_nullishCoalesce(readers.get(event.name), () => ( IDENTITY_GATE)))(event, actor);
4586
4601
  }
4587
- return { sensitive: sensitive2, query_readers, handler_readers };
4602
+ const advisory = advised.size > 0 ? `Act has ${advised.size} sensitive field(s) whose type isn't a string: ${[...advised].join(", ")}. A caller who may not see one reads "[REDACTED]" or "[SHREDDED]" there instead, which its type doesn't allow. Declare sensitive fields as strings. See docs/docs/guides/sensitive-data.md.` : void 0;
4603
+ return { sensitive: sensitive2, advisory, query_readers, handler_readers };
4604
+ }
4605
+ function reads_as_string(schema) {
4606
+ const type = _optionalChain([_chunkPN5GNW6Ecjs.def_of.call(void 0, _chunkPN5GNW6Ecjs.output_of.call(void 0, schema)), 'optionalAccess', _166 => _166.type]);
4607
+ return type === "string" || type === "transform";
4588
4608
  }
4589
4609
 
4590
4610
  // src/builders/act-builder.ts
@@ -4639,27 +4659,9 @@ function act() {
4639
4659
  const fold_specs = [];
4640
4660
  const lanes = [];
4641
4661
  let _built = false;
4642
- const advise_pii_types = () => {
4643
- const fields = /* @__PURE__ */ new Set();
4644
- for (const state2 of states.values()) {
4645
- const shape = _nullishCoalesce(state2.state.shape, () => ( {}));
4646
- for (const [event, schema] of Object.entries(state2.events))
4647
- for (const [field, field_schema] of Object.entries(
4648
- _chunkTCADE3WYcjs.pii_schemas.call(void 0, schema)
4649
- )) {
4650
- if (!reads_as_string(field_schema)) fields.add(`${event}.${field}`);
4651
- if (shape[field] && !reads_as_string(shape[field]))
4652
- fields.add(`${state2.name}.${field}`);
4653
- }
4654
- }
4655
- if (fields.size > 0)
4656
- _chunkBYTYS2LBcjs.log.call(void 0, ).warn(
4657
- `Act has ${fields.size} sensitive field(s) whose type isn't a string: ${[...fields].join(", ")}. A caller who may not see one reads "[REDACTED]" or "[SHREDDED]" there instead, which its type doesn't allow. Declare sensitive fields as strings. See docs/docs/guides/sensitive-data.md.`
4658
- );
4659
- };
4660
4662
  const read_wrap = (original) => {
4661
4663
  const wrapped = async (events, stream) => {
4662
- const read = events.map((e) => _nullishCoalesce(_optionalChain([_hr, 'access', _169 => _169.get, 'call', _170 => _170(e.name), 'optionalCall', _171 => _171(e)]), () => ( e)));
4664
+ const read = events.map((e) => _nullishCoalesce(_optionalChain([_hr, 'access', _167 => _167.get, 'call', _168 => _168(e.name), 'optionalCall', _169 => _169(e)]), () => ( e)));
4663
4665
  return original(read, stream);
4664
4666
  };
4665
4667
  const reset = original[FOLD_RESET];
@@ -4700,7 +4702,7 @@ function act() {
4700
4702
  });
4701
4703
  }
4702
4704
  for (const [action_name, handler] of Object.entries(state2.on)) {
4703
- const static_target = _optionalChain([handler, 'optionalAccess', _172 => _172._static_emit]);
4705
+ const static_target = _optionalChain([handler, 'optionalAccess', _170 => _170._static_emit]);
4704
4706
  if (static_target && deprecated.has(static_target)) {
4705
4707
  const current = current_version_of(static_target, event_names);
4706
4708
  throw new Error(
@@ -4713,7 +4715,7 @@ function act() {
4713
4715
  const list = deprecation_summary.map(
4714
4716
  (d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
4715
4717
  ).join(", ");
4716
- _chunkBYTYS2LBcjs.log.call(void 0, ).info(
4718
+ _chunkUPKDCTS2cjs.log.call(void 0, ).info(
4717
4719
  `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.`
4718
4720
  );
4719
4721
  }
@@ -4755,7 +4757,7 @@ function act() {
4755
4757
  return reaction_on(event, registry.events, builder);
4756
4758
  },
4757
4759
  build: (options) => {
4758
- _chunkBYTYS2LBcjs.resolveActConfig.call(void 0, options);
4760
+ _chunkUPKDCTS2cjs.resolveActConfig.call(void 0, options);
4759
4761
  if (!_built) {
4760
4762
  for (const proj of pending_projections) add_projection(proj);
4761
4763
  for (const proj of fold_projections) {
@@ -4773,7 +4775,7 @@ function act() {
4773
4775
  `State projection "${proj.target}" of "${fold.name}" is missing events ${missing.join(", ")} \u2014 pass every partial of the state to .of()`
4774
4776
  );
4775
4777
  const claimed = fold_specs.find((s) => s.target === proj.target);
4776
- if (_optionalChain([claimed, 'optionalAccess', _173 => _173.projection]) === proj) continue;
4778
+ if (_optionalChain([claimed, 'optionalAccess', _171 => _171.projection]) === proj) continue;
4777
4779
  if (batch_handlers.has(proj.target) || claimed)
4778
4780
  throw new Error(
4779
4781
  `Duplicate projection target "${proj.target}" \u2014 a target is served by one batch handler or one state projection, never both`
@@ -4795,7 +4797,7 @@ function act() {
4795
4797
  for (const [name, gate] of built.query_readers) _qg.set(name, gate);
4796
4798
  for (const [name, gate] of built.handler_readers) _hr.set(name, gate);
4797
4799
  finalize_deprecations();
4798
- advise_pii_types();
4800
+ if (built.advisory) _chunkUPKDCTS2cjs.log.call(void 0, ).warn(built.advisory);
4799
4801
  for (const state2 of states.values()) {
4800
4802
  if (state2.disclose) _dp.set(state2.name, state2.disclose);
4801
4803
  if (state2.autoclose) _ac.set(state2.name, state2.autoclose);
@@ -4807,7 +4809,7 @@ function act() {
4807
4809
  synthesize_autoclose_reactions(
4808
4810
  registry,
4809
4811
  states,
4810
- _chunkBYTYS2LBcjs.current_autoclose_window
4812
+ _chunkUPKDCTS2cjs.current_autoclose_window
4811
4813
  );
4812
4814
  Object.freeze(registry.actions);
4813
4815
  Object.freeze(registry.events);
@@ -4826,12 +4828,6 @@ function act() {
4826
4828
  };
4827
4829
  return builder;
4828
4830
  }
4829
- function reads_as_string(schema) {
4830
- const def = schema._zod.def;
4831
- if (def.type === "string" || def.type === "transform") return true;
4832
- if (def.out) return reads_as_string(def.out);
4833
- return def.innerType ? reads_as_string(def.innerType) : false;
4834
- }
4835
4831
 
4836
4832
  // src/builders/projection-builder.ts
4837
4833
  function _projection(target) {
@@ -4861,8 +4857,8 @@ function _projection(target) {
4861
4857
  handler,
4862
4858
  resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
4863
4859
  options: {
4864
- blockOnError: _chunkBYTYS2LBcjs.DEFAULT_BLOCK_ON_ERROR,
4865
- maxRetries: _chunkBYTYS2LBcjs.DEFAULT_MAX_RETRIES
4860
+ blockOnError: _chunkUPKDCTS2cjs.DEFAULT_BLOCK_ON_ERROR,
4861
+ maxRetries: _chunkUPKDCTS2cjs.DEFAULT_MAX_RETRIES
4866
4862
  }
4867
4863
  }),
4868
4864
  widened
@@ -4903,7 +4899,7 @@ function _projection(target) {
4903
4899
  throw new Error(
4904
4900
  `Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
4905
4901
  );
4906
- const config2 = _chunkBYTYS2LBcjs.resolveFoldConfig.call(void 0, options);
4902
+ const config2 = _chunkUPKDCTS2cjs.resolveFoldConfig.call(void 0, options);
4907
4903
  const fold_events = {};
4908
4904
  for (const partial of partials)
4909
4905
  for (const [event_name, schema] of Object.entries(partial.events)) {
@@ -4921,8 +4917,8 @@ function _projection(target) {
4921
4917
  handler: noop,
4922
4918
  resolver: { target },
4923
4919
  options: {
4924
- blockOnError: _chunkBYTYS2LBcjs.DEFAULT_BLOCK_ON_ERROR,
4925
- maxRetries: _chunkBYTYS2LBcjs.DEFAULT_MAX_RETRIES
4920
+ blockOnError: _chunkUPKDCTS2cjs.DEFAULT_BLOCK_ON_ERROR,
4921
+ maxRetries: _chunkUPKDCTS2cjs.DEFAULT_MAX_RETRIES
4926
4922
  }
4927
4923
  }
4928
4924
  ]
@@ -5038,7 +5034,7 @@ function action_builder(state2) {
5038
5034
  throw new Error(`Duplicate action "${action2}"`);
5039
5035
  internal.actions[action2] = schema;
5040
5036
  if (options) {
5041
- _chunkBYTYS2LBcjs.resolveActionConfig.call(void 0, options);
5037
+ _chunkUPKDCTS2cjs.resolveActionConfig.call(void 0, options);
5042
5038
  internal.options ??= {};
5043
5039
  internal.options[action2] = options;
5044
5040
  }
@@ -5331,5 +5327,5 @@ function write_line(writer, line) {
5331
5327
 
5332
5328
 
5333
5329
 
5334
- exports.Act = Act; exports.ActorSchema = _chunkTCADE3WYcjs.ActorSchema; exports.CausationEventSchema = _chunkTCADE3WYcjs.CausationEventSchema; exports.CommittedMetaSchema = _chunkTCADE3WYcjs.CommittedMetaSchema; exports.ConcurrencyError = _chunkTCADE3WYcjs.ConcurrencyError; exports.ConsoleLogger = _chunkBYTYS2LBcjs.ConsoleLogger; exports.CsvFile = CsvFile; exports.DEFAULT_LANE = _chunkTCADE3WYcjs.DEFAULT_LANE; exports.DEFAULT_MAX_SUBSCRIBED_STREAMS = _chunkTCADE3WYcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS; exports.DEFAULT_SETTLE_DEBOUNCE_MS = _chunkTCADE3WYcjs.DEFAULT_SETTLE_DEBOUNCE_MS; exports.DeferSignal = _chunkTCADE3WYcjs.DeferSignal; exports.Environments = _chunkTCADE3WYcjs.Environments; exports.Errors = _chunkTCADE3WYcjs.Errors; exports.EventMetaSchema = _chunkTCADE3WYcjs.EventMetaSchema; exports.ExitCodes = _chunkTCADE3WYcjs.ExitCodes; exports.InMemoryCache = _chunkBYTYS2LBcjs.InMemoryCache; exports.InMemoryStore = _chunkBYTYS2LBcjs.InMemoryStore; exports.InvariantError = _chunkTCADE3WYcjs.InvariantError; exports.LogLevels = _chunkTCADE3WYcjs.LogLevels; exports.NonRetryableError = _chunkTCADE3WYcjs.NonRetryableError; exports.PackageSchema = _chunkBYTYS2LBcjs.PackageSchema; exports.PreconditionError = _chunkTCADE3WYcjs.PreconditionError; exports.QuerySchema = _chunkTCADE3WYcjs.QuerySchema; exports.REDACTED = _chunkTCADE3WYcjs.REDACTED; exports.SHREDDED = _chunkTCADE3WYcjs.SHREDDED; exports.SNAP_EVENT = _chunkTCADE3WYcjs.SNAP_EVENT; exports.StoreError = _chunkTCADE3WYcjs.StoreError; exports.StreamClosedError = _chunkTCADE3WYcjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunkTCADE3WYcjs.TOMBSTONE_EVENT; exports.TargetSchema = _chunkTCADE3WYcjs.TargetSchema; exports.ValidationError = _chunkTCADE3WYcjs.ValidationError; exports.ZodEmpty = _chunkTCADE3WYcjs.ZodEmpty; exports.act = act; exports.cache = _chunkBYTYS2LBcjs.cache; exports.config = _chunkBYTYS2LBcjs.config; exports.dateReviver = _chunkBYTYS2LBcjs.dateReviver; exports.default_scope = _chunkBYTYS2LBcjs.default_scope; exports.dispose = _chunkBYTYS2LBcjs.dispose; exports.disposeAndExit = _chunkBYTYS2LBcjs.disposeAndExit; exports.extend = _chunkBYTYS2LBcjs.extend; exports.is_literal_source = _chunkBYTYS2LBcjs.is_literal_source; exports.log = _chunkBYTYS2LBcjs.log; exports.pii_fields = _chunkTCADE3WYcjs.pii_fields; exports.port = _chunkBYTYS2LBcjs.port; exports.projection = projection; exports.resolveAutocloseConfig = _chunkBYTYS2LBcjs.resolveAutocloseConfig2; exports.sensitive = _chunkTCADE3WYcjs.sensitive; exports.sleep = _chunkBYTYS2LBcjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkBYTYS2LBcjs.store; exports.validate = _chunkBYTYS2LBcjs.validate;
5330
+ exports.Act = Act; exports.ActorSchema = _chunkPN5GNW6Ecjs.ActorSchema; exports.CausationEventSchema = _chunkPN5GNW6Ecjs.CausationEventSchema; exports.CommittedMetaSchema = _chunkPN5GNW6Ecjs.CommittedMetaSchema; exports.ConcurrencyError = _chunkPN5GNW6Ecjs.ConcurrencyError; exports.ConsoleLogger = _chunkUPKDCTS2cjs.ConsoleLogger; exports.CsvFile = CsvFile; exports.DEFAULT_LANE = _chunkPN5GNW6Ecjs.DEFAULT_LANE; exports.DEFAULT_MAX_SUBSCRIBED_STREAMS = _chunkPN5GNW6Ecjs.DEFAULT_MAX_SUBSCRIBED_STREAMS; exports.DEFAULT_SETTLE_DEBOUNCE_MS = _chunkPN5GNW6Ecjs.DEFAULT_SETTLE_DEBOUNCE_MS; exports.DeferSignal = _chunkPN5GNW6Ecjs.DeferSignal; exports.Environments = _chunkPN5GNW6Ecjs.Environments; exports.Errors = _chunkPN5GNW6Ecjs.Errors; exports.EventMetaSchema = _chunkPN5GNW6Ecjs.EventMetaSchema; exports.ExitCodes = _chunkPN5GNW6Ecjs.ExitCodes; exports.InMemoryCache = _chunkUPKDCTS2cjs.InMemoryCache; exports.InMemoryStore = _chunkUPKDCTS2cjs.InMemoryStore; exports.InvariantError = _chunkPN5GNW6Ecjs.InvariantError; exports.LogLevels = _chunkPN5GNW6Ecjs.LogLevels; exports.NonRetryableError = _chunkPN5GNW6Ecjs.NonRetryableError; exports.PackageSchema = _chunkUPKDCTS2cjs.PackageSchema; exports.PreconditionError = _chunkPN5GNW6Ecjs.PreconditionError; exports.QuerySchema = _chunkPN5GNW6Ecjs.QuerySchema; exports.REDACTED = _chunkPN5GNW6Ecjs.REDACTED; exports.SHREDDED = _chunkPN5GNW6Ecjs.SHREDDED; exports.SNAP_EVENT = _chunkPN5GNW6Ecjs.SNAP_EVENT; exports.StoreError = _chunkPN5GNW6Ecjs.StoreError; exports.StreamClosedError = _chunkPN5GNW6Ecjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunkPN5GNW6Ecjs.TOMBSTONE_EVENT; exports.TargetSchema = _chunkPN5GNW6Ecjs.TargetSchema; exports.ValidationError = _chunkPN5GNW6Ecjs.ValidationError; exports.ZodEmpty = _chunkPN5GNW6Ecjs.ZodEmpty; exports.act = act; exports.cache = _chunkUPKDCTS2cjs.cache; exports.config = _chunkUPKDCTS2cjs.config; exports.dateReviver = _chunkUPKDCTS2cjs.dateReviver; exports.default_scope = _chunkUPKDCTS2cjs.default_scope; exports.dispose = _chunkUPKDCTS2cjs.dispose; exports.disposeAndExit = _chunkUPKDCTS2cjs.disposeAndExit; exports.extend = _chunkUPKDCTS2cjs.extend; exports.is_literal_source = _chunkUPKDCTS2cjs.is_literal_source; exports.log = _chunkUPKDCTS2cjs.log; exports.pii_fields = _chunkPN5GNW6Ecjs.pii_fields; exports.port = _chunkUPKDCTS2cjs.port; exports.projection = projection; exports.resolveAutocloseConfig = _chunkUPKDCTS2cjs.resolveAutocloseConfig2; exports.sensitive = _chunkPN5GNW6Ecjs.sensitive; exports.sleep = _chunkUPKDCTS2cjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkUPKDCTS2cjs.store; exports.validate = _chunkUPKDCTS2cjs.validate;
5335
5331
  //# sourceMappingURL=index.cjs.map