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

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 +53 -16
  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
+ await 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.698" : "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;
@@ -55876,7 +55891,13 @@ function createWorkspaceEngine(opts) {
55876
55891
  skills: readSkillManifest(paths.skillsManifest),
55877
55892
  ...lastSelfCiteSkips > 0 ? { selfCiteSkips: lastSelfCiteSkips } : {}
55878
55893
  };
55879
- const prebuilt = passWorker ? await passWorker.snapshot(snapOpts).catch(() => null) : null;
55894
+ const prebuilt = passWorker ? await passWorker.snapshot(snapOpts).catch((err2) => {
55895
+ console.warn(
55896
+ `[errata] snapshot worker failed \u2014 rendering INLINE on main:`,
55897
+ err2 instanceof Error ? err2.message : err2
55898
+ );
55899
+ return null;
55900
+ }) : null;
55880
55901
  const doneRender = prebuilt ? null : markPass(`context-render-inline:${profile.name}`);
55881
55902
  const pendingUpdate = opts.pendingUpdate?.() ?? null;
55882
55903
  const reviewItems = pickReviewItems();
@@ -58227,14 +58248,30 @@ var ConsolidateWorker = class {
58227
58248
  * unavailable — the caller's inline fallback handles it. */
58228
58249
  run(req) {
58229
58250
  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
- );
58251
+ return withHeavyPassSlot(`consolidate:${req.kind ?? "pass"}`, async () => {
58252
+ if (this.stopped) throw new Error("consolidate worker stopped");
58253
+ this.ensureWorker();
58254
+ const id = this.nextId++;
58255
+ try {
58256
+ await this.ready;
58257
+ return await new Promise((resolve6, reject) => {
58258
+ this.pending.set(id, { resolve: resolve6, reject });
58259
+ this.worker.postMessage({ ...req, id });
58260
+ });
58261
+ } finally {
58262
+ await this.recycleIdle();
58263
+ }
58264
+ });
58265
+ }
58266
+ async recycleIdle() {
58267
+ if (this.stopped || !this.worker || this.pending.size > 0) return;
58268
+ const w = this.worker;
58269
+ this.worker = null;
58270
+ this.ready = null;
58271
+ try {
58272
+ await w.terminate();
58273
+ } catch {
58274
+ }
58238
58275
  }
58239
58276
  ensureWorker() {
58240
58277
  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.698",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {