@inerrata-corporation/errata 2.0.22-dev.4054 → 2.0.22-dev.4071

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.
@@ -15222,7 +15222,7 @@ function compileNodeSelect(q) {
15222
15222
  }
15223
15223
  const orderParams = !q.orderBy && q.labels.length > 1 ? [...q.labels] : [];
15224
15224
  const limit = q.limit !== void 0 ? ` LIMIT ${Math.max(0, Math.floor(q.limit))}` : "";
15225
- const sql = `SELECT id, label, description, created_at, last_updated_at, page_rank, cumulative_hits, extraction_confidence, extraction_source, community, created_at_seq, last_reinforced_at_seq, valid_to, ${EMBEDDING_DIM_SQL} AS embedding_dim${q.withEmbedding ? ", embedding_blob, embedding_json" : ""}${attrCols} FROM nodes WHERE ${where} ORDER BY ${order}${limit}`;
15225
+ const sql = `SELECT id, label, description, created_at, last_updated_at, page_rank, cumulative_hits, extraction_confidence, extraction_source, community, created_at_seq, last_reinforced_at_seq, valid_to, logical_id, version, ${EMBEDDING_DIM_SQL} AS embedding_dim${q.withEmbedding ? ", embedding_blob, embedding_json" : ""}${attrCols} FROM nodes WHERE ${where} ORDER BY ${order}${limit}`;
15226
15226
  return { sql, params: [...params, ...orderParams] };
15227
15227
  }
15228
15228
  function decodeAttr(value, type) {
@@ -15263,6 +15263,8 @@ function decodeSelectedRow(r, attrs, decodeVector) {
15263
15263
  ...r["created_at_seq"] != null ? { createdAtSeq: r["created_at_seq"] } : {},
15264
15264
  ...r["last_reinforced_at_seq"] != null ? { lastReinforcedAtSeq: r["last_reinforced_at_seq"] } : {},
15265
15265
  validTo: r["valid_to"] ?? null,
15266
+ logicalId: r["logical_id"] ?? r["id"],
15267
+ version: Number(r["version"] ?? 1),
15266
15268
  embeddingDim: Number(r["embedding_dim"] ?? 0),
15267
15269
  ...decodeVector ? { embedding: decodeVector(r["embedding_blob"], r["embedding_json"] ?? "[]") } : {},
15268
15270
  attrs: out
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata-corporation/errata",
3
- "version": "2.0.22-dev.4054",
3
+ "version": "2.0.22-dev.4071",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {
package/pass-worker.mjs CHANGED
@@ -26081,7 +26081,7 @@ function compileNodeSelect(q) {
26081
26081
  }
26082
26082
  const orderParams = !q.orderBy && q.labels.length > 1 ? [...q.labels] : [];
26083
26083
  const limit = q.limit !== void 0 ? ` LIMIT ${Math.max(0, Math.floor(q.limit))}` : "";
26084
- const sql = `SELECT id, label, description, created_at, last_updated_at, page_rank, cumulative_hits, extraction_confidence, extraction_source, community, created_at_seq, last_reinforced_at_seq, valid_to, ${EMBEDDING_DIM_SQL} AS embedding_dim${q.withEmbedding ? ", embedding_blob, embedding_json" : ""}${attrCols} FROM nodes WHERE ${where} ORDER BY ${order}${limit}`;
26084
+ const sql = `SELECT id, label, description, created_at, last_updated_at, page_rank, cumulative_hits, extraction_confidence, extraction_source, community, created_at_seq, last_reinforced_at_seq, valid_to, logical_id, version, ${EMBEDDING_DIM_SQL} AS embedding_dim${q.withEmbedding ? ", embedding_blob, embedding_json" : ""}${attrCols} FROM nodes WHERE ${where} ORDER BY ${order}${limit}`;
26085
26085
  return { sql, params: [...params, ...orderParams] };
26086
26086
  }
26087
26087
  function decodeAttr(value, type) {
@@ -26122,6 +26122,8 @@ function decodeSelectedRow(r, attrs, decodeVector) {
26122
26122
  ...r["created_at_seq"] != null ? { createdAtSeq: r["created_at_seq"] } : {},
26123
26123
  ...r["last_reinforced_at_seq"] != null ? { lastReinforcedAtSeq: r["last_reinforced_at_seq"] } : {},
26124
26124
  validTo: r["valid_to"] ?? null,
26125
+ logicalId: r["logical_id"] ?? r["id"],
26126
+ version: Number(r["version"] ?? 1),
26125
26127
  embeddingDim: Number(r["embedding_dim"] ?? 0),
26126
26128
  ...decodeVector ? { embedding: decodeVector(r["embedding_blob"], r["embedding_json"] ?? "[]") } : {},
26127
26129
  attrs: out2
@@ -28023,16 +28025,19 @@ function foldDuplicateProblem(store2, dup, survivor, ts) {
28023
28025
  if (!surv) return;
28024
28026
  const sources = new Set(surv.attrs["sources"] ?? []);
28025
28027
  for (const s of dup.attrs["sources"] ?? []) sources.add(s);
28026
- const dupSeq = dup.attrs["createdAtSeq"] ?? store2.currentIngestSeq();
28027
- const exposure = priorExposure(store2, survivor.id, dupSeq);
28028
- const expField = `reinforce${exposure[0].toUpperCase()}${exposure.slice(1)}Count`;
28028
+ const samePass = dup.createdAt === surv.createdAt;
28029
+ const [held, restated] = dup.createdAt < surv.createdAt ? [dup, surv] : [surv, dup];
28030
+ const at = {
28031
+ seq: restated.createdAtSeq ?? restated.attrs["createdAtSeq"] ?? store2.currentIngestSeq(),
28032
+ ts: restated.createdAt
28033
+ };
28034
+ const exposure = samePass ? null : priorExposure(store2, held.id, at);
28029
28035
  store2.updateNode(survivor.id, {
28030
28036
  attrs: {
28031
28037
  ...surv.attrs,
28032
28038
  sources: [...sources],
28033
28039
  corroborations: corroborations(surv) + corroborations(dup) + 1,
28034
- [expField]: (surv.attrs[expField] ?? 0) + 1,
28035
- lastReinforceExposure: exposure
28040
+ ...exposure ? exposureOutcomeAttrs(surv, exposure, at) : {}
28036
28041
  },
28037
28042
  cumulativeHits: (surv.cumulativeHits ?? 0) + (dup.cumulativeHits ?? 0),
28038
28043
  lastUpdatedAt: ts
@@ -28456,16 +28461,77 @@ function clearSettledFixCandidates(store2, t) {
28456
28461
  }
28457
28462
  return report;
28458
28463
  }
28459
- function priorExposure(store2, nodeId, atSeq) {
28464
+ function exposureLog(attrs) {
28465
+ const raw = attrs["exposureLog"];
28466
+ if (!Array.isArray(raw)) return [];
28467
+ return raw.filter(
28468
+ (e) => Array.isArray(e) && typeof e[0] === "number" && (e[1] === "r" || e[1] === "c" || e[1] === "e")
28469
+ );
28470
+ }
28471
+ function priorExposure(store2, nodeId, at) {
28460
28472
  const n = store2.getNode(nodeId);
28461
28473
  if (!n || !n.attrs) return "unshown";
28462
- const shownSeq = n.attrs["lastShownAtSeq"];
28463
- if (shownSeq !== void 0 && shownSeq <= atSeq) return "shown";
28464
- const evictedSeq = n.attrs["lastEvictedAtSeq"];
28465
- if (evictedSeq !== void 0 && evictedSeq <= atSeq) return "evicted";
28466
- if ((n.attrs["evictedCount"] ?? 0) > 0) return "evicted";
28474
+ const a = n.attrs;
28475
+ const num2 = (k) => typeof a[k] === "number" ? a[k] : void 0;
28476
+ const since = num2("lastOutcomeAt");
28477
+ const outOfOrder = since !== void 0 && at.ts <= since;
28478
+ const lo = outOfOrder || since === void 0 ? -Infinity : since;
28479
+ const kinds = ["r", "c", "e"];
28480
+ const seen = { r: false, c: false, e: false };
28481
+ const maybe = { r: outOfOrder, c: outOfOrder, e: outOfOrder };
28482
+ for (const [t, kind] of exposureLog(a)) if (t > lo && t <= at.ts) seen[kind] = true;
28483
+ const logSince = num2("exposureLogSince");
28484
+ const trimmed = a["exposureTrimmed"] ?? {};
28485
+ if (logSince !== void 0 && lo < logSince) {
28486
+ for (const k of kinds) {
28487
+ const t = trimmed[k];
28488
+ if (typeof t !== "number" || t <= lo) continue;
28489
+ if (t <= at.ts) seen[k] = true;
28490
+ else maybe[k] = true;
28491
+ }
28492
+ }
28493
+ const firstShownAt = num2("firstShownAt");
28494
+ const firstEvictedAt = num2("firstEvictedAt");
28495
+ const legacyShowSeq = num2("firstShownAtSeq") ?? num2("lastShownAtSeq");
28496
+ const legacyShown = firstShownAt === 0 || firstShownAt === void 0 && legacyShowSeq !== void 0;
28497
+ const legacyEvicted = firstEvictedAt === 0 || firstEvictedAt === void 0 && (num2("lastEvictedAtSeq") !== void 0 || (num2("evictedCount") ?? 0) > 0);
28498
+ const logStart = num2("exposureLogStart");
28499
+ const beforeLog = logStart === void 0 || lo < logStart;
28500
+ if (beforeLog && legacyShown) maybe.r = true;
28501
+ if (beforeLog && legacyEvicted) maybe.e = true;
28502
+ const first = a["exposureFirst"] ?? {};
28503
+ const legacyBy = (seq) => logStart !== void 0 && at.ts >= logStart ? true : seq !== void 0 && seq <= at.seq;
28504
+ const happenedBy = {
28505
+ r: typeof first["r"] === "number" && first["r"] <= at.ts || legacyShown && legacyBy(legacyShowSeq),
28506
+ c: typeof first["c"] === "number" && first["c"] <= at.ts,
28507
+ e: typeof first["e"] === "number" && first["e"] <= at.ts || legacyEvicted && (legacyBy(num2("lastEvictedAtSeq")) || a["lastEvictedAtSeq"] === void 0 && (num2("evictedCount") ?? 0) > 0)
28508
+ };
28509
+ const present = (k) => seen[k] || maybe[k] && happenedBy[k];
28510
+ if (present("r")) return "shown";
28511
+ if (present("c")) return "recent";
28512
+ if (present("e")) return "evicted";
28467
28513
  return "unshown";
28468
28514
  }
28515
+ function passivelyShowable(n) {
28516
+ const quality = n.attrs["historyQuality"];
28517
+ const evaluatedAt = quality && typeof quality === "object" ? quality["evaluatedAtCommit"] : void 0;
28518
+ return historyReadPolicy(n, {
28519
+ mode: "passive",
28520
+ atCommit: typeof evaluatedAt === "string" ? evaluatedAt : void 0
28521
+ }).allow;
28522
+ }
28523
+ function exposureOutcomeAttrs(node, exposure, at) {
28524
+ const attrs = node.attrs;
28525
+ const field = `reinforce${exposure[0].toUpperCase()}${exposure.slice(1)}Count`;
28526
+ const prev = attrs["lastOutcomeAt"];
28527
+ const queryOnly = exposure === "unshown" && !passivelyShowable(node);
28528
+ return {
28529
+ [field]: (attrs[field] ?? 0) + 1,
28530
+ ...queryOnly ? { reinforceUnshownQueryOnlyCount: (attrs["reinforceUnshownQueryOnlyCount"] ?? 0) + 1 } : {},
28531
+ lastReinforceExposure: exposure,
28532
+ lastOutcomeAt: typeof prev === "number" ? Math.max(prev, at.ts) : at.ts
28533
+ };
28534
+ }
28469
28535
 
28470
28536
  // ../../packages/local-graph/src/intent.ts
28471
28537
  init_src();
@@ -29158,45 +29224,63 @@ var WM_CALIBRATION_LABELS = [
29158
29224
  "Technique",
29159
29225
  "AntiPattern"
29160
29226
  ];
29227
+ var WM_CALIBRATION_SCHEMA = 2;
29161
29228
  var num = (v) => typeof v === "number" && Number.isFinite(v) ? v : 0;
29162
29229
  var WM_CALIBRATION_KEYS = [
29163
29230
  "shownCount",
29164
29231
  "evictedCount",
29165
29232
  "reinforceShownCount",
29233
+ "reinforceRecentCount",
29166
29234
  "reinforceEvictedCount",
29167
- "reinforceUnshownCount"
29235
+ "reinforceUnshownCount",
29236
+ "reinforceUnshownQueryOnlyCount"
29168
29237
  ];
29169
29238
  function wmCalibrationCells(store2) {
29170
29239
  const cells = {
29240
+ calibrationSchema: WM_CALIBRATION_SCHEMA,
29171
29241
  shownNodes: 0,
29172
29242
  shownImpressions: 0,
29173
29243
  evictedNodes: 0,
29174
29244
  evictedImpressions: 0,
29175
29245
  reinforceShown: 0,
29246
+ reinforceRecent: 0,
29176
29247
  reinforceEvicted: 0,
29177
29248
  reinforceUnshown: 0,
29178
- reinforcedNodes: 0
29249
+ reinforceUnshownQueryOnly: 0,
29250
+ reinforcedNodes: 0,
29251
+ reinforcedShownNodes: 0
29179
29252
  };
29253
+ const newest = /* @__PURE__ */ new Map();
29180
29254
  for (const label of WM_CALIBRATION_LABELS) {
29181
- for (const n of store2.findNodeFieldsByLabel(label, WM_CALIBRATION_KEYS)) {
29182
- const shown = num(n.attrs["shownCount"]);
29183
- const evicted = num(n.attrs["evictedCount"]);
29184
- if (shown > 0) {
29185
- cells.shownNodes++;
29186
- cells.shownImpressions += shown;
29187
- }
29188
- if (evicted > 0) {
29189
- cells.evictedNodes++;
29190
- cells.evictedImpressions += evicted;
29191
- }
29192
- const rs = num(n.attrs["reinforceShownCount"]);
29193
- const re = num(n.attrs["reinforceEvictedCount"]);
29194
- const ru = num(n.attrs["reinforceUnshownCount"]);
29195
- cells.reinforceShown += rs;
29196
- cells.reinforceEvicted += re;
29197
- cells.reinforceUnshown += ru;
29198
- if (rs + re + ru > 0) cells.reinforcedNodes++;
29199
- }
29255
+ for (const n of store2.selectNodes({ labels: [label], attrs: WM_CALIBRATION_KEYS, includeClosed: true })) {
29256
+ const live = n.validTo === null;
29257
+ const prev = newest.get(n.logicalId);
29258
+ if (prev && (prev.live || !live && prev.version >= n.version)) continue;
29259
+ newest.set(n.logicalId, { version: n.version, live, attrs: n.attrs });
29260
+ }
29261
+ }
29262
+ for (const { attrs } of newest.values()) {
29263
+ const shown = num(attrs["shownCount"]);
29264
+ const evicted = num(attrs["evictedCount"]);
29265
+ if (shown > 0) {
29266
+ cells.shownNodes++;
29267
+ cells.shownImpressions += shown;
29268
+ }
29269
+ if (evicted > 0) {
29270
+ cells.evictedNodes++;
29271
+ cells.evictedImpressions += evicted;
29272
+ }
29273
+ const rs = num(attrs["reinforceShownCount"]);
29274
+ const rr = num(attrs["reinforceRecentCount"]);
29275
+ const re = num(attrs["reinforceEvictedCount"]);
29276
+ const ru = num(attrs["reinforceUnshownCount"]);
29277
+ cells.reinforceShown += rs;
29278
+ cells.reinforceRecent += rr;
29279
+ cells.reinforceEvicted += re;
29280
+ cells.reinforceUnshown += ru;
29281
+ cells.reinforceUnshownQueryOnly += num(attrs["reinforceUnshownQueryOnlyCount"]);
29282
+ if (rs + rr + re + ru > 0) cells.reinforcedNodes++;
29283
+ if (rs > 0) cells.reinforcedShownNodes++;
29200
29284
  }
29201
29285
  return cells;
29202
29286
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "errata-context",
3
- "version": "2.0.22-dev.4054",
3
+ "version": "2.0.22-dev.4071",
4
4
  "description": "A minimal 3D view of loaded Errata priors and recent graph bursts.",
5
5
  "author": {
6
6
  "name": "inErrata"
@@ -1,4 +1,4 @@
1
- a2cfe71e3f16c077959a201ff6ffb9d28203e992b5e6ea58bcfce9c8684b93e6 .codex-plugin/plugin.json
1
+ 2a7469f40a64a12ef74c4313dce84feb8ecccca9e841502b5b2e159fa098636f .codex-plugin/plugin.json
2
2
  a7bebae9fb01c838d6c75fc784129e28be571233fa66ff5ee8039b574f35ccf7 assets/icon.png
3
3
  fc38b64e4df1e0b72c35764bef6c4c05430d97c9009ad0ecc8a9e75b4deab232 configure-local.mjs
4
4
  73dc6028b3b070257c7c31f252d11e55a9e096f4aed0f187f10cb21716e1e6d7 dist/client.js