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

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 +102 -53
  2. package/package.json +1 -1
package/errata.mjs CHANGED
@@ -22197,7 +22197,10 @@ function evaluateMechanisms(store, invocations = /* @__PURE__ */ new Map(), mech
22197
22197
  return mechanisms.map((d) => {
22198
22198
  const fed = evaluateFed(store, d);
22199
22199
  const inv = invocations.get(d.pass);
22200
- const effectCount = inv?.totals[d.effectCounter] ?? 0;
22200
+ const effectCount = d.effectIsLevel ? Math.max(
22201
+ 0,
22202
+ (inv?.lastTotals?.[d.effectCounter] ?? 0) - (inv?.firstTotals?.[d.effectCounter] ?? 0)
22203
+ ) : inv?.totals[d.effectCounter] ?? 0;
22201
22204
  const backlog = d.backlogCounter ? inv?.lastTotals?.[d.backlogCounter] : void 0;
22202
22205
  const backlogWas = d.backlogCounter ? inv?.firstTotals?.[d.backlogCounter] : void 0;
22203
22206
  const span = inv?.firstTs === void 0 ? 0 : inv.lastTs - inv.firstTs;
@@ -22394,7 +22397,11 @@ var init_mechanism_liveness = __esm({
22394
22397
  // this store's measured state on 2026-08-09, day one of WM-labels.
22395
22398
  fed: { labels: ["Problem"], attr: "lastReinforceExposure", minFraction: 0 },
22396
22399
  // A LEVEL, not an increment: nonzero once any node ever carried an outcome.
22400
+ // Which is precisely why it must be read as movement — measured across the
22401
+ // 103 retained rows it never left 1, and the summed reading called that
22402
+ // "effect 103, ok".
22397
22403
  effectCounter: "reinforcedNodes",
22404
+ effectIsLevel: true,
22398
22405
  note: "levels ride the wm-calibration row; expect no-effect until outcome data accrues"
22399
22406
  },
22400
22407
  {
@@ -56036,53 +56043,6 @@ function maybeFlushDigests() {
56036
56043
 
56037
56044
  // src/liveness-watch.ts
56038
56045
  init_src5();
56039
- var LIVENESS_WATCH_INTERVAL_MS = 60 * 60 * 1e3;
56040
- var ALARM_RENOTIFY_MS = 24 * 60 * 60 * 1e3;
56041
- function createLivenessWatch(deps) {
56042
- let lastRunAt = 0;
56043
- const lastAlarmedAt = /* @__PURE__ */ new Map();
56044
- return {
56045
- maybeRun(nowMs = Date.now()) {
56046
- if (nowMs - lastRunAt < LIVENESS_WATCH_INTERVAL_MS) return null;
56047
- lastRunAt = nowMs;
56048
- try {
56049
- const started2 = Date.now();
56050
- const invocations = /* @__PURE__ */ new Map();
56051
- for (const [kind, s] of summarizePassLedger(deps.configDir)) {
56052
- invocations.set(kind, {
56053
- lastTs: s.lastTs,
56054
- firstTs: s.firstTs,
56055
- runs: s.runs,
56056
- totals: s.totals,
56057
- firstTotals: s.firstTotals,
56058
- lastTotals: s.lastTotals
56059
- });
56060
- }
56061
- const rows = evaluateMechanisms(deps.store, invocations);
56062
- const workspaceActive = invocations.has("capture") || invocations.has("render");
56063
- const bad = workspaceActive ? rows.filter((r) => hasStarvedMechanism([r])) : [];
56064
- appendPassLedger(deps.configDir, "liveness-watch", Date.now() - started2, {
56065
- mechanisms: rows.length,
56066
- alarms: bad.length,
56067
- ...Object.fromEntries(bad.map((r) => [`starved:${r.id}`, 1]))
56068
- });
56069
- if (bad.length > 0) {
56070
- const lines = formatMechanismStatus(rows, nowMs);
56071
- for (const r of bad) {
56072
- const at = lastAlarmedAt.get(r.id) ?? 0;
56073
- if (nowMs - at < ALARM_RENOTIFY_MS) continue;
56074
- lastAlarmedAt.set(r.id, nowMs);
56075
- const line = lines.find((l) => l.includes(r.id)) ?? `${r.verdict} ${r.id}`;
56076
- deps.onAlarm(r.id, `${line.trim()} \u2014 ${r.what}`);
56077
- }
56078
- }
56079
- return rows;
56080
- } catch {
56081
- return null;
56082
- }
56083
- }
56084
- };
56085
- }
56086
56046
 
56087
56047
  // src/loop-lag.ts
56088
56048
  var HEARTBEAT_MS = 500;
@@ -56157,8 +56117,69 @@ function watchCensusLine(c = watchCensus()) {
56157
56117
  return base;
56158
56118
  }
56159
56119
 
56120
+ // src/liveness-watch.ts
56121
+ var LIVENESS_WATCH_INTERVAL_MS = 60 * 60 * 1e3;
56122
+ var ALARM_RENOTIFY_MS = 24 * 60 * 60 * 1e3;
56123
+ function createLivenessWatch(deps) {
56124
+ let lastRunAt = 0;
56125
+ const lastAlarmedAt = /* @__PURE__ */ new Map();
56126
+ return {
56127
+ maybeRun(nowMs = Date.now()) {
56128
+ if (nowMs - lastRunAt < LIVENESS_WATCH_INTERVAL_MS) return null;
56129
+ lastRunAt = nowMs;
56130
+ try {
56131
+ const started2 = Date.now();
56132
+ const invocations = /* @__PURE__ */ new Map();
56133
+ for (const [kind, s] of summarizePassLedger(deps.configDir)) {
56134
+ invocations.set(kind, {
56135
+ lastTs: s.lastTs,
56136
+ firstTs: s.firstTs,
56137
+ runs: s.runs,
56138
+ totals: s.totals,
56139
+ firstTotals: s.firstTotals,
56140
+ lastTotals: s.lastTotals
56141
+ });
56142
+ }
56143
+ const rows = evaluateMechanisms(deps.store, invocations);
56144
+ const workspaceActive = invocations.has("capture") || invocations.has("render");
56145
+ const bad = workspaceActive ? rows.filter((r) => hasStarvedMechanism([r])) : [];
56146
+ const watch2 = watchCensus();
56147
+ const pass = passState();
56148
+ appendPassLedger(deps.configDir, "liveness-watch", Date.now() - started2, {
56149
+ mechanisms: rows.length,
56150
+ alarms: bad.length,
56151
+ ...Object.fromEntries(bad.map((r) => [`starved:${r.id}`, 1])),
56152
+ ...deps.witnessParked ? { witnessParked: deps.witnessParked() } : {},
56153
+ watchDispatched: watch2.dispatched,
56154
+ watchEmitted: watch2.emitted,
56155
+ watchLogged: watch2.logged,
56156
+ watchRejected: watch2.rejected,
56157
+ // Concurrency and the longest single holder — the two readings that
56158
+ // named the 6017s zombie pass. A pass legitimately running for hours
56159
+ // and one wedged forever look identical without a trend.
56160
+ passesActive: pass.active.length,
56161
+ passLongestRunningMs: pass.active.reduce((m, p) => Math.max(m, p.runningMs), 0)
56162
+ });
56163
+ if (bad.length > 0) {
56164
+ const lines = formatMechanismStatus(rows, nowMs);
56165
+ for (const r of bad) {
56166
+ const at = lastAlarmedAt.get(r.id) ?? 0;
56167
+ if (nowMs - at < ALARM_RENOTIFY_MS) continue;
56168
+ lastAlarmedAt.set(r.id, nowMs);
56169
+ const line = lines.find((l) => l.includes(r.id)) ?? `${r.verdict} ${r.id}`;
56170
+ deps.onAlarm(r.id, `${line.trim()} \u2014 ${r.what}`);
56171
+ }
56172
+ }
56173
+ return rows;
56174
+ } catch {
56175
+ return null;
56176
+ }
56177
+ }
56178
+ };
56179
+ }
56180
+
56160
56181
  // src/engine.ts
56161
- var DAEMON_VERSION = true ? "2.0.2-dev.881" : "2.0.0-alpha.0";
56182
+ var DAEMON_VERSION = true ? "2.0.2-dev.886" : "2.0.0-alpha.0";
56162
56183
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
56163
56184
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
56164
56185
  var GIT_OP_MUTE_MS = 4e3;
@@ -56504,7 +56525,11 @@ function createWorkspaceEngine(opts) {
56504
56525
  onAlarm: (id, line) => {
56505
56526
  console.warn(`[errata] mechanism not working: ${line}`);
56506
56527
  notifyEvent("mechanism-stalled", line, { key: id });
56507
- }
56528
+ },
56529
+ // Read through a closure, not captured once: `witnessQueue` is reassigned
56530
+ // on every harvest, so a snapshot would freeze the depth at boot — which is
56531
+ // the same in-memory-only blindness this counter exists to end.
56532
+ witnessParked: () => witnessQueue.length
56508
56533
  });
56509
56534
  const intents = createIntentState();
56510
56535
  const toolRuns = createToolRunState();
@@ -60435,7 +60460,11 @@ async function startMultiDaemon(opts = {}) {
60435
60460
  ...compositionCounters(composition),
60436
60461
  accepted: 0,
60437
60462
  rejected: 0,
60438
- blocked: 0
60463
+ blocked: 0,
60464
+ // Same shape as the drained row: a first/last trend reading must not
60465
+ // straddle rows where the counter is merely absent.
60466
+ blockedRepeat: 0,
60467
+ rejectedRepeat: 0
60439
60468
  });
60440
60469
  }
60441
60470
  if (instances) {
@@ -60476,15 +60505,29 @@ async function startMultiDaemon(opts = {}) {
60476
60505
  if (sh) return { s: sharedStore, n: sh };
60477
60506
  return null;
60478
60507
  };
60508
+ let blockedRepeat = 0;
60509
+ let rejectedRepeat = 0;
60510
+ const noteRefused = (id, repeat) => {
60511
+ const owner = owningStore(id);
60512
+ if (!owner) return;
60513
+ if (owner.n.attrs["shipRefusedSinceSeq"] !== void 0) repeat();
60514
+ else
60515
+ owner.s.updateNode(id, {
60516
+ attrs: { ...owner.n.attrs, shipRefusedSinceSeq: seq }
60517
+ });
60518
+ };
60519
+ for (const id of blocked) noteRefused(id, () => blockedRepeat++);
60520
+ for (const id of rejected.keys()) noteRefused(id, () => rejectedRepeat++);
60479
60521
  for (const n of instances.nodes) {
60480
60522
  const owner = owningStore(n.id);
60481
60523
  if (!owner || !["Problem", "Solution", "RootCause"].includes(owner.n.label)) continue;
60482
60524
  if (blocked.has(n.id)) continue;
60483
60525
  if (rejected.has(n.id)) continue;
60484
60526
  const cloudNodeId = cloudIdByLocal.get(n.id);
60527
+ const { shipRefusedSinceSeq: _cleared, ...carried } = owner.n.attrs;
60485
60528
  owner.s.updateNode(n.id, {
60486
60529
  attrs: {
60487
- ...owner.n.attrs,
60530
+ ...carried,
60488
60531
  contributedAtSeq: seq,
60489
60532
  ...cloudNodeId && cloudNodeId !== n.id ? { cloudNodeId } : {}
60490
60533
  }
@@ -60510,7 +60553,13 @@ async function startMultiDaemon(opts = {}) {
60510
60553
  ...compositionCounters(instances.composition),
60511
60554
  accepted: res.accepted,
60512
60555
  rejected: rejected.size,
60513
- blocked: blocked.size
60556
+ blocked: blocked.size,
60557
+ // The half of the refusal count that is NOT news. `blocked` flat
60558
+ // at 1 with `blockedRepeat` also 1 is one permanently stranded
60559
+ // node; flat at 1 with `blockedRepeat` 0 is a different node
60560
+ // failing every pass. Same total, different bug.
60561
+ blockedRepeat,
60562
+ rejectedRepeat
60514
60563
  });
60515
60564
  return res.accepted;
60516
60565
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata-corporation/errata",
3
- "version": "2.0.2-dev.881",
3
+ "version": "2.0.2-dev.886",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {