@inerrata-corporation/errata 2.0.6-dev.2608 → 2.0.6-dev.2618

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 +27 -12
  2. package/package.json +1 -1
package/errata.mjs CHANGED
@@ -31078,13 +31078,18 @@ function bindCanonicalNeighbors(store, opts) {
31078
31078
  const problems = store.findNodesByLabel("Problem").filter((p) => p.embedding.length > 0 && live2(p));
31079
31079
  const patterns = store.findNodesByLabel("Pattern").filter((p) => p.embedding.length > 0);
31080
31080
  const candidates = [...problems, ...patterns];
31081
+ const since = opts.freshSince;
31082
+ const fresh = (n) => since === void 0 || n.createdAt > since || n.lastUpdatedAt > since;
31083
+ const freshCandidates = since === void 0 ? candidates : candidates.filter(fresh);
31081
31084
  let bound = 0;
31082
31085
  for (const p of problems) {
31086
+ const pool = fresh(p) ? candidates : freshCandidates;
31087
+ if (pool.length === 0) continue;
31083
31088
  const existing = new Set(
31084
31089
  store.outEdges(p.id, ["MATCHES", "INSTANCE_OF", "RELATES_TO"]).map((e) => e.to)
31085
31090
  );
31086
31091
  if (existing.size >= k) continue;
31087
- const ranked = candidates.filter(
31092
+ const ranked = pool.filter(
31088
31093
  (c) => c.id !== p.id && !existing.has(c.id) && c.embedding.length === p.embedding.length && (c.attrs["embeddingVersion"] ?? "") === (p.attrs["embeddingVersion"] ?? "")
31089
31094
  ).map((c) => ({ c, s: cosine(p.embedding, c.embedding) })).filter((x) => x.s >= CANONICAL_BIND_MIN && x.s < NEMORI_DEDUP_COSINE).sort((a, b) => b.s - a.s);
31090
31095
  const picked = [];
@@ -78421,7 +78426,7 @@ function createWatchBreaker(deps) {
78421
78426
  }
78422
78427
 
78423
78428
  // src/engine.ts
78424
- var DAEMON_VERSION = true ? "2.0.6-dev.2608" : "2.0.0-alpha.0";
78429
+ var DAEMON_VERSION = true ? "2.0.6-dev.2618" : "2.0.0-alpha.0";
78425
78430
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
78426
78431
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
78427
78432
  var GIT_OP_MUTE_MS = 4e3;
@@ -80549,8 +80554,10 @@ B: ${b}`,
80549
80554
  return report;
80550
80555
  },
80551
80556
  async embedSettled() {
80557
+ const yieldLoop = () => new Promise((r) => setImmediate(r));
80552
80558
  try {
80553
80559
  const sem = await embedSemanticNodes(store);
80560
+ await yieldLoop();
80554
80561
  if (sem.embedded > 0) {
80555
80562
  console.log(`[errata] embedded ${sem.embedded} semantic node(s)`);
80556
80563
  }
@@ -80563,18 +80570,27 @@ B: ${b}`,
80563
80570
  if (e.merged > 0 || (e.nearMissMarked ?? 0) > 0) {
80564
80571
  console.log(`[errata] dedup: merged ${e.merged} paraphrased problem(s) across ${e.clusters} cluster(s), parked ${e.nearMissMarked ?? 0} near-miss nomination(s)${parkWmRaw === null ? " (first full sweep)" : ""}`);
80565
80572
  }
80573
+ await yieldLoop();
80566
80574
  if (sem.embedded > 0) {
80567
- const cb = bindCanonicalNeighbors(store, { ts: Date.now() });
80575
+ const bindStart = Date.now();
80576
+ const bindWmRaw = store.getMeta?.("canon_bind_at") ?? null;
80577
+ const cb = bindCanonicalNeighbors(store, {
80578
+ ts: bindStart,
80579
+ ...bindWmRaw !== null ? { freshSince: Number(bindWmRaw) || 0 } : {}
80580
+ });
80581
+ store.setMeta?.("canon_bind_at", String(bindStart));
80568
80582
  if (cb.bound > 0) {
80569
80583
  console.log(`[errata] canonical-bind: +${cb.bound} machine-proposed link(s) across ${cb.scanned} problem(s)`);
80570
80584
  }
80571
80585
  refreshContextNow();
80572
80586
  }
80587
+ await yieldLoop();
80573
80588
  const rg = bindResolvedRegressions(store, { ts: Date.now() });
80574
80589
  if (rg.bound > 0) {
80575
80590
  console.warn(`[errata] REGRESSION: bound ${rg.bound} open problem(s) to resolved predecessors${rg.full ? " (first full sweep)" : ""}`);
80576
80591
  refreshContextNow();
80577
80592
  }
80593
+ await yieldLoop();
80578
80594
  const fjStart = Date.now();
80579
80595
  const fj = await resolveFoldCandidates(store, {
80580
80596
  ts: fjStart,
@@ -89869,7 +89885,7 @@ async function cmdDash(args2) {
89869
89885
  let triggerConsolidation = () => {
89870
89886
  };
89871
89887
  const runBoundaryFlush = (reason) => {
89872
- void handle2.sessionBoundaryFlush().then((r) => {
89888
+ return handle2.sessionBoundaryFlush().then((r) => {
89873
89889
  if (r.skipped) return;
89874
89890
  if (r.uploaded > 0 || r.written > 0 || r.pruned > 0) {
89875
89891
  console.log(
@@ -89903,16 +89919,15 @@ async function cmdDash(args2) {
89903
89919
  if (quiesceTimer) clearTimeout(quiesceTimer);
89904
89920
  quiesceTimer = setTimeout(() => {
89905
89921
  quiesceTimer = null;
89906
- runBoundaryFlush("quiescent");
89907
- runSemanticPass("quiescent");
89908
- triggerConsolidation(false);
89922
+ settleThenConsolidate("quiescent", false);
89909
89923
  }, QUIESCENCE_MS);
89910
89924
  };
89911
- handle2.onSessionBoundary(() => {
89912
- runBoundaryFlush("session-end");
89913
- runSemanticPass("session-end");
89914
- triggerConsolidation(true);
89915
- });
89925
+ const settleThenConsolidate = (reason, force) => {
89926
+ const flushed = runBoundaryFlush(reason);
89927
+ setImmediate(() => runSemanticPass(reason));
89928
+ void flushed.finally(() => triggerConsolidation(force));
89929
+ };
89930
+ handle2.onSessionBoundary(() => settleThenConsolidate("session-end", true));
89916
89931
  let ticking = false;
89917
89932
  const interval = setInterval(() => {
89918
89933
  if (ticking) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata-corporation/errata",
3
- "version": "2.0.6-dev.2608",
3
+ "version": "2.0.6-dev.2618",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {