@rotorsoft/act 1.22.4 → 1.22.6

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.
@@ -373,6 +373,10 @@ var extend = (source, schema, target) => {
373
373
  async function sleep(ms) {
374
374
  return new Promise((resolve) => setTimeout(resolve, ms ?? config().sleepMs));
375
375
  }
376
+ var SOURCE_METACHARACTERS = /[\^$.*+?()[\]{}|\\]/;
377
+ function is_literal_source(source) {
378
+ return !SOURCE_METACHARACTERS.test(source);
379
+ }
376
380
 
377
381
  // src/config.ts
378
382
  var PackageSchema = import_zod4.z.object({
@@ -649,8 +653,9 @@ var InMemoryStore = class {
649
653
  _streams = /* @__PURE__ */ new Map();
650
654
  // last committed version per stream — O(1) replacement for filter-on-commit
651
655
  _stream_versions = /* @__PURE__ */ new Map();
652
- // max non-snapshot event id per stream — drives the exact-source probe in claim()
653
- // without scanning the full event log.
656
+ // max non-snapshot event id per stream — drives the has-work probe in
657
+ // claim(): an O(1) lookup for a literal source, and the per-stream max
658
+ // that a pattern source scans, without touching the full event log.
654
659
  _max_event_id_by_stream = /* @__PURE__ */ new Map();
655
660
  // global max non-snapshot event id — fast pre-check for source-less streams in claim()
656
661
  _max_non_snap_event_id = -1;
@@ -840,8 +845,15 @@ var InMemoryStore = class {
840
845
  const has_work = (s) => {
841
846
  if (s.at < 0) return true;
842
847
  if (!s.source) return s.at < this._max_non_snap_event_id;
843
- const max_id = this._max_event_id_by_stream.get(s.source);
844
- return max_id !== void 0 && max_id > s.at;
848
+ if (is_literal_source(s.source)) {
849
+ const max_id = this._max_event_id_by_stream.get(s.source);
850
+ return max_id !== void 0 && max_id > s.at;
851
+ }
852
+ const re = new RegExp(s.source);
853
+ for (const [stream_name, max_id] of this._max_event_id_by_stream) {
854
+ if (max_id > s.at && re.test(stream_name)) return true;
855
+ }
856
+ return false;
845
857
  };
846
858
  const available = [...this._streams.values()].filter(
847
859
  (s) => s.is_available && has_work(s) && (lane === void 0 || s.lane === lane)