@rotorsoft/act 1.33.18 → 1.33.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -40,7 +40,7 @@ import {
40
40
  sleep,
41
41
  store,
42
42
  validate
43
- } from "./chunk-3OTABSIB.js";
43
+ } from "./chunk-5Z53Y7SG.js";
44
44
  import {
45
45
  ActorSchema,
46
46
  CausationEventSchema,
@@ -70,7 +70,7 @@ import {
70
70
  pii_fields,
71
71
  pii_schemas,
72
72
  sensitive
73
- } from "./chunk-SD7SW47Z.js";
73
+ } from "./chunk-HEHGZHHA.js";
74
74
 
75
75
  // src/signals.ts
76
76
  process.once("SIGINT", async (arg) => {
@@ -1177,7 +1177,7 @@ var CorrelateCycle = class {
1177
1177
  _restoring = false;
1178
1178
  _init_promise;
1179
1179
  // Bounded by `maxSubscribedStreams`; static records live apart so eviction
1180
- // never drops their +Infinity floor.
1180
+ // never lets a resolution re-lane them.
1181
1181
  _dynamic_subscriptions;
1182
1182
  _static_subscriptions = /* @__PURE__ */ new Map();
1183
1183
  _patterns = new LruMap(PATTERN_CACHE_SIZE);
@@ -1226,7 +1226,6 @@ var CorrelateCycle = class {
1226
1226
  this._checkpoint = correlated_at >= 0 ? correlated_at : Math.max(-1, watermark - COLD_START_BACK_SCAN);
1227
1227
  for (const { stream, priority = 0, lane } of this._static_targets) {
1228
1228
  this._static_subscriptions.set(stream, {
1229
- floor: Number.POSITIVE_INFINITY,
1230
1229
  priority,
1231
1230
  lane
1232
1231
  });
@@ -1330,9 +1329,10 @@ var CorrelateCycle = class {
1330
1329
  );
1331
1330
  lane = void 0;
1332
1331
  }
1333
- const recorded = this._static_subscriptions.get(resolved.target) ?? this._dynamic_subscriptions.get(resolved.target);
1332
+ const fixed = this._static_subscriptions.get(resolved.target);
1333
+ const recorded = fixed ?? this._dynamic_subscriptions.get(resolved.target);
1334
1334
  const priority = resolved.priority ?? 0;
1335
- const upgraded = !recorded || priority > recorded.floor;
1335
+ const upgraded = !recorded || !fixed && priority > recorded.priority;
1336
1336
  const carried = upgraded ? { priority, lane } : { priority: recorded.priority, lane: recorded.lane };
1337
1337
  const entry = correlated.get(resolved.target) || {
1338
1338
  source: resolved.source,
@@ -1402,7 +1402,6 @@ var CorrelateCycle = class {
1402
1402
  for (const { stream, priority, lane } of streams) {
1403
1403
  if (correlated.get(stream)?.upgraded)
1404
1404
  this._dynamic_subscriptions.set(stream, {
1405
- floor: priority,
1406
1405
  priority,
1407
1406
  lane
1408
1407
  });
@@ -1431,7 +1430,6 @@ var CorrelateCycle = class {
1431
1430
  );
1432
1431
  if (!row) return;
1433
1432
  this._dynamic_subscriptions.set(stream, {
1434
- floor: row.priority,
1435
1433
  priority: row.priority,
1436
1434
  lane: row.lane
1437
1435
  });
@@ -2345,15 +2343,14 @@ async function run_drain_cycle(deps, cycle) {
2345
2343
  return handle({ ...lease, at }, payloads);
2346
2344
  })
2347
2345
  );
2348
- const blocked = await ops.block(
2349
- handled.filter(({ block: block2 }) => block2).map(({ lease, error }) => ({ ...lease, error }))
2350
- );
2346
+ const to_block = handled.filter(({ block: block2 }) => block2).map(({ lease, error }) => ({ ...lease, error }));
2347
+ const blocked = to_block.length ? await ops.block(to_block) : [];
2351
2348
  if (blocked.length) deps.on_blocked(blocked);
2352
2349
  const submitted = handled.flatMap((h, i) => {
2353
2350
  const advance = h.handled > 0 ? h.acked_at : leased[i].at;
2354
2351
  return h.defer !== void 0 ? { ...h.lease, at: advance, due: h.defer, retry: -1 } : h.next_attempt_at !== void 0 ? { ...h.lease, at: advance, due: h.next_attempt_at } : h.handled > 0 || !h.error ? { ...h.lease, at: h.acked_at } : [];
2355
2352
  });
2356
- const acked = await ops.ack(submitted);
2353
+ const acked = submitted.length ? await ops.ack(submitted) : [];
2357
2354
  const expected = submitted.filter((l) => l.due === void 0).length;
2358
2355
  if (acked.length < expected)
2359
2356
  log().warn(
@@ -2856,9 +2853,8 @@ var SettleLoop = class {
2856
2853
  * `debounceMs` brings it forward), and a call during a running cycle
2857
2854
  * queues one more pass after it. Callers pass options, which the next
2858
2855
  * pass uses; internal wake-ups pass none, so they never discard a
2859
- * caller's. The cycle runs correlate→drain in a
2860
- * loop until no progress is made (no new subscriptions, no events read,
2861
- * no streams leased) or `maxPasses` is reached, then emits the
2856
+ * caller's. The cycle runs correlate→drain passes until one makes no
2857
+ * progress (see {@link SettleOptions.maxPasses}), then emits the
2862
2858
  * `"settled"` lifecycle event via {@link SettleDeps.on_settled}.
2863
2859
  */
2864
2860
  schedule(options) {
@@ -3737,8 +3733,8 @@ var Act = class {
3737
3733
  * `__snapshot__` events (counted in the result); `on_progress`
3738
3734
  * fires once per event.
3739
3735
  * @param sink - Where the events land. Defaults to this Act's store.
3740
- * @returns {@link ScanResult} with `kept`, `duration_ms`, and
3741
- * `dropped` per-category counters.
3736
+ * @returns The {@link ScanResult}: what was kept, migrated and dropped,
3737
+ * and how long it took.
3742
3738
  *
3743
3739
  * @example Restore a CSV backup into the connected store
3744
3740
  * ```typescript
@@ -3908,8 +3904,8 @@ var Act = class {
3908
3904
  * `unblock()`, `restore()`) schedules this on its own unless the app
3909
3905
  * sets `autoSettle: false`. Call it at startup, to run what was pending
3910
3906
  * before a restart, or with options for the next pass; the scheduling
3911
- * rule is in the event-sourcing docs (§ settle). Runs correlate→drain in a loop until a pass makes no
3912
- * progress — no new subscriptions, no events read, no streams leased —
3907
+ * rule is in the event-sourcing docs (§ settle). Runs correlate→drain
3908
+ * passes until one makes no progress (see {@link SettleOptions.maxPasses}),
3913
3909
  * then emits the `"settled"` lifecycle event, so one call fully catches
3914
3910
  * up paginated streams without forcing callers to loop.
3915
3911
  *