crbro-memory 1.15.0 → 2.0.0
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/README.md +70 -41
- package/bin/crbro.mjs +84 -41
- package/dist/engine/brain.js +1 -1
- package/dist/engine/brain.js.map +1 -1
- package/dist/engine/cortex.d.ts +189 -1
- package/dist/engine/cortex.d.ts.map +1 -1
- package/dist/engine/cortex.js +639 -17
- package/dist/engine/cortex.js.map +1 -1
- package/dist/engine/hippocampus.d.ts +27 -1
- package/dist/engine/hippocampus.d.ts.map +1 -1
- package/dist/engine/hippocampus.js +51 -2
- package/dist/engine/hippocampus.js.map +1 -1
- package/dist/engine/maintenance.d.ts +49 -2
- package/dist/engine/maintenance.d.ts.map +1 -1
- package/dist/engine/maintenance.js +301 -28
- package/dist/engine/maintenance.js.map +1 -1
- package/dist/engine/prefrontal.d.ts +25 -7
- package/dist/engine/prefrontal.d.ts.map +1 -1
- package/dist/engine/prefrontal.js +55 -27
- package/dist/engine/prefrontal.js.map +1 -1
- package/dist/engine/synapses.d.ts +38 -0
- package/dist/engine/synapses.d.ts.map +1 -1
- package/dist/engine/synapses.js +116 -11
- package/dist/engine/synapses.js.map +1 -1
- package/dist/search/index.d.ts +18 -2
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +54 -10
- package/dist/search/index.js.map +1 -1
- package/dist/search/semantic.d.ts +8 -0
- package/dist/search/semantic.d.ts.map +1 -1
- package/dist/search/semantic.js +34 -12
- package/dist/search/semantic.js.map +1 -1
- package/dist/server.d.ts +7 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +764 -827
- package/dist/server.js.map +1 -1
- package/dist/sync/materialize.d.ts +1 -1
- package/dist/sync/materialize.d.ts.map +1 -1
- package/dist/sync/materialize.js +40 -3
- package/dist/sync/materialize.js.map +1 -1
- package/dist/sync/ops.d.ts +9 -4
- package/dist/sync/ops.d.ts.map +1 -1
- package/dist/sync/ops.js.map +1 -1
- package/dist/sync/space.d.ts +27 -0
- package/dist/sync/space.d.ts.map +1 -1
- package/dist/sync/space.js +113 -1
- package/dist/sync/space.js.map +1 -1
- package/dist/types/index.d.ts +29 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +56 -54
|
@@ -41,11 +41,29 @@ class Prefrontal {
|
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Update the active context.
|
|
44
|
+
*
|
|
45
|
+
* A call with nothing to change is a read: it returns the context and does
|
|
46
|
+
* NOT touch the file. It used to rewrite last_updated on every read, so the
|
|
47
|
+
* timestamp said "changed just now" about a context nobody had changed.
|
|
44
48
|
*/
|
|
45
49
|
async updateContext(updates) {
|
|
46
50
|
const ctx = await this.getContext();
|
|
47
|
-
const
|
|
51
|
+
const hayCambio = updates.clear === true ||
|
|
52
|
+
updates.set_topics !== undefined ||
|
|
53
|
+
(updates.add_pending !== undefined && updates.add_pending !== '') ||
|
|
54
|
+
(updates.resolve_pending !== undefined && updates.resolve_pending !== '') ||
|
|
55
|
+
(updates.discard_pending !== undefined && updates.discard_pending !== '');
|
|
56
|
+
if (!hayCambio) {
|
|
57
|
+
return { ...ctx, resolved: [], discarded: [], written: false };
|
|
58
|
+
}
|
|
59
|
+
if (updates.clear) {
|
|
60
|
+
ctx.active_topics = [];
|
|
61
|
+
ctx.pending_tasks = [];
|
|
62
|
+
ctx.recently_closed = [];
|
|
63
|
+
}
|
|
64
|
+
let tasks = ctx.pending_tasks.map(toTask);
|
|
48
65
|
let resolved = [];
|
|
66
|
+
let discarded = [];
|
|
49
67
|
if (updates.set_topics) {
|
|
50
68
|
ctx.active_topics = updates.set_topics;
|
|
51
69
|
}
|
|
@@ -56,27 +74,44 @@ class Prefrontal {
|
|
|
56
74
|
tasks.push({ id, text, added: (0, fs_js_1.now)() });
|
|
57
75
|
}
|
|
58
76
|
}
|
|
59
|
-
|
|
60
|
-
|
|
77
|
+
// Id, exact text, or a case-insensitive substring of at least 8 chars in
|
|
78
|
+
// either direction — the same predicate for resolving and discarding.
|
|
79
|
+
const matcher = (needleRaw) => {
|
|
80
|
+
const needle = needleRaw.trim();
|
|
61
81
|
const lower = needle.toLowerCase();
|
|
62
|
-
|
|
82
|
+
return (t) => t.id === needle ||
|
|
63
83
|
t.text === needle ||
|
|
64
84
|
(lower.length >= 8 &&
|
|
65
85
|
(t.text.toLowerCase().includes(lower) || lower.includes(t.text.toLowerCase())));
|
|
86
|
+
};
|
|
87
|
+
if (updates.resolve_pending) {
|
|
88
|
+
const hit = matcher(updates.resolve_pending);
|
|
66
89
|
resolved = tasks.filter(hit).map(t => ({ ...t, closed: (0, fs_js_1.now)() }));
|
|
67
|
-
|
|
90
|
+
tasks = tasks.filter(t => !hit(t));
|
|
68
91
|
if (resolved.length > 0) {
|
|
69
92
|
ctx.recently_closed = [...resolved, ...(ctx.recently_closed || [])]
|
|
70
93
|
.slice(0, RECENTLY_CLOSED_CAP);
|
|
71
94
|
}
|
|
72
|
-
ctx.pending_tasks = keep;
|
|
73
95
|
}
|
|
74
|
-
|
|
75
|
-
|
|
96
|
+
if (updates.discard_pending) {
|
|
97
|
+
const hit = matcher(updates.discard_pending);
|
|
98
|
+
discarded = tasks.filter(hit);
|
|
99
|
+
tasks = tasks.filter(t => !hit(t));
|
|
76
100
|
}
|
|
101
|
+
ctx.pending_tasks = tasks;
|
|
102
|
+
ctx.last_updated = (0, fs_js_1.now)();
|
|
103
|
+
await (0, fs_js_1.writeJSON)(this.brain.paths.activeContext(), ctx);
|
|
104
|
+
return { ...ctx, resolved, discarded, written: true };
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Record which session was logged last. Nothing else in the context moves.
|
|
108
|
+
* Before this, nothing ever wrote last_session, so boot reported null forever.
|
|
109
|
+
*/
|
|
110
|
+
async setLastSession(sessionId) {
|
|
111
|
+
const ctx = await this.getContext();
|
|
112
|
+
ctx.last_session = sessionId;
|
|
77
113
|
ctx.last_updated = (0, fs_js_1.now)();
|
|
78
114
|
await (0, fs_js_1.writeJSON)(this.brain.paths.activeContext(), ctx);
|
|
79
|
-
return { ...ctx, resolved };
|
|
80
115
|
}
|
|
81
116
|
// ─── Hot Topics ─────────────────────────────────────────────────
|
|
82
117
|
/**
|
|
@@ -94,9 +129,16 @@ class Prefrontal {
|
|
|
94
129
|
}
|
|
95
130
|
// ─── Global Map ────────────────────────────────────────────────
|
|
96
131
|
/**
|
|
97
|
-
*
|
|
132
|
+
* The global map — clusters of related neurons and bridges between domains.
|
|
133
|
+
*
|
|
134
|
+
* Computed live from the cortex and the connections on every call, and
|
|
135
|
+
* never written to disk. The cached global_map.json it replaces was the one
|
|
136
|
+
* file a maintenance dry run still rewrote, and it went stale between
|
|
137
|
+
* rebuilds; a map that is always current costs one pass over the neurons.
|
|
138
|
+
* `last_rebuilt` keeps its name so the GlobalMap shape does not change: it
|
|
139
|
+
* is the moment this map was computed.
|
|
98
140
|
*/
|
|
99
|
-
async
|
|
141
|
+
async getGlobalMap() {
|
|
100
142
|
const ids = await (0, fs_js_1.listJSONFiles)(this.brain.paths.cortex);
|
|
101
143
|
const neurons = [];
|
|
102
144
|
for (const id of ids) {
|
|
@@ -129,7 +171,7 @@ class Prefrontal {
|
|
|
129
171
|
// Find bridges — neurons that connect different domains
|
|
130
172
|
const bridges = [];
|
|
131
173
|
for (const neuron of neurons) {
|
|
132
|
-
if (neuron.connections.length === 0)
|
|
174
|
+
if (!neuron.connections || neuron.connections.length === 0)
|
|
133
175
|
continue;
|
|
134
176
|
// Get connected neurons' domains
|
|
135
177
|
const connectedDomains = new Set();
|
|
@@ -160,25 +202,11 @@ class Prefrontal {
|
|
|
160
202
|
}
|
|
161
203
|
}
|
|
162
204
|
}
|
|
163
|
-
|
|
205
|
+
return {
|
|
164
206
|
last_rebuilt: (0, fs_js_1.now)(),
|
|
165
207
|
clusters: clusters.sort((a, b) => b.heat - a.heat),
|
|
166
208
|
bridges,
|
|
167
209
|
};
|
|
168
|
-
await (0, fs_js_1.writeJSON)(this.brain.paths.globalMap(), globalMap);
|
|
169
|
-
return globalMap;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Get the current global map (read from cache, or build if missing).
|
|
173
|
-
*/
|
|
174
|
-
async getGlobalMap(rebuild = false) {
|
|
175
|
-
if (rebuild) {
|
|
176
|
-
return this.buildGlobalMap();
|
|
177
|
-
}
|
|
178
|
-
const existing = await (0, fs_js_1.readJSON)(this.brain.paths.globalMap());
|
|
179
|
-
if (existing)
|
|
180
|
-
return existing;
|
|
181
|
-
return this.buildGlobalMap();
|
|
182
210
|
}
|
|
183
211
|
}
|
|
184
212
|
exports.Prefrontal = Prefrontal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefrontal.js","sourceRoot":"","sources":["../../src/engine/prefrontal.ts"],"names":[],"mappings":";AAAA,oEAAoE;AACpE,oEAAoE;;;AAEpE,0CAAyE;AACzE,8CAA6C;AAI7C,4DAA4D;AAC5D,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,8DAA8D;AAC9D,SAAS,MAAM,CAAC,KAA2B;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,EAAE,EAAE,EAAE,IAAA,mBAAS,EAAC,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAa,UAAU;IACD;IAApB,YAAoB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;IAAG,CAAC;IAEpC,kEAAkE;IAElE;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,MAAM,GAAG,GAAG,MAAM,IAAA,gBAAQ,EAAgB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC;QAC5E,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO;gBACL,YAAY,EAAE,EAAE;gBAChB,aAAa,EAAE,EAAE;gBACjB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xC,CAAC,CAAC;4BACF,OAAO,EAAE,qBAAqB,MAAM,CAAC,IAAI,EAAE;yBAC5C,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO;YACL,YAAY,EAAE,IAAA,WAAG,GAAE;YACnB,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;YAClD,OAAO;SACR,CAAC;IACJ,CAAC;CACF;AA7OD,gCA6OC"}
|
|
@@ -11,10 +11,48 @@ export declare class Synapses {
|
|
|
11
11
|
initialStrength?: number;
|
|
12
12
|
/** On strengthen, keep whatever context is already there instead of replacing it. */
|
|
13
13
|
keepExistingContext?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Absolute strength 0..1, applied on create AND on strengthen instead
|
|
16
|
+
* of the +0.1 rule. The caller says how strong the link is; the engine
|
|
17
|
+
* stops guessing.
|
|
18
|
+
*/
|
|
19
|
+
strength?: number;
|
|
14
20
|
}): Promise<{
|
|
15
21
|
synapse: Synapse;
|
|
16
22
|
action: 'created' | 'strengthened';
|
|
17
23
|
}>;
|
|
24
|
+
/**
|
|
25
|
+
* Remove one synapse and unlink both neurons. Absent → removed:false, no
|
|
26
|
+
* error: "disconnect what is not connected" is a no-op, not a failure.
|
|
27
|
+
*/
|
|
28
|
+
disconnect(fromId: string, toId: string): Promise<{
|
|
29
|
+
synapse_id: string;
|
|
30
|
+
removed: boolean;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Set the strength of an EXISTING synapse without touching anything else:
|
|
34
|
+
* no co-access bump, no type or context change. Null when there is no such
|
|
35
|
+
* synapse — this never creates one.
|
|
36
|
+
*/
|
|
37
|
+
setStrength(fromId: string, toId: string, strength: number): Promise<Synapse | null>;
|
|
38
|
+
/**
|
|
39
|
+
* Remove every synapse touching a neuron. Returns how many went. Used when
|
|
40
|
+
* a whole neuron is forgotten, after the Cortex has deleted its file.
|
|
41
|
+
*/
|
|
42
|
+
removeAllFor(neuronId: string): Promise<number>;
|
|
43
|
+
/**
|
|
44
|
+
* Move every synapse of `fromId` onto `intoId`, for a neuron merge.
|
|
45
|
+
* - the other end is `intoId` itself → dropped (it would be a self loop);
|
|
46
|
+
* - `intoId` already links to the other end → merged: max strength, summed
|
|
47
|
+
* co-access, later last_co_access, the existing context kept;
|
|
48
|
+
* - otherwise the synapse is rewritten under its new id and nodes (moved).
|
|
49
|
+
* Neuron connection lists follow. Manifest goes down by merged + dropped.
|
|
50
|
+
*/
|
|
51
|
+
rewire(fromId: string, intoId: string): Promise<{
|
|
52
|
+
moved: number;
|
|
53
|
+
merged: number;
|
|
54
|
+
dropped: number;
|
|
55
|
+
}>;
|
|
18
56
|
/**
|
|
19
57
|
* Get all connections for a neuron.
|
|
20
58
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synapses.d.ts","sourceRoot":"","sources":["../../src/engine/synapses.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAU,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"synapses.d.ts","sourceRoot":"","sources":["../../src/engine/synapses.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAU,MAAM,mBAAmB,CAAC;AAQtE,qBAAa,QAAQ;IACP,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,KAAK;IAEhC;;OAEG;IACG,OAAO,CACX,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,WAAW,EACjB,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;QACR,uFAAuF;QACvF,e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KhE;;;OAGG;IACG,KAAK,CAAC,cAAc,GAAE,MAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IA+B3D;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;YAOhB,qBAAqB;YAUrB,0BAA0B;CAOzC"}
|
package/dist/engine/synapses.js
CHANGED
|
@@ -5,6 +5,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
exports.Synapses = void 0;
|
|
6
6
|
const fs_js_1 = require("../utils/fs.js");
|
|
7
7
|
const ids_js_1 = require("../utils/ids.js");
|
|
8
|
+
/** Strength is stored in [0, 1] with three decimals, like decay writes it. */
|
|
9
|
+
function clampStrength(value) {
|
|
10
|
+
const v = Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : 0;
|
|
11
|
+
return Math.round(v * 1000) / 1000;
|
|
12
|
+
}
|
|
8
13
|
class Synapses {
|
|
9
14
|
brain;
|
|
10
15
|
constructor(brain) {
|
|
@@ -17,9 +22,10 @@ class Synapses {
|
|
|
17
22
|
const id = (0, ids_js_1.synapseId)(fromId, toId);
|
|
18
23
|
let synapse = await (0, fs_js_1.readJSON)(this.brain.paths.synapse(id));
|
|
19
24
|
let action;
|
|
25
|
+
const absoluta = typeof options?.strength === 'number' ? clampStrength(options.strength) : undefined;
|
|
20
26
|
if (synapse) {
|
|
21
27
|
// Strengthen existing synapse
|
|
22
|
-
synapse.strength = Math.min(1.0, synapse.strength + 0.1);
|
|
28
|
+
synapse.strength = absoluta !== undefined ? absoluta : Math.min(1.0, synapse.strength + 0.1);
|
|
23
29
|
synapse.co_access_count += 1;
|
|
24
30
|
synapse.last_co_access = (0, fs_js_1.now)();
|
|
25
31
|
if (context && !(options?.keepExistingContext && synapse.context)) {
|
|
@@ -32,7 +38,7 @@ class Synapses {
|
|
|
32
38
|
synapse = {
|
|
33
39
|
id,
|
|
34
40
|
nodes: [fromId, toId],
|
|
35
|
-
strength: options?.initialStrength ?? 0.5,
|
|
41
|
+
strength: absoluta !== undefined ? absoluta : (options?.initialStrength ?? 0.5),
|
|
36
42
|
type,
|
|
37
43
|
context: context || '',
|
|
38
44
|
co_access_count: 1,
|
|
@@ -49,6 +55,110 @@ class Synapses {
|
|
|
49
55
|
await this.addConnectionToNeuron(toId, fromId);
|
|
50
56
|
return { synapse, action };
|
|
51
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Remove one synapse and unlink both neurons. Absent → removed:false, no
|
|
60
|
+
* error: "disconnect what is not connected" is a no-op, not a failure.
|
|
61
|
+
*/
|
|
62
|
+
async disconnect(fromId, toId) {
|
|
63
|
+
const id = (0, ids_js_1.synapseId)(fromId, toId);
|
|
64
|
+
const synapse = await (0, fs_js_1.readJSON)(this.brain.paths.synapse(id));
|
|
65
|
+
if (!synapse)
|
|
66
|
+
return { synapse_id: id, removed: false };
|
|
67
|
+
await (0, fs_js_1.deleteJSON)(this.brain.paths.synapse(id));
|
|
68
|
+
// Remove from neuron connection lists. Use the nodes the file recorded,
|
|
69
|
+
// not the ids the caller passed: the id is order-free and prefix-free, so
|
|
70
|
+
// the caller's spelling may differ from what the neurons hold.
|
|
71
|
+
await this.removeConnectionFromNeuron(synapse.nodes[0], synapse.nodes[1]);
|
|
72
|
+
await this.removeConnectionFromNeuron(synapse.nodes[1], synapse.nodes[0]);
|
|
73
|
+
const manifest = await this.brain.getManifest();
|
|
74
|
+
await this.brain.updateManifest({ total_synapses: Math.max(0, manifest.total_synapses - 1) });
|
|
75
|
+
return { synapse_id: id, removed: true };
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Set the strength of an EXISTING synapse without touching anything else:
|
|
79
|
+
* no co-access bump, no type or context change. Null when there is no such
|
|
80
|
+
* synapse — this never creates one.
|
|
81
|
+
*/
|
|
82
|
+
async setStrength(fromId, toId, strength) {
|
|
83
|
+
const id = (0, ids_js_1.synapseId)(fromId, toId);
|
|
84
|
+
const synapse = await (0, fs_js_1.readJSON)(this.brain.paths.synapse(id));
|
|
85
|
+
if (!synapse)
|
|
86
|
+
return null;
|
|
87
|
+
synapse.strength = clampStrength(strength);
|
|
88
|
+
await (0, fs_js_1.writeJSON)(this.brain.paths.synapse(id), synapse);
|
|
89
|
+
return synapse;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Remove every synapse touching a neuron. Returns how many went. Used when
|
|
93
|
+
* a whole neuron is forgotten, after the Cortex has deleted its file.
|
|
94
|
+
*/
|
|
95
|
+
async removeAllFor(neuronId) {
|
|
96
|
+
let removed = 0;
|
|
97
|
+
for (const id of await (0, fs_js_1.listJSONFiles)(this.brain.paths.synapses)) {
|
|
98
|
+
const synapse = await (0, fs_js_1.readJSON)(this.brain.paths.synapse(id));
|
|
99
|
+
if (!synapse || !synapse.nodes.includes(neuronId))
|
|
100
|
+
continue;
|
|
101
|
+
const r = await this.disconnect(synapse.nodes[0], synapse.nodes[1]);
|
|
102
|
+
if (r.removed)
|
|
103
|
+
removed++;
|
|
104
|
+
}
|
|
105
|
+
return removed;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Move every synapse of `fromId` onto `intoId`, for a neuron merge.
|
|
109
|
+
* - the other end is `intoId` itself → dropped (it would be a self loop);
|
|
110
|
+
* - `intoId` already links to the other end → merged: max strength, summed
|
|
111
|
+
* co-access, later last_co_access, the existing context kept;
|
|
112
|
+
* - otherwise the synapse is rewritten under its new id and nodes (moved).
|
|
113
|
+
* Neuron connection lists follow. Manifest goes down by merged + dropped.
|
|
114
|
+
*/
|
|
115
|
+
async rewire(fromId, intoId) {
|
|
116
|
+
const out = { moved: 0, merged: 0, dropped: 0 };
|
|
117
|
+
if (fromId === intoId)
|
|
118
|
+
return out;
|
|
119
|
+
for (const id of await (0, fs_js_1.listJSONFiles)(this.brain.paths.synapses)) {
|
|
120
|
+
const synapse = await (0, fs_js_1.readJSON)(this.brain.paths.synapse(id));
|
|
121
|
+
if (!synapse || !synapse.nodes.includes(fromId))
|
|
122
|
+
continue;
|
|
123
|
+
const other = synapse.nodes[0] === fromId ? synapse.nodes[1] : synapse.nodes[0];
|
|
124
|
+
if (other === intoId) {
|
|
125
|
+
await (0, fs_js_1.deleteJSON)(this.brain.paths.synapse(id));
|
|
126
|
+
await this.removeConnectionFromNeuron(intoId, fromId);
|
|
127
|
+
out.dropped++;
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
const nuevoId = (0, ids_js_1.synapseId)(intoId, other);
|
|
131
|
+
// Ids drop the type prefix, so two neurons differing only by prefix
|
|
132
|
+
// yield the same synapse id: then the file stays, only the nodes move.
|
|
133
|
+
const existente = nuevoId === id ? null : await (0, fs_js_1.readJSON)(this.brain.paths.synapse(nuevoId));
|
|
134
|
+
if (existente) {
|
|
135
|
+
existente.strength = clampStrength(Math.max(existente.strength, synapse.strength));
|
|
136
|
+
existente.co_access_count = (existente.co_access_count || 0) + (synapse.co_access_count || 0);
|
|
137
|
+
if ((synapse.last_co_access || '') > (existente.last_co_access || '')) {
|
|
138
|
+
existente.last_co_access = synapse.last_co_access;
|
|
139
|
+
}
|
|
140
|
+
await (0, fs_js_1.writeJSON)(this.brain.paths.synapse(nuevoId), existente);
|
|
141
|
+
await (0, fs_js_1.deleteJSON)(this.brain.paths.synapse(id));
|
|
142
|
+
out.merged++;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
const movido = { ...synapse, id: nuevoId, nodes: [intoId, other] };
|
|
146
|
+
await (0, fs_js_1.writeJSON)(this.brain.paths.synapse(nuevoId), movido);
|
|
147
|
+
if (nuevoId !== id)
|
|
148
|
+
await (0, fs_js_1.deleteJSON)(this.brain.paths.synapse(id));
|
|
149
|
+
out.moved++;
|
|
150
|
+
}
|
|
151
|
+
await this.removeConnectionFromNeuron(other, fromId);
|
|
152
|
+
await this.addConnectionToNeuron(other, intoId);
|
|
153
|
+
await this.addConnectionToNeuron(intoId, other);
|
|
154
|
+
}
|
|
155
|
+
const bajan = out.merged + out.dropped;
|
|
156
|
+
if (bajan > 0) {
|
|
157
|
+
const manifest = await this.brain.getManifest();
|
|
158
|
+
await this.brain.updateManifest({ total_synapses: Math.max(0, manifest.total_synapses - bajan) });
|
|
159
|
+
}
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
52
162
|
/**
|
|
53
163
|
* Get all connections for a neuron.
|
|
54
164
|
*/
|
|
@@ -109,15 +219,10 @@ class Synapses {
|
|
|
109
219
|
decayFactor = 0.95;
|
|
110
220
|
synapse.strength = Math.round(synapse.strength * decayFactor * 1000) / 1000;
|
|
111
221
|
if (synapse.strength < pruneThreshold) {
|
|
112
|
-
// Prune weak synapse
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
await this.removeConnectionFromNeuron(synapse.nodes[0], synapse.nodes[1]);
|
|
117
|
-
await this.removeConnectionFromNeuron(synapse.nodes[1], synapse.nodes[0]);
|
|
118
|
-
const manifest = await this.brain.getManifest();
|
|
119
|
-
await this.brain.updateManifest({ total_synapses: Math.max(0, manifest.total_synapses - 1) });
|
|
120
|
-
pruned++;
|
|
222
|
+
// Prune weak synapse: same path as an explicit disconnect.
|
|
223
|
+
const r = await this.disconnect(synapse.nodes[0], synapse.nodes[1]);
|
|
224
|
+
if (r.removed)
|
|
225
|
+
pruned++;
|
|
121
226
|
}
|
|
122
227
|
else {
|
|
123
228
|
await (0, fs_js_1.writeJSON)(this.brain.paths.synapse(id), synapse);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synapses.js","sourceRoot":"","sources":["../../src/engine/synapses.ts"],"names":[],"mappings":";AAAA,oEAAoE;AACpE,4DAA4D;;;AAE5D,0CAAyE;AACzE,4CAA4C;AAI5C,MAAa,QAAQ;IACC;IAApB,YAAoB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;IAAG,CAAC;IAEpC;;OAEG;IACH,KAAK,CAAC,OAAO,CACX,MAAc,EACd,IAAY,EACZ,IAAiB,EACjB,OAAgB,EAChB,OAKC;QAED,MAAM,EAAE,GAAG,IAAA,kBAAS,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earchResult } from '../types/index.js';
|
|
|
6
6
|
* matched nothing, so every index built before it carries chunks for facts
|
|
7
7
|
* that were later revised or forgotten. The bump forces those poisoned
|
|
8
8
|
* indexes to rebuild once, which heals them.
|
|
9
|
+
* v5: retired decisions / patterns / errors / debts (entry_status sidecar,
|
|
10
|
+
* 2.0) are no longer chunked, so an index built before it must be rebuilt or
|
|
11
|
+
* it would keep serving entries that were retired.
|
|
9
12
|
*/
|
|
10
|
-
export declare const INDEX_VERSION =
|
|
13
|
+
export declare const INDEX_VERSION = 5;
|
|
11
14
|
export declare class SearchEngine {
|
|
12
15
|
private brain;
|
|
13
16
|
private db;
|
|
@@ -31,6 +34,8 @@ export declare class SearchEngine {
|
|
|
31
34
|
private semantic;
|
|
32
35
|
/** Chunks inserted since the last embedding pass: id → text. */
|
|
33
36
|
private pendingEmbed;
|
|
37
|
+
/** The background embedding job of the last rebuild, if any. */
|
|
38
|
+
private embedding;
|
|
34
39
|
constructor(brain: Brain);
|
|
35
40
|
/** Vectors held by the semantic layer (0 when it is off). */
|
|
36
41
|
semanticCount(): number;
|
|
@@ -67,6 +72,13 @@ export declare class SearchEngine {
|
|
|
67
72
|
* Re-index a single neuron: drop its old chunks, insert the current ones.
|
|
68
73
|
*/
|
|
69
74
|
indexNeuron(neuron: Neuron): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Drop every chunk of a neuron that no longer exists (forgotten or merged
|
|
77
|
+
* away). No-op when the index is not loaded or the neuron has no chunks.
|
|
78
|
+
*/
|
|
79
|
+
removeNeuron(neuronId: string): Promise<void>;
|
|
80
|
+
/** Wait for the background embedding job of a rebuild, if one is running. */
|
|
81
|
+
awaitEmbeddings(): Promise<void>;
|
|
70
82
|
/** Write the index to disk now. */
|
|
71
83
|
persist(): Promise<void>;
|
|
72
84
|
/** Flush if there are unsaved changes. Called on consolidate/shutdown. */
|
|
@@ -119,7 +131,11 @@ export declare class SearchEngine {
|
|
|
119
131
|
* re-indexed; chunks of deleted neurons are removed on the spot.
|
|
120
132
|
*/
|
|
121
133
|
private materializeResults;
|
|
122
|
-
/**
|
|
134
|
+
/**
|
|
135
|
+
* Does the chunk still describe something the neuron holds as current?
|
|
136
|
+
* A retired entry (entry_status sidecar) counts as dead, exactly like a
|
|
137
|
+
* superseded fact: it is still in the file, but recall must not serve it.
|
|
138
|
+
*/
|
|
123
139
|
private chunkVive;
|
|
124
140
|
/**
|
|
125
141
|
* Search one term. Exact first; only if a reasonably long term finds
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/search/index.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAQ,MAAM,mBAAmB,CAAC;AAEpE
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/search/index.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAQ,MAAM,mBAAmB,CAAC;AAEpE;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,IAAI,CAAC;AAiE/B,qBAAa,YAAY;IA2BX,OAAO,CAAC,KAAK;IA1BzB,OAAO,CAAC,EAAE,CAAyB;IACnC,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,YAAY,CAA+B;IAEnD;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc,CAAkC;IAExD;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAA8B;IAC9C,gEAAgE;IAChE,OAAO,CAAC,YAAY,CAA6B;IACjD,gEAAgE;IAChE,OAAO,CAAC,SAAS,CAA8B;gBAE3B,KAAK,EAAE,KAAK;IAMhC,6DAA6D;IAC7D,aAAa,IAAI,MAAM;IAMvB;;;;;;;;OAQG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CAO9B"}
|
package/dist/search/index.js
CHANGED
|
@@ -32,8 +32,11 @@ const ops_js_1 = require("../sync/ops.js");
|
|
|
32
32
|
* matched nothing, so every index built before it carries chunks for facts
|
|
33
33
|
* that were later revised or forgotten. The bump forces those poisoned
|
|
34
34
|
* indexes to rebuild once, which heals them.
|
|
35
|
+
* v5: retired decisions / patterns / errors / debts (entry_status sidecar,
|
|
36
|
+
* 2.0) are no longer chunked, so an index built before it must be rebuilt or
|
|
37
|
+
* it would keep serving entries that were retired.
|
|
35
38
|
*/
|
|
36
|
-
exports.INDEX_VERSION =
|
|
39
|
+
exports.INDEX_VERSION = 5; // 4: keys field (1.15) · 5: entry_status (2.0)
|
|
37
40
|
/** Weight given to a neuron for each *additional* chunk that matches. */
|
|
38
41
|
const BREADTH_BONUS = 0.05;
|
|
39
42
|
/** Cap on the breadth bonus — breadth is a tiebreaker, never the main signal. */
|
|
@@ -99,6 +102,8 @@ class SearchEngine {
|
|
|
99
102
|
semantic = null;
|
|
100
103
|
/** Chunks inserted since the last embedding pass: id → text. */
|
|
101
104
|
pendingEmbed = new Map();
|
|
105
|
+
/** The background embedding job of the last rebuild, if any. */
|
|
106
|
+
embedding = null;
|
|
102
107
|
constructor(brain) {
|
|
103
108
|
this.brain = brain;
|
|
104
109
|
if ((0, semantic_js_1.semanticEnabled)()) {
|
|
@@ -123,9 +128,9 @@ class SearchEngine {
|
|
|
123
128
|
if (this.semantic) {
|
|
124
129
|
await this.semantic.load();
|
|
125
130
|
// Warm the model off the critical path: boot returns at once and the
|
|
126
|
-
// first recall waits only for what is left of the
|
|
127
|
-
|
|
128
|
-
|
|
131
|
+
// first recall (or the first save) waits only for what is left of the
|
|
132
|
+
// ~13 s cold load.
|
|
133
|
+
this.semantic.warm();
|
|
129
134
|
}
|
|
130
135
|
const indexPath = this.brain.paths.chunksIndex();
|
|
131
136
|
if (await (0, fs_js_1.fileExists)(indexPath)) {
|
|
@@ -188,7 +193,10 @@ class SearchEngine {
|
|
|
188
193
|
// Skip unreadable neuron, keep going.
|
|
189
194
|
}
|
|
190
195
|
}
|
|
191
|
-
|
|
196
|
+
// Embeddings off the critical path: a rebuild after an upgrade must not
|
|
197
|
+
// hold boot for minutes on a big brain. Recall serves what is embedded so
|
|
198
|
+
// far; the vectors go to disk with the next index write.
|
|
199
|
+
this.embedding = this.flushEmbeddings().then(() => this.markDirty()).catch(() => undefined);
|
|
192
200
|
await this.persist();
|
|
193
201
|
await this.dropLegacyIndex();
|
|
194
202
|
return this.docCount;
|
|
@@ -207,6 +215,23 @@ class SearchEngine {
|
|
|
207
215
|
await this.flushEmbeddings();
|
|
208
216
|
this.markDirty();
|
|
209
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Drop every chunk of a neuron that no longer exists (forgotten or merged
|
|
220
|
+
* away). No-op when the index is not loaded or the neuron has no chunks.
|
|
221
|
+
*/
|
|
222
|
+
async removeNeuron(neuronId) {
|
|
223
|
+
if (!this.db)
|
|
224
|
+
return;
|
|
225
|
+
if (!this.chunksByNeuron.has(neuronId))
|
|
226
|
+
return;
|
|
227
|
+
await this.removeNeuronChunks(neuronId);
|
|
228
|
+
this.markDirty();
|
|
229
|
+
}
|
|
230
|
+
/** Wait for the background embedding job of a rebuild, if one is running. */
|
|
231
|
+
async awaitEmbeddings() {
|
|
232
|
+
if (this.embedding)
|
|
233
|
+
await this.embedding;
|
|
234
|
+
}
|
|
210
235
|
/** Write the index to disk now. */
|
|
211
236
|
async persist() {
|
|
212
237
|
if (!this.db)
|
|
@@ -528,25 +553,29 @@ class SearchEngine {
|
|
|
528
553
|
}
|
|
529
554
|
return top.map(x => x.r);
|
|
530
555
|
}
|
|
531
|
-
/**
|
|
556
|
+
/**
|
|
557
|
+
* Does the chunk still describe something the neuron holds as current?
|
|
558
|
+
* A retired entry (entry_status sidecar) counts as dead, exactly like a
|
|
559
|
+
* superseded fact: it is still in the file, but recall must not serve it.
|
|
560
|
+
*/
|
|
532
561
|
chunkVive(chunk, neuron) {
|
|
533
562
|
switch (chunk.kind) {
|
|
534
563
|
case 'fact':
|
|
535
564
|
return (neuron.facts || []).some(f => !isRetired(f) && f.text === chunk.text);
|
|
536
565
|
case 'error':
|
|
537
|
-
return (neuron.errors || []).includes(chunk.text);
|
|
566
|
+
return (neuron.errors || []).includes(chunk.text) && !entryRetired(neuron, chunk.text);
|
|
538
567
|
case 'debt':
|
|
539
|
-
return (neuron.debts || []).includes(chunk.text);
|
|
568
|
+
return (neuron.debts || []).includes(chunk.text) && !entryRetired(neuron, chunk.text);
|
|
540
569
|
case 'map':
|
|
541
570
|
return neuron.map?.text === chunk.text;
|
|
542
571
|
case 'pattern':
|
|
543
|
-
return (neuron.patterns || []).includes(chunk.text);
|
|
572
|
+
return (neuron.patterns || []).includes(chunk.text) && !entryRetired(neuron, chunk.text);
|
|
544
573
|
case 'preference':
|
|
545
574
|
return (neuron.preferences || []).includes(chunk.text);
|
|
546
575
|
case 'decision':
|
|
547
576
|
return (neuron.decisions || []).some(d => {
|
|
548
577
|
const texto = d.rationale ? `${d.text} — ${d.rationale}` : d.text;
|
|
549
|
-
return texto === chunk.text;
|
|
578
|
+
return texto === chunk.text && !entryRetired(neuron, d.text);
|
|
550
579
|
});
|
|
551
580
|
default:
|
|
552
581
|
// Headers describe the neuron itself; identity, not content.
|
|
@@ -641,6 +670,8 @@ class SearchEngine {
|
|
|
641
670
|
for (const decision of neuron.decisions || []) {
|
|
642
671
|
if (!decision || !decision.text)
|
|
643
672
|
continue;
|
|
673
|
+
if (entryRetired(neuron, decision.text))
|
|
674
|
+
continue;
|
|
644
675
|
const text = decision.rationale
|
|
645
676
|
? `${decision.text} — ${decision.rationale}`
|
|
646
677
|
: decision.text;
|
|
@@ -658,6 +689,8 @@ class SearchEngine {
|
|
|
658
689
|
for (const pattern of neuron.patterns || []) {
|
|
659
690
|
if (!pattern)
|
|
660
691
|
continue;
|
|
692
|
+
if (entryRetired(neuron, pattern))
|
|
693
|
+
continue;
|
|
661
694
|
await this.put({
|
|
662
695
|
...base,
|
|
663
696
|
id: (0, hash_js_1.chunkId)(neuron.id, pattern),
|
|
@@ -680,6 +713,8 @@ class SearchEngine {
|
|
|
680
713
|
for (const err of neuron.errors || []) {
|
|
681
714
|
if (!err)
|
|
682
715
|
continue;
|
|
716
|
+
if (entryRetired(neuron, err))
|
|
717
|
+
continue;
|
|
683
718
|
await this.put({
|
|
684
719
|
...base,
|
|
685
720
|
id: (0, hash_js_1.chunkId)(neuron.id, `error:${err}`),
|
|
@@ -691,6 +726,8 @@ class SearchEngine {
|
|
|
691
726
|
for (const debt of neuron.debts || []) {
|
|
692
727
|
if (!debt)
|
|
693
728
|
continue;
|
|
729
|
+
if (entryRetired(neuron, debt))
|
|
730
|
+
continue;
|
|
694
731
|
await this.put({
|
|
695
732
|
...base,
|
|
696
733
|
id: (0, hash_js_1.chunkId)(neuron.id, `debt:${debt}`),
|
|
@@ -836,4 +873,11 @@ exports.SearchEngine = SearchEngine;
|
|
|
836
873
|
function isRetired(fact) {
|
|
837
874
|
return fact.status === 'superseded' || fact.status === 'retracted';
|
|
838
875
|
}
|
|
876
|
+
/**
|
|
877
|
+
* A decision, pattern, error or debt retired through the entry_status
|
|
878
|
+
* sidecar (2.0). Keyed by entryId(text), like entry_dates; absent === active.
|
|
879
|
+
*/
|
|
880
|
+
function entryRetired(neuron, text) {
|
|
881
|
+
return !!neuron.entry_status?.[(0, ops_js_1.entryId)(text)];
|
|
882
|
+
}
|
|
839
883
|
//# sourceMappingURL=index.js.map
|