@equationalapplications/core-llm-wiki 9.4.2 → 9.5.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/dist/{chunk-TJYITTAO.mjs → chunk-ZVVZACYI.mjs} +36 -12
- package/dist/chunk-ZVVZACYI.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +101 -11
- 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-CTCRwhs0.d.mts} +39 -2
- package/dist/{testing-BVY5P6BS.d.ts → testing-CTCRwhs0.d.ts} +39 -2
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +34 -10
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-TJYITTAO.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyMode, R as ReadOptions, S as SQLiteAdapter, W as WikiOptions, c as WikiMemory } from './testing-
|
|
2
|
-
export { C as CheckpointIncompleteError, d as ChunkFailure, e as ClassifierAnswer, f as ClassifierQuestion, g as ClassifyRequest, h as ClassifyResponse, D as DegradedRecord, i as DraftPage, E as EmbedFactResult, j as EmbedFailureKind, k as EmbeddingMarkerKind, l as EntityMaintenanceReport, m as EntityStatus, n as EraseReport, o as EraseStepError, p as ExtractedFact, q as ExtractedFactEdge, r as ExtractedFactWithOntology, s as ExtractedTask, t as ForgetParams, u as ForgetResult, v as GraphTraversalOptions, w as GroundingConfig, H as HEAL_BATCH_SIZE, x as HEAL_RECHECK_MS, y as HOOK_TIMEOUT_MARKER, z as HealResult, I as ImportDumpResult, A as IngestDocumentResult, L as LLMProvider, B as LibrarianConfig, J as LibrarianGateConfig, K as LockedMaintenanceJob, N as MaintenanceJob, P as MaintenanceStopReason, Q as MemoryDumpEntity, T as MigrationPolicy, U as ONTOLOGY_BACKFILL_BATCH_SIZE, V as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, X as ONTOLOGY_BACKFILL_RECHECK_MS, Y as OntologyBackfillResult, Z as OntologyConfig, _ as OntologyEdgeType, $ as OntologyManifest, a0 as OntologyNodeType, a1 as OntologyPromptContext, a2 as OntologyUpdates, a3 as PendingMaintenance, a4 as PendingMigrationWork, a5 as PendingSourceStatus, a6 as PromptOverrides, a7 as PromptService, a8 as PrunePartialFailureError, a9 as ReembedResult, aa as RememberInput, ab as RunPendingMaintenanceOptions, ac as RunPendingMaintenanceResult, ad as SourcePassage, ae as StoreSourceResult, af as StoredSource, ag as StoredSourceDump, ah as StoredSourceSummary, ai as SupersedeReplacement, aj as VectorRanker, ak as VectorRankerFallback, al as VectorRankerRankArgs, am as VectorRankerSemanticResult, an as WikiBusyError, ao as WikiBusyOperation, ap as WikiCheckpoint, aq as WikiConfig, ar as WikiDiagnostic, as as WikiDiagnosticCode, at as WikiDiagnosticDetail, au as WikiDiagnosticOperation, av as WikiDiagnosticSeverity, aw as WikiDiagnosticTrigger, ax as WikiDraftNotFound, ay as WikiDuplicateHashError, az as WikiEdge, aA as WikiEvent, aB as WikiExternalDeletionError, aC as WikiFact, aD as WikiGraphNodeOwnershipConflict, aE as WikiIngestEmptyError, aF as WikiInstructions, aG as WikiInvalidReadOptions, aH as WikiLintReport, aI as WikiMemoryTestAccess, aJ as WikiMigrationRequiredError, aK as WikiOutboxEvent, aL as WikiParseError, aM as WikiSearchUnavailableError, aN as WikiSourcePointer, aO as WikiSourceRefHashCollision, aP as WikiStrictOntologyViolation, aQ as WikiSupersedeError, aR as WikiSupersedeReason, aS as WikiTask, aT as WikiTransactionError, aU as isWikiSearchUnavailableError, aV as validateManifest } from './testing-
|
|
1
|
+
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyMode, R as ReadOptions, S as SQLiteAdapter, W as WikiOptions, c as WikiMemory } from './testing-CTCRwhs0.mjs';
|
|
2
|
+
export { C as CheckpointIncompleteError, d as ChunkFailure, e as ClassifierAnswer, f as ClassifierQuestion, g as ClassifyRequest, h as ClassifyResponse, D as DegradedRecord, i as DraftPage, E as EmbedFactResult, j as EmbedFailureKind, k as EmbeddingMarkerKind, l as EntityMaintenanceReport, m as EntityStatus, n as EraseReport, o as EraseStepError, p as ExtractedFact, q as ExtractedFactEdge, r as ExtractedFactWithOntology, s as ExtractedTask, t as ForgetParams, u as ForgetResult, v as GraphTraversalOptions, w as GroundingConfig, H as HEAL_BATCH_SIZE, x as HEAL_RECHECK_MS, y as HOOK_TIMEOUT_MARKER, z as HealResult, I as ImportDumpResult, A as IngestDocumentResult, L as LLMProvider, B as LibrarianConfig, J as LibrarianGateConfig, K as LockedMaintenanceJob, N as MaintenanceJob, P as MaintenanceStopReason, Q as MemoryDumpEntity, T as MigrationPolicy, U as ONTOLOGY_BACKFILL_BATCH_SIZE, V as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, X as ONTOLOGY_BACKFILL_RECHECK_MS, Y as OntologyBackfillResult, Z as OntologyConfig, _ as OntologyEdgeType, $ as OntologyManifest, a0 as OntologyNodeType, a1 as OntologyPromptContext, a2 as OntologyUpdates, a3 as PendingMaintenance, a4 as PendingMigrationWork, a5 as PendingSourceStatus, a6 as PromptOverrides, a7 as PromptService, a8 as PrunePartialFailureError, a9 as ReembedResult, aa as RememberInput, ab as RunPendingMaintenanceOptions, ac as RunPendingMaintenanceResult, ad as SourcePassage, ae as StoreSourceResult, af as StoredSource, ag as StoredSourceDump, ah as StoredSourceSummary, ai as SupersedeReplacement, aj as VectorRanker, ak as VectorRankerFallback, al as VectorRankerRankArgs, am as VectorRankerSemanticResult, an as WikiBusyError, ao as WikiBusyOperation, ap as WikiCheckpoint, aq as WikiConfig, ar as WikiDiagnostic, as as WikiDiagnosticCode, at as WikiDiagnosticDetail, au as WikiDiagnosticOperation, av as WikiDiagnosticSeverity, aw as WikiDiagnosticTrigger, ax as WikiDraftNotFound, ay as WikiDuplicateHashError, az as WikiEdge, aA as WikiEvent, aB as WikiExternalDeletionError, aC as WikiFact, aD as WikiGraphNodeOwnershipConflict, aE as WikiIngestEmptyError, aF as WikiInstructions, aG as WikiInvalidReadOptions, aH as WikiLintReport, aI as WikiMemoryTestAccess, aJ as WikiMigrationRequiredError, aK as WikiOutboxEvent, aL as WikiParseError, aM as WikiSearchUnavailableError, aN as WikiSourcePointer, aO as WikiSourceRefHashCollision, aP as WikiStrictOntologyViolation, aQ as WikiSupersedeError, aR as WikiSupersedeReason, aS as WikiTask, aT as WikiTransactionError, aU as isWikiSearchUnavailableError, aV as validateManifest } from './testing-CTCRwhs0.mjs';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyMode, R as ReadOptions, S as SQLiteAdapter, W as WikiOptions, c as WikiMemory } from './testing-
|
|
2
|
-
export { C as CheckpointIncompleteError, d as ChunkFailure, e as ClassifierAnswer, f as ClassifierQuestion, g as ClassifyRequest, h as ClassifyResponse, D as DegradedRecord, i as DraftPage, E as EmbedFactResult, j as EmbedFailureKind, k as EmbeddingMarkerKind, l as EntityMaintenanceReport, m as EntityStatus, n as EraseReport, o as EraseStepError, p as ExtractedFact, q as ExtractedFactEdge, r as ExtractedFactWithOntology, s as ExtractedTask, t as ForgetParams, u as ForgetResult, v as GraphTraversalOptions, w as GroundingConfig, H as HEAL_BATCH_SIZE, x as HEAL_RECHECK_MS, y as HOOK_TIMEOUT_MARKER, z as HealResult, I as ImportDumpResult, A as IngestDocumentResult, L as LLMProvider, B as LibrarianConfig, J as LibrarianGateConfig, K as LockedMaintenanceJob, N as MaintenanceJob, P as MaintenanceStopReason, Q as MemoryDumpEntity, T as MigrationPolicy, U as ONTOLOGY_BACKFILL_BATCH_SIZE, V as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, X as ONTOLOGY_BACKFILL_RECHECK_MS, Y as OntologyBackfillResult, Z as OntologyConfig, _ as OntologyEdgeType, $ as OntologyManifest, a0 as OntologyNodeType, a1 as OntologyPromptContext, a2 as OntologyUpdates, a3 as PendingMaintenance, a4 as PendingMigrationWork, a5 as PendingSourceStatus, a6 as PromptOverrides, a7 as PromptService, a8 as PrunePartialFailureError, a9 as ReembedResult, aa as RememberInput, ab as RunPendingMaintenanceOptions, ac as RunPendingMaintenanceResult, ad as SourcePassage, ae as StoreSourceResult, af as StoredSource, ag as StoredSourceDump, ah as StoredSourceSummary, ai as SupersedeReplacement, aj as VectorRanker, ak as VectorRankerFallback, al as VectorRankerRankArgs, am as VectorRankerSemanticResult, an as WikiBusyError, ao as WikiBusyOperation, ap as WikiCheckpoint, aq as WikiConfig, ar as WikiDiagnostic, as as WikiDiagnosticCode, at as WikiDiagnosticDetail, au as WikiDiagnosticOperation, av as WikiDiagnosticSeverity, aw as WikiDiagnosticTrigger, ax as WikiDraftNotFound, ay as WikiDuplicateHashError, az as WikiEdge, aA as WikiEvent, aB as WikiExternalDeletionError, aC as WikiFact, aD as WikiGraphNodeOwnershipConflict, aE as WikiIngestEmptyError, aF as WikiInstructions, aG as WikiInvalidReadOptions, aH as WikiLintReport, aI as WikiMemoryTestAccess, aJ as WikiMigrationRequiredError, aK as WikiOutboxEvent, aL as WikiParseError, aM as WikiSearchUnavailableError, aN as WikiSourcePointer, aO as WikiSourceRefHashCollision, aP as WikiStrictOntologyViolation, aQ as WikiSupersedeError, aR as WikiSupersedeReason, aS as WikiTask, aT as WikiTransactionError, aU as isWikiSearchUnavailableError, aV as validateManifest } from './testing-
|
|
1
|
+
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyMode, R as ReadOptions, S as SQLiteAdapter, W as WikiOptions, c as WikiMemory } from './testing-CTCRwhs0.js';
|
|
2
|
+
export { C as CheckpointIncompleteError, d as ChunkFailure, e as ClassifierAnswer, f as ClassifierQuestion, g as ClassifyRequest, h as ClassifyResponse, D as DegradedRecord, i as DraftPage, E as EmbedFactResult, j as EmbedFailureKind, k as EmbeddingMarkerKind, l as EntityMaintenanceReport, m as EntityStatus, n as EraseReport, o as EraseStepError, p as ExtractedFact, q as ExtractedFactEdge, r as ExtractedFactWithOntology, s as ExtractedTask, t as ForgetParams, u as ForgetResult, v as GraphTraversalOptions, w as GroundingConfig, H as HEAL_BATCH_SIZE, x as HEAL_RECHECK_MS, y as HOOK_TIMEOUT_MARKER, z as HealResult, I as ImportDumpResult, A as IngestDocumentResult, L as LLMProvider, B as LibrarianConfig, J as LibrarianGateConfig, K as LockedMaintenanceJob, N as MaintenanceJob, P as MaintenanceStopReason, Q as MemoryDumpEntity, T as MigrationPolicy, U as ONTOLOGY_BACKFILL_BATCH_SIZE, V as ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, X as ONTOLOGY_BACKFILL_RECHECK_MS, Y as OntologyBackfillResult, Z as OntologyConfig, _ as OntologyEdgeType, $ as OntologyManifest, a0 as OntologyNodeType, a1 as OntologyPromptContext, a2 as OntologyUpdates, a3 as PendingMaintenance, a4 as PendingMigrationWork, a5 as PendingSourceStatus, a6 as PromptOverrides, a7 as PromptService, a8 as PrunePartialFailureError, a9 as ReembedResult, aa as RememberInput, ab as RunPendingMaintenanceOptions, ac as RunPendingMaintenanceResult, ad as SourcePassage, ae as StoreSourceResult, af as StoredSource, ag as StoredSourceDump, ah as StoredSourceSummary, ai as SupersedeReplacement, aj as VectorRanker, ak as VectorRankerFallback, al as VectorRankerRankArgs, am as VectorRankerSemanticResult, an as WikiBusyError, ao as WikiBusyOperation, ap as WikiCheckpoint, aq as WikiConfig, ar as WikiDiagnostic, as as WikiDiagnosticCode, at as WikiDiagnosticDetail, au as WikiDiagnosticOperation, av as WikiDiagnosticSeverity, aw as WikiDiagnosticTrigger, ax as WikiDraftNotFound, ay as WikiDuplicateHashError, az as WikiEdge, aA as WikiEvent, aB as WikiExternalDeletionError, aC as WikiFact, aD as WikiGraphNodeOwnershipConflict, aE as WikiIngestEmptyError, aF as WikiInstructions, aG as WikiInvalidReadOptions, aH as WikiLintReport, aI as WikiMemoryTestAccess, aJ as WikiMigrationRequiredError, aK as WikiOutboxEvent, aL as WikiParseError, aM as WikiSearchUnavailableError, aN as WikiSourcePointer, aO as WikiSourceRefHashCollision, aP as WikiStrictOntologyViolation, aQ as WikiSupersedeError, aR as WikiSupersedeReason, aS as WikiTask, aT as WikiTransactionError, aU as isWikiSearchUnavailableError, aV as validateManifest } from './testing-CTCRwhs0.js';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.js
CHANGED
|
@@ -245,10 +245,12 @@ var SQLITE_RESULT_CODE_NAMES = {
|
|
|
245
245
|
27: "SQLITE_NOTICE",
|
|
246
246
|
28: "SQLITE_WARNING",
|
|
247
247
|
// Extended result codes (https://sqlite.org/rescode.html#extended_result_code_list).
|
|
248
|
-
// 2067 = SQLITE_CONSTRAINT_UNIQUE —
|
|
249
|
-
//
|
|
250
|
-
//
|
|
251
|
-
//
|
|
248
|
+
// 2067 = SQLITE_CONSTRAINT_UNIQUE — a UNIQUE index rejecting an INSERT/UPDATE.
|
|
249
|
+
// better-sqlite3 / node:sqlite enable extended result codes and report it
|
|
250
|
+
// directly. expo-sqlite never emits it (as of expo-sqlite 58.0.14, per
|
|
251
|
+
// #403): it leaves extended result codes off and surfaces the same failure
|
|
252
|
+
// as the primary code 19 with the "UNIQUE constraint failed" message text,
|
|
253
|
+
// which `extractSqliteCode` below refines back to this name (#403).
|
|
252
254
|
2067: "SQLITE_CONSTRAINT_UNIQUE",
|
|
253
255
|
// 267 = SQLITE_CORRUPT_VTAB — a corrupt FTS5 shadow table (ftsCorruptionClass).
|
|
254
256
|
267: "SQLITE_CORRUPT_VTAB",
|
|
@@ -264,7 +266,13 @@ function extractSqliteCode(err) {
|
|
|
264
266
|
if (typeof code === "string" && code.startsWith("SQLITE_")) return code;
|
|
265
267
|
if (typeof message === "string") {
|
|
266
268
|
const m = /^Error code (\d+):/.exec(message);
|
|
267
|
-
if (m)
|
|
269
|
+
if (m) {
|
|
270
|
+
const n = Number(m[1]);
|
|
271
|
+
if (n === 19 && message.includes("UNIQUE constraint failed")) {
|
|
272
|
+
return nameForSqliteResultCode(2067);
|
|
273
|
+
}
|
|
274
|
+
return nameForSqliteResultCode(n);
|
|
275
|
+
}
|
|
268
276
|
}
|
|
269
277
|
return void 0;
|
|
270
278
|
}
|
|
@@ -2518,6 +2526,59 @@ var _EntryRepository = class _EntryRepository extends BaseRepository {
|
|
|
2518
2526
|
}
|
|
2519
2527
|
return result.changes;
|
|
2520
2528
|
}
|
|
2529
|
+
/**
|
|
2530
|
+
* IDs of the entity's entries whose source_pointer names the event id.
|
|
2531
|
+
* `includeDeleted = true` returns live + tombstoned rows (the forget
|
|
2532
|
+
* enumeration superset for index sync and the ledger backstop).
|
|
2533
|
+
*/
|
|
2534
|
+
async findIdsByPointerEvent(entityId, eventId, tx, includeDeleted = false) {
|
|
2535
|
+
const executor = this.getExecutor(tx);
|
|
2536
|
+
let sql = `SELECT id FROM ${this.prefix}entries WHERE entity_id = ? AND ${_EntryRepository.POINTER_EVENT_MATCH_SQL}`;
|
|
2537
|
+
const args = [entityId, eventId];
|
|
2538
|
+
if (!includeDeleted) sql += ` AND deleted_at IS NULL`;
|
|
2539
|
+
const rows = await executor.getAllAsync(sql, args);
|
|
2540
|
+
return rows.map((r) => r.id);
|
|
2541
|
+
}
|
|
2542
|
+
/** Live-row count for the event id — dry-run only (a real call is idempotent over tombstones). */
|
|
2543
|
+
async countLiveByPointerEvent(entityId, eventId, tx) {
|
|
2544
|
+
const executor = this.getExecutor(tx);
|
|
2545
|
+
const row = await executor.getFirstAsync(
|
|
2546
|
+
`SELECT COUNT(*) AS n FROM ${this.prefix}entries WHERE entity_id = ? AND deleted_at IS NULL AND ${_EntryRepository.POINTER_EVENT_MATCH_SQL}`,
|
|
2547
|
+
[entityId, eventId]
|
|
2548
|
+
);
|
|
2549
|
+
return row?.n ?? 0;
|
|
2550
|
+
}
|
|
2551
|
+
/**
|
|
2552
|
+
* Soft-delete the entity's entries whose source_pointer names the event id,
|
|
2553
|
+
* within a transaction. Stages a DELETE outbox entry for each row that
|
|
2554
|
+
* changed, in the same transaction (parity with softDeleteBySource — synced
|
|
2555
|
+
* replicas learn of the tombstones through the outbox). The `deleted_at
|
|
2556
|
+
* IS NULL` guard makes the call idempotent: already-tombstoned rows are
|
|
2557
|
+
* no-op hits and are not counted. `tx` is REQUIRED.
|
|
2558
|
+
* Returns the number of rows deleted.
|
|
2559
|
+
*/
|
|
2560
|
+
async softDeleteByPointerEvent(entityId, eventId, tx) {
|
|
2561
|
+
const executor = this.getExecutor(tx);
|
|
2562
|
+
const now = Date.now();
|
|
2563
|
+
const idsToDelete = await executor.getAllAsync(
|
|
2564
|
+
`SELECT id FROM ${this.prefix}entries WHERE entity_id = ? AND deleted_at IS NULL AND ${_EntryRepository.POINTER_EVENT_MATCH_SQL}`,
|
|
2565
|
+
[entityId, eventId]
|
|
2566
|
+
);
|
|
2567
|
+
const result = await executor.runAsync(
|
|
2568
|
+
`UPDATE ${this.prefix}entries SET deleted_at = ?, updated_at = ? WHERE entity_id = ? AND deleted_at IS NULL AND ${_EntryRepository.POINTER_EVENT_MATCH_SQL}`,
|
|
2569
|
+
[now, now, entityId, eventId]
|
|
2570
|
+
);
|
|
2571
|
+
for (const row of idsToDelete) {
|
|
2572
|
+
await this.outbox.push({
|
|
2573
|
+
entityId,
|
|
2574
|
+
tableName: "entries",
|
|
2575
|
+
recordId: row.id,
|
|
2576
|
+
operation: "DELETE",
|
|
2577
|
+
payload: { id: row.id, entity_id: entityId, deleted_at: now }
|
|
2578
|
+
}, tx);
|
|
2579
|
+
}
|
|
2580
|
+
return result.changes;
|
|
2581
|
+
}
|
|
2521
2582
|
/**
|
|
2522
2583
|
* Fetch IDs + entity_ids of soft-deleted rows older than cutoff for a given entity.
|
|
2523
2584
|
* Used by runPrune().
|
|
@@ -3542,6 +3603,18 @@ var _EntryRepository = class _EntryRepository extends BaseRepository {
|
|
|
3542
3603
|
*/
|
|
3543
3604
|
_EntryRepository.MINI_SEARCH_COLUMNS = "id, entity_id, title, body, tags";
|
|
3544
3605
|
_EntryRepository.MINI_SEARCH_LIVE_WHERE = "WHERE deleted_at IS NULL";
|
|
3606
|
+
/**
|
|
3607
|
+
* Shared JSON match predicate for source_pointer event ids
|
|
3608
|
+
* (specs/forget-by-event-id §D1). Every JSON call sits under the single
|
|
3609
|
+
* `json_valid` guard: unguarded JSON functions RAISE on malformed text, and
|
|
3610
|
+
* three-valued logic forces evaluation of AND operands after a NULL-guarded
|
|
3611
|
+
* term — a two-term form is only as safe as the planner's term-splitting.
|
|
3612
|
+
* The tombstone guard (`deleted_at IS NULL`) is added per-method.
|
|
3613
|
+
*/
|
|
3614
|
+
_EntryRepository.POINTER_EVENT_MATCH_SQL = `CASE WHEN json_valid(source_pointer)
|
|
3615
|
+
THEN json_type(source_pointer, '$.event_id') = 'text'
|
|
3616
|
+
AND json_extract(source_pointer, '$.event_id') = ?
|
|
3617
|
+
ELSE 0 END`;
|
|
3545
3618
|
var EntryRepository = _EntryRepository;
|
|
3546
3619
|
|
|
3547
3620
|
// src/utils/ids.ts
|
|
@@ -10885,15 +10958,21 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
10885
10958
|
}
|
|
10886
10959
|
}
|
|
10887
10960
|
async forget(entityId, params, opts) {
|
|
10888
|
-
if (params.clearAll && (params.entryId !== void 0 || params.taskId !== void 0 || params.sourceRef !== void 0 || params.sourceHash !== void 0)) {
|
|
10889
|
-
throw new Error("forget() clearAll is mutually exclusive with entryId, taskId, sourceRef, and
|
|
10961
|
+
if (params.clearAll && (params.entryId !== void 0 || params.taskId !== void 0 || params.sourceRef !== void 0 || params.sourceHash !== void 0 || params.eventId !== void 0)) {
|
|
10962
|
+
throw new Error("forget() clearAll is mutually exclusive with entryId, taskId, sourceRef, sourceHash, and eventId");
|
|
10890
10963
|
}
|
|
10891
10964
|
if (params.includeEvents && !params.clearAll) {
|
|
10892
10965
|
throw new Error("forget() includeEvents requires clearAll: true");
|
|
10893
10966
|
}
|
|
10894
|
-
if (params.includeChain && (params.entryId === void 0 || params.clearAll || params.taskId !== void 0 || params.sourceRef !== void 0 || params.sourceHash !== void 0)) {
|
|
10967
|
+
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)) {
|
|
10895
10968
|
throw new Error("forget() includeChain composes only with entryId");
|
|
10896
10969
|
}
|
|
10970
|
+
if (params.eventId !== void 0 && (params.entryId !== void 0 || params.taskId !== void 0 || params.sourceRef !== void 0 || params.sourceHash !== void 0)) {
|
|
10971
|
+
throw new Error("forget() eventId is mutually exclusive with entryId, taskId, sourceRef, and sourceHash");
|
|
10972
|
+
}
|
|
10973
|
+
if (params.eventId !== void 0 && (typeof params.eventId !== "string" || params.eventId === "")) {
|
|
10974
|
+
throw new Error("Invalid eventId");
|
|
10975
|
+
}
|
|
10897
10976
|
if (opts?.dryRun === true) {
|
|
10898
10977
|
return this.forgetDryRun(entityId, params);
|
|
10899
10978
|
}
|
|
@@ -10961,14 +11040,19 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
10961
11040
|
if (sourceRef || sourceHash) {
|
|
10962
11041
|
for (const id of await this.entryRepo.findIdsBySource(entityId, sourceRef, sourceHash, tx, true)) deletedEntryIds.push(id);
|
|
10963
11042
|
}
|
|
11043
|
+
if (params.eventId !== void 0) {
|
|
11044
|
+
for (const id of await this.entryRepo.findIdsByPointerEvent(entityId, params.eventId, tx, true)) deletedEntryIds.push(id);
|
|
11045
|
+
}
|
|
10964
11046
|
const entryPromise = params.entryId ? this.entryRepo.softDelete(params.entryId, entityId, tx).then((r) => r.changes > 0) : null;
|
|
10965
11047
|
const taskDeletedPromise = params.taskId ? this.taskRepo.softDeleteById(params.taskId, entityId, tx).then((r) => r.changes > 0) : null;
|
|
10966
11048
|
const refPromise = sourceRef || sourceHash ? this.entryRepo.softDeleteBySource(entityId, tx, sourceRef, sourceHash) : null;
|
|
11049
|
+
const pointerPromise = params.eventId !== void 0 ? this.entryRepo.softDeleteByPointerEvent(entityId, params.eventId, tx) : null;
|
|
10967
11050
|
const sourceRefIndexPromise = touchSourceRefIndex && sourceRef ? this.sourceRefIndexRepo.softDeleteByEntityAndSourceRef(entityId, sourceRef, tx).then(() => void 0) : null;
|
|
10968
|
-
const [entryResult, taskResult, refResult] = await Promise.all([
|
|
11051
|
+
const [entryResult, taskResult, refResult, pointerResult] = await Promise.all([
|
|
10969
11052
|
entryPromise ?? Promise.resolve(false),
|
|
10970
11053
|
taskDeletedPromise ?? Promise.resolve(false),
|
|
10971
11054
|
refPromise ?? Promise.resolve(0),
|
|
11055
|
+
pointerPromise ?? Promise.resolve(0),
|
|
10972
11056
|
sourceRefIndexPromise ?? Promise.resolve(void 0)
|
|
10973
11057
|
]);
|
|
10974
11058
|
if (entryResult) deletedEntries++;
|
|
@@ -10977,6 +11061,7 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
10977
11061
|
}
|
|
10978
11062
|
if (taskResult) deletedTasks++;
|
|
10979
11063
|
deletedEntries += refResult;
|
|
11064
|
+
deletedEntries += pointerResult;
|
|
10980
11065
|
}
|
|
10981
11066
|
if (ledgerOn && this.vectorRemoval?.gate() === "hook" && deletedEntryIds.length > 0) {
|
|
10982
11067
|
await this.vectorRemovalRepo?.backstopEnqueue(entityId, Array.from(new Set(deletedEntryIds)), now, tx);
|
|
@@ -11122,7 +11207,7 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
11122
11207
|
return out;
|
|
11123
11208
|
}
|
|
11124
11209
|
if (params.entryId !== void 0 || params.taskId !== void 0) {
|
|
11125
|
-
throw new Error("forget({ dryRun: true }) does not support entryId/taskId selectors (entryId is accepted only with includeChain); use sourceRef/sourceHash or clearAll");
|
|
11210
|
+
throw new Error("forget({ dryRun: true }) does not support entryId/taskId selectors (entryId is accepted only with includeChain); use sourceRef/sourceHash, eventId, or clearAll");
|
|
11126
11211
|
}
|
|
11127
11212
|
if (params.clearAll) {
|
|
11128
11213
|
const entries2 = await this.entryRepo.countLiveByEntityId(entityId);
|
|
@@ -11133,6 +11218,10 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
11133
11218
|
}
|
|
11134
11219
|
return { deleted: { entries: entries2, tasks }, metadataReset: true };
|
|
11135
11220
|
}
|
|
11221
|
+
if (params.eventId !== void 0) {
|
|
11222
|
+
const entries2 = await this.entryRepo.countLiveByPointerEvent(entityId, params.eventId);
|
|
11223
|
+
return { deleted: { entries: entries2, tasks: 0 } };
|
|
11224
|
+
}
|
|
11136
11225
|
const sourceRef = params.sourceRef !== void 0 ? normalizeSourceRef(params.sourceRef) : null;
|
|
11137
11226
|
if (params.sourceRef !== void 0 && !sourceRef) throw new Error("Invalid sourceRef");
|
|
11138
11227
|
const sourceHash = params.sourceHash !== void 0 ? normalizeSourceHash(params.sourceHash) : null;
|
|
@@ -15678,7 +15767,8 @@ var WikiMemory = class {
|
|
|
15678
15767
|
}
|
|
15679
15768
|
}
|
|
15680
15769
|
/**
|
|
15681
|
-
* Soft-delete facts and tasks by id, by source,
|
|
15770
|
+
* Soft-delete facts and tasks by id, by source, by source-pointer event id,
|
|
15771
|
+
* or all of them (`clearAll`).
|
|
15682
15772
|
* `clearAll` also deletes the entity's edges and its source-ref index rows.
|
|
15683
15773
|
* Add `includeEvents: true` to `clearAll` to hard-delete every event too,
|
|
15684
15774
|
* read or not, and reset the librarian's position: without it a later
|