@framers/agentos 0.15.55 → 0.15.56

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.
@@ -15,6 +15,9 @@
15
15
  * - Merge `tags` arrays (union, dedup).
16
16
  * - A trace of another scope id is not a duplicate: its tags and time are
17
17
  * left as they are.
18
+ * - The source's live rows are read before its forgotten ones
19
+ * (`liveRecordsFirst`), so a text the source holds both forgotten and live
20
+ * arrives live, and the forgotten row merges into that trace.
18
21
  * - A trace a release older than `memory_traces.scope_id` wrote to the
19
22
  * target holds `''` in that column whatever scope id its metadata names;
20
23
  * the import files such traces under that scope id before it merges
@@ -23,6 +26,12 @@
23
26
  * - New traces are inserted wholesale.
24
27
  * - **knowledge_nodes**: deduplicated by `label` + `type`.
25
28
  * - New nodes are inserted; existing nodes are left unchanged.
29
+ * - A trace's memory-graph node (`type` `memory_graph`, whose id is its
30
+ * trace's) comes in with its trace alone, under that id
31
+ * (`memoryGraphNodeImport`): the node of a source trace merged into a
32
+ * trace of another id, written under a new id, or not written, or of a
33
+ * trace the brain does not hold, is skipped, with the edges that name it;
34
+ * a node the brain holds under that id is its duplicate.
26
35
  * - **knowledge_edges**: deduplicated by `source_id` + `target_id` + `type`.
27
36
  * - New edges are inserted; existing edges are left unchanged.
28
37
  *
@@ -44,7 +53,7 @@
44
53
  import { sha256 as crossSha256 } from '../core/util/crossPlatformCrypto.js';
45
54
  import { v4 as uuidv4 } from 'uuid';
46
55
  import { resolveStorageAdapter } from '@framers/sql-storage-adapter';
47
- import { duplicateTraceCondition, duplicateTraceParams, importedScopeId } from './importScope.js';
56
+ import { duplicateTraceCondition, duplicateTraceParams, importedScopeId, isForgottenRecord, liveRecordsFirst, MEMORY_GRAPH_NODE_TYPE, memoryGraphNodeImport, } from './importScope.js';
48
57
  import { fillScopeIds } from '../retrieval/store/migrations/v2-to-v3.js';
49
58
  import { parseTraceMetadata } from '../retrieval/store/tracePersistence.js';
50
59
  /** The tables the importer reads. */
@@ -105,14 +114,18 @@ export class SqliteImporter {
105
114
  const read = (table) => scoped.has(table) && brainIds.length === 1
106
115
  ? [`SELECT * FROM ${table} WHERE brain_id = ?`, [brainIds[0]]]
107
116
  : [`SELECT * FROM ${table}`, []];
108
- let traces = { inserted: 0, retagged: 0 };
117
+ let traces = {
118
+ inserted: 0,
119
+ retagged: 0,
120
+ unfiled: new Set(),
121
+ };
109
122
  await this.brain.transaction(async (trx) => {
110
123
  // A trace an older release wrote holds scope_id '': filed under its scope id first, it is matched there.
111
124
  if (options?.dedup ?? true)
112
125
  await fillScopeIds(trx, this.brain.brainId);
113
126
  traces = await this._mergeTraces(sourceAdapter, read, result, trx, options);
114
- await this._mergeNodes(sourceAdapter, read, result, trx);
115
- await this._mergeEdges(sourceAdapter, read, result, trx);
127
+ const skippedNodes = await this._mergeNodes(sourceAdapter, read, result, trx, traces.unfiled);
128
+ await this._mergeEdges(sourceAdapter, read, result, trx, skippedNodes);
116
129
  });
117
130
  // The inserts are not synced into the full-text index, and a tag merge
118
131
  // rewrites a held trace's tags in place and counts as skipped. One
@@ -160,20 +173,27 @@ export class SqliteImporter {
160
173
  }
161
174
  /**
162
175
  * Insert the source's traces, or merge a duplicate's tags and time into
163
- * the trace the brain holds.
176
+ * the trace the brain holds. The source's live rows are read before its
177
+ * forgotten ones (see `liveRecordsFirst`).
164
178
  *
165
- * @returns How many traces it inserted, and how many held traces a merge
166
- * gave new tags.
179
+ * @returns How many traces it inserted, how many held traces a merge gave
180
+ * new tags, and the ids of the source traces it did not write, or match
181
+ * as a duplicate, under their own id (merged into a trace of another id,
182
+ * written under a new id, or not written), whose memory-graph nodes stay
183
+ * out.
167
184
  */
168
185
  async _mergeTraces(src, read, result, trx, options) {
169
186
  let inserted = 0;
170
187
  let retagged = 0;
188
+ const seen = new Set();
189
+ const filed = new Set();
190
+ const unfiledOf = () => new Set([...seen].filter((id) => !filed.has(id)));
171
191
  let sourceRows;
172
192
  try {
173
193
  sourceRows = await src.all(...read('memory_traces'));
174
194
  }
175
195
  catch {
176
- return { inserted, retagged };
196
+ return { inserted, retagged, unfiled: unfiledOf() };
177
197
  }
178
198
  const brainId = this.brain.brainId;
179
199
  const checkSql = `SELECT id, created_at, tags
@@ -186,8 +206,10 @@ export class SqliteImporter {
186
206
  retrieval_count, tags, emotions, metadata, deleted, scope_id)
187
207
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`;
188
208
  const updateTimestampSql = `UPDATE memory_traces SET created_at = ?, tags = ? WHERE brain_id = ? AND id = ?`;
189
- for (const row of sourceRows) {
209
+ for (const row of liveRecordsFirst(sourceRows, isForgottenRecord)) {
190
210
  try {
211
+ if (row.id)
212
+ seen.add(row.id);
191
213
  const hash = await this._sha256(row.content);
192
214
  const scope = row.scope ?? 'user';
193
215
  // The metadata names the scope id, so it is read before the dedup check. Metadata that is not a JSON object
@@ -212,6 +234,8 @@ export class SqliteImporter {
212
234
  await trx.run(updateTimestampSql, [newerAt, merged, brainId, existing.id]);
213
235
  if (merged !== existing.tags)
214
236
  retagged++;
237
+ if (row.id && existing.id === row.id)
238
+ filed.add(row.id);
215
239
  result.skipped++;
216
240
  continue;
217
241
  }
@@ -235,6 +259,8 @@ export class SqliteImporter {
235
259
  row.deleted ?? 0,
236
260
  scopeId,
237
261
  ]);
262
+ if (row.id && id === row.id)
263
+ filed.add(row.id);
238
264
  inserted++;
239
265
  result.imported++;
240
266
  }
@@ -242,7 +268,7 @@ export class SqliteImporter {
242
268
  result.errors.push(`Trace merge error: ${String(err)}`);
243
269
  }
244
270
  }
245
- return { inserted, retagged };
271
+ return { inserted, retagged, unfiled: unfiledOf() };
246
272
  }
247
273
  /**
248
274
  * Rebuild the brain's full-text index (best-effort) with the statement
@@ -264,13 +290,24 @@ export class SqliteImporter {
264
290
  console.warn(`[SqliteImporter] full-text index rebuild after an import failed for brain ${this.brain.brainId}: ${message}`);
265
291
  }
266
292
  }
267
- async _mergeNodes(src, read, result, trx) {
293
+ /**
294
+ * Insert the source's knowledge nodes the brain has no node of the same
295
+ * label and type for. A memory-graph node comes in with its trace alone,
296
+ * under its trace's id (see `memoryGraphNodeImport`).
297
+ *
298
+ * @param unfiled - The source trace ids the trace merge did not write, or
299
+ * match as a duplicate, under their own id.
300
+ * @returns The ids of the memory-graph nodes it skipped, whose edges stay
301
+ * out too.
302
+ */
303
+ async _mergeNodes(src, read, result, trx, unfiled) {
304
+ const skipped = new Set();
268
305
  let sourceRows;
269
306
  try {
270
307
  sourceRows = await src.all(...read('knowledge_nodes'));
271
308
  }
272
309
  catch {
273
- return;
310
+ return skipped;
274
311
  }
275
312
  const checkSql = `SELECT id FROM knowledge_nodes WHERE brain_id = ? AND label = ? AND type = ? LIMIT 1`;
276
313
  const { dialect } = this.brain.features;
@@ -278,10 +315,21 @@ export class SqliteImporter {
278
315
  const insertSql = dialect.insertOrIgnore('knowledge_nodes', ['brain_id', 'id', 'type', 'label', 'properties', 'embedding', 'confidence', 'source', 'created_at'], ['?', '?', '?', '?', '?', '?', '?', '?', '?']);
279
316
  for (const row of sourceRows) {
280
317
  try {
281
- const existing = await trx.get(checkSql, [brainId, row.label ?? '', row.type ?? '']);
282
- if (existing) {
283
- result.skipped++;
284
- continue;
318
+ if (row.type === MEMORY_GRAPH_NODE_TYPE) {
319
+ const take = await memoryGraphNodeImport(trx, brainId, row.id, (traceId) => unfiled.has(traceId));
320
+ if (take.action !== 'write') {
321
+ if (take.action === 'skip' && typeof row.id === 'string')
322
+ skipped.add(row.id);
323
+ result.skipped++;
324
+ continue;
325
+ }
326
+ }
327
+ else {
328
+ const existing = await trx.get(checkSql, [brainId, row.label ?? '', row.type ?? '']);
329
+ if (existing) {
330
+ result.skipped++;
331
+ continue;
332
+ }
285
333
  }
286
334
  await trx.run(insertSql, [
287
335
  brainId,
@@ -300,8 +348,14 @@ export class SqliteImporter {
300
348
  result.errors.push(`Node merge error: ${String(err)}`);
301
349
  }
302
350
  }
351
+ return skipped;
303
352
  }
304
- async _mergeEdges(src, read, result, trx) {
353
+ /**
354
+ * Insert the source's knowledge edges the brain has no edge of the same
355
+ * source, target and type for, except those that name a memory-graph node
356
+ * the node merge skipped.
357
+ */
358
+ async _mergeEdges(src, read, result, trx, skippedNodes) {
305
359
  let sourceRows;
306
360
  try {
307
361
  sourceRows = await src.all(...read('knowledge_edges'));
@@ -317,7 +371,7 @@ export class SqliteImporter {
317
371
  const insertSql = dialect.insertOrIgnore('knowledge_edges', ['brain_id', 'id', 'source_id', 'target_id', 'type', 'weight', 'bidirectional', 'metadata', 'created_at'], ['?', '?', '?', '?', '?', '?', '?', '?', '?']);
318
372
  for (const row of sourceRows) {
319
373
  try {
320
- if (!row.source_id || !row.target_id) {
374
+ if (!row.source_id || !row.target_id || skippedNodes.has(row.source_id) || skippedNodes.has(row.target_id)) {
321
375
  result.skipped++;
322
376
  continue;
323
377
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SqliteImporter.js","sourceRoot":"","sources":["../../../../src/cognition/memory/io/SqliteImporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAIpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AA8C5E,qCAAqC;AACrC,MAAM,aAAa,GAAG,CAAC,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,CAAU,CAAC;AAMvF,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;;;;;;;;;;GAWG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WAAW,CAAC,CAClC,CAAC;QACF,OAAO,QAAQ,CAAC,CAAC,CAAC,MAAM,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC;IACnD,CAAC;CACF"}
@@ -469,10 +469,12 @@ export interface ImportOptions {
469
469
  /**
470
470
  * Whether a record is skipped as a duplicate when a trace of the same scope and scope id holds its text, or names
471
471
  * that text's SHA-256 as `import_hash` or `content_hash`; a Markdown or Obsidian note is also skipped when it is
472
- * the own note of the trace its front-matter `id` names. A trace of another scope id is not a duplicate. A SQLite
473
- * import merges a skipped record's tags, and the later creation time, into the trace it matches, and an Obsidian
474
- * note adds the tags and links that trace lacks. With `false`, no trace record is skipped as a duplicate and nothing
475
- * is merged into a trace the brain holds.
472
+ * the own note of the trace its front-matter `id` names. A trace of another scope id is not a duplicate, and a trace
473
+ * the brain forgot counts as any other. A JSON, SQLite or CSV import reads a file's live records before its forgotten
474
+ * ones, so a text the file holds both forgotten and live arrives live. A SQLite import merges a skipped record's
475
+ * tags, and the later creation time, into the trace it matches, and an Obsidian note adds the tags and links that
476
+ * trace lacks. With `false`, no trace record is skipped as a duplicate and nothing is merged into a trace the brain
477
+ * holds.
476
478
  * @default true
477
479
  */
478
480
  dedup?: boolean;
@@ -482,20 +484,22 @@ export interface ImportOptions {
482
484
  */
483
485
  export interface ImportResult {
484
486
  /**
485
- * How many rows the import wrote: its traces, and, from a JSON file, its knowledge nodes and edges, documents,
486
- * chunks, images, conversations and messages too; from a SQLite file, its knowledge nodes and edges too.
487
+ * How many traces the import wrote, and, from a JSON file, its knowledge nodes and edges, documents, chunks,
488
+ * images, conversations and messages too; from a SQLite file, its knowledge nodes and edges too. A JSON file's brain
489
+ * metadata, the knowledge nodes and edge an Obsidian note's wikilink adds, and the `conversations` row of each
490
+ * conversation in a ChatGPT export are written and not counted.
487
491
  */
488
492
  imported: number;
489
493
  /**
490
494
  * How many records the import did not write: a duplicate trace (see `ImportOptions.dedup`), a graph, document,
491
495
  * chunk, image, conversation or message row the brain holds already, a Markdown or Obsidian note whose body is
492
- * blank, a CSV row whose `content` is blank, and a row that lacks a field it needs, such as an edge with no
493
- * source or target.
496
+ * blank, a CSV row whose `content` is blank, a memory-graph node whose trace the import did not write under its id
497
+ * and an edge that names one, and a row that lacks a field it needs, such as an edge with no source or target.
494
498
  */
495
499
  skipped: number;
496
500
  /**
497
- * Human-readable messages for the records that failed to import, and for a source that could not be read or
498
- * parsed.
501
+ * Human-readable messages for the records that failed to import, for an Obsidian note's link or tag the import
502
+ * could not write, and for a source that could not be read or parsed.
499
503
  */
500
504
  errors: string[];
501
505
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/cognition/memory/io/facade/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAM1E;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAMD;;;;;;GAMG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAC;IAE1C;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAI5B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAA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ED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB;;OAEG;IACH,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,EAAE,gBAAgB,CAAC;IAE3B;;OAEG;IACH,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;IAEzB;;;OAGG;IACH,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;IAE1B;;OAEG;IACH,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;IAE1B;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -4,7 +4,11 @@
4
4
  * An importer files each trace under its scope and scope id and deduplicates inside that pair: a record whose text a
5
5
  * trace of another scope id holds (another tenant's, user's or session's) is imported, and a record whose text a trace
6
6
  * of its own scope and scope id holds is a duplicate, whichever writer stored that trace. The Markdown export writes
7
- * the same scope id into a trace's front matter, so a note carries it out of one brain and into another.
7
+ * the same scope id into a trace's front matter, so a note carries it out of one brain and into another. An importer
8
+ * whose source marks forgotten traces reads the source's live records before its forgotten ones, so a text the source
9
+ * holds both forgotten and live arrives live. A trace's memory-graph node comes in with its trace alone, under its
10
+ * trace's id, so a record merged into another trace leaves no node behind that stands for a trace the brain does not
11
+ * hold.
8
12
  *
9
13
  * @module memory/io/importScope
10
14
  */
@@ -29,7 +33,9 @@ export declare function importedScopeId(metadata: unknown, scopeIdColumn?: unkno
29
33
  * `import_hash` (an import stores it) or `content_hash` (`remember()`, `ingest()` and `memory_add` store it). A trace
30
34
  * the cognitive memory store wrote carries neither hash, and its text finds it. A trace the brain forgot counts as any
31
35
  * other, so an import does not bring it back: a forgotten row stays a record of what the brain let go, and a JSON or
32
- * SQLite export carries it, so leaving it out would add another forgotten copy at each import of such a file.
36
+ * SQLite export carries it, so leaving it out would add another forgotten copy at each import of such a file. An
37
+ * importer reads a source's live records before its forgotten ones (see {@link liveRecordsFirst}), so a forgotten trace
38
+ * the same import writes is never what makes a live record of its text a duplicate.
33
39
  *
34
40
  * @param brain - The brain the query runs on; its dialect reads the metadata.
35
41
  * @returns A parenthesised condition on `memory_traces` with the three placeholders {@link duplicateTraceParams}
@@ -44,4 +50,58 @@ export declare function duplicateTraceCondition(brain: Pick<Brain, 'features'>):
44
50
  * @returns The hash twice, then the text.
45
51
  */
46
52
  export declare function duplicateTraceParams(hash: string, content: string): [string, string, string];
53
+ /**
54
+ * A source's trace records in the order an importer reads them: its live records, then its forgotten ones, each group
55
+ * in the source's order. A source can hold a forgotten and a live trace of one text in one scope and scope id:
56
+ * `forget()` and then `remember()` of the text leave them, and so does a consolidation merge of two traces of it. An
57
+ * export holds its rows in no set order. Read first, the live record is imported and the forgotten one is its
58
+ * duplicate, so the text arrives live; read the other way round, the live record would be the duplicate of the
59
+ * forgotten trace the same import had just written, and the text would arrive forgotten.
60
+ *
61
+ * @param records - The source's trace records, in its order.
62
+ * @param isForgotten - Whether a record is of a trace its source forgot.
63
+ * @returns The live records, then the forgotten ones.
64
+ */
65
+ export declare function liveRecordsFirst<T>(records: readonly T[], isForgotten: (record: T) => boolean): T[];
66
+ /**
67
+ * Whether a JSON or SQLite trace record is of a trace its source forgot: its `deleted` is present and not zero. A
68
+ * record whose `deleted` is absent or `null` is stored as live, as one whose `deleted` is `0` is.
69
+ *
70
+ * @param record - A trace record as its source holds it; a value that is not an object is not forgotten.
71
+ * @returns `true` when the record's `deleted` is present and not zero.
72
+ */
73
+ export declare function isForgottenRecord(record: unknown): boolean;
74
+ /**
75
+ * The `knowledge_nodes.type` of a memory-graph node (`SqlMemoryGraph`): the node of the trace whose id it carries as
76
+ * its own.
77
+ */
78
+ export declare const MEMORY_GRAPH_NODE_TYPE = "memory_graph";
79
+ /** How an import takes a memory-graph node its file holds (see {@link memoryGraphNodeImport}). */
80
+ export type MemoryGraphNodeImport = {
81
+ action: 'write' | 'duplicate';
82
+ id: string;
83
+ } | {
84
+ action: 'skip';
85
+ };
86
+ /**
87
+ * How an import takes a memory-graph node its file holds, the node of the trace whose id it carries. The node comes in
88
+ * with its trace alone and under that id. It is skipped, and so are the edges that name it, when the file holds its
89
+ * trace and the import did not write that trace, or match it as a duplicate, under that id (the record merged into a
90
+ * trace of another id, was written under a new id, or failed), or when the brain holds no trace of that id; written
91
+ * there, the node would stand for a trace the brain does not hold. A node the brain holds under that id is the
92
+ * record's duplicate, and the edges that name the record's node name it; a node of another type under that id makes
93
+ * the record's node a skip, as it cannot take that id. Otherwise the node is written under that id.
94
+ *
95
+ * A record merged into a trace of another id brings no node and no edges: the brain's node of that trace keeps its own
96
+ * edges, and the record merged is most often a forgotten one (see {@link liveRecordsFirst}), whose edges its source no
97
+ * longer reads.
98
+ *
99
+ * @param trx - The import's transaction.
100
+ * @param brainId - The brain the import writes.
101
+ * @param nodeId - The node record's id, which is its trace's id.
102
+ * @param unfiled - Whether the file holds the trace of an id that the import did not write, or match as a duplicate,
103
+ * under that id.
104
+ * @returns `write` or `duplicate` with the id, or `skip`.
105
+ */
106
+ export declare function memoryGraphNodeImport(trx: Pick<Brain, 'get'>, brainId: string, nodeId: unknown, unfiled: (traceId: string) => boolean): Promise<MemoryGraphNodeImport>;
47
107
  //# sourceMappingURL=importScope.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"importScope.d.ts","sourceRoot":"","sources":["../../../../src/cognition/memory/io/importScope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAEzD;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG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EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvG;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,EACvB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,GACpC,OAAO,CAAC,qBAAqB,CAAC,CAahC"}
@@ -4,7 +4,11 @@
4
4
  * An importer files each trace under its scope and scope id and deduplicates inside that pair: a record whose text a
5
5
  * trace of another scope id holds (another tenant's, user's or session's) is imported, and a record whose text a trace
6
6
  * of its own scope and scope id holds is a duplicate, whichever writer stored that trace. The Markdown export writes
7
- * the same scope id into a trace's front matter, so a note carries it out of one brain and into another.
7
+ * the same scope id into a trace's front matter, so a note carries it out of one brain and into another. An importer
8
+ * whose source marks forgotten traces reads the source's live records before its forgotten ones, so a text the source
9
+ * holds both forgotten and live arrives live. A trace's memory-graph node comes in with its trace alone, under its
10
+ * trace's id, so a record merged into another trace leaves no node behind that stands for a trace the brain does not
11
+ * hold.
8
12
  *
9
13
  * @module memory/io/importScope
10
14
  */
@@ -39,7 +43,9 @@ export function importedScopeId(metadata, scopeIdColumn) {
39
43
  * `import_hash` (an import stores it) or `content_hash` (`remember()`, `ingest()` and `memory_add` store it). A trace
40
44
  * the cognitive memory store wrote carries neither hash, and its text finds it. A trace the brain forgot counts as any
41
45
  * other, so an import does not bring it back: a forgotten row stays a record of what the brain let go, and a JSON or
42
- * SQLite export carries it, so leaving it out would add another forgotten copy at each import of such a file.
46
+ * SQLite export carries it, so leaving it out would add another forgotten copy at each import of such a file. An
47
+ * importer reads a source's live records before its forgotten ones (see {@link liveRecordsFirst}), so a forgotten trace
48
+ * the same import writes is never what makes a live record of its text a duplicate.
43
49
  *
44
50
  * @param brain - The brain the query runs on; its dialect reads the metadata.
45
51
  * @returns A parenthesised condition on `memory_traces` with the three placeholders {@link duplicateTraceParams}
@@ -61,4 +67,78 @@ export function duplicateTraceCondition(brain) {
61
67
  export function duplicateTraceParams(hash, content) {
62
68
  return [hash, hash, content];
63
69
  }
70
+ /**
71
+ * A source's trace records in the order an importer reads them: its live records, then its forgotten ones, each group
72
+ * in the source's order. A source can hold a forgotten and a live trace of one text in one scope and scope id:
73
+ * `forget()` and then `remember()` of the text leave them, and so does a consolidation merge of two traces of it. An
74
+ * export holds its rows in no set order. Read first, the live record is imported and the forgotten one is its
75
+ * duplicate, so the text arrives live; read the other way round, the live record would be the duplicate of the
76
+ * forgotten trace the same import had just written, and the text would arrive forgotten.
77
+ *
78
+ * @param records - The source's trace records, in its order.
79
+ * @param isForgotten - Whether a record is of a trace its source forgot.
80
+ * @returns The live records, then the forgotten ones.
81
+ */
82
+ export function liveRecordsFirst(records, isForgotten) {
83
+ const live = [];
84
+ const forgotten = [];
85
+ for (const record of records)
86
+ (isForgotten(record) ? forgotten : live).push(record);
87
+ return live.concat(forgotten);
88
+ }
89
+ /**
90
+ * Whether a JSON or SQLite trace record is of a trace its source forgot: its `deleted` is present and not zero. A
91
+ * record whose `deleted` is absent or `null` is stored as live, as one whose `deleted` is `0` is.
92
+ *
93
+ * @param record - A trace record as its source holds it; a value that is not an object is not forgotten.
94
+ * @returns `true` when the record's `deleted` is present and not zero.
95
+ */
96
+ export function isForgottenRecord(record) {
97
+ if (typeof record !== 'object' || record === null)
98
+ return false;
99
+ const deleted = record.deleted;
100
+ return deleted !== undefined && deleted !== null && Number(deleted) !== 0;
101
+ }
102
+ /**
103
+ * The `knowledge_nodes.type` of a memory-graph node (`SqlMemoryGraph`): the node of the trace whose id it carries as
104
+ * its own.
105
+ */
106
+ export const MEMORY_GRAPH_NODE_TYPE = 'memory_graph';
107
+ /**
108
+ * How an import takes a memory-graph node its file holds, the node of the trace whose id it carries. The node comes in
109
+ * with its trace alone and under that id. It is skipped, and so are the edges that name it, when the file holds its
110
+ * trace and the import did not write that trace, or match it as a duplicate, under that id (the record merged into a
111
+ * trace of another id, was written under a new id, or failed), or when the brain holds no trace of that id; written
112
+ * there, the node would stand for a trace the brain does not hold. A node the brain holds under that id is the
113
+ * record's duplicate, and the edges that name the record's node name it; a node of another type under that id makes
114
+ * the record's node a skip, as it cannot take that id. Otherwise the node is written under that id.
115
+ *
116
+ * A record merged into a trace of another id brings no node and no edges: the brain's node of that trace keeps its own
117
+ * edges, and the record merged is most often a forgotten one (see {@link liveRecordsFirst}), whose edges its source no
118
+ * longer reads.
119
+ *
120
+ * @param trx - The import's transaction.
121
+ * @param brainId - The brain the import writes.
122
+ * @param nodeId - The node record's id, which is its trace's id.
123
+ * @param unfiled - Whether the file holds the trace of an id that the import did not write, or match as a duplicate,
124
+ * under that id.
125
+ * @returns `write` or `duplicate` with the id, or `skip`.
126
+ */
127
+ export async function memoryGraphNodeImport(trx, brainId, nodeId, unfiled) {
128
+ if (typeof nodeId !== 'string' || unfiled(nodeId))
129
+ return { action: 'skip' };
130
+ const trace = await trx.get('SELECT id FROM memory_traces WHERE brain_id = ? AND id = ? LIMIT 1', [
131
+ brainId,
132
+ nodeId,
133
+ ]);
134
+ if (!trace)
135
+ return { action: 'skip' };
136
+ const held = await trx.get('SELECT type FROM knowledge_nodes WHERE brain_id = ? AND id = ? LIMIT 1', [
137
+ brainId,
138
+ nodeId,
139
+ ]);
140
+ if (!held)
141
+ return { action: 'write', id: nodeId };
142
+ return held.type === MEMORY_GRAPH_NODE_TYPE ? { action: 'duplicate', id: nodeId } : { action: 'skip' };
143
+ }
64
144
  //# sourceMappingURL=importScope.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"importScope.js","sourceRoot":"","sources":["../../../../src/cognition/memory/io/importScope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,eAAe,CAAC,QAAiB,EAAE,aAAuB;IACxE,MAAM,MAAM,GACV,QAAQ,KAAK,IAAI,I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K,SAAS,IAAI,OAAO,KAAK,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC5E,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,cAAc,CAAC;AAKrD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,GAAuB,EACvB,OAAe,EACf,MAAe,EACf,OAAqC;IAErC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC7E,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,GAAG,CAAiB,oEAAoE,EAAE;QAChH,OAAO;QACP,MAAM;KACP,CAAC,CAAC;IACH,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACtC,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,GAAG,CAAmB,wEAAwE,EAAE;QACrH,OAAO;QACP,MAAM;KACP,CAAC,CAAC;IACH,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;IAClD,OAAO,IAAI,CAAC,IAAI,KAAK,sBAAsB,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACzG,CAAC"}
@@ -65,7 +65,9 @@ export interface Checkpoint {
65
65
  /**
66
66
  * Results recorded when this checkpoint was taken, keyed by node id: those of the
67
67
  * nodes in `visitedNodes` and, in the checkpoint of a run that a node interrupted,
68
- * that node's. A node that failed records none, so a resume runs it again.
68
+ * that node's, as in the checkpoint saved before an expansion that came after a
69
+ * `write`, `external` or `human` node. A node that failed records none, so a
70
+ * resume runs it again.
69
71
  */
70
72
  nodeResults: Record<string, {
71
73
  /** The node's declared effect class. */
@@ -74,6 +76,16 @@ export interface Checkpoint {
74
76
  output: unknown;
75
77
  /** Wall-clock execution time in milliseconds. */
76
78
  durationMs: number;
79
+ /**
80
+ * The target the node picked itself, as a router, a guardrail that reroutes or
81
+ * the exit of a voice node does. A resume that marks the node complete with this
82
+ * result, as it does a `write`, `external` or `human` node such as a voice node,
83
+ * goes there rather than evaluating the node's edges. `routerNode()` and
84
+ * `guardrailNode()` build `pure` nodes, which a resume never marks complete from
85
+ * a recorded result: one the checkpoint does not list as completed runs again and
86
+ * picks its target anew.
87
+ */
88
+ routeTarget?: string;
77
89
  }>;
78
90
  /** Ordered list of node ids that had completed execution when this checkpoint was taken. */
79
91
  visitedNodes: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"ICheckpointStore.d.ts","sourceRoot":"","sources":["../../../src/orchestration/checkpoint/ICheckpointStore.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGnG,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAMzD;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAC;IACX,yDAAyD;IACzD,OAAO,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,KAAK,EAAE;QACL,8DAA8D;QAC9D,KAAK,EAAE,OAAO,CAAC;QACf,uEAAuE;QACvE,OAAO,EAAE,OAAO,CAAC;QACjB,+DAA+D;QAC/D,SAAS,EAAE,OAAO,CAAC;QACnB,8DAA8D;QAC9D,WAAW,EAAE,eAAe,CAAC;KAC9B,CAAC;IAEF;;;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E,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAEjE;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAElD;;;;;;;OAOG;IACH,IAAI,CACF,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAC3C,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAEjC;;;;;;OAMG;IACH,MAAM,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5C;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC/E"}
@@ -68,6 +68,17 @@ export interface GraphExpansionContext {
68
68
  nodeId: string;
69
69
  state: GraphState;
70
70
  request: GraphExpansionRequest;
71
+ /**
72
+ * The checkpoint the runtime saved after the node and before it handed any of
73
+ * this step's expansion requests to the handler. The node's edges are decided
74
+ * after the expansion, on the graph it leaves, so the checkpoint does not list
75
+ * the node in `visitedNodes`, and a resume from it routes the node once by its
76
+ * edges. A `write`, `external` or `human` node keeps its result and what it
77
+ * wrote, and a resume marks it complete with its recorded output; a `pure` or
78
+ * `read` node is saved as it was before it ran, and a resume runs it again.
79
+ * After a parallel batch, whose nodes' edges are decided before the expansion,
80
+ * the checkpoint lists every node of the batch.
81
+ */
71
82
  checkpointIdBefore?: string;
72
83
  completedNodes: string[];
73
84
  skippedNodes: string[];
@@ -142,8 +153,10 @@ export declare class GraphRuntime {
142
153
  * node of the batch runs to the end first, none of the batch's events is yielded,
143
154
  * and the error is the first in the order the nodes are declared; a node of the
144
155
  * batch counts as completed only once its edges are decided, so a node whose edges
145
- * threw is in no checkpoint as completed. A resume by the `runId` of `run_start`
146
- * continues from the last checkpoint the store saved.
156
+ * threw is in no checkpoint as completed. The checkpoint saved before an expansion
157
+ * does not list the node the expansion came after as completed either (see
158
+ * {@link GraphExpansionContext.checkpointIdBefore}). A resume by the `runId` of
159
+ * `run_start` continues from the last checkpoint the store saved.
147
160
  *
148
161
  * @param graph - Compiled execution graph to run.
149
162
  * @param input - Initial user-provided input; frozen into `GraphState.input`.
@@ -163,8 +176,9 @@ export declare class GraphRuntime {
163
176
  * evaluated on the restored state with the node's visit recorded
164
177
  * (`currentNodeId` names the node and `visitedNodes` lists it), as a node's
165
178
  * are after it runs, so the run follows the targets they pick and skips the
166
- * others. A node that failed recorded no result and wrote nothing, so it runs
167
- * again, from the state it ran on.
179
+ * others; a replayed node that picked its target itself, as the exit of a voice
180
+ * node does, goes to the target its recorded result names. A node that failed
181
+ * recorded no result and wrote nothing, so it runs again, from the state it ran on.
168
182
  *
169
183
  * @param graph - The same compiled graph that was originally invoked.
170
184
  * @param runOrCheckpointId - Either the original run id or an exact checkpoint id.