@rotorsoft/act 1.28.1 → 1.29.0

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
@@ -22,7 +22,7 @@ import {
22
22
  sleep,
23
23
  store,
24
24
  validate
25
- } from "./chunk-7WFKIQKY.js";
25
+ } from "./chunk-PX3IBVLW.js";
26
26
  import {
27
27
  ActorSchema,
28
28
  CausationEventSchema,
@@ -1499,7 +1499,7 @@ async function partition_by_safety(stream_info, reactive_events_size, skipped, p
1499
1499
  (position) => {
1500
1500
  last = position.stream;
1501
1501
  const source_re = position.source ? get_regex(position.source) : void 0;
1502
- const has_work = position.correlated_at === void 0 || position.at < position.correlated_at;
1502
+ const has_work = position.correlated_at !== void 0 && position.at < position.correlated_at;
1503
1503
  if (!has_work) return;
1504
1504
  for (const [stream, info] of stream_info) {
1505
1505
  if ((!source_re || source_re.test(stream)) && position.at < info.max_id) {
@@ -1805,6 +1805,9 @@ var CorrelateCycle = class {
1805
1805
  }
1806
1806
  if (streams.length) {
1807
1807
  const { subscribed } = await this._cd.subscribe(streams, last_id);
1808
+ const marked = streams.filter(
1809
+ (entry) => entry.correlated_at !== void 0
1810
+ ).length;
1808
1811
  this._checkpoint = last_id;
1809
1812
  for (const { stream, priority, lane } of streams) {
1810
1813
  if (correlated.get(stream)?.upgraded)
@@ -1814,10 +1817,10 @@ var CorrelateCycle = class {
1814
1817
  lane
1815
1818
  });
1816
1819
  }
1817
- return { subscribed, last_id };
1820
+ return { subscribed, last_id, marked };
1818
1821
  }
1819
1822
  this._checkpoint = last_id;
1820
- return { subscribed: 0, last_id };
1823
+ return { subscribed: 0, last_id, marked: 0 };
1821
1824
  }
1822
1825
  /**
1823
1826
  * Start a periodic correlation worker. Returns false if one is already
@@ -4128,10 +4131,10 @@ var Act = class {
4128
4131
  async correlate(query = { after: -1, limit: 10 }) {
4129
4132
  if (!this._drain) return { subscribed: 0, last_id: -1 };
4130
4133
  return this._scoped(async () => {
4131
- const result = await this._correlate.correlate(query);
4132
- if (result.subscribed > 0 && this._reactive_events.size > 0)
4134
+ const { subscribed, last_id, marked } = await this._correlate.correlate(query);
4135
+ if ((subscribed > 0 || marked > 0) && this._reactive_events.size > 0)
4133
4136
  this._arm_all();
4134
- return result;
4137
+ return { subscribed, last_id };
4135
4138
  });
4136
4139
  }
4137
4140
  /**