@rotorsoft/act 1.37.3 → 1.37.5

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