@rotorsoft/act 1.32.7 → 1.32.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.
package/dist/index.cjs CHANGED
@@ -1540,6 +1540,12 @@ var InMemoryStore = class {
1540
1540
  const prev_max_event_id_by_stream = this._max_event_id_by_stream;
1541
1541
  const prev_max_non_snap_event_id = this._max_non_snap_event_id;
1542
1542
  const prev_pii = this._pii;
1543
+ const prev_correlated_at = this._correlated_at;
1544
+ const prev_correlators = new Map(
1545
+ [...this._correlators].map(([k, v]) => [k, { ...v }])
1546
+ );
1547
+ this._correlated_at = -1;
1548
+ for (const c of this._correlators.values()) c.at = -1;
1543
1549
  this._events = [];
1544
1550
  this._next_id = 0;
1545
1551
  this._streams = /* @__PURE__ */ new Map();
@@ -1576,6 +1582,8 @@ var InMemoryStore = class {
1576
1582
  this._max_event_id_by_stream = prev_max_event_id_by_stream;
1577
1583
  this._max_non_snap_event_id = prev_max_non_snap_event_id;
1578
1584
  this._pii = prev_pii;
1585
+ this._correlated_at = prev_correlated_at;
1586
+ this._correlators = prev_correlators;
1579
1587
  throw err;
1580
1588
  }
1581
1589
  }
@@ -3392,6 +3400,24 @@ var CorrelateCycle = class {
3392
3400
  * `_static_subscriptions`, which this never touches, so they stay pinned
3393
3401
  * at +Infinity and the dynamic path never re-opens them.
3394
3402
  */
3403
+ /**
3404
+ * Start correlation over after the event log was replaced wholesale
3405
+ * (`restore`). The restored log is renumbered from the start and its
3406
+ * subscription rows are gone, so the in-memory scan position and both
3407
+ * subscription records describe a log that no longer exists. Dropping them
3408
+ * and the init latch makes the next pass run cold-start again: static
3409
+ * targets are re-subscribed, the checkpoint is re-read from the store
3410
+ * (which `restore` reset), and dynamic targets are rediscovered by the
3411
+ * scan (#1772).
3412
+ */
3413
+ restart() {
3414
+ this._initialized = false;
3415
+ this._init_promise = void 0;
3416
+ this._checkpoint = -1;
3417
+ this._dynamic_subscriptions.clear();
3418
+ this._static_subscriptions.clear();
3419
+ this._armed = true;
3420
+ }
3395
3421
  forget_subscribed(streams) {
3396
3422
  for (const stream of streams) this._dynamic_subscriptions.delete(stream);
3397
3423
  }
@@ -6333,6 +6359,10 @@ var Act = class {
6333
6359
  migrated = partial.migrated;
6334
6360
  dropped = partial.dropped;
6335
6361
  });
6362
+ if (!sink) {
6363
+ this._correlate.restart();
6364
+ this._arm_all();
6365
+ }
6336
6366
  return { kept, migrated, dropped, duration_ms: Date.now() - started };
6337
6367
  });
6338
6368
  }