@rotorsoft/act 2.1.12 → 2.1.14

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.
Files changed (62) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/@types/act.d.ts.map +1 -1
  3. package/dist/@types/builders/act-builder.d.ts.map +1 -1
  4. package/dist/@types/builders/event-builder.d.ts +7 -3
  5. package/dist/@types/builders/event-builder.d.ts.map +1 -1
  6. package/dist/@types/builders/merge.d.ts.map +1 -1
  7. package/dist/@types/deprecated.d.ts +10 -0
  8. package/dist/@types/deprecated.d.ts.map +1 -1
  9. package/dist/@types/index.d.ts +2 -3
  10. package/dist/@types/index.d.ts.map +1 -1
  11. package/dist/@types/internal/audit.d.ts +2 -0
  12. package/dist/@types/internal/audit.d.ts.map +1 -1
  13. package/dist/@types/internal/config.d.ts +9 -0
  14. package/dist/@types/internal/config.d.ts.map +1 -1
  15. package/dist/@types/internal/pii.d.ts +1 -1
  16. package/dist/@types/{sensitive.d.ts → internal/sensitive.d.ts} +0 -24
  17. package/dist/@types/internal/sensitive.d.ts.map +1 -0
  18. package/dist/@types/ports.d.ts +0 -5
  19. package/dist/@types/ports.d.ts.map +1 -1
  20. package/dist/@types/types/action-rules.d.ts +177 -0
  21. package/dist/@types/types/action-rules.d.ts.map +1 -0
  22. package/dist/@types/types/builders.d.ts +15 -311
  23. package/dist/@types/types/builders.d.ts.map +1 -1
  24. package/dist/@types/types/ports.d.ts +1 -1
  25. package/dist/@types/types/projection.d.ts +135 -0
  26. package/dist/@types/types/projection.d.ts.map +1 -0
  27. package/dist/@types/types/registry.d.ts +7 -4
  28. package/dist/@types/types/registry.d.ts.map +1 -1
  29. package/dist/@types/types/schemas.d.ts +0 -1
  30. package/dist/@types/types/schemas.d.ts.map +1 -1
  31. package/dist/adapter.cjs +3 -3
  32. package/dist/adapter.js +2 -2
  33. package/dist/{chunk-SC6TY4P2.cjs → chunk-DCWPJFXR.cjs} +12 -4
  34. package/dist/chunk-DCWPJFXR.cjs.map +1 -0
  35. package/dist/{chunk-RV34EYSN.js → chunk-EIGZVFT7.js} +11 -3
  36. package/dist/{chunk-RV34EYSN.js.map → chunk-EIGZVFT7.js.map} +1 -1
  37. package/dist/{chunk-BQUOIHOR.js → chunk-GDPBPAML.js} +31 -87
  38. package/dist/chunk-GDPBPAML.js.map +1 -0
  39. package/dist/{chunk-Y2ISPWQL.js → chunk-SCH4GLWM.js} +78 -42
  40. package/dist/{chunk-Y2ISPWQL.js.map → chunk-SCH4GLWM.js.map} +1 -1
  41. package/dist/chunk-UEGKXCSQ.cjs +247 -0
  42. package/dist/chunk-UEGKXCSQ.cjs.map +1 -0
  43. package/dist/{chunk-N74AN6L5.cjs → chunk-WDIBO6AW.cjs} +91 -55
  44. package/dist/chunk-WDIBO6AW.cjs.map +1 -0
  45. package/dist/index.cjs +685 -454
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.js +428 -197
  48. package/dist/index.js.map +1 -1
  49. package/dist/test/index.cjs +13 -9
  50. package/dist/test/index.cjs.map +1 -1
  51. package/dist/test/index.js +11 -7
  52. package/dist/test/index.js.map +1 -1
  53. package/dist/types/index.cjs +2 -6
  54. package/dist/types/index.cjs.map +1 -1
  55. package/dist/types/index.js +3 -7
  56. package/package.json +1 -1
  57. package/dist/@types/sensitive.d.ts.map +0 -1
  58. package/dist/chunk-BQUOIHOR.js.map +0 -1
  59. package/dist/chunk-N74AN6L5.cjs.map +0 -1
  60. package/dist/chunk-SC6TY4P2.cjs.map +0 -1
  61. package/dist/chunk-ZTHGF62O.cjs +0 -303
  62. package/dist/chunk-ZTHGF62O.cjs.map +0 -1
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  store,
28
28
  unscoped_ports,
29
29
  validate
30
- } from "./chunk-Y2ISPWQL.js";
30
+ } from "./chunk-SCH4GLWM.js";
31
31
  import {
32
32
  checkAppends,
33
33
  checkVersion,
@@ -36,7 +36,7 @@ import {
36
36
  isStreamName,
37
37
  parseNotification,
38
38
  seedEvent
39
- } from "./chunk-RV34EYSN.js";
39
+ } from "./chunk-EIGZVFT7.js";
40
40
  import {
41
41
  ActorSchema,
42
42
  CausationEventSchema,
@@ -64,14 +64,9 @@ import {
64
64
  TargetSchema,
65
65
  ValidationError,
66
66
  ZodEmpty,
67
- def_of,
68
- inner_of,
69
- output_of,
70
- pii_fields,
71
- pii_schemas,
72
- sensitive,
73
- sensitiveFields
74
- } from "./chunk-BQUOIHOR.js";
67
+ __name,
68
+ sensitive
69
+ } from "./chunk-GDPBPAML.js";
75
70
 
76
71
  // src/signals.ts
77
72
  process.once("SIGINT", async (arg) => {
@@ -83,10 +78,12 @@ process.once("SIGTERM", async (arg) => {
83
78
  await disposeAndExit("EXIT");
84
79
  });
85
80
  process.once("uncaughtException", async (arg) => {
81
+ process.exitCode = 1;
86
82
  log().error(arg, "Uncaught Exception");
87
83
  await disposeAndExit("ERROR");
88
84
  });
89
85
  process.once("unhandledRejection", async (arg) => {
86
+ process.exitCode = 1;
90
87
  log().error(arg, "Unhandled Rejection");
91
88
  await disposeAndExit("ERROR");
92
89
  });
@@ -104,6 +101,7 @@ function parse(name) {
104
101
  }
105
102
  return { base: name, version: 1 };
106
103
  }
104
+ __name(parse, "parse");
107
105
  function deprecated_event_names(names) {
108
106
  const groups = /* @__PURE__ */ new Map();
109
107
  for (const name of names) {
@@ -129,6 +127,7 @@ function deprecated_event_names(names) {
129
127
  }
130
128
  return deprecated;
131
129
  }
130
+ __name(deprecated_event_names, "deprecated_event_names");
132
131
  function current_version_of(deprecated_name, all_names) {
133
132
  const target = parse(deprecated_name);
134
133
  let highest;
@@ -139,6 +138,7 @@ function current_version_of(deprecated_name, all_names) {
139
138
  }
140
139
  return highest && highest.version > target.version ? highest.name : void 0;
141
140
  }
141
+ __name(current_version_of, "current_version_of");
142
142
 
143
143
  // src/internal/walk-streams.ts
144
144
  var DEFAULT_STREAM_PAGE = 500;
@@ -160,6 +160,7 @@ async function walk_streams(store2, callback, query) {
160
160
  after = last;
161
161
  }
162
162
  }
163
+ __name(walk_streams, "walk_streams");
163
164
 
164
165
  // src/internal/audit.ts
165
166
  var DEFAULTS = {
@@ -224,6 +225,7 @@ async function* audit(deps, categories, options = {}) {
224
225
  for (const f of p.drain()) yield f;
225
226
  }
226
227
  }
228
+ __name(audit, "audit");
227
229
  async function scan_events_resiliently(deps, query, on_event, on_unreadable) {
228
230
  let cursor = query?.after;
229
231
  let remaining = query?.limit;
@@ -259,7 +261,8 @@ async function scan_events_resiliently(deps, query, on_event, on_unreadable) {
259
261
  }
260
262
  }
261
263
  }
262
- var make_schema_pass = (deps) => {
264
+ __name(scan_events_resiliently, "scan_events_resiliently");
265
+ var make_schema_pass = /* @__PURE__ */ __name((deps) => {
263
266
  const findings = [];
264
267
  return {
265
268
  category: "schema",
@@ -278,7 +281,7 @@ var make_schema_pass = (deps) => {
278
281
  return;
279
282
  }
280
283
  const schema = state2.events[name];
281
- const sensitive2 = sensitiveFields(schema);
284
+ const sensitive2 = deps.sensitive_fields(name);
282
285
  let parse_schema = schema;
283
286
  if (sensitive2.length > 0) {
284
287
  const omitter = schema.omit;
@@ -302,10 +305,10 @@ var make_schema_pass = (deps) => {
302
305
  });
303
306
  }
304
307
  },
305
- drain: () => findings
308
+ drain: /* @__PURE__ */ __name(() => findings, "drain")
306
309
  };
307
- };
308
- var classify_deprecated_by_state = (deps) => {
310
+ }, "make_schema_pass");
311
+ var classify_deprecated_by_state = /* @__PURE__ */ __name((deps) => {
309
312
  const names_by_state = /* @__PURE__ */ new Map();
310
313
  for (const [name, state2] of deps.event_to_state) {
311
314
  let set = names_by_state.get(state2);
@@ -322,8 +325,8 @@ var classify_deprecated_by_state = (deps) => {
322
325
  }
323
326
  }
324
327
  return deprecated_to_current;
325
- };
326
- var make_deprecated_load_pass = (deps, options) => {
328
+ }, "classify_deprecated_by_state");
329
+ var make_deprecated_load_pass = /* @__PURE__ */ __name((deps, options) => {
327
330
  const share_min = options.thresholds?.deprecated_min ?? DEFAULTS.deprecated_min;
328
331
  const totals = /* @__PURE__ */ new Map();
329
332
  const per_stream = /* @__PURE__ */ new Map();
@@ -362,8 +365,8 @@ var make_deprecated_load_pass = (deps, options) => {
362
365
  return findings;
363
366
  }
364
367
  };
365
- };
366
- var make_close_candidate_pass = (deps, options) => {
368
+ }, "make_deprecated_load_pass");
369
+ var make_close_candidate_pass = /* @__PURE__ */ __name((deps, options) => {
367
370
  const idle_days = options.thresholds?.idle_days ?? DEFAULTS.idle_days;
368
371
  const terminal_events = new Set(options.thresholds?.terminal_events ?? []);
369
372
  const idle_cutoff = Date.now() - idle_days * 24 * 60 * 60 * 1e3;
@@ -386,10 +389,10 @@ var make_close_candidate_pass = (deps, options) => {
386
389
  restart_supported: restart_is_supported(deps, head_name)
387
390
  });
388
391
  },
389
- drain: () => findings
392
+ drain: /* @__PURE__ */ __name(() => findings, "drain")
390
393
  };
391
- };
392
- var make_restart_candidate_pass = (deps, options) => {
394
+ }, "make_close_candidate_pass");
395
+ var make_restart_candidate_pass = /* @__PURE__ */ __name((deps, options) => {
393
396
  const threshold = options.thresholds?.restart_min ?? DEFAULTS.restart_min;
394
397
  const candidates = [];
395
398
  const findings = [];
@@ -426,10 +429,10 @@ var make_restart_candidate_pass = (deps, options) => {
426
429
  });
427
430
  }
428
431
  },
429
- drain: () => findings
432
+ drain: /* @__PURE__ */ __name(() => findings, "drain")
430
433
  };
431
- };
432
- var make_reaction_health_pass = (_deps, options) => {
434
+ }, "make_restart_candidate_pass");
435
+ var make_reaction_health_pass = /* @__PURE__ */ __name((_deps, options) => {
433
436
  const near_block = options.thresholds?.near_block ?? DEFAULTS.near_block;
434
437
  const stuck_minutes = options.thresholds?.stuck_minutes ?? DEFAULTS.stuck_minutes;
435
438
  const stuck_cutoff = Date.now() - stuck_minutes * 60 * 1e3;
@@ -470,10 +473,10 @@ var make_reaction_health_pass = (_deps, options) => {
470
473
  });
471
474
  }
472
475
  },
473
- drain: () => findings
476
+ drain: /* @__PURE__ */ __name(() => findings, "drain")
474
477
  };
475
- };
476
- var make_snapshot_drift_pass = (deps, options) => {
478
+ }, "make_reaction_health_pass");
479
+ var make_snapshot_drift_pass = /* @__PURE__ */ __name((deps, options) => {
477
480
  const drift_min = options.thresholds?.drift_min ?? DEFAULTS.drift_min;
478
481
  const candidates = [];
479
482
  const findings = [];
@@ -525,10 +528,10 @@ var make_snapshot_drift_pass = (deps, options) => {
525
528
  });
526
529
  }
527
530
  },
528
- drain: () => findings
531
+ drain: /* @__PURE__ */ __name(() => findings, "drain")
529
532
  };
530
- };
531
- var make_routing_health_pass = (deps) => {
533
+ }, "make_snapshot_drift_pass");
534
+ var make_routing_health_pass = /* @__PURE__ */ __name((deps) => {
532
535
  const findings = [];
533
536
  const seen_event_names = /* @__PURE__ */ new Set();
534
537
  return {
@@ -560,10 +563,10 @@ var make_routing_health_pass = (deps) => {
560
563
  }
561
564
  return Promise.resolve();
562
565
  },
563
- drain: () => findings
566
+ drain: /* @__PURE__ */ __name(() => findings, "drain")
564
567
  };
565
- };
566
- var make_correlation_gaps_pass = () => {
568
+ }, "make_routing_health_pass");
569
+ var make_correlation_gaps_pass = /* @__PURE__ */ __name(() => {
567
570
  const seen_ids = /* @__PURE__ */ new Set();
568
571
  const checks = [];
569
572
  return {
@@ -591,8 +594,8 @@ var make_correlation_gaps_pass = () => {
591
594
  return findings;
592
595
  }
593
596
  };
594
- };
595
- var make_clock_anomalies_pass = () => {
597
+ }, "make_correlation_gaps_pass");
598
+ var make_clock_anomalies_pass = /* @__PURE__ */ __name(() => {
596
599
  const findings = [];
597
600
  const last_per_stream = /* @__PURE__ */ new Map();
598
601
  return {
@@ -618,13 +621,14 @@ var make_clock_anomalies_pass = () => {
618
621
  }
619
622
  last_per_stream.set(e.stream, created);
620
623
  },
621
- drain: () => findings
624
+ drain: /* @__PURE__ */ __name(() => findings, "drain")
622
625
  };
623
- };
626
+ }, "make_clock_anomalies_pass");
624
627
  function restart_is_supported(deps, head_event_name) {
625
628
  const state2 = deps.event_to_state.get(head_event_name);
626
629
  return state2?.snap !== void 0;
627
630
  }
631
+ __name(restart_is_supported, "restart_is_supported");
628
632
  function make_unreadable_events_pass() {
629
633
  const findings = [];
630
634
  return {
@@ -638,9 +642,10 @@ function make_unreadable_events_pass() {
638
642
  error
639
643
  });
640
644
  },
641
- drain: () => findings
645
+ drain: /* @__PURE__ */ __name(() => findings, "drain")
642
646
  };
643
647
  }
648
+ __name(make_unreadable_events_pass, "make_unreadable_events_pass");
644
649
  var PASS_FACTORIES = {
645
650
  schema: make_schema_pass,
646
651
  "deprecated-load": make_deprecated_load_pass,
@@ -656,6 +661,9 @@ var PASS_FACTORIES = {
656
661
 
657
662
  // src/internal/circuit-breaker.ts
658
663
  var CircuitBreaker = class {
664
+ static {
665
+ __name(this, "CircuitBreaker");
666
+ }
659
667
  _failures = 0;
660
668
  _opened_at;
661
669
  _wake;
@@ -747,7 +755,7 @@ var CircuitBreaker = class {
747
755
 
748
756
  // src/internal/classify.ts
749
757
  var ALL_LANES = /* @__PURE__ */ Symbol("act/all-lanes");
750
- var describe_source = (source) => source === void 0 ? "no source (every stream)" : `"${source}"`;
758
+ var describe_source = /* @__PURE__ */ __name((source) => source === void 0 ? "no source (every stream)" : `"${source}"`, "describe_source");
751
759
  function classify_registry(registry, states) {
752
760
  const statics = /* @__PURE__ */ new Map();
753
761
  const target_lanes = /* @__PURE__ */ new Map();
@@ -798,33 +806,41 @@ function classify_registry(registry, states) {
798
806
  event_to_lanes
799
807
  };
800
808
  }
809
+ __name(classify_registry, "classify_registry");
801
810
 
802
811
  // src/internal/autoclose-policy.ts
803
812
  var DAY_MS = 864e5;
804
813
  function days_after(date, days) {
805
814
  return new Date(date.getTime() + days * DAY_MS);
806
815
  }
816
+ __name(days_after, "days_after");
807
817
  function days_before_now(days) {
808
818
  return new Date(Date.now() - days * DAY_MS);
809
819
  }
820
+ __name(days_before_now, "days_before_now");
810
821
  function compile_after(after) {
811
822
  return (_stream, head) => days_after(head.created, after.days) <= /* @__PURE__ */ new Date();
812
823
  }
824
+ __name(compile_after, "compile_after");
813
825
  function compile_is(is) {
814
826
  const set = new Set(typeof is === "string" ? [is] : is);
815
827
  return (_stream, head) => set.has(head.name);
816
828
  }
829
+ __name(compile_is, "compile_is");
817
830
  function compile_reaches(reaches) {
818
831
  return (_stream, _head, count) => count >= reaches;
819
832
  }
833
+ __name(compile_reaches, "compile_reaches");
820
834
  function policy_after_windows(options) {
821
835
  const parsed = check("autoclose_policy", options);
822
836
  return [parsed.after, parsed.or?.after].flatMap((w) => w ? [w.days] : []);
823
837
  }
838
+ __name(policy_after_windows, "policy_after_windows");
824
839
  function policy_keep_days(options) {
825
840
  const parsed = check("autoclose_policy", options);
826
841
  return parsed.keep?.days;
827
842
  }
843
+ __name(policy_keep_days, "policy_keep_days");
828
844
  function compile_autoclose_policy(options) {
829
845
  const parsed = check("autoclose_policy", options);
830
846
  const and_preds = [];
@@ -847,6 +863,7 @@ function compile_autoclose_policy(options) {
847
863
  return false;
848
864
  };
849
865
  }
866
+ __name(compile_autoclose_policy, "compile_autoclose_policy");
850
867
 
851
868
  // src/internal/autoclose-window.ts
852
869
  function hour_in_zone(now, timeZone) {
@@ -857,20 +874,24 @@ function hour_in_zone(now, timeZone) {
857
874
  }).formatToParts(now);
858
875
  return Number(parts.find((p) => p.type === "hour")?.value);
859
876
  }
877
+ __name(hour_in_zone, "hour_in_zone");
860
878
  function hour_in_range(hour, start, end) {
861
879
  return start < end ? hour >= start && hour < end : hour >= start || hour < end;
862
880
  }
881
+ __name(hour_in_range, "hour_in_range");
863
882
  function is_dst_gap_open(now, timeZone, start) {
864
883
  const hour = hour_in_zone(now, timeZone);
865
884
  if (hour <= start) return false;
866
885
  const prev = hour_in_zone(new Date(now.getTime() - 36e5), timeZone);
867
886
  return prev === start - 1 && hour === start + 1;
868
887
  }
888
+ __name(is_dst_gap_open, "is_dst_gap_open");
869
889
  function in_autoclose_window(window, now) {
870
890
  if (!window) return true;
871
891
  const hour = hour_in_zone(now, window.timeZone);
872
892
  return hour_in_range(hour, window.start, window.end) || is_dst_gap_open(now, window.timeZone, window.start);
873
893
  }
894
+ __name(in_autoclose_window, "in_autoclose_window");
874
895
  function next_window_open(window, now) {
875
896
  const start_ms = now.getTime();
876
897
  for (let h = 0; h <= 48; h++) {
@@ -885,26 +906,30 @@ function next_window_open(window, now) {
885
906
  }
886
907
  return new Date(start_ms + 864e5);
887
908
  }
909
+ __name(next_window_open, "next_window_open");
888
910
 
889
911
  // src/internal/defer-config.ts
890
912
  function duration_ms(d) {
891
913
  return (d.days ?? 0) * 864e5 + (d.hours ?? 0) * 36e5 + (d.minutes ?? 0) * 6e4;
892
914
  }
915
+ __name(duration_ms, "duration_ms");
893
916
  function resolve_defer_at(when, event) {
894
917
  const parsed = check("defer", when);
895
918
  if (parsed.after) return event.created.getTime() + duration_ms(parsed.after);
896
919
  return parsed.at.getTime();
897
920
  }
921
+ __name(resolve_defer_at, "resolve_defer_at");
898
922
  function make_deferred(handler, schedule) {
899
923
  const call = handler;
900
- const deferred = async (event, stream, app) => {
924
+ const deferred = /* @__PURE__ */ __name(async (event, stream, app) => {
901
925
  const when = typeof schedule === "function" ? schedule(event) : schedule;
902
926
  if (Date.now() < resolve_defer_at(when, event)) throw new DeferSignal(when);
903
927
  return call(event, stream, app);
904
- };
928
+ }, "deferred");
905
929
  Object.defineProperty(deferred, "name", { value: handler.name });
906
930
  return deferred;
907
931
  }
932
+ __name(make_deferred, "make_deferred");
908
933
 
909
934
  // src/internal/drain-cycle.ts
910
935
  import { randomUUID } from "crypto";
@@ -933,10 +958,14 @@ function compute_backoff_delay(retry, opts) {
933
958
  if (opts.jitter) delay = delay * (0.5 + Math.random());
934
959
  return Math.max(0, Math.floor(delay));
935
960
  }
961
+ __name(compute_backoff_delay, "compute_backoff_delay");
936
962
 
937
963
  // src/internal/defer-timer.ts
938
964
  var MAX_TIMER_DELAY_MS = 2147483647;
939
965
  var DeferTimer = class {
966
+ static {
967
+ __name(this, "DeferTimer");
968
+ }
940
969
  _due = /* @__PURE__ */ new Map();
941
970
  _timer;
942
971
  _on_wake;
@@ -1026,6 +1055,7 @@ function compute_lag_lead_ratio(handled, lagging, leading) {
1026
1055
  if (total === 0) return RATIO_DEFAULT;
1027
1056
  return Math.max(RATIO_MIN, Math.min(RATIO_MAX, lagging_avg / total));
1028
1057
  }
1058
+ __name(compute_lag_lead_ratio, "compute_lag_lead_ratio");
1029
1059
 
1030
1060
  // src/internal/report-once.ts
1031
1061
  function report_once(seen, key, message) {
@@ -1033,6 +1063,7 @@ function report_once(seen, key, message) {
1033
1063
  seen.add(key);
1034
1064
  log().error(new Error(message));
1035
1065
  }
1066
+ __name(report_once, "report_once");
1036
1067
 
1037
1068
  // src/internal/correlation-id.ts
1038
1069
  import { randomInt } from "crypto";
@@ -1042,13 +1073,14 @@ var SEG_SPACE = BASE ** SEG_WIDTH;
1042
1073
  function seg(n) {
1043
1074
  return n.toString(BASE).padStart(SEG_WIDTH, "0");
1044
1075
  }
1045
- var default_correlator = ({ state: state2, action: action2 }) => {
1076
+ __name(seg, "seg");
1077
+ var default_correlator = /* @__PURE__ */ __name(({ state: state2, action: action2 }) => {
1046
1078
  const s = state2.slice(0, SEG_WIDTH).toLowerCase();
1047
1079
  const a = action2.slice(0, SEG_WIDTH).toLowerCase();
1048
1080
  const ts = seg(Date.now() % SEG_SPACE);
1049
1081
  const rnd = seg(randomInt(SEG_SPACE));
1050
1082
  return `${s}-${a}-${ts}${rnd}`;
1051
- };
1083
+ }, "default_correlator");
1052
1084
  function close_correlation(correlator, actor) {
1053
1085
  return correlator({
1054
1086
  state: "$close",
@@ -1057,9 +1089,10 @@ function close_correlation(correlator, actor) {
1057
1089
  actor
1058
1090
  });
1059
1091
  }
1092
+ __name(close_correlation, "close_correlation");
1060
1093
 
1061
1094
  // src/internal/drain-ops.ts
1062
- var claim = (lagging, leading, by, millis, lane) => store().claim(lagging, leading, by, millis, lane);
1095
+ var claim = /* @__PURE__ */ __name((lagging, leading, by, millis, lane) => store().claim(lagging, leading, by, millis, lane), "claim");
1063
1096
  async function fetch(leased, eventLimit) {
1064
1097
  return Promise.all(
1065
1098
  leased.map(async ({ stream, source, at, lagging }) => {
@@ -1086,9 +1119,10 @@ async function fetch(leased, eventLimit) {
1086
1119
  })
1087
1120
  );
1088
1121
  }
1089
- var ack = (leases) => store().ack(leases);
1090
- var block = (leases) => store().block(leases);
1091
- var subscribe = (streams, correlated_at, correlator) => store().subscribe(streams, correlated_at, correlator);
1122
+ __name(fetch, "fetch");
1123
+ var ack = /* @__PURE__ */ __name((leases) => store().ack(leases), "ack");
1124
+ var block = /* @__PURE__ */ __name((leases) => store().block(leases), "block");
1125
+ var subscribe = /* @__PURE__ */ __name((streams, correlated_at, correlator) => store().subscribe(streams, correlated_at, correlator), "subscribe");
1092
1126
 
1093
1127
  // src/internal/event-sourcing.ts
1094
1128
  import { patch } from "@rotorsoft/act-patch";
@@ -1096,6 +1130,55 @@ import { prettifyError, ZodError } from "zod";
1096
1130
 
1097
1131
  // src/internal/date-reviver.ts
1098
1132
  import { z } from "zod";
1133
+
1134
+ // src/internal/zod.ts
1135
+ var def_of = /* @__PURE__ */ __name((schema) => schema?._zod?.def, "def_of");
1136
+ var SINGLE_INNER = [
1137
+ "optional",
1138
+ "nullable",
1139
+ "default",
1140
+ "prefault",
1141
+ "nonoptional",
1142
+ "readonly",
1143
+ "catch"
1144
+ ];
1145
+ var inner_of = /* @__PURE__ */ __name((def) => SINGLE_INNER.includes(def.type) ? def.innerType : void 0, "inner_of");
1146
+ function wrapped(schema) {
1147
+ const def = def_of(schema);
1148
+ if (!def) return [];
1149
+ if (def.type === "pipe") return [def.in, def.out];
1150
+ if (def.type === "lazy") return [def.getter()];
1151
+ const inner = inner_of(def);
1152
+ return inner ? [inner] : [];
1153
+ }
1154
+ __name(wrapped, "wrapped");
1155
+ function some_layer(schema, test) {
1156
+ const seen = /* @__PURE__ */ new Set();
1157
+ const visit = /* @__PURE__ */ __name((s) => {
1158
+ if (seen.has(s)) return false;
1159
+ seen.add(s);
1160
+ const def = def_of(s);
1161
+ return !!def && (test(def) || wrapped(s).some(visit));
1162
+ }, "visit");
1163
+ return visit(schema);
1164
+ }
1165
+ __name(some_layer, "some_layer");
1166
+ function output_of(schema) {
1167
+ const seen = /* @__PURE__ */ new Set();
1168
+ let cur = schema;
1169
+ while (!seen.has(cur)) {
1170
+ seen.add(cur);
1171
+ const def = def_of(cur);
1172
+ if (!def) return cur;
1173
+ const next = def.type === "pipe" ? def.out : wrapped(cur)[0];
1174
+ if (!next) return cur;
1175
+ cur = next;
1176
+ }
1177
+ return cur;
1178
+ }
1179
+ __name(output_of, "output_of");
1180
+
1181
+ // src/internal/date-reviver.ts
1099
1182
  function variant_schema(schema, walk) {
1100
1183
  const shape = def_of(schema)?.shape;
1101
1184
  if (!shape) {
@@ -1111,12 +1194,13 @@ function variant_schema(schema, walk) {
1111
1194
  }
1112
1195
  return { schema: z.looseObject(next), dated };
1113
1196
  }
1197
+ __name(variant_schema, "variant_schema");
1114
1198
  function date_reviver_schema(schema) {
1115
1199
  let recursive = false;
1116
- const pass = (tie) => {
1200
+ const pass = /* @__PURE__ */ __name((tie) => {
1117
1201
  const done = /* @__PURE__ */ new Map();
1118
1202
  const active = /* @__PURE__ */ new Set();
1119
- const walk = (node) => {
1203
+ const walk = /* @__PURE__ */ __name((node) => {
1120
1204
  if (done.has(node)) return done.get(node);
1121
1205
  if (active.has(node)) {
1122
1206
  recursive = true;
@@ -1127,16 +1211,17 @@ function date_reviver_schema(schema) {
1127
1211
  active.delete(node);
1128
1212
  done.set(node, result);
1129
1213
  return result;
1130
- };
1214
+ }, "walk");
1131
1215
  return walk(schema);
1132
- };
1216
+ }, "pass");
1133
1217
  const first = pass(false);
1134
1218
  return first && recursive ? pass(true) : first;
1135
1219
  }
1220
+ __name(date_reviver_schema, "date_reviver_schema");
1136
1221
  function build(schema, walk) {
1137
1222
  const def = def_of(schema);
1138
1223
  if (!def) return void 0;
1139
- const inner = () => walk(def.innerType);
1224
+ const inner = /* @__PURE__ */ __name(() => walk(def.innerType), "inner");
1140
1225
  switch (def.type) {
1141
1226
  case "date":
1142
1227
  return z.coerce.date();
@@ -1183,14 +1268,15 @@ function build(schema, walk) {
1183
1268
  return inner_of(def) ? inner() : void 0;
1184
1269
  }
1185
1270
  }
1271
+ __name(build, "build");
1186
1272
 
1187
1273
  // src/internal/event-sourcing.ts
1188
- var bare_patch = (_me, state2, partial) => patch(state2, partial);
1189
- var value_at = (value, path) => path.reduce(
1274
+ var bare_patch = /* @__PURE__ */ __name((_me, state2, partial) => patch(state2, partial), "bare_patch");
1275
+ var value_at = /* @__PURE__ */ __name((value, path) => path.reduce(
1190
1276
  (at, key) => at?.[key],
1191
1277
  value
1192
- );
1193
- var check_invariants = (target, state2, schema, pii_aware) => {
1278
+ ), "value_at");
1279
+ var check_invariants = /* @__PURE__ */ __name((target, state2, schema, pii_aware) => {
1194
1280
  let result;
1195
1281
  try {
1196
1282
  result = schema.safeParse(state2);
@@ -1208,20 +1294,20 @@ var check_invariants = (target, state2, schema, pii_aware) => {
1208
1294
  state2,
1209
1295
  prettifyError(new ZodError(issues))
1210
1296
  );
1211
- };
1297
+ }, "check_invariants");
1212
1298
  var DEFAULT_BATCH = 500;
1213
- var cache_put = (stream, entry) => cache().set(stream, entry).catch(
1299
+ var cache_put = /* @__PURE__ */ __name((stream, entry) => cache().set(stream, entry).catch(
1214
1300
  (err) => log().warn(
1215
1301
  err,
1216
1302
  "cache set skipped; the next load re-folds from the store"
1217
1303
  )
1218
- );
1219
- var cache_drop = (stream) => cache().invalidate(stream).catch(
1304
+ ), "cache_put");
1305
+ var cache_drop = /* @__PURE__ */ __name((stream) => cache().invalidate(stream).catch(
1220
1306
  (err) => log().warn(
1221
1307
  err,
1222
1308
  "cache invalidate skipped; a stale checkpoint re-folds from its event_id"
1223
1309
  )
1224
- );
1310
+ ), "cache_drop");
1225
1311
  async function snap(snapshot) {
1226
1312
  const { id, stream, name, meta, version } = snapshot.event;
1227
1313
  try {
@@ -1247,6 +1333,7 @@ async function snap(snapshot) {
1247
1333
  );
1248
1334
  }
1249
1335
  }
1336
+ __name(snap, "snap");
1250
1337
  async function tombstone(stream, expectedVersion, correlation) {
1251
1338
  try {
1252
1339
  const [committed] = await store().commit(
@@ -1265,12 +1352,14 @@ async function tombstone(stream, expectedVersion, correlation) {
1265
1352
  throw error;
1266
1353
  }
1267
1354
  }
1355
+ __name(tombstone, "tombstone");
1268
1356
  function is_valid(event) {
1269
1357
  if (event.version < 0) return false;
1270
1358
  if (!(event.created instanceof Date) || Number.isNaN(event.created.getTime()))
1271
1359
  return false;
1272
1360
  return true;
1273
1361
  }
1362
+ __name(is_valid, "is_valid");
1274
1363
  async function scan(source, opts = {}, callback) {
1275
1364
  const {
1276
1365
  drop_snapshots = false,
@@ -1402,6 +1491,7 @@ async function scan(source, opts = {}, callback) {
1402
1491
  }
1403
1492
  };
1404
1493
  }
1494
+ __name(scan, "scan");
1405
1495
  async function load(me, target, callback, patch_fn = bare_patch) {
1406
1496
  const { stream, actor, asOf } = target;
1407
1497
  const time_travel = !!asOf && Object.values(asOf).some((v) => v !== void 0);
@@ -1478,6 +1568,7 @@ async function load(me, target, callback, patch_fn = bare_patch) {
1478
1568
  replayed
1479
1569
  };
1480
1570
  }
1571
+ __name(load, "load");
1481
1572
  async function load_others(loads, payload, own, actor, patch_fn, refuse) {
1482
1573
  const streams = loads.map((l) => l.target(payload, own.state));
1483
1574
  streams.forEach((stream, i) => {
@@ -1510,6 +1601,7 @@ async function load_others(loads, payload, own, actor, patch_fn, refuse) {
1510
1601
  })
1511
1602
  );
1512
1603
  }
1604
+ __name(load_others, "load_others");
1513
1605
  async function action(me, action2, target, payload, options, patch_fn = bare_patch) {
1514
1606
  const { stream, expectedVersion, actor } = target;
1515
1607
  if (!stream) throw new Error("Missing target stream");
@@ -1695,6 +1787,7 @@ async function action(me, action2, target, payload, options, patch_fn = bare_pat
1695
1787
  }
1696
1788
  }
1697
1789
  }
1790
+ __name(action, "action");
1698
1791
 
1699
1792
  // src/internal/tracing.ts
1700
1793
  var PRETTY = config().env !== "production";
@@ -1706,32 +1799,32 @@ var C_DRAIN = "\x1B[38;5;244m";
1706
1799
  var C_HIT = "\x1B[38;5;82m";
1707
1800
  var C_MISS = "\x1B[38;5;220m";
1708
1801
  var C_RESET = "\x1B[0m";
1709
- var es_caption = (caption, color, body) => PRETTY ? `${color}${body}${C_RESET}` : `${caption}: ${body}`;
1802
+ var es_caption = /* @__PURE__ */ __name((caption, color, body) => PRETTY ? `${color}${body}${C_RESET}` : `${caption}: ${body}`, "es_caption");
1710
1803
  var C_LANE = "\x1B[38;5;183m";
1711
1804
  var C_DIM = "\x1B[38;5;240m";
1712
1805
  var C_ERR = "\x1B[38;5;196m";
1713
1806
  var C_STREAM = "\x1B[38;5;226m";
1714
- var dim = (text) => PRETTY ? `${C_DIM}${text}${C_RESET}` : text;
1715
- var hue = (color, text) => PRETTY ? `${color}${text}${C_RESET}` : text;
1716
- var drain_caption = (caption, lane) => {
1807
+ var dim = /* @__PURE__ */ __name((text) => PRETTY ? `${C_DIM}${text}${C_RESET}` : text, "dim");
1808
+ var hue = /* @__PURE__ */ __name((color, text) => PRETTY ? `${color}${text}${C_RESET}` : text, "hue");
1809
+ var drain_caption = /* @__PURE__ */ __name((caption, lane) => {
1717
1810
  const show_lane = lane && lane !== "default";
1718
1811
  if (PRETTY) {
1719
1812
  const tag = `${C_DRAIN}>> ${caption}${C_RESET}`;
1720
1813
  return show_lane ? `${tag} ${C_LANE}${lane}${C_RESET}` : tag;
1721
1814
  }
1722
1815
  return show_lane ? `>> ${caption} ${lane}` : `>> ${caption}`;
1723
- };
1724
- var cache_marker = (hit) => {
1816
+ }, "drain_caption");
1817
+ var cache_marker = /* @__PURE__ */ __name((hit) => {
1725
1818
  const word = hit ? "hit" : "miss";
1726
1819
  if (!PRETTY) return word;
1727
1820
  return `${hit ? C_HIT : C_MISS}${word}${C_RESET}${C_GREEN}`;
1728
- };
1729
- var stats_marker = (version, replayed, snaps, patches) => {
1821
+ }, "cache_marker");
1822
+ var stats_marker = /* @__PURE__ */ __name((version, replayed, snaps, patches) => {
1730
1823
  const text = `v=${version} replayed=${replayed} snaps=${snaps} patches=${patches}`;
1731
1824
  if (!PRETTY) return text;
1732
1825
  return `${C_DRAIN}${text}${C_RESET}${C_GREEN}`;
1733
- };
1734
- var as_of_marker = (asOf) => {
1826
+ }, "stats_marker");
1827
+ var as_of_marker = /* @__PURE__ */ __name((asOf) => {
1735
1828
  if (!asOf) return "";
1736
1829
  const parts = [];
1737
1830
  if (asOf.before !== void 0) parts.push(`before=${asOf.before}`);
@@ -1741,23 +1834,23 @@ var as_of_marker = (asOf) => {
1741
1834
  parts.push(`created_after=${asOf.created_after.toISOString()}`);
1742
1835
  if (asOf.limit !== void 0) parts.push(`limit=${asOf.limit}`);
1743
1836
  return parts.length ? ` (as-of ${parts.join(" ")})` : " (as-of)";
1744
- };
1745
- var traced = (inner, exit, entry) => (async (...args) => {
1837
+ }, "as_of_marker");
1838
+ var traced = /* @__PURE__ */ __name((inner, exit, entry) => (async (...args) => {
1746
1839
  entry?.(...args);
1747
1840
  const result = await inner(...args);
1748
1841
  exit?.(result, ...args);
1749
1842
  return result;
1750
- });
1843
+ }), "traced");
1751
1844
  function build_es(logger, correlator = default_correlator, patch_fn = bare_patch) {
1752
- const bound_action = (me, action_name, target, payload, options) => action(
1845
+ const bound_action = /* @__PURE__ */ __name((me, action_name, target, payload, options) => action(
1753
1846
  me,
1754
1847
  action_name,
1755
1848
  target,
1756
1849
  payload,
1757
1850
  { ...options, correlator: options?.correlator ?? correlator },
1758
1851
  patch_fn
1759
- );
1760
- const bound_load = (me, target, callback) => load(me, target, callback, patch_fn);
1852
+ ), "bound_action");
1853
+ const bound_load = /* @__PURE__ */ __name((me, target, callback) => load(me, target, callback, patch_fn), "bound_load");
1761
1854
  if (logger.level !== "trace") {
1762
1855
  return {
1763
1856
  snap,
@@ -1819,6 +1912,7 @@ function build_es(logger, correlator = default_correlator, patch_fn = bare_patch
1819
1912
  })
1820
1913
  };
1821
1914
  }
1915
+ __name(build_es, "build_es");
1822
1916
  function build_drain(logger) {
1823
1917
  return {
1824
1918
  claim,
@@ -1838,6 +1932,7 @@ function build_drain(logger) {
1838
1932
  })
1839
1933
  };
1840
1934
  }
1935
+ __name(build_drain, "build_drain");
1841
1936
  function trace_cycle(logger, leased, fetched, handled, acked, blocked) {
1842
1937
  if (logger.level !== "trace" || !leased.length) return;
1843
1938
  const lane = leased[0]?.lane;
@@ -1875,6 +1970,7 @@ function trace_cycle(logger, leased, fetched, handled, acked, blocked) {
1875
1970
  }).join(", ");
1876
1971
  logger.trace(`${drain_caption("drained", lane)} ${detail}`);
1877
1972
  }
1973
+ __name(trace_cycle, "trace_cycle");
1878
1974
 
1879
1975
  // src/internal/drain-cycle.ts
1880
1976
  function budget_exhausted(lease, options, store_failing) {
@@ -1884,6 +1980,7 @@ function budget_exhausted(lease, options, store_failing) {
1884
1980
  log().error(error);
1885
1981
  return { lease, handled: 0, acked_at: lease.at, error, block: true };
1886
1982
  }
1983
+ __name(budget_exhausted, "budget_exhausted");
1887
1984
  function fetch_failure_policy(registry) {
1888
1985
  let blockOnError = true;
1889
1986
  let maxRetries = 0;
@@ -1894,6 +1991,7 @@ function fetch_failure_policy(registry) {
1894
1991
  }
1895
1992
  return { blockOnError, maxRetries };
1896
1993
  }
1994
+ __name(fetch_failure_policy, "fetch_failure_policy");
1897
1995
  function finalize(lease, handled, at, error, options, logger, failed_at) {
1898
1996
  if (!error) return { lease, handled, acked_at: at };
1899
1997
  logger.error(error);
@@ -1914,6 +2012,7 @@ function finalize(lease, handled, at, error, options, logger, failed_at) {
1914
2012
  failed_at
1915
2013
  };
1916
2014
  }
2015
+ __name(finalize, "finalize");
1917
2016
  function warn_misrouted(seen, stream, handler, event) {
1918
2017
  report_once(
1919
2018
  seen,
@@ -1921,6 +2020,7 @@ function warn_misrouted(seen, stream, handler, event) {
1921
2020
  `Reaction "${handler}" on "${event}" resolved to target "${stream}", which a projection already serves. A target is served by one batch handler or one state projection, so this reaction can never run \u2014 and delivering to it would hand the projection an aggregate from another stream. Skipping it. The equivalent static \`.to({ target })\` is rejected at build; a dynamic resolver's target is only knowable here.`
1922
2021
  );
1923
2022
  }
2023
+ __name(warn_misrouted, "warn_misrouted");
1924
2024
  async function run_drain_cycle(deps, cycle) {
1925
2025
  const { ops, registry, batch_handlers, handle, handle_batch, lane } = deps;
1926
2026
  const {
@@ -2037,6 +2137,7 @@ async function run_drain_cycle(deps, cycle) {
2037
2137
  const closeable = handled.filter((h) => h.close !== void 0).map((h) => h.close);
2038
2138
  return { leased, fetched, handled, acked, blocked, closeable };
2039
2139
  }
2140
+ __name(run_drain_cycle, "run_drain_cycle");
2040
2141
  var EMPTY_DRAIN = {
2041
2142
  fetched: [],
2042
2143
  leased: [],
@@ -2051,8 +2152,12 @@ function merge_drains(drains) {
2051
2152
  blocked: drains.flatMap((d) => d.blocked)
2052
2153
  };
2053
2154
  }
2155
+ __name(merge_drains, "merge_drains");
2054
2156
  var RETRY = "";
2055
2157
  var DrainController = class {
2158
+ static {
2159
+ __name(this, "DrainController");
2160
+ }
2056
2161
  // Armed while `_raised` is ahead of `_lowered` (the raise count the last
2057
2162
  // empty claim saw), so a claim never lowers over a raise that landed
2058
2163
  // during it.
@@ -2106,12 +2211,12 @@ var DrainController = class {
2106
2211
  */
2107
2212
  start(cycleMs) {
2108
2213
  const run = this._deps.run_scoped;
2109
- const tick = async () => {
2214
+ const tick = /* @__PURE__ */ __name(async () => {
2110
2215
  if (this.armed) await run(() => this.drain());
2111
2216
  if (this._stopped) return;
2112
2217
  this._worker = setTimeout(tick, cycleMs);
2113
2218
  this._worker.unref();
2114
- };
2219
+ }, "tick");
2115
2220
  this._worker = setTimeout(tick, cycleMs);
2116
2221
  this._worker.unref();
2117
2222
  }
@@ -2189,6 +2294,9 @@ var DrainController = class {
2189
2294
 
2190
2295
  // src/internal/reaction-dispatch.ts
2191
2296
  var CloseSignal = class extends Error {
2297
+ static {
2298
+ __name(this, "CloseSignal");
2299
+ }
2192
2300
  /**
2193
2301
  * Stream to close. Omitted → the reaction's own lease stream (a self-close).
2194
2302
  * The synthesized autoclose reaction sets it to the aggregate stream, since
@@ -2304,6 +2412,7 @@ function build_handle(deps) {
2304
2412
  return finalize(lease, handled, at, void 0, payloads[0].options, logger);
2305
2413
  };
2306
2414
  }
2415
+ __name(build_handle, "build_handle");
2307
2416
  function build_handle_batch(logger) {
2308
2417
  return async (lease, payloads, batchHandler) => {
2309
2418
  const stream = lease.stream;
@@ -2332,6 +2441,7 @@ function build_handle_batch(logger) {
2332
2441
  }
2333
2442
  };
2334
2443
  }
2444
+ __name(build_handle_batch, "build_handle_batch");
2335
2445
 
2336
2446
  // src/internal/autoclose-reaction.ts
2337
2447
  var AUTOCLOSE_TARGET_PREFIX = "__autoclose__:";
@@ -2352,14 +2462,14 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
2352
2462
  // An anchored stream name would read as a pattern, and a store may refuse
2353
2463
  // it at subscribe, stopping every reaction. Such a stream has no
2354
2464
  // autoclose: `app.close` still closes it.
2355
- resolver: (e) => isStreamName(e.stream) ? {
2465
+ resolver: /* @__PURE__ */ __name((e) => isStreamName(e.stream) ? {
2356
2466
  target: `${AUTOCLOSE_TARGET_PREFIX}${e.stream}`,
2357
2467
  source: e.stream
2358
- } : void 0,
2468
+ } : void 0, "resolver"),
2359
2469
  // Never block on autoclose: a transient query/store error should retry,
2360
2470
  // not quarantine the synthetic stream.
2361
2471
  options: { blockOnError: false, maxRetries: DEFAULT_MAX_RETRIES },
2362
- handler: async (event) => {
2472
+ handler: /* @__PURE__ */ __name(async (event) => {
2363
2473
  const aggregate = event.stream;
2364
2474
  const window = read_window();
2365
2475
  if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
@@ -2406,7 +2516,7 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
2406
2516
  const future = dues.map((d) => d.getTime()).filter((t) => t > Date.now());
2407
2517
  if (future.length)
2408
2518
  throw new DeferSignal({ at: new Date(Math.min(...future)) });
2409
- }
2519
+ }, "handler")
2410
2520
  };
2411
2521
  const key = `__autoclose_${st.name}`;
2412
2522
  for (const event_name of Object.keys(st.events)) {
@@ -2417,6 +2527,7 @@ function synthesize_autoclose_reactions(registry, states, read_window) {
2417
2527
  }
2418
2528
  }
2419
2529
  }
2530
+ __name(synthesize_autoclose_reactions, "synthesize_autoclose_reactions");
2420
2531
 
2421
2532
  // src/internal/close-cycle.ts
2422
2533
  var CLOSE_CATCH_UP_LIMIT = 1e3;
@@ -2430,16 +2541,20 @@ async function catch_up_correlation(cursor, correlate, until) {
2430
2541
  }
2431
2542
  return cursor.checkpoint;
2432
2543
  }
2544
+ __name(catch_up_correlation, "catch_up_correlation");
2433
2545
  var CloseLock = class {
2546
+ static {
2547
+ __name(this, "CloseLock");
2548
+ }
2434
2549
  _tails = /* @__PURE__ */ new Map();
2435
2550
  /** Run `work` after every earlier close of `stream` has settled. */
2436
2551
  run(stream, work) {
2437
2552
  const prev = this._tails.get(stream) ?? Promise.resolve();
2438
2553
  const next = prev.then(work, work);
2439
2554
  this._tails.set(stream, next);
2440
- const cleanup = () => {
2555
+ const cleanup = /* @__PURE__ */ __name(() => {
2441
2556
  if (this._tails.get(stream) === next) this._tails.delete(stream);
2442
- };
2557
+ }, "cleanup");
2443
2558
  next.then(cleanup, cleanup);
2444
2559
  return next;
2445
2560
  }
@@ -2470,6 +2585,7 @@ async function run_close_cycle(targets, deps) {
2470
2585
  for (const [stream, entry] of windowed_result) truncated.set(stream, entry);
2471
2586
  return { truncated, skipped };
2472
2587
  }
2588
+ __name(run_close_cycle, "run_close_cycle");
2473
2589
  function with_stream_locks(streams, deps, work) {
2474
2590
  const with_lock = deps.with_stream_lock ?? ((_stream, w) => w());
2475
2591
  return [...streams].sort().reduceRight(
@@ -2477,6 +2593,7 @@ function with_stream_locks(streams, deps, work) {
2477
2593
  work
2478
2594
  )();
2479
2595
  }
2596
+ __name(with_stream_locks, "with_stream_locks");
2480
2597
  async function run_full_closes(full, target_map, deps, skipped) {
2481
2598
  const none = /* @__PURE__ */ new Map();
2482
2599
  const streams = full.map((t) => t.stream);
@@ -2532,6 +2649,7 @@ async function run_full_closes(full, target_map, deps, skipped) {
2532
2649
  deps.correlation
2533
2650
  );
2534
2651
  }
2652
+ __name(run_full_closes, "run_full_closes");
2535
2653
  async function run_windowed_closes(windowed, deps, skipped) {
2536
2654
  const checkpoint = deps.reactive ? await deps.catch_up_correlation(Number.MAX_SAFE_INTEGER) : -1;
2537
2655
  const min_at = deps.reactive ? await probe_min_watermarks(
@@ -2557,6 +2675,7 @@ async function run_windowed_closes(windowed, deps, skipped) {
2557
2675
  }
2558
2676
  return truncated;
2559
2677
  }
2678
+ __name(run_windowed_closes, "run_windowed_closes");
2560
2679
  async function windowed_prune_pending(stream, before, max_id) {
2561
2680
  let boundary_id;
2562
2681
  let min_id;
@@ -2570,6 +2689,7 @@ async function windowed_prune_pending(stream, before, max_id) {
2570
2689
  );
2571
2690
  return boundary_id !== void 0 && min_id < boundary_id;
2572
2691
  }
2692
+ __name(windowed_prune_pending, "windowed_prune_pending");
2573
2693
  async function probe_min_watermarks(streams, page_size, checkpoint) {
2574
2694
  const min_at = /* @__PURE__ */ new Map();
2575
2695
  const matches = source_matcher();
@@ -2589,6 +2709,7 @@ async function probe_min_watermarks(streams, page_size, checkpoint) {
2589
2709
  );
2590
2710
  return min_at;
2591
2711
  }
2712
+ __name(probe_min_watermarks, "probe_min_watermarks");
2592
2713
  function source_matcher() {
2593
2714
  const compiled = /* @__PURE__ */ new Map();
2594
2715
  return (source, target, stream) => {
@@ -2602,6 +2723,7 @@ function source_matcher() {
2602
2723
  return re.test(stream);
2603
2724
  };
2604
2725
  }
2726
+ __name(source_matcher, "source_matcher");
2605
2727
  async function scan_stream_heads(streams) {
2606
2728
  const stats = await store().query_stats(streams, {
2607
2729
  exclude: [SNAP_EVENT]
@@ -2623,6 +2745,7 @@ async function scan_stream_heads(streams) {
2623
2745
  }
2624
2746
  return out;
2625
2747
  }
2748
+ __name(scan_stream_heads, "scan_stream_heads");
2626
2749
  async function partition_by_safety(stream_info, reactive, skipped, page_size, catch_up_correlation2) {
2627
2750
  if (!reactive) return [...stream_info.keys()];
2628
2751
  let needed = -1;
@@ -2656,6 +2779,7 @@ async function partition_by_safety(stream_info, reactive, skipped, page_size, ca
2656
2779
  }
2657
2780
  return safe;
2658
2781
  }
2782
+ __name(partition_by_safety, "partition_by_safety");
2659
2783
  async function guard_with_tombstones(safe, stream_info, correlation, tombstone2, skipped) {
2660
2784
  const guarded = [];
2661
2785
  const guard_events = /* @__PURE__ */ new Map();
@@ -2678,6 +2802,7 @@ async function guard_with_tombstones(safe, stream_info, correlation, tombstone2,
2678
2802
  );
2679
2803
  return { guarded, guard_events };
2680
2804
  }
2805
+ __name(guard_with_tombstones, "guard_with_tombstones");
2681
2806
  async function load_restart_seeds(guarded, target_map, stream_info, event_to_state, load2, logger) {
2682
2807
  const seed_states = /* @__PURE__ */ new Map();
2683
2808
  await Promise.all(
@@ -2696,12 +2821,14 @@ async function load_restart_seeds(guarded, target_map, stream_info, event_to_sta
2696
2821
  );
2697
2822
  return seed_states;
2698
2823
  }
2824
+ __name(load_restart_seeds, "load_restart_seeds");
2699
2825
  async function run_archive_callbacks(guarded, target_map) {
2700
2826
  for (const stream of guarded) {
2701
2827
  const archive_fn = target_map.get(stream)?.archive;
2702
2828
  if (archive_fn) await archive_fn();
2703
2829
  }
2704
2830
  }
2831
+ __name(run_archive_callbacks, "run_archive_callbacks");
2705
2832
  async function heads_still_guarded(guarded, guard_events, skipped) {
2706
2833
  const heads = await store().query_stats(guarded, {});
2707
2834
  return guarded.filter((stream) => {
@@ -2711,6 +2838,7 @@ async function heads_still_guarded(guarded, guard_events, skipped) {
2711
2838
  return false;
2712
2839
  });
2713
2840
  }
2841
+ __name(heads_still_guarded, "heads_still_guarded");
2714
2842
  async function truncate_and_warm_cache(guarded, seed_states, guard_events, correlation) {
2715
2843
  const trunc_targets = guarded.map((stream) => {
2716
2844
  const snapshot = seed_states.get(stream);
@@ -2747,15 +2875,16 @@ async function truncate_and_warm_cache(guarded, seed_states, guard_events, corre
2747
2875
  );
2748
2876
  return truncated;
2749
2877
  }
2878
+ __name(truncate_and_warm_cache, "truncate_and_warm_cache");
2750
2879
 
2751
2880
  // src/internal/correlate-cycle.ts
2752
2881
  import { createHash, randomUUID as randomUUID2 } from "crypto";
2753
2882
  var COLD_START_BACK_SCAN = 1e4;
2754
2883
  var CORRELATION_LEASE_MS = 5e3;
2755
- var registry_key = (events) => {
2884
+ var registry_key = /* @__PURE__ */ __name((events) => {
2756
2885
  const shape = Object.keys(events).filter((name) => events[name].reactions.size > 0).sort().map((name) => [name, [...events[name].reactions.keys()].sort()]);
2757
2886
  return createHash("sha256").update(JSON.stringify(shape)).digest("hex").slice(0, 32);
2758
- };
2887
+ }, "registry_key");
2759
2888
  var PATTERN_CACHE_SIZE = 32;
2760
2889
  function report_undeclared_lane(seen, handler, target, lane, declared) {
2761
2890
  report_once(
@@ -2764,6 +2893,7 @@ function report_undeclared_lane(seen, handler, target, lane, declared) {
2764
2893
  `Reaction "${handler}" resolved onto undeclared lane "${lane}" \u2014 for example target "${target}". Declared lanes: ${[...declared].map((l) => `"${l}"`).join(", ")}. No controller claims it, so the stream would never drain \u2014 running it on "default" instead. The equivalent static \`.to({ lane })\` is rejected at build; a dynamic resolver's lane is only knowable here.`
2765
2894
  );
2766
2895
  }
2896
+ __name(report_undeclared_lane, "report_undeclared_lane");
2767
2897
  function report_bad_priority(seen, handler, target, priority) {
2768
2898
  report_once(
2769
2899
  seen,
@@ -2771,6 +2901,7 @@ function report_bad_priority(seen, handler, target, priority) {
2771
2901
  `Reaction "${handler}" resolved priority ${String(priority)} for target "${target}", which isn't a 32-bit integer. Running it at priority 0 instead. The equivalent static \`.to({ priority })\` is rejected at build; a dynamic resolver's priority is only knowable here.`
2772
2902
  );
2773
2903
  }
2904
+ __name(report_bad_priority, "report_bad_priority");
2774
2905
  function report_lane_conflict(seen, handler, target, kept, dropped) {
2775
2906
  report_once(
2776
2907
  seen,
@@ -2778,7 +2909,11 @@ function report_lane_conflict(seen, handler, target, kept, dropped) {
2778
2909
  `Reaction "${handler}" resolved lane "${dropped}" for a stream already on "${kept}" \u2014 for example "${target}". These are conflicting lane assignments from two dynamic resolutions at equal priority. Keeping "${kept}", the lane it was first discovered on \u2014 re-laning a live stream would move it out from under a worker holding its lease. The reaction resolving "${dropped}" runs inside the "${kept}" lane's budget, and a process restricted to "${dropped}" via onlyLanes never runs it. The equivalent static declaration is rejected at build; align the resolvers, or split the target.`
2779
2910
  );
2780
2911
  }
2912
+ __name(report_lane_conflict, "report_lane_conflict");
2781
2913
  var CorrelateCycle = class {
2914
+ static {
2915
+ __name(this, "CorrelateCycle");
2916
+ }
2782
2917
  _checkpoint = -1;
2783
2918
  // Lease holder id; per instance, so a restart never inherits a stale claim.
2784
2919
  _by = randomUUID2();
@@ -2898,10 +3033,10 @@ var CorrelateCycle = class {
2898
3033
  async _scan(limit, lease) {
2899
3034
  await this._init();
2900
3035
  const epoch = this._epoch;
2901
- const idle = () => ({
3036
+ const idle = /* @__PURE__ */ __name(() => ({
2902
3037
  kind: "idle",
2903
3038
  last_id: this._checkpoint
2904
- });
3039
+ }), "idle");
2905
3040
  if (this._raised === this._lowered) return idle();
2906
3041
  const raised = this._raised;
2907
3042
  const now = Date.now();
@@ -3109,6 +3244,7 @@ function pii_split(emitted, fields) {
3109
3244
  }
3110
3245
  return { name: emitted.name, data, pii };
3111
3246
  }
3247
+ __name(pii_split, "pii_split");
3112
3248
  function pii_gate(event, fields, predicate, actor) {
3113
3249
  const data = event.data;
3114
3250
  const { pii, ...rest } = event;
@@ -3128,10 +3264,12 @@ function pii_gate(event, fields, predicate, actor) {
3128
3264
  for (const f of fields) redacted[f] = REDACTED;
3129
3265
  return { ...rest, data: redacted };
3130
3266
  }
3131
- var IDENTITY_GATE = (event) => event;
3267
+ __name(pii_gate, "pii_gate");
3268
+ var IDENTITY_GATE = /* @__PURE__ */ __name((event) => event, "IDENTITY_GATE");
3132
3269
  function make_gate(fields, predicate) {
3133
3270
  return (event, actor) => pii_gate(event, fields, predicate, actor);
3134
3271
  }
3272
+ __name(make_gate, "make_gate");
3135
3273
  function pii_strip(event, fields) {
3136
3274
  const data = event.data;
3137
3275
  const stripped = {};
@@ -3144,21 +3282,22 @@ function pii_strip(event, fields) {
3144
3282
  data: stripped
3145
3283
  };
3146
3284
  }
3285
+ __name(pii_strip, "pii_strip");
3147
3286
 
3148
3287
  // src/internal/projection-fold.ts
3149
3288
  var FOLD_RESET = /* @__PURE__ */ Symbol("act.fold.reset");
3150
3289
  function make_fold_handler(me, flush, config2, sensitive_fields) {
3151
3290
  const load_me = {
3152
3291
  ...me,
3153
- view: (raw, actor) => {
3292
+ view: /* @__PURE__ */ __name((raw, actor) => {
3154
3293
  const viewed = me.view(raw, actor);
3155
3294
  const fields = sensitive_fields(viewed.name);
3156
3295
  return fields.length ? pii_strip(viewed, fields) : viewed;
3157
- }
3296
+ }, "view")
3158
3297
  };
3159
3298
  const cache2 = /* @__PURE__ */ new Map();
3160
- const row = ({ dirty: _, ...row2 }) => row2;
3161
- const flush_dirty = async () => {
3299
+ const row = /* @__PURE__ */ __name(({ dirty: _, ...row2 }) => row2, "row");
3300
+ const flush_dirty = /* @__PURE__ */ __name(async () => {
3162
3301
  const rows = [];
3163
3302
  const flushed = [];
3164
3303
  for (const f of cache2.values())
@@ -3169,8 +3308,8 @@ function make_fold_handler(me, flush, config2, sensitive_fields) {
3169
3308
  if (rows.length === 0) return;
3170
3309
  await flush(rows);
3171
3310
  for (const f of flushed) f.dirty = false;
3172
- };
3173
- const first_sight = async (stream) => {
3311
+ }, "flush_dirty");
3312
+ const first_sight = /* @__PURE__ */ __name(async (stream) => {
3174
3313
  if (cache2.size >= config2.maxCachedStates) {
3175
3314
  const oldest = cache2.keys().next().value;
3176
3315
  const evictee = cache2.get(oldest);
@@ -3189,8 +3328,8 @@ function make_fold_handler(me, flush, config2, sensitive_fields) {
3189
3328
  };
3190
3329
  cache2.set(stream, seated);
3191
3330
  return seated;
3192
- };
3193
- const handler = async (events) => {
3331
+ }, "first_sight");
3332
+ const handler = /* @__PURE__ */ __name(async (events) => {
3194
3333
  let folded_since_flush = 0;
3195
3334
  for (const event of events) {
3196
3335
  const stream = event.stream;
@@ -3227,13 +3366,17 @@ function make_fold_handler(me, flush, config2, sensitive_fields) {
3227
3366
  }
3228
3367
  }
3229
3368
  await flush_dirty();
3230
- };
3231
- Object.defineProperty(handler, FOLD_RESET, { value: () => cache2.clear() });
3369
+ }, "handler");
3370
+ Object.defineProperty(handler, FOLD_RESET, { value: /* @__PURE__ */ __name(() => cache2.clear(), "value") });
3232
3371
  return handler;
3233
3372
  }
3373
+ __name(make_fold_handler, "make_fold_handler");
3234
3374
 
3235
3375
  // src/internal/settle.ts
3236
3376
  var SettleLoop = class {
3377
+ static {
3378
+ __name(this, "SettleLoop");
3379
+ }
3237
3380
  _timer = void 0;
3238
3381
  // The cycle in flight, set while one runs. Shutdown waits for it
3239
3382
  // (`stop()` cancels scheduling only). Never rejects.
@@ -3334,6 +3477,9 @@ var SettleLoop = class {
3334
3477
 
3335
3478
  // src/act.ts
3336
3479
  var Act = class {
3480
+ static {
3481
+ __name(this, "Act");
3482
+ }
3337
3483
  _emitter = new EventEmitter();
3338
3484
  _breaker;
3339
3485
  _drain;
@@ -3449,6 +3595,7 @@ var Act = class {
3449
3595
  throw new Error(
3450
3596
  `ActOptions.onlyLanes references undeclared lane(s): ${undeclared.map((l) => `"${l}"`).join(", ")}`
3451
3597
  );
3598
+ check("act", options);
3452
3599
  if (options.scoped) check("store", options.scoped.store);
3453
3600
  this._ports = options.scoped ?? unscoped_ports();
3454
3601
  const ports = this._ports;
@@ -3506,10 +3653,10 @@ var Act = class {
3506
3653
  return new CircuitBreaker(
3507
3654
  check("circuit_breaker", options.circuitBreaker ?? {}),
3508
3655
  {
3509
- on_error: (error, circuit) => this._emit_error(error, circuit),
3656
+ on_error: /* @__PURE__ */ __name((error, circuit) => this._emit_error(error, circuit), "on_error"),
3510
3657
  // When the cooldown elapses, settle once: its scan or claim is the
3511
3658
  // half-open probe that closes or re-opens the breaker.
3512
- on_retry: () => this._schedule()
3659
+ on_retry: /* @__PURE__ */ __name(() => this._schedule(), "on_retry")
3513
3660
  }
3514
3661
  );
3515
3662
  }
@@ -3529,12 +3676,12 @@ var Act = class {
3529
3676
  batch_handlers: this._batch_handlers,
3530
3677
  handle,
3531
3678
  handle_batch,
3532
- on_acked: (acked) => this.emit("acked", acked),
3533
- on_blocked: (blocked) => this.emit("blocked", blocked),
3679
+ on_acked: /* @__PURE__ */ __name((acked) => this.emit("acked", acked), "on_acked"),
3680
+ on_blocked: /* @__PURE__ */ __name((blocked) => this.emit("blocked", blocked), "on_blocked"),
3534
3681
  // Reaction-requested close: the same machinery as `app.close`.
3535
3682
  // A store failure reaches the breaker; anything else (the archive
3536
3683
  // callback is app code) is logged here, never counted.
3537
- on_close: async (targets) => {
3684
+ on_close: /* @__PURE__ */ __name(async (targets) => {
3538
3685
  try {
3539
3686
  await this._run_close(targets);
3540
3687
  } catch (error) {
@@ -3544,7 +3691,7 @@ var Act = class {
3544
3691
  `Reaction-requested close of ${targets.map((t) => `"${t.stream}"`).join(", ")} failed; the policy retries it (a full close the next day, a prune on the stream's next commit), or close it now with app.close(...) once the cause is fixed.`
3545
3692
  );
3546
3693
  }
3547
- },
3694
+ }, "on_close"),
3548
3695
  breaker: this._breaker,
3549
3696
  run_scoped: this._scoped,
3550
3697
  lane: single_default_lane ? void 0 : name,
@@ -3574,6 +3721,7 @@ var Act = class {
3574
3721
  return {
3575
3722
  store,
3576
3723
  event_to_state: this._event_to_state,
3724
+ sensitive_fields: this.registry.sensitive_fields,
3577
3725
  // Declared lanes, not this process's controllers: a lane another
3578
3726
  // worker drains is not `unknown-lane`.
3579
3727
  declared_lanes: new Set(this._declared_lanes),
@@ -3592,10 +3740,10 @@ var Act = class {
3592
3740
  // Built after the controllers, so their keys are the active lanes.
3593
3741
  shard: this._drain_controllers.size < this._declared_lanes.length ? [...this._drain_controllers.keys()] : void 0,
3594
3742
  // Only reached on a draining app: writer-only ones never correlate.
3595
- on_init: async () => {
3743
+ on_init: /* @__PURE__ */ __name(async () => {
3596
3744
  this._arm_all();
3597
3745
  await this._seed_persisted_defers();
3598
- }
3746
+ }, "on_init")
3599
3747
  });
3600
3748
  }
3601
3749
  // Cold start: an idle deferred stream still fires on time after a restart.
@@ -3610,11 +3758,11 @@ var Act = class {
3610
3758
  _build_settle(options) {
3611
3759
  return new SettleLoop(
3612
3760
  {
3613
- correlate: (q) => this._correlate_pass(q.limit ?? this._poll_limit ?? 100, true),
3761
+ correlate: /* @__PURE__ */ __name((q) => this._correlate_pass(q.limit ?? this._poll_limit ?? 100, true), "correlate"),
3614
3762
  // `settle()` validated the options, and `_schedule` skips writer-only
3615
3763
  // instances, so the loop drains through the internal path.
3616
- drain: (o) => this._scoped(() => this._drain_all(o)),
3617
- on_settled: (drain) => this.emit("settled", drain),
3764
+ drain: /* @__PURE__ */ __name((o) => this._scoped(() => this._drain_all(o)), "drain"),
3765
+ on_settled: /* @__PURE__ */ __name((drain) => this.emit("settled", drain), "on_settled"),
3618
3766
  breaker: this._breaker
3619
3767
  },
3620
3768
  options.settleDebounceMs ?? DEFAULT_SETTLE_DEBOUNCE_MS
@@ -3980,6 +4128,7 @@ var Act = class {
3980
4128
  * @see {@link start_correlations} for automatic periodic correlation
3981
4129
  */
3982
4130
  async correlate(query = {}) {
4131
+ check("page", query);
3983
4132
  const pass = await this._correlate_pass(query.limit ?? 10);
3984
4133
  return {
3985
4134
  subscribed: pass.kind === "scanned" ? pass.subscribed : 0,
@@ -4025,6 +4174,8 @@ var Act = class {
4025
4174
  * @see {@link stop_correlations} to stop the poll
4026
4175
  */
4027
4176
  start_correlations(query = {}, frequency = 1e4) {
4177
+ check("page", query);
4178
+ check("poll", { frequency });
4028
4179
  if (this._poll) return false;
4029
4180
  this._poll_limit = query.limit || void 0;
4030
4181
  this._poll = setInterval(() => {
@@ -4188,12 +4339,12 @@ var Act = class {
4188
4339
  let kept = 0;
4189
4340
  let migrated = 0;
4190
4341
  let dropped = { closed_streams: 0, snapshots: 0 };
4191
- const run = () => target.restore(async (callback) => {
4342
+ const run = /* @__PURE__ */ __name(() => target.restore(async (callback) => {
4192
4343
  const partial = await scan(source, opts, callback);
4193
4344
  kept = partial.kept;
4194
4345
  migrated = partial.migrated;
4195
4346
  dropped = partial.dropped;
4196
- });
4347
+ }), "run");
4197
4348
  if (sink) await run();
4198
4349
  else {
4199
4350
  await this._correlate.restart(run);
@@ -4226,6 +4377,7 @@ var Act = class {
4226
4377
  * ```
4227
4378
  */
4228
4379
  async blocked_streams(options) {
4380
+ check("page", options ?? {});
4229
4381
  return this._scoped(async () => {
4230
4382
  const positions = [];
4231
4383
  await store().query_streams(
@@ -4290,18 +4442,18 @@ var Act = class {
4290
4442
  const close_actor = { id: "$close", name: "close" };
4291
4443
  const result = await run_close_cycle(targets, {
4292
4444
  reactive: this._reactive,
4293
- catch_up_correlation: (until) => catch_up_correlation(
4445
+ catch_up_correlation: /* @__PURE__ */ __name((until) => catch_up_correlation(
4294
4446
  this._correlate,
4295
4447
  (limit) => this.correlate({ limit }),
4296
4448
  until
4297
- ),
4449
+ ), "catch_up_correlation"),
4298
4450
  event_to_state: this._event_to_state,
4299
4451
  load: this._es.load,
4300
4452
  tombstone: this._es.tombstone,
4301
4453
  logger: this._logger,
4302
4454
  correlation: close_correlation(this._correlator, close_actor),
4303
- with_stream_lock: (stream, work) => this._close_lock.run(stream, work),
4304
- forget_subscribed: (streams) => this._correlate.forget_subscribed(streams)
4455
+ with_stream_lock: /* @__PURE__ */ __name((stream, work) => this._close_lock.run(stream, work), "with_stream_lock"),
4456
+ forget_subscribed: /* @__PURE__ */ __name((streams) => this._correlate.forget_subscribed(streams), "forget_subscribed")
4305
4457
  });
4306
4458
  this.emit("closed", result);
4307
4459
  return result;
@@ -4376,6 +4528,7 @@ function base_type_name(schema) {
4376
4528
  def = def_of(inner);
4377
4529
  return def.type === "array" ? `array of ${base_type_name(def.element)}` : def.type;
4378
4530
  }
4531
+ __name(base_type_name, "base_type_name");
4379
4532
  function merge_schemas(existing, incoming, state_name) {
4380
4533
  if (existing === incoming) return existing;
4381
4534
  const existing_object = as_object(existing, "existing", state_name);
@@ -4395,15 +4548,18 @@ function merge_schemas(existing, incoming, state_name) {
4395
4548
  }
4396
4549
  return existing_object.extend(incoming_shape);
4397
4550
  }
4551
+ __name(merge_schemas, "merge_schemas");
4398
4552
  function as_object(schema, side, state_name) {
4399
4553
  if (schema instanceof ZodObject) return schema;
4400
4554
  throw new Error(
4401
4555
  `Cannot merge state schemas for "${state_name}": the ${side} partial's schema is a ${schema.constructor.name}, not a z.object. Partials of the same state are merged by extending their shapes, so declare every partial's state as a plain z.object({ ... }).`
4402
4556
  );
4403
4557
  }
4558
+ __name(as_object, "as_object");
4404
4559
  function merge_inits(existing, incoming) {
4405
4560
  return () => ({ ...existing(), ...incoming() });
4406
4561
  }
4562
+ __name(merge_inits, "merge_inits");
4407
4563
  function register_state(state2, states, actions, events) {
4408
4564
  const existing = states.get(state2.name);
4409
4565
  if (existing) {
@@ -4412,22 +4568,30 @@ function register_state(state2, states, actions, events) {
4412
4568
  register_new_state(state2, states, actions, events);
4413
4569
  }
4414
4570
  }
4571
+ __name(register_state, "register_state");
4572
+ var shared_name = /* @__PURE__ */ __name((name) => new Error(
4573
+ `Action and event share the name "${name}" \u2014 action and event names must be unique across the application. Rename one of them.`
4574
+ ), "shared_name");
4415
4575
  function register_new_state(state2, states, actions, events) {
4416
4576
  states.set(state2.name, state2);
4417
4577
  for (const name of Object.keys(state2.actions)) {
4418
4578
  if (actions[name]) throw new Error(`Duplicate action "${name}"`);
4579
+ if (events[name]) throw shared_name(name);
4419
4580
  actions[name] = state2;
4420
4581
  }
4421
4582
  for (const name of Object.keys(state2.events)) {
4422
4583
  if (events[name]) throw new Error(`Duplicate event "${name}"`);
4584
+ if (actions[name]) throw shared_name(name);
4423
4585
  events[name] = { schema: state2.events[name], reactions: /* @__PURE__ */ new Map() };
4424
4586
  }
4425
4587
  }
4588
+ __name(register_new_state, "register_new_state");
4426
4589
  function pick_declared(existing, incoming, what, state_name) {
4427
4590
  if (existing && incoming && existing !== incoming)
4428
4591
  throw new Error(`Duplicate ${what} for state "${state_name}"`);
4429
4592
  return incoming ?? existing;
4430
4593
  }
4594
+ __name(pick_declared, "pick_declared");
4431
4595
  function autoclose_of(existing, state2) {
4432
4596
  pick_declared(
4433
4597
  existing.autoclose,
@@ -4443,10 +4607,12 @@ function autoclose_of(existing, state2) {
4443
4607
  autoclose_keep_days: owner.autoclose_keep_days
4444
4608
  };
4445
4609
  }
4610
+ __name(autoclose_of, "autoclose_of");
4446
4611
  function merge_into_existing(state2, existing, states, actions, events) {
4447
4612
  for (const name of Object.keys(state2.actions)) {
4448
4613
  if (existing.on[name] === state2.on[name]) continue;
4449
4614
  if (actions[name]) throw new Error(`Duplicate action "${name}"`);
4615
+ if (events[name] || state2.events[name]) throw shared_name(name);
4450
4616
  }
4451
4617
  for (const name of Object.keys(state2.events)) {
4452
4618
  if (existing.events[name] === state2.events[name]) continue;
@@ -4456,6 +4622,7 @@ function merge_into_existing(state2, existing, states, actions, events) {
4456
4622
  );
4457
4623
  }
4458
4624
  if (events[name]) throw new Error(`Duplicate event "${name}"`);
4625
+ if (actions[name]) throw shared_name(name);
4459
4626
  }
4460
4627
  const merged_patch = merge_patches(existing.patch, state2.patch, state2.name);
4461
4628
  const merged = {
@@ -4498,6 +4665,7 @@ function merge_into_existing(state2, existing, states, actions, events) {
4498
4665
  events[name] = { schema: state2.events[name], reactions: /* @__PURE__ */ new Map() };
4499
4666
  }
4500
4667
  }
4668
+ __name(merge_into_existing, "merge_into_existing");
4501
4669
  function merge_patches(existing, incoming, state_name) {
4502
4670
  const merged = { ...existing };
4503
4671
  for (const name of Object.keys(incoming)) {
@@ -4520,6 +4688,7 @@ function merge_patches(existing, incoming, state_name) {
4520
4688
  }
4521
4689
  return merged;
4522
4690
  }
4691
+ __name(merge_patches, "merge_patches");
4523
4692
  function merge_event_register(target, source) {
4524
4693
  for (const [event_name, source_reg] of Object.entries(source)) {
4525
4694
  const target_reg = target[event_name];
@@ -4534,6 +4703,7 @@ function merge_event_register(target, source) {
4534
4703
  }
4535
4704
  }
4536
4705
  }
4706
+ __name(merge_event_register, "merge_event_register");
4537
4707
  function merge_projection(proj, events) {
4538
4708
  for (const event_name of Object.keys(proj.events)) {
4539
4709
  const proj_register = proj.events[event_name];
@@ -4553,10 +4723,11 @@ function merge_projection(proj, events) {
4553
4723
  }
4554
4724
  }
4555
4725
  }
4556
- var _this_ = ({ stream }) => ({
4726
+ __name(merge_projection, "merge_projection");
4727
+ var _this_ = /* @__PURE__ */ __name(({ stream }) => ({
4557
4728
  source: stream,
4558
4729
  target: stream
4559
- });
4730
+ }), "_this_");
4560
4731
 
4561
4732
  // src/builders/builder-utils.ts
4562
4733
  function register_lane(config2, lanes) {
@@ -4570,6 +4741,7 @@ function register_lane(config2, lanes) {
4570
4741
  `Lane "${config2.name}" was already declared with a different config`
4571
4742
  );
4572
4743
  }
4744
+ __name(register_lane, "register_lane");
4573
4745
  function add_reaction(events, event, name, kind, make, builder) {
4574
4746
  if (!name)
4575
4747
  throw new Error(
@@ -4590,8 +4762,9 @@ function add_reaction(events, event, name, kind, make, builder) {
4590
4762
  }
4591
4763
  });
4592
4764
  }
4765
+ __name(add_reaction, "add_reaction");
4593
4766
  function reaction_on(event, events, builder) {
4594
- const register = (handler, options, schedule) => add_reaction(
4767
+ const register = /* @__PURE__ */ __name((handler, options, schedule) => add_reaction(
4595
4768
  events,
4596
4769
  event,
4597
4770
  handler.name,
@@ -4613,17 +4786,45 @@ function reaction_on(event, events, builder) {
4613
4786
  };
4614
4787
  },
4615
4788
  builder
4616
- );
4789
+ ), "register");
4617
4790
  return {
4618
- do: (handler, options) => register(handler, options),
4619
- defer: (schedule) => ({
4620
- do: (handler, options) => register(handler, options, schedule)
4621
- })
4791
+ do: /* @__PURE__ */ __name((handler, options) => register(handler, options), "do"),
4792
+ defer: /* @__PURE__ */ __name((schedule) => ({
4793
+ do: /* @__PURE__ */ __name((handler, options) => register(handler, options, schedule), "do")
4794
+ }), "defer")
4622
4795
  };
4623
4796
  }
4797
+ __name(reaction_on, "reaction_on");
4624
4798
 
4625
4799
  // src/builders/event-builder.ts
4626
4800
  import { z as z2 } from "zod";
4801
+
4802
+ // src/internal/sensitive.ts
4803
+ var SENSITIVE = /* @__PURE__ */ Symbol.for("act.sensitive");
4804
+ var is_pii = /* @__PURE__ */ __name((schema) => some_layer(schema, (def) => def[SENSITIVE] === true), "is_pii");
4805
+ function pii_schemas(schema) {
4806
+ const shape = schema.shape;
4807
+ if (shape && typeof shape === "object") {
4808
+ const fields = {};
4809
+ for (const key of Object.keys(shape))
4810
+ if (is_pii(shape[key])) fields[key] = shape[key];
4811
+ return fields;
4812
+ }
4813
+ const options = schema.options;
4814
+ if (Array.isArray(options)) {
4815
+ const fields = {};
4816
+ for (const option of options)
4817
+ for (const [key, field] of Object.entries(
4818
+ pii_schemas(option)
4819
+ ))
4820
+ fields[key] ??= field;
4821
+ return fields;
4822
+ }
4823
+ return {};
4824
+ }
4825
+ __name(pii_schemas, "pii_schemas");
4826
+
4827
+ // src/builders/event-builder.ts
4627
4828
  function event_tags(schema) {
4628
4829
  const pii = pii_schemas(schema);
4629
4830
  const pii_dates = {};
@@ -4632,10 +4833,10 @@ function event_tags(schema) {
4632
4833
  if (dates) pii_dates[key] = dates.optional();
4633
4834
  }
4634
4835
  const data_reviver_schema = date_reviver_schema(schema);
4635
- const revive = (schema2) => (data) => {
4836
+ const revive = /* @__PURE__ */ __name((schema2) => (data) => {
4636
4837
  const revived = schema2.safeParse(data);
4637
4838
  return revived.success ? revived.data : data;
4638
- };
4839
+ }, "revive");
4639
4840
  const dated_pii = Object.keys(pii_dates).length > 0;
4640
4841
  return {
4641
4842
  sensitive: pii,
@@ -4643,6 +4844,7 @@ function event_tags(schema) {
4643
4844
  pii_date_reviver: dated_pii ? revive(z2.looseObject(pii_dates)) : void 0
4644
4845
  };
4645
4846
  }
4847
+ __name(event_tags, "event_tags");
4646
4848
  function make_event_reader(tags, disclosure, predicate = null) {
4647
4849
  const { date_reviver, pii_date_reviver } = tags;
4648
4850
  const sensitive2 = Object.keys(tags.sensitive);
@@ -4662,6 +4864,7 @@ function make_event_reader(tags, disclosure, predicate = null) {
4662
4864
  );
4663
4865
  });
4664
4866
  }
4867
+ __name(make_event_reader, "make_event_reader");
4665
4868
  function build_events(registry, states, lanes, owners) {
4666
4869
  const declared = /* @__PURE__ */ new Set([DEFAULT_LANE, ...lanes.map((l) => l.name)]);
4667
4870
  const lane_errors = [];
@@ -4696,9 +4899,9 @@ function build_events(registry, states, lanes, owners) {
4696
4899
  handler_readers.set(event_name, handler_reader);
4697
4900
  for (const [name, reaction] of def.reactions) {
4698
4901
  const inner = reaction.handler;
4699
- const wrapped = (evt, stream, app) => inner(handler_reader(evt), stream, app);
4700
- Object.defineProperty(wrapped, "name", { value: inner.name });
4701
- reaction.handler = wrapped;
4902
+ const wrapped2 = /* @__PURE__ */ __name((evt, stream, app) => inner(handler_reader(evt), stream, app), "wrapped");
4903
+ Object.defineProperty(wrapped2, "name", { value: inner.name });
4904
+ reaction.handler = wrapped2;
4702
4905
  def.reactions.set(name, reaction);
4703
4906
  }
4704
4907
  }
@@ -4742,13 +4945,19 @@ function build_events(registry, states, lanes, owners) {
4742
4945
  if (readers.size === 0) continue;
4743
4946
  state2.view = (event, actor) => (readers.get(event.name) ?? IDENTITY_GATE)(event, actor);
4744
4947
  }
4948
+ for (const [action_name, state2] of Object.entries(registry.actions)) {
4949
+ const fields = Object.keys(pii_schemas(state2.actions[action_name]));
4950
+ if (fields.length > 0) sensitive2.set(action_name, fields);
4951
+ }
4745
4952
  const advisory = advised.size > 0 ? `Act has ${advised.size} sensitive field(s) whose type isn't a string: ${[...advised].join(", ")}. A caller who may not see one reads "[REDACTED]" or "[SHREDDED]" there instead, which its type doesn't allow. Declare sensitive fields as strings. See docs/docs/guides/sensitive-data.md.` : void 0;
4746
4953
  return { sensitive: sensitive2, advisory, query_readers, handler_readers };
4747
4954
  }
4955
+ __name(build_events, "build_events");
4748
4956
  function reads_as_string(schema) {
4749
4957
  const type = def_of(output_of(schema))?.type;
4750
4958
  return type === "string" || type === "transform";
4751
4959
  }
4960
+ __name(reads_as_string, "reads_as_string");
4752
4961
 
4753
4962
  // src/builders/act-builder.ts
4754
4963
  function register_batch_handler(proj, batch_handlers) {
@@ -4761,6 +4970,7 @@ function register_batch_handler(proj, batch_handlers) {
4761
4970
  }
4762
4971
  batch_handlers.set(proj.target, proj.batchHandler);
4763
4972
  }
4973
+ __name(register_batch_handler, "register_batch_handler");
4764
4974
  function act() {
4765
4975
  const states = /* @__PURE__ */ new Map();
4766
4976
  const _sf = /* @__PURE__ */ new Map();
@@ -4774,44 +4984,44 @@ function act() {
4774
4984
  const registry = {
4775
4985
  actions: {},
4776
4986
  events: {},
4777
- sensitive_fields: (event_name) => _sf.get(event_name) ?? [],
4778
- query_gate: (event_name) => _qg.get(event_name) ?? IDENTITY_GATE,
4779
- disclosure_predicate: (state_name) => _dp.get(state_name) ?? null,
4780
- deprecated_events: (state_name) => _de.get(state_name) ?? EMPTY_DEPRECATED,
4781
- autoclose_policy: (state_name) => _ac.get(state_name) ?? null,
4782
- autoclose_archiver: (state_name) => _aa.get(state_name) ?? null
4987
+ sensitive_fields: /* @__PURE__ */ __name((name) => _sf.get(name) ?? [], "sensitive_fields"),
4988
+ query_gate: /* @__PURE__ */ __name((event_name) => _qg.get(event_name) ?? IDENTITY_GATE, "query_gate"),
4989
+ disclosure_predicate: /* @__PURE__ */ __name((state_name) => _dp.get(state_name) ?? null, "disclosure_predicate"),
4990
+ deprecated_events: /* @__PURE__ */ __name((state_name) => _de.get(state_name) ?? EMPTY_DEPRECATED, "deprecated_events"),
4991
+ autoclose_policy: /* @__PURE__ */ __name((state_name) => _ac.get(state_name) ?? null, "autoclose_policy"),
4992
+ autoclose_archiver: /* @__PURE__ */ __name((state_name) => _aa.get(state_name) ?? null, "autoclose_archiver")
4783
4993
  };
4784
4994
  const pending_projections = [];
4785
4995
  const projection_reactions = /* @__PURE__ */ new Set();
4786
- const record_projection_reactions = (proj) => {
4996
+ const record_projection_reactions = /* @__PURE__ */ __name((proj) => {
4787
4997
  if (!proj.batchHandler && !proj.fold) return;
4788
4998
  for (const register of Object.values(
4789
4999
  proj.events
4790
5000
  ))
4791
5001
  for (const reaction of register.reactions.values())
4792
5002
  projection_reactions.add(reaction);
4793
- };
5003
+ }, "record_projection_reactions");
4794
5004
  const fold_projections = [];
4795
5005
  const batch_handlers = /* @__PURE__ */ new Map();
4796
- const add_projection = (proj) => {
5006
+ const add_projection = /* @__PURE__ */ __name((proj) => {
4797
5007
  record_projection_reactions(proj);
4798
5008
  merge_projection(proj, registry.events);
4799
5009
  register_batch_handler(proj, batch_handlers);
4800
5010
  if (proj.fold) fold_projections.push(proj);
4801
- };
5011
+ }, "add_projection");
4802
5012
  const fold_specs = [];
4803
5013
  const lanes = [];
4804
5014
  let _built = false;
4805
- const read_wrap = (original) => {
4806
- const wrapped = async (events, stream) => {
5015
+ const read_wrap = /* @__PURE__ */ __name((original) => {
5016
+ const wrapped2 = /* @__PURE__ */ __name(async (events, stream) => {
4807
5017
  const read = events.map((e) => _hr.get(e.name)?.(e) ?? e);
4808
5018
  return original(read, stream);
4809
- };
5019
+ }, "wrapped");
4810
5020
  const reset = original[FOLD_RESET];
4811
- if (reset) Object.defineProperty(wrapped, FOLD_RESET, { value: reset });
4812
- return wrapped;
4813
- };
4814
- const make_batch_handlers = () => {
5021
+ if (reset) Object.defineProperty(wrapped2, FOLD_RESET, { value: reset });
5022
+ return wrapped2;
5023
+ }, "read_wrap");
5024
+ const make_batch_handlers = /* @__PURE__ */ __name(() => {
4815
5025
  const handlers = new Map(batch_handlers);
4816
5026
  for (const spec of fold_specs) {
4817
5027
  handlers.set(
@@ -4828,8 +5038,8 @@ function act() {
4828
5038
  );
4829
5039
  }
4830
5040
  return handlers;
4831
- };
4832
- const finalize_deprecations = () => {
5041
+ }, "make_batch_handlers");
5042
+ const finalize_deprecations = /* @__PURE__ */ __name(() => {
4833
5043
  const deprecation_summary = [];
4834
5044
  for (const state2 of states.values()) {
4835
5045
  const event_names = Object.keys(state2.events);
@@ -4862,19 +5072,19 @@ function act() {
4862
5072
  `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.`
4863
5073
  );
4864
5074
  }
4865
- };
4866
- const closed = (method) => {
5075
+ }, "finalize_deprecations");
5076
+ const closed = /* @__PURE__ */ __name((method) => {
4867
5077
  throw new Error(
4868
5078
  `act().${method}() was called after build(); the registry is already classified. Register everything before build() \u2014 build() itself may be called repeatedly (e.g. once per tenant with ActOptions.scoped).`
4869
5079
  );
4870
- };
5080
+ }, "closed");
4871
5081
  const builder = {
4872
- withState: (state2) => {
5082
+ withState: /* @__PURE__ */ __name((state2) => {
4873
5083
  if (_built) closed("withState");
4874
5084
  register_state(state2, states, registry.actions, registry.events);
4875
5085
  return builder;
4876
- },
4877
- withSlice: (input) => {
5086
+ }, "withState"),
5087
+ withSlice: /* @__PURE__ */ __name((input) => {
4878
5088
  if (_built) closed("withSlice");
4879
5089
  for (const s of input.states.values()) {
4880
5090
  register_state(s, states, registry.actions, registry.events);
@@ -4883,24 +5093,23 @@ function act() {
4883
5093
  pending_projections.push(...input.projections);
4884
5094
  for (const lane of input.lanes) register_lane(lane, lanes);
4885
5095
  return builder;
4886
- },
4887
- withProjection: (proj) => {
5096
+ }, "withSlice"),
5097
+ withProjection: /* @__PURE__ */ __name((proj) => {
4888
5098
  if (_built) closed("withProjection");
4889
5099
  add_projection(proj);
4890
5100
  return builder;
4891
- },
4892
- withActor: () => builder,
4893
- withLane: (config2) => {
5101
+ }, "withProjection"),
5102
+ withActor: /* @__PURE__ */ __name(() => builder, "withActor"),
5103
+ withLane: /* @__PURE__ */ __name((config2) => {
4894
5104
  if (_built) closed("withLane");
4895
5105
  register_lane(config2, lanes);
4896
5106
  return builder;
4897
- },
4898
- on: (event) => {
5107
+ }, "withLane"),
5108
+ on: /* @__PURE__ */ __name((event) => {
4899
5109
  if (_built) closed("on");
4900
5110
  return reaction_on(event, registry.events, builder);
4901
- },
4902
- build: (options) => {
4903
- check("act", options ?? {});
5111
+ }, "on"),
5112
+ build: /* @__PURE__ */ __name((options) => {
4904
5113
  if (!_built) {
4905
5114
  for (const proj of pending_projections) add_projection(proj);
4906
5115
  for (const proj of fold_projections) {
@@ -4998,18 +5207,19 @@ function act() {
4998
5207
  options,
4999
5208
  lanes
5000
5209
  );
5001
- },
5210
+ }, "build"),
5002
5211
  events: registry.events
5003
5212
  };
5004
5213
  return builder;
5005
5214
  }
5215
+ __name(act, "act");
5006
5216
 
5007
5217
  // src/builders/projection-builder.ts
5008
5218
  function _projection(target) {
5009
5219
  const events = {};
5010
5220
  const default_resolver = typeof target === "string" ? { target } : void 0;
5011
5221
  const base = {
5012
- on: (entry) => {
5222
+ on: /* @__PURE__ */ __name((entry) => {
5013
5223
  const keys = Object.keys(entry);
5014
5224
  if (keys.length !== 1) throw new Error(".on() requires exactly one key");
5015
5225
  const event = keys[0];
@@ -5021,7 +5231,7 @@ function _projection(target) {
5021
5231
  };
5022
5232
  }
5023
5233
  return {
5024
- do: (handler) => {
5234
+ do: /* @__PURE__ */ __name((handler) => {
5025
5235
  const widened = base;
5026
5236
  return add_reaction(
5027
5237
  events,
@@ -5038,32 +5248,32 @@ function _projection(target) {
5038
5248
  }),
5039
5249
  widened
5040
5250
  );
5041
- }
5251
+ }, "do")
5042
5252
  };
5043
- },
5044
- build: () => ({
5253
+ }, "on"),
5254
+ build: /* @__PURE__ */ __name(() => ({
5045
5255
  _tag: "Projection",
5046
5256
  events,
5047
5257
  ...target !== void 0 && { target }
5048
- }),
5258
+ }), "build"),
5049
5259
  events
5050
5260
  };
5051
5261
  if (typeof target === "string") {
5052
5262
  return Object.assign(base, {
5053
- batch: (handler) => ({
5054
- build: () => ({
5263
+ batch: /* @__PURE__ */ __name((handler) => ({
5264
+ build: /* @__PURE__ */ __name(() => ({
5055
5265
  _tag: "Projection",
5056
5266
  events,
5057
5267
  target,
5058
5268
  batchHandler: handler
5059
- })
5060
- }),
5061
- of: (...args) => {
5269
+ }), "build")
5270
+ }), "batch"),
5271
+ of: /* @__PURE__ */ __name((...args) => {
5062
5272
  if (Object.keys(events).length > 0)
5063
5273
  throw new Error(
5064
5274
  `Projection "${target}" mixes .of() with .on() handlers \u2014 a projection either folds a state or declares handlers, never both`
5065
5275
  );
5066
- const is_state = (a) => !!a && typeof a.init === "function";
5276
+ const is_state = /* @__PURE__ */ __name((a) => !!a && typeof a.init === "function", "is_state");
5067
5277
  const partials = args.filter(is_state);
5068
5278
  const options = args.find((a) => !is_state(a)) ?? {};
5069
5279
  if (partials.length === 0)
@@ -5101,23 +5311,25 @@ function _projection(target) {
5101
5311
  };
5102
5312
  }
5103
5313
  return {
5104
- flush: (handler) => ({
5105
- build: () => ({
5314
+ flush: /* @__PURE__ */ __name((handler) => ({
5315
+ build: /* @__PURE__ */ __name(() => ({
5106
5316
  _tag: "Projection",
5107
5317
  events: fold_events,
5108
5318
  target,
5109
5319
  fold: { name, flush: handler, config: config2 }
5110
- })
5111
- })
5320
+ }), "build")
5321
+ }), "flush")
5112
5322
  };
5113
- }
5323
+ }, "of")
5114
5324
  });
5115
5325
  }
5116
5326
  return base;
5117
5327
  }
5328
+ __name(_projection, "_projection");
5118
5329
  function projection(target) {
5119
5330
  return _projection(target);
5120
5331
  }
5332
+ __name(projection, "projection");
5121
5333
 
5122
5334
  // src/builders/slice-builder.ts
5123
5335
  function slice() {
@@ -5127,30 +5339,31 @@ function slice() {
5127
5339
  const projections = [];
5128
5340
  const lanes = [];
5129
5341
  const builder = {
5130
- withState: (state2) => {
5342
+ withState: /* @__PURE__ */ __name((state2) => {
5131
5343
  register_state(state2, states, actions, events);
5132
5344
  return builder;
5133
- },
5134
- withProjection: (proj) => {
5345
+ }, "withState"),
5346
+ withProjection: /* @__PURE__ */ __name((proj) => {
5135
5347
  projections.push(proj);
5136
5348
  return builder;
5137
- },
5138
- withLane: (config2) => {
5349
+ }, "withProjection"),
5350
+ withLane: /* @__PURE__ */ __name((config2) => {
5139
5351
  register_lane(config2, lanes);
5140
5352
  return builder;
5141
- },
5142
- on: (event) => reaction_on(event, events, builder),
5143
- build: () => ({
5353
+ }, "withLane"),
5354
+ on: /* @__PURE__ */ __name((event) => reaction_on(event, events, builder), "on"),
5355
+ build: /* @__PURE__ */ __name(() => ({
5144
5356
  _tag: "Slice",
5145
5357
  states,
5146
5358
  events,
5147
5359
  projections,
5148
5360
  lanes
5149
- }),
5361
+ }), "build"),
5150
5362
  events
5151
5363
  };
5152
5364
  return builder;
5153
5365
  }
5366
+ __name(slice, "slice");
5154
5367
 
5155
5368
  // src/builders/state-builder.ts
5156
5369
  function state(entry) {
@@ -5182,8 +5395,8 @@ function state(entry) {
5182
5395
  // `act().build()` flips both on states with `sensitive(...)`
5183
5396
  // events to bake in the gate / split and gate the cache write.
5184
5397
  pii_aware: false,
5185
- view: (event) => event,
5186
- message: (validated) => validated
5398
+ view: /* @__PURE__ */ __name((event) => event, "view"),
5399
+ message: /* @__PURE__ */ __name((validated) => validated, "message")
5187
5400
  };
5188
5401
  const builder = action_builder(internal);
5189
5402
  return Object.assign(builder, {
@@ -5197,6 +5410,7 @@ function state(entry) {
5197
5410
  }
5198
5411
  };
5199
5412
  }
5413
+ __name(state, "state");
5200
5414
  function action_builder(state2) {
5201
5415
  const internal = state2;
5202
5416
  const builder = {
@@ -5233,10 +5447,12 @@ function action_builder(state2) {
5233
5447
  (internal.loads ??= {})[action2] = loads;
5234
5448
  return { loads: load2, requires, emit };
5235
5449
  }
5450
+ __name(load2, "load");
5236
5451
  function requires(rules) {
5237
5452
  (internal.requires ??= {})[action2] = rules;
5238
5453
  return { emit };
5239
5454
  }
5455
+ __name(requires, "requires");
5240
5456
  function emit(handler) {
5241
5457
  if (typeof handler === "string") {
5242
5458
  const event_name = handler;
@@ -5252,6 +5468,7 @@ function action_builder(state2) {
5252
5468
  }
5253
5469
  return builder;
5254
5470
  }
5471
+ __name(emit, "emit");
5255
5472
  return { loads: load2, requires, emit };
5256
5473
  },
5257
5474
  snap(snap2) {
@@ -5302,6 +5519,7 @@ function action_builder(state2) {
5302
5519
  };
5303
5520
  return builder;
5304
5521
  }
5522
+ __name(action_builder, "action_builder");
5305
5523
 
5306
5524
  // src/csv.ts
5307
5525
  import { createReadStream, createWriteStream } from "fs";
@@ -5316,6 +5534,9 @@ var CSV_COLUMNS = [
5316
5534
  "meta"
5317
5535
  ];
5318
5536
  var CsvFile = class {
5537
+ static {
5538
+ __name(this, "CsvFile");
5539
+ }
5319
5540
  path;
5320
5541
  blob;
5321
5542
  constructor(options) {
@@ -5409,6 +5630,7 @@ async function* linesFromFile(path) {
5409
5630
  stream.close();
5410
5631
  }
5411
5632
  }
5633
+ __name(linesFromFile, "linesFromFile");
5412
5634
  async function* linesFromBlob(blob) {
5413
5635
  let start = 0;
5414
5636
  while (start < blob.length) {
@@ -5419,6 +5641,7 @@ async function* linesFromBlob(blob) {
5419
5641
  await Promise.resolve();
5420
5642
  }
5421
5643
  }
5644
+ __name(linesFromBlob, "linesFromBlob");
5422
5645
  function parse_csv_line(line) {
5423
5646
  const fields = [];
5424
5647
  let i = 0;
@@ -5452,10 +5675,12 @@ function parse_csv_line(line) {
5452
5675
  }
5453
5676
  return fields;
5454
5677
  }
5678
+ __name(parse_csv_line, "parse_csv_line");
5455
5679
  function csv_escape(value) {
5456
5680
  if (/[",\n\r]/.test(value)) return `"${value.replace(/"/g, '""')}"`;
5457
5681
  return value;
5458
5682
  }
5683
+ __name(csv_escape, "csv_escape");
5459
5684
  function write_line(writer, line) {
5460
5685
  return new Promise((resolve, reject) => {
5461
5686
  writer.write(`${line}
@@ -5465,6 +5690,7 @@ function write_line(writer, line) {
5465
5690
  });
5466
5691
  });
5467
5692
  }
5693
+ __name(write_line, "write_line");
5468
5694
 
5469
5695
  // src/deprecated.ts
5470
5696
  var check_appends = checkAppends;
@@ -5489,9 +5715,14 @@ var DEFAULT_MAX_SUBSCRIBED_STREAMS2 = DEFAULT_MAX_SUBSCRIBED_STREAMS;
5489
5715
  var DEFAULT_SETTLE_DEBOUNCE_MS2 = DEFAULT_SETTLE_DEBOUNCE_MS;
5490
5716
  var PackageSchema = package_schema;
5491
5717
  var default_scope = unscoped_ports;
5492
- var extend = (source, schema, target) => ({ ...target, ...validate("config", source, schema) });
5718
+ var extend = /* @__PURE__ */ __name((source, schema, target) => ({ ...target, ...validate("config", source, schema) }), "extend");
5493
5719
  var ISO_8601 = /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(\.\d+)?(Z|[+-][0-2][0-9]:[0-5][0-9])?$/;
5494
- var dateReviver = (_key, value) => typeof value === "string" && ISO_8601.test(value) ? new Date(value) : value;
5720
+ var dateReviver = /* @__PURE__ */ __name((_key, value) => typeof value === "string" && ISO_8601.test(value) ? new Date(value) : value, "dateReviver");
5721
+ function sensitiveFields(schema) {
5722
+ return Object.keys(pii_schemas(schema));
5723
+ }
5724
+ __name(sensitiveFields, "sensitiveFields");
5725
+ var pii_fields = sensitiveFields;
5495
5726
  export {
5496
5727
  Act,
5497
5728
  ActorSchema2 as ActorSchema,