@rotorsoft/act 1.32.20 → 1.32.21

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.
@@ -212,6 +212,17 @@ export declare class CorrelateCycle<TSchemaReg extends SchemaRegister<TActions>,
212
212
  /** False when the pass was disarmed and returned without a store read. */
213
213
  scanned: boolean;
214
214
  }>;
215
+ /**
216
+ * Give each target this scan had no record of the record its row holds.
217
+ *
218
+ * A target with no record is either new or forgotten. Its row, when it
219
+ * has one, says what lane and priority it was subscribed at; a resolution
220
+ * that doesn't beat that priority carries the row's values, exactly as if
221
+ * the record had never been evicted. One read per target with no record,
222
+ * and only when more than one lane is declared: with one lane there is no
223
+ * lane to lose, and the store already keeps the higher priority.
224
+ */
225
+ private _recall;
215
226
  /**
216
227
  * Hand the correlation lease back early.
217
228
  *
@@ -1 +1 @@
1
- {"version":3,"file":"correlate-cycle.d.ts","sourceRoot":"","sources":["../../../src/internal/correlate-cycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,KAAK,EAEV,KAAK,EACL,QAAQ,EACR,cAAc,EACd,OAAO,EAER,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA4E3C;;;;;;;;;GASG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAgDF,2DAA2D;AAC3D,MAAM,MAAM,kBAAkB,CAC5B,UAAU,SAAS,cAAc,CAAC,QAAQ,CAAC,EAC3C,OAAO,SAAS,OAAO,EACvB,QAAQ,SAAS,OAAO,IACtB;IACF,QAAQ,EAAE,QAAQ,CA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nD,YAA2C,GAC5C,EAAE,kBAAkB,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,EAanD;IAED,gCAAgC;IAChC,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED;;;;OAIG;IACH,GAAG,IAAI,IAAI,CAEV;IAED;;;;;;;;;OASG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAa1B;YAEa,SAAS;IA0BvB;;;;;;;;;OASG;IACH,OAAO,IAAI,IAAI,CAOd;IAED;;;;OAIG;IACH,iBAAiB,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,CAEjD;IAED;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IAcxB;;;;;;;;;OASG;IACG,SAAS,CACb,KAAK,GAAE,KAAgC;IACvC;;;;;;;;;;OAUG;IACH,KAAK,UAAQ,GACZ,OAAO,CAAC;QACT,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,0EAA0E;QAC1E,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC,CAwMD;IAED;;;;;;;;;OASG;YACW,OAAO;IAmCrB;;;;;;OAMG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAiBzC;CACF"}
@@ -5,13 +5,17 @@
5
5
  * The shared "next visit time" primitive. A `DeferTimer` holds a
6
6
  * `stream → due-time` map and a single collapsed wake timer: it parks
7
7
  * streams that should be re-visited later and fires one `on_wake` callback
8
- * at the earliest pending due-time, garbage-collecting the entries that have
9
- * come due.
8
+ * at the earliest pending due-time.
10
9
  *
11
10
  * The {@link "drain-cycle".DrainController} rides it for per-reaction
12
11
  * backoff (a retry's `next_attempt_at`) and for the `defer` outcome, which
13
12
  * holds a stream pending without advancing the watermark or bumping `retry`.
14
13
  * The wake runs a drain, and the drain re-schedules the timer when it ends.
14
+ * An entry stays until its stream is acked or blocked, re-parked, or a
15
+ * drain that started after it came due claims nothing ({@link prune}): a
16
+ * wake that lands during another drain, or a pass that reaches only some of
17
+ * the due streams, leaves the rest due, so the next re-schedule fires again
18
+ * at once.
15
19
  *
16
20
  * Lives in process memory, per worker — the same per-worker pacing trade-off
17
21
  * documented for backoff. Durability comes from the data the due-time is
@@ -29,9 +33,8 @@ export declare class DeferTimer {
29
33
  private _timer;
30
34
  private readonly _on_wake;
31
35
  /**
32
- * @param on_wake - invoked once each time the earliest due-time elapses,
33
- * after the come-due entries have been removed. The consumer re-schedules
34
- * for whatever is still parked.
36
+ * @param on_wake - invoked once each time the earliest due-time elapses.
37
+ * The consumer re-schedules for whatever is still parked.
35
38
  */
36
39
  constructor(on_wake: () => void);
37
40
  /** Number of currently parked streams. */
@@ -50,6 +53,13 @@ export declare class DeferTimer {
50
53
  set(stream: string, at: number): void;
51
54
  /** Drop `stream` from the parked set (e.g. on a successful ack or block). */
52
55
  delete(stream: string): void;
56
+ /**
57
+ * Drop every entry due at or before `before`. The drain calls it when a
58
+ * pass that started at `before` claimed nothing: whatever was due by then
59
+ * was handled elsewhere (another worker) or has no work left, so waking
60
+ * for it again would spin.
61
+ */
62
+ prune(before: number): void;
53
63
  /**
54
64
  * (Re)schedule the wake timer at the earliest pending due-time. Idempotent
55
65
  * — collapses many parked streams into a single timer. A no-op clears any
@@ -1 +1 @@
1
- {"version":3,"file":"defer-timer.d.ts","sourceRoot":"","sources":["../../../src/internal/defer-timer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAkBH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA6B;IAClD,OAAO,CAAC,MAAM,CAA4C;IAC1D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAa;IAEtC;;;;OAIG;IACH,YAAY,OAAO,EAAE,MAAM,IAAI,EAE9B;IAED,0CAA0C;IAC1C,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;OAGG;IACH,WAAW,WAAY,MAAM,KAAG,OAAO,CAGrC;IAEF;;;;;OAKG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAEpC;IAED,6EAA6E;IAC7E,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAE3B;IAED;;;;;;;OAOG;IACH,QAAQ,IAAI,IAAI,CA4Bf;IAED,+EAA+E;IAC/E,IAAI,IAAI,IAAI,CAKX;CACF"}
1
+ {"version":3,"file":"defer-timer.d.ts","sourceRoot":"","sources":["../../../src/internal/defer-timer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAkBH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA6B;IAClD,OAAO,CAAC,MAAM,CAA4C;IAC1D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAa;IAEtC;;;OAGG;IACH,YAAY,OAAO,EAAE,MAAM,IAAI,EAE9B;IAED,0CAA0C;IAC1C,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;OAGG;IACH,WAAW,WAAY,MAAM,KAAG,OAAO,CAGrC;IAEF;;;;;OAKG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAEpC;IAED,6EAA6E;IAC7E,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAE3B;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAG1B;IAED;;;;;;;OAOG;IACH,QAAQ,IAAI,IAAI,CAuBf;IAED,+EAA+E;IAC/E,IAAI,IAAI,IAAI,CAKX;CACF"}
@@ -133,6 +133,9 @@ export declare class DrainController<TEvents extends Schemas, TActions extends S
133
133
  * schedule itself is persisted in the store; this runs the drain at the
134
134
  * earliest pending visit. A parked stream already carries its mark, so
135
135
  * the drain alone finds it, and on an idle app nothing else would.
136
+ * Every drain re-aims it when it ends, and a due entry stays until a pass
137
+ * handles it or a pass that started after it came due claims nothing, so
138
+ * the wake keeps draining until every due stream is reached.
136
139
  * `stop()` cancels the timer and a stopped drain never re-schedules it,
137
140
  * so a wake never runs after a stop.
138
141
  */
@@ -1 +1 @@
1
- {"version":3,"file":"drain-cycle.d.ts","sourceRoot":"","sources":["../../../src/internal/drain-cycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,KAAK,EACL,YAAY,EAEZ,KAAK,EACL,MAAM,EAEN,eAAe,EACf,QAAQ,EACR,cAAc,EACd,OAAO,EACR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAQ3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAK3C;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;IAClC,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,MAAM,CAAC,OAAO,SAAS,OAAO,IAAI,CAC5C,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,KACjC,OAAO,CAAC,YAAY,CAAC,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,WAAW,CA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B;IAED,qDAAqD;IACrD,IAAI,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAExC;IAED,8EAA8E;IAC9E,IAAI,YAAY,IAAI,MAAM,GAAG,SAAS,CAErC;IAED,+DAA+D;IAC/D,IAAI,IAAI,IAAI,MAAM,GAAG,SAAS,CAE7B;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAa3B;IAED,4CAA4C;IAC5C,IAAI,IAAI,IAAI,CAOX;IAED,4EAA4E;IACtE,KAAK,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAkG/D;CACF"}
package/dist/index.cjs CHANGED
@@ -3474,6 +3474,8 @@ var CorrelateCycle = class {
3474
3474
  priority: carried.priority,
3475
3475
  lane: carried.lane,
3476
3476
  upgraded,
3477
+ missed: !recorded,
3478
+ handler: reaction.handler.name,
3477
3479
  correlated_at: void 0
3478
3480
  };
3479
3481
  const seen_in_scan = correlated.has(resolved.target);
@@ -3492,6 +3494,7 @@ var CorrelateCycle = class {
3492
3494
  entry.priority = carried.priority;
3493
3495
  entry.lane = carried.lane;
3494
3496
  entry.upgraded = upgraded;
3497
+ entry.handler = reaction.handler.name;
3495
3498
  }
3496
3499
  if (this._in_fetch_window(resolved.source, event.stream))
3497
3500
  entry.correlated_at = event.id;
@@ -3505,6 +3508,7 @@ var CorrelateCycle = class {
3505
3508
  // actor-less, so plaintext here would be un-gated disclosure.
3506
3509
  { ...query, after, with_pii: false }
3507
3510
  );
3511
+ if (this._declared_lanes.size > 1) await this._recall(correlated);
3508
3512
  const streams = [];
3509
3513
  for (const [stream, entry] of correlated) {
3510
3514
  if (entry.upgraded || entry.correlated_at !== void 0)
@@ -3543,6 +3547,50 @@ var CorrelateCycle = class {
3543
3547
  this._armed = found === query.limit;
3544
3548
  return { subscribed: 0, last_id, marked: 0, scanned: true };
3545
3549
  }
3550
+ /**
3551
+ * Give each target this scan had no record of the record its row holds.
3552
+ *
3553
+ * A target with no record is either new or forgotten. Its row, when it
3554
+ * has one, says what lane and priority it was subscribed at; a resolution
3555
+ * that doesn't beat that priority carries the row's values, exactly as if
3556
+ * the record had never been evicted. One read per target with no record,
3557
+ * and only when more than one lane is declared: with one lane there is no
3558
+ * lane to lose, and the store already keeps the higher priority.
3559
+ */
3560
+ async _recall(correlated) {
3561
+ const missed = [...correlated].filter(([, entry]) => entry.missed);
3562
+ await Promise.all(
3563
+ missed.map(async ([stream, entry]) => {
3564
+ let row;
3565
+ await store2().query_streams(
3566
+ (position) => {
3567
+ row = position;
3568
+ },
3569
+ { stream, stream_exact: true, limit: 1 }
3570
+ );
3571
+ if (!row) return;
3572
+ this._dynamic_subscriptions.set(stream, {
3573
+ floor: row.priority,
3574
+ priority: row.priority,
3575
+ lane: row.lane
3576
+ });
3577
+ if (entry.priority > row.priority) return;
3578
+ const held_lane = row.lane ?? DEFAULT_LANE;
3579
+ const resolved_lane = entry.lane ?? DEFAULT_LANE;
3580
+ if (entry.priority === row.priority && held_lane !== resolved_lane)
3581
+ report_lane_conflict(
3582
+ this._reported,
3583
+ entry.handler,
3584
+ stream,
3585
+ held_lane,
3586
+ resolved_lane
3587
+ );
3588
+ entry.priority = row.priority;
3589
+ entry.lane = row.lane;
3590
+ entry.upgraded = false;
3591
+ })
3592
+ );
3593
+ }
3546
3594
  /**
3547
3595
  * Hand the correlation lease back early.
3548
3596
  *
@@ -3702,9 +3750,8 @@ var DeferTimer = class {
3702
3750
  _timer;
3703
3751
  _on_wake;
3704
3752
  /**
3705
- * @param on_wake - invoked once each time the earliest due-time elapses,
3706
- * after the come-due entries have been removed. The consumer re-schedules
3707
- * for whatever is still parked.
3753
+ * @param on_wake - invoked once each time the earliest due-time elapses.
3754
+ * The consumer re-schedules for whatever is still parked.
3708
3755
  */
3709
3756
  constructor(on_wake) {
3710
3757
  this._on_wake = on_wake;
@@ -3734,6 +3781,16 @@ var DeferTimer = class {
3734
3781
  delete(stream) {
3735
3782
  this._due.delete(stream);
3736
3783
  }
3784
+ /**
3785
+ * Drop every entry due at or before `before`. The drain calls it when a
3786
+ * pass that started at `before` claimed nothing: whatever was due by then
3787
+ * was handled elsewhere (another worker) or has no work left, so waking
3788
+ * for it again would spin.
3789
+ */
3790
+ prune(before) {
3791
+ for (const [stream, at] of this._due)
3792
+ if (at <= before) this._due.delete(stream);
3793
+ }
3737
3794
  /**
3738
3795
  * (Re)schedule the wake timer at the earliest pending due-time. Idempotent
3739
3796
  * — collapses many parked streams into a single timer. A no-op clears any
@@ -3756,9 +3813,6 @@ var DeferTimer = class {
3756
3813
  );
3757
3814
  this._timer = setTimeout(() => {
3758
3815
  this._timer = void 0;
3759
- const now = Date.now();
3760
- for (const [stream, at] of this._due)
3761
- if (at <= now) this._due.delete(stream);
3762
3816
  this._on_wake();
3763
3817
  }, delay);
3764
3818
  this._timer.unref();
@@ -4527,6 +4581,9 @@ var DrainController = class {
4527
4581
  * schedule itself is persisted in the store; this runs the drain at the
4528
4582
  * earliest pending visit. A parked stream already carries its mark, so
4529
4583
  * the drain alone finds it, and on an idle app nothing else would.
4584
+ * Every drain re-aims it when it ends, and a due entry stays until a pass
4585
+ * handles it or a pass that started after it came due claims nothing, so
4586
+ * the wake keeps draining until every due stream is reached.
4530
4587
  * `stop()` cancels the timer and a stopped drain never re-schedules it,
4531
4588
  * so a wake never runs after a stop.
4532
4589
  */
@@ -4624,15 +4681,16 @@ var DrainController = class {
4624
4681
  const streamLimit = d.streamLimit ?? options.streamLimit ?? DEFAULT_STREAM_LIMIT;
4625
4682
  const eventLimit = d.eventLimit ?? options.eventLimit ?? DEFAULT_EVENT_LIMIT;
4626
4683
  const leaseMillis = d.leaseMillis ?? options.leaseMillis ?? DEFAULT_LEASE_MILLIS;
4684
+ if (this._deps.breaker.state(Date.now()) === "open")
4685
+ return EMPTY_DRAIN;
4627
4686
  try {
4628
- if (this._deps.breaker.state(Date.now()) === "open")
4629
- return EMPTY_DRAIN;
4630
4687
  this._locked = true;
4631
4688
  this._inflight = new Promise((done) => {
4632
4689
  this._inflight_done = done;
4633
4690
  });
4634
4691
  const lagging = Math.ceil(streamLimit * this._ratio);
4635
4692
  const leading = streamLimit - lagging;
4693
+ const started = Date.now();
4636
4694
  const cycle = await run_drain_cycle(this._deps, {
4637
4695
  lagging,
4638
4696
  leading,
@@ -4642,6 +4700,7 @@ var DrainController = class {
4642
4700
  store_failing: this._deps.breaker.failing
4643
4701
  });
4644
4702
  if (!cycle) {
4703
+ this._defer.prune(started);
4645
4704
  this._deps.breaker.passed();
4646
4705
  this._armed = false;
4647
4706
  return EMPTY_DRAIN;