@inerrata-corporation/errata 2.0.23 → 2.0.24-dev.5107

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.
package/pass-worker.mjs CHANGED
@@ -16534,7 +16534,25 @@ var TAG_CANONICAL_ID_PREFIXES, TAG_HANDLE_SOURCE, TAG_THREAD_SOURCE, TAG_PLACEHO
16534
16534
  var init_tag_grammar = __esm({
16535
16535
  "../../packages/local-shared/src/tag-grammar.ts"() {
16536
16536
  "use strict";
16537
- TAG_CANONICAL_ID_PREFIXES = ["pat", "sol", "drc", "dcause", "dfix", "dprob", "dvuln", "prob", "claim", "err"];
16537
+ TAG_CANONICAL_ID_PREFIXES = [
16538
+ "motif_community_projn",
16539
+ "motif_community_orgn",
16540
+ "motif",
16541
+ "projn",
16542
+ "orgn",
16543
+ "dtri",
16544
+ "dom",
16545
+ "pat",
16546
+ "sol",
16547
+ "drc",
16548
+ "dcause",
16549
+ "dfix",
16550
+ "dprob",
16551
+ "dvuln",
16552
+ "prob",
16553
+ "claim",
16554
+ "err"
16555
+ ];
16538
16556
  TAG_HANDLE_SOURCE = String.raw`\[([a-z0-9][\w-]{0,80})\]|((?:${TAG_CANONICAL_ID_PREFIXES.join("|")})_[0-9a-f]{6,})`;
16539
16557
  TAG_THREAD_SOURCE = String.raw`#([a-z][\w-]{0,63})`;
16540
16558
  TAG_PLACEHOLDER_HANDLES = /* @__PURE__ */ new Set([
@@ -26818,6 +26836,197 @@ function communityDomain(memberDomains, domainSize) {
26818
26836
  return best;
26819
26837
  }
26820
26838
 
26839
+ // ../../packages/math/src/spectral.ts
26840
+ function largestConnectedComponent(n, adj) {
26841
+ const seen = new Uint8Array(n);
26842
+ let best = [];
26843
+ for (let start2 = 0; start2 < n; start2++) {
26844
+ if (seen[start2]) continue;
26845
+ const comp = [];
26846
+ const queue = [start2];
26847
+ seen[start2] = 1;
26848
+ while (queue.length) {
26849
+ const v = queue.shift();
26850
+ comp.push(v);
26851
+ for (const { j } of adj[v]) {
26852
+ if (!seen[j]) {
26853
+ seen[j] = 1;
26854
+ queue.push(j);
26855
+ }
26856
+ }
26857
+ }
26858
+ if (comp.length > best.length) best = comp;
26859
+ }
26860
+ return best;
26861
+ }
26862
+ function indexedAdjacency(input) {
26863
+ const idx = new Map(input.nodeIds.map((id, i2) => [id, i2]));
26864
+ const adj = input.nodeIds.map(() => []);
26865
+ for (const id of input.nodeIds) {
26866
+ const i2 = idx.get(id);
26867
+ for (const { to, weight } of input.adj.get(id) ?? []) {
26868
+ const j = idx.get(to);
26869
+ if (j === void 0 || j === i2) continue;
26870
+ adj[i2].push({ j, w: weight });
26871
+ }
26872
+ }
26873
+ return adj;
26874
+ }
26875
+ function largestConnectedComponentSize(input) {
26876
+ return largestConnectedComponent(input.nodeIds.length, indexedAdjacency(input)).length;
26877
+ }
26878
+
26879
+ // ../../packages/math/src/detectability.ts
26880
+ var BETHE_DEFAULT_MAX = 32;
26881
+ var betheSteps = (maxCommunities) => 2 * maxCommunities + 40;
26882
+ var NEGATIVE_TOLERANCE = 1e-7;
26883
+ function betheDetectability(input, opts = {}) {
26884
+ const unweighted = opts.unweighted ?? true;
26885
+ const maxCommunities = opts.maxCommunities ?? BETHE_DEFAULT_MAX;
26886
+ const n = input.nodeIds.length;
26887
+ const empty = {
26888
+ nodes: n,
26889
+ meanDegree: 0,
26890
+ negativeEigenvalues: [],
26891
+ detectableCommunities: 0,
26892
+ capped: false
26893
+ };
26894
+ if (n < 2) return empty;
26895
+ const idx = /* @__PURE__ */ new Map();
26896
+ input.nodeIds.forEach((id, i2) => idx.set(id, i2));
26897
+ const rows = input.nodeIds.map(() => []);
26898
+ const deg = new Float64Array(n);
26899
+ let twoM = 0;
26900
+ for (const id of input.nodeIds) {
26901
+ const i2 = idx.get(id);
26902
+ for (const { to, weight } of input.adj.get(id) ?? []) {
26903
+ const j = idx.get(to);
26904
+ if (j === void 0 || j === i2 || weight <= 0) continue;
26905
+ const w = unweighted ? 1 : weight;
26906
+ rows[i2].push([j, w]);
26907
+ deg[i2] = deg[i2] + w;
26908
+ twoM += w;
26909
+ }
26910
+ }
26911
+ if (twoM <= 0) return empty;
26912
+ const d = twoM / n;
26913
+ let sumSq = 0;
26914
+ for (let i2 = 0; i2 < n; i2++) sumSq += deg[i2] * deg[i2];
26915
+ const excess = sumSq / twoM - 1;
26916
+ if (excess <= 0) return { ...empty, meanDegree: d };
26917
+ const r = Math.sqrt(excess);
26918
+ const diagShift = r * r - 1;
26919
+ const apply = (v, out2) => {
26920
+ for (let i2 = 0; i2 < n; i2++) {
26921
+ let av = 0;
26922
+ for (const [j, w] of rows[i2]) av += w * v[j];
26923
+ out2[i2] = diagShift * v[i2] - r * av + deg[i2] * v[i2];
26924
+ }
26925
+ };
26926
+ const ritz = lanczosRitzValues(n, apply, Math.min(n, betheSteps(maxCommunities)), 24301);
26927
+ let scale = 1;
26928
+ for (const x of ritz) scale = Math.max(scale, Math.abs(x));
26929
+ const negatives = ritz.filter((x) => x < -NEGATIVE_TOLERANCE * scale);
26930
+ const capped = negatives.length >= maxCommunities;
26931
+ const kept = negatives.slice(0, maxCommunities);
26932
+ return {
26933
+ nodes: n,
26934
+ meanDegree: d,
26935
+ negativeEigenvalues: kept,
26936
+ detectableCommunities: Math.max(0, kept.length - 1),
26937
+ capped
26938
+ };
26939
+ }
26940
+ function lanczosRitzValues(n, apply, steps, seed) {
26941
+ const prng = mulberry32(seed);
26942
+ let v = new Float64Array(n);
26943
+ for (let i2 = 0; i2 < n; i2++) v[i2] = prng() - 0.5;
26944
+ const shaped = new Float64Array(n);
26945
+ apply(v, shaped);
26946
+ if (normalize2(shaped) > 0) v = shaped;
26947
+ else if (normalize2(v) === 0) return [];
26948
+ const basis = [];
26949
+ const alpha = [];
26950
+ const beta = [];
26951
+ let prev = null;
26952
+ let b = 0;
26953
+ for (let j = 0; j < steps; j++) {
26954
+ basis.push(v);
26955
+ const w = new Float64Array(n);
26956
+ apply(v, w);
26957
+ let a = 0;
26958
+ for (let i2 = 0; i2 < n; i2++) a += w[i2] * v[i2];
26959
+ alpha.push(a);
26960
+ for (let i2 = 0; i2 < n; i2++) w[i2] = w[i2] - a * v[i2] - (prev ? b * prev[i2] : 0);
26961
+ for (const u of basis) projectOff(w, u);
26962
+ b = normalize2(w);
26963
+ if (b <= 1e-12 * Math.max(1, Math.abs(a))) break;
26964
+ beta.push(b);
26965
+ prev = v;
26966
+ v = w;
26967
+ }
26968
+ return tridiagonalEigenvalues(alpha, beta.slice(0, alpha.length - 1));
26969
+ }
26970
+ function tridiagonalEigenvalues(alpha, beta) {
26971
+ const m = alpha.length;
26972
+ if (m === 0) return [];
26973
+ let lo = Infinity;
26974
+ let hi = -Infinity;
26975
+ for (let i2 = 0; i2 < m; i2++) {
26976
+ const radius = (i2 > 0 ? Math.abs(beta[i2 - 1]) : 0) + (i2 < m - 1 ? Math.abs(beta[i2]) : 0);
26977
+ lo = Math.min(lo, alpha[i2] - radius);
26978
+ hi = Math.max(hi, alpha[i2] + radius);
26979
+ }
26980
+ const tiny = 1e-300;
26981
+ const countBelow = (x) => {
26982
+ let count = 0;
26983
+ let q = alpha[0] - x;
26984
+ if (q < 0) count++;
26985
+ for (let i2 = 1; i2 < m; i2++) {
26986
+ if (q === 0) q = tiny;
26987
+ q = alpha[i2] - x - beta[i2 - 1] * beta[i2 - 1] / q;
26988
+ if (q < 0) count++;
26989
+ }
26990
+ return count;
26991
+ };
26992
+ const out2 = [];
26993
+ const width = Math.max(hi - lo, 1e-12);
26994
+ for (let k = 0; k < m; k++) {
26995
+ let a = lo;
26996
+ let c = hi;
26997
+ for (let it = 0; it < 200 && c - a > 1e-13 * width; it++) {
26998
+ const mid = (a + c) / 2;
26999
+ if (countBelow(mid) > k) c = mid;
27000
+ else a = mid;
27001
+ }
27002
+ out2.push((a + c) / 2);
27003
+ }
27004
+ return out2;
27005
+ }
27006
+ function mulberry32(seed) {
27007
+ let a = seed >>> 0;
27008
+ return () => {
27009
+ a = a + 1831565813 >>> 0;
27010
+ let t = a;
27011
+ t = Math.imul(t ^ t >>> 15, t | 1);
27012
+ t ^= t + Math.imul(t ^ t >>> 7, t | 61);
27013
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
27014
+ };
27015
+ }
27016
+ function projectOff(v, u) {
27017
+ let dot = 0;
27018
+ for (let i2 = 0; i2 < v.length; i2++) dot += v[i2] * u[i2];
27019
+ if (dot === 0) return;
27020
+ for (let i2 = 0; i2 < v.length; i2++) v[i2] = v[i2] - dot * u[i2];
27021
+ }
27022
+ function normalize2(v) {
27023
+ let s = 0;
27024
+ for (let i2 = 0; i2 < v.length; i2++) s += v[i2] * v[i2];
27025
+ const norm = Math.sqrt(s);
27026
+ if (norm > 0) for (let i2 = 0; i2 < v.length; i2++) v[i2] = v[i2] / norm;
27027
+ return norm;
27028
+ }
27029
+
26821
27030
  // ../../packages/math/src/void-demand.ts
26822
27031
  var DEMAND_HOT = Math.log1p(10);
26823
27032
  var DEMAND_WARM = Math.log1p(5);
@@ -26976,13 +27185,23 @@ function pagerankLocal(input) {
26976
27185
  return { scores, iterations: iter, converged };
26977
27186
  }
26978
27187
 
27188
+ // ../../packages/math/src/reader-evidence.ts
27189
+ var FIELD_CODES = {
27190
+ a: "acceptedCount",
27191
+ c: "corroborationCount",
27192
+ f: "failureReportCount",
27193
+ p: "contradictionPressure"
27194
+ };
27195
+ var FIELDS = Object.values(FIELD_CODES);
27196
+
26979
27197
  // ../../packages/local-graph/src/node-select.ts
26980
27198
  var SELECT_INDEXES = [
26981
27199
  "nodes_live_local_community",
26982
27200
  "nodes_live_fold_candidate",
26983
27201
  "nodes_live_resolved",
26984
27202
  "nodes_live_fix_candidate",
26985
- "nodes_live_anchor_hint"
27203
+ "nodes_live_anchor_hint",
27204
+ "nodes_live_created_v2"
26986
27205
  ];
26987
27206
  var EMBEDDING_DIM_SQL = "(CASE WHEN length(embedding_blob) >= 4 THEN length(embedding_blob) / 4 ELSE COALESCE(json_array_length(embedding_json), 0) END)";
26988
27207
  var KEY = /^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/;
@@ -27303,7 +27522,10 @@ CREATE UNIQUE INDEX IF NOT EXISTS edges_triple ON edges(from_id, type, to_id);
27303
27522
  `;
27304
27523
  var TEMPORAL_INDEX_SQL = `
27305
27524
  CREATE INDEX IF NOT EXISTS nodes_live ON nodes(label, valid_to);
27306
- CREATE INDEX IF NOT EXISTS nodes_live_count ON nodes(valid_to);
27525
+ -- Dropped: a prefix of nodes_live_page_rank (valid_to, page_rank), which serves
27526
+ -- the live count and the "any live node?" check as a covering index too. It was
27527
+ -- re-keyed on every close and revive: ~11 KB of a symbol flip's ~80 KB.
27528
+ DROP INDEX IF EXISTS nodes_live_count;
27307
27529
  -- Problems by recency (the only label read newest-first). Over every live row,
27308
27530
  -- each write that stamps last_updated_at moved a code symbol's entry from a
27309
27531
  -- scattered leaf: ~19 KB per position-only symbol rewrite on a 1.1 GB store.
@@ -27315,7 +27537,13 @@ CREATE INDEX IF NOT EXISTS nodes_live_problem_recent ON nodes(label, last_update
27315
27537
  -- walks nodes_live and reads every live row of the label to test created_at:
27316
27538
  -- 56 MB per guard on a 1.1 GB store, to learn there was nothing to do. valid_to
27317
27539
  -- is a key column so the planner prefers this over nodes_live (one more term).
27318
- CREATE INDEX IF NOT EXISTS nodes_live_created ON nodes(label, valid_to, created_at) WHERE valid_to IS NULL;
27540
+ -- last_updated_at rides along for errata.recent on code labels, which names this
27541
+ -- index: the filter runs on index entries, not on every row of the label (79 ms
27542
+ -- \u2192 3 ms for Function on a 1.1 GB store). It costs no extra writes: a close or
27543
+ -- revive already re-keys this index, and mergeNodeIfChanged leaves a symbol's
27544
+ -- last_updated_at alone when only its position moved.
27545
+ DROP INDEX IF EXISTS nodes_live_created;
27546
+ CREATE INDEX IF NOT EXISTS nodes_live_created_v2 ON nodes(label, valid_to, created_at, last_updated_at) WHERE valid_to IS NULL;
27319
27547
  -- Community members (the skills pull reads them twice per session boundary):
27320
27548
  -- ~15% of semantic nodes carry a localCommunity, and without this every live
27321
27549
  -- semantic row was read to find them (168 MB \u2192 18 MB per read).
@@ -27500,6 +27728,12 @@ function sameSqlValue(a, b) {
27500
27728
  if (a instanceof Uint8Array && b instanceof Uint8Array) return Buffer.compare(a, b) === 0;
27501
27729
  return false;
27502
27730
  }
27731
+ var POSITION_ATTRS = ["startByte", "endByte", "startRow"];
27732
+ function attrsJsonWithoutPositions(attrs) {
27733
+ const rest = { ...attrs };
27734
+ for (const k of POSITION_ATTRS) delete rest[k];
27735
+ return JSON.stringify(rest);
27736
+ }
27503
27737
  var PRIOR_TAG_MARKER = '"priorTag":true';
27504
27738
  var SqliteGraphStore = class {
27505
27739
  db;
@@ -27600,7 +27834,7 @@ var SqliteGraphStore = class {
27600
27834
  lastUpdatedOf: this.db.prepare("SELECT last_updated_at AS t, attrs_json FROM nodes WHERE id = ?"),
27601
27835
  labelOf: this.db.prepare("SELECT label FROM nodes WHERE id = ?"),
27602
27836
  nodeContent: this.db.prepare(
27603
- "SELECT label, description, extraction_confidence, extraction_source, stability, valid_to, attrs_json FROM nodes WHERE id = ?"
27837
+ "SELECT label, description, extraction_confidence, extraction_source, stability, valid_to, last_updated_at, attrs_json FROM nodes WHERE id = ?"
27604
27838
  ),
27605
27839
  edgeContent: this.db.prepare(
27606
27840
  "SELECT confidence, valid_to, attrs_json FROM edges WHERE from_id = ? AND type = ? AND to_id = ?"
@@ -28013,11 +28247,23 @@ var SqliteGraphStore = class {
28013
28247
  * rank, community, landmark, surprise, hits, tier and the vector belong to
28014
28248
  * the passes that compute them, and a skipped write leaves them as they are
28015
28249
  * where a merge would have reset them to the producer's defaults. Returns
28016
- * whether it wrote. */
28250
+ * whether it wrote.
28251
+ *
28252
+ * A live row whose only change is its position keeps its lastUpdatedAt, so
28253
+ * that stamp means "this symbol's content changed": what errata.recent lists
28254
+ * and the fix-candidate ask reads, and what lets nodes_live_created_v2 carry
28255
+ * it without being re-keyed by every edit above a symbol. A closed row is
28256
+ * always stamped: reviveReobserved reopens what this pass stamped. */
28017
28257
  mergeNodeIfChanged(node) {
28018
28258
  const row = this.stmts.nodeContent.get(node.id);
28019
- if (row && row.valid_to === null && row.label === node.label && row.description === node.description && row.extraction_confidence === node.extractionConfidence && row.stability === node.stability && !EXPOSURE_ATTRS.some((k) => node.attrs?.[k] !== void 0) && row.attrs_json === JSON.stringify(node.attrs ?? {})) return false;
28020
- this.mergeNode(node);
28259
+ if (!row || row.valid_to !== null || row.label !== node.label || row.description !== node.description || row.extraction_confidence !== node.extractionConfidence || row.stability !== node.stability || EXPOSURE_ATTRS.some((k) => node.attrs?.[k] !== void 0)) {
28260
+ this.mergeNode(node);
28261
+ return true;
28262
+ }
28263
+ const attrs = node.attrs ?? {};
28264
+ if (row.attrs_json === JSON.stringify(attrs)) return false;
28265
+ const moved = attrsJsonWithoutPositions(JSON.parse(row.attrs_json)) === attrsJsonWithoutPositions(attrs);
28266
+ this.mergeNode(moved ? { ...node, lastUpdatedAt: row.last_updated_at } : node);
28021
28267
  return true;
28022
28268
  }
28023
28269
  updateNode(id, patch) {
@@ -28097,8 +28343,8 @@ var SqliteGraphStore = class {
28097
28343
  stmt2 = this.db.prepare(
28098
28344
  // Ordered, not left to the planner: readers take "first row wins" (the
28099
28345
  // symbol lexicon's name winner and doc pick), and the order otherwise
28100
- // followed whichever partial index the planner chose. nodes_live_created
28101
- // serves this order without a sort.
28346
+ // followed whichever partial index the planner chose. nodes_live_created_v2
28347
+ // serves it, sorting rowids only within an equal created_at.
28102
28348
  `SELECT id, description, community, extraction_confidence${cols} FROM nodes WHERE label = ? AND valid_to IS NULL ORDER BY created_at, rowid`
28103
28349
  );
28104
28350
  this.fieldStmts.set(cacheKey, stmt2);
@@ -29130,10 +29376,12 @@ function crystallize(store2, opts = { ts: 0 }) {
29130
29376
  const s = support(c) + Math.max(0, sourcesCount(c) - 1);
29131
29377
  const f = contradictions;
29132
29378
  const confidence = (1 + s) / (2 + s + f);
29133
- store2.updateNode(c.id, {
29134
- attrs: { ...c.attrs, confidence },
29135
- lastUpdatedAt: opts.ts
29136
- });
29379
+ if (c.attrs["confidence"] !== confidence) {
29380
+ store2.updateNode(c.id, {
29381
+ attrs: { ...c.attrs, confidence },
29382
+ lastUpdatedAt: opts.ts
29383
+ });
29384
+ }
29137
29385
  const sup = support(c);
29138
29386
  let tier = c.memoryTier;
29139
29387
  if (sup >= PERSISTENT_SUPPORT && confidence >= PERSISTENT_CONFIDENCE) tier = "persistent";
@@ -29201,7 +29449,10 @@ function mergeTruthKind(a, b) {
29201
29449
  function markBoth(store2, a, b, patch, ts) {
29202
29450
  for (const n of [a, b]) {
29203
29451
  const fresh = store2.getNode(n.id);
29204
- store2.updateNode(n.id, { attrs: { ...fresh.attrs, ...patch }, lastUpdatedAt: ts });
29452
+ const next = { ...patch };
29453
+ if (fresh.attrs["revisit"] === true && fresh.attrs["revisitReason"] === next["revisitReason"]) delete next["revisitSinceTs"];
29454
+ if (Object.entries(next).every(([k, v]) => fresh.attrs[k] === v)) continue;
29455
+ store2.updateNode(n.id, { attrs: { ...fresh.attrs, ...next }, lastUpdatedAt: ts });
29205
29456
  }
29206
29457
  }
29207
29458
 
@@ -29392,6 +29643,20 @@ function backfillProblemContext(store2, ts) {
29392
29643
  return report;
29393
29644
  }
29394
29645
 
29646
+ // ../../packages/embedding/src/bands.ts
29647
+ var DESIGNED_FOR_MINILM = {
29648
+ dedup: 0.88,
29649
+ softWriteMin: 0.8,
29650
+ bindMin: 0.78,
29651
+ nearMiss: 0.72,
29652
+ judgeMin: 0.5,
29653
+ predictionFloor: 0.5,
29654
+ relevanceFloor: 0.25,
29655
+ relatedWeak: 0.35,
29656
+ relatedStrong: 0.45
29657
+ };
29658
+ var UNKNOWN = { ...DESIGNED_FOR_MINILM, relevanceFloor: 0.5 };
29659
+
29395
29660
  // ../../packages/local-graph/src/design-problem.ts
29396
29661
  init_src2();
29397
29662
 
@@ -30225,8 +30490,78 @@ function candidateDomains(store2, ids, labelOf) {
30225
30490
  }
30226
30491
  return out2;
30227
30492
  }
30493
+ function buildJointAdjacency(store2, ids) {
30494
+ const adj = /* @__PURE__ */ new Map();
30495
+ const protect = [];
30496
+ const add = (a, b, w) => {
30497
+ const l = adj.get(a) ?? [];
30498
+ l.push({ to: b, weight: w });
30499
+ adj.set(a, l);
30500
+ };
30501
+ for (const id of ids) {
30502
+ for (const e of store2.outEdges(id, [...JOINT_COMMUNITY_EDGES])) {
30503
+ if (!ids.has(e.to)) continue;
30504
+ if (e.type === "INSTANCE_OF" && e.extractionSource === "bko-inferred") continue;
30505
+ const conf = e.confidence > 0 ? e.confidence : 0.5;
30506
+ const w = Math.max(EDGE_WEIGHT[e.type] ?? 1, 0.1) * conf;
30507
+ add(id, e.to, w);
30508
+ add(e.to, id, w);
30509
+ if (isCausalProtected(e.type)) protect.push([id, e.to]);
30510
+ }
30511
+ }
30512
+ return { adj, protect };
30513
+ }
30514
+ function projectionDetectability(input) {
30515
+ let support2 = 0;
30516
+ for (const id of input.nodeIds) support2 += (input.adj.get(id) ?? []).length;
30517
+ const meanDegree = input.nodeIds.length > 0 ? support2 / input.nodeIds.length : 0;
30518
+ const lccIds = largestConnectedComponentMembers(input);
30519
+ const lcc = lccIds.length >= 3 ? betheDetectability({ nodeIds: lccIds, adj: input.adj }) : null;
30520
+ return {
30521
+ readings: {
30522
+ meanDegree,
30523
+ lccSize: lccIds.length,
30524
+ lccDetectable: lcc?.detectableCommunities ?? 0
30525
+ },
30526
+ lccIds
30527
+ };
30528
+ }
30529
+ function largestConnectedComponentMembers(input) {
30530
+ if (largestConnectedComponentSize(input) <= 1) return input.nodeIds.slice(0, 1);
30531
+ const present = new Set(input.nodeIds);
30532
+ const seen = /* @__PURE__ */ new Set();
30533
+ let best = [];
30534
+ for (const start2 of input.nodeIds) {
30535
+ if (seen.has(start2)) continue;
30536
+ const comp = [];
30537
+ const stack = [start2];
30538
+ seen.add(start2);
30539
+ while (stack.length > 0) {
30540
+ const id = stack.pop();
30541
+ comp.push(id);
30542
+ for (const { to } of input.adj.get(id) ?? []) {
30543
+ if (!present.has(to) || seen.has(to)) continue;
30544
+ seen.add(to);
30545
+ stack.push(to);
30546
+ }
30547
+ }
30548
+ if (comp.length > best.length) best = comp;
30549
+ }
30550
+ return best;
30551
+ }
30228
30552
  function detectLocalCommunities(store2, opts = {}) {
30229
- const report = { candidates: 0, communities: 0, joint: 0, assigned: 0, belowFloor: 0, cleared: 0 };
30553
+ const report = {
30554
+ candidates: 0,
30555
+ communities: 0,
30556
+ joint: 0,
30557
+ assigned: 0,
30558
+ belowFloor: 0,
30559
+ cleared: 0,
30560
+ meanDegree: 0,
30561
+ lccSize: 0,
30562
+ lccDetectable: 0,
30563
+ lccPieces: 0
30564
+ };
30230
30565
  const nodes = /* @__PURE__ */ new Map();
30231
30566
  const unowned = [];
30232
30567
  for (const label of JOINT_COMMUNITY_LABELS) {
@@ -30250,25 +30585,12 @@ function detectLocalCommunities(store2, opts = {}) {
30250
30585
  }
30251
30586
  });
30252
30587
  if (ids.size === 0) return report;
30253
- const adj = /* @__PURE__ */ new Map();
30254
- const protect = [];
30255
- const add = (a, b, w) => {
30256
- const l = adj.get(a) ?? [];
30257
- l.push({ to: b, weight: w });
30258
- adj.set(a, l);
30259
- };
30260
- for (const id of ids) {
30261
- for (const e of store2.outEdges(id, [...JOINT_COMMUNITY_EDGES])) {
30262
- if (!ids.has(e.to)) continue;
30263
- if (e.type === "INSTANCE_OF" && e.extractionSource === "bko-inferred") continue;
30264
- const conf = e.confidence > 0 ? e.confidence : 0.5;
30265
- const w = Math.max(EDGE_WEIGHT[e.type] ?? 1, 0.1) * conf;
30266
- add(id, e.to, w);
30267
- add(e.to, id, w);
30268
- if (isCausalProtected(e.type)) protect.push([id, e.to]);
30269
- }
30270
- }
30271
- const comm = detectCommunitiesLeiden({ nodeIds: [...ids], adj }, { protect });
30588
+ const { adj, protect } = buildJointAdjacency(store2, ids);
30589
+ const input = { nodeIds: [...ids], adj };
30590
+ const detectability = projectionDetectability(input);
30591
+ Object.assign(report, detectability.readings);
30592
+ const comm = detectCommunitiesLeiden(input, { protect });
30593
+ report.lccPieces = new Set(detectability.lccIds.map((id) => comm.community.get(id))).size;
30272
30594
  const members = /* @__PURE__ */ new Map();
30273
30595
  for (const [id, c] of comm.community) {
30274
30596
  const l = members.get(c) ?? [];
@@ -30346,6 +30668,70 @@ var MECHANISMS = [
30346
30668
  effectCounter: "refutesStamped",
30347
30669
  note: "RG-mark; reason text is local-only (wire ships nodeId+witnessKey)"
30348
30670
  },
30671
+ {
30672
+ id: "confirm-local-stamp",
30673
+ what: "stamps a harvested confirm / leaned-on witness onto the LOCAL node (confirmedAt/confirmations)",
30674
+ pass: "capture",
30675
+ // The consumer is errata.search's one formula (apps/daemon one-search.ts
30676
+ // localEvidence → packages/math rankKnowledge reliability). Self-gated and
30677
+ // synthetic-gated at harvest, so a quiet counter can also mean every cite
30678
+ // was the session's own — the written-at-all bar, like refutedAt.
30679
+ fed: {
30680
+ labels: ["Problem", "Solution", "RootCause", "Pattern"],
30681
+ attr: "confirmedAt",
30682
+ minFraction: 0
30683
+ },
30684
+ effectCounter: "confirmsStamped",
30685
+ note: "consumed by one-search rankKnowledge; transport to cloud corroborationCount unchanged"
30686
+ },
30687
+ {
30688
+ id: "supersession-ask",
30689
+ what: "asks how a just-recorded fix relates to earlier fixes for the same symptom; the agent's answer mints SUPERSEDES/BUILDS_ON/ALTERNATIVE_TO",
30690
+ pass: "capture",
30691
+ // Conditional and rare (a fix landing beside earlier ones) — written-at-all
30692
+ // bar. The consumer is supersededBy in rankKnowledge (local lifecycle.ts,
30693
+ // cloud entry-rank.ts) and the superseded/held notes agents read.
30694
+ fed: {
30695
+ labels: ["Solution"],
30696
+ attr: "supersessionAskedAt",
30697
+ minFraction: 0
30698
+ },
30699
+ effectCounter: "structureLinksMinted",
30700
+ note: "the answer is the agent's; nothing is inferred"
30701
+ },
30702
+ {
30703
+ id: "held-ask",
30704
+ what: "asks a session whether a prior it leaned on held; the agent's confirm/refute answers it",
30705
+ pass: "capture",
30706
+ // Opened only by a lean-on cite of a prior the session did not mint —
30707
+ // written-at-all bar. The answers feed confirmedAt/refutedAt locally and
30708
+ // the cloud's corroborate/contradict channels (§5.4 α/β) — the contrastive
30709
+ // verdicts the FEP core needs (docs/reference/plans/fep-core.md §5.7).
30710
+ fed: {
30711
+ labels: ["Problem", "Solution", "RootCause", "Pattern"],
30712
+ attr: "heldAskedAt",
30713
+ minFraction: 0
30714
+ },
30715
+ // Counts only answers to questions a render actually SHOWED — a verdict the
30716
+ // agent would have given unasked does not prove the ask did anything.
30717
+ effectCounter: "heldAnswered",
30718
+ note: "asked, never inferred; the lean is provisional while asked and replaced by the answer; Network-only priors are asked by id"
30719
+ },
30720
+ {
30721
+ id: "neighbour-ask",
30722
+ what: "shows a just-minted problem's nearest existing problems once; the agent's bare cite ([h]) mints RELATES_TO",
30723
+ pass: "capture",
30724
+ // Conditional (a new problem with a neighbour in the band) — written-at-all
30725
+ // bar. Before this, 69% of open agent-observed Problems had no cause,
30726
+ // instance or relation edge and never gained one (live store 2026-10-27).
30727
+ fed: {
30728
+ labels: ["Problem"],
30729
+ attr: "neighbourAskedAt",
30730
+ minFraction: 0
30731
+ },
30732
+ effectCounter: "neighbourLinksMinted",
30733
+ note: "MEL-203; the link is the agent's \u2014 nothing is inferred from similarity"
30734
+ },
30349
30735
  {
30350
30736
  id: "regression-recognize",
30351
30737
  what: "marks a resolved problem as resolutionSuspect when it recurs at the door",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "errata-context",
3
- "version": "2.0.23",
3
+ "version": "2.0.24-dev.5107",
4
4
  "description": "A minimal 3D view of loaded Errata priors and recent graph bursts.",
5
5
  "author": {
6
6
  "name": "inErrata"
@@ -1,14 +1,14 @@
1
- 2f63c615dcb8381cd2e5eda37ba5bb8aa79e35c7f536e9bbbb9ff5ec18d36040 .codex-plugin/plugin.json
1
+ af56c071ef86e48a2112bfca26f77c5f0b1794b0b6eadac1903e12f5a82673a6 .codex-plugin/plugin.json
2
2
  a7bebae9fb01c838d6c75fc784129e28be571233fa66ff5ee8039b574f35ccf7 assets/icon.png
3
3
  fc38b64e4df1e0b72c35764bef6c4c05430d97c9009ad0ecc8a9e75b4deab232 configure-local.mjs
4
- 73dc6028b3b070257c7c31f252d11e55a9e096f4aed0f187f10cb21716e1e6d7 dist/client.js
4
+ 80431e822def1ed5f5376ff0e67af30b4d26829572982e08fe24f438838f134c dist/client.js
5
5
  6d2d2068ffa7e6627151aa69e86654d1b3452e7205d75a15b312c1bc663d03d4 dist/index.html
6
- 1c5b4bdf92eca32629bf74003f711cf5bafebb5c9cf988ea068feb8da536457b dist/mcp-server.mjs
7
- fca26cc5a0ee1080a9f4aa1773b3e634ea7ff12376bbb66ea66ee3670dc5f274 dist/panel.html
6
+ aa0bb16795d53b70e0de3aad9dbe2d9d13aec1bbe7f7b10f2ad6d636c574e265 dist/mcp-server.mjs
7
+ 18146fb994a6e04a1078bed957061e8128be97e8e9e15a06f5a82192476e0b7c dist/panel.html
8
8
  ab99177aff0d134ef44f7867c61a7c4eb8a6afbb0f138c08dbb68e7546260147 dist/server.mjs
9
9
  5a721b645e399e676d48f8691ec81694172f1bbdea309c852dd099ef7a147018 dist/style.css
10
10
  2644953a4a3762926663db951c03ad3175061c9d52de49cf90d07ddb4c73846a INSTALL.md
11
11
  fb840ab74865258c91565529fa08f9f8586261f973c08a798e8f66d85d3260ed launch.mjs
12
12
  5abff6ef2aff3bc033862e2293421908e6d6fe9425de042412e0c8b577a6d8fc skills/context-graph/SKILL.md
13
13
  9f8d96a5a28248e04b54fdabed59319a640dead39ede67fe9b9283aec678d46f SUBMISSION.md
14
- 5852d66e82ac6aab92911ba375fa1a02f3ad853f498517e1d50cc0225aa67d66 THIRD-PARTY-NOTICES.md
14
+ 24b45b998aae358bcdfbd7569c7243efe494acaca7f89089bbd848b07fc4eefb THIRD-PARTY-NOTICES.md
@@ -251,7 +251,7 @@ the full license text.
251
251
 
252
252
  ---
253
253
 
254
- ## @modelcontextprotocol/sdk@1.29.0
254
+ ## @modelcontextprotocol/sdk@1.32.2
255
255
 
256
256
  LICENSE
257
257
  MIT License
@@ -996,6 +996,34 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
996
996
  SOFTWARE.
997
997
 
998
998
 
999
+ ---
1000
+
1001
+ ## eventsource-parser@3.1.1
1002
+
1003
+ LICENSE
1004
+ MIT License
1005
+
1006
+ Copyright (c) 2026 Espen Hovlandsdal <espen@hovlandsdal.com>
1007
+
1008
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1009
+ of this software and associated documentation files (the "Software"), to deal
1010
+ in the Software without restriction, including without limitation the rights
1011
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1012
+ copies of the Software, and to permit persons to whom the Software is
1013
+ furnished to do so, subject to the following conditions:
1014
+
1015
+ The above copyright notice and this permission notice shall be included in all
1016
+ copies or substantial portions of the Software.
1017
+
1018
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1019
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1020
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1021
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1022
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1023
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1024
+ SOFTWARE.
1025
+
1026
+
999
1027
  ---
1000
1028
 
1001
1029
  ## eventsource@3.0.7