@equationalapplications/core-llm-wiki 9.4.3 → 9.5.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.
- package/README.md +1 -1
- package/dist/{chunk-TRLMWC5G.mjs → chunk-Q6ZS2RKS.mjs} +76 -14
- package/dist/chunk-Q6ZS2RKS.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +141 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-BVY5P6BS.d.mts → testing-BZyrIoJp.d.mts} +47 -3
- package/dist/{testing-BVY5P6BS.d.ts → testing-BZyrIoJp.d.ts} +47 -3
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +74 -12
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-TRLMWC5G.mjs.map +0 -1
|
@@ -1300,12 +1300,21 @@ interface ForgetParams {
|
|
|
1300
1300
|
* predecessor and successor reached by walking `superseded_by` links, capped
|
|
1301
1301
|
* at 100 per direction). The walk is NOT the connected component: with
|
|
1302
1302
|
* fan-in A→C←B, forgetting A reaches C but not B. The forward walk deletes
|
|
1303
|
-
* the live current fact. Does not compose with other selectors
|
|
1303
|
+
* the live current fact. Does not compose with other selectors (including
|
|
1304
|
+
* `eventId`).
|
|
1304
1305
|
*/
|
|
1305
1306
|
includeChain?: boolean;
|
|
1306
1307
|
taskId?: string;
|
|
1307
1308
|
sourceRef?: string;
|
|
1308
1309
|
sourceHash?: string;
|
|
1310
|
+
/**
|
|
1311
|
+
* Soft-delete every librarian fact whose `source_pointer` names this event
|
|
1312
|
+
* id (entity-scoped; exact match, no normalization — event ids are
|
|
1313
|
+
* engine-generated). Mutually exclusive with every other selector;
|
|
1314
|
+
* `clearAll` excludes it. Removal reports through the return value and the
|
|
1315
|
+
* per-row outbox DELETE events. See `specs/forget-by-event-id/` (issue #386).
|
|
1316
|
+
*/
|
|
1317
|
+
eventId?: string;
|
|
1309
1318
|
/** Soft-delete every fact and task of the entity, delete its edges, and delete its source-ref index rows. */
|
|
1310
1319
|
clearAll?: boolean;
|
|
1311
1320
|
/**
|
|
@@ -1525,6 +1534,13 @@ interface WikiInstructions {
|
|
|
1525
1534
|
ingest: string;
|
|
1526
1535
|
librarian: string;
|
|
1527
1536
|
heal: string;
|
|
1537
|
+
/**
|
|
1538
|
+
* Template only: the run-time prompt additionally carries a TITLE CATALOG
|
|
1539
|
+
* of the entity's typed node titles (appended after this text, before the
|
|
1540
|
+
* ontology block) whenever a catalog is built — see
|
|
1541
|
+
* `buildTitleCatalogBlock` and the data-scope note in the ontology-backfill
|
|
1542
|
+
* spec Errata (PR #425).
|
|
1543
|
+
*/
|
|
1528
1544
|
ontologyBackfill: string;
|
|
1529
1545
|
}
|
|
1530
1546
|
type MaintenanceJob = 'librarian' | 'heal' | 'reembed' | 'externalDeletions';
|
|
@@ -1835,6 +1851,33 @@ declare class EntryRepository extends BaseRepository {
|
|
|
1835
1851
|
* Returns the number of rows deleted.
|
|
1836
1852
|
*/
|
|
1837
1853
|
softDeleteBySource(entityId: string, tx: SQLiteAdapter, sourceRef?: string | null, sourceHash?: string | null): Promise<number>;
|
|
1854
|
+
/**
|
|
1855
|
+
* Shared JSON match predicate for source_pointer event ids
|
|
1856
|
+
* (specs/forget-by-event-id §D1). Every JSON call sits under the single
|
|
1857
|
+
* `json_valid` guard: unguarded JSON functions RAISE on malformed text, and
|
|
1858
|
+
* three-valued logic forces evaluation of AND operands after a NULL-guarded
|
|
1859
|
+
* term — a two-term form is only as safe as the planner's term-splitting.
|
|
1860
|
+
* The tombstone guard (`deleted_at IS NULL`) is added per-method.
|
|
1861
|
+
*/
|
|
1862
|
+
static readonly POINTER_EVENT_MATCH_SQL = "CASE WHEN json_valid(source_pointer)\n THEN json_type(source_pointer, '$.event_id') = 'text'\n AND json_extract(source_pointer, '$.event_id') = ?\n ELSE 0 END";
|
|
1863
|
+
/**
|
|
1864
|
+
* IDs of the entity's entries whose source_pointer names the event id.
|
|
1865
|
+
* `includeDeleted = true` returns live + tombstoned rows (the forget
|
|
1866
|
+
* enumeration superset for index sync and the ledger backstop).
|
|
1867
|
+
*/
|
|
1868
|
+
findIdsByPointerEvent(entityId: string, eventId: string, tx?: SQLiteAdapter, includeDeleted?: boolean): Promise<string[]>;
|
|
1869
|
+
/** Live-row count for the event id — dry-run only (a real call is idempotent over tombstones). */
|
|
1870
|
+
countLiveByPointerEvent(entityId: string, eventId: string, tx?: SQLiteAdapter): Promise<number>;
|
|
1871
|
+
/**
|
|
1872
|
+
* Soft-delete the entity's entries whose source_pointer names the event id,
|
|
1873
|
+
* within a transaction. Stages a DELETE outbox entry for each row that
|
|
1874
|
+
* changed, in the same transaction (parity with softDeleteBySource — synced
|
|
1875
|
+
* replicas learn of the tombstones through the outbox). The `deleted_at
|
|
1876
|
+
* IS NULL` guard makes the call idempotent: already-tombstoned rows are
|
|
1877
|
+
* no-op hits and are not counted. `tx` is REQUIRED.
|
|
1878
|
+
* Returns the number of rows deleted.
|
|
1879
|
+
*/
|
|
1880
|
+
softDeleteByPointerEvent(entityId: string, eventId: string, tx: SQLiteAdapter): Promise<number>;
|
|
1838
1881
|
/**
|
|
1839
1882
|
* Fetch IDs + entity_ids of soft-deleted rows older than cutoff for a given entity.
|
|
1840
1883
|
* Used by runPrune().
|
|
@@ -3372,7 +3415,7 @@ declare class PromptService {
|
|
|
3372
3415
|
degraded: DegradedRecord[];
|
|
3373
3416
|
groundingCorpus?: string[];
|
|
3374
3417
|
};
|
|
3375
|
-
buildOntologyBackfillPrompt(facts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null): {
|
|
3418
|
+
buildOntologyBackfillPrompt(facts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null, titleCatalog?: string): {
|
|
3376
3419
|
systemPrompt: string;
|
|
3377
3420
|
userPrompt: string;
|
|
3378
3421
|
};
|
|
@@ -4732,7 +4775,8 @@ declare class WikiMemory {
|
|
|
4732
4775
|
merge?: boolean;
|
|
4733
4776
|
}): Promise<ImportDumpResult>;
|
|
4734
4777
|
/**
|
|
4735
|
-
* Soft-delete facts and tasks by id, by source,
|
|
4778
|
+
* Soft-delete facts and tasks by id, by source, by source-pointer event id,
|
|
4779
|
+
* or all of them (`clearAll`).
|
|
4736
4780
|
* `clearAll` also deletes the entity's edges and its source-ref index rows.
|
|
4737
4781
|
* Add `includeEvents: true` to `clearAll` to hard-delete every event too,
|
|
4738
4782
|
* read or not, and reset the librarian's position: without it a later
|
|
@@ -1300,12 +1300,21 @@ interface ForgetParams {
|
|
|
1300
1300
|
* predecessor and successor reached by walking `superseded_by` links, capped
|
|
1301
1301
|
* at 100 per direction). The walk is NOT the connected component: with
|
|
1302
1302
|
* fan-in A→C←B, forgetting A reaches C but not B. The forward walk deletes
|
|
1303
|
-
* the live current fact. Does not compose with other selectors
|
|
1303
|
+
* the live current fact. Does not compose with other selectors (including
|
|
1304
|
+
* `eventId`).
|
|
1304
1305
|
*/
|
|
1305
1306
|
includeChain?: boolean;
|
|
1306
1307
|
taskId?: string;
|
|
1307
1308
|
sourceRef?: string;
|
|
1308
1309
|
sourceHash?: string;
|
|
1310
|
+
/**
|
|
1311
|
+
* Soft-delete every librarian fact whose `source_pointer` names this event
|
|
1312
|
+
* id (entity-scoped; exact match, no normalization — event ids are
|
|
1313
|
+
* engine-generated). Mutually exclusive with every other selector;
|
|
1314
|
+
* `clearAll` excludes it. Removal reports through the return value and the
|
|
1315
|
+
* per-row outbox DELETE events. See `specs/forget-by-event-id/` (issue #386).
|
|
1316
|
+
*/
|
|
1317
|
+
eventId?: string;
|
|
1309
1318
|
/** Soft-delete every fact and task of the entity, delete its edges, and delete its source-ref index rows. */
|
|
1310
1319
|
clearAll?: boolean;
|
|
1311
1320
|
/**
|
|
@@ -1525,6 +1534,13 @@ interface WikiInstructions {
|
|
|
1525
1534
|
ingest: string;
|
|
1526
1535
|
librarian: string;
|
|
1527
1536
|
heal: string;
|
|
1537
|
+
/**
|
|
1538
|
+
* Template only: the run-time prompt additionally carries a TITLE CATALOG
|
|
1539
|
+
* of the entity's typed node titles (appended after this text, before the
|
|
1540
|
+
* ontology block) whenever a catalog is built — see
|
|
1541
|
+
* `buildTitleCatalogBlock` and the data-scope note in the ontology-backfill
|
|
1542
|
+
* spec Errata (PR #425).
|
|
1543
|
+
*/
|
|
1528
1544
|
ontologyBackfill: string;
|
|
1529
1545
|
}
|
|
1530
1546
|
type MaintenanceJob = 'librarian' | 'heal' | 'reembed' | 'externalDeletions';
|
|
@@ -1835,6 +1851,33 @@ declare class EntryRepository extends BaseRepository {
|
|
|
1835
1851
|
* Returns the number of rows deleted.
|
|
1836
1852
|
*/
|
|
1837
1853
|
softDeleteBySource(entityId: string, tx: SQLiteAdapter, sourceRef?: string | null, sourceHash?: string | null): Promise<number>;
|
|
1854
|
+
/**
|
|
1855
|
+
* Shared JSON match predicate for source_pointer event ids
|
|
1856
|
+
* (specs/forget-by-event-id §D1). Every JSON call sits under the single
|
|
1857
|
+
* `json_valid` guard: unguarded JSON functions RAISE on malformed text, and
|
|
1858
|
+
* three-valued logic forces evaluation of AND operands after a NULL-guarded
|
|
1859
|
+
* term — a two-term form is only as safe as the planner's term-splitting.
|
|
1860
|
+
* The tombstone guard (`deleted_at IS NULL`) is added per-method.
|
|
1861
|
+
*/
|
|
1862
|
+
static readonly POINTER_EVENT_MATCH_SQL = "CASE WHEN json_valid(source_pointer)\n THEN json_type(source_pointer, '$.event_id') = 'text'\n AND json_extract(source_pointer, '$.event_id') = ?\n ELSE 0 END";
|
|
1863
|
+
/**
|
|
1864
|
+
* IDs of the entity's entries whose source_pointer names the event id.
|
|
1865
|
+
* `includeDeleted = true` returns live + tombstoned rows (the forget
|
|
1866
|
+
* enumeration superset for index sync and the ledger backstop).
|
|
1867
|
+
*/
|
|
1868
|
+
findIdsByPointerEvent(entityId: string, eventId: string, tx?: SQLiteAdapter, includeDeleted?: boolean): Promise<string[]>;
|
|
1869
|
+
/** Live-row count for the event id — dry-run only (a real call is idempotent over tombstones). */
|
|
1870
|
+
countLiveByPointerEvent(entityId: string, eventId: string, tx?: SQLiteAdapter): Promise<number>;
|
|
1871
|
+
/**
|
|
1872
|
+
* Soft-delete the entity's entries whose source_pointer names the event id,
|
|
1873
|
+
* within a transaction. Stages a DELETE outbox entry for each row that
|
|
1874
|
+
* changed, in the same transaction (parity with softDeleteBySource — synced
|
|
1875
|
+
* replicas learn of the tombstones through the outbox). The `deleted_at
|
|
1876
|
+
* IS NULL` guard makes the call idempotent: already-tombstoned rows are
|
|
1877
|
+
* no-op hits and are not counted. `tx` is REQUIRED.
|
|
1878
|
+
* Returns the number of rows deleted.
|
|
1879
|
+
*/
|
|
1880
|
+
softDeleteByPointerEvent(entityId: string, eventId: string, tx: SQLiteAdapter): Promise<number>;
|
|
1838
1881
|
/**
|
|
1839
1882
|
* Fetch IDs + entity_ids of soft-deleted rows older than cutoff for a given entity.
|
|
1840
1883
|
* Used by runPrune().
|
|
@@ -3372,7 +3415,7 @@ declare class PromptService {
|
|
|
3372
3415
|
degraded: DegradedRecord[];
|
|
3373
3416
|
groundingCorpus?: string[];
|
|
3374
3417
|
};
|
|
3375
|
-
buildOntologyBackfillPrompt(facts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null): {
|
|
3418
|
+
buildOntologyBackfillPrompt(facts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null, titleCatalog?: string): {
|
|
3376
3419
|
systemPrompt: string;
|
|
3377
3420
|
userPrompt: string;
|
|
3378
3421
|
};
|
|
@@ -4732,7 +4775,8 @@ declare class WikiMemory {
|
|
|
4732
4775
|
merge?: boolean;
|
|
4733
4776
|
}): Promise<ImportDumpResult>;
|
|
4734
4777
|
/**
|
|
4735
|
-
* Soft-delete facts and tasks by id, by source,
|
|
4778
|
+
* Soft-delete facts and tasks by id, by source, by source-pointer event id,
|
|
4779
|
+
* or all of them (`clearAll`).
|
|
4736
4780
|
* `clearAll` also deletes the entity's edges and its source-ref index rows.
|
|
4737
4781
|
* Add `includeEvents: true` to `clearAll` to hard-delete every event too,
|
|
4738
4782
|
* read or not, and reset the librarian's position: without it a later
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { aW as EmbeddingService, aX as ImportExportService, aY as IngestionService, aZ as JobManager, aZ as JobManagerType, a_ as MaintenanceService, a$ as RetrievalService, b0 as SearchService, b0 as SearchServiceType, aI as WikiMemoryTestAccess, b1 as WriteService } from './testing-
|
|
1
|
+
export { aW as EmbeddingService, aX as ImportExportService, aY as IngestionService, aZ as JobManager, aZ as JobManagerType, a_ as MaintenanceService, a$ as RetrievalService, b0 as SearchService, b0 as SearchServiceType, aI as WikiMemoryTestAccess, b1 as WriteService } from './testing-BZyrIoJp.mjs';
|
|
2
2
|
import '@equationalapplications/core-okf';
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { aW as EmbeddingService, aX as ImportExportService, aY as IngestionService, aZ as JobManager, aZ as JobManagerType, a_ as MaintenanceService, a$ as RetrievalService, b0 as SearchService, b0 as SearchServiceType, aI as WikiMemoryTestAccess, b1 as WriteService } from './testing-
|
|
1
|
+
export { aW as EmbeddingService, aX as ImportExportService, aY as IngestionService, aZ as JobManager, aZ as JobManagerType, a_ as MaintenanceService, a$ as RetrievalService, b0 as SearchService, b0 as SearchServiceType, aI as WikiMemoryTestAccess, b1 as WriteService } from './testing-BZyrIoJp.js';
|
|
2
2
|
import '@equationalapplications/core-okf';
|
package/dist/testing.js
CHANGED
|
@@ -36,10 +36,9 @@ var SQLITE_RESULT_CODE_NAMES = {
|
|
|
36
36
|
// 2067 = SQLITE_CONSTRAINT_UNIQUE — a UNIQUE index rejecting an INSERT/UPDATE.
|
|
37
37
|
// better-sqlite3 / node:sqlite enable extended result codes and report it
|
|
38
38
|
// directly. expo-sqlite never emits it (as of expo-sqlite 58.0.14, per
|
|
39
|
-
// #403): it leaves extended result codes off
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
// refines back to this name (#403).
|
|
39
|
+
// #403): it leaves extended result codes off and surfaces the same failure
|
|
40
|
+
// as the primary code 19 with the "UNIQUE constraint failed" message text,
|
|
41
|
+
// which `extractSqliteCode` below refines back to this name (#403).
|
|
43
42
|
2067: "SQLITE_CONSTRAINT_UNIQUE",
|
|
44
43
|
// 267 = SQLITE_CORRUPT_VTAB — a corrupt FTS5 shadow table (ftsCorruptionClass).
|
|
45
44
|
267: "SQLITE_CORRUPT_VTAB",
|
|
@@ -2413,6 +2412,47 @@ Return ONLY a valid JSON object matching this schema:
|
|
|
2413
2412
|
}
|
|
2414
2413
|
If no manifest type fits a fact, omit that fact from "classifications" entirely \u2014 do not guess.
|
|
2415
2414
|
When echoing an existing fact's title verbatim into "target_title", preserve every JSON escape sequence (\\", \\n, \\\\, \\/) exactly as it appeared in the input body \u2014 do not strip backslashes, do not add unescaped quotes. Do not return markdown, just raw JSON.`;
|
|
2415
|
+
var TITLE_CATALOG_MAX_ENTRIES = 200;
|
|
2416
|
+
function buildTitleCatalogBlock(rows) {
|
|
2417
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
2418
|
+
for (const r of rows) {
|
|
2419
|
+
if (typeof r.title !== "string" || r.title.length === 0) continue;
|
|
2420
|
+
if (typeof r.okf_type !== "string" || r.okf_type.length === 0) continue;
|
|
2421
|
+
byKey.set(normalizeTitleKey(r.title), { title: r.title, okf_type: r.okf_type });
|
|
2422
|
+
}
|
|
2423
|
+
const typed = [...byKey.values()].sort((a, b) => a.title < b.title ? -1 : a.title > b.title ? 1 : 0);
|
|
2424
|
+
const CHAR_BUDGET = 8e3;
|
|
2425
|
+
const listed = [];
|
|
2426
|
+
let used = 0;
|
|
2427
|
+
for (const r of typed) {
|
|
2428
|
+
const line = `- ${JSON.stringify(r.title)} (${r.okf_type})`;
|
|
2429
|
+
if (line.length + 1 > CHAR_BUDGET) continue;
|
|
2430
|
+
if (listed.length >= TITLE_CATALOG_MAX_ENTRIES) break;
|
|
2431
|
+
if (used + line.length + 1 > CHAR_BUDGET) continue;
|
|
2432
|
+
listed.push(r);
|
|
2433
|
+
used += line.length + 1;
|
|
2434
|
+
}
|
|
2435
|
+
const truncated = typed.length > listed.length;
|
|
2436
|
+
if (typed.length === 0) {
|
|
2437
|
+
return [
|
|
2438
|
+
"TITLE CATALOG: this memory contains no typed nodes yet.",
|
|
2439
|
+
'A fact classified in this same response is a valid "target_title" once typed. Otherwise omit "edges" rather than invent a target_title.'
|
|
2440
|
+
].join("\n");
|
|
2441
|
+
}
|
|
2442
|
+
if (listed.length === 0) {
|
|
2443
|
+
return [
|
|
2444
|
+
"TITLE CATALOG: existing typed nodes exist in this memory, but none fit the catalog budget.",
|
|
2445
|
+
'A fact classified in this same response is a valid "target_title" once typed. Otherwise omit "edges" rather than invent a target_title.'
|
|
2446
|
+
].join("\n");
|
|
2447
|
+
}
|
|
2448
|
+
const catalog = listed.map((r) => `- ${JSON.stringify(r.title)} (${r.okf_type})`).join("\n");
|
|
2449
|
+
return [
|
|
2450
|
+
"TITLE CATALOG: existing typed nodes in this memory include:",
|
|
2451
|
+
catalog,
|
|
2452
|
+
...truncated ? ["(This list is truncated; more typed nodes exist than are shown here.)"] : [],
|
|
2453
|
+
'A "target_title" may be copied verbatim from this catalog, or be another fact classified in this same response. If no valid target exists, omit "edges" rather than invent a target_title.'
|
|
2454
|
+
].join("\n");
|
|
2455
|
+
}
|
|
2416
2456
|
var GROUNDING_SOURCE = {
|
|
2417
2457
|
ingest: { key: "facts", source: "the document chunk" },
|
|
2418
2458
|
librarian: { key: "facts", source: 'the "summary" text of the events' },
|
|
@@ -2743,7 +2783,7 @@ The following document anchors are provided for contradiction detection only. Do
|
|
|
2743
2783
|
...corpusField
|
|
2744
2784
|
};
|
|
2745
2785
|
}
|
|
2746
|
-
buildOntologyBackfillPrompt(facts, runtimeOverride, ontologyContext) {
|
|
2786
|
+
buildOntologyBackfillPrompt(facts, runtimeOverride, ontologyContext, titleCatalog) {
|
|
2747
2787
|
const template = runtimeOverride ?? this.globalOverrides?.ontologyBackfillSystemPrompt ?? ONTOLOGY_BACKFILL_SYSTEM_PROMPT;
|
|
2748
2788
|
const hasFacts = /\{\{\s*facts\s*\}\}/.test(template);
|
|
2749
2789
|
if (hasFacts || this.hasOntologyPlaceholders(template)) {
|
|
@@ -2753,8 +2793,11 @@ The following document anchors are provided for contradiction detection only. Do
|
|
|
2753
2793
|
${JSON.stringify(facts, null, 2)}`
|
|
2754
2794
|
};
|
|
2755
2795
|
}
|
|
2796
|
+
const effective = titleCatalog !== void 0 ? `${template}
|
|
2797
|
+
|
|
2798
|
+
${titleCatalog}` : template;
|
|
2756
2799
|
return {
|
|
2757
|
-
systemPrompt: this.appendOntology(
|
|
2800
|
+
systemPrompt: this.appendOntology(effective, ontologyContext),
|
|
2758
2801
|
userPrompt: `Facts:
|
|
2759
2802
|
${JSON.stringify(facts, null, 2)}`
|
|
2760
2803
|
};
|
|
@@ -6069,15 +6112,21 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
6069
6112
|
}
|
|
6070
6113
|
}
|
|
6071
6114
|
async forget(entityId, params, opts) {
|
|
6072
|
-
if (params.clearAll && (params.entryId !== void 0 || params.taskId !== void 0 || params.sourceRef !== void 0 || params.sourceHash !== void 0)) {
|
|
6073
|
-
throw new Error("forget() clearAll is mutually exclusive with entryId, taskId, sourceRef, and
|
|
6115
|
+
if (params.clearAll && (params.entryId !== void 0 || params.taskId !== void 0 || params.sourceRef !== void 0 || params.sourceHash !== void 0 || params.eventId !== void 0)) {
|
|
6116
|
+
throw new Error("forget() clearAll is mutually exclusive with entryId, taskId, sourceRef, sourceHash, and eventId");
|
|
6074
6117
|
}
|
|
6075
6118
|
if (params.includeEvents && !params.clearAll) {
|
|
6076
6119
|
throw new Error("forget() includeEvents requires clearAll: true");
|
|
6077
6120
|
}
|
|
6078
|
-
if (params.includeChain && (params.entryId === void 0 || params.clearAll || params.taskId !== void 0 || params.sourceRef !== void 0 || params.sourceHash !== void 0)) {
|
|
6121
|
+
if (params.includeChain && (params.entryId === void 0 || params.clearAll || params.taskId !== void 0 || params.sourceRef !== void 0 || params.sourceHash !== void 0 || params.eventId !== void 0)) {
|
|
6079
6122
|
throw new Error("forget() includeChain composes only with entryId");
|
|
6080
6123
|
}
|
|
6124
|
+
if (params.eventId !== void 0 && (params.entryId !== void 0 || params.taskId !== void 0 || params.sourceRef !== void 0 || params.sourceHash !== void 0)) {
|
|
6125
|
+
throw new Error("forget() eventId is mutually exclusive with entryId, taskId, sourceRef, and sourceHash");
|
|
6126
|
+
}
|
|
6127
|
+
if (params.eventId !== void 0 && (typeof params.eventId !== "string" || params.eventId === "")) {
|
|
6128
|
+
throw new Error("Invalid eventId");
|
|
6129
|
+
}
|
|
6081
6130
|
if (opts?.dryRun === true) {
|
|
6082
6131
|
return this.forgetDryRun(entityId, params);
|
|
6083
6132
|
}
|
|
@@ -6145,14 +6194,19 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
6145
6194
|
if (sourceRef || sourceHash) {
|
|
6146
6195
|
for (const id of await this.entryRepo.findIdsBySource(entityId, sourceRef, sourceHash, tx, true)) deletedEntryIds.push(id);
|
|
6147
6196
|
}
|
|
6197
|
+
if (params.eventId !== void 0) {
|
|
6198
|
+
for (const id of await this.entryRepo.findIdsByPointerEvent(entityId, params.eventId, tx, true)) deletedEntryIds.push(id);
|
|
6199
|
+
}
|
|
6148
6200
|
const entryPromise = params.entryId ? this.entryRepo.softDelete(params.entryId, entityId, tx).then((r) => r.changes > 0) : null;
|
|
6149
6201
|
const taskDeletedPromise = params.taskId ? this.taskRepo.softDeleteById(params.taskId, entityId, tx).then((r) => r.changes > 0) : null;
|
|
6150
6202
|
const refPromise = sourceRef || sourceHash ? this.entryRepo.softDeleteBySource(entityId, tx, sourceRef, sourceHash) : null;
|
|
6203
|
+
const pointerPromise = params.eventId !== void 0 ? this.entryRepo.softDeleteByPointerEvent(entityId, params.eventId, tx) : null;
|
|
6151
6204
|
const sourceRefIndexPromise = touchSourceRefIndex && sourceRef ? this.sourceRefIndexRepo.softDeleteByEntityAndSourceRef(entityId, sourceRef, tx).then(() => void 0) : null;
|
|
6152
|
-
const [entryResult, taskResult, refResult] = await Promise.all([
|
|
6205
|
+
const [entryResult, taskResult, refResult, pointerResult] = await Promise.all([
|
|
6153
6206
|
entryPromise ?? Promise.resolve(false),
|
|
6154
6207
|
taskDeletedPromise ?? Promise.resolve(false),
|
|
6155
6208
|
refPromise ?? Promise.resolve(0),
|
|
6209
|
+
pointerPromise ?? Promise.resolve(0),
|
|
6156
6210
|
sourceRefIndexPromise ?? Promise.resolve(void 0)
|
|
6157
6211
|
]);
|
|
6158
6212
|
if (entryResult) deletedEntries++;
|
|
@@ -6161,6 +6215,7 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
6161
6215
|
}
|
|
6162
6216
|
if (taskResult) deletedTasks++;
|
|
6163
6217
|
deletedEntries += refResult;
|
|
6218
|
+
deletedEntries += pointerResult;
|
|
6164
6219
|
}
|
|
6165
6220
|
if (ledgerOn && this.vectorRemoval?.gate() === "hook" && deletedEntryIds.length > 0) {
|
|
6166
6221
|
await this.vectorRemovalRepo?.backstopEnqueue(entityId, Array.from(new Set(deletedEntryIds)), now, tx);
|
|
@@ -6306,7 +6361,7 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
6306
6361
|
return out;
|
|
6307
6362
|
}
|
|
6308
6363
|
if (params.entryId !== void 0 || params.taskId !== void 0) {
|
|
6309
|
-
throw new Error("forget({ dryRun: true }) does not support entryId/taskId selectors (entryId is accepted only with includeChain); use sourceRef/sourceHash or clearAll");
|
|
6364
|
+
throw new Error("forget({ dryRun: true }) does not support entryId/taskId selectors (entryId is accepted only with includeChain); use sourceRef/sourceHash, eventId, or clearAll");
|
|
6310
6365
|
}
|
|
6311
6366
|
if (params.clearAll) {
|
|
6312
6367
|
const entries2 = await this.entryRepo.countLiveByEntityId(entityId);
|
|
@@ -6317,6 +6372,10 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
6317
6372
|
}
|
|
6318
6373
|
return { deleted: { entries: entries2, tasks }, metadataReset: true };
|
|
6319
6374
|
}
|
|
6375
|
+
if (params.eventId !== void 0) {
|
|
6376
|
+
const entries2 = await this.entryRepo.countLiveByPointerEvent(entityId, params.eventId);
|
|
6377
|
+
return { deleted: { entries: entries2, tasks: 0 } };
|
|
6378
|
+
}
|
|
6320
6379
|
const sourceRef = params.sourceRef !== void 0 ? normalizeSourceRef(params.sourceRef) : null;
|
|
6321
6380
|
if (params.sourceRef !== void 0 && !sourceRef) throw new Error("Invalid sourceRef");
|
|
6322
6381
|
const sourceHash = params.sourceHash !== void 0 ? normalizeSourceHash(params.sourceHash) : null;
|
|
@@ -6723,11 +6782,14 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
6723
6782
|
}
|
|
6724
6783
|
}
|
|
6725
6784
|
const ontologyContext = await ontologyService.buildPromptContext(entityId);
|
|
6785
|
+
const titleRows = await this.entryRepo.findTitleIndexByEntityId(entityId);
|
|
6786
|
+
const titleCatalog = buildTitleCatalogBlock(titleRows);
|
|
6726
6787
|
const toPromptShape = (f) => ({ id: f.id, title: f.title, body: f.body, tags: f.tags });
|
|
6727
6788
|
const buildPrompt = (facts) => this.promptService.buildOntologyBackfillPrompt(
|
|
6728
6789
|
facts.map(toPromptShape),
|
|
6729
6790
|
options?.promptOverride,
|
|
6730
|
-
ontologyContext
|
|
6791
|
+
ontologyContext,
|
|
6792
|
+
titleCatalog
|
|
6731
6793
|
);
|
|
6732
6794
|
const outcome = await runBatched({
|
|
6733
6795
|
items: candidates,
|