crbro-memory 2.6.0 → 2.7.1

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 (60) hide show
  1. package/README.md +515 -487
  2. package/SECURITY.md +222 -0
  3. package/bin/crbro.mjs +241 -6
  4. package/dist/engine/backup.d.ts.map +1 -1
  5. package/dist/engine/backup.js +5 -1
  6. package/dist/engine/backup.js.map +1 -1
  7. package/dist/engine/cortex.d.ts +61 -0
  8. package/dist/engine/cortex.d.ts.map +1 -1
  9. package/dist/engine/cortex.js +270 -24
  10. package/dist/engine/cortex.js.map +1 -1
  11. package/dist/engine/hookverify.d.ts +42 -0
  12. package/dist/engine/hookverify.d.ts.map +1 -0
  13. package/dist/engine/hookverify.js +169 -0
  14. package/dist/engine/hookverify.js.map +1 -0
  15. package/dist/engine/maintenance.d.ts.map +1 -1
  16. package/dist/engine/maintenance.js +15 -2
  17. package/dist/engine/maintenance.js.map +1 -1
  18. package/dist/engine/postmortem.d.ts +81 -0
  19. package/dist/engine/postmortem.d.ts.map +1 -0
  20. package/dist/engine/postmortem.js +449 -0
  21. package/dist/engine/postmortem.js.map +1 -0
  22. package/dist/engine/prefrontal.d.ts +1 -0
  23. package/dist/engine/prefrontal.d.ts.map +1 -1
  24. package/dist/engine/prefrontal.js +8 -2
  25. package/dist/engine/prefrontal.js.map +1 -1
  26. package/dist/engine/secrets.d.ts +9 -0
  27. package/dist/engine/secrets.d.ts.map +1 -1
  28. package/dist/engine/secrets.js +7 -0
  29. package/dist/engine/secrets.js.map +1 -1
  30. package/dist/engine/triggers.d.ts +8 -2
  31. package/dist/engine/triggers.d.ts.map +1 -1
  32. package/dist/engine/triggers.js +21 -11
  33. package/dist/engine/triggers.js.map +1 -1
  34. package/dist/engine/usage.d.ts +61 -0
  35. package/dist/engine/usage.d.ts.map +1 -0
  36. package/dist/engine/usage.js +252 -0
  37. package/dist/engine/usage.js.map +1 -0
  38. package/dist/search/index.d.ts +40 -0
  39. package/dist/search/index.d.ts.map +1 -1
  40. package/dist/search/index.js +186 -5
  41. package/dist/search/index.js.map +1 -1
  42. package/dist/server.d.ts.map +1 -1
  43. package/dist/server.js +98 -10
  44. package/dist/server.js.map +1 -1
  45. package/dist/sync/materialize.d.ts.map +1 -1
  46. package/dist/sync/materialize.js +54 -1
  47. package/dist/sync/materialize.js.map +1 -1
  48. package/dist/types/index.d.ts +28 -0
  49. package/dist/types/index.d.ts.map +1 -1
  50. package/dist/utils/ids.d.ts +6 -0
  51. package/dist/utils/ids.d.ts.map +1 -1
  52. package/dist/utils/ids.js +14 -4
  53. package/dist/utils/ids.js.map +1 -1
  54. package/dist/utils/transcripts.d.ts +63 -0
  55. package/dist/utils/transcripts.d.ts.map +1 -0
  56. package/dist/utils/transcripts.js +242 -0
  57. package/dist/utils/transcripts.js.map +1 -0
  58. package/hooks/crbro-lifecycle.mjs +608 -0
  59. package/hooks/crbro-subagent.mjs +17 -4
  60. package/package.json +2 -1
@@ -1,10 +1,17 @@
1
1
  import { AsyncLocalStorage } from 'node:async_hooks';
2
2
  import type { Brain } from './brain.js';
3
3
  import type { Neuron, NeuronType, FactStatus } from '../types/index.js';
4
+ /**
5
+ * `witnessed`: "<neuron>|<fact id>" of every fact this session stored or
6
+ * confirmed. A session is one witness: storing the same line again in the
7
+ * same session (a retry, the post-compaction re-save) does not count twice.
8
+ * Not cleared by consolidate, which ends a chapter, not the conversation.
9
+ */
4
10
  export interface SessionTally {
5
11
  facts: number;
6
12
  decisions: number;
7
13
  topics: Set<string>;
14
+ witnessed?: Set<string>;
8
15
  }
9
16
  export declare const newTally: () => SessionTally;
10
17
  /**
@@ -17,6 +24,58 @@ export declare const sessionScope: AsyncLocalStorage<{
17
24
  tally: SessionTally;
18
25
  resumed?: boolean;
19
26
  }>;
27
+ /**
28
+ * Near-duplicates of `content` among `candidates`, best first: Dice ≥ 0.8 on
29
+ * lower-cased text, both sides at least NEAR_DUP_MIN_LENGTH characters. The
30
+ * one rule behind learn's near_duplicates warning (inside one neuron) and
31
+ * consolidate's promotion_candidates (across project neurons), so the two
32
+ * cannot disagree on what "almost the same line" means.
33
+ */
34
+ export declare function nearDuplicatesAmong(content: string, candidates: Array<{
35
+ id: string;
36
+ text: string;
37
+ }>): Array<{
38
+ id: string;
39
+ similarity: number;
40
+ text: string;
41
+ }>;
42
+ /** Lesson kinds that can be promoted: what was learned, not what was decided or preferred. */
43
+ export type LessonKind = 'fact' | 'pattern' | 'error';
44
+ export interface PromotionCandidate {
45
+ kind: LessonKind;
46
+ /** The telling to promote: the most confirmed copy, then the longest. */
47
+ text: string;
48
+ /** Project neurons that hold it, the one written this session first. */
49
+ neurons: string[];
50
+ /** The entry id of the copy in each of `neurons`, same order. */
51
+ entry_ids: string[];
52
+ /** Lowest similarity in the group: 1 when every copy is the same text. */
53
+ similarity: number;
54
+ /** Sum of the copies' confirmations (each copy counts at least 1). */
55
+ confirmations: number;
56
+ }
57
+ /** Most promotion candidates consolidate reports. More is a backlog, not a nudge. */
58
+ export declare const MAX_PROMOTION_CANDIDATES = 5;
59
+ /**
60
+ * The same lesson living in two or more project neurons: the mark of
61
+ * something that is not about one project at all and belongs in a tech_ or
62
+ * process_ neuron where every project finds it.
63
+ *
64
+ * Generalises findNearDuplicates (one neuron) to many without making it
65
+ * quadratic: only the lessons of `seedIds` — the project neurons this session
66
+ * touched — are compared, and each only against the lessons that hold the
67
+ * same numbers and most of its distinctive words (inverted indexes built
68
+ * once). The bigram test then decides, as in learn. Exact copies (same
69
+ * normalised text) count at any length.
70
+ *
71
+ * Only the user's own lessons take part. A line that arrived from a shared
72
+ * space, the miner or anything that is not this machine's session is left
73
+ * out: promoting it would rewrite a third party's text as the user's own
74
+ * lesson, valid for every project, and drop the origin recall shows for it.
75
+ *
76
+ * Read-only and pure: it suggests, it never moves anything.
77
+ */
78
+ export declare function findPromotionCandidates(neurons: Neuron[], seedIds: Iterable<string>, max?: number): PromotionCandidate[];
20
79
  export type Indexer = (neuron: Neuron) => Promise<void> | void;
21
80
  /**
22
81
  * Called after a write so shared neurons can append a note to the team log.
@@ -256,6 +315,8 @@ export declare class Cortex {
256
315
  revised?: string;
257
316
  note?: string;
258
317
  } | null;
318
+ /** Exact-duplicate fact only: how many times the line has now been learned (2.7). */
319
+ confirmations?: number;
259
320
  }>;
260
321
  /**
261
322
  * Mark facts as no longer current.
@@ -1 +1 @@
1
- {"version":3,"file":"cortex.d.ts","sourceRoot":"","sources":["../../src/engine/cortex.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAMrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAkB,UAAU,EAAgC,MAAM,mBAAmB,CAAC;AAgBtH,MAAM,WAAW,YAAY;IAAG,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE;AACvF,eAAO,MAAM,QAAQ,QAAO,YAAuE,CAAC;AACpG;;;;;GAKG;AACH,eAAO,MAAM,YAAY;WAAkC,YAAY;cAAY,OAAO;EAAK,CAAC;AA6ChG,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,CACpB,QAAQ,EAAE,MAAM,EAChB,MAAM,EACF;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GACpG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,GAA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AAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAC7G,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QACpB,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IA8CF;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,KAAK,CAAC;QAClC,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;KACb,CAAC,CAAC;IA8CH;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIjC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;CAI/B"}
@@ -2,7 +2,9 @@
2
2
  // ─── CRBRO Cortex Engine ─────────────────────────────────────────
3
3
  // Neuron CRUD — create, read, update, list neurons
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.Cortex = exports.sessionScope = exports.newTally = void 0;
5
+ exports.Cortex = exports.MAX_PROMOTION_CANDIDATES = exports.sessionScope = exports.newTally = void 0;
6
+ exports.nearDuplicatesAmong = nearDuplicatesAmong;
7
+ exports.findPromotionCandidates = findPromotionCandidates;
6
8
  exports.unionNeuron = unionNeuron;
7
9
  exports.normalizeKeys = normalizeKeys;
8
10
  const node_async_hooks_1 = require("node:async_hooks");
@@ -22,7 +24,7 @@ const NEAR_DUP_THRESHOLD = 0.8;
22
24
  const NEAR_DUP_MIN_LENGTH = 60;
23
25
  /** Minimum similarity before we accept a near-miss as "the same topic". */
24
26
  const NAME_MATCH_THRESHOLD = 0.85;
25
- const newTally = () => ({ facts: 0, decisions: 0, topics: new Set() });
27
+ const newTally = () => ({ facts: 0, decisions: 0, topics: new Set(), witnessed: new Set() });
26
28
  exports.newTally = newTally;
27
29
  /**
28
30
  * The connection a request belongs to, carried through every await. Empty
@@ -73,6 +75,207 @@ function sameNumbers(a, b) {
73
75
  const nb = b.match(/\d+/g) || [];
74
76
  return na.length === nb.length && na.every((v, i) => v === nb[i]);
75
77
  }
78
+ /**
79
+ * Near-duplicates of `content` among `candidates`, best first: Dice ≥ 0.8 on
80
+ * lower-cased text, both sides at least NEAR_DUP_MIN_LENGTH characters. The
81
+ * one rule behind learn's near_duplicates warning (inside one neuron) and
82
+ * consolidate's promotion_candidates (across project neurons), so the two
83
+ * cannot disagree on what "almost the same line" means.
84
+ */
85
+ function nearDuplicatesAmong(content, candidates) {
86
+ if (content.length < NEAR_DUP_MIN_LENGTH)
87
+ return [];
88
+ const nuevo = content.toLowerCase();
89
+ const out = [];
90
+ for (const c of candidates) {
91
+ if (!c.text || c.text.length < NEAR_DUP_MIN_LENGTH)
92
+ continue;
93
+ // Dice over bigrams cannot reach the threshold when one side is much
94
+ // longer: 2·min/(a+b) bounds it. A free filter before the real count.
95
+ const otro = c.text.toLowerCase();
96
+ const a = nuevo.length, b = otro.length;
97
+ if ((2 * Math.min(a, b)) / (a + b) < NEAR_DUP_THRESHOLD)
98
+ continue;
99
+ const score = similarity(nuevo, otro);
100
+ if (score >= NEAR_DUP_THRESHOLD)
101
+ out.push({ id: c.id, similarity: Math.round(score * 100) / 100, text: c.text });
102
+ }
103
+ out.sort((x, y) => y.similarity - x.similarity);
104
+ return out;
105
+ }
106
+ /** Most promotion candidates consolidate reports. More is a backlog, not a nudge. */
107
+ exports.MAX_PROMOTION_CANDIDATES = 5;
108
+ /** Lessons of this session's project neurons compared against the rest. Bounds the cost of a sprawling session. */
109
+ const MAX_PROMOTION_SEEDS = 300;
110
+ /** Share of a lesson's distinctive words a copy must also hold before the bigram test runs. */
111
+ const PROMOTION_MIN_OVERLAP = 0.6;
112
+ /**
113
+ * A word found in more lessons than this says nothing about which lesson is
114
+ * a copy of which ("para", "proyecto"): it is not counted. The larger of an
115
+ * absolute floor and a share of the brain, so small brains keep every word.
116
+ */
117
+ const PROMOTION_COMMON_WORD = { min: 200, share: 0.05 };
118
+ /** Lower-cased, accents folded, whitespace collapsed: the "same text" test. */
119
+ function normLesson(text) {
120
+ return text.normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase().replace(/\s+/g, ' ').trim();
121
+ }
122
+ function lessonWords(norm) {
123
+ return [...new Set(norm.split(/[^a-z0-9_]+/).filter(w => w.length >= 3 && !/^\d+$/.test(w)))];
124
+ }
125
+ function lessonNumbers(norm) {
126
+ return [...new Set(norm.match(/\d+/g) || [])];
127
+ }
128
+ /**
129
+ * The same lesson living in two or more project neurons: the mark of
130
+ * something that is not about one project at all and belongs in a tech_ or
131
+ * process_ neuron where every project finds it.
132
+ *
133
+ * Generalises findNearDuplicates (one neuron) to many without making it
134
+ * quadratic: only the lessons of `seedIds` — the project neurons this session
135
+ * touched — are compared, and each only against the lessons that hold the
136
+ * same numbers and most of its distinctive words (inverted indexes built
137
+ * once). The bigram test then decides, as in learn. Exact copies (same
138
+ * normalised text) count at any length.
139
+ *
140
+ * Only the user's own lessons take part. A line that arrived from a shared
141
+ * space, the miner or anything that is not this machine's session is left
142
+ * out: promoting it would rewrite a third party's text as the user's own
143
+ * lesson, valid for every project, and drop the origin recall shows for it.
144
+ *
145
+ * Read-only and pure: it suggests, it never moves anything.
146
+ */
147
+ function findPromotionCandidates(neurons, seedIds, max = exports.MAX_PROMOTION_CANDIDATES) {
148
+ const semillasIds = new Set(seedIds);
149
+ if (semillasIds.size === 0)
150
+ return [];
151
+ const lecciones = [];
152
+ for (const n of neurons) {
153
+ if (!n || n.type !== 'project')
154
+ continue;
155
+ const retirada = (t) => !!n.entry_status?.[(0, ops_js_1.entryId)(t)];
156
+ for (const f of n.facts || []) {
157
+ if (!f?.text || f.status === 'superseded' || f.status === 'retracted')
158
+ continue;
159
+ if (f.source && f.source !== 'session')
160
+ continue; // not the user's own: never promoted
161
+ lecciones.push({ neuron: n.id, kind: 'fact', id: f.id || (0, hash_js_1.factId)(f.text), text: f.text, norm: normLesson(f.text), conf: Math.max(1, f.confirmations ?? 1) });
162
+ }
163
+ for (const [kind, lista] of [['pattern', n.patterns], ['error', n.errors]]) {
164
+ for (const t of lista || []) {
165
+ if (!t || retirada(t))
166
+ continue;
167
+ if (n.entry_source?.[(0, ops_js_1.entryId)(t)])
168
+ continue; // a teammate's or the miner's: never promoted
169
+ lecciones.push({ neuron: n.id, kind, id: (0, ops_js_1.entryId)(t), text: t, norm: normLesson(t), conf: 1 });
170
+ }
171
+ }
172
+ }
173
+ // Inverted indexes built once: word → lessons, number → lessons, text → lessons.
174
+ const porPalabra = new Map();
175
+ const porNumero = new Map();
176
+ const porTexto = new Map();
177
+ const palabras = [];
178
+ lecciones.forEach((l, i) => {
179
+ const ws = lessonWords(l.norm);
180
+ palabras.push(new Set(ws));
181
+ for (const w of ws)
182
+ (porPalabra.get(w) || porPalabra.set(w, []).get(w)).push(i);
183
+ for (const n of lessonNumbers(l.norm))
184
+ (porNumero.get(n) || porNumero.set(n, []).get(n)).push(i);
185
+ (porTexto.get(l.norm) || porTexto.set(l.norm, []).get(l.norm)).push(i);
186
+ });
187
+ const comun = Math.max(PROMOTION_COMMON_WORD.min, Math.ceil(lecciones.length * PROMOTION_COMMON_WORD.share));
188
+ /**
189
+ * The lessons worth a bigram test against seed `s`. Two filters, both
190
+ * cheaper than one Dice count and both implied by what follows it:
191
+ * - numbers: a near copy must carry the same numbers (the guard below), so
192
+ * it must hold every number the seed holds — an intersection of postings;
193
+ * - words: it must share most of the seed's distinctive words.
194
+ * Templated text ("module 155 uses table 5…" ×24,000) is exactly where a
195
+ * plain rare-word probe degrades into comparing against everything.
196
+ */
197
+ const candidatosDe = (s) => {
198
+ const semilla = lecciones[s];
199
+ const nums = lessonNumbers(semilla.norm);
200
+ const distintivas = [...palabras[s]].filter(w => (porPalabra.get(w)?.length ?? 0) <= comun);
201
+ // Nothing to tell copies apart by — every word is everywhere — means
202
+ // exact copies only, even when it holds a number: "2026" alone would
203
+ // otherwise send it against every lesson written this year.
204
+ if (distintivas.length === 0)
205
+ return [];
206
+ const minimo = Math.ceil(distintivas.length * PROMOTION_MIN_OVERLAP);
207
+ let base = null;
208
+ if (nums.length) {
209
+ const listas = nums.map(n => porNumero.get(n) || []).sort((a, b) => a.length - b.length);
210
+ let inter = new Set(listas[0]);
211
+ for (const l of listas.slice(1)) {
212
+ const otra = new Set(l);
213
+ inter = new Set([...inter].filter(i => otra.has(i)));
214
+ }
215
+ base = [...inter];
216
+ }
217
+ const fuera = (i) => lecciones[i].neuron === semilla.neuron || lecciones[i].norm === semilla.norm;
218
+ if (base) {
219
+ return base.filter(i => !fuera(i) && distintivas.reduce((n, w) => n + (palabras[i].has(w) ? 1 : 0), 0) >= minimo);
220
+ }
221
+ const cuenta = new Map();
222
+ for (const w of distintivas)
223
+ for (const i of porPalabra.get(w))
224
+ cuenta.set(i, (cuenta.get(i) || 0) + 1);
225
+ return [...cuenta].filter(([i, n]) => n >= minimo && !fuera(i)).map(([i]) => i);
226
+ };
227
+ const semillas = lecciones.map((_, i) => i).filter(i => semillasIds.has(lecciones[i].neuron)).slice(0, MAX_PROMOTION_SEEDS);
228
+ const usadas = new Set();
229
+ const grupos = [];
230
+ for (const s of semillas) {
231
+ if (usadas.has(s))
232
+ continue;
233
+ const semilla = lecciones[s];
234
+ // Best copy per OTHER project neuron.
235
+ const mejor = new Map();
236
+ const anotar = (i, sim) => {
237
+ const l = lecciones[i];
238
+ if (l.neuron === semilla.neuron)
239
+ return;
240
+ const prev = mejor.get(l.neuron);
241
+ if (!prev || sim > prev.sim)
242
+ mejor.set(l.neuron, { i, sim });
243
+ };
244
+ for (const i of porTexto.get(semilla.norm) || [])
245
+ anotar(i, 1);
246
+ if (semilla.text.length >= NEAR_DUP_MIN_LENGTH) {
247
+ // Across projects, a copy that disagrees on a number is another lesson
248
+ // ("the 2.5 index" vs "the 2.6 index"): the same guard name matching uses.
249
+ const pool = candidatosDe(s)
250
+ .filter(i => sameNumbers(semilla.text, lecciones[i].text))
251
+ .map(i => ({ id: String(i), text: lecciones[i].text }));
252
+ for (const hit of nearDuplicatesAmong(semilla.text, pool))
253
+ anotar(Number(hit.id), hit.similarity);
254
+ }
255
+ if (mejor.size === 0)
256
+ continue;
257
+ const miembros = [s, ...[...mejor.values()].map(m => m.i)];
258
+ for (const m of miembros)
259
+ usadas.add(m);
260
+ grupos.push({ miembros, similarity: Math.min(...[...mejor.values()].map(m => m.sim)) });
261
+ }
262
+ return grupos
263
+ .map(g => {
264
+ const ls = g.miembros.map(i => lecciones[i]);
265
+ const rep = [...ls].sort((a, b) => (b.conf - a.conf) || (b.text.length - a.text.length))[0];
266
+ return {
267
+ kind: rep.kind,
268
+ text: rep.text,
269
+ neurons: ls.map(l => l.neuron),
270
+ entry_ids: ls.map(l => l.id),
271
+ similarity: g.similarity,
272
+ confirmations: ls.reduce((n, l) => n + l.conf, 0),
273
+ };
274
+ })
275
+ .sort((a, b) => (b.neurons.length - a.neurons.length) || (b.confirmations - a.confirmations)
276
+ || (b.similarity - a.similarity) || (a.text < b.text ? -1 : 1))
277
+ .slice(0, max);
278
+ }
76
279
  /** Where a fact's lifecycle stands, for "take the furthest-along status". */
77
280
  function statusRank(status) {
78
281
  return status === 'retracted' ? 2 : status === 'superseded' ? 1 : 0;
@@ -147,6 +350,11 @@ function unionNeuron(target, source) {
147
350
  hit.superseded_by = sf.superseded_by;
148
351
  }
149
352
  hit.added = earliestOf(hit.added, sf.added);
353
+ // Two copies of one line: the better-witnessed count stands. Summing
354
+ // would count twice the sessions both copies may have seen.
355
+ const conf = Math.max(hit.confirmations ?? 1, sf.confirmations ?? 1);
356
+ if (conf > 1)
357
+ hit.confirmations = conf;
150
358
  const keys = normalizeKeys([...(hit.keys || []), ...(sf.keys || [])]);
151
359
  if (keys.length)
152
360
  hit.keys = keys;
@@ -227,6 +435,15 @@ function unionNeuron(target, source) {
227
435
  neuron.entry_status = estadosVivos;
228
436
  else
229
437
  delete neuron.entry_status;
438
+ const origenes = { ...(source.entry_source || {}), ...(target.entry_source || {}) };
439
+ const origenesVivos = {};
440
+ for (const k of Object.keys(origenes).sort())
441
+ if (vivos.has(k))
442
+ origenesVivos[k] = origenes[k];
443
+ if (Object.keys(origenesVivos).length)
444
+ neuron.entry_source = origenesVivos;
445
+ else
446
+ delete neuron.entry_source;
230
447
  // ── Map: the target's if it has one, else the source's ──
231
448
  if (target.map)
232
449
  neuron.map = { ...target.map };
@@ -532,6 +749,7 @@ class Cortex {
532
749
  let emitir = null;
533
750
  let duplicate = false;
534
751
  let updatedInPlace = false;
752
+ let confirmations;
535
753
  let skippedRetired = null;
536
754
  // A retired decision, pattern, error or debt must not come back through
537
755
  // learn: the sidecar says so, and the index already hides it.
@@ -553,6 +771,21 @@ class Cortex {
553
771
  n.entry_dates = {};
554
772
  n.entry_dates[(0, ops_js_1.entryId)(text)] = (0, fs_js_1.now)();
555
773
  };
774
+ // Where a non-fact entry came from, when it is not this session (2.7):
775
+ // the sidecar twin of Fact.source. A line written here clears a stale
776
+ // mark, so a teammate's pattern forgotten and re-learned reads as yours.
777
+ const origen = (n, text) => {
778
+ const k = (0, ops_js_1.entryId)(text);
779
+ const src = options?.source;
780
+ if (src && src !== 'session' && src !== 'manual') {
781
+ (n.entry_source ||= {})[k] = src;
782
+ }
783
+ else if (n.entry_source?.[k]) {
784
+ delete n.entry_source[k];
785
+ if (Object.keys(n.entry_source).length === 0)
786
+ delete n.entry_source;
787
+ }
788
+ };
556
789
  const actualizada = await (0, fs_js_1.updateJSON)(this.brain.paths.neuron(neuron.id), current => {
557
790
  const n = current || neuron;
558
791
  switch (type) {
@@ -577,6 +810,17 @@ class Cortex {
577
810
  // may be edited in place. The indexer re-indexes the neuron
578
811
  // afterwards, keys included.
579
812
  duplicate = true;
813
+ // The same line from another session is a second witness (2.7).
814
+ // The same session saying it again is not (a retry, the re-save
815
+ // after a compaction), and neither is the miner re-reading a file.
816
+ const testigo = `${n.id}|${existente.id || (0, hash_js_1.factId)(existente.text)}`;
817
+ const vistos = (this.tally.witnessed ??= new Set());
818
+ if (options?.source !== 'miner' && !vistos.has(testigo)) {
819
+ existente.confirmations = (existente.confirmations ?? 1) + 1;
820
+ }
821
+ if (options?.source !== 'miner')
822
+ vistos.add(testigo);
823
+ confirmations = existente.confirmations ?? 1;
580
824
  let cambiado = false;
581
825
  if (options?.confidence !== undefined && options.confidence !== existente.confidence) {
582
826
  existente.confidence = options.confidence;
@@ -633,6 +877,8 @@ class Cortex {
633
877
  if (keys.length)
634
878
  fact.keys = keys;
635
879
  n.facts.push(fact);
880
+ if (fact.source !== 'miner')
881
+ (this.tally.witnessed ??= new Set()).add(`${n.id}|${id}`);
636
882
  this.tally.facts++;
637
883
  this.tally.topics.add(n.id);
638
884
  emitir = { kind: 'fact', text: content, fid: id,
@@ -649,6 +895,7 @@ class Cortex {
649
895
  rationale: options?.rationale || '',
650
896
  };
651
897
  n.decisions.push(decision);
898
+ origen(n, content);
652
899
  this.tally.decisions++;
653
900
  this.tally.topics.add(n.id);
654
901
  emitir = { kind: 'decision', text: content,
@@ -661,6 +908,7 @@ class Cortex {
661
908
  if (!n.patterns.includes(content)) {
662
909
  n.patterns.push(content);
663
910
  fechar(n, content);
911
+ origen(n, content);
664
912
  emitir = { kind: 'pattern', text: content, at: (0, fs_js_1.now)() };
665
913
  }
666
914
  break;
@@ -680,6 +928,7 @@ class Cortex {
680
928
  if (!n.errors.includes(content)) {
681
929
  n.errors.push(content);
682
930
  fechar(n, content);
931
+ origen(n, content);
683
932
  this.tally.topics.add(n.id);
684
933
  emitir = { kind: 'error', text: content, at: (0, fs_js_1.now)() };
685
934
  }
@@ -693,6 +942,7 @@ class Cortex {
693
942
  if (!n.debts.includes(content)) {
694
943
  n.debts.push(content);
695
944
  fechar(n, content);
945
+ origen(n, content);
696
946
  this.tally.topics.add(n.id);
697
947
  emitir = { kind: 'debt', text: content, at: (0, fs_js_1.now)() };
698
948
  }
@@ -724,6 +974,7 @@ class Cortex {
724
974
  neuron: final, action, superseded, supersedes_unmatched: supersedesUnmatched,
725
975
  near_duplicates: nearDuplicates, redacted: limpio.found,
726
976
  duplicate, updated_in_place: updatedInPlace, skipped_retired: null,
977
+ ...(confirmations !== undefined ? { confirmations } : {}),
727
978
  };
728
979
  }
729
980
  /**
@@ -784,28 +1035,12 @@ class Cortex {
784
1035
  * telling, never the engine merging on its own.
785
1036
  */
786
1037
  findNearDuplicates(neuron, content) {
787
- if (content.length < NEAR_DUP_MIN_LENGTH)
788
- return [];
789
- const nuevo = content.toLowerCase();
790
- const out = [];
791
- for (const fact of neuron.facts) {
792
- if (fact.status === 'superseded' || fact.status === 'retracted')
793
- continue;
794
- if (!fact.text || fact.text.length < NEAR_DUP_MIN_LENGTH)
795
- continue;
796
- if (fact.text === content)
797
- continue; // the new fact itself, already pushed
798
- const score = similarity(nuevo, fact.text.toLowerCase());
799
- if (score >= NEAR_DUP_THRESHOLD) {
800
- out.push({
801
- id: fact.id || (0, hash_js_1.factId)(fact.text),
802
- similarity: Math.round(score * 100) / 100,
803
- preview: fact.text.slice(0, 120),
804
- });
805
- }
806
- }
807
- out.sort((a, b) => b.similarity - a.similarity);
808
- return out.slice(0, 5);
1038
+ const activos = neuron.facts
1039
+ .filter(f => f.status !== 'superseded' && f.status !== 'retracted' && f.text && f.text !== content)
1040
+ .map(f => ({ id: f.id || (0, hash_js_1.factId)(f.text), text: f.text }));
1041
+ return nearDuplicatesAmong(content, activos)
1042
+ .slice(0, 5)
1043
+ .map(({ id, similarity: s, text }) => ({ id, similarity: s, preview: text.slice(0, 120) }));
809
1044
  }
810
1045
  /**
811
1046
  * Flip matching facts to a non-active status.
@@ -1203,6 +1438,17 @@ class Cortex {
1203
1438
  if (Object.keys(current.entry_status).length === 0)
1204
1439
  delete current.entry_status;
1205
1440
  }
1441
+ // And for provenance: a forgotten teammate line that comes back through
1442
+ // a sync replay must be labelled by that replay, not by a stale key.
1443
+ if (current.entry_source) {
1444
+ const vivos = liveEntryKeys(current);
1445
+ for (const k of Object.keys(current.entry_source)) {
1446
+ if (!vivos.has(k))
1447
+ delete current.entry_source[k];
1448
+ }
1449
+ if (Object.keys(current.entry_source).length === 0)
1450
+ delete current.entry_source;
1451
+ }
1206
1452
  current.last_accessed = (0, fs_js_1.now)();
1207
1453
  return current;
1208
1454
  });