@inerrata-corporation/errata 2.0.0-dev.91 → 2.0.0-dev.92

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/errata.mjs CHANGED
@@ -17918,11 +17918,90 @@ function linkProblemToLanguages(store, problemId, text, ts, index) {
17918
17918
  }
17919
17919
  return linked;
17920
17920
  }
17921
- function deriveContextFromStatement(store, problemId, text, ts, pkgIndex) {
17922
- return {
17923
- packages: linkProblemToPackages(store, problemId, text, ts, pkgIndex).linked,
17924
- languages: linkProblemToLanguages(store, problemId, text, ts)
17921
+ function isShapedSymbol(name2) {
17922
+ if (name2.length < SYMBOL_MIN_LEN) return false;
17923
+ return name2 !== name2.toLowerCase() || name2.includes("_") || name2.includes(".");
17924
+ }
17925
+ function buildSymbolIndex(store) {
17926
+ const idx = /* @__PURE__ */ new Map();
17927
+ const ambiguous = /* @__PURE__ */ new Set();
17928
+ for (const label of SYMBOL_LABELS) {
17929
+ for (const n of store.findNodesByLabel(label)) {
17930
+ const name2 = n.description?.trim();
17931
+ if (!name2 || ambiguous.has(name2) || !isShapedSymbol(name2)) continue;
17932
+ if (idx.has(name2)) {
17933
+ idx.delete(name2);
17934
+ ambiguous.add(name2);
17935
+ } else {
17936
+ idx.set(name2, n);
17937
+ }
17938
+ }
17939
+ }
17940
+ return idx;
17941
+ }
17942
+ function matchSymbolsInText(text, index) {
17943
+ const out2 = [];
17944
+ for (const [name2, node2] of index) {
17945
+ if (!text.includes(name2)) continue;
17946
+ const bounded = new RegExp(`(?<![\\w$])${escapeRe3(name2)}(?![\\w$])`);
17947
+ if (bounded.test(text)) out2.push(node2);
17948
+ }
17949
+ return out2;
17950
+ }
17951
+ function linkProblemToSymbols(store, problemId, text, ts, index) {
17952
+ const p = store.getNode(problemId);
17953
+ if (!p || p.label !== "Problem") return [];
17954
+ const idx = index ?? buildSymbolIndex(store);
17955
+ if (idx.size === 0) return [];
17956
+ let fileByPath = null;
17957
+ const fileFor2 = (relPath) => {
17958
+ if (!fileByPath) {
17959
+ fileByPath = /* @__PURE__ */ new Map();
17960
+ for (const f of store.findNodesByLabel("File")) {
17961
+ const rp = String(f.attrs["relPath"] ?? f.description ?? "");
17962
+ if (rp) fileByPath.set(rp, f);
17963
+ }
17964
+ }
17965
+ return fileByPath.get(relPath) ?? null;
17925
17966
  };
17967
+ const already = new Set(store.outEdges(problemId, ["ANCHORED_AT"]).map((e) => e.to));
17968
+ const linked = [];
17969
+ for (const sym of matchSymbolsInText(text, idx)) {
17970
+ const relPath = String(sym.attrs["relPath"] ?? "");
17971
+ if (!relPath) continue;
17972
+ const file2 = fileFor2(relPath);
17973
+ if (!file2 || already.has(file2.id)) continue;
17974
+ store.mergeEdge({
17975
+ id: `edge_${digest({ from: problemId, type: "ANCHORED_AT", to: file2.id })}`.slice(0, 24),
17976
+ from: problemId,
17977
+ to: file2.id,
17978
+ type: "ANCHORED_AT",
17979
+ confidence: 0.3,
17980
+ // soft — a lexical mention, below a witnessed anchor's 0.4
17981
+ extractionSource: "daemon-extracted",
17982
+ createdAt: ts,
17983
+ lastSeenAt: ts,
17984
+ navSuccesses: 0,
17985
+ navFailures: 0,
17986
+ // `mention` gates it out of resolveDesignProblems (fix-detection); the
17987
+ // symbol name is kept for provenance + eventual symbol-level anchoring.
17988
+ attrs: { provisional: true, mention: true, mentionSymbol: sym.description }
17989
+ });
17990
+ already.add(file2.id);
17991
+ linked.push(file2.id);
17992
+ }
17993
+ return linked;
17994
+ }
17995
+ function deriveContextFromStatement(store, problemId, text, ts, pkgIndex) {
17996
+ const packages = linkProblemToPackages(store, problemId, text, ts, pkgIndex).linked;
17997
+ const languages = linkProblemToLanguages(store, problemId, text, ts);
17998
+ const anchoredFiles = linkProblemToSymbols(store, problemId, text, ts);
17999
+ if (anchoredFiles.length > 0) {
18000
+ const ctx = deriveContextFromAnchors(store, problemId, ts, pkgIndex);
18001
+ for (const l of ctx.languages) if (!languages.includes(l)) languages.push(l);
18002
+ for (const pk of ctx.packages) if (!packages.includes(pk)) packages.push(pk);
18003
+ }
18004
+ return { packages, languages };
17926
18005
  }
17927
18006
  function problemText(store, p) {
17928
18007
  const parts2 = [p.description];
@@ -18045,7 +18124,7 @@ function backfillProblemContext(store, ts) {
18045
18124
  }
18046
18125
  return report;
18047
18126
  }
18048
- var NAME_SEPARATOR, MIN_NAME_LEN, LANGUAGE_MIN_LEN;
18127
+ var NAME_SEPARATOR, MIN_NAME_LEN, LANGUAGE_MIN_LEN, SYMBOL_MIN_LEN, SYMBOL_LABELS;
18049
18128
  var init_problem_package_link = __esm({
18050
18129
  "../../packages/local-graph/src/problem-package-link.ts"() {
18051
18130
  "use strict";
@@ -18054,6 +18133,8 @@ var init_problem_package_link = __esm({
18054
18133
  NAME_SEPARATOR = /[@/\-._]/;
18055
18134
  MIN_NAME_LEN = 3;
18056
18135
  LANGUAGE_MIN_LEN = 4;
18136
+ SYMBOL_MIN_LEN = 5;
18137
+ SYMBOL_LABELS = ["Function", "Method", "Class", "Const"];
18057
18138
  }
18058
18139
  });
18059
18140
 
@@ -18437,6 +18518,7 @@ function resolveDesignProblems(store, t) {
18437
18518
  let symRelPath;
18438
18519
  let edited = false;
18439
18520
  for (const e of store.outEdges(p.id, ["ANCHORED_AT"])) {
18521
+ if (e.attrs?.["mention"] === true) continue;
18440
18522
  const sym = store.getNode(e.to);
18441
18523
  if (sym && sym.lastUpdatedAt > p.createdAt) {
18442
18524
  edited = true;
@@ -20630,6 +20712,7 @@ __export(src_exports2, {
20630
20712
  buildLanguageIndex: () => buildLanguageIndex,
20631
20713
  buildPackageIndex: () => buildPackageIndex,
20632
20714
  buildPrincipleSync: () => buildPrincipleSync,
20715
+ buildSymbolIndex: () => buildSymbolIndex,
20633
20716
  causalChain: () => causalChain,
20634
20717
  claimId: () => claimId,
20635
20718
  clearRevisit: () => clearRevisit,
@@ -20658,10 +20741,12 @@ __export(src_exports2, {
20658
20741
  isPlaceholderStatement: () => isPlaceholderStatement,
20659
20742
  linkProblemToLanguages: () => linkProblemToLanguages,
20660
20743
  linkProblemToPackages: () => linkProblemToPackages,
20744
+ linkProblemToSymbols: () => linkProblemToSymbols,
20661
20745
  listNeedsRevisit: () => listNeedsRevisit,
20662
20746
  markRevisit: () => markRevisit,
20663
20747
  matchLanguagesInText: () => matchLanguagesInText,
20664
20748
  matchPackagesInText: () => matchPackagesInText,
20749
+ matchSymbolsInText: () => matchSymbolsInText,
20665
20750
  mergeCloudCounts: () => mergeCloudCounts,
20666
20751
  mergeDuplicateProblems: () => mergeDuplicateProblems,
20667
20752
  mintPatternNode: () => mintPatternNode,
@@ -25287,7 +25372,7 @@ function isDistinctiveIdentifier(name2) {
25287
25372
  function buildSymbolLexicon(store, summariesByBodyHash2) {
25288
25373
  const lex = /* @__PURE__ */ new Map();
25289
25374
  const candidates = [];
25290
- for (const [label, kind] of SYMBOL_LABELS) {
25375
+ for (const [label, kind] of SYMBOL_LABELS2) {
25291
25376
  for (const n of store.findNodesByLabel(label)) {
25292
25377
  const bodyHash = typeof n.attrs["bodyHash"] === "string" ? n.attrs["bodyHash"] : void 0;
25293
25378
  const summary = bodyHash ? summariesByBodyHash2?.get(bodyHash) : void 0;
@@ -25326,13 +25411,13 @@ function generalizeSymbols(text, lexicon, level = 1) {
25326
25411
  }
25327
25412
  return generalize(out2, { level }).text;
25328
25413
  }
25329
- var SYMBOL_LABELS, KIND_PHRASE, RE_RESERVED2, escapeRe4, TOKEN_RE3;
25414
+ var SYMBOL_LABELS2, KIND_PHRASE, RE_RESERVED2, escapeRe4, TOKEN_RE3;
25330
25415
  var init_generalize_graph = __esm({
25331
25416
  "src/generalize-graph.ts"() {
25332
25417
  "use strict";
25333
25418
  init_src8();
25334
25419
  init_src();
25335
- SYMBOL_LABELS = [
25420
+ SYMBOL_LABELS2 = [
25336
25421
  ["Function", "function"],
25337
25422
  ["Method", "method"],
25338
25423
  ["Class", "class"],
@@ -49268,7 +49353,7 @@ function parseInlineTags(text) {
49268
49353
  let seqNo = -1;
49269
49354
  for (const raw2 of deFenced.split(/(?<=[.!?])\s+|\n+/)) {
49270
49355
  seqNo++;
49271
- if (raw2.length > 600) continue;
49356
+ if (raw2.length > 2e4) continue;
49272
49357
  const seqStart = out2.length;
49273
49358
  const sentence = raw2.replace(
49274
49359
  /`[^`]*`/g,
@@ -51301,7 +51386,7 @@ function startLoopLagMonitor(thresholdMs = 1e3) {
51301
51386
  }
51302
51387
 
51303
51388
  // src/engine.ts
51304
- var DAEMON_VERSION = true ? "2.0.0-dev.91" : "2.0.0-alpha.0";
51389
+ var DAEMON_VERSION = true ? "2.0.0-dev.92" : "2.0.0-alpha.0";
51305
51390
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
51306
51391
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
51307
51392
  var GIT_OP_MUTE_MS = 4e3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata-corporation/errata",
3
- "version": "2.0.0-dev.91",
3
+ "version": "2.0.0-dev.92",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {
package/pass-worker.mjs CHANGED
@@ -25215,6 +25215,7 @@ function resolveDesignProblems(store2, t) {
25215
25215
  let symRelPath;
25216
25216
  let edited = false;
25217
25217
  for (const e of store2.outEdges(p.id, ["ANCHORED_AT"])) {
25218
+ if (e.attrs?.["mention"] === true) continue;
25218
25219
  const sym = store2.getNode(e.to);
25219
25220
  if (sym && sym.lastUpdatedAt > p.createdAt) {
25220
25221
  edited = true;