@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.cjs CHANGED
@@ -445,32 +445,27 @@ function pii_split(emitted, fields) {
445
445
  return { name: emitted.name, data, pii };
446
446
  }
447
447
  function pii_gate(event, fields, predicate, actor) {
448
- if (fields.length === 0) return event;
449
448
  const data = event.data;
450
- if (event.pii == null) {
449
+ const { pii, ...rest } = event;
450
+ if (pii == null) {
451
451
  const shredded = { ...data };
452
452
  for (const f of fields) shredded[f] = SHREDDED;
453
- return {
454
- ...event,
455
- data: shredded
456
- };
453
+ return { ...rest, data: shredded };
457
454
  }
458
455
  const allowed = !!actor && !!predicate && predicate(event, actor);
459
456
  if (allowed) {
460
457
  return {
461
- ...event,
462
- data: {
463
- ...data,
464
- ...event.pii
465
- }
458
+ ...rest,
459
+ data: { ...data, ...pii }
466
460
  };
467
461
  }
468
462
  const redacted = { ...data };
469
463
  for (const f of fields) redacted[f] = REDACTED;
470
- return {
471
- ...event,
472
- data: redacted
473
- };
464
+ return { ...rest, data: redacted };
465
+ }
466
+ var IDENTITY_GATE = (event) => event;
467
+ function make_gate(fields, predicate) {
468
+ return (event, actor) => pii_gate(event, fields, predicate, actor);
474
469
  }
475
470
  function pii_strip(event, fields) {
476
471
  const data = event.data;
@@ -2044,84 +2039,8 @@ var PASS_FACTORIES = {
2044
2039
  "clock-anomalies": make_clock_anomalies_pass
2045
2040
  };
2046
2041
 
2047
- // src/internal/autoclose-config.ts
2048
- var import_zod5 = require("zod");
2049
- var DEFAULT_AUTOCLOSE_CYCLE_MINUTES = 720;
2050
- var DEFAULT_CLOSE_BATCH_SIZE = 64;
2051
- var DEFAULT_CLOSE_YIELD_MS = 0;
2052
- var DEFAULT_AUTOCLOSE_WINDOW_TZ = "UTC";
2053
- function is_valid_time_zone(tz) {
2054
- try {
2055
- new Intl.DateTimeFormat("en-US", { timeZone: tz });
2056
- return true;
2057
- } catch {
2058
- return false;
2059
- }
2060
- }
2061
- var AutocloseWindowSchema = import_zod5.z.object({
2062
- start: import_zod5.z.number().int().min(0).max(23, { message: "autocloseWindow.start must be an hour in [0, 23]" }),
2063
- end: import_zod5.z.number().int().min(0).max(23, { message: "autocloseWindow.end must be an hour in [0, 23]" }),
2064
- timeZone: import_zod5.z.string().refine(is_valid_time_zone, {
2065
- message: "autocloseWindow.timeZone must be a valid IANA time zone"
2066
- }).default(DEFAULT_AUTOCLOSE_WINDOW_TZ)
2067
- }).refine((w) => w.start !== w.end, {
2068
- message: "autocloseWindow.start and end must differ \u2014 an empty window disables autoclose"
2069
- });
2070
- var AutocloseOptionsSchema = import_zod5.z.object({
2071
- autocloseCycleMinutes: import_zod5.z.number().int().min(1).max(1440).default(DEFAULT_AUTOCLOSE_CYCLE_MINUTES),
2072
- closeBatchSize: import_zod5.z.number().int().min(1).max(1024).default(DEFAULT_CLOSE_BATCH_SIZE),
2073
- closeYieldMs: import_zod5.z.number().min(0).max(1e3).default(DEFAULT_CLOSE_YIELD_MS),
2074
- closeOnError: import_zod5.z.boolean().default(false),
2075
- autocloseWindow: AutocloseWindowSchema.optional()
2076
- });
2077
- function resolveAutocloseConfig(options) {
2078
- return AutocloseOptionsSchema.parse({
2079
- autocloseCycleMinutes: options?.autocloseCycleMinutes,
2080
- closeBatchSize: options?.closeBatchSize,
2081
- closeYieldMs: options?.closeYieldMs,
2082
- closeOnError: options?.closeOnError,
2083
- autocloseWindow: options?.autocloseWindow
2084
- });
2085
- }
2086
- function hour_in_zone(now, timeZone) {
2087
- const parts = new Intl.DateTimeFormat("en-US", {
2088
- timeZone,
2089
- hour: "2-digit",
2090
- hourCycle: "h23"
2091
- }).formatToParts(now);
2092
- return Number(parts.find((p) => p.type === "hour")?.value);
2093
- }
2094
- function hour_in_range(hour, start, end) {
2095
- return start < end ? hour >= start && hour < end : hour >= start || hour < end;
2096
- }
2097
- function is_dst_gap_open(now, timeZone, start) {
2098
- const hour = hour_in_zone(now, timeZone);
2099
- if (hour <= start) return false;
2100
- const prev = hour_in_zone(new Date(now.getTime() - 36e5), timeZone);
2101
- return prev === start - 1 && hour === start + 1;
2102
- }
2103
- function in_autoclose_window(window, now) {
2104
- if (!window) return true;
2105
- const hour = hour_in_zone(now, window.timeZone);
2106
- return hour_in_range(hour, window.start, window.end) || is_dst_gap_open(now, window.timeZone, window.start);
2107
- }
2108
- function next_window_open(window, now) {
2109
- const start_ms = now.getTime();
2110
- for (let h = 0; h <= 48; h++) {
2111
- const candidate = new Date(start_ms + h * 36e5);
2112
- if (hour_in_zone(candidate, window.timeZone) === window.start)
2113
- return candidate;
2114
- const boundary = new Date(
2115
- candidate.getTime() - candidate.getTime() % 36e5
2116
- );
2117
- if (is_dst_gap_open(boundary, window.timeZone, window.start))
2118
- return boundary;
2119
- }
2120
- return new Date(start_ms + 864e5);
2121
- }
2122
-
2123
2042
  // src/internal/autoclose-policy.ts
2124
- var import_zod6 = require("zod");
2043
+ var import_zod5 = require("zod");
2125
2044
  var DAY_MS = 864e5;
2126
2045
  var MIN_AFTER_DAYS = 1 / 1440;
2127
2046
  var MIN_KEEP_DAYS = 1;
@@ -2131,21 +2050,21 @@ function days_after(date, days) {
2131
2050
  function days_before_now(days) {
2132
2051
  return new Date(Date.now() - days * DAY_MS);
2133
2052
  }
2134
- var window_schema = (field, min_days, floor) => import_zod6.z.object({
2135
- days: import_zod6.z.number({ message: `autocloses: ${field}.days must be a number` }).positive(`autocloses: ${field}.days must be > 0`)
2053
+ var window_schema = (field, min_days, floor) => import_zod5.z.object({
2054
+ days: import_zod5.z.number({ message: `autocloses: ${field}.days must be a number` }).positive(`autocloses: ${field}.days must be > 0`)
2136
2055
  }).refine((o) => o.days >= min_days, {
2137
2056
  message: `autocloses: ${field} resolves to < ${floor}, which is too short to be a meaningful retention window`
2138
2057
  });
2139
2058
  var AfterSchema = window_schema("after", MIN_AFTER_DAYS, "one minute");
2140
2059
  var KeepSchema = window_schema("keep", MIN_KEEP_DAYS, "one day");
2141
- var IsSchema = import_zod6.z.union([
2142
- import_zod6.z.string().min(1, "autocloses: is must be a non-empty event name"),
2143
- import_zod6.z.array(
2144
- import_zod6.z.string().min(1, "autocloses: is entries must be non-empty event names")
2060
+ var IsSchema = import_zod5.z.union([
2061
+ import_zod5.z.string().min(1, "autocloses: is must be a non-empty event name"),
2062
+ import_zod5.z.array(
2063
+ import_zod5.z.string().min(1, "autocloses: is entries must be non-empty event names")
2145
2064
  ).min(1, "autocloses: is must include at least one event name").readonly()
2146
2065
  ]);
2147
- var ReachesSchema = import_zod6.z.number({ message: "autocloses: reaches must be a number" }).int("autocloses: reaches must be an integer").min(1, "autocloses: reaches must be >= 1");
2148
- var OrBlockSchema = import_zod6.z.object({
2066
+ var ReachesSchema = import_zod5.z.number({ message: "autocloses: reaches must be a number" }).int("autocloses: reaches must be an integer").min(1, "autocloses: reaches must be >= 1");
2067
+ var OrBlockSchema = import_zod5.z.object({
2149
2068
  after: AfterSchema.optional(),
2150
2069
  is: IsSchema.optional(),
2151
2070
  reaches: ReachesSchema.optional()
@@ -2155,7 +2074,7 @@ var OrBlockSchema = import_zod6.z.object({
2155
2074
  message: "autocloses: `or` block must include at least one of after / is / reaches"
2156
2075
  }
2157
2076
  );
2158
- var AutoclosePolicySchema = import_zod6.z.object({
2077
+ var AutoclosePolicySchema = import_zod5.z.object({
2159
2078
  after: AfterSchema.optional(),
2160
2079
  is: IsSchema.optional(),
2161
2080
  reaches: ReachesSchema.optional(),
@@ -2211,6 +2130,44 @@ function compile_autoclose_policy(options) {
2211
2130
  };
2212
2131
  }
2213
2132
 
2133
+ // src/internal/autoclose-window.ts
2134
+ function hour_in_zone(now, timeZone) {
2135
+ const parts = new Intl.DateTimeFormat("en-US", {
2136
+ timeZone,
2137
+ hour: "2-digit",
2138
+ hourCycle: "h23"
2139
+ }).formatToParts(now);
2140
+ return Number(parts.find((p) => p.type === "hour")?.value);
2141
+ }
2142
+ function hour_in_range(hour, start, end) {
2143
+ return start < end ? hour >= start && hour < end : hour >= start || hour < end;
2144
+ }
2145
+ function is_dst_gap_open(now, timeZone, start) {
2146
+ const hour = hour_in_zone(now, timeZone);
2147
+ if (hour <= start) return false;
2148
+ const prev = hour_in_zone(new Date(now.getTime() - 36e5), timeZone);
2149
+ return prev === start - 1 && hour === start + 1;
2150
+ }
2151
+ function in_autoclose_window(window, now) {
2152
+ if (!window) return true;
2153
+ const hour = hour_in_zone(now, window.timeZone);
2154
+ return hour_in_range(hour, window.start, window.end) || is_dst_gap_open(now, window.timeZone, window.start);
2155
+ }
2156
+ function next_window_open(window, now) {
2157
+ const start_ms = now.getTime();
2158
+ for (let h = 0; h <= 48; h++) {
2159
+ const candidate = new Date(start_ms + h * 36e5);
2160
+ if (hour_in_zone(candidate, window.timeZone) === window.start)
2161
+ return candidate;
2162
+ const boundary = new Date(
2163
+ candidate.getTime() - candidate.getTime() % 36e5
2164
+ );
2165
+ if (is_dst_gap_open(boundary, window.timeZone, window.start))
2166
+ return boundary;
2167
+ }
2168
+ return new Date(start_ms + 864e5);
2169
+ }
2170
+
2214
2171
  // src/internal/close-signal.ts
2215
2172
  var CloseSignal = class extends Error {
2216
2173
  /**
@@ -2391,6 +2348,123 @@ function classify_registry(registry, states) {
2391
2348
  };
2392
2349
  }
2393
2350
 
2351
+ // src/internal/config.ts
2352
+ var import_zod6 = require("zod");
2353
+ var BackoffOptionsSchema = import_zod6.z.object({
2354
+ strategy: import_zod6.z.enum(["fixed", "linear", "exponential"]),
2355
+ baseMs: import_zod6.z.number().min(0),
2356
+ maxMs: import_zod6.z.number().gt(0).optional(),
2357
+ jitter: import_zod6.z.boolean().optional()
2358
+ });
2359
+ var ReactionOptionsSchema = import_zod6.z.object({
2360
+ blockOnError: import_zod6.z.boolean(),
2361
+ maxRetries: import_zod6.z.number().int().min(0),
2362
+ backoff: BackoffOptionsSchema.optional()
2363
+ });
2364
+ function resolveReactionConfig(options) {
2365
+ return ReactionOptionsSchema.parse(options);
2366
+ }
2367
+ var ActionOptionsSchema = import_zod6.z.object({
2368
+ maxRetries: import_zod6.z.number().int().min(0).optional(),
2369
+ backoff: BackoffOptionsSchema.optional()
2370
+ });
2371
+ function resolveActionConfig(options) {
2372
+ return ActionOptionsSchema.parse(options);
2373
+ }
2374
+ var LaneConfigSchema = import_zod6.z.object({
2375
+ name: import_zod6.z.string().min(1),
2376
+ leaseMillis: import_zod6.z.number().min(0).optional(),
2377
+ streamLimit: import_zod6.z.number().int().min(0).optional(),
2378
+ cycleMs: import_zod6.z.number().min(0).optional()
2379
+ });
2380
+ function resolveLaneConfig(options) {
2381
+ LaneConfigSchema.parse(options);
2382
+ return options;
2383
+ }
2384
+ var DrainOptionsSchema = import_zod6.z.object({
2385
+ streamLimit: import_zod6.z.number().int().min(0).optional(),
2386
+ eventLimit: import_zod6.z.number().int().min(0).optional(),
2387
+ leaseMillis: import_zod6.z.number().min(0).optional()
2388
+ });
2389
+ function resolveDrainConfig(options) {
2390
+ if (options === void 0) return void 0;
2391
+ DrainOptionsSchema.parse(options);
2392
+ return options;
2393
+ }
2394
+ var SettleOptionsSchema = DrainOptionsSchema.extend({
2395
+ debounceMs: import_zod6.z.number().min(0).optional(),
2396
+ // `maxPasses` defaults to Infinity (no cap) when omitted; a present value is
2397
+ // a non-negative integer — `0` is legal and means "run no passes".
2398
+ maxPasses: import_zod6.z.number().int().min(0).optional()
2399
+ }).loose();
2400
+ function resolveSettleConfig(options) {
2401
+ if (options === void 0) return void 0;
2402
+ SettleOptionsSchema.parse(options);
2403
+ return options;
2404
+ }
2405
+ var ActOptionsSchema = import_zod6.z.object({
2406
+ maxSubscribedStreams: import_zod6.z.number().int().min(1).optional(),
2407
+ settleDebounceMs: import_zod6.z.number().int().min(0).optional()
2408
+ }).loose();
2409
+ function resolveActConfig(options) {
2410
+ if (options === void 0) return void 0;
2411
+ ActOptionsSchema.parse(options);
2412
+ return options;
2413
+ }
2414
+ var DEFAULT_AUTOCLOSE_CYCLE_MINUTES = 720;
2415
+ var DEFAULT_CLOSE_BATCH_SIZE = 64;
2416
+ var DEFAULT_CLOSE_YIELD_MS = 0;
2417
+ var DEFAULT_AUTOCLOSE_WINDOW_TZ = "UTC";
2418
+ function is_valid_time_zone(tz) {
2419
+ try {
2420
+ new Intl.DateTimeFormat("en-US", { timeZone: tz });
2421
+ return true;
2422
+ } catch {
2423
+ return false;
2424
+ }
2425
+ }
2426
+ var AutocloseWindowSchema = import_zod6.z.object({
2427
+ start: import_zod6.z.number().int().min(0).max(23, { message: "autocloseWindow.start must be an hour in [0, 23]" }),
2428
+ end: import_zod6.z.number().int().min(0).max(23, { message: "autocloseWindow.end must be an hour in [0, 23]" }),
2429
+ timeZone: import_zod6.z.string().refine(is_valid_time_zone, {
2430
+ message: "autocloseWindow.timeZone must be a valid IANA time zone"
2431
+ }).default(DEFAULT_AUTOCLOSE_WINDOW_TZ)
2432
+ }).refine((w) => w.start !== w.end, {
2433
+ message: "autocloseWindow.start and end must differ \u2014 an empty window disables autoclose"
2434
+ });
2435
+ var AutocloseOptionsSchema = import_zod6.z.object({
2436
+ autocloseCycleMinutes: import_zod6.z.number().int().min(1).max(1440).default(DEFAULT_AUTOCLOSE_CYCLE_MINUTES),
2437
+ closeBatchSize: import_zod6.z.number().int().min(1).max(1024).default(DEFAULT_CLOSE_BATCH_SIZE),
2438
+ closeYieldMs: import_zod6.z.number().min(0).max(1e3).default(DEFAULT_CLOSE_YIELD_MS),
2439
+ closeOnError: import_zod6.z.boolean().default(false),
2440
+ autocloseWindow: AutocloseWindowSchema.optional()
2441
+ });
2442
+ function resolveAutocloseConfig(options) {
2443
+ return AutocloseOptionsSchema.parse({
2444
+ autocloseCycleMinutes: options?.autocloseCycleMinutes,
2445
+ closeBatchSize: options?.closeBatchSize,
2446
+ closeYieldMs: options?.closeYieldMs,
2447
+ closeOnError: options?.closeOnError,
2448
+ autocloseWindow: options?.autocloseWindow
2449
+ });
2450
+ }
2451
+ var DEFAULT_CIRCUIT_FAILURE_THRESHOLD = 5;
2452
+ var DEFAULT_CIRCUIT_COOLDOWN_MS = 3e4;
2453
+ var CircuitBreakerOptionsSchema = import_zod6.z.object({
2454
+ failureThreshold: import_zod6.z.number().int().min(1).default(DEFAULT_CIRCUIT_FAILURE_THRESHOLD),
2455
+ cooldownMs: import_zod6.z.number().int().min(100).max(36e5).default(DEFAULT_CIRCUIT_COOLDOWN_MS)
2456
+ });
2457
+ var resolveCircuitBreakerConfig = (options) => CircuitBreakerOptionsSchema.parse(options ?? {});
2458
+ var DEFAULT_FOLD_FLUSH_EVERY = 1e3;
2459
+ var DEFAULT_MAX_CACHED_STATES = 1e4;
2460
+ var FoldOptionsSchema = import_zod6.z.object({
2461
+ flushEvery: import_zod6.z.number().int().min(1).default(DEFAULT_FOLD_FLUSH_EVERY),
2462
+ maxCachedStates: import_zod6.z.number().int().min(1).default(DEFAULT_MAX_CACHED_STATES)
2463
+ });
2464
+ function resolveFoldConfig(options) {
2465
+ return FoldOptionsSchema.parse(options);
2466
+ }
2467
+
2394
2468
  // src/internal/defer-config.ts
2395
2469
  var import_zod7 = require("zod");
2396
2470
  var DeferDurationSchema = import_zod7.z.object({
@@ -2598,11 +2672,14 @@ function reaction_on(event, events, builder) {
2598
2672
  const reaction = {
2599
2673
  handler: schedule ? make_deferred(handler, schedule) : handler,
2600
2674
  resolver: _this_,
2601
- options: {
2675
+ // #1269: validate the whole bag at the declaration site so a bad
2676
+ // `maxRetries`/`backoff`/`blockOnError` throws ZodError at build,
2677
+ // not a NaN gate on the first retry.
2678
+ options: resolveReactionConfig({
2602
2679
  blockOnError: options?.blockOnError ?? true,
2603
2680
  maxRetries: options?.maxRetries ?? 3,
2604
2681
  backoff: options?.backoff
2605
- }
2682
+ })
2606
2683
  };
2607
2684
  events[event].reactions.set(handler.name, reaction);
2608
2685
  return Object.assign(builder, {
@@ -2621,14 +2698,6 @@ function reaction_on(event, events, builder) {
2621
2698
  }
2622
2699
 
2623
2700
  // src/internal/circuit-breaker.ts
2624
- var import_zod9 = require("zod");
2625
- var DEFAULT_CIRCUIT_FAILURE_THRESHOLD = 5;
2626
- var DEFAULT_CIRCUIT_COOLDOWN_MS = 3e4;
2627
- var CircuitBreakerOptionsSchema = import_zod9.z.object({
2628
- failureThreshold: import_zod9.z.number().int().min(1).default(DEFAULT_CIRCUIT_FAILURE_THRESHOLD),
2629
- cooldownMs: import_zod9.z.number().int().min(100).max(36e5).default(DEFAULT_CIRCUIT_COOLDOWN_MS)
2630
- });
2631
- var resolveCircuitBreakerConfig = (options) => CircuitBreakerOptionsSchema.parse(options ?? {});
2632
2701
  var CircuitBreaker = class {
2633
2702
  _failures = 0;
2634
2703
  _opened_at;
@@ -3296,6 +3365,10 @@ function compute_backoff_delay(retry, opts) {
3296
3365
  delay = opts.baseMs * 2 ** r;
3297
3366
  if (opts.maxMs !== void 0) delay = Math.min(delay, opts.maxMs);
3298
3367
  break;
3368
+ default: {
3369
+ const _never = opts.strategy;
3370
+ throw new Error(`unknown backoff strategy: ${String(_never)}`);
3371
+ }
3299
3372
  }
3300
3373
  if (opts.jitter) delay = delay * (0.5 + Math.random());
3301
3374
  return Math.max(0, Math.floor(delay));
@@ -4052,16 +4125,6 @@ var DrainController = class {
4052
4125
  };
4053
4126
 
4054
4127
  // src/internal/projection-fold.ts
4055
- var import_zod10 = require("zod");
4056
- var DEFAULT_FOLD_FLUSH_EVERY = 1e3;
4057
- var DEFAULT_MAX_CACHED_STATES = 1e4;
4058
- var FoldOptionsSchema = import_zod10.z.object({
4059
- flushEvery: import_zod10.z.number().int().min(1).default(DEFAULT_FOLD_FLUSH_EVERY),
4060
- maxCachedStates: import_zod10.z.number().int().min(1).default(DEFAULT_MAX_CACHED_STATES)
4061
- });
4062
- function resolveFoldConfig(options) {
4063
- return FoldOptionsSchema.parse(options);
4064
- }
4065
4128
  function make_fold_handler(me, flush, config2, patch_fn = bare_patch) {
4066
4129
  const cache3 = /* @__PURE__ */ new Map();
4067
4130
  const row = ({ dirty: _, ...row2 }) => row2;
@@ -4982,9 +5045,10 @@ var Act = class {
4982
5045
  let first;
4983
5046
  let last;
4984
5047
  const count = await store2().query((e) => {
4985
- if (!first) first = e;
4986
- last = e;
4987
- callback?.(e);
5048
+ const gated = this.registry.query_gate(e.name)(e);
5049
+ if (!first) first = gated;
5050
+ last = gated;
5051
+ callback?.(gated);
4988
5052
  }, query);
4989
5053
  return { first, last, count };
4990
5054
  });
@@ -5018,7 +5082,10 @@ var Act = class {
5018
5082
  async query_array(query) {
5019
5083
  return this._scoped(async () => {
5020
5084
  const events = [];
5021
- await store2().query((e) => events.push(e), query);
5085
+ await store2().query(
5086
+ (e) => events.push(this.registry.query_gate(e.name)(e)),
5087
+ query
5088
+ );
5022
5089
  return events;
5023
5090
  });
5024
5091
  }
@@ -5088,6 +5155,7 @@ var Act = class {
5088
5155
  * @see {@link start_correlations} for automatic correlation
5089
5156
  */
5090
5157
  async drain(options = {}) {
5158
+ resolveDrainConfig(options);
5091
5159
  if (!this._drain)
5092
5160
  return { fetched: [], leased: [], acked: [], blocked: [] };
5093
5161
  return this._scoped(() => this._drain_all(options));
@@ -5650,6 +5718,7 @@ var Act = class {
5650
5718
  * @see {@link correlate} for manual correlation
5651
5719
  */
5652
5720
  settle(options = {}) {
5721
+ resolveSettleConfig(options);
5653
5722
  if (!this._drain) return;
5654
5723
  this._settle.schedule(options);
5655
5724
  }
@@ -5683,6 +5752,7 @@ function validate_lane_references(registry, lanes) {
5683
5752
  function act() {
5684
5753
  const states = /* @__PURE__ */ new Map();
5685
5754
  const _sf = /* @__PURE__ */ new Map();
5755
+ const _qg = /* @__PURE__ */ new Map();
5686
5756
  const _dp = /* @__PURE__ */ new Map();
5687
5757
  const _de = /* @__PURE__ */ new Map();
5688
5758
  const _ac = /* @__PURE__ */ new Map();
@@ -5692,6 +5762,7 @@ function act() {
5692
5762
  actions: {},
5693
5763
  events: {},
5694
5764
  sensitive_fields: (event_name) => _sf.get(event_name) ?? [],
5765
+ query_gate: (event_name) => _qg.get(event_name) ?? IDENTITY_GATE,
5695
5766
  disclosure_predicate: (state_name) => _dp.get(state_name) ?? null,
5696
5767
  deprecated_events: (state_name) => _de.get(state_name) ?? EMPTY_DEPRECATED,
5697
5768
  autoclose_policy: (state_name) => _ac.get(state_name) ?? null,
@@ -5770,11 +5841,12 @@ function act() {
5770
5841
  },
5771
5842
  withActor: () => builder,
5772
5843
  withLane: (config2) => {
5773
- register_lane(config2, lanes);
5844
+ register_lane(resolveLaneConfig(config2), lanes);
5774
5845
  return builder;
5775
5846
  },
5776
5847
  on: (event) => reaction_on(event, registry.events, builder),
5777
5848
  build: (options) => {
5849
+ resolveActConfig(options);
5778
5850
  const patch_fn = options?.validateFoldedState === true ? validating_patch : bare_patch;
5779
5851
  if (!_built) {
5780
5852
  for (const proj of pending_projections) {
@@ -5809,6 +5881,7 @@ function act() {
5809
5881
  const fields = pii_fields(reg.schema);
5810
5882
  if (fields.length === 0) continue;
5811
5883
  _sf.set(event_name, fields);
5884
+ _qg.set(event_name, make_gate(fields, null));
5812
5885
  for (const [name, reaction] of reg.reactions) {
5813
5886
  const inner = reaction.handler;
5814
5887
  const wrapped = (event, stream, app) => inner(pii_strip(event, fields), stream, app);
@@ -5835,10 +5908,12 @@ function act() {
5835
5908
  }
5836
5909
  const disclose = state2.disclose ?? null;
5837
5910
  state2.pii_aware = true;
5838
- state2.view = (event, actor) => pii_gate(
5911
+ const view_gates = /* @__PURE__ */ new Map();
5912
+ for (const [event_name, fields] of fields_by_event) {
5913
+ view_gates.set(event_name, make_gate(fields, disclose));
5914
+ }
5915
+ state2.view = (event, actor) => (view_gates.get(event.name) ?? IDENTITY_GATE)(
5839
5916
  event,
5840
- fields_by_event.get(event.name) ?? [],
5841
- disclose,
5842
5917
  actor
5843
5918
  );
5844
5919
  state2.message = (validated) => {
@@ -6091,6 +6166,7 @@ function action_builder(state2) {
6091
6166
  throw new Error(`Duplicate action "${action2}"`);
6092
6167
  internal.actions[action2] = schema;
6093
6168
  if (options) {
6169
+ resolveActionConfig(options);
6094
6170
  internal.options ??= {};
6095
6171
  internal.options[action2] = options;
6096
6172
  }