@inerrata-corporation/errata 2.0.2-dev.873 → 2.0.2-dev.881

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 +35 -21
  2. package/package.json +1 -1
package/errata.mjs CHANGED
@@ -53425,7 +53425,7 @@ function typePriorEdge(sourceLabel, targetLabel2, sentence = "") {
53425
53425
  if (direct) return direct;
53426
53426
  if (sentence && !NEG.test(sentence)) {
53427
53427
  const t = TIEBREAK.find((c) => c.re.test(sentence));
53428
- if (t) return t.type;
53428
+ if (t && isValidEdge(sourceLabel, t.type, targetLabel2).ok) return t.type;
53429
53429
  }
53430
53430
  return "RELATES_TO";
53431
53431
  }
@@ -55763,9 +55763,6 @@ function saveWitnessQueue(path2, queue) {
55763
55763
  } catch {
55764
55764
  }
55765
55765
  }
55766
- function pruneWitnessQueue(queue, now) {
55767
- return pruneWitnessQueueWithDispositions(queue, now).queue;
55768
- }
55769
55766
  function pruneWitnessQueueWithDispositions(queue, now) {
55770
55767
  const dropped = { expiredTtl: 0, exhaustedAttempts: 0, cappedOverflow: 0 };
55771
55768
  const live2 = [];
@@ -55780,15 +55777,20 @@ function pruneWitnessQueueWithDispositions(queue, now) {
55780
55777
  }
55781
55778
  return { queue: live2, dropped };
55782
55779
  }
55783
- function enqueueWitnesses(queue, fresh, now) {
55780
+ function enqueueWitnessesWithDispositions(queue, fresh, now) {
55784
55781
  const byKey = new Map(queue.map((w) => [`${w.channel}:${w.witnessKey}`, w]));
55785
55782
  for (const f of fresh) {
55786
55783
  const k = `${f.channel}:${f.witnessKey}`;
55784
+ const counted = f.counted !== false;
55787
55785
  const existing = byKey.get(k);
55788
- if (existing) existing.attempts += 1;
55789
- else byKey.set(k, { ...f, ts: now, attempts: 1 });
55786
+ if (existing) {
55787
+ if (counted) existing.attempts += 1;
55788
+ } else {
55789
+ const { counted: _drop, ...w } = f;
55790
+ byKey.set(k, { ...w, ts: now, attempts: counted ? 1 : 0 });
55791
+ }
55790
55792
  }
55791
- return pruneWitnessQueue([...byKey.values()], now);
55793
+ return pruneWitnessQueueWithDispositions([...byKey.values()], now);
55792
55794
  }
55793
55795
  function pendingFor(queue, channel) {
55794
55796
  return queue.filter((w) => w.channel === channel);
@@ -56061,7 +56063,8 @@ function createLivenessWatch(deps) {
56061
56063
  const bad = workspaceActive ? rows.filter((r) => hasStarvedMechanism([r])) : [];
56062
56064
  appendPassLedger(deps.configDir, "liveness-watch", Date.now() - started2, {
56063
56065
  mechanisms: rows.length,
56064
- alarms: bad.length
56066
+ alarms: bad.length,
56067
+ ...Object.fromEntries(bad.map((r) => [`starved:${r.id}`, 1]))
56065
56068
  });
56066
56069
  if (bad.length > 0) {
56067
56070
  const lines = formatMechanismStatus(rows, nowMs);
@@ -56155,7 +56158,7 @@ function watchCensusLine(c = watchCensus()) {
56155
56158
  }
56156
56159
 
56157
56160
  // src/engine.ts
56158
- var DAEMON_VERSION = true ? "2.0.2-dev.873" : "2.0.0-alpha.0";
56161
+ var DAEMON_VERSION = true ? "2.0.2-dev.881" : "2.0.0-alpha.0";
56159
56162
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
56160
56163
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
56161
56164
  var GIT_OP_MUTE_MS = 4e3;
@@ -57354,14 +57357,11 @@ function createWorkspaceEngine(opts) {
57354
57357
  const citingSession = sessionOriginKey(sessionId);
57355
57358
  const mintedHere = (nodeId) => store.getNode(nodeId)?.attrs["sources"]?.[0] === sessionId;
57356
57359
  const sendWitnesses = async (channel, fresh, send) => {
57357
- const { replay: queued, waiting } = partitionReplayable(
57358
- witnessQueue,
57359
- channel,
57360
- (nodeId) => {
57361
- const n = store.getNode(nodeId);
57362
- return !n || n.attrs["contributedAtSeq"] != null;
57363
- }
57364
- );
57360
+ const isShipped = (nodeId) => {
57361
+ const n = store.getNode(nodeId);
57362
+ return !n || n.attrs["contributedAtSeq"] != null;
57363
+ };
57364
+ const { replay: queued, waiting } = partitionReplayable(witnessQueue, channel, isShipped);
57365
57365
  if (fresh.length === 0 && queued.length === 0) {
57366
57366
  if (waiting.length > 0) {
57367
57367
  console.log(`[errata] ${channel}: ${waiting.length} parked awaiting node drain`);
@@ -57400,17 +57400,31 @@ function createWorkspaceEngine(opts) {
57400
57400
  selfGated += d.selfGated;
57401
57401
  const missing = new Set(d.unmatchedIds);
57402
57402
  for (const it of items2) {
57403
- if (missing.has(it.nodeId)) stillUnmatched.push({ channel, ...it, sessionKey: session });
57403
+ if (missing.has(it.nodeId)) stillUnmatched.push({ channel, ...it, sessionKey: session, counted: isShipped(it.nodeId) });
57404
57404
  else settled.add(it.witnessKey);
57405
57405
  }
57406
57406
  } catch (err2) {
57407
57407
  console.warn(`[errata] ${channel} transport failed (witnesses kept for retry):`, err2 instanceof Error ? err2.message : err2);
57408
- for (const it of items2) stillUnmatched.push({ channel, ...it, sessionKey: session });
57408
+ for (const it of items2) stillUnmatched.push({ channel, ...it, sessionKey: session, counted: false });
57409
57409
  }
57410
57410
  }
57411
+ const recovered = queued.filter((q) => settled.has(q.witnessKey)).length;
57411
57412
  witnessQueue = retireWitnesses(witnessQueue, channel, settled);
57412
- witnessQueue = enqueueWitnesses(witnessQueue, stillUnmatched, Date.now());
57413
+ const enq = enqueueWitnessesWithDispositions(witnessQueue, stillUnmatched, Date.now());
57414
+ witnessQueue = enq.queue;
57413
57415
  saveWitnessQueue(witnessQueuePath(paths.configDir), witnessQueue);
57416
+ const lost = enq.dropped.expiredTtl + enq.dropped.exhaustedAttempts + enq.dropped.cappedOverflow;
57417
+ if (lost > 0 || recovered > 0) {
57418
+ appendPassLedger(paths.configDir, "witness-queue", 0, {
57419
+ recovered,
57420
+ replayed: queued.length,
57421
+ awaitingDrain: waiting.length,
57422
+ parked: pendingFor(witnessQueue, channel).length,
57423
+ expiredTtl: enq.dropped.expiredTtl,
57424
+ exhaustedAttempts: enq.dropped.exhaustedAttempts,
57425
+ cappedOverflow: enq.dropped.cappedOverflow
57426
+ });
57427
+ }
57414
57428
  console.log(
57415
57429
  `[errata] ${channel}: ${formatDisposition({ recorded, unmatched, duplicate, selfGated })}` + (queued.length > 0 ? ` (incl. ${queued.length} replayed)` : "") + (waiting.length > 0 ? ` (${waiting.length} awaiting drain)` : "")
57416
57430
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata-corporation/errata",
3
- "version": "2.0.2-dev.873",
3
+ "version": "2.0.2-dev.881",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {