@rotorsoft/act 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -44,10 +44,10 @@
44
44
 
45
45
 
46
46
 
47
- var _chunkS2BEPQ5Zcjs = require('./chunk-S2BEPQ5Z.cjs');
48
47
 
49
48
 
50
49
 
50
+ var _chunkEAFNHF5Scjs = require('./chunk-EAFNHF5S.cjs');
51
51
 
52
52
 
53
53
 
@@ -77,24 +77,27 @@ var _chunkS2BEPQ5Zcjs = require('./chunk-S2BEPQ5Z.cjs');
77
77
 
78
78
 
79
79
 
80
- var _chunk3CQWJ4UAcjs = require('./chunk-3CQWJ4UA.cjs');
80
+
81
+
82
+
83
+ var _chunkVD4BLAY4cjs = require('./chunk-VD4BLAY4.cjs');
81
84
 
82
85
  // src/signals.ts
83
86
  process.once("SIGINT", async (arg) => {
84
- _chunkS2BEPQ5Zcjs.log.call(void 0, ).info(arg, "SIGINT");
85
- await _chunkS2BEPQ5Zcjs.disposeAndExit.call(void 0, "EXIT");
87
+ _chunkEAFNHF5Scjs.log.call(void 0, ).info(arg, "SIGINT");
88
+ await _chunkEAFNHF5Scjs.disposeAndExit.call(void 0, "EXIT");
86
89
  });
87
90
  process.once("SIGTERM", async (arg) => {
88
- _chunkS2BEPQ5Zcjs.log.call(void 0, ).info(arg, "SIGTERM");
89
- await _chunkS2BEPQ5Zcjs.disposeAndExit.call(void 0, "EXIT");
91
+ _chunkEAFNHF5Scjs.log.call(void 0, ).info(arg, "SIGTERM");
92
+ await _chunkEAFNHF5Scjs.disposeAndExit.call(void 0, "EXIT");
90
93
  });
91
94
  process.once("uncaughtException", async (arg) => {
92
- _chunkS2BEPQ5Zcjs.log.call(void 0, ).error(arg, "Uncaught Exception");
93
- await _chunkS2BEPQ5Zcjs.disposeAndExit.call(void 0, "ERROR");
95
+ _chunkEAFNHF5Scjs.log.call(void 0, ).error(arg, "Uncaught Exception");
96
+ await _chunkEAFNHF5Scjs.disposeAndExit.call(void 0, "ERROR");
94
97
  });
95
98
  process.once("unhandledRejection", async (arg) => {
96
- _chunkS2BEPQ5Zcjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
97
- await _chunkS2BEPQ5Zcjs.disposeAndExit.call(void 0, "ERROR");
99
+ _chunkEAFNHF5Scjs.log.call(void 0, ).error(arg, "Unhandled Rejection");
100
+ await _chunkEAFNHF5Scjs.disposeAndExit.call(void 0, "ERROR");
98
101
  });
99
102
 
100
103
  // src/act.ts
@@ -202,7 +205,7 @@ async function* audit(deps, categories, options = {}) {
202
205
  if (need_stats) {
203
206
  const stats = await deps.store().query_stats(
204
207
  {},
205
- { count: true, names: true, exclude: [_chunk3CQWJ4UAcjs.SNAP_EVENT] }
208
+ { count: true, names: true, exclude: [_chunkVD4BLAY4cjs.SNAP_EVENT] }
206
209
  );
207
210
  for (const [stream, s] of stats) {
208
211
  for (const p of passes) _optionalChain([p, 'access', _4 => _4.on_stat, 'optionalCall', _5 => _5(stream, s)]);
@@ -284,7 +287,7 @@ var make_schema_pass = (deps) => {
284
287
  return;
285
288
  }
286
289
  const schema = state2.events[name];
287
- const sensitive2 = _chunk3CQWJ4UAcjs.pii_fields.call(void 0, schema);
290
+ const sensitive2 = _chunkVD4BLAY4cjs.pii_fields.call(void 0, schema);
288
291
  let parse_schema = schema;
289
292
  if (sensitive2.length > 0) {
290
293
  const omitter = schema.omit;
@@ -418,7 +421,7 @@ var make_restart_candidate_pass = (deps, options) => {
418
421
  {
419
422
  stream,
420
423
  stream_exact: true,
421
- names: [_chunk3CQWJ4UAcjs.SNAP_EVENT],
424
+ names: [_chunkVD4BLAY4cjs.SNAP_EVENT],
422
425
  with_snaps: true,
423
426
  // From the start: on its own, `with_snaps` resumes at the latest.
424
427
  after: -1
@@ -578,7 +581,7 @@ var make_correlation_gaps_pass = () => {
578
581
  seen_ids.add(e.id);
579
582
  const causation = _optionalChain([e, 'access', _31 => _31.meta, 'optionalAccess', _32 => _32.causation]);
580
583
  const parent_id = _optionalChain([causation, 'optionalAccess', _33 => _33.event, 'optionalAccess', _34 => _34.id]);
581
- if (parent_id !== void 0 && e.name !== _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT) {
584
+ if (parent_id !== void 0 && e.name !== _chunkVD4BLAY4cjs.TOMBSTONE_EVENT) {
582
585
  checks.push({ stream: e.stream, id: e.id, parent_id });
583
586
  }
584
587
  },
@@ -862,20 +865,13 @@ function compile_is(is) {
862
865
  function compile_reaches(reaches) {
863
866
  return (_stream, _head, count) => count >= reaches;
864
867
  }
865
- function policy_min_after_days(options) {
866
- const parsed = AutoclosePolicySchema.parse(options);
867
- const windows = [];
868
- if (parsed.after) windows.push(parsed.after.days);
869
- if (_optionalChain([parsed, 'access', _42 => _42.or, 'optionalAccess', _43 => _43.after])) windows.push(parsed.or.after.days);
870
- return windows.length ? Math.min(...windows) : void 0;
871
- }
872
868
  function policy_after_windows(options) {
873
869
  const parsed = AutoclosePolicySchema.parse(options);
874
- return [parsed.after, _optionalChain([parsed, 'access', _44 => _44.or, 'optionalAccess', _45 => _45.after])].flatMap((w) => w ? [w.days] : []);
870
+ return [parsed.after, _optionalChain([parsed, 'access', _42 => _42.or, 'optionalAccess', _43 => _43.after])].flatMap((w) => w ? [w.days] : []);
875
871
  }
876
872
  function policy_keep_days(options) {
877
873
  const parsed = AutoclosePolicySchema.parse(options);
878
- return _optionalChain([parsed, 'access', _46 => _46.keep, 'optionalAccess', _47 => _47.days]);
874
+ return _optionalChain([parsed, 'access', _44 => _44.keep, 'optionalAccess', _45 => _45.days]);
879
875
  }
880
876
  function compile_autoclose_policy(options) {
881
877
  const parsed = AutoclosePolicySchema.parse(options);
@@ -907,7 +903,7 @@ function hour_in_zone(now, timeZone) {
907
903
  hour: "2-digit",
908
904
  hourCycle: "h23"
909
905
  }).formatToParts(now);
910
- return Number(_optionalChain([parts, 'access', _48 => _48.find, 'call', _49 => _49((p) => p.type === "hour"), 'optionalAccess', _50 => _50.value]));
906
+ return Number(_optionalChain([parts, 'access', _46 => _46.find, 'call', _47 => _47((p) => p.type === "hour"), 'optionalAccess', _48 => _48.value]));
911
907
  }
912
908
  function hour_in_range(hour, start, end) {
913
909
  return start < end ? hour >= start && hour < end : hour >= start || hour < end;
@@ -968,7 +964,7 @@ function make_deferred(handler, schedule) {
968
964
  const call = handler;
969
965
  const deferred = async (event, stream, app) => {
970
966
  const when = typeof schedule === "function" ? schedule(event) : schedule;
971
- if (Date.now() < resolve_defer_at(when, event)) throw new (0, _chunk3CQWJ4UAcjs.DeferSignal)(when);
967
+ if (Date.now() < resolve_defer_at(when, event)) throw new (0, _chunkVD4BLAY4cjs.DeferSignal)(when);
972
968
  return call(event, stream, app);
973
969
  };
974
970
  Object.defineProperty(deferred, "name", { value: handler.name });
@@ -1100,7 +1096,7 @@ function compute_lag_lead_ratio(handled, lagging, leading) {
1100
1096
  function report_once(seen, key, message) {
1101
1097
  if (seen.has(key)) return;
1102
1098
  seen.add(key);
1103
- _chunkS2BEPQ5Zcjs.log.call(void 0, ).error(new Error(message));
1099
+ _chunkEAFNHF5Scjs.log.call(void 0, ).error(new Error(message));
1104
1100
  }
1105
1101
 
1106
1102
  // src/internal/correlation-id.ts
@@ -1128,14 +1124,14 @@ function close_correlation(correlator, actor) {
1128
1124
  }
1129
1125
 
1130
1126
  // src/internal/drain-ops.ts
1131
- var claim = (lagging, leading, by, millis, lane) => _chunkS2BEPQ5Zcjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane);
1127
+ var claim = (lagging, leading, by, millis, lane) => _chunkEAFNHF5Scjs.store.call(void 0, ).claim(lagging, leading, by, millis, lane);
1132
1128
  async function fetch(leased, eventLimit) {
1133
1129
  return Promise.all(
1134
1130
  leased.map(async ({ stream, source, at, lagging }) => {
1135
1131
  const events = [];
1136
- const stream_exact = source !== void 0 && _chunkS2BEPQ5Zcjs.is_literal_source.call(void 0, source, stream) ? true : void 0;
1132
+ const stream_exact = source !== void 0 && _chunkEAFNHF5Scjs.is_literal_source.call(void 0, source, stream) ? true : void 0;
1137
1133
  try {
1138
- await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query((e) => events.push(e), {
1134
+ await _chunkEAFNHF5Scjs.store.call(void 0, ).query((e) => events.push(e), {
1139
1135
  stream: source,
1140
1136
  stream_exact,
1141
1137
  after: at,
@@ -1148,23 +1144,23 @@ async function fetch(leased, eventLimit) {
1148
1144
  at,
1149
1145
  lagging,
1150
1146
  events: [],
1151
- error: _nullishCoalesce(_optionalChain([error, 'optionalAccess', _51 => _51.message]), () => ( String(error)))
1147
+ error: _nullishCoalesce(_optionalChain([error, 'optionalAccess', _49 => _49.message]), () => ( String(error)))
1152
1148
  };
1153
1149
  }
1154
1150
  return { stream, source, at, lagging, events };
1155
1151
  })
1156
1152
  );
1157
1153
  }
1158
- var ack = (leases) => _chunkS2BEPQ5Zcjs.store.call(void 0, ).ack(leases);
1159
- var block = (leases) => _chunkS2BEPQ5Zcjs.store.call(void 0, ).block(leases);
1160
- var subscribe = (streams, correlated_at, correlator) => _chunkS2BEPQ5Zcjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator);
1154
+ var ack = (leases) => _chunkEAFNHF5Scjs.store.call(void 0, ).ack(leases);
1155
+ var block = (leases) => _chunkEAFNHF5Scjs.store.call(void 0, ).block(leases);
1156
+ var subscribe = (streams, correlated_at, correlator) => _chunkEAFNHF5Scjs.store.call(void 0, ).subscribe(streams, correlated_at, correlator);
1161
1157
 
1162
1158
  // src/internal/event-sourcing.ts
1163
1159
  var _actpatch = require('@rotorsoft/act-patch');
1164
1160
 
1165
1161
  var bare_patch = (_me, state2, partial) => _actpatch.patch.call(void 0, state2, partial);
1166
1162
  var value_at = (value, path) => path.reduce(
1167
- (at, key) => _optionalChain([at, 'optionalAccess', _52 => _52[key]]),
1163
+ (at, key) => _optionalChain([at, 'optionalAccess', _50 => _50[key]]),
1168
1164
  value
1169
1165
  );
1170
1166
  var check_invariants = (target, state2, schema, pii_aware) => {
@@ -1172,29 +1168,29 @@ var check_invariants = (target, state2, schema, pii_aware) => {
1172
1168
  try {
1173
1169
  result = schema.safeParse(state2);
1174
1170
  } catch (error) {
1175
- throw new (0, _chunk3CQWJ4UAcjs.ValidationError)(target, state2, error);
1171
+ throw new (0, _chunkVD4BLAY4cjs.ValidationError)(target, state2, error);
1176
1172
  }
1177
1173
  if (result.success) return;
1178
1174
  const issues = pii_aware ? result.error.issues.filter((issue) => {
1179
1175
  const value = value_at(state2, issue.path);
1180
- return value !== _chunk3CQWJ4UAcjs.REDACTED && value !== _chunk3CQWJ4UAcjs.SHREDDED;
1176
+ return value !== _chunkVD4BLAY4cjs.REDACTED && value !== _chunkVD4BLAY4cjs.SHREDDED;
1181
1177
  }) : result.error.issues;
1182
1178
  if (issues.length)
1183
- throw new (0, _chunk3CQWJ4UAcjs.ValidationError)(
1179
+ throw new (0, _chunkVD4BLAY4cjs.ValidationError)(
1184
1180
  target,
1185
1181
  state2,
1186
1182
  _zod.prettifyError.call(void 0, new (0, _zod.ZodError)(issues))
1187
1183
  );
1188
1184
  };
1189
1185
  var DEFAULT_BATCH = 500;
1190
- var cache_put = (stream, entry) => _chunkS2BEPQ5Zcjs.cache.call(void 0, ).set(stream, entry).catch(
1191
- (err) => _chunkS2BEPQ5Zcjs.log.call(void 0, ).warn(
1186
+ var cache_put = (stream, entry) => _chunkEAFNHF5Scjs.cache.call(void 0, ).set(stream, entry).catch(
1187
+ (err) => _chunkEAFNHF5Scjs.log.call(void 0, ).warn(
1192
1188
  err,
1193
1189
  "cache set skipped; the next load re-folds from the store"
1194
1190
  )
1195
1191
  );
1196
- var cache_drop = (stream) => _chunkS2BEPQ5Zcjs.cache.call(void 0, ).invalidate(stream).catch(
1197
- (err) => _chunkS2BEPQ5Zcjs.log.call(void 0, ).warn(
1192
+ var cache_drop = (stream) => _chunkEAFNHF5Scjs.cache.call(void 0, ).invalidate(stream).catch(
1193
+ (err) => _chunkEAFNHF5Scjs.log.call(void 0, ).warn(
1198
1194
  err,
1199
1195
  "cache invalidate skipped; a stale checkpoint re-folds from its event_id"
1200
1196
  )
@@ -1202,11 +1198,11 @@ var cache_drop = (stream) => _chunkS2BEPQ5Zcjs.cache.call(void 0, ).invalidate(s
1202
1198
  async function snap(snapshot) {
1203
1199
  const { id, stream, name, meta, version } = snapshot.event;
1204
1200
  try {
1205
- const [committed] = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).commit(
1201
+ const [committed] = await _chunkEAFNHF5Scjs.store.call(void 0, ).commit(
1206
1202
  [
1207
1203
  {
1208
1204
  stream,
1209
- msgs: [{ name: _chunk3CQWJ4UAcjs.SNAP_EVENT, data: snapshot.state }],
1205
+ msgs: [{ name: _chunkVD4BLAY4cjs.SNAP_EVENT, data: snapshot.state }],
1210
1206
  // IMPORTANT! - state events are committed right after the snapshot event
1211
1207
  expectedVersion: version
1212
1208
  }
@@ -1219,18 +1215,18 @@ async function snap(snapshot) {
1219
1215
  return committed;
1220
1216
  } catch (error) {
1221
1217
  const reason = error instanceof Error ? error.message : String(error);
1222
- _chunkS2BEPQ5Zcjs.log.call(void 0, ).warn(
1218
+ _chunkEAFNHF5Scjs.log.call(void 0, ).warn(
1223
1219
  `Snapshot write failed on stream "${stream}": ${reason} \u2014 cold starts will replay full history until snapshots succeed.`
1224
1220
  );
1225
1221
  }
1226
1222
  }
1227
1223
  async function tombstone(stream, expectedVersion, correlation) {
1228
1224
  try {
1229
- const [committed] = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).commit(
1225
+ const [committed] = await _chunkEAFNHF5Scjs.store.call(void 0, ).commit(
1230
1226
  [
1231
1227
  {
1232
1228
  stream,
1233
- msgs: [{ name: _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT, data: {} }],
1229
+ msgs: [{ name: _chunkVD4BLAY4cjs.TOMBSTONE_EVENT, data: {} }],
1234
1230
  expectedVersion
1235
1231
  }
1236
1232
  ],
@@ -1238,7 +1234,7 @@ async function tombstone(stream, expectedVersion, correlation) {
1238
1234
  );
1239
1235
  return committed;
1240
1236
  } catch (error) {
1241
- if (error instanceof _chunk3CQWJ4UAcjs.ConcurrencyError) return void 0;
1237
+ if (error instanceof _chunkVD4BLAY4cjs.ConcurrencyError) return void 0;
1242
1238
  throw error;
1243
1239
  }
1244
1240
  }
@@ -1268,9 +1264,9 @@ async function scan(source, opts = {}, callback) {
1268
1264
  if (drop_closed_streams) {
1269
1265
  await source.query(
1270
1266
  (e) => {
1271
- if (e.name === _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT) closed_streams.add(e.stream);
1267
+ if (e.name === _chunkVD4BLAY4cjs.TOMBSTONE_EVENT) closed_streams.add(e.stream);
1272
1268
  },
1273
- { names: [_chunk3CQWJ4UAcjs.TOMBSTONE_EVENT] }
1269
+ { names: [_chunkVD4BLAY4cjs.TOMBSTONE_EVENT] }
1274
1270
  );
1275
1271
  }
1276
1272
  let max_id;
@@ -1292,16 +1288,16 @@ async function scan(source, opts = {}, callback) {
1292
1288
  if (!is_valid(event))
1293
1289
  throw new Error(`Invalid event at index ${processed}`);
1294
1290
  if (on_progress) on_progress({ processed, id: event.id, max_id });
1295
- if (drop_snapshots && event.name === _chunk3CQWJ4UAcjs.SNAP_EVENT) {
1291
+ if (drop_snapshots && event.name === _chunkVD4BLAY4cjs.SNAP_EVENT) {
1296
1292
  dropped_snaps++;
1297
1293
  return;
1298
1294
  }
1299
- if (closed_streams.has(event.stream) && event.name !== _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT) {
1295
+ if (closed_streams.has(event.stream) && event.name !== _chunkVD4BLAY4cjs.TOMBSTONE_EVENT) {
1300
1296
  dropped_closed++;
1301
1297
  return;
1302
1298
  }
1303
1299
  let migrated = event;
1304
- const migration = _optionalChain([event_migrations, 'optionalAccess', _53 => _53[event.name]]);
1300
+ const migration = _optionalChain([event_migrations, 'optionalAccess', _51 => _51[event.name]]);
1305
1301
  if (migration) {
1306
1302
  const old_data = migration.from_schema.parse(event.data);
1307
1303
  const new_data = migration.migrate(old_data);
@@ -1323,7 +1319,7 @@ async function scan(source, opts = {}, callback) {
1323
1319
  return;
1324
1320
  }
1325
1321
  let remapped = migrated;
1326
- const caused_by = _optionalChain([migrated, 'access', _54 => _54.meta, 'access', _55 => _55.causation, 'access', _56 => _56.event, 'optionalAccess', _57 => _57.id]);
1322
+ const caused_by = _optionalChain([migrated, 'access', _52 => _52.meta, 'access', _53 => _53.causation, 'access', _54 => _54.event, 'optionalAccess', _55 => _55.id]);
1327
1323
  if (caused_by !== void 0) {
1328
1324
  const new_caused_by = id_map.get(caused_by);
1329
1325
  if (new_caused_by !== void 0 && new_caused_by !== caused_by) {
@@ -1364,18 +1360,18 @@ async function load(me, target, callback, patch_fn = bare_patch) {
1364
1360
  const { stream, actor, asOf } = target;
1365
1361
  const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
1366
1362
  const seeded = time_travel && asOf.limit === void 0 && !asOf.created_after;
1367
- const cached = time_travel ? void 0 : await _chunkS2BEPQ5Zcjs.cache.call(void 0, ).get(stream);
1363
+ const cached = time_travel ? void 0 : await _chunkEAFNHF5Scjs.cache.call(void 0, ).get(stream);
1368
1364
  const cache_hit = !!cached;
1369
- let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _58 => _58.state]), () => ( (me.init ? me.init() : {})));
1370
- let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _59 => _59.patches]), () => ( 0));
1371
- let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _60 => _60.snaps]), () => ( 0));
1365
+ let state2 = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _56 => _56.state]), () => ( (me.init ? me.init() : {})));
1366
+ let patches = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _57 => _57.patches]), () => ( 0));
1367
+ let snaps = _nullishCoalesce(_optionalChain([cached, 'optionalAccess', _58 => _58.snaps]), () => ( 0));
1372
1368
  let replayed = 0;
1373
1369
  let event;
1374
- await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query(
1370
+ await _chunkEAFNHF5Scjs.store.call(void 0, ).query(
1375
1371
  (raw) => {
1376
- if (seeded && raw.name === _chunk3CQWJ4UAcjs.SNAP_EVENT && replayed > 0) return;
1372
+ if (seeded && raw.name === _chunkVD4BLAY4cjs.SNAP_EVENT && replayed > 0) return;
1377
1373
  event = me.view(raw, actor);
1378
- if (event.name === _chunk3CQWJ4UAcjs.SNAP_EVENT) {
1374
+ if (event.name === _chunkVD4BLAY4cjs.SNAP_EVENT) {
1379
1375
  state2 = event.data;
1380
1376
  snaps++;
1381
1377
  patches = 0;
@@ -1384,12 +1380,12 @@ async function load(me, target, callback, patch_fn = bare_patch) {
1384
1380
  state2 = patch_fn(me, state2, me.patch[event.name](event, state2), event);
1385
1381
  patches++;
1386
1382
  replayed++;
1387
- } else if (event.name !== _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT) {
1388
- _chunkS2BEPQ5Zcjs.log.call(void 0, ).warn(
1383
+ } else if (event.name !== _chunkVD4BLAY4cjs.TOMBSTONE_EVENT) {
1384
+ _chunkEAFNHF5Scjs.log.call(void 0, ).warn(
1389
1385
  `Skipping unknown event "${String(event.name)}" on stream "${stream}" (id=${event.id}) \u2014 no reducer in state "${me.name}"`
1390
1386
  );
1391
1387
  }
1392
- _optionalChain([callback, 'optionalCall', _61 => _61({
1388
+ _optionalChain([callback, 'optionalCall', _59 => _59({
1393
1389
  event,
1394
1390
  state: state2,
1395
1391
  version: event.version,
@@ -1413,7 +1409,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
1413
1409
  ) : time_travel ? asOf : { with_snaps: true }
1414
1410
  }
1415
1411
  );
1416
- const head_is_tombstone = _optionalChain([event, 'optionalAccess', _62 => _62.name]) === _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT;
1412
+ const head_is_tombstone = _optionalChain([event, 'optionalAccess', _60 => _60.name]) === _chunkVD4BLAY4cjs.TOMBSTONE_EVENT;
1417
1413
  if (replayed > 0 && !time_travel && event && !me.pii_aware && !head_is_tombstone) {
1418
1414
  await cache_put(stream, {
1419
1415
  stream,
@@ -1427,9 +1423,9 @@ async function load(me, target, callback, patch_fn = bare_patch) {
1427
1423
  return {
1428
1424
  event,
1429
1425
  state: state2,
1430
- version: _nullishCoalesce(_nullishCoalesce(_optionalChain([event, 'optionalAccess', _63 => _63.version]), () => ( _optionalChain([cached, 'optionalAccess', _64 => _64.version]))), () => ( -1)),
1426
+ version: _nullishCoalesce(_nullishCoalesce(_optionalChain([event, 'optionalAccess', _61 => _61.version]), () => ( _optionalChain([cached, 'optionalAccess', _62 => _62.version]))), () => ( -1)),
1431
1427
  // Captured with `state`, so consumers never race a separate cache lookup.
1432
- id: _nullishCoalesce(_nullishCoalesce(_optionalChain([event, 'optionalAccess', _65 => _65.id]), () => ( _optionalChain([cached, 'optionalAccess', _66 => _66.event_id]))), () => ( -1)),
1428
+ id: _nullishCoalesce(_nullishCoalesce(_optionalChain([event, 'optionalAccess', _63 => _63.id]), () => ( _optionalChain([cached, 'optionalAccess', _64 => _64.event_id]))), () => ( -1)),
1433
1429
  patches,
1434
1430
  snaps,
1435
1431
  cache_hit,
@@ -1456,8 +1452,8 @@ async function load_others(loads, payload, own, actor, patch_fn, refuse) {
1456
1452
  void 0,
1457
1453
  patch_fn
1458
1454
  );
1459
- if (_optionalChain([snapshot, 'access', _67 => _67.event, 'optionalAccess', _68 => _68.name]) === _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT)
1460
- throw new (0, _chunk3CQWJ4UAcjs.StreamClosedError)(stream);
1455
+ if (_optionalChain([snapshot, 'access', _65 => _65.event, 'optionalAccess', _66 => _66.name]) === _chunkVD4BLAY4cjs.TOMBSTONE_EVENT)
1456
+ throw new (0, _chunkVD4BLAY4cjs.StreamClosedError)(stream);
1461
1457
  return {
1462
1458
  state: l.state,
1463
1459
  stream,
@@ -1471,12 +1467,12 @@ async function load_others(loads, payload, own, actor, patch_fn, refuse) {
1471
1467
  async function action(me, action2, target, payload, options, patch_fn = bare_patch) {
1472
1468
  const { stream, expectedVersion, actor } = target;
1473
1469
  if (!stream) throw new Error("Missing target stream");
1474
- const reactingTo = _optionalChain([options, 'optionalAccess', _69 => _69.reactingTo]);
1475
- const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _70 => _70.correlator]), () => ( default_correlator));
1476
- const validated = _chunkS2BEPQ5Zcjs.validate.call(void 0, action2, payload, me.actions[action2]);
1477
- const opts = _optionalChain([me, 'access', _71 => _71.options, 'optionalAccess', _72 => _72[action2]]);
1478
- const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _73 => _73.maxRetries]), () => ( 0));
1479
- const loads = _nullishCoalesce(_optionalChain([me, 'access', _74 => _74.loads, 'optionalAccess', _75 => _75[action2]]), () => ( []));
1470
+ const reactingTo = _optionalChain([options, 'optionalAccess', _67 => _67.reactingTo]);
1471
+ const correlator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _68 => _68.correlator]), () => ( default_correlator));
1472
+ const validated = _chunkEAFNHF5Scjs.validate.call(void 0, action2, payload, me.actions[action2]);
1473
+ const opts = _optionalChain([me, 'access', _69 => _69.options, 'optionalAccess', _70 => _70[action2]]);
1474
+ const max_retries = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _71 => _71.maxRetries]), () => ( 0));
1475
+ const loads = _nullishCoalesce(_optionalChain([me, 'access', _72 => _72.loads, 'optionalAccess', _73 => _73[action2]]), () => ( []));
1480
1476
  for (let attempt = 0; ; attempt++) {
1481
1477
  try {
1482
1478
  const snapshot = await load(
@@ -1485,8 +1481,8 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1485
1481
  void 0,
1486
1482
  patch_fn
1487
1483
  );
1488
- if (_optionalChain([snapshot, 'access', _76 => _76.event, 'optionalAccess', _77 => _77.name]) === _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT)
1489
- throw new (0, _chunk3CQWJ4UAcjs.StreamClosedError)(stream);
1484
+ if (_optionalChain([snapshot, 'access', _74 => _74.event, 'optionalAccess', _75 => _75.name]) === _chunkVD4BLAY4cjs.TOMBSTONE_EVENT)
1485
+ throw new (0, _chunkVD4BLAY4cjs.StreamClosedError)(stream);
1490
1486
  const own = {
1491
1487
  state: me,
1492
1488
  stream,
@@ -1500,7 +1496,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1500
1496
  { stream, state: snapshot.state },
1501
1497
  target.actor,
1502
1498
  patch_fn,
1503
- (description) => new (0, _chunk3CQWJ4UAcjs.PreconditionError)(
1499
+ (description) => new (0, _chunkVD4BLAY4cjs.PreconditionError)(
1504
1500
  action2,
1505
1501
  validated,
1506
1502
  target,
@@ -1509,11 +1505,11 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1509
1505
  )
1510
1506
  ) : [];
1511
1507
  const loaded = Object.fromEntries(
1512
- others.map((p, i) => [loads[i].name, _optionalChain([p, 'optionalAccess', _78 => _78.snapshot, 'access', _79 => _79.state])])
1508
+ others.map((p, i) => [loads[i].name, _optionalChain([p, 'optionalAccess', _76 => _76.snapshot, 'access', _77 => _77.state])])
1513
1509
  );
1514
- for (const { holds, description } of _nullishCoalesce(_optionalChain([me, 'access', _80 => _80.requires, 'optionalAccess', _81 => _81[action2]]), () => ( [])))
1510
+ for (const { holds, description } of _nullishCoalesce(_optionalChain([me, 'access', _78 => _78.requires, 'optionalAccess', _79 => _79[action2]]), () => ( [])))
1515
1511
  if (!holds(validated, snapshot.state, actor, loaded))
1516
- throw new (0, _chunk3CQWJ4UAcjs.PreconditionError)(
1512
+ throw new (0, _chunkVD4BLAY4cjs.PreconditionError)(
1517
1513
  action2,
1518
1514
  validated,
1519
1515
  target,
@@ -1535,7 +1531,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1535
1531
  );
1536
1532
  to.events.push({
1537
1533
  name: event,
1538
- data: _chunkS2BEPQ5Zcjs.validate.call(void 0, event, data, to.state.events[event])
1534
+ data: _chunkEAFNHF5Scjs.validate.call(void 0, event, data, to.state.events[event])
1539
1535
  });
1540
1536
  }
1541
1537
  if (!own.events.length)
@@ -1543,10 +1539,10 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1543
1539
  `Action "${action2}" appends only to the streams it loads; it must append an event to its own stream too`
1544
1540
  );
1545
1541
  const appends = [own, ...others].filter(
1546
- (p) => !!_optionalChain([p, 'optionalAccess', _82 => _82.events, 'access', _83 => _83.length])
1542
+ (p) => !!_optionalChain([p, 'optionalAccess', _80 => _80.events, 'access', _81 => _81.length])
1547
1543
  );
1548
1544
  const meta = {
1549
- correlation: _optionalChain([reactingTo, 'optionalAccess', _84 => _84.meta, 'access', _85 => _85.correlation]) || correlator({
1545
+ correlation: _optionalChain([reactingTo, 'optionalAccess', _82 => _82.meta, 'access', _83 => _83.correlation]) || correlator({
1550
1546
  action: action2,
1551
1547
  state: me.name,
1552
1548
  stream,
@@ -1592,7 +1588,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1592
1588
  });
1593
1589
  let committed;
1594
1590
  try {
1595
- committed = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).commit(
1591
+ committed = await _chunkEAFNHF5Scjs.store.call(void 0, ).commit(
1596
1592
  appends.map((p) => ({
1597
1593
  stream: p.stream,
1598
1594
  msgs: p.events.map((e) => p.state.message(e)),
@@ -1601,7 +1597,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1601
1597
  meta
1602
1598
  );
1603
1599
  } catch (error) {
1604
- if (error instanceof _chunk3CQWJ4UAcjs.ConcurrencyError) void cache_drop(error.stream);
1600
+ if (error instanceof _chunkVD4BLAY4cjs.ConcurrencyError) void cache_drop(error.stream);
1605
1601
  throw error;
1606
1602
  }
1607
1603
  let row = 0;
@@ -1624,13 +1620,13 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1624
1620
  };
1625
1621
  });
1626
1622
  const last = appended.at(-1);
1627
- const snap_event = _optionalChain([owner, 'access', _86 => _86.snap, 'optionalCall', _87 => _87(last)]) ? await snap(last) : void 0;
1623
+ const snap_event = _optionalChain([owner, 'access', _84 => _84.snap, 'optionalCall', _85 => _85(last)]) ? await snap(last) : void 0;
1628
1624
  if (!owner.pii_aware)
1629
1625
  void cache_put(append.stream, {
1630
1626
  stream: append.stream,
1631
1627
  state: last.state,
1632
- version: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess', _88 => _88.version]), () => ( last.event.version)),
1633
- event_id: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess', _89 => _89.id]), () => ( last.event.id)),
1628
+ version: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess', _86 => _86.version]), () => ( last.event.version)),
1629
+ event_id: _nullishCoalesce(_optionalChain([snap_event, 'optionalAccess', _87 => _87.id]), () => ( last.event.id)),
1634
1630
  patches: snap_event ? 0 : last.patches,
1635
1631
  snaps: snap_event ? last.snaps + 1 : last.snaps
1636
1632
  });
@@ -1643,19 +1639,19 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1643
1639
  }
1644
1640
  return snapshots;
1645
1641
  } catch (error) {
1646
- if (!(error instanceof _chunk3CQWJ4UAcjs.ConcurrencyError)) throw error;
1642
+ if (!(error instanceof _chunkVD4BLAY4cjs.ConcurrencyError)) throw error;
1647
1643
  if (expectedVersion !== void 0 && error.stream === stream) throw error;
1648
1644
  if (attempt >= max_retries) throw error;
1649
- if (_optionalChain([opts, 'optionalAccess', _90 => _90.backoff])) {
1645
+ if (_optionalChain([opts, 'optionalAccess', _88 => _88.backoff])) {
1650
1646
  const delay_ms = compute_backoff_delay(attempt, opts.backoff);
1651
- if (delay_ms > 0) await _chunkS2BEPQ5Zcjs.sleep.call(void 0, delay_ms);
1647
+ if (delay_ms > 0) await _chunkEAFNHF5Scjs.sleep.call(void 0, delay_ms);
1652
1648
  }
1653
1649
  }
1654
1650
  }
1655
1651
  }
1656
1652
 
1657
1653
  // src/internal/tracing.ts
1658
- var PRETTY = _chunkS2BEPQ5Zcjs.config.call(void 0, ).env !== "production";
1654
+ var PRETTY = _chunkEAFNHF5Scjs.config.call(void 0, ).env !== "production";
1659
1655
  var C_BLUE = "\x1B[38;5;39m";
1660
1656
  var C_ORANGE = "\x1B[38;5;208m";
1661
1657
  var C_GREEN = "\x1B[38;5;42m";
@@ -1701,9 +1697,9 @@ var as_of_marker = (asOf) => {
1701
1697
  return parts.length ? ` (as-of ${parts.join(" ")})` : " (as-of)";
1702
1698
  };
1703
1699
  var traced = (inner, exit, entry) => (async (...args) => {
1704
- _optionalChain([entry, 'optionalCall', _91 => _91(...args)]);
1700
+ _optionalChain([entry, 'optionalCall', _89 => _89(...args)]);
1705
1701
  const result = await inner(...args);
1706
- _optionalChain([exit, 'optionalCall', _92 => _92(result, ...args)]);
1702
+ _optionalChain([exit, 'optionalCall', _90 => _90(result, ...args)]);
1707
1703
  return result;
1708
1704
  });
1709
1705
  function build_es(logger, correlator = default_correlator, patch_fn = bare_patch) {
@@ -1712,7 +1708,7 @@ function build_es(logger, correlator = default_correlator, patch_fn = bare_patch
1712
1708
  action_name,
1713
1709
  target,
1714
1710
  payload,
1715
- { ...options, correlator: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _93 => _93.correlator]), () => ( correlator)) },
1711
+ { ...options, correlator: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _91 => _91.correlator]), () => ( correlator)) },
1716
1712
  patch_fn
1717
1713
  );
1718
1714
  const bound_load = (me, target, callback) => load(me, target, callback, patch_fn);
@@ -1786,7 +1782,7 @@ function build_drain(logger) {
1786
1782
  subscribe: logger.level !== "trace" ? subscribe : traced(subscribe, (result, streams) => {
1787
1783
  if (!result.subscribed) return;
1788
1784
  const lanes = new Set(streams.map((s) => _nullishCoalesce(s.lane, () => ( "default"))));
1789
- const uniform_lane = lanes.size === 1 ? _optionalChain([streams, 'access', _94 => _94[0], 'optionalAccess', _95 => _95.lane]) : void 0;
1785
+ const uniform_lane = lanes.size === 1 ? _optionalChain([streams, 'access', _92 => _92[0], 'optionalAccess', _93 => _93.lane]) : void 0;
1790
1786
  const data = streams.map(
1791
1787
  ({ stream, lane }) => uniform_lane || !lane || lane === "default" ? hue(C_STREAM, stream) : `${hue(C_STREAM, stream)}${dim(`[${lane}]`)}`
1792
1788
  ).join(" ");
@@ -1798,7 +1794,7 @@ function build_drain(logger) {
1798
1794
  }
1799
1795
  function trace_cycle(logger, leased, fetched, handled, acked, blocked) {
1800
1796
  if (logger.level !== "trace" || !leased.length) return;
1801
- const lane = _optionalChain([leased, 'access', _96 => _96[0], 'optionalAccess', _97 => _97.lane]);
1797
+ const lane = _optionalChain([leased, 'access', _94 => _94[0], 'optionalAccess', _95 => _95.lane]);
1802
1798
  const fetch_by_stream = new Map(fetched.map((f) => [f.stream, f]));
1803
1799
  const acked_by_stream = new Map(acked.map((a) => [a.stream, a.at]));
1804
1800
  const blocked_by_stream = new Map(blocked.map((b) => [b.stream, b.error]));
@@ -1807,8 +1803,8 @@ function trace_cycle(logger, leased, fetched, handled, acked, blocked) {
1807
1803
  );
1808
1804
  const detail = leased.map(({ stream, at, retry }) => {
1809
1805
  const f = fetch_by_stream.get(stream);
1810
- const key = _optionalChain([f, 'optionalAccess', _98 => _98.source]) ? `${hue(C_STREAM, stream)}${dim(`<-${f.source}`)}` : hue(C_STREAM, stream);
1811
- const events = _optionalChain([f, 'optionalAccess', _99 => _99.events, 'access', _100 => _100.length]) ? ` ${dim(
1806
+ const key = _optionalChain([f, 'optionalAccess', _96 => _96.source]) ? `${hue(C_STREAM, stream)}${dim(`<-${f.source}`)}` : hue(C_STREAM, stream);
1807
+ const events = _optionalChain([f, 'optionalAccess', _97 => _97.events, 'access', _98 => _98.length]) ? ` ${dim(
1812
1808
  `[${f.events.map(({ id, name }) => `#${id} ${String(name)}`).join(", ")}]`
1813
1809
  )}` : "";
1814
1810
  const acked_at = acked_by_stream.get(stream);
@@ -1836,10 +1832,10 @@ function trace_cycle(logger, leased, fetched, handled, acked, blocked) {
1836
1832
 
1837
1833
  // src/internal/drain-cycle.ts
1838
1834
  function budget_exhausted(lease, options, store_failing) {
1839
- if (store_failing || !_optionalChain([options, 'optionalAccess', _101 => _101.blockOnError]) || lease.retry <= options.maxRetries)
1835
+ if (store_failing || !_optionalChain([options, 'optionalAccess', _99 => _99.blockOnError]) || lease.retry <= options.maxRetries)
1840
1836
  return void 0;
1841
1837
  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.`;
1842
- _chunkS2BEPQ5Zcjs.log.call(void 0, ).error(error);
1838
+ _chunkEAFNHF5Scjs.log.call(void 0, ).error(error);
1843
1839
  return { lease, handled: 0, acked_at: lease.at, error, block: true };
1844
1840
  }
1845
1841
  function fetch_failure_policy(registry) {
@@ -1855,13 +1851,13 @@ function fetch_failure_policy(registry) {
1855
1851
  function finalize(lease, handled, at, error, options, logger, failed_at) {
1856
1852
  if (!error) return { lease, handled, acked_at: at };
1857
1853
  logger.error(error);
1858
- const non_retryable = error instanceof _chunk3CQWJ4UAcjs.NonRetryableError;
1854
+ const non_retryable = error instanceof _chunkVD4BLAY4cjs.NonRetryableError;
1859
1855
  const block2 = options.blockOnError && (non_retryable || lease.retry >= options.maxRetries);
1860
1856
  if (block2)
1861
1857
  logger.error(
1862
1858
  non_retryable ? `Blocking ${lease.stream} on non-retryable error.` : `Blocking ${lease.stream} after ${lease.retry} retries.`
1863
1859
  );
1864
- const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkS2BEPQ5Zcjs.DEFAULT_BACKOFF)));
1860
+ const next_attempt_at = block2 ? void 0 : Date.now() + compute_backoff_delay(lease.retry, _nullishCoalesce(options.backoff, () => ( _chunkEAFNHF5Scjs.DEFAULT_BACKOFF)));
1865
1861
  return {
1866
1862
  lease,
1867
1863
  handled,
@@ -1900,7 +1896,7 @@ async function run_drain_cycle(deps, cycle) {
1900
1896
  const fetched = await ops.fetch(leased, eventLimit);
1901
1897
  const fetch_map = /* @__PURE__ */ new Map();
1902
1898
  const fetch_window_at = fetched.reduce(
1903
- (max, { at, events }) => Math.max(max, _optionalChain([events, 'access', _102 => _102.at, 'call', _103 => _103(-1), 'optionalAccess', _104 => _104.id]) || at),
1899
+ (max, { at, events }) => Math.max(max, _optionalChain([events, 'access', _100 => _100.at, 'call', _101 => _101(-1), 'optionalAccess', _102 => _102.id]) || at),
1904
1900
  0
1905
1901
  );
1906
1902
  for (const f of fetched) {
@@ -1964,11 +1960,11 @@ async function run_drain_cycle(deps, cycle) {
1964
1960
  deps.logger
1965
1961
  )
1966
1962
  );
1967
- const at = _optionalChain([entry, 'access', _105 => _105.fetch, 'access', _106 => _106.events, 'access', _107 => _107.at, 'call', _108 => _108(-1), 'optionalAccess', _109 => _109.id]) || fetch_window_at;
1963
+ const at = _optionalChain([entry, 'access', _103 => _103.fetch, 'access', _104 => _104.events, 'access', _105 => _105.at, 'call', _106 => _106(-1), 'optionalAccess', _107 => _107.id]) || fetch_window_at;
1968
1964
  const { payloads } = entry;
1969
1965
  const exhausted = budget_exhausted(
1970
1966
  lease,
1971
- _optionalChain([payloads, 'access', _110 => _110[0], 'optionalAccess', _111 => _111.options]),
1967
+ _optionalChain([payloads, 'access', _108 => _108[0], 'optionalAccess', _109 => _109.options]),
1972
1968
  store_failing
1973
1969
  );
1974
1970
  if (exhausted) return Promise.resolve(exhausted);
@@ -1989,7 +1985,7 @@ async function run_drain_cycle(deps, cycle) {
1989
1985
  const acked = submitted.length ? await ops.ack(submitted) : [];
1990
1986
  const expected = submitted.filter((l) => l.due === void 0).length;
1991
1987
  if (acked.length < expected)
1992
- _chunkS2BEPQ5Zcjs.log.call(void 0, ).warn(
1988
+ _chunkEAFNHF5Scjs.log.call(void 0, ).warn(
1993
1989
  `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.`
1994
1990
  );
1995
1991
  const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
@@ -2053,7 +2049,7 @@ var DrainController = (_class3 = class {
2053
2049
  }
2054
2050
  /** This lane's configured lease, or `undefined`; the shutdown grace basis. */
2055
2051
  get lease_millis() {
2056
- return _optionalChain([this, 'access', _112 => _112._deps, 'access', _113 => _113.defaults, 'optionalAccess', _114 => _114.leaseMillis]);
2052
+ return _optionalChain([this, 'access', _110 => _110._deps, 'access', _111 => _111.defaults, 'optionalAccess', _112 => _112.leaseMillis]);
2057
2053
  }
2058
2054
  get lane() {
2059
2055
  return this._deps.lane;
@@ -2085,9 +2081,9 @@ var DrainController = (_class3 = class {
2085
2081
  if (!this.armed || this._stopped || this._inflight)
2086
2082
  return EMPTY_DRAIN;
2087
2083
  const d = _nullishCoalesce(this._deps.defaults, () => ( {}));
2088
- const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkS2BEPQ5Zcjs.DEFAULT_STREAM_LIMIT));
2089
- const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkS2BEPQ5Zcjs.DEFAULT_EVENT_LIMIT));
2090
- const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkS2BEPQ5Zcjs.DEFAULT_LEASE_MILLIS));
2084
+ const streamLimit = _nullishCoalesce(_nullishCoalesce(d.streamLimit, () => ( options.streamLimit)), () => ( _chunkEAFNHF5Scjs.DEFAULT_STREAM_LIMIT));
2085
+ const eventLimit = _nullishCoalesce(options.eventLimit, () => ( _chunkEAFNHF5Scjs.DEFAULT_EVENT_LIMIT));
2086
+ const leaseMillis = _nullishCoalesce(_nullishCoalesce(d.leaseMillis, () => ( options.leaseMillis)), () => ( _chunkEAFNHF5Scjs.DEFAULT_LEASE_MILLIS));
2091
2087
  if (this._deps.breaker.state(Date.now()) === "open")
2092
2088
  return EMPTY_DRAIN;
2093
2089
  const pass = this._pass(streamLimit, eventLimit, leaseMillis).finally(
@@ -2179,11 +2175,11 @@ var CloseSignal = class extends Error {
2179
2175
  constructor(opts) {
2180
2176
  super("reaction requested close");
2181
2177
  this.name = "CloseSignal";
2182
- this.stream = _optionalChain([opts, 'optionalAccess', _115 => _115.stream]);
2183
- this.archive = _optionalChain([opts, 'optionalAccess', _116 => _116.archive]);
2184
- this.at = _optionalChain([opts, 'optionalAccess', _117 => _117.at]);
2185
- this.before = _optionalChain([opts, 'optionalAccess', _118 => _118.before]);
2186
- this.defer = _optionalChain([opts, 'optionalAccess', _119 => _119.defer]);
2178
+ this.stream = _optionalChain([opts, 'optionalAccess', _113 => _113.stream]);
2179
+ this.archive = _optionalChain([opts, 'optionalAccess', _114 => _114.archive]);
2180
+ this.at = _optionalChain([opts, 'optionalAccess', _115 => _115.at]);
2181
+ this.before = _optionalChain([opts, 'optionalAccess', _116 => _116.before]);
2182
+ this.defer = _optionalChain([opts, 'optionalAccess', _117 => _117.defer]);
2187
2183
  }
2188
2184
  };
2189
2185
  function build_handle(deps) {
@@ -2213,7 +2209,7 @@ function build_handle(deps) {
2213
2209
  handled++;
2214
2210
  }
2215
2211
  } catch (error) {
2216
- if (error instanceof _chunk3CQWJ4UAcjs.DeferSignal) {
2212
+ if (error instanceof _chunkVD4BLAY4cjs.DeferSignal) {
2217
2213
  let defer;
2218
2214
  try {
2219
2215
  defer = resolve_defer_at(error.when, event);
@@ -2237,7 +2233,7 @@ function build_handle(deps) {
2237
2233
  // Advance to the live head the handler evaluated against (when
2238
2234
  // provided) so the close-cycle guard sees this reaction caught up.
2239
2235
  acked_at: _nullishCoalesce(error.at, () => ( event.id)),
2240
- defer: _optionalChain([error, 'access', _120 => _120.defer, 'optionalAccess', _121 => _121.getTime, 'call', _122 => _122()]),
2236
+ defer: _optionalChain([error, 'access', _118 => _118.defer, 'optionalAccess', _119 => _119.getTime, 'call', _120 => _120()]),
2241
2237
  // Close the signalled stream (the autoclose reaction's aggregate,
2242
2238
  // which differs from its synthetic lease stream); a self-closing
2243
2239
  // user reaction omits it and closes its own lease stream. A
@@ -2310,22 +2306,22 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
2310
2306
  // An anchored stream name would read as a pattern, and a store may refuse
2311
2307
  // it at subscribe, stopping every reaction. Such a stream has no
2312
2308
  // autoclose: `app.close` still closes it.
2313
- resolver: (e) => _chunkS2BEPQ5Zcjs.is_literal_source.call(void 0, e.stream) ? {
2309
+ resolver: (e) => _chunkEAFNHF5Scjs.is_literal_source.call(void 0, e.stream) ? {
2314
2310
  target: `${AUTOCLOSE_TARGET_PREFIX}${e.stream}`,
2315
2311
  source: e.stream
2316
2312
  } : void 0,
2317
2313
  // Never block on autoclose: a transient query/store error should retry,
2318
2314
  // not quarantine the synthetic stream.
2319
- options: { blockOnError: false, maxRetries: _chunkS2BEPQ5Zcjs.DEFAULT_MAX_RETRIES },
2315
+ options: { blockOnError: false, maxRetries: _chunkEAFNHF5Scjs.DEFAULT_MAX_RETRIES },
2320
2316
  handler: async (event) => {
2321
2317
  const aggregate = event.stream;
2322
2318
  const window = read_window();
2323
2319
  if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
2324
- throw new (0, _chunk3CQWJ4UAcjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
2325
- const stats = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query_stats([aggregate], {
2320
+ throw new (0, _chunkVD4BLAY4cjs.DeferSignal)({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
2321
+ const stats = await _chunkEAFNHF5Scjs.store.call(void 0, ).query_stats([aggregate], {
2326
2322
  count: true,
2327
2323
  tail: keep_days !== void 0 ? true : void 0,
2328
- exclude: [_chunk3CQWJ4UAcjs.TOMBSTONE_EVENT, _chunk3CQWJ4UAcjs.SNAP_EVENT]
2324
+ exclude: [_chunkVD4BLAY4cjs.TOMBSTONE_EVENT, _chunkVD4BLAY4cjs.SNAP_EVENT]
2329
2325
  });
2330
2326
  const entry = stats.get(aggregate);
2331
2327
  if (!entry) return;
@@ -2361,12 +2357,12 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
2361
2357
  dues.push(days_after(entry.tail.created, keep_days));
2362
2358
  const future = dues.map((d) => d.getTime()).filter((t) => t > Date.now());
2363
2359
  if (future.length)
2364
- throw new (0, _chunk3CQWJ4UAcjs.DeferSignal)({ at: new Date(Math.min(...future)) });
2360
+ throw new (0, _chunkVD4BLAY4cjs.DeferSignal)({ at: new Date(Math.min(...future)) });
2365
2361
  }
2366
2362
  };
2367
2363
  const key = `__autoclose_${st.name}`;
2368
2364
  for (const event_name of Object.keys(st.events)) {
2369
- _optionalChain([registry, 'access', _123 => _123.events, 'access', _124 => _124[event_name], 'optionalAccess', _125 => _125.reactions, 'access', _126 => _126.set, 'call', _127 => _127(
2365
+ _optionalChain([registry, 'access', _121 => _121.events, 'access', _122 => _122[event_name], 'optionalAccess', _123 => _123.reactions, 'access', _124 => _124.set, 'call', _125 => _125(
2370
2366
  key,
2371
2367
  reaction
2372
2368
  )]);
@@ -2421,8 +2417,8 @@ async function run_close_cycle(targets, deps) {
2421
2417
  deps,
2422
2418
  () => run_full_closes(full, target_map, deps, skipped)
2423
2419
  );
2424
- const retired = [...truncated.entries()].filter(([, r]) => r.committed.name === _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT).map(([stream]) => stream);
2425
- if (retired.length) _optionalChain([deps, 'access', _128 => _128.forget_subscribed, 'optionalCall', _129 => _129(retired)]);
2420
+ const retired = [...truncated.entries()].filter(([, r]) => r.committed.name === _chunkVD4BLAY4cjs.TOMBSTONE_EVENT).map(([stream]) => stream);
2421
+ if (retired.length) _optionalChain([deps, 'access', _126 => _126.forget_subscribed, 'optionalCall', _127 => _127(retired)]);
2426
2422
  for (const [stream, entry] of windowed_result) truncated.set(stream, entry);
2427
2423
  return { truncated, skipped };
2428
2424
  }
@@ -2442,7 +2438,7 @@ async function run_full_closes(full, target_map, deps, skipped) {
2442
2438
  const info = stream_info.get(target.stream);
2443
2439
  if (!info) continue;
2444
2440
  const owner = deps.event_to_state.get(info.last_event_name);
2445
- if (_optionalChain([owner, 'optionalAccess', _130 => _130.pii_aware])) {
2441
+ if (_optionalChain([owner, 'optionalAccess', _128 => _128.pii_aware])) {
2446
2442
  deps.logger.error(
2447
2443
  `Refusing to close "${target.stream}" with restart: state "${owner.name}" carries sensitive fields, so a restart seed would persist redacted values while deleting the originals. Close it without restart to retire the stream, or leave it open.`
2448
2444
  );
@@ -2503,7 +2499,7 @@ async function run_windowed_closes(windowed, deps, skipped) {
2503
2499
  if (!await windowed_prune_pending(t.stream, t.before, max_id))
2504
2500
  return void 0;
2505
2501
  if (t.archive) await t.archive();
2506
- const result = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).truncate([
2502
+ const result = await _chunkEAFNHF5Scjs.store.call(void 0, ).truncate([
2507
2503
  { stream: t.stream, before: t.before, max_id }
2508
2504
  ]);
2509
2505
  return result.get(t.stream);
@@ -2516,10 +2512,10 @@ async function run_windowed_closes(windowed, deps, skipped) {
2516
2512
  async function windowed_prune_pending(stream, before, max_id) {
2517
2513
  let boundary_id;
2518
2514
  let min_id;
2519
- await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query(
2515
+ await _chunkEAFNHF5Scjs.store.call(void 0, ).query(
2520
2516
  (event) => {
2521
2517
  if (min_id === void 0 || event.id < min_id) min_id = event.id;
2522
- if (event.name === _chunk3CQWJ4UAcjs.SNAP_EVENT && event.created < before && (max_id === void 0 || event.id <= max_id) && (boundary_id === void 0 || event.id > boundary_id))
2518
+ if (event.name === _chunkVD4BLAY4cjs.SNAP_EVENT && event.created < before && (max_id === void 0 || event.id <= max_id) && (boundary_id === void 0 || event.id > boundary_id))
2523
2519
  boundary_id = event.id;
2524
2520
  },
2525
2521
  { stream, stream_exact: true, with_snaps: true, after: -1 }
@@ -2530,7 +2526,7 @@ async function probe_min_watermarks(streams, page_size, checkpoint) {
2530
2526
  const min_at = /* @__PURE__ */ new Map();
2531
2527
  const matches = source_matcher();
2532
2528
  await walk_streams(
2533
- _chunkS2BEPQ5Zcjs.store.call(void 0, ),
2529
+ _chunkEAFNHF5Scjs.store.call(void 0, ),
2534
2530
  (position) => {
2535
2531
  const pending = position.correlated_at === void 0 || position.at < position.correlated_at;
2536
2532
  const cap = pending ? position.at : Math.max(position.at, checkpoint);
@@ -2549,7 +2545,7 @@ function source_matcher() {
2549
2545
  const compiled = /* @__PURE__ */ new Map();
2550
2546
  return (source, target, stream) => {
2551
2547
  if (!source) return true;
2552
- if (_chunkS2BEPQ5Zcjs.is_literal_source.call(void 0, source, target)) return source === stream;
2548
+ if (_chunkEAFNHF5Scjs.is_literal_source.call(void 0, source, target)) return source === stream;
2553
2549
  let re = compiled.get(source);
2554
2550
  if (!re) {
2555
2551
  re = new RegExp(source);
@@ -2559,17 +2555,17 @@ function source_matcher() {
2559
2555
  };
2560
2556
  }
2561
2557
  async function scan_stream_heads(streams) {
2562
- const stats = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query_stats(streams, {
2563
- exclude: [_chunk3CQWJ4UAcjs.SNAP_EVENT]
2558
+ const stats = await _chunkEAFNHF5Scjs.store.call(void 0, ).query_stats(streams, {
2559
+ exclude: [_chunkVD4BLAY4cjs.SNAP_EVENT]
2564
2560
  });
2565
- const domain_heads = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query_stats(streams, {
2566
- exclude: [_chunk3CQWJ4UAcjs.SNAP_EVENT, _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT]
2561
+ const domain_heads = await _chunkEAFNHF5Scjs.store.call(void 0, ).query_stats(streams, {
2562
+ exclude: [_chunkVD4BLAY4cjs.SNAP_EVENT, _chunkVD4BLAY4cjs.TOMBSTONE_EVENT]
2567
2563
  });
2568
- const true_heads = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query_stats(streams, {});
2564
+ const true_heads = await _chunkEAFNHF5Scjs.store.call(void 0, ).query_stats(streams, {});
2569
2565
  const out = /* @__PURE__ */ new Map();
2570
2566
  for (const [stream, { head }] of domain_heads) {
2571
- const marker_head = _optionalChain([stats, 'access', _131 => _131.get, 'call', _132 => _132(stream), 'optionalAccess', _133 => _133.head]);
2572
- const interrupted = _optionalChain([marker_head, 'optionalAccess', _134 => _134.name]) === _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT;
2567
+ const marker_head = _optionalChain([stats, 'access', _129 => _129.get, 'call', _130 => _130(stream), 'optionalAccess', _131 => _131.head]);
2568
+ const interrupted = _optionalChain([marker_head, 'optionalAccess', _132 => _132.name]) === _chunkVD4BLAY4cjs.TOMBSTONE_EVENT;
2573
2569
  out.set(stream, {
2574
2570
  max_id: head.id,
2575
2571
  version: true_heads.get(stream).head.version,
@@ -2592,7 +2588,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
2592
2588
  const pending_set = /* @__PURE__ */ new Set();
2593
2589
  const matches = source_matcher();
2594
2590
  await walk_streams(
2595
- _chunkS2BEPQ5Zcjs.store.call(void 0, ),
2591
+ _chunkEAFNHF5Scjs.store.call(void 0, ),
2596
2592
  (position) => {
2597
2593
  const has_work = position.correlated_at !== void 0 && position.at < position.correlated_at;
2598
2594
  if (!has_work) return;
@@ -2637,7 +2633,7 @@ async function guard_with_tombstones(safe, stream_info, correlation, tombstone2,
2637
2633
  async function load_restart_seeds(guarded, target_map, stream_info, event_to_state, load2, logger) {
2638
2634
  const seed_states = /* @__PURE__ */ new Map();
2639
2635
  await Promise.all(
2640
- guarded.filter((s) => _optionalChain([target_map, 'access', _135 => _135.get, 'call', _136 => _136(s), 'optionalAccess', _137 => _137.restart])).map(async (stream) => {
2636
+ guarded.filter((s) => _optionalChain([target_map, 'access', _133 => _133.get, 'call', _134 => _134(s), 'optionalAccess', _135 => _135.restart])).map(async (stream) => {
2641
2637
  const last_event_name = stream_info.get(stream).last_event_name;
2642
2638
  const owner_state = event_to_state.get(last_event_name);
2643
2639
  if (!owner_state) {
@@ -2654,14 +2650,14 @@ async function load_restart_seeds(guarded, target_map, stream_info, event_to_sta
2654
2650
  }
2655
2651
  async function run_archive_callbacks(guarded, target_map) {
2656
2652
  for (const stream of guarded) {
2657
- const archive_fn = _optionalChain([target_map, 'access', _138 => _138.get, 'call', _139 => _139(stream), 'optionalAccess', _140 => _140.archive]);
2653
+ const archive_fn = _optionalChain([target_map, 'access', _136 => _136.get, 'call', _137 => _137(stream), 'optionalAccess', _138 => _138.archive]);
2658
2654
  if (archive_fn) await archive_fn();
2659
2655
  }
2660
2656
  }
2661
2657
  async function heads_still_guarded(guarded, guard_events, skipped) {
2662
- const heads = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query_stats(guarded, {});
2658
+ const heads = await _chunkEAFNHF5Scjs.store.call(void 0, ).query_stats(guarded, {});
2663
2659
  return guarded.filter((stream) => {
2664
- if (_optionalChain([heads, 'access', _141 => _141.get, 'call', _142 => _142(stream), 'optionalAccess', _143 => _143.head, 'access', _144 => _144.id]) === guard_events.get(stream).id)
2660
+ if (_optionalChain([heads, 'access', _139 => _139.get, 'call', _140 => _140(stream), 'optionalAccess', _141 => _141.head, 'access', _142 => _142.id]) === guard_events.get(stream).id)
2665
2661
  return true;
2666
2662
  skipped.push(stream);
2667
2663
  return false;
@@ -2677,18 +2673,18 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
2677
2673
  meta: {
2678
2674
  correlation,
2679
2675
  causation: {
2680
- event: { id: guard.id, name: _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT, stream: guard.stream }
2676
+ event: { id: guard.id, name: _chunkVD4BLAY4cjs.TOMBSTONE_EVENT, stream: guard.stream }
2681
2677
  }
2682
2678
  }
2683
2679
  };
2684
2680
  });
2685
- const truncated = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).truncate(trunc_targets);
2681
+ const truncated = await _chunkEAFNHF5Scjs.store.call(void 0, ).truncate(trunc_targets);
2686
2682
  await Promise.all(
2687
2683
  guarded.map(async (stream) => {
2688
2684
  const entry = truncated.get(stream);
2689
2685
  const state2 = seed_states.get(stream);
2690
2686
  if (state2 && entry) {
2691
- await _chunkS2BEPQ5Zcjs.cache.call(void 0, ).set(stream, {
2687
+ await _chunkEAFNHF5Scjs.cache.call(void 0, ).set(stream, {
2692
2688
  stream,
2693
2689
  state: state2,
2694
2690
  version: entry.committed.version,
@@ -2697,7 +2693,7 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
2697
2693
  snaps: 1
2698
2694
  });
2699
2695
  } else {
2700
- await _chunkS2BEPQ5Zcjs.cache.call(void 0, ).invalidate(stream);
2696
+ await _chunkEAFNHF5Scjs.cache.call(void 0, ).invalidate(stream);
2701
2697
  }
2702
2698
  })
2703
2699
  );
@@ -2749,7 +2745,7 @@ var CorrelateCycle = (_class5 = class {
2749
2745
  // never lets a resolution re-lane them.
2750
2746
 
2751
2747
  __init18() {this._static_subscriptions = /* @__PURE__ */ new Map()}
2752
- __init19() {this._patterns = new (0, _chunkS2BEPQ5Zcjs.LruMap)(PATTERN_CACHE_SIZE)}
2748
+ __init19() {this._patterns = new (0, _chunkEAFNHF5Scjs.LruMap)(PATTERN_CACHE_SIZE)}
2753
2749
 
2754
2750
 
2755
2751
 
@@ -2767,7 +2763,7 @@ var CorrelateCycle = (_class5 = class {
2767
2763
  on_init
2768
2764
  }) {;_class5.prototype.__init10.call(this);_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);_class5.prototype.__init14.call(this);_class5.prototype.__init15.call(this);_class5.prototype.__init16.call(this);_class5.prototype.__init17.call(this);_class5.prototype.__init18.call(this);_class5.prototype.__init19.call(this);_class5.prototype.__init20.call(this);
2769
2765
  this._key = shard ? `${registry_key(registry.events)}:${[...shard].sort().join(",")}` : registry_key(registry.events);
2770
- this._dynamic_subscriptions = new (0, _chunkS2BEPQ5Zcjs.LruMap)(max_subscribed_streams);
2766
+ this._dynamic_subscriptions = new (0, _chunkEAFNHF5Scjs.LruMap)(max_subscribed_streams);
2771
2767
  this._registry = registry;
2772
2768
  this._declared_lanes = declared_lanes;
2773
2769
  this._static_targets = static_targets;
@@ -2799,7 +2795,7 @@ var CorrelateCycle = (_class5 = class {
2799
2795
  lane
2800
2796
  });
2801
2797
  }
2802
- await _optionalChain([this, 'access', _145 => _145._on_init, 'optionalCall', _146 => _146()]);
2798
+ await _optionalChain([this, 'access', _143 => _143._on_init, 'optionalCall', _144 => _144()]);
2803
2799
  }
2804
2800
  /**
2805
2801
  * Replace the log with no pass in flight, then cold-start: a pass that
@@ -2825,7 +2821,7 @@ var CorrelateCycle = (_class5 = class {
2825
2821
  // Would the target's own `fetch` (filtered by `source`) return this event?
2826
2822
  _in_fetch_window(source, stream) {
2827
2823
  if (source === void 0 || source === stream) return true;
2828
- if (_chunkS2BEPQ5Zcjs.is_literal_source.call(void 0, source)) return false;
2824
+ if (_chunkEAFNHF5Scjs.is_literal_source.call(void 0, source)) return false;
2829
2825
  let pattern = this._patterns.get(source);
2830
2826
  if (!pattern) {
2831
2827
  pattern = new RegExp(source);
@@ -2868,7 +2864,7 @@ var CorrelateCycle = (_class5 = class {
2868
2864
  const correlated = /* @__PURE__ */ new Map();
2869
2865
  let last_id = after;
2870
2866
  let stopped = false;
2871
- const found = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query(
2867
+ const found = await _chunkEAFNHF5Scjs.store.call(void 0, ).query(
2872
2868
  (event) => {
2873
2869
  if (stopped) return;
2874
2870
  const register = this._registry.events[event.name];
@@ -2913,9 +2909,9 @@ var CorrelateCycle = (_class5 = class {
2913
2909
  correlated_at: void 0
2914
2910
  };
2915
2911
  const seen_in_scan = correlated.has(resolved.target);
2916
- const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _147 => _147.lane])), () => ( _chunk3CQWJ4UAcjs.DEFAULT_LANE));
2917
- const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess', _148 => _148.priority]);
2918
- const resolved_lane = _nullishCoalesce(lane, () => ( _chunk3CQWJ4UAcjs.DEFAULT_LANE));
2912
+ const held_lane = _nullishCoalesce((seen_in_scan ? entry.lane : _optionalChain([recorded, 'optionalAccess', _145 => _145.lane])), () => ( _chunkVD4BLAY4cjs.DEFAULT_LANE));
2913
+ const held_priority = seen_in_scan ? entry.priority : _optionalChain([recorded, 'optionalAccess', _146 => _146.priority]);
2914
+ const resolved_lane = _nullishCoalesce(lane, () => ( _chunkVD4BLAY4cjs.DEFAULT_LANE));
2919
2915
  if (held_priority === priority && held_lane !== resolved_lane)
2920
2916
  report_lane_conflict(
2921
2917
  this._reported,
@@ -2969,7 +2965,7 @@ var CorrelateCycle = (_class5 = class {
2969
2965
  ).length;
2970
2966
  this._checkpoint = last_id;
2971
2967
  for (const { stream, priority, lane } of streams) {
2972
- if (_optionalChain([correlated, 'access', _149 => _149.get, 'call', _150 => _150(stream), 'optionalAccess', _151 => _151.upgraded]))
2968
+ if (_optionalChain([correlated, 'access', _147 => _147.get, 'call', _148 => _148(stream), 'optionalAccess', _149 => _149.upgraded]))
2973
2969
  this._dynamic_subscriptions.set(stream, {
2974
2970
  priority,
2975
2971
  lane
@@ -2989,7 +2985,7 @@ var CorrelateCycle = (_class5 = class {
2989
2985
  await Promise.all(
2990
2986
  missed.map(async ([stream, entry]) => {
2991
2987
  let row;
2992
- await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query_streams(
2988
+ await _chunkEAFNHF5Scjs.store.call(void 0, ).query_streams(
2993
2989
  (position) => {
2994
2990
  row = position;
2995
2991
  },
@@ -3001,8 +2997,8 @@ var CorrelateCycle = (_class5 = class {
3001
2997
  lane: row.lane
3002
2998
  });
3003
2999
  if (entry.priority > row.priority) return;
3004
- const held_lane = _nullishCoalesce(row.lane, () => ( _chunk3CQWJ4UAcjs.DEFAULT_LANE));
3005
- const resolved_lane = _nullishCoalesce(entry.lane, () => ( _chunk3CQWJ4UAcjs.DEFAULT_LANE));
3000
+ const held_lane = _nullishCoalesce(row.lane, () => ( _chunkVD4BLAY4cjs.DEFAULT_LANE));
3001
+ const resolved_lane = _nullishCoalesce(entry.lane, () => ( _chunkVD4BLAY4cjs.DEFAULT_LANE));
3006
3002
  if (entry.priority === row.priority && held_lane !== resolved_lane)
3007
3003
  report_lane_conflict(
3008
3004
  this._reported,
@@ -3028,7 +3024,7 @@ var CorrelateCycle = (_class5 = class {
3028
3024
  millis: 0
3029
3025
  });
3030
3026
  } catch (error) {
3031
- _chunkS2BEPQ5Zcjs.log.call(void 0, ).warn(
3027
+ _chunkEAFNHF5Scjs.log.call(void 0, ).warn(
3032
3028
  `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(_nullishCoalesce(error.cause, () => ( error)))}`
3033
3029
  );
3034
3030
  }
@@ -3052,7 +3048,7 @@ function pii_gate(event, fields, predicate, actor) {
3052
3048
  const { pii, ...rest } = event;
3053
3049
  if (pii == null) {
3054
3050
  const shredded = { ...data };
3055
- for (const f of fields) shredded[f] = _chunk3CQWJ4UAcjs.SHREDDED;
3051
+ for (const f of fields) shredded[f] = _chunkVD4BLAY4cjs.SHREDDED;
3056
3052
  return { ...rest, data: shredded };
3057
3053
  }
3058
3054
  const allowed = !!actor && !!predicate && predicate(event, actor);
@@ -3063,7 +3059,7 @@ function pii_gate(event, fields, predicate, actor) {
3063
3059
  };
3064
3060
  }
3065
3061
  const redacted = { ...data };
3066
- for (const f of fields) redacted[f] = _chunk3CQWJ4UAcjs.REDACTED;
3062
+ for (const f of fields) redacted[f] = _chunkVD4BLAY4cjs.REDACTED;
3067
3063
  return { ...rest, data: redacted };
3068
3064
  }
3069
3065
  var IDENTITY_GATE = (event) => event;
@@ -3208,7 +3204,7 @@ var SettleLoop = (_class6 = class {
3208
3204
  this._pending = true;
3209
3205
  return;
3210
3206
  }
3211
- const delay = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _152 => _152.debounceMs]), () => ( this._default_debounce_ms));
3207
+ const delay = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _150 => _150.debounceMs]), () => ( this._default_debounce_ms));
3212
3208
  const due = Date.now() + delay;
3213
3209
  if (this._timer) {
3214
3210
  if (due >= this._due) return;
@@ -3365,7 +3361,7 @@ var Act = (_class7 = class {
3365
3361
  // Lanes to arm per event; `"all"` when a dynamic resolver hides the lane.
3366
3362
 
3367
3363
 
3368
- __init27() {this._logger = _chunkS2BEPQ5Zcjs.log.call(void 0, )}
3364
+ __init27() {this._logger = _chunkEAFNHF5Scjs.log.call(void 0, )}
3369
3365
  // This Act's ports: its own bag, or the singleton adapters.
3370
3366
 
3371
3367
  // Runs a body so internal `store()`/`cache()` calls resolve to `_ports`.
@@ -3387,10 +3383,10 @@ var Act = (_class7 = class {
3387
3383
  this._lanes = lanes;
3388
3384
  this._declared_lanes = ["default", ...lanes.map((l) => l.name)];
3389
3385
  validate_only_lanes(options.onlyLanes, this._declared_lanes);
3390
- if (options.scoped) _chunkS2BEPQ5Zcjs.check_store.call(void 0, options.scoped.store);
3391
- this._ports = _nullishCoalesce(options.scoped, () => ( _chunkS2BEPQ5Zcjs.default_scope.call(void 0, )));
3386
+ if (options.scoped) _chunkEAFNHF5Scjs.check_store.call(void 0, options.scoped.store);
3387
+ this._ports = _nullishCoalesce(options.scoped, () => ( _chunkEAFNHF5Scjs.default_scope.call(void 0, )));
3392
3388
  const ports = this._ports;
3393
- this._scoped = _chunkS2BEPQ5Zcjs.make_run_scoped.call(void 0, {
3389
+ this._scoped = _chunkEAFNHF5Scjs.make_run_scoped.call(void 0, {
3394
3390
  // Getters, not a spread: the singletons resolve lazily, so a later
3395
3391
  // `store(...)` / `cache(...)` still takes effect.
3396
3392
  get store() {
@@ -3400,14 +3396,14 @@ var Act = (_class7 = class {
3400
3396
  return ports.cache;
3401
3397
  },
3402
3398
  // Parsed per build, so a bad window throws on every build.
3403
- autoclose_window: _chunkS2BEPQ5Zcjs.resolveAutocloseConfig.call(void 0, options).autocloseWindow
3399
+ autoclose_window: _chunkEAFNHF5Scjs.resolveAutocloseConfig.call(void 0, options).autocloseWindow
3404
3400
  });
3405
3401
  this._correlator = _nullishCoalesce(options.correlator, () => ( default_correlator));
3406
3402
  this._es = build_es(this._logger, this._correlator, patch_fn);
3407
3403
  this._cd = build_drain(this._logger);
3408
3404
  const handle = build_handle({
3409
3405
  logger: this._logger,
3410
- reaction_scope: _chunkS2BEPQ5Zcjs.make_reaction_scope.call(void 0, {
3406
+ reaction_scope: _chunkEAFNHF5Scjs.make_reaction_scope.call(void 0, {
3411
3407
  do: this.do.bind(this),
3412
3408
  load: this.load.bind(this),
3413
3409
  query: this.query.bind(this),
@@ -3437,12 +3433,12 @@ var Act = (_class7 = class {
3437
3433
  this._ports.store,
3438
3434
  options.listen !== false
3439
3435
  );
3440
- _chunkS2BEPQ5Zcjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
3436
+ _chunkEAFNHF5Scjs.register_weak_disposer.call(void 0, new WeakRef(this), (self) => self.shutdown());
3441
3437
  }
3442
3438
  // Shared by drain, settle and autoclose; bad knobs throw at build.
3443
3439
  _build_breaker(options) {
3444
3440
  return new CircuitBreaker(
3445
- _chunkS2BEPQ5Zcjs.resolveCircuitBreakerConfig.call(void 0, options.circuitBreaker),
3441
+ _chunkEAFNHF5Scjs.resolveCircuitBreakerConfig.call(void 0, options.circuitBreaker),
3446
3442
  {
3447
3443
  on_error: (error, circuit) => this._emit_error(error, circuit),
3448
3444
  // When the cooldown elapses, settle once: its scan or claim is the
@@ -3454,7 +3450,7 @@ var Act = (_class7 = class {
3454
3450
  // Apps that declare no lanes pass no lane filter to `claim`.
3455
3451
  _build_drain_controllers(options, lanes, handle, handle_batch) {
3456
3452
  const all_lanes = this._declared_lanes;
3457
- const only_set = _optionalChain([options, 'access', _153 => _153.onlyLanes, 'optionalAccess', _154 => _154.length]) ? new Set(options.onlyLanes) : void 0;
3453
+ const only_set = _optionalChain([options, 'access', _151 => _151.onlyLanes, 'optionalAccess', _152 => _152.length]) ? new Set(options.onlyLanes) : void 0;
3458
3454
  const active_lanes = only_set ? all_lanes.filter((n) => only_set.has(n)) : all_lanes;
3459
3455
  const single_default_lane = lanes.length === 0;
3460
3456
  const controllers = /* @__PURE__ */ new Map();
@@ -3476,7 +3472,7 @@ var Act = (_class7 = class {
3476
3472
  try {
3477
3473
  await this._run_close(targets);
3478
3474
  } catch (error) {
3479
- if (error instanceof _chunk3CQWJ4UAcjs.StoreError) throw error;
3475
+ if (error instanceof _chunkVD4BLAY4cjs.StoreError) throw error;
3480
3476
  this._logger.error(
3481
3477
  error,
3482
3478
  `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.`
@@ -3491,7 +3487,7 @@ var Act = (_class7 = class {
3491
3487
  leaseMillis: cfg.leaseMillis
3492
3488
  }
3493
3489
  });
3494
- if (_optionalChain([cfg, 'optionalAccess', _155 => _155.cycleMs]) !== void 0 && this._drain)
3490
+ if (_optionalChain([cfg, 'optionalAccess', _153 => _153.cycleMs]) !== void 0 && this._drain)
3495
3491
  controller.start(cfg.cycleMs);
3496
3492
  controllers.set(name, controller);
3497
3493
  }
@@ -3510,7 +3506,7 @@ var Act = (_class7 = class {
3510
3506
  // Audit deps, built after the controllers so the lane set is final.
3511
3507
  _build_audit_deps() {
3512
3508
  return {
3513
- store: _chunkS2BEPQ5Zcjs.store,
3509
+ store: _chunkEAFNHF5Scjs.store,
3514
3510
  event_to_state: this._event_to_state,
3515
3511
  // Declared lanes, not this process's controllers: a lane another
3516
3512
  // worker drains is not `unknown-lane`.
@@ -3523,7 +3519,7 @@ var Act = (_class7 = class {
3523
3519
  registry: this.registry,
3524
3520
  static_targets: classification.static_targets,
3525
3521
  cd: this._cd,
3526
- max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunk3CQWJ4UAcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
3522
+ max_subscribed_streams: _nullishCoalesce(options.maxSubscribedStreams, () => ( _chunkVD4BLAY4cjs.DEFAULT_MAX_SUBSCRIBED_STREAMS)),
3527
3523
  // Declared lanes (not active ones): a lane another process claims is
3528
3524
  // still a valid destination.
3529
3525
  declared_lanes: new Set(this._declared_lanes),
@@ -3539,10 +3535,10 @@ var Act = (_class7 = class {
3539
3535
  // Cold start: an idle deferred stream still fires on time after a restart.
3540
3536
  async _seed_persisted_defers() {
3541
3537
  const now = Date.now();
3542
- await walk_streams(_chunkS2BEPQ5Zcjs.store.call(void 0, ), (pos) => {
3538
+ await walk_streams(_chunkEAFNHF5Scjs.store.call(void 0, ), (pos) => {
3543
3539
  if (pos.deferred_at === void 0 || pos.deferred_at <= now) return;
3544
3540
  const controller = this._drain_controllers.get(_nullishCoalesce(pos.lane, () => ( "default")));
3545
- _optionalChain([controller, 'optionalAccess', _156 => _156.seed_defer, 'call', _157 => _157(pos.stream, pos.deferred_at)]);
3541
+ _optionalChain([controller, 'optionalAccess', _154 => _154.seed_defer, 'call', _155 => _155(pos.stream, pos.deferred_at)]);
3546
3542
  });
3547
3543
  }
3548
3544
  _build_settle(options) {
@@ -3555,7 +3551,7 @@ var Act = (_class7 = class {
3555
3551
  on_settled: (drain) => this.emit("settled", drain),
3556
3552
  breaker: this._breaker
3557
3553
  },
3558
- _nullishCoalesce(options.settleDebounceMs, () => ( _chunk3CQWJ4UAcjs.DEFAULT_SETTLE_DEBOUNCE_MS))
3554
+ _nullishCoalesce(options.settleDebounceMs, () => ( _chunkVD4BLAY4cjs.DEFAULT_SETTLE_DEBOUNCE_MS))
3559
3555
  );
3560
3556
  }
3561
3557
 
@@ -3575,7 +3571,7 @@ var Act = (_class7 = class {
3575
3571
  */
3576
3572
  shutdown(options) {
3577
3573
  if (!this._shutdown_promise) {
3578
- _chunkS2BEPQ5Zcjs.resolveShutdownConfig.call(void 0, options);
3574
+ _chunkEAFNHF5Scjs.resolveShutdownConfig.call(void 0, options);
3579
3575
  this._shutdown_promise = (async () => {
3580
3576
  this.stop_correlations();
3581
3577
  this._settle.stop(true);
@@ -3583,7 +3579,7 @@ var Act = (_class7 = class {
3583
3579
  for (const c of this._drain_controllers.values()) c.stop();
3584
3580
  const disposer = await this._notify_disposer;
3585
3581
  if (disposer) await disposer();
3586
- await this._await_inflight(_optionalChain([options, 'optionalAccess', _158 => _158.graceMs]));
3582
+ await this._await_inflight(_optionalChain([options, 'optionalAccess', _156 => _156.graceMs]));
3587
3583
  await this._scoped(() => this._correlate.release_correlation());
3588
3584
  this._emitter.removeAllListeners();
3589
3585
  })();
@@ -3593,10 +3589,10 @@ var Act = (_class7 = class {
3593
3589
  // The largest `leaseMillis` among lanes with a cycle in flight (the
3594
3590
  // default for none or 0, and for a running settle), capped.
3595
3591
  _derive_grace_ms(running, settling) {
3596
- let max = settling ? _chunkS2BEPQ5Zcjs.DEFAULT_LEASE_MILLIS : 0;
3592
+ let max = settling ? _chunkEAFNHF5Scjs.DEFAULT_LEASE_MILLIS : 0;
3597
3593
  for (const c of running)
3598
- max = Math.max(max, c.lease_millis || _chunkS2BEPQ5Zcjs.DEFAULT_LEASE_MILLIS);
3599
- return Math.min(max, _chunkS2BEPQ5Zcjs.MAX_SHUTDOWN_GRACE_MS);
3594
+ max = Math.max(max, c.lease_millis || _chunkEAFNHF5Scjs.DEFAULT_LEASE_MILLIS);
3595
+ return Math.min(max, _chunkEAFNHF5Scjs.MAX_SHUTDOWN_GRACE_MS);
3600
3596
  }
3601
3597
  async _await_inflight(grace_ms) {
3602
3598
  const running = [...this._drain_controllers.values()].filter(
@@ -3680,8 +3676,8 @@ var Act = (_class7 = class {
3680
3676
  * @see {@link ValidationError}, {@link PreconditionError}, {@link ConcurrencyError}
3681
3677
  */
3682
3678
  async do(action2, target, payload, options) {
3683
- const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _159 => _159.reactingTo]), () => ( _chunkS2BEPQ5Zcjs.current_reacting.call(void 0, )));
3684
- const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _160 => _160.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
3679
+ const reacting_to = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _157 => _157.reactingTo]), () => ( _chunkEAFNHF5Scjs.current_reacting.call(void 0, )));
3680
+ const do_options = reacting_to === _optionalChain([options, 'optionalAccess', _158 => _158.reactingTo]) ? options : { ...options, reactingTo: reacting_to };
3685
3681
  return this._scoped(async () => {
3686
3682
  const snapshots = await this._es.action(
3687
3683
  this.registry.actions[action2],
@@ -3755,11 +3751,11 @@ var Act = (_class7 = class {
3755
3751
  return this._scoped(async () => {
3756
3752
  let first;
3757
3753
  let last;
3758
- const count = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query((e) => {
3754
+ const count = await _chunkEAFNHF5Scjs.store.call(void 0, ).query((e) => {
3759
3755
  const gated = this.registry.query_gate(e.name)(e);
3760
3756
  if (!first) first = gated;
3761
3757
  last = gated;
3762
- _optionalChain([callback, 'optionalCall', _161 => _161(gated)]);
3758
+ _optionalChain([callback, 'optionalCall', _159 => _159(gated)]);
3763
3759
  }, query);
3764
3760
  return { first, last, count };
3765
3761
  });
@@ -3785,7 +3781,7 @@ var Act = (_class7 = class {
3785
3781
  async query_array(query) {
3786
3782
  return this._scoped(async () => {
3787
3783
  const events = [];
3788
- await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query((e) => {
3784
+ await _chunkEAFNHF5Scjs.store.call(void 0, ).query((e) => {
3789
3785
  events.push(this.registry.query_gate(e.name)(e));
3790
3786
  }, query);
3791
3787
  return events;
@@ -3805,14 +3801,14 @@ var Act = (_class7 = class {
3805
3801
  */
3806
3802
  async forget(stream) {
3807
3803
  return this._scoped(async () => {
3808
- const s = _chunkS2BEPQ5Zcjs.store.call(void 0, );
3804
+ const s = _chunkEAFNHF5Scjs.store.call(void 0, );
3809
3805
  if (!s.forget_pii) {
3810
3806
  throw new Error(
3811
3807
  `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).`
3812
3808
  );
3813
3809
  }
3814
3810
  const eventCount = await s.forget_pii(stream);
3815
- await _chunkS2BEPQ5Zcjs.cache.call(void 0, ).invalidate(stream);
3811
+ await _chunkEAFNHF5Scjs.cache.call(void 0, ).invalidate(stream);
3816
3812
  if (eventCount > 0) {
3817
3813
  this.emit("forgotten", { stream, at: /* @__PURE__ */ new Date(), eventCount });
3818
3814
  }
@@ -3846,7 +3842,7 @@ var Act = (_class7 = class {
3846
3842
  * @see {@link correlate} for dynamic stream discovery
3847
3843
  */
3848
3844
  async drain(options = {}) {
3849
- _chunkS2BEPQ5Zcjs.resolveDrainConfig.call(void 0, options);
3845
+ _chunkEAFNHF5Scjs.resolveDrainConfig.call(void 0, options);
3850
3846
  if (!this._drain)
3851
3847
  return { fetched: [], leased: [], acked: [], blocked: [] };
3852
3848
  return this._scoped(() => this._drain_all(options));
@@ -3884,7 +3880,7 @@ var Act = (_class7 = class {
3884
3880
  }
3885
3881
  if (to_arm.size === 0) return false;
3886
3882
  this._correlate.arm();
3887
- for (const lane of to_arm) _optionalChain([this, 'access', _162 => _162._drain_controllers, 'access', _163 => _163.get, 'call', _164 => _164(lane), 'optionalAccess', _165 => _165.arm, 'call', _166 => _166()]);
3883
+ for (const lane of to_arm) _optionalChain([this, 'access', _160 => _160._drain_controllers, 'access', _161 => _161.get, 'call', _162 => _162(lane), 'optionalAccess', _163 => _163.arm, 'call', _164 => _164()]);
3888
3884
  return true;
3889
3885
  }
3890
3886
  // In parallel, so a slow lane never holds up a fast one.
@@ -4026,9 +4022,9 @@ var Act = (_class7 = class {
4026
4022
  */
4027
4023
  async reset(input) {
4028
4024
  return this._scoped(async () => {
4029
- const count = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).reset(input);
4025
+ const count = await _chunkEAFNHF5Scjs.store.call(void 0, ).reset(input);
4030
4026
  for (const handler of this._batch_handlers.values())
4031
- _optionalChain([handler, 'access', _167 => _167[FOLD_RESET], 'optionalCall', _168 => _168()]);
4027
+ _optionalChain([handler, 'access', _165 => _165[FOLD_RESET], 'optionalCall', _166 => _166()]);
4032
4028
  if (count > 0) {
4033
4029
  this._wake();
4034
4030
  }
@@ -4062,7 +4058,7 @@ var Act = (_class7 = class {
4062
4058
  */
4063
4059
  async unblock(input) {
4064
4060
  return this._scoped(async () => {
4065
- const count = await _chunkS2BEPQ5Zcjs.store.call(void 0, ).unblock(input);
4061
+ const count = await _chunkEAFNHF5Scjs.store.call(void 0, ).unblock(input);
4066
4062
  if (count > 0) {
4067
4063
  this._wake();
4068
4064
  }
@@ -4117,7 +4113,7 @@ var Act = (_class7 = class {
4117
4113
  return { ...partial, duration_ms: Date.now() - started };
4118
4114
  }
4119
4115
  const target = _nullishCoalesce(sink, () => ( (() => {
4120
- const s = _chunkS2BEPQ5Zcjs.store.call(void 0, );
4116
+ const s = _chunkEAFNHF5Scjs.store.call(void 0, );
4121
4117
  if (!s.restore) throw new Error("adapter has no restore capability");
4122
4118
  return s;
4123
4119
  })()));
@@ -4163,11 +4159,11 @@ var Act = (_class7 = class {
4163
4159
  async blocked_streams(options) {
4164
4160
  return this._scoped(async () => {
4165
4161
  const positions = [];
4166
- await _chunkS2BEPQ5Zcjs.store.call(void 0, ).query_streams(
4162
+ await _chunkEAFNHF5Scjs.store.call(void 0, ).query_streams(
4167
4163
  (p) => {
4168
4164
  positions.push(p);
4169
4165
  },
4170
- { blocked: true, after: _optionalChain([options, 'optionalAccess', _169 => _169.after]), limit: _optionalChain([options, 'optionalAccess', _170 => _170.limit]) }
4166
+ { blocked: true, after: _optionalChain([options, 'optionalAccess', _167 => _167.after]), limit: _optionalChain([options, 'optionalAccess', _168 => _168.limit]) }
4171
4167
  );
4172
4168
  return positions;
4173
4169
  });
@@ -4215,7 +4211,7 @@ var Act = (_class7 = class {
4215
4211
  * @see {@link Store.prioritize} for the underlying primitive
4216
4212
  */
4217
4213
  async prioritize(filter, priority) {
4218
- return this._scoped(() => _chunkS2BEPQ5Zcjs.store.call(void 0, ).prioritize(filter, priority));
4214
+ return this._scoped(() => _chunkEAFNHF5Scjs.store.call(void 0, ).prioritize(filter, priority));
4219
4215
  }
4220
4216
  // Shared by `close()` and reaction-requested closes.
4221
4217
  async _run_close(targets) {
@@ -4295,7 +4291,7 @@ var Act = (_class7 = class {
4295
4291
  * @see {@link correlate} for manual correlation
4296
4292
  */
4297
4293
  settle(options) {
4298
- _chunkS2BEPQ5Zcjs.resolveSettleConfig.call(void 0, _nullishCoalesce(options, () => ( {})));
4294
+ _chunkEAFNHF5Scjs.resolveSettleConfig.call(void 0, _nullishCoalesce(options, () => ( {})));
4299
4295
  this._schedule(options);
4300
4296
  }
4301
4297
  }, _class7);
@@ -4303,9 +4299,9 @@ var Act = (_class7 = class {
4303
4299
  // src/builders/merge.ts
4304
4300
 
4305
4301
  function base_type_name(schema) {
4306
- let def = _chunk3CQWJ4UAcjs.def_of.call(void 0, schema);
4307
- for (let inner = _chunk3CQWJ4UAcjs.inner_of.call(void 0, def); inner; inner = _chunk3CQWJ4UAcjs.inner_of.call(void 0, def))
4308
- def = _chunk3CQWJ4UAcjs.def_of.call(void 0, inner);
4302
+ let def = _chunkVD4BLAY4cjs.def_of.call(void 0, schema);
4303
+ for (let inner = _chunkVD4BLAY4cjs.inner_of.call(void 0, def); inner; inner = _chunkVD4BLAY4cjs.inner_of.call(void 0, def))
4304
+ def = _chunkVD4BLAY4cjs.def_of.call(void 0, inner);
4309
4305
  return def.type === "array" ? `array of ${base_type_name(def.element)}` : def.type;
4310
4306
  }
4311
4307
  function merge_schemas(existing, incoming, state_name) {
@@ -4492,9 +4488,9 @@ var _this_ = ({ stream }) => ({
4492
4488
 
4493
4489
  // src/builders/builder-utils.ts
4494
4490
  function register_lane(config2, lanes) {
4495
- _chunkS2BEPQ5Zcjs.resolveLaneConfig.call(void 0, config2);
4496
- if (config2.name === _chunk3CQWJ4UAcjs.DEFAULT_LANE)
4497
- throw new Error(`Lane "${_chunk3CQWJ4UAcjs.DEFAULT_LANE}" is reserved`);
4491
+ _chunkEAFNHF5Scjs.resolveLaneConfig.call(void 0, config2);
4492
+ if (config2.name === _chunkVD4BLAY4cjs.DEFAULT_LANE)
4493
+ throw new Error(`Lane "${_chunkVD4BLAY4cjs.DEFAULT_LANE}" is reserved`);
4498
4494
  const existing = lanes.find((l) => l.name === config2.name);
4499
4495
  if (!existing) return void lanes.push(config2);
4500
4496
  if (existing.leaseMillis !== config2.leaseMillis || existing.streamLimit !== config2.streamLimit || existing.cycleMs !== config2.cycleMs)
@@ -4536,10 +4532,10 @@ function reaction_on(event, events, builder) {
4536
4532
  // Validate the whole bag at the declaration site so a bad
4537
4533
  // `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
4538
4534
  // not a NaN gate on the first retry.
4539
- options: _chunkS2BEPQ5Zcjs.resolveReactionConfig.call(void 0, {
4540
- blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _171 => _171.blockOnError]), () => ( _chunkS2BEPQ5Zcjs.DEFAULT_BLOCK_ON_ERROR)),
4541
- maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _172 => _172.maxRetries]), () => ( _chunkS2BEPQ5Zcjs.DEFAULT_MAX_RETRIES)),
4542
- backoff: _optionalChain([options, 'optionalAccess', _173 => _173.backoff])
4535
+ options: _chunkEAFNHF5Scjs.resolveReactionConfig.call(void 0, {
4536
+ blockOnError: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _169 => _169.blockOnError]), () => ( _chunkEAFNHF5Scjs.DEFAULT_BLOCK_ON_ERROR)),
4537
+ maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _170 => _170.maxRetries]), () => ( _chunkEAFNHF5Scjs.DEFAULT_MAX_RETRIES)),
4538
+ backoff: _optionalChain([options, 'optionalAccess', _171 => _171.backoff])
4543
4539
  })
4544
4540
  };
4545
4541
  },
@@ -4559,7 +4555,7 @@ function reaction_on(event, events, builder) {
4559
4555
  // src/internal/date-reviver.ts
4560
4556
 
4561
4557
  function variant_schema(schema, walk) {
4562
- const shape = _optionalChain([_chunk3CQWJ4UAcjs.def_of.call(void 0, schema), 'optionalAccess', _174 => _174.shape]);
4558
+ const shape = _optionalChain([_chunkVD4BLAY4cjs.def_of.call(void 0, schema), 'optionalAccess', _172 => _172.shape]);
4563
4559
  if (!shape) {
4564
4560
  const dates = walk(schema);
4565
4561
  return { schema: _nullishCoalesce(dates, () => ( schema)), dated: !!dates };
@@ -4596,7 +4592,7 @@ function date_reviver_schema(schema) {
4596
4592
  return first && recursive ? pass(true) : first;
4597
4593
  }
4598
4594
  function build(schema, walk) {
4599
- const def = _chunk3CQWJ4UAcjs.def_of.call(void 0, schema);
4595
+ const def = _chunkVD4BLAY4cjs.def_of.call(void 0, schema);
4600
4596
  if (!def) return void 0;
4601
4597
  const inner = () => walk(def.innerType);
4602
4598
  switch (def.type) {
@@ -4631,7 +4627,7 @@ function build(schema, walk) {
4631
4627
  return variants.some((v) => v.dated) ? _zod.z.union(variants.map((v) => v.schema)) : void 0;
4632
4628
  }
4633
4629
  case "nullable":
4634
- return _optionalChain([inner, 'call', _175 => _175(), 'optionalAccess', _176 => _176.nullable, 'call', _177 => _177()]);
4630
+ return _optionalChain([inner, 'call', _173 => _173(), 'optionalAccess', _174 => _174.nullable, 'call', _175 => _175()]);
4635
4631
  case "pipe":
4636
4632
  return walk(def.out);
4637
4633
  case "lazy":
@@ -4642,13 +4638,13 @@ function build(schema, walk) {
4642
4638
  return left && right ? left.pipe(right) : _nullishCoalesce(left, () => ( right));
4643
4639
  }
4644
4640
  default:
4645
- return _chunk3CQWJ4UAcjs.inner_of.call(void 0, def) ? inner() : void 0;
4641
+ return _chunkVD4BLAY4cjs.inner_of.call(void 0, def) ? inner() : void 0;
4646
4642
  }
4647
4643
  }
4648
4644
 
4649
4645
  // src/builders/event-builder.ts
4650
4646
  function event_tags(schema) {
4651
- const pii = _chunk3CQWJ4UAcjs.pii_schemas.call(void 0, schema);
4647
+ const pii = _chunkVD4BLAY4cjs.pii_schemas.call(void 0, schema);
4652
4648
  const pii_dates = {};
4653
4649
  for (const [key, field] of Object.entries(pii)) {
4654
4650
  const dates = date_reviver_schema(field);
@@ -4686,7 +4682,7 @@ function make_event_reader(tags, disclosure, predicate = null) {
4686
4682
  });
4687
4683
  }
4688
4684
  function build_events(registry, states, lanes, owners) {
4689
- const declared = /* @__PURE__ */ new Set([_chunk3CQWJ4UAcjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
4685
+ const declared = /* @__PURE__ */ new Set([_chunkVD4BLAY4cjs.DEFAULT_LANE, ...lanes.map((l) => l.name)]);
4690
4686
  const lane_errors = [];
4691
4687
  const tags = /* @__PURE__ */ new Map();
4692
4688
  const sensitive2 = /* @__PURE__ */ new Map();
@@ -4761,7 +4757,7 @@ function build_events(registry, states, lanes, owners) {
4761
4757
  if (reader) readers.set(event_name, reader);
4762
4758
  }
4763
4759
  const snap2 = make_event_reader(event_tags(state2.state), "redact", null);
4764
- if (snap2) readers.set(_chunk3CQWJ4UAcjs.SNAP_EVENT, snap2);
4760
+ if (snap2) readers.set(_chunkVD4BLAY4cjs.SNAP_EVENT, snap2);
4765
4761
  if (readers.size === 0) continue;
4766
4762
  state2.view = (event, actor) => (_nullishCoalesce(readers.get(event.name), () => ( IDENTITY_GATE)))(event, actor);
4767
4763
  }
@@ -4769,7 +4765,7 @@ function build_events(registry, states, lanes, owners) {
4769
4765
  return { sensitive: sensitive2, advisory, query_readers, handler_readers };
4770
4766
  }
4771
4767
  function reads_as_string(schema) {
4772
- const type = _optionalChain([_chunk3CQWJ4UAcjs.def_of.call(void 0, _chunk3CQWJ4UAcjs.output_of.call(void 0, schema)), 'optionalAccess', _178 => _178.type]);
4768
+ const type = _optionalChain([_chunkVD4BLAY4cjs.def_of.call(void 0, _chunkVD4BLAY4cjs.output_of.call(void 0, schema)), 'optionalAccess', _176 => _176.type]);
4773
4769
  return type === "string" || type === "transform";
4774
4770
  }
4775
4771
 
@@ -4827,7 +4823,7 @@ function act() {
4827
4823
  let _built = false;
4828
4824
  const read_wrap = (original) => {
4829
4825
  const wrapped = async (events, stream) => {
4830
- const read = events.map((e) => _nullishCoalesce(_optionalChain([_hr, 'access', _179 => _179.get, 'call', _180 => _180(e.name), 'optionalCall', _181 => _181(e)]), () => ( e)));
4826
+ const read = events.map((e) => _nullishCoalesce(_optionalChain([_hr, 'access', _177 => _177.get, 'call', _178 => _178(e.name), 'optionalCall', _179 => _179(e)]), () => ( e)));
4831
4827
  return original(read, stream);
4832
4828
  };
4833
4829
  const reset = original[FOLD_RESET];
@@ -4868,7 +4864,7 @@ function act() {
4868
4864
  });
4869
4865
  }
4870
4866
  for (const [action_name, handler] of Object.entries(state2.on)) {
4871
- const static_target = _optionalChain([handler, 'optionalAccess', _182 => _182._static_emit]);
4867
+ const static_target = _optionalChain([handler, 'optionalAccess', _180 => _180._static_emit]);
4872
4868
  if (static_target && deprecated.has(static_target)) {
4873
4869
  const current = current_version_of(static_target, event_names);
4874
4870
  throw new Error(
@@ -4881,7 +4877,7 @@ function act() {
4881
4877
  const list = deprecation_summary.map(
4882
4878
  (d) => `"${d.deprecated}" (current: "${d.current}", state: "${d.state_name}")`
4883
4879
  ).join(", ");
4884
- _chunkS2BEPQ5Zcjs.log.call(void 0, ).info(
4880
+ _chunkEAFNHF5Scjs.log.call(void 0, ).info(
4885
4881
  `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.`
4886
4882
  );
4887
4883
  }
@@ -4923,7 +4919,7 @@ function act() {
4923
4919
  return reaction_on(event, registry.events, builder);
4924
4920
  },
4925
4921
  build: (options) => {
4926
- _chunkS2BEPQ5Zcjs.resolveActConfig.call(void 0, options);
4922
+ _chunkEAFNHF5Scjs.resolveActConfig.call(void 0, options);
4927
4923
  if (!_built) {
4928
4924
  for (const proj of pending_projections) add_projection(proj);
4929
4925
  for (const proj of fold_projections) {
@@ -4941,7 +4937,7 @@ function act() {
4941
4937
  `State projection "${proj.target}" of "${fold.name}" is missing events ${missing.join(", ")} \u2014 pass every partial of the state to .of()`
4942
4938
  );
4943
4939
  const claimed = fold_specs.find((s) => s.target === proj.target);
4944
- if (_optionalChain([claimed, 'optionalAccess', _183 => _183.projection]) === proj) continue;
4940
+ if (_optionalChain([claimed, 'optionalAccess', _181 => _181.projection]) === proj) continue;
4945
4941
  if (batch_handlers.has(proj.target) || claimed)
4946
4942
  throw new Error(
4947
4943
  `Duplicate projection target "${proj.target}" \u2014 a target is served by one batch handler or one state projection, never both`
@@ -4963,7 +4959,7 @@ function act() {
4963
4959
  for (const [name, gate] of built.query_readers) _qg.set(name, gate);
4964
4960
  for (const [name, gate] of built.handler_readers) _hr.set(name, gate);
4965
4961
  finalize_deprecations();
4966
- if (built.advisory) _chunkS2BEPQ5Zcjs.log.call(void 0, ).warn(built.advisory);
4962
+ if (built.advisory) _chunkEAFNHF5Scjs.log.call(void 0, ).warn(built.advisory);
4967
4963
  for (const [name, state2] of states) {
4968
4964
  if (!state2.loads) continue;
4969
4965
  const resolved = {};
@@ -4975,7 +4971,7 @@ function act() {
4975
4971
  `Action "${action2}" loads "${l.state.name}", which is not registered \u2014 add it via withState/withSlice before build()`
4976
4972
  );
4977
4973
  const deprecated = l.events.find(
4978
- (e) => _optionalChain([_de, 'access', _184 => _184.get, 'call', _185 => _185(registered.name), 'optionalAccess', _186 => _186.has, 'call', _187 => _187(e)])
4974
+ (e) => _optionalChain([_de, 'access', _182 => _182.get, 'call', _183 => _183(registered.name), 'optionalAccess', _184 => _184.has, 'call', _185 => _185(e)])
4979
4975
  );
4980
4976
  if (deprecated)
4981
4977
  throw new Error(
@@ -5007,7 +5003,7 @@ function act() {
5007
5003
  synthesize_autoclose_reactions(
5008
5004
  registry,
5009
5005
  states,
5010
- _chunkS2BEPQ5Zcjs.current_autoclose_window
5006
+ _chunkEAFNHF5Scjs.current_autoclose_window
5011
5007
  );
5012
5008
  Object.freeze(registry.actions);
5013
5009
  Object.freeze(registry.events);
@@ -5055,8 +5051,8 @@ function _projection(target) {
5055
5051
  handler,
5056
5052
  resolver: _nullishCoalesce(default_resolver, () => ( _this_)),
5057
5053
  options: {
5058
- blockOnError: _chunkS2BEPQ5Zcjs.DEFAULT_BLOCK_ON_ERROR,
5059
- maxRetries: _chunkS2BEPQ5Zcjs.DEFAULT_MAX_RETRIES
5054
+ blockOnError: _chunkEAFNHF5Scjs.DEFAULT_BLOCK_ON_ERROR,
5055
+ maxRetries: _chunkEAFNHF5Scjs.DEFAULT_MAX_RETRIES
5060
5056
  }
5061
5057
  }),
5062
5058
  widened
@@ -5097,7 +5093,7 @@ function _projection(target) {
5097
5093
  throw new Error(
5098
5094
  `Projection "${target}" .of() partials must share one state name \u2014 got "${name}" and "${partial.name}"`
5099
5095
  );
5100
- const config2 = _chunkS2BEPQ5Zcjs.resolveFoldConfig.call(void 0, options);
5096
+ const config2 = _chunkEAFNHF5Scjs.resolveFoldConfig.call(void 0, options);
5101
5097
  const fold_events = {};
5102
5098
  for (const partial of partials)
5103
5099
  for (const [event_name, schema] of Object.entries(partial.events)) {
@@ -5115,8 +5111,8 @@ function _projection(target) {
5115
5111
  handler: noop,
5116
5112
  resolver: { target },
5117
5113
  options: {
5118
- blockOnError: _chunkS2BEPQ5Zcjs.DEFAULT_BLOCK_ON_ERROR,
5119
- maxRetries: _chunkS2BEPQ5Zcjs.DEFAULT_MAX_RETRIES
5114
+ blockOnError: _chunkEAFNHF5Scjs.DEFAULT_BLOCK_ON_ERROR,
5115
+ maxRetries: _chunkEAFNHF5Scjs.DEFAULT_MAX_RETRIES
5120
5116
  }
5121
5117
  }
5122
5118
  ]
@@ -5232,7 +5228,7 @@ function action_builder(state2) {
5232
5228
  throw new Error(`Duplicate action "${action2}"`);
5233
5229
  internal.actions[action2] = schema;
5234
5230
  if (options) {
5235
- _chunkS2BEPQ5Zcjs.resolveActionConfig.call(void 0, options);
5231
+ _chunkEAFNHF5Scjs.resolveActionConfig.call(void 0, options);
5236
5232
  internal.options ??= {};
5237
5233
  internal.options[action2] = options;
5238
5234
  }
@@ -5304,8 +5300,9 @@ function action_builder(state2) {
5304
5300
  internal.autoclose = compile_autoclose_policy(
5305
5301
  policy
5306
5302
  );
5307
- internal.autoclose_after_days = policy_min_after_days(policy);
5308
- internal.autoclose_after_windows = policy_after_windows(policy);
5303
+ const windows = policy_after_windows(policy);
5304
+ internal.autoclose_after_windows = windows;
5305
+ internal.autoclose_after_days = windows.length ? Math.min(...windows) : void 0;
5309
5306
  internal.autoclose_keep_days = policy_keep_days(policy);
5310
5307
  return builder;
5311
5308
  },
@@ -5544,5 +5541,8 @@ function write_line(writer, line) {
5544
5541
 
5545
5542
 
5546
5543
 
5547
- exports.Act = Act; exports.ActorSchema = _chunk3CQWJ4UAcjs.ActorSchema; exports.CausationEventSchema = _chunk3CQWJ4UAcjs.CausationEventSchema; exports.CommittedMetaSchema = _chunk3CQWJ4UAcjs.CommittedMetaSchema; exports.ConcurrencyError = _chunk3CQWJ4UAcjs.ConcurrencyError; exports.ConsoleLogger = _chunkS2BEPQ5Zcjs.ConsoleLogger; exports.CsvFile = CsvFile; exports.DEFAULT_LANE = _chunk3CQWJ4UAcjs.DEFAULT_LANE; exports.DEFAULT_MAX_SUBSCRIBED_STREAMS = _chunk3CQWJ4UAcjs.DEFAULT_MAX_SUBSCRIBED_STREAMS; exports.DEFAULT_QUERY_STREAMS_LIMIT = _chunkS2BEPQ5Zcjs.DEFAULT_QUERY_STREAMS_LIMIT; exports.DEFAULT_SETTLE_DEBOUNCE_MS = _chunk3CQWJ4UAcjs.DEFAULT_SETTLE_DEBOUNCE_MS; exports.DeferSignal = _chunk3CQWJ4UAcjs.DeferSignal; exports.Environments = _chunk3CQWJ4UAcjs.Environments; exports.Errors = _chunk3CQWJ4UAcjs.Errors; exports.EventMetaSchema = _chunk3CQWJ4UAcjs.EventMetaSchema; exports.ExitCodes = _chunk3CQWJ4UAcjs.ExitCodes; exports.InMemoryCache = _chunkS2BEPQ5Zcjs.InMemoryCache; exports.InMemoryStore = _chunkS2BEPQ5Zcjs.InMemoryStore; exports.LogLevels = _chunk3CQWJ4UAcjs.LogLevels; exports.NonRetryableError = _chunk3CQWJ4UAcjs.NonRetryableError; exports.PackageSchema = _chunkS2BEPQ5Zcjs.PackageSchema; exports.PreconditionError = _chunk3CQWJ4UAcjs.PreconditionError; exports.QuerySchema = _chunk3CQWJ4UAcjs.QuerySchema; exports.REDACTED = _chunk3CQWJ4UAcjs.REDACTED; exports.SHREDDED = _chunk3CQWJ4UAcjs.SHREDDED; exports.SNAP_EVENT = _chunk3CQWJ4UAcjs.SNAP_EVENT; exports.StoreError = _chunk3CQWJ4UAcjs.StoreError; exports.StreamClosedError = _chunk3CQWJ4UAcjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunk3CQWJ4UAcjs.TOMBSTONE_EVENT; exports.TargetSchema = _chunk3CQWJ4UAcjs.TargetSchema; exports.ValidationError = _chunk3CQWJ4UAcjs.ValidationError; exports.ZodEmpty = _chunk3CQWJ4UAcjs.ZodEmpty; exports.act = act; exports.cache = _chunkS2BEPQ5Zcjs.cache; exports.check_appends = _chunkS2BEPQ5Zcjs.check_appends; exports.config = _chunkS2BEPQ5Zcjs.config; exports.dateReviver = _chunkS2BEPQ5Zcjs.dateReviver; exports.default_scope = _chunkS2BEPQ5Zcjs.default_scope; exports.dispose = _chunkS2BEPQ5Zcjs.dispose; exports.disposeAndExit = _chunkS2BEPQ5Zcjs.disposeAndExit; exports.extend = _chunkS2BEPQ5Zcjs.extend; exports.fair_slots = _chunkS2BEPQ5Zcjs.fair_slots; exports.is_literal_source = _chunkS2BEPQ5Zcjs.is_literal_source; exports.log = _chunkS2BEPQ5Zcjs.log; exports.pii_fields = _chunk3CQWJ4UAcjs.pii_fields; exports.port = _chunkS2BEPQ5Zcjs.port; exports.projection = projection; exports.resolveAutocloseConfig = _chunkS2BEPQ5Zcjs.resolveAutocloseConfig2; exports.sensitive = _chunk3CQWJ4UAcjs.sensitive; exports.sleep = _chunkS2BEPQ5Zcjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkS2BEPQ5Zcjs.store; exports.validate = _chunkS2BEPQ5Zcjs.validate;
5544
+
5545
+
5546
+
5547
+ exports.Act = Act; exports.ActorSchema = _chunkVD4BLAY4cjs.ActorSchema; exports.CausationEventSchema = _chunkVD4BLAY4cjs.CausationEventSchema; exports.CommittedMetaSchema = _chunkVD4BLAY4cjs.CommittedMetaSchema; exports.ConcurrencyError = _chunkVD4BLAY4cjs.ConcurrencyError; exports.ConsoleLogger = _chunkEAFNHF5Scjs.ConsoleLogger; exports.CsvFile = CsvFile; exports.DEFAULT_LANE = _chunkVD4BLAY4cjs.DEFAULT_LANE; exports.DEFAULT_MAX_SUBSCRIBED_STREAMS = _chunkVD4BLAY4cjs.DEFAULT_MAX_SUBSCRIBED_STREAMS; exports.DEFAULT_QUERY_STREAMS_LIMIT = _chunkEAFNHF5Scjs.DEFAULT_QUERY_STREAMS_LIMIT; exports.DEFAULT_SETTLE_DEBOUNCE_MS = _chunkVD4BLAY4cjs.DEFAULT_SETTLE_DEBOUNCE_MS; exports.DeferSignal = _chunkVD4BLAY4cjs.DeferSignal; exports.Environments = _chunkVD4BLAY4cjs.Environments; exports.Errors = _chunkVD4BLAY4cjs.Errors; exports.EventMetaSchema = _chunkVD4BLAY4cjs.EventMetaSchema; exports.ExitCodes = _chunkVD4BLAY4cjs.ExitCodes; exports.InMemoryCache = _chunkEAFNHF5Scjs.InMemoryCache; exports.InMemoryStore = _chunkEAFNHF5Scjs.InMemoryStore; exports.LogLevels = _chunkVD4BLAY4cjs.LogLevels; exports.NonRetryableError = _chunkVD4BLAY4cjs.NonRetryableError; exports.PackageSchema = _chunkEAFNHF5Scjs.PackageSchema; exports.PreconditionError = _chunkVD4BLAY4cjs.PreconditionError; exports.QuerySchema = _chunkVD4BLAY4cjs.QuerySchema; exports.REDACTED = _chunkVD4BLAY4cjs.REDACTED; exports.SHREDDED = _chunkVD4BLAY4cjs.SHREDDED; exports.SNAP_EVENT = _chunkVD4BLAY4cjs.SNAP_EVENT; exports.StoreError = _chunkVD4BLAY4cjs.StoreError; exports.StreamClosedError = _chunkVD4BLAY4cjs.StreamClosedError; exports.TOMBSTONE_EVENT = _chunkVD4BLAY4cjs.TOMBSTONE_EVENT; exports.TargetSchema = _chunkVD4BLAY4cjs.TargetSchema; exports.ValidationError = _chunkVD4BLAY4cjs.ValidationError; exports.ZodEmpty = _chunkVD4BLAY4cjs.ZodEmpty; exports.act = act; exports.cache = _chunkEAFNHF5Scjs.cache; exports.check_appends = _chunkEAFNHF5Scjs.check_appends; exports.concurrency_error = _chunkEAFNHF5Scjs.concurrency_error; exports.config = _chunkEAFNHF5Scjs.config; exports.dateReviver = _chunkEAFNHF5Scjs.dateReviver; exports.default_scope = _chunkEAFNHF5Scjs.default_scope; exports.dispose = _chunkEAFNHF5Scjs.dispose; exports.disposeAndExit = _chunkEAFNHF5Scjs.disposeAndExit; exports.extend = _chunkEAFNHF5Scjs.extend; exports.fair_slots = _chunkEAFNHF5Scjs.fair_slots; exports.is_literal_source = _chunkEAFNHF5Scjs.is_literal_source; exports.log = _chunkEAFNHF5Scjs.log; exports.pii_fields = _chunkVD4BLAY4cjs.pii_fields; exports.port = _chunkEAFNHF5Scjs.port; exports.projection = projection; exports.resolveAutocloseConfig = _chunkEAFNHF5Scjs.resolveAutocloseConfig2; exports.seed_event = _chunkEAFNHF5Scjs.seed_event; exports.sensitive = _chunkVD4BLAY4cjs.sensitive; exports.sleep = _chunkEAFNHF5Scjs.sleep; exports.slice = slice; exports.state = state; exports.store = _chunkEAFNHF5Scjs.store; exports.throw_if_stale = _chunkEAFNHF5Scjs.throw_if_stale; exports.validate = _chunkEAFNHF5Scjs.validate;
5548
5548
  //# sourceMappingURL=index.cjs.map