@inerrata-corporation/errata 2.0.2-dev.635 → 2.0.2-dev.650

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 +42 -16
  2. package/package.json +1 -1
package/errata.mjs CHANGED
@@ -18962,14 +18962,19 @@ function ingestDesignProblem(store, flag, opts) {
18962
18962
  }
18963
18963
  let solutionId = null;
18964
18964
  if (flag.fix?.trim() && !isFragmentFixNote(flag.fix)) {
18965
- solutionId = `dfix_${digest({ problemId, fix: flag.fix })}`.slice(0, 56);
18966
- store.mergeNode(
18967
- buildNode(store, solutionId, "Solution", flag.fix.trim(), opts.ts, {
18968
- source: "convo",
18969
- provisional: true,
18970
- rationale: flag.fix.trim()
18971
- })
18972
- );
18965
+ const reuse = findReusableSolution(store, flag.fix);
18966
+ if (reuse) {
18967
+ solutionId = reuse.id;
18968
+ } else {
18969
+ solutionId = `dfix_${digest({ problemId, fix: flag.fix })}`.slice(0, 56);
18970
+ store.mergeNode(
18971
+ buildNode(store, solutionId, "Solution", flag.fix.trim(), opts.ts, {
18972
+ source: "convo",
18973
+ provisional: true,
18974
+ rationale: flag.fix.trim()
18975
+ })
18976
+ );
18977
+ }
18973
18978
  mergeEdge(store, problemId, solutionId, "SOLVED_BY", opts.ts);
18974
18979
  }
18975
18980
  let anchored = false;
@@ -19177,6 +19182,19 @@ function isFragmentFixNote(note) {
19177
19182
  function isAutoMinted(n) {
19178
19183
  return n.label === "Solution" && String(n.description ?? "").startsWith(AUTO_MINT_PREFIX);
19179
19184
  }
19185
+ function solutionTextKey(text) {
19186
+ return text.trim().replace(/\s+/g, " ").toLowerCase();
19187
+ }
19188
+ function findReusableSolution(store, fixText) {
19189
+ const key = solutionTextKey(fixText);
19190
+ if (!key) return null;
19191
+ for (const s of store.findNodesByLabel("Solution")) {
19192
+ if (s.validTo != null) continue;
19193
+ if (isAutoMinted(s)) continue;
19194
+ if (solutionTextKey(s.description ?? "") === key) return s;
19195
+ }
19196
+ return null;
19197
+ }
19180
19198
  function priorsForFile(store, relPath) {
19181
19199
  const want = relPath.trim().replace(/^\.?\//, "");
19182
19200
  let file2 = null;
@@ -19360,11 +19378,16 @@ function closeDesignProblem(store, problemId, fixNote, t) {
19360
19378
  if (fixNote?.trim() && !isFragmentFixNote(fixNote)) {
19361
19379
  const sols = store.outEdges(problemId, ["SOLVED_BY"]).map((e) => store.getNode(e.to)).filter((n) => n !== null);
19362
19380
  if (sols.every((s) => isAutoMinted(s))) {
19363
- const solId = `dfix_${digest({ problemId, fix: fixNote })}`.slice(0, 56);
19364
- store.mergeNode(
19365
- buildNode(store, solId, "Solution", fixNote.trim(), t, { source: "convo", provisional: false })
19366
- );
19367
- mergeEdge(store, problemId, solId, "SOLVED_BY", t);
19381
+ const reuse = findReusableSolution(store, fixNote);
19382
+ if (reuse) {
19383
+ mergeEdge(store, problemId, reuse.id, "SOLVED_BY", t);
19384
+ } else {
19385
+ const solId = `dfix_${digest({ problemId, fix: fixNote })}`.slice(0, 56);
19386
+ store.mergeNode(
19387
+ buildNode(store, solId, "Solution", fixNote.trim(), t, { source: "convo", provisional: false })
19388
+ );
19389
+ mergeEdge(store, problemId, solId, "SOLVED_BY", t);
19390
+ }
19368
19391
  }
19369
19392
  }
19370
19393
  if (p.attrs["resolvedAt"]) return false;
@@ -21246,8 +21269,9 @@ function harvestTriageFences(l2, text, opts) {
21246
21269
  );
21247
21270
  if (f.fix) {
21248
21271
  const fix = f.fix.trim();
21249
- const fixId = `dfix_${digest({ cause: causeId, fix })}`.slice(0, 56);
21250
- if (!l2.getNode(fixId)) {
21272
+ const reuse = findReusableSolution(l2, fix);
21273
+ const fixId = reuse ? reuse.id : `dfix_${digest({ cause: causeId, fix })}`.slice(0, 56);
21274
+ if (!reuse && !l2.getNode(fixId)) {
21251
21275
  l2.mergeNode(semNode(l2, fixId, "Solution", fix, opts.ts, { scope: {} }));
21252
21276
  }
21253
21277
  const solEdgeId = `edge_sol_${causeId}_${fixId}`;
@@ -21264,6 +21288,7 @@ var init_triage2 = __esm({
21264
21288
  "../../packages/local-graph/src/triage.ts"() {
21265
21289
  "use strict";
21266
21290
  init_src();
21291
+ init_design_problem();
21267
21292
  init_src();
21268
21293
  init_src();
21269
21294
  init_src4();
@@ -22294,6 +22319,7 @@ __export(src_exports2, {
22294
22319
  findMintTimeDuplicate: () => findMintTimeDuplicate,
22295
22320
  findOrCreatePackage: () => findOrCreatePackage,
22296
22321
  findPath: () => findPath,
22322
+ findReusableSolution: () => findReusableSolution,
22297
22323
  flattenCloudCounts: () => flattenCloudCounts,
22298
22324
  foldDuplicateProblem: () => foldDuplicateProblem,
22299
22325
  formatMechanismStatus: () => formatMechanismStatus,
@@ -54965,7 +54991,7 @@ function startLoopLagMonitor(thresholdMs = 1e3) {
54965
54991
  }
54966
54992
 
54967
54993
  // src/engine.ts
54968
- var DAEMON_VERSION = true ? "2.0.2-dev.635" : "2.0.0-alpha.0";
54994
+ var DAEMON_VERSION = true ? "2.0.2-dev.650" : "2.0.0-alpha.0";
54969
54995
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
54970
54996
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
54971
54997
  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.2-dev.635",
3
+ "version": "2.0.2-dev.650",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {