@rotorsoft/act 1.23.6 → 1.23.8

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 (39) 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/state-builder.d.ts.map +1 -1
  5. package/dist/@types/internal/autoclose-reaction.d.ts +1 -1
  6. package/dist/@types/internal/autoclose-reaction.d.ts.map +1 -1
  7. package/dist/@types/internal/autoclose-window.d.ts +66 -0
  8. package/dist/@types/internal/autoclose-window.d.ts.map +1 -0
  9. package/dist/@types/internal/backoff.d.ts.map +1 -1
  10. package/dist/@types/internal/builder-utils.d.ts.map +1 -1
  11. package/dist/@types/internal/circuit-breaker.d.ts +1 -19
  12. package/dist/@types/internal/circuit-breaker.d.ts.map +1 -1
  13. package/dist/@types/internal/config.d.ts +139 -0
  14. package/dist/@types/internal/config.d.ts.map +1 -0
  15. package/dist/@types/internal/index.d.ts +5 -4
  16. package/dist/@types/internal/index.d.ts.map +1 -1
  17. package/dist/@types/internal/projection-fold.d.ts +2 -11
  18. package/dist/@types/internal/projection-fold.d.ts.map +1 -1
  19. package/dist/@types/internal/sensitive.d.ts +50 -5
  20. package/dist/@types/internal/sensitive.d.ts.map +1 -1
  21. package/dist/@types/types/action.d.ts +7 -2
  22. package/dist/@types/types/action.d.ts.map +1 -1
  23. package/dist/@types/types/registry.d.ts +10 -0
  24. package/dist/@types/types/registry.d.ts.map +1 -1
  25. package/dist/{chunk-C7H3GARW.js → chunk-7PG2SR37.js} +2 -2
  26. package/dist/{chunk-LDWS6I2C.js → chunk-RLM4M5UV.js} +13 -17
  27. package/dist/{chunk-LDWS6I2C.js.map → chunk-RLM4M5UV.js.map} +1 -1
  28. package/dist/index.cjs +205 -129
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.js +199 -117
  31. package/dist/index.js.map +1 -1
  32. package/dist/test/index.cjs.map +1 -1
  33. package/dist/test/index.js +2 -2
  34. package/dist/types/index.cjs.map +1 -1
  35. package/dist/types/index.js +1 -1
  36. package/package.json +2 -2
  37. package/dist/@types/internal/autoclose-config.d.ts +0 -142
  38. package/dist/@types/internal/autoclose-config.d.ts.map +0 -1
  39. /package/dist/{chunk-C7H3GARW.js.map → chunk-7PG2SR37.js.map} +0 -0
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ import {
20
20
  sleep,
21
21
  store,
22
22
  validate
23
- } from "./chunk-C7H3GARW.js";
23
+ } from "./chunk-7PG2SR37.js";
24
24
  import {
25
25
  ActorSchema,
26
26
  CausationEventSchema,
@@ -29,6 +29,7 @@ import {
29
29
  Environments,
30
30
  Errors,
31
31
  EventMetaSchema,
32
+ IDENTITY_GATE,
32
33
  InvariantError,
33
34
  LogLevels,
34
35
  NonRetryableError,
@@ -40,12 +41,12 @@ import {
40
41
  TargetSchema,
41
42
  ValidationError,
42
43
  ZodEmpty,
44
+ make_gate,
43
45
  pii_fields,
44
- pii_gate,
45
46
  pii_split,
46
47
  pii_strip,
47
48
  sensitive
48
- } from "./chunk-LDWS6I2C.js";
49
+ } from "./chunk-RLM4M5UV.js";
49
50
 
50
51
  // src/signals.ts
51
52
  process.once("SIGINT", async (arg) => {
@@ -496,84 +497,8 @@ var PASS_FACTORIES = {
496
497
  "clock-anomalies": make_clock_anomalies_pass
497
498
  };
498
499
 
499
- // src/internal/autoclose-config.ts
500
- import { z } from "zod";
501
- var DEFAULT_AUTOCLOSE_CYCLE_MINUTES = 720;
502
- var DEFAULT_CLOSE_BATCH_SIZE = 64;
503
- var DEFAULT_CLOSE_YIELD_MS = 0;
504
- var DEFAULT_AUTOCLOSE_WINDOW_TZ = "UTC";
505
- function is_valid_time_zone(tz) {
506
- try {
507
- new Intl.DateTimeFormat("en-US", { timeZone: tz });
508
- return true;
509
- } catch {
510
- return false;
511
- }
512
- }
513
- var AutocloseWindowSchema = z.object({
514
- start: z.number().int().min(0).max(23, { message: "autocloseWindow.start must be an hour in [0, 23]" }),
515
- end: z.number().int().min(0).max(23, { message: "autocloseWindow.end must be an hour in [0, 23]" }),
516
- timeZone: z.string().refine(is_valid_time_zone, {
517
- message: "autocloseWindow.timeZone must be a valid IANA time zone"
518
- }).default(DEFAULT_AUTOCLOSE_WINDOW_TZ)
519
- }).refine((w) => w.start !== w.end, {
520
- message: "autocloseWindow.start and end must differ \u2014 an empty window disables autoclose"
521
- });
522
- var AutocloseOptionsSchema = z.object({
523
- autocloseCycleMinutes: z.number().int().min(1).max(1440).default(DEFAULT_AUTOCLOSE_CYCLE_MINUTES),
524
- closeBatchSize: z.number().int().min(1).max(1024).default(DEFAULT_CLOSE_BATCH_SIZE),
525
- closeYieldMs: z.number().min(0).max(1e3).default(DEFAULT_CLOSE_YIELD_MS),
526
- closeOnError: z.boolean().default(false),
527
- autocloseWindow: AutocloseWindowSchema.optional()
528
- });
529
- function resolveAutocloseConfig(options) {
530
- return AutocloseOptionsSchema.parse({
531
- autocloseCycleMinutes: options?.autocloseCycleMinutes,
532
- closeBatchSize: options?.closeBatchSize,
533
- closeYieldMs: options?.closeYieldMs,
534
- closeOnError: options?.closeOnError,
535
- autocloseWindow: options?.autocloseWindow
536
- });
537
- }
538
- function hour_in_zone(now, timeZone) {
539
- const parts = new Intl.DateTimeFormat("en-US", {
540
- timeZone,
541
- hour: "2-digit",
542
- hourCycle: "h23"
543
- }).formatToParts(now);
544
- return Number(parts.find((p) => p.type === "hour")?.value);
545
- }
546
- function hour_in_range(hour, start, end) {
547
- return start < end ? hour >= start && hour < end : hour >= start || hour < end;
548
- }
549
- function is_dst_gap_open(now, timeZone, start) {
550
- const hour = hour_in_zone(now, timeZone);
551
- if (hour <= start) return false;
552
- const prev = hour_in_zone(new Date(now.getTime() - 36e5), timeZone);
553
- return prev === start - 1 && hour === start + 1;
554
- }
555
- function in_autoclose_window(window, now) {
556
- if (!window) return true;
557
- const hour = hour_in_zone(now, window.timeZone);
558
- return hour_in_range(hour, window.start, window.end) || is_dst_gap_open(now, window.timeZone, window.start);
559
- }
560
- function next_window_open(window, now) {
561
- const start_ms = now.getTime();
562
- for (let h = 0; h <= 48; h++) {
563
- const candidate = new Date(start_ms + h * 36e5);
564
- if (hour_in_zone(candidate, window.timeZone) === window.start)
565
- return candidate;
566
- const boundary = new Date(
567
- candidate.getTime() - candidate.getTime() % 36e5
568
- );
569
- if (is_dst_gap_open(boundary, window.timeZone, window.start))
570
- return boundary;
571
- }
572
- return new Date(start_ms + 864e5);
573
- }
574
-
575
500
  // src/internal/autoclose-policy.ts
576
- import { z as z2 } from "zod";
501
+ import { z } from "zod";
577
502
  var DAY_MS = 864e5;
578
503
  var MIN_AFTER_DAYS = 1 / 1440;
579
504
  var MIN_KEEP_DAYS = 1;
@@ -583,21 +508,21 @@ function days_after(date, days) {
583
508
  function days_before_now(days) {
584
509
  return new Date(Date.now() - days * DAY_MS);
585
510
  }
586
- var window_schema = (field, min_days, floor) => z2.object({
587
- days: z2.number({ message: `autocloses: ${field}.days must be a number` }).positive(`autocloses: ${field}.days must be > 0`)
511
+ var window_schema = (field, min_days, floor) => z.object({
512
+ days: z.number({ message: `autocloses: ${field}.days must be a number` }).positive(`autocloses: ${field}.days must be > 0`)
588
513
  }).refine((o) => o.days >= min_days, {
589
514
  message: `autocloses: ${field} resolves to < ${floor}, which is too short to be a meaningful retention window`
590
515
  });
591
516
  var AfterSchema = window_schema("after", MIN_AFTER_DAYS, "one minute");
592
517
  var KeepSchema = window_schema("keep", MIN_KEEP_DAYS, "one day");
593
- var IsSchema = z2.union([
594
- z2.string().min(1, "autocloses: is must be a non-empty event name"),
595
- z2.array(
596
- z2.string().min(1, "autocloses: is entries must be non-empty event names")
518
+ var IsSchema = z.union([
519
+ z.string().min(1, "autocloses: is must be a non-empty event name"),
520
+ z.array(
521
+ z.string().min(1, "autocloses: is entries must be non-empty event names")
597
522
  ).min(1, "autocloses: is must include at least one event name").readonly()
598
523
  ]);
599
- var ReachesSchema = z2.number({ message: "autocloses: reaches must be a number" }).int("autocloses: reaches must be an integer").min(1, "autocloses: reaches must be >= 1");
600
- var OrBlockSchema = z2.object({
524
+ var ReachesSchema = z.number({ message: "autocloses: reaches must be a number" }).int("autocloses: reaches must be an integer").min(1, "autocloses: reaches must be >= 1");
525
+ var OrBlockSchema = z.object({
601
526
  after: AfterSchema.optional(),
602
527
  is: IsSchema.optional(),
603
528
  reaches: ReachesSchema.optional()
@@ -607,7 +532,7 @@ var OrBlockSchema = z2.object({
607
532
  message: "autocloses: `or` block must include at least one of after / is / reaches"
608
533
  }
609
534
  );
610
- var AutoclosePolicySchema = z2.object({
535
+ var AutoclosePolicySchema = z.object({
611
536
  after: AfterSchema.optional(),
612
537
  is: IsSchema.optional(),
613
538
  reaches: ReachesSchema.optional(),
@@ -663,6 +588,44 @@ function compile_autoclose_policy(options) {
663
588
  };
664
589
  }
665
590
 
591
+ // src/internal/autoclose-window.ts
592
+ function hour_in_zone(now, timeZone) {
593
+ const parts = new Intl.DateTimeFormat("en-US", {
594
+ timeZone,
595
+ hour: "2-digit",
596
+ hourCycle: "h23"
597
+ }).formatToParts(now);
598
+ return Number(parts.find((p) => p.type === "hour")?.value);
599
+ }
600
+ function hour_in_range(hour, start, end) {
601
+ return start < end ? hour >= start && hour < end : hour >= start || hour < end;
602
+ }
603
+ function is_dst_gap_open(now, timeZone, start) {
604
+ const hour = hour_in_zone(now, timeZone);
605
+ if (hour <= start) return false;
606
+ const prev = hour_in_zone(new Date(now.getTime() - 36e5), timeZone);
607
+ return prev === start - 1 && hour === start + 1;
608
+ }
609
+ function in_autoclose_window(window, now) {
610
+ if (!window) return true;
611
+ const hour = hour_in_zone(now, window.timeZone);
612
+ return hour_in_range(hour, window.start, window.end) || is_dst_gap_open(now, window.timeZone, window.start);
613
+ }
614
+ function next_window_open(window, now) {
615
+ const start_ms = now.getTime();
616
+ for (let h = 0; h <= 48; h++) {
617
+ const candidate = new Date(start_ms + h * 36e5);
618
+ if (hour_in_zone(candidate, window.timeZone) === window.start)
619
+ return candidate;
620
+ const boundary = new Date(
621
+ candidate.getTime() - candidate.getTime() % 36e5
622
+ );
623
+ if (is_dst_gap_open(boundary, window.timeZone, window.start))
624
+ return boundary;
625
+ }
626
+ return new Date(start_ms + 864e5);
627
+ }
628
+
666
629
  // src/internal/close-signal.ts
667
630
  var CloseSignal = class extends Error {
668
631
  /**
@@ -843,6 +806,123 @@ function classify_registry(registry, states) {
843
806
  };
844
807
  }
845
808
 
809
+ // src/internal/config.ts
810
+ import { z as z2 } from "zod";
811
+ var BackoffOptionsSchema = z2.object({
812
+ strategy: z2.enum(["fixed", "linear", "exponential"]),
813
+ baseMs: z2.number().min(0),
814
+ maxMs: z2.number().gt(0).optional(),
815
+ jitter: z2.boolean().optional()
816
+ });
817
+ var ReactionOptionsSchema = z2.object({
818
+ blockOnError: z2.boolean(),
819
+ maxRetries: z2.number().int().min(0),
820
+ backoff: BackoffOptionsSchema.optional()
821
+ });
822
+ function resolveReactionConfig(options) {
823
+ return ReactionOptionsSchema.parse(options);
824
+ }
825
+ var ActionOptionsSchema = z2.object({
826
+ maxRetries: z2.number().int().min(0).optional(),
827
+ backoff: BackoffOptionsSchema.optional()
828
+ });
829
+ function resolveActionConfig(options) {
830
+ return ActionOptionsSchema.parse(options);
831
+ }
832
+ var LaneConfigSchema = z2.object({
833
+ name: z2.string().min(1),
834
+ leaseMillis: z2.number().min(0).optional(),
835
+ streamLimit: z2.number().int().min(0).optional(),
836
+ cycleMs: z2.number().min(0).optional()
837
+ });
838
+ function resolveLaneConfig(options) {
839
+ LaneConfigSchema.parse(options);
840
+ return options;
841
+ }
842
+ var DrainOptionsSchema = z2.object({
843
+ streamLimit: z2.number().int().min(0).optional(),
844
+ eventLimit: z2.number().int().min(0).optional(),
845
+ leaseMillis: z2.number().min(0).optional()
846
+ });
847
+ function resolveDrainConfig(options) {
848
+ if (options === void 0) return void 0;
849
+ DrainOptionsSchema.parse(options);
850
+ return options;
851
+ }
852
+ var SettleOptionsSchema = DrainOptionsSchema.extend({
853
+ debounceMs: z2.number().min(0).optional(),
854
+ // `maxPasses` defaults to Infinity (no cap) when omitted; a present value is
855
+ // a non-negative integer — `0` is legal and means "run no passes".
856
+ maxPasses: z2.number().int().min(0).optional()
857
+ }).loose();
858
+ function resolveSettleConfig(options) {
859
+ if (options === void 0) return void 0;
860
+ SettleOptionsSchema.parse(options);
861
+ return options;
862
+ }
863
+ var ActOptionsSchema = z2.object({
864
+ maxSubscribedStreams: z2.number().int().min(1).optional(),
865
+ settleDebounceMs: z2.number().int().min(0).optional()
866
+ }).loose();
867
+ function resolveActConfig(options) {
868
+ if (options === void 0) return void 0;
869
+ ActOptionsSchema.parse(options);
870
+ return options;
871
+ }
872
+ var DEFAULT_AUTOCLOSE_CYCLE_MINUTES = 720;
873
+ var DEFAULT_CLOSE_BATCH_SIZE = 64;
874
+ var DEFAULT_CLOSE_YIELD_MS = 0;
875
+ var DEFAULT_AUTOCLOSE_WINDOW_TZ = "UTC";
876
+ function is_valid_time_zone(tz) {
877
+ try {
878
+ new Intl.DateTimeFormat("en-US", { timeZone: tz });
879
+ return true;
880
+ } catch {
881
+ return false;
882
+ }
883
+ }
884
+ var AutocloseWindowSchema = z2.object({
885
+ start: z2.number().int().min(0).max(23, { message: "autocloseWindow.start must be an hour in [0, 23]" }),
886
+ end: z2.number().int().min(0).max(23, { message: "autocloseWindow.end must be an hour in [0, 23]" }),
887
+ timeZone: z2.string().refine(is_valid_time_zone, {
888
+ message: "autocloseWindow.timeZone must be a valid IANA time zone"
889
+ }).default(DEFAULT_AUTOCLOSE_WINDOW_TZ)
890
+ }).refine((w) => w.start !== w.end, {
891
+ message: "autocloseWindow.start and end must differ \u2014 an empty window disables autoclose"
892
+ });
893
+ var AutocloseOptionsSchema = z2.object({
894
+ autocloseCycleMinutes: z2.number().int().min(1).max(1440).default(DEFAULT_AUTOCLOSE_CYCLE_MINUTES),
895
+ closeBatchSize: z2.number().int().min(1).max(1024).default(DEFAULT_CLOSE_BATCH_SIZE),
896
+ closeYieldMs: z2.number().min(0).max(1e3).default(DEFAULT_CLOSE_YIELD_MS),
897
+ closeOnError: z2.boolean().default(false),
898
+ autocloseWindow: AutocloseWindowSchema.optional()
899
+ });
900
+ function resolveAutocloseConfig(options) {
901
+ return AutocloseOptionsSchema.parse({
902
+ autocloseCycleMinutes: options?.autocloseCycleMinutes,
903
+ closeBatchSize: options?.closeBatchSize,
904
+ closeYieldMs: options?.closeYieldMs,
905
+ closeOnError: options?.closeOnError,
906
+ autocloseWindow: options?.autocloseWindow
907
+ });
908
+ }
909
+ var DEFAULT_CIRCUIT_FAILURE_THRESHOLD = 5;
910
+ var DEFAULT_CIRCUIT_COOLDOWN_MS = 3e4;
911
+ var CircuitBreakerOptionsSchema = z2.object({
912
+ failureThreshold: z2.number().int().min(1).default(DEFAULT_CIRCUIT_FAILURE_THRESHOLD),
913
+ cooldownMs: z2.number().int().min(100).max(36e5).default(DEFAULT_CIRCUIT_COOLDOWN_MS)
914
+ });
915
+ var resolveCircuitBreakerConfig = (options) => CircuitBreakerOptionsSchema.parse(options ?? {});
916
+ var DEFAULT_FOLD_FLUSH_EVERY = 1e3;
917
+ var DEFAULT_MAX_CACHED_STATES = 1e4;
918
+ var FoldOptionsSchema = z2.object({
919
+ flushEvery: z2.number().int().min(1).default(DEFAULT_FOLD_FLUSH_EVERY),
920
+ maxCachedStates: z2.number().int().min(1).default(DEFAULT_MAX_CACHED_STATES)
921
+ });
922
+ function resolveFoldConfig(options) {
923
+ return FoldOptionsSchema.parse(options);
924
+ }
925
+
846
926
  // src/internal/defer-config.ts
847
927
  import { z as z3 } from "zod";
848
928
  var DeferDurationSchema = z3.object({
@@ -1050,11 +1130,14 @@ function reaction_on(event, events, builder) {
1050
1130
  const reaction = {
1051
1131
  handler: schedule ? make_deferred(handler, schedule) : handler,
1052
1132
  resolver: _this_,
1053
- options: {
1133
+ // #1269: validate the whole bag at the declaration site so a bad
1134
+ // `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
1135
+ // not a NaN gate on the first retry.
1136
+ options: resolveReactionConfig({
1054
1137
  blockOnError: options?.blockOnError ?? true,
1055
1138
  maxRetries: options?.maxRetries ?? 3,
1056
1139
  backoff: options?.backoff
1057
- }
1140
+ })
1058
1141
  };
1059
1142
  events[event].reactions.set(handler.name, reaction);
1060
1143
  return Object.assign(builder, {
@@ -1073,14 +1156,6 @@ function reaction_on(event, events, builder) {
1073
1156
  }
1074
1157
 
1075
1158
  // src/internal/circuit-breaker.ts
1076
- import { z as z4 } from "zod";
1077
- var DEFAULT_CIRCUIT_FAILURE_THRESHOLD = 5;
1078
- var DEFAULT_CIRCUIT_COOLDOWN_MS = 3e4;
1079
- var CircuitBreakerOptionsSchema = z4.object({
1080
- failureThreshold: z4.number().int().min(1).default(DEFAULT_CIRCUIT_FAILURE_THRESHOLD),
1081
- cooldownMs: z4.number().int().min(100).max(36e5).default(DEFAULT_CIRCUIT_COOLDOWN_MS)
1082
- });
1083
- var resolveCircuitBreakerConfig = (options) => CircuitBreakerOptionsSchema.parse(options ?? {});
1084
1159
  var CircuitBreaker = class {
1085
1160
  _failures = 0;
1086
1161
  _opened_at;
@@ -1748,6 +1823,10 @@ function compute_backoff_delay(retry, opts) {
1748
1823
  delay = opts.baseMs * 2 ** r;
1749
1824
  if (opts.maxMs !== void 0) delay = Math.min(delay, opts.maxMs);
1750
1825
  break;
1826
+ default: {
1827
+ const _never = opts.strategy;
1828
+ throw new Error(`unknown backoff strategy: ${String(_never)}`);
1829
+ }
1751
1830
  }
1752
1831
  if (opts.jitter) delay = delay * (0.5 + Math.random());
1753
1832
  return Math.max(0, Math.floor(delay));
@@ -2504,16 +2583,6 @@ var DrainController = class {
2504
2583
  };
2505
2584
 
2506
2585
  // src/internal/projection-fold.ts
2507
- import { z as z5 } from "zod";
2508
- var DEFAULT_FOLD_FLUSH_EVERY = 1e3;
2509
- var DEFAULT_MAX_CACHED_STATES = 1e4;
2510
- var FoldOptionsSchema = z5.object({
2511
- flushEvery: z5.number().int().min(1).default(DEFAULT_FOLD_FLUSH_EVERY),
2512
- maxCachedStates: z5.number().int().min(1).default(DEFAULT_MAX_CACHED_STATES)
2513
- });
2514
- function resolveFoldConfig(options) {
2515
- return FoldOptionsSchema.parse(options);
2516
- }
2517
2586
  function make_fold_handler(me, flush, config2, patch_fn = bare_patch) {
2518
2587
  const cache2 = /* @__PURE__ */ new Map();
2519
2588
  const row = ({ dirty: _, ...row2 }) => row2;
@@ -3434,9 +3503,10 @@ var Act = class {
3434
3503
  let first;
3435
3504
  let last;
3436
3505
  const count = await store().query((e) => {
3437
- if (!first) first = e;
3438
- last = e;
3439
- callback?.(e);
3506
+ const gated = this.registry.query_gate(e.name)(e);
3507
+ if (!first) first = gated;
3508
+ last = gated;
3509
+ callback?.(gated);
3440
3510
  }, query);
3441
3511
  return { first, last, count };
3442
3512
  });
@@ -3470,7 +3540,10 @@ var Act = class {
3470
3540
  async query_array(query) {
3471
3541
  return this._scoped(async () => {
3472
3542
  const events = [];
3473
- await store().query((e) => events.push(e), query);
3543
+ await store().query(
3544
+ (e) => events.push(this.registry.query_gate(e.name)(e)),
3545
+ query
3546
+ );
3474
3547
  return events;
3475
3548
  });
3476
3549
  }
@@ -3540,6 +3613,7 @@ var Act = class {
3540
3613
  * @see {@link start_correlations} for automatic correlation
3541
3614
  */
3542
3615
  async drain(options = {}) {
3616
+ resolveDrainConfig(options);
3543
3617
  if (!this._drain)
3544
3618
  return { fetched: [], leased: [], acked: [], blocked: [] };
3545
3619
  return this._scoped(() => this._drain_all(options));
@@ -4102,6 +4176,7 @@ var Act = class {
4102
4176
  * @see {@link correlate} for manual correlation
4103
4177
  */
4104
4178
  settle(options = {}) {
4179
+ resolveSettleConfig(options);
4105
4180
  if (!this._drain) return;
4106
4181
  this._settle.schedule(options);
4107
4182
  }
@@ -4135,6 +4210,7 @@ function validate_lane_references(registry, lanes) {
4135
4210
  function act() {
4136
4211
  const states = /* @__PURE__ */ new Map();
4137
4212
  const _sf = /* @__PURE__ */ new Map();
4213
+ const _qg = /* @__PURE__ */ new Map();
4138
4214
  const _dp = /* @__PURE__ */ new Map();
4139
4215
  const _de = /* @__PURE__ */ new Map();
4140
4216
  const _ac = /* @__PURE__ */ new Map();
@@ -4144,6 +4220,7 @@ function act() {
4144
4220
  actions: {},
4145
4221
  events: {},
4146
4222
  sensitive_fields: (event_name) => _sf.get(event_name) ?? [],
4223
+ query_gate: (event_name) => _qg.get(event_name) ?? IDENTITY_GATE,
4147
4224
  disclosure_predicate: (state_name) => _dp.get(state_name) ?? null,
4148
4225
  deprecated_events: (state_name) => _de.get(state_name) ?? EMPTY_DEPRECATED,
4149
4226
  autoclose_policy: (state_name) => _ac.get(state_name) ?? null,
@@ -4222,11 +4299,12 @@ function act() {
4222
4299
  },
4223
4300
  withActor: () => builder,
4224
4301
  withLane: (config2) => {
4225
- register_lane(config2, lanes);
4302
+ register_lane(resolveLaneConfig(config2), lanes);
4226
4303
  return builder;
4227
4304
  },
4228
4305
  on: (event) => reaction_on(event, registry.events, builder),
4229
4306
  build: (options) => {
4307
+ resolveActConfig(options);
4230
4308
  const patch_fn = options?.validateFoldedState === true ? validating_patch : bare_patch;
4231
4309
  if (!_built) {
4232
4310
  for (const proj of pending_projections) {
@@ -4261,6 +4339,7 @@ function act() {
4261
4339
  const fields = pii_fields(reg.schema);
4262
4340
  if (fields.length === 0) continue;
4263
4341
  _sf.set(event_name, fields);
4342
+ _qg.set(event_name, make_gate(fields, null));
4264
4343
  for (const [name, reaction] of reg.reactions) {
4265
4344
  const inner = reaction.handler;
4266
4345
  const wrapped = (event, stream, app) => inner(pii_strip(event, fields), stream, app);
@@ -4287,10 +4366,12 @@ function act() {
4287
4366
  }
4288
4367
  const disclose = state2.disclose ?? null;
4289
4368
  state2.pii_aware = true;
4290
- state2.view = (event, actor) => pii_gate(
4369
+ const view_gates = /* @__PURE__ */ new Map();
4370
+ for (const [event_name, fields] of fields_by_event) {
4371
+ view_gates.set(event_name, make_gate(fields, disclose));
4372
+ }
4373
+ state2.view = (event, actor) => (view_gates.get(event.name) ?? IDENTITY_GATE)(
4291
4374
  event,
4292
- fields_by_event.get(event.name) ?? [],
4293
- disclose,
4294
4375
  actor
4295
4376
  );
4296
4377
  state2.message = (validated) => {
@@ -4543,6 +4624,7 @@ function action_builder(state2) {
4543
4624
  throw new Error(`Duplicate action "${action2}"`);
4544
4625
  internal.actions[action2] = schema;
4545
4626
  if (options) {
4627
+ resolveActionConfig(options);
4546
4628
  internal.options ??= {};
4547
4629
  internal.options[action2] = options;
4548
4630
  }