@inerrata-corporation/errata 2.0.2-dev.588 → 2.0.2-dev.597

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 +104 -5
  2. package/package.json +1 -1
package/errata.mjs CHANGED
@@ -19150,11 +19150,15 @@ function reinforceSameAnchorProblem(store, relPath, workspaceId2, statement, sou
19150
19150
  if (!sources.includes(source)) {
19151
19151
  const corroborations2 = (existing.attrs["corroborations"] ?? 0) + 1;
19152
19152
  const promoted = corroborations2 >= DESIGN_PROMOTE_AT;
19153
+ const exposure = priorExposure(store, existing.id, store.currentIngestSeq());
19154
+ const expField = `reinforce${exposure[0].toUpperCase()}${exposure.slice(1)}Count`;
19153
19155
  store.updateNode(existing.id, {
19154
19156
  attrs: {
19155
19157
  ...existing.attrs,
19156
19158
  sources: [...sources, source],
19157
19159
  corroborations: corroborations2,
19160
+ [expField]: (existing.attrs[expField] ?? 0) + 1,
19161
+ lastReinforceExposure: exposure,
19158
19162
  ...promoted ? { provisional: false } : {}
19159
19163
  },
19160
19164
  cumulativeHits: (existing.cumulativeHits ?? 0) + 1,
@@ -19471,6 +19475,8 @@ function recordRenderLedger(store, ledger, seq, ts) {
19471
19475
  if (field === "shownCount") {
19472
19476
  attrs["lastShownAtSeq"] = seq;
19473
19477
  if (attrs["firstShownAtSeq"] === void 0) attrs["firstShownAtSeq"] = seq;
19478
+ } else {
19479
+ attrs["lastEvictedAtSeq"] = seq;
19474
19480
  }
19475
19481
  store.updateNode(id, { attrs, lastUpdatedAt: node2.lastUpdatedAt });
19476
19482
  n++;
@@ -19485,6 +19491,16 @@ function recordRenderLedger(store, ledger, seq, ts) {
19485
19491
  });
19486
19492
  return { shown, evicted };
19487
19493
  }
19494
+ function priorExposure(store, nodeId, atSeq) {
19495
+ const n = store.getNode(nodeId);
19496
+ if (!n || !n.attrs) return "unshown";
19497
+ const shownSeq = n.attrs["lastShownAtSeq"];
19498
+ if (shownSeq !== void 0 && shownSeq <= atSeq) return "shown";
19499
+ const evictedSeq = n.attrs["lastEvictedAtSeq"];
19500
+ if (evictedSeq !== void 0 && evictedSeq <= atSeq) return "evicted";
19501
+ if ((n.attrs["evictedCount"] ?? 0) > 0) return "evicted";
19502
+ return "unshown";
19503
+ }
19488
19504
  var DESIGN_PROMOTE_AT, STATEMENT_ALIAS_CAP, PATTERN_DEDUP_COSINE, PATTERN_ALIAS_CAP, DEDUP_STOPWORDS, SAME_ANCHOR_DEDUP_JACCARD, CITABLE_PRIOR_LABELS, MAX_ANCHOR_FILES, AUTO_MINT_PREFIX, FIX_CANDIDATE_ASK_LIMIT;
19489
19505
  var init_design_problem = __esm({
19490
19506
  "../../packages/local-graph/src/design-problem.ts"() {
@@ -22170,6 +22186,7 @@ __export(src_exports2, {
22170
22186
  pendingAbstractions: () => pendingAbstractions,
22171
22187
  pendingDiscriminators: () => pendingDiscriminators,
22172
22188
  percolate: () => percolate,
22189
+ priorExposure: () => priorExposure,
22173
22190
  priorsForFile: () => priorsForFile,
22174
22191
  promoteRouteWithDiscriminator: () => promoteRouteWithDiscriminator,
22175
22192
  propagateFactChange: () => propagateFactChange,
@@ -22556,6 +22573,21 @@ function renderSnapshot(s) {
22556
22573
  lines.push(`- **${h.description}** \u2014 \`${h.id}\``);
22557
22574
  }
22558
22575
  }
22576
+ if (si.remoteHits?.length) {
22577
+ lines.push("");
22578
+ lines.push("_From the Errata Network \u2014 collective priors on this intent:_");
22579
+ for (const h of si.remoteHits) {
22580
+ lines.push(`- **${h.label}:** ${h.description} \u2014 \`${h.id}\``);
22581
+ }
22582
+ }
22583
+ if (si.knownGap) {
22584
+ const g = si.knownGap;
22585
+ const others = g.othersStuck !== null ? `, ${g.othersStuck} other contributor(s) stuck here` : "";
22586
+ lines.push("");
22587
+ lines.push(
22588
+ `_\u26A0 Known gap: the collective graph knows it doesn't know this (open void \u2014 demand ${g.demand.toFixed(1)}, ${g.demandTier}${others}). What you capture on this intent fills a gap someone is already waiting on._`
22589
+ );
22590
+ }
22559
22591
  lines.push("");
22560
22592
  } else if (s.workingFile) {
22561
22593
  const w = s.workingFile;
@@ -23701,9 +23733,15 @@ var init_client = __esm({
23701
23733
  if (q.codeFingerprint) qs.set("codeFingerprint", q.codeFingerprint);
23702
23734
  if (q.seed?.length) qs.set("seed", q.seed.join(","));
23703
23735
  if (q.q) qs.set("q", q.q);
23736
+ if (q.channel) qs.set("channel", q.channel);
23704
23737
  const res = await this.json("GET", `/v2/search?${qs.toString()}`);
23705
23738
  const { nodes, edges } = this.toCastalia(res);
23706
- return { nodes, edges, generatedAt: res.generatedAt };
23739
+ return {
23740
+ nodes,
23741
+ edges,
23742
+ generatedAt: res.generatedAt,
23743
+ ...res.voidSignal ? { voidSignal: res.voidSignal } : {}
23744
+ };
23707
23745
  }
23708
23746
  /**
23709
23747
  * The castalia wire shape → local-mergeable graph. Extracted so the priming fetch
@@ -52046,7 +52084,7 @@ function harvestInlineTags(store, text, opts) {
52046
52084
  const source = opts.sourceId ? store.getNode(opts.sourceId) : null;
52047
52085
  const mintPriors = opts.mintPriors ?? true;
52048
52086
  const touched = opts.sessionTouchedIds ?? /* @__PURE__ */ new Set();
52049
- const plan = { priorEdges: 0, corroboratedEdges: 0, problems: [], fixes: [], triages: [], causalLinks: [], attempts: [], unresolvedFixes: [], transfers: [], solutionLinks: [], instances: [], patterns: [], domains: [], packages: [], components: [], refutes: [], corroborations: [] };
52087
+ const plan = { priorEdges: 0, corroboratedEdges: 0, exposureShown: 0, exposureEvicted: 0, exposureUnshown: 0, problems: [], fixes: [], triages: [], causalLinks: [], attempts: [], unresolvedFixes: [], transfers: [], solutionLinks: [], instances: [], patterns: [], domains: [], packages: [], components: [], refutes: [], corroborations: [] };
52050
52088
  const tags = parseInlineTags(text);
52051
52089
  const symptomSeqs = tags.filter((t) => (t.kind === "problem" || t.kind === "todo") && t.statement).map((t) => ({ seq: t.seq ?? -1, statement: t.statement, threadId: t.threadId })).sort((a, b) => a.seq - b.seq);
52052
52090
  const bindSymptom = (seq, threadId) => {
@@ -52236,7 +52274,11 @@ function harvestInlineTags(store, text, opts) {
52236
52274
  if (targetId && citedLabel && CORROBORATABLE_LABELS.has(citedLabel)) {
52237
52275
  const witnessKey = `corrob:${targetId}:lean:${digest({ h: tag.handle })}`.slice(0, 72);
52238
52276
  if (!plan.corroborations.some((c) => c.witnessKey === witnessKey)) {
52239
- plan.corroborations.push({ nodeId: targetId, witnessKey });
52277
+ const exposure = typeof store.currentIngestSeq === "function" ? priorExposure(store, targetId, store.currentIngestSeq()) : "unshown";
52278
+ if (exposure === "shown") plan.exposureShown++;
52279
+ else if (exposure === "evicted") plan.exposureEvicted++;
52280
+ else plan.exposureUnshown++;
52281
+ plan.corroborations.push({ nodeId: targetId, witnessKey, exposure });
52240
52282
  }
52241
52283
  }
52242
52284
  if (mintPriors && source && target) {
@@ -54420,7 +54462,7 @@ function startLoopLagMonitor(thresholdMs = 1e3) {
54420
54462
  }
54421
54463
 
54422
54464
  // src/engine.ts
54423
- var DAEMON_VERSION = true ? "2.0.2-dev.588" : "2.0.0-alpha.0";
54465
+ var DAEMON_VERSION = true ? "2.0.2-dev.597" : "2.0.0-alpha.0";
54424
54466
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
54425
54467
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
54426
54468
  var GIT_OP_MUTE_MS = 4e3;
@@ -54759,6 +54801,8 @@ function createWorkspaceEngine(opts) {
54759
54801
  let lastRemoteAt = 0;
54760
54802
  let remoteInFlight = false;
54761
54803
  const REMOTE_REFRESH_MS = 5 * 6e4;
54804
+ let intentRemote = null;
54805
+ let intentRemoteInFlight = false;
54762
54806
  let ctxRefreshInFlight = false;
54763
54807
  let ctxRefreshQueued = false;
54764
54808
  let lastSelfCiteSkips = 0;
@@ -54820,12 +54864,14 @@ function createWorkspaceEngine(opts) {
54820
54864
  const pendingUpdate = opts.pendingUpdate?.() ?? null;
54821
54865
  const reviewItems = pickReviewItems();
54822
54866
  const liveIntent = intents.mostRecent(Date.now());
54867
+ maybeRefreshIntentPriors(liveIntent ?? null);
54823
54868
  const intentHits = liveIntent ? searchByIntent(store, liveIntent, { limit: 4 }).map((h) => ({
54824
54869
  id: h.node.id,
54825
54870
  label: h.node.label,
54826
54871
  description: h.node.description,
54827
54872
  coverage: h.coverage
54828
54873
  })) : [];
54874
+ const intentCollective = liveIntent && intentRemote?.forIntent === liveIntent ? intentRemote : null;
54829
54875
  const { body: body2, snapshot, ledger } = assembleAgentContext({
54830
54876
  store,
54831
54877
  ...snapOpts,
@@ -54834,7 +54880,20 @@ function createWorkspaceEngine(opts) {
54834
54880
  ...prebuilt ? { snapshot: prebuilt } : {},
54835
54881
  ...pendingUpdate ? { pendingUpdate } : {},
54836
54882
  ...reviewItems.length ? { reviewItems } : {},
54837
- ...liveIntent ? { statedIntent: { text: liveIntent, hits: intentHits } } : {}
54883
+ ...liveIntent ? {
54884
+ statedIntent: {
54885
+ text: liveIntent,
54886
+ hits: intentHits,
54887
+ ...intentCollective && intentCollective.hits.length > 0 ? {
54888
+ remoteHits: intentCollective.hits.slice(0, 4).map((n) => ({
54889
+ id: n.id,
54890
+ label: n.label,
54891
+ description: n.description
54892
+ }))
54893
+ } : {},
54894
+ ...intentCollective?.voidSignal ? { knownGap: intentCollective.voidSignal } : {}
54895
+ }
54896
+ } : {}
54838
54897
  });
54839
54898
  doneRender?.();
54840
54899
  try {
@@ -54888,6 +54947,10 @@ function createWorkspaceEngine(opts) {
54888
54947
  domains: norm(profile.domains),
54889
54948
  kinds: ["Pattern", "Technique", "AntiPattern"],
54890
54949
  ...seed.length ? { seed } : {},
54950
+ // VD-priorsearch: this is the AMBIENT lane — declaring it keeps its
54951
+ // misses from masquerading as asks (the 1515-miss mega-void was this
54952
+ // exact query, unlabeled).
54953
+ channel: "priming",
54891
54954
  limit: 8
54892
54955
  };
54893
54956
  cloud.search(q).then((res) => {
@@ -54901,6 +54964,32 @@ function createWorkspaceEngine(opts) {
54901
54964
  remoteInFlight = false;
54902
54965
  }
54903
54966
  };
54967
+ const maybeRefreshIntentPriors = (liveIntent) => {
54968
+ if (!liveIntent || opts.skipContextWriter || intentRemoteInFlight) return;
54969
+ if (intentRemote?.forIntent === liveIntent) return;
54970
+ const syncOk = opts.syncConsent ?? loadConfig().consent.sync;
54971
+ if (!syncOk) return;
54972
+ if (typeof cloud.search !== "function") return;
54973
+ intentRemoteInFlight = true;
54974
+ cloud.search({
54975
+ stack: [],
54976
+ domains: [],
54977
+ kinds: ["Pattern", "Technique", "AntiPattern", "Problem", "Solution"],
54978
+ q: liveIntent,
54979
+ channel: "intent",
54980
+ limit: 6
54981
+ }).then((res) => {
54982
+ intentRemote = {
54983
+ forIntent: liveIntent,
54984
+ hits: res.nodes ?? [],
54985
+ ...res.voidSignal ? { voidSignal: res.voidSignal } : {}
54986
+ };
54987
+ contextDirty = true;
54988
+ }).catch(() => {
54989
+ }).finally(() => {
54990
+ intentRemoteInFlight = false;
54991
+ });
54992
+ };
54904
54993
  const runNightly = async () => {
54905
54994
  if (passWorker) {
54906
54995
  try {
@@ -55093,6 +55182,9 @@ function createWorkspaceEngine(opts) {
55093
55182
  let abstracted = 0;
55094
55183
  let triaged = 0;
55095
55184
  let priorEdges = 0;
55185
+ let exposureShown = 0;
55186
+ let exposureEvicted = 0;
55187
+ let exposureUnshown = 0;
55096
55188
  let corroboratedEdges = 0;
55097
55189
  let touchedFileTurns = 0;
55098
55190
  let touchedToolTurns = 0;
@@ -55216,6 +55308,9 @@ function createWorkspaceEngine(opts) {
55216
55308
  });
55217
55309
  priorEdges += plan.priorEdges;
55218
55310
  corroboratedEdges += plan.corroboratedEdges;
55311
+ exposureShown += plan.exposureShown;
55312
+ exposureEvicted += plan.exposureEvicted;
55313
+ exposureUnshown += plan.exposureUnshown;
55219
55314
  if (touchedFileId) touchedFileTurns++;
55220
55315
  if ((toolRuns.get(sessionId)?.size ?? 0) > 0) touchedToolTurns++;
55221
55316
  const wf = workingFiles.get(sessionId);
@@ -55628,6 +55723,10 @@ function createWorkspaceEngine(opts) {
55628
55723
  triaged,
55629
55724
  priorEdges,
55630
55725
  corroboratedEdges,
55726
+ // WM-labels calibration cells (see prior-tags exposure split).
55727
+ exposureShown,
55728
+ exposureEvicted,
55729
+ exposureUnshown,
55631
55730
  touchedFileTurns,
55632
55731
  touchedToolTurns,
55633
55732
  // Seam diagnostic: sessions holding tool-run records at harvest time.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata-corporation/errata",
3
- "version": "2.0.2-dev.588",
3
+ "version": "2.0.2-dev.597",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {