@equationalapplications/core-llm-wiki 8.2.0 → 8.3.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 +1 -1
- package/dist/{chunk-FOX6TNFO.mjs → chunk-V432RHCG.mjs} +239 -29
- package/dist/chunk-V432RHCG.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +108 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -183
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-D6So3dKX.d.mts → testing-BT5qSnGB.d.mts} +57 -34
- package/dist/{testing-D6So3dKX.d.ts → testing-BT5qSnGB.d.ts} +57 -34
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +245 -16
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-FOX6TNFO.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Platform-agnostic TypeScript engine for hybrid LLM memory. Features episodic fac
|
|
|
19
19
|
- **Hybrid retrieval.** Vector cosine ranking with a keyword fallback (SQLite FTS5 or in-memory MiniSearch), [tunable](https://equationalapplications.github.io/expo-llm-wiki/guides/tune-retrieval/) per call.
|
|
20
20
|
- **Multi-entity reads.** Search several namespaces in one pass with `tierWeights` and `tierFloors`.
|
|
21
21
|
- **GraphRAG.** Per-entity [seeded ontologies](https://equationalapplications.github.io/expo-llm-wiki/guides/ontologies/) (Strict, Emergent or Off) and SQL-only [graph traversal](https://equationalapplications.github.io/expo-llm-wiki/guides/graphrag/).
|
|
22
|
-
- **
|
|
22
|
+
- **Maintenance.** Librarian, heal, reembed and prune jobs. By default you run them on your own schedule ([deferred](https://equationalapplications.github.io/expo-llm-wiki/guides/maintenance/)), or set `maintenance: 'auto'` to have `write()` start the librarian and heal (reembed and prune stay on your schedule).
|
|
23
23
|
- **Temporal facts, drafts and grounding** for [trust and provenance](https://equationalapplications.github.io/expo-llm-wiki/concepts/trust-and-provenance/).
|
|
24
24
|
- **OKF v0.1 and v0.2** [import and export](https://equationalapplications.github.io/expo-llm-wiki/guides/okf/).
|
|
25
25
|
- **Diagnostics.** An optional `onDiagnostic` hook with typed, content-free reports.
|
|
@@ -3109,6 +3109,201 @@ var BaseRepository = class {
|
|
|
3109
3109
|
}
|
|
3110
3110
|
};
|
|
3111
3111
|
|
|
3112
|
+
// src/utils/temporal.ts
|
|
3113
|
+
function liveAtSql(mode, alias = "") {
|
|
3114
|
+
const from = mode === "asOf" ? `COALESCE(${alias}valid_from, ${alias}created_at) <= ?` : `(${alias}valid_from IS NULL OR ${alias}valid_from <= ?)`;
|
|
3115
|
+
return `(${from} AND (${alias}valid_to IS NULL OR ${alias}valid_to > ?))`;
|
|
3116
|
+
}
|
|
3117
|
+
function isLiveAt(f, mode, t) {
|
|
3118
|
+
if (f.deleted_at != null) return false;
|
|
3119
|
+
const from = mode === "asOf" ? f.valid_from ?? f.created_at : f.valid_from;
|
|
3120
|
+
if (from != null && from > t) return false;
|
|
3121
|
+
return f.valid_to == null || f.valid_to > t;
|
|
3122
|
+
}
|
|
3123
|
+
function assertEpochMs(name, v) {
|
|
3124
|
+
if (typeof v !== "number" || !Number.isFinite(v) || v < 0) {
|
|
3125
|
+
throw new TypeError(`${name} must be a finite epoch-ms number >= 0`);
|
|
3126
|
+
}
|
|
3127
|
+
return Math.trunc(v);
|
|
3128
|
+
}
|
|
3129
|
+
|
|
3130
|
+
// src/repositories/EdgeRepository.ts
|
|
3131
|
+
var CONFIDENCE_RANK = {
|
|
3132
|
+
tentative: 0,
|
|
3133
|
+
inferred: 1,
|
|
3134
|
+
certain: 2
|
|
3135
|
+
};
|
|
3136
|
+
var EdgeRepository = class extends BaseRepository {
|
|
3137
|
+
/**
|
|
3138
|
+
* Insert an edge, silently skipping on primary-key or uniqueness conflicts.
|
|
3139
|
+
* Returns true when a row was inserted, false when skipped as a duplicate.
|
|
3140
|
+
* Throws when the insert was skipped due to an id collision with a different edge tuple.
|
|
3141
|
+
*/
|
|
3142
|
+
async addIgnoreDuplicate(edge, tx) {
|
|
3143
|
+
const executor = this.getExecutor(tx);
|
|
3144
|
+
const result = await executor.runAsync(
|
|
3145
|
+
`INSERT OR IGNORE INTO ${this.prefix}edges (id, entity_id, source_id, target_id, edge_type, created_at)
|
|
3146
|
+
VALUES (?, ?, ?, ?, ?, ?)`,
|
|
3147
|
+
[edge.id, edge.entity_id, edge.source_id, edge.target_id, edge.edge_type, edge.created_at]
|
|
3148
|
+
);
|
|
3149
|
+
if (result.changes > 0) return true;
|
|
3150
|
+
const existing = await executor.getFirstAsync(
|
|
3151
|
+
`SELECT entity_id, source_id, target_id, edge_type FROM ${this.prefix}edges WHERE id = ?`,
|
|
3152
|
+
[edge.id]
|
|
3153
|
+
);
|
|
3154
|
+
if (!existing) return false;
|
|
3155
|
+
if (String(existing.entity_id) !== edge.entity_id || String(existing.source_id) !== edge.source_id || String(existing.target_id) !== edge.target_id || String(existing.edge_type) !== edge.edge_type) {
|
|
3156
|
+
throw new Error(
|
|
3157
|
+
`Edge id collision: ${JSON.stringify(edge.id)} already exists with a different (entity_id, source_id, target_id, edge_type) tuple`
|
|
3158
|
+
);
|
|
3159
|
+
}
|
|
3160
|
+
return false;
|
|
3161
|
+
}
|
|
3162
|
+
async getByEntityId(entityId, tx) {
|
|
3163
|
+
const executor = this.getExecutor(tx);
|
|
3164
|
+
const rows = await executor.getAllAsync(
|
|
3165
|
+
`SELECT * FROM ${this.prefix}edges WHERE entity_id = ? ORDER BY created_at ASC`,
|
|
3166
|
+
[entityId]
|
|
3167
|
+
);
|
|
3168
|
+
return rows.map(mapRowToEdge);
|
|
3169
|
+
}
|
|
3170
|
+
/** Hard delete — edges have no soft-delete concept, only presence/absence. `tx` is REQUIRED. */
|
|
3171
|
+
async bulkDeleteByEntityId(entityId, tx) {
|
|
3172
|
+
const executor = this.getExecutor(tx);
|
|
3173
|
+
await executor.runAsync(`DELETE FROM ${this.prefix}edges WHERE entity_id = ?`, [entityId]);
|
|
3174
|
+
}
|
|
3175
|
+
/**
|
|
3176
|
+
* Hard-delete every edge whose `source_id` is in `sourceFactIds`, scoped to
|
|
3177
|
+
* `entityId`. Returns the number of rows deleted. Edges have no soft-delete
|
|
3178
|
+
* concept; this method is named `softDeleteBySourceFactIds` for symmetry with
|
|
3179
|
+
* `EntryRepository.softDeleteBySource` (which IS a soft delete), but its
|
|
3180
|
+
* semantics are immediate presence/absence removal. Use ONLY inside an open
|
|
3181
|
+
* transaction — the method requires `tx` and performs no autocommit.
|
|
3182
|
+
*
|
|
3183
|
+
* Used by `IngestionService.upsertGraphCore` to retire the prior parse's
|
|
3184
|
+
* edges whose source facts are being superseded by `softDeleteBySource`.
|
|
3185
|
+
*/
|
|
3186
|
+
async softDeleteBySourceFactIds(entityId, sourceFactIds, tx) {
|
|
3187
|
+
if (sourceFactIds.length === 0) return 0;
|
|
3188
|
+
const executor = this.getExecutor(tx);
|
|
3189
|
+
const chunkSize = 500;
|
|
3190
|
+
let totalChanges = 0;
|
|
3191
|
+
for (let i = 0; i < sourceFactIds.length; i += chunkSize) {
|
|
3192
|
+
const chunk = sourceFactIds.slice(i, i + chunkSize);
|
|
3193
|
+
const placeholders = chunk.map(() => "?").join(",");
|
|
3194
|
+
const result = await executor.runAsync(
|
|
3195
|
+
`DELETE FROM ${this.prefix}edges
|
|
3196
|
+
WHERE entity_id = ? AND source_id IN (${placeholders})`,
|
|
3197
|
+
[entityId, ...chunk]
|
|
3198
|
+
);
|
|
3199
|
+
totalChanges += result.changes;
|
|
3200
|
+
}
|
|
3201
|
+
return totalChanges;
|
|
3202
|
+
}
|
|
3203
|
+
/**
|
|
3204
|
+
* Multi-hop traversal from `sourceId` via SQLite `WITH RECURSIVE`. All filtering,
|
|
3205
|
+
* dead-ending, cycle-guarding, capping, and ordering happens in this one query.
|
|
3206
|
+
* The anchor is validated (exists, right entity, not soft-deleted) but never gated
|
|
3207
|
+
* by confidence/source_type — only nodes discovered beyond it are.
|
|
3208
|
+
*/
|
|
3209
|
+
async getNeighborhood(entityId, sourceId, opts, tx) {
|
|
3210
|
+
const executor = this.getExecutor(tx);
|
|
3211
|
+
if (opts.edgeTypes && opts.edgeTypes.length === 0) {
|
|
3212
|
+
const anchor = await executor.getFirstAsync(
|
|
3213
|
+
`SELECT id FROM ${this.prefix}entries WHERE id = ? AND entity_id = ? AND deleted_at IS NULL`,
|
|
3214
|
+
[sourceId, entityId]
|
|
3215
|
+
);
|
|
3216
|
+
return { nodeIds: anchor ? [anchor.id] : [], edges: [] };
|
|
3217
|
+
}
|
|
3218
|
+
const edgeTypesClause = opts.edgeTypes ? `e.edge_type IN (${opts.edgeTypes.map(() => "?").join(",")})` : "1=1";
|
|
3219
|
+
const excludeSourceTypesPlaceholders = opts.excludeSourceTypes.map(() => "?").join(",");
|
|
3220
|
+
const minConfidenceRank = CONFIDENCE_RANK[opts.minConfidence];
|
|
3221
|
+
const sql = `
|
|
3222
|
+
WITH RECURSIVE walk(node_id, depth, visited) AS (
|
|
3223
|
+
SELECT id, 0, ',' || id || ','
|
|
3224
|
+
FROM ${this.prefix}entries
|
|
3225
|
+
WHERE id = ? AND entity_id = ? AND deleted_at IS NULL
|
|
3226
|
+
|
|
3227
|
+
UNION
|
|
3228
|
+
|
|
3229
|
+
SELECT
|
|
3230
|
+
CASE WHEN e.source_id = w.node_id THEN e.target_id ELSE e.source_id END,
|
|
3231
|
+
w.depth + 1,
|
|
3232
|
+
w.visited || (CASE WHEN e.source_id = w.node_id THEN e.target_id ELSE e.source_id END) || ','
|
|
3233
|
+
FROM walk w
|
|
3234
|
+
JOIN ${this.prefix}edges e
|
|
3235
|
+
ON e.entity_id = ?
|
|
3236
|
+
AND (
|
|
3237
|
+
(? != 'inbound' AND e.source_id = w.node_id) OR
|
|
3238
|
+
(? != 'outbound' AND e.target_id = w.node_id)
|
|
3239
|
+
)
|
|
3240
|
+
AND (${edgeTypesClause})
|
|
3241
|
+
JOIN ${this.prefix}entries n
|
|
3242
|
+
ON n.id = (CASE WHEN e.source_id = w.node_id THEN e.target_id ELSE e.source_id END)
|
|
3243
|
+
AND n.entity_id = ?
|
|
3244
|
+
AND n.deleted_at IS NULL
|
|
3245
|
+
AND (
|
|
3246
|
+
CASE n.confidence
|
|
3247
|
+
WHEN 'tentative' THEN 0
|
|
3248
|
+
WHEN 'inferred' THEN 1
|
|
3249
|
+
WHEN 'certain' THEN 2
|
|
3250
|
+
ELSE -1
|
|
3251
|
+
END
|
|
3252
|
+
) >= ?
|
|
3253
|
+
AND n.source_type NOT IN (${excludeSourceTypesPlaceholders})
|
|
3254
|
+
AND (? = 0 OR n.lifecycle_status != 'draft')
|
|
3255
|
+
AND ${liveAtSql(opts.live.mode, "n.")}
|
|
3256
|
+
WHERE w.depth < ?
|
|
3257
|
+
AND instr(w.visited, ',' || (CASE WHEN e.source_id = w.node_id THEN e.target_id ELSE e.source_id END) || ',') = 0
|
|
3258
|
+
)
|
|
3259
|
+
SELECT node_id, MIN(depth) AS depth
|
|
3260
|
+
FROM walk
|
|
3261
|
+
GROUP BY node_id
|
|
3262
|
+
ORDER BY depth ASC, (SELECT updated_at FROM ${this.prefix}entries WHERE id = node_id) DESC
|
|
3263
|
+
LIMIT ?
|
|
3264
|
+
`;
|
|
3265
|
+
const params = [
|
|
3266
|
+
sourceId,
|
|
3267
|
+
entityId,
|
|
3268
|
+
entityId,
|
|
3269
|
+
opts.direction,
|
|
3270
|
+
opts.direction,
|
|
3271
|
+
...opts.edgeTypes ?? [],
|
|
3272
|
+
entityId,
|
|
3273
|
+
minConfidenceRank,
|
|
3274
|
+
...opts.excludeSourceTypes,
|
|
3275
|
+
opts.excludeDrafts === true ? 1 : 0,
|
|
3276
|
+
opts.live.t,
|
|
3277
|
+
opts.live.t,
|
|
3278
|
+
opts.maxDepth,
|
|
3279
|
+
opts.maxNodes
|
|
3280
|
+
];
|
|
3281
|
+
const rows = await executor.getAllAsync(sql, params);
|
|
3282
|
+
const nodeIds = rows.map((r) => r.node_id);
|
|
3283
|
+
if (nodeIds.length === 0) return { nodeIds: [], edges: [] };
|
|
3284
|
+
const valueRows = nodeIds.map(() => "(?)").join(", ");
|
|
3285
|
+
const edgeRows = await executor.getAllAsync(
|
|
3286
|
+
`WITH neighborhood(node_id) AS (VALUES ${valueRows})
|
|
3287
|
+
SELECT e.* FROM ${this.prefix}edges e
|
|
3288
|
+
JOIN neighborhood ns ON e.source_id = ns.node_id
|
|
3289
|
+
JOIN neighborhood nt ON e.target_id = nt.node_id
|
|
3290
|
+
WHERE e.entity_id = ?`,
|
|
3291
|
+
[...nodeIds, entityId]
|
|
3292
|
+
);
|
|
3293
|
+
return { nodeIds, edges: edgeRows.map(mapRowToEdge) };
|
|
3294
|
+
}
|
|
3295
|
+
};
|
|
3296
|
+
function mapRowToEdge(row) {
|
|
3297
|
+
return {
|
|
3298
|
+
id: String(row.id),
|
|
3299
|
+
entity_id: String(row.entity_id),
|
|
3300
|
+
source_id: String(row.source_id),
|
|
3301
|
+
target_id: String(row.target_id),
|
|
3302
|
+
edge_type: String(row.edge_type),
|
|
3303
|
+
created_at: Number(row.created_at)
|
|
3304
|
+
};
|
|
3305
|
+
}
|
|
3306
|
+
|
|
3112
3307
|
// src/repositories/MetadataRepository.ts
|
|
3113
3308
|
function entitySummaryMetaKey(entityId) {
|
|
3114
3309
|
return `entity_summary:${entityId}`;
|
|
@@ -4472,7 +4667,9 @@ async function runExtract(deps, ctx, batch) {
|
|
|
4472
4667
|
const base = { entityId, operation: "librarian", trigger };
|
|
4473
4668
|
const diagnostics = [];
|
|
4474
4669
|
const byLabel = new Map(batch.map((l) => [l.label, l]));
|
|
4475
|
-
|
|
4670
|
+
let newestAt = batch[0].at;
|
|
4671
|
+
for (const l of batch) if (l.at > newestAt) newestAt = l.at;
|
|
4672
|
+
const defaultValidFrom = Math.min(newestAt, Date.now());
|
|
4476
4673
|
const candidates = [];
|
|
4477
4674
|
(Array.isArray(parsed.facts) ? parsed.facts : []).forEach((raw, index) => {
|
|
4478
4675
|
const fact = validateFact(raw);
|
|
@@ -4482,7 +4679,7 @@ async function runExtract(deps, ctx, batch) {
|
|
|
4482
4679
|
}
|
|
4483
4680
|
const r = raw;
|
|
4484
4681
|
const sourceLabel = typeof r.source_event === "string" && byLabel.has(r.source_event) ? r.source_event : null;
|
|
4485
|
-
const validFrom = parseValidFrom(r.valid_from) ?? (sourceLabel ? byLabel.get(sourceLabel).at :
|
|
4682
|
+
const validFrom = parseValidFrom(r.valid_from) ?? (sourceLabel ? byLabel.get(sourceLabel).at : defaultValidFrom);
|
|
4486
4683
|
candidates.push({ index, fact, sourceLabel, validFrom });
|
|
4487
4684
|
});
|
|
4488
4685
|
const tasks = [];
|
|
@@ -4671,24 +4868,6 @@ async function runResolve(deps, ctx, ambiguous) {
|
|
|
4671
4868
|
return out;
|
|
4672
4869
|
}
|
|
4673
4870
|
|
|
4674
|
-
// src/utils/temporal.ts
|
|
4675
|
-
function liveAtSql(mode, alias = "") {
|
|
4676
|
-
const from = mode === "asOf" ? `COALESCE(${alias}valid_from, ${alias}created_at) <= ?` : `(${alias}valid_from IS NULL OR ${alias}valid_from <= ?)`;
|
|
4677
|
-
return `(${from} AND (${alias}valid_to IS NULL OR ${alias}valid_to > ?))`;
|
|
4678
|
-
}
|
|
4679
|
-
function isLiveAt(f, mode, t) {
|
|
4680
|
-
if (f.deleted_at != null) return false;
|
|
4681
|
-
const from = mode === "asOf" ? f.valid_from ?? f.created_at : f.valid_from;
|
|
4682
|
-
if (from != null && from > t) return false;
|
|
4683
|
-
return f.valid_to == null || f.valid_to > t;
|
|
4684
|
-
}
|
|
4685
|
-
function assertEpochMs(name, v) {
|
|
4686
|
-
if (typeof v !== "number" || !Number.isFinite(v) || v < 0) {
|
|
4687
|
-
throw new TypeError(`${name} must be a finite epoch-ms number >= 0`);
|
|
4688
|
-
}
|
|
4689
|
-
return Math.trunc(v);
|
|
4690
|
-
}
|
|
4691
|
-
|
|
4692
4871
|
// src/services/TemporalService.ts
|
|
4693
4872
|
var HISTORY_MAX_DEPTH = 100;
|
|
4694
4873
|
var TemporalService = class {
|
|
@@ -5070,7 +5249,7 @@ var formatSkipError = (err) => {
|
|
|
5070
5249
|
return base;
|
|
5071
5250
|
};
|
|
5072
5251
|
var MaintenanceService = class {
|
|
5073
|
-
constructor(db, prefix, options, entryRepo, sourceRefIndexRepo, taskRepo, eventRepo, metadataRepo, searchService, jobManager, embeddingService, promptService, ontologyService) {
|
|
5252
|
+
constructor(db, prefix, options, entryRepo, sourceRefIndexRepo, taskRepo, eventRepo, metadataRepo, searchService, jobManager, embeddingService, promptService, ontologyService, edgeRepo) {
|
|
5074
5253
|
this.db = db;
|
|
5075
5254
|
this.prefix = prefix;
|
|
5076
5255
|
this.options = options;
|
|
@@ -5084,6 +5263,7 @@ var MaintenanceService = class {
|
|
|
5084
5263
|
this.embeddingService = embeddingService;
|
|
5085
5264
|
this.ontologyService = ontologyService;
|
|
5086
5265
|
this.promptService = promptService ?? new PromptService(this.options.config?.prompts, resolveGrounding(this.options.config?.grounding));
|
|
5266
|
+
this.edgeRepo = edgeRepo ?? new EdgeRepository(this.db, this.prefix);
|
|
5087
5267
|
}
|
|
5088
5268
|
async runPrune(entityId, options) {
|
|
5089
5269
|
this.jobManager.acquireLock("prune", entityId);
|
|
@@ -5314,6 +5494,9 @@ var MaintenanceService = class {
|
|
|
5314
5494
|
if (params.clearAll && (params.entryId !== void 0 || params.taskId !== void 0 || params.sourceRef !== void 0 || params.sourceHash !== void 0)) {
|
|
5315
5495
|
throw new Error("forget() clearAll is mutually exclusive with entryId, taskId, sourceRef, and sourceHash");
|
|
5316
5496
|
}
|
|
5497
|
+
if (params.includeEvents && !params.clearAll) {
|
|
5498
|
+
throw new Error("forget() includeEvents requires clearAll: true");
|
|
5499
|
+
}
|
|
5317
5500
|
if (opts?.dryRun === true) {
|
|
5318
5501
|
return this.forgetDryRun(entityId, params);
|
|
5319
5502
|
}
|
|
@@ -5322,13 +5505,23 @@ var MaintenanceService = class {
|
|
|
5322
5505
|
const now = Date.now();
|
|
5323
5506
|
let deletedEntries = 0;
|
|
5324
5507
|
let deletedTasks = 0;
|
|
5508
|
+
let deletedEvents = 0;
|
|
5325
5509
|
const deletedEntryIds = [];
|
|
5326
5510
|
await this.db.withTransactionAsync(async (tx) => {
|
|
5327
5511
|
if (params.clearAll) {
|
|
5328
|
-
|
|
5512
|
+
for (const id of await this.entryRepo.findIdsBySource(entityId, null, null, tx, true)) deletedEntryIds.push(id);
|
|
5329
5513
|
deletedEntries = await this.entryRepo.bulkSoftDeleteByEntityId(entityId, tx);
|
|
5330
5514
|
deletedTasks = await this.taskRepo.bulkSoftDeleteByEntityId(entityId, tx);
|
|
5331
|
-
await this.
|
|
5515
|
+
if (await this.sourceRefIndexPresent(tx)) {
|
|
5516
|
+
await this.sourceRefIndexRepo.deleteByEntityId(entityId, tx);
|
|
5517
|
+
}
|
|
5518
|
+
await this.edgeRepo.bulkDeleteByEntityId(entityId, tx);
|
|
5519
|
+
if (params.includeEvents) {
|
|
5520
|
+
deletedEvents = (await this.eventRepo.deleteByEntityId(entityId, tx)).changes;
|
|
5521
|
+
await this.metadataRepo.deleteCheckpoint(entityId, tx);
|
|
5522
|
+
} else {
|
|
5523
|
+
await this.metadataRepo.updateCheckpoint(entityId, { memory: 0, heal: 0 }, tx);
|
|
5524
|
+
}
|
|
5332
5525
|
await this.metadataRepo.deleteMeta(entitySummaryMetaKey(entityId), tx);
|
|
5333
5526
|
} else {
|
|
5334
5527
|
const hasIdSelectors = params.entryId !== void 0 || params.taskId !== void 0;
|
|
@@ -5346,7 +5539,7 @@ var MaintenanceService = class {
|
|
|
5346
5539
|
if (entryId) deletedEntryIds.push(entryId);
|
|
5347
5540
|
}
|
|
5348
5541
|
if (sourceRef || sourceHash) {
|
|
5349
|
-
|
|
5542
|
+
for (const id of await this.entryRepo.findIdsBySource(entityId, sourceRef, sourceHash, tx, true)) deletedEntryIds.push(id);
|
|
5350
5543
|
}
|
|
5351
5544
|
const entryPromise = params.entryId ? this.entryRepo.softDelete(params.entryId, entityId, tx).then((r) => r.changes > 0) : null;
|
|
5352
5545
|
const taskDeletedPromise = params.taskId ? this.taskRepo.softDeleteById(params.taskId, entityId, tx).then((r) => r.changes > 0) : null;
|
|
@@ -5380,7 +5573,8 @@ var MaintenanceService = class {
|
|
|
5380
5573
|
throw new Error(`forget(${entityId}/${factId}) failed: ANN cleanup hook rejected`, { cause: this._sanitizeRankerError(hookErr) });
|
|
5381
5574
|
}
|
|
5382
5575
|
}
|
|
5383
|
-
|
|
5576
|
+
if (!params.clearAll) return { deleted: { entries: deletedEntries, tasks: deletedTasks } };
|
|
5577
|
+
return params.includeEvents ? { deleted: { entries: deletedEntries, tasks: deletedTasks, events: deletedEvents }, metadataReset: true } : { deleted: { entries: deletedEntries, tasks: deletedTasks }, metadataReset: true };
|
|
5384
5578
|
} finally {
|
|
5385
5579
|
this.jobManager.releaseLock("forget", entityId);
|
|
5386
5580
|
}
|
|
@@ -5431,6 +5625,10 @@ var MaintenanceService = class {
|
|
|
5431
5625
|
if (params.clearAll) {
|
|
5432
5626
|
const entries2 = await this.entryRepo.countLiveByEntityId(entityId);
|
|
5433
5627
|
const tasks = await this.taskRepo.countLiveByEntityId(entityId);
|
|
5628
|
+
if (params.includeEvents) {
|
|
5629
|
+
const events = await this.eventRepo.count(entityId);
|
|
5630
|
+
return { deleted: { entries: entries2, tasks, events }, metadataReset: true };
|
|
5631
|
+
}
|
|
5434
5632
|
return { deleted: { entries: entries2, tasks }, metadataReset: true };
|
|
5435
5633
|
}
|
|
5436
5634
|
const sourceRef = params.sourceRef !== void 0 ? normalizeSourceRef(params.sourceRef) : null;
|
|
@@ -6594,7 +6792,19 @@ var ImportExportService = class {
|
|
|
6594
6792
|
tags: Array.isArray(fact.tags) || typeof fact.tags === "string" ? fact.tags : []
|
|
6595
6793
|
}, { operation: "importDump", trigger: "call" });
|
|
6596
6794
|
if (!embedded) {
|
|
6597
|
-
|
|
6795
|
+
try {
|
|
6796
|
+
await this.embeddingService.notifyEmbeddingPersisted(entityId, fact.id, null);
|
|
6797
|
+
} catch (hookErr) {
|
|
6798
|
+
console.warn(
|
|
6799
|
+
`[WikiMemory] onEmbeddingPersisted hook failed for unembedded fact ${fact.id}:`,
|
|
6800
|
+
hookErr
|
|
6801
|
+
);
|
|
6802
|
+
this.embeddingService.reportHookFailed(
|
|
6803
|
+
{ operation: "importDump", trigger: "call" },
|
|
6804
|
+
entityId,
|
|
6805
|
+
fact.id
|
|
6806
|
+
);
|
|
6807
|
+
}
|
|
6598
6808
|
}
|
|
6599
6809
|
}
|
|
6600
6810
|
}
|
|
@@ -7919,6 +8129,6 @@ var WriteService = class {
|
|
|
7919
8129
|
}
|
|
7920
8130
|
};
|
|
7921
8131
|
|
|
7922
|
-
export { BaseRepository, CURRENT_SCHEMA_VERSION, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DiagnosticBuffer, EMBED_CHARS_CEILING, EmbeddingService, FTS5_DRAIN_CHUNK, FTS5_REBUILD_SNAPSHOT_KEY, FTS5_REBUILD_WM_KEY, FTS5_RECLAIM_MERGE_PAGES, FTS5_RETIRED_COUNTER_KEY, FTS5_RETIRED_TABLES_KEY, FTS5_STATE_KEY, FTS5_SWEEP_CURSOR_KEY, HEAL_ANCHORS_PER_CANDIDATE, HEAL_BATCH_SIZE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, HEAL_RECHECK_MS, HOOK_TIMEOUT_MARKER, ImportExportService, IngestionService, JobManager, MAX_EMBED_ATTEMPTS, MIGRATIONS, MaintenanceService, MetadataRepository, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, RetrievalService, SearchService, TemporalService, UnavailableIndexStrategy, UsageMeter, WikiBusyError, WikiDraftNotFound, WikiDuplicateHashError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiMigrationRequiredError, WikiParseError, WikiSearchUnavailableError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiSupersedeError, WikiTransactionError, WriteService, __privateAdd, __privateGet, __privateSet, assertEntityId, assertEpochMs, chunkText, configureRandomSource, createLegacySourceTypeIndex, createdAtValue, detectSchemaVersion, drainChunkSql, drainHiSql, edgeTripleAllowed, emptyManifest, entityDrainChunkSql, entityDrainHiSql, entitySummaryMetaKey, extractSqliteCode, factTokenCost, fts5LedgerDropSql, fts5PendingIndexesDdl, fts5TablesDdl, fts5TriggerNames, fts5TriggersDdl, generateId, idDrainChunkSql, idReindexChunkSql, isLiveAt, isRetiredTableName, isUsableDate, isWikiSearchUnavailableError, liveAtSql, normalizeSourceHash, normalizeSourceRef, normalizeTitleKey, packFactsByBudget, parseEmbedding, parseJsonArray, parseJsonObject, probePendingWork, readRebuildProgress, reanchorRebuildFingerprint, resolveEdgeDefinitions, resolveGrounding, resolveLibrarianStrategy, resolveNodeType, retiredTableName, runSourceRefNormalize, safeSlice, setupDatabase, sweepChunkSql, sweepHiSql, typeSatisfies, validateInlineEdges, validateManifest, warnChangedDefaultsOnce, windowChunkSql, windowHiSql, writeNormalizeStamp, writeRebuildStart };
|
|
7923
|
-
//# sourceMappingURL=chunk-
|
|
7924
|
-
//# sourceMappingURL=chunk-
|
|
8132
|
+
export { BaseRepository, CURRENT_SCHEMA_VERSION, DEFAULT_CHUNK_OVERLAP, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DiagnosticBuffer, EMBED_CHARS_CEILING, EdgeRepository, EmbeddingService, FTS5_DRAIN_CHUNK, FTS5_REBUILD_SNAPSHOT_KEY, FTS5_REBUILD_WM_KEY, FTS5_RECLAIM_MERGE_PAGES, FTS5_RETIRED_COUNTER_KEY, FTS5_RETIRED_TABLES_KEY, FTS5_STATE_KEY, FTS5_SWEEP_CURSOR_KEY, HEAL_ANCHORS_PER_CANDIDATE, HEAL_BATCH_SIZE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, HEAL_RECHECK_MS, HOOK_TIMEOUT_MARKER, ImportExportService, IngestionService, JobManager, MAX_EMBED_ATTEMPTS, MIGRATIONS, MaintenanceService, MetadataRepository, ONTOLOGY_BACKFILL_BATCH_SIZE, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_RECHECK_MS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, PromptService, PrunePartialFailureError, RetrievalService, SearchService, TemporalService, UnavailableIndexStrategy, UsageMeter, WikiBusyError, WikiDraftNotFound, WikiDuplicateHashError, WikiGraphNodeOwnershipConflict, WikiIngestEmptyError, WikiInvalidReadOptions, WikiMigrationRequiredError, WikiParseError, WikiSearchUnavailableError, WikiSourceRefHashCollision, WikiStrictOntologyViolation, WikiSupersedeError, WikiTransactionError, WriteService, __privateAdd, __privateGet, __privateSet, assertEntityId, assertEpochMs, chunkText, configureRandomSource, createLegacySourceTypeIndex, createdAtValue, detectSchemaVersion, drainChunkSql, drainHiSql, edgeTripleAllowed, emptyManifest, entityDrainChunkSql, entityDrainHiSql, entitySummaryMetaKey, extractSqliteCode, factTokenCost, fts5LedgerDropSql, fts5PendingIndexesDdl, fts5TablesDdl, fts5TriggerNames, fts5TriggersDdl, generateId, idDrainChunkSql, idReindexChunkSql, isLiveAt, isRetiredTableName, isUsableDate, isWikiSearchUnavailableError, liveAtSql, normalizeSourceHash, normalizeSourceRef, normalizeTitleKey, packFactsByBudget, parseEmbedding, parseJsonArray, parseJsonObject, probePendingWork, readRebuildProgress, reanchorRebuildFingerprint, resolveEdgeDefinitions, resolveGrounding, resolveLibrarianStrategy, resolveNodeType, retiredTableName, runSourceRefNormalize, safeSlice, setupDatabase, sweepChunkSql, sweepHiSql, typeSatisfies, validateInlineEdges, validateManifest, warnChangedDefaultsOnce, windowChunkSql, windowHiSql, writeNormalizeStamp, writeRebuildStart };
|
|
8133
|
+
//# sourceMappingURL=chunk-V432RHCG.mjs.map
|
|
8134
|
+
//# sourceMappingURL=chunk-V432RHCG.mjs.map
|