@inerrata-corporation/errata 2.0.2-dev.690 → 2.0.2-dev.692

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.
Files changed (2) hide show
  1. package/errata.mjs +46 -15
  2. package/package.json +1 -1
package/errata.mjs CHANGED
@@ -53880,18 +53880,33 @@ var PassWorker = class {
53880
53880
  }
53881
53881
  call(kind, payload) {
53882
53882
  if (this.stopped) return Promise.reject(new Error("pass worker stopped"));
53883
- return withHeavyPassSlot(`${kind}:${this.init.workspaceId}`, () => {
53884
- if (this.stopped) return Promise.reject(new Error("pass worker stopped"));
53883
+ return withHeavyPassSlot(`${kind}:${this.init.workspaceId}`, async () => {
53884
+ if (this.stopped) throw new Error("pass worker stopped");
53885
53885
  this.ensureWorker();
53886
53886
  const id = this.nextId++;
53887
- return this.ready.then(
53888
- () => new Promise((resolve6, reject) => {
53887
+ try {
53888
+ await this.ready;
53889
+ return await new Promise((resolve6, reject) => {
53889
53890
  this.pending.set(id, { resolve: resolve6, reject });
53890
53891
  this.worker.postMessage({ id, kind, ...payload !== void 0 ? { payload } : {} });
53891
- })
53892
- );
53892
+ });
53893
+ } finally {
53894
+ void this.recycleIdle();
53895
+ }
53893
53896
  });
53894
53897
  }
53898
+ /** Terminate the (idle) worker so its retained heap returns to the OS; the
53899
+ * next call respawns it. No-op when requests are pending or already down. */
53900
+ async recycleIdle() {
53901
+ if (this.stopped || !this.worker || this.pending.size > 0) return;
53902
+ const w = this.worker;
53903
+ this.worker = null;
53904
+ this.ready = null;
53905
+ try {
53906
+ await w.terminate();
53907
+ } catch {
53908
+ }
53909
+ }
53895
53910
  ensureWorker() {
53896
53911
  if (this.worker) return;
53897
53912
  const workerUrl = new URL("./pass-worker.mjs", import.meta.url);
@@ -55479,7 +55494,7 @@ function startLoopLagMonitor(thresholdMs = 1e3) {
55479
55494
  }
55480
55495
 
55481
55496
  // src/engine.ts
55482
- var DAEMON_VERSION = true ? "2.0.2-dev.690" : "2.0.0-alpha.0";
55497
+ var DAEMON_VERSION = true ? "2.0.2-dev.692" : "2.0.0-alpha.0";
55483
55498
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
55484
55499
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
55485
55500
  var GIT_OP_MUTE_MS = 4e3;
@@ -58227,14 +58242,30 @@ var ConsolidateWorker = class {
58227
58242
  * unavailable — the caller's inline fallback handles it. */
58228
58243
  run(req) {
58229
58244
  if (this.stopped) return Promise.reject(new Error("consolidate worker stopped"));
58230
- this.ensureWorker();
58231
- const id = this.nextId++;
58232
- return this.ready.then(
58233
- () => new Promise((resolve6, reject) => {
58234
- this.pending.set(id, { resolve: resolve6, reject });
58235
- this.worker.postMessage({ ...req, id });
58236
- })
58237
- );
58245
+ return withHeavyPassSlot(`consolidate:${req.kind ?? "pass"}`, async () => {
58246
+ if (this.stopped) throw new Error("consolidate worker stopped");
58247
+ this.ensureWorker();
58248
+ const id = this.nextId++;
58249
+ try {
58250
+ await this.ready;
58251
+ return await new Promise((resolve6, reject) => {
58252
+ this.pending.set(id, { resolve: resolve6, reject });
58253
+ this.worker.postMessage({ ...req, id });
58254
+ });
58255
+ } finally {
58256
+ void this.recycleIdle();
58257
+ }
58258
+ });
58259
+ }
58260
+ async recycleIdle() {
58261
+ if (this.stopped || !this.worker || this.pending.size > 0) return;
58262
+ const w = this.worker;
58263
+ this.worker = null;
58264
+ this.ready = null;
58265
+ try {
58266
+ await w.terminate();
58267
+ } catch {
58268
+ }
58238
58269
  }
58239
58270
  ensureWorker() {
58240
58271
  if (this.worker) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata-corporation/errata",
3
- "version": "2.0.2-dev.690",
3
+ "version": "2.0.2-dev.692",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {