@equationalapplications/core-llm-wiki 9.1.0 → 9.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/dist/{chunk-SIJD5GEF.mjs → chunk-H436I7OM.mjs} +1832 -496
- package/dist/chunk-H436I7OM.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2161 -404
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +655 -236
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-CmcCGx0_.d.mts → testing-DsD-idCv.d.mts} +401 -29
- package/dist/{testing-CmcCGx0_.d.ts → testing-DsD-idCv.d.ts} +401 -29
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1298 -173
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-SIJD5GEF.mjs.map +0 -1
|
@@ -278,6 +278,11 @@ interface LibrarianConfig {
|
|
|
278
278
|
guidanceForEntity?: (entityId: string) => string | undefined;
|
|
279
279
|
}
|
|
280
280
|
interface WikiConfig {
|
|
281
|
+
/** Source-store limits (spec source-store section 9). Defaults live in SourceStoreService. */
|
|
282
|
+
sourceStore?: {
|
|
283
|
+
maxCharsPerSource?: number;
|
|
284
|
+
maxTotalChars?: number;
|
|
285
|
+
};
|
|
281
286
|
/**
|
|
282
287
|
* Prefix applied to every SQL table/index/trigger name. Must match
|
|
283
288
|
* `^[A-Za-z][A-Za-z0-9_]{0,30}_$` (letter, then alphanumeric/underscore,
|
|
@@ -414,6 +419,16 @@ interface WikiConfig {
|
|
|
414
419
|
setupBudgetMs?: number;
|
|
415
420
|
}
|
|
416
421
|
interface ReadOptions {
|
|
422
|
+
/**
|
|
423
|
+
* Opt in to stored-source passages (spec source-store section 7). Per entity:
|
|
424
|
+
* at most `maxPassages` (default 8) windows, each at most `charBudget`
|
|
425
|
+
* (default 4,000) UTF-16 code units.
|
|
426
|
+
*/
|
|
427
|
+
sources?: {
|
|
428
|
+
query: string;
|
|
429
|
+
maxPassages?: number;
|
|
430
|
+
charBudget?: number;
|
|
431
|
+
};
|
|
417
432
|
maxResults?: number;
|
|
418
433
|
/**
|
|
419
434
|
* undefined → use WikiConfig.preFilterLimit (or no pre-filter if also unset).
|
|
@@ -847,9 +862,9 @@ type WikiDiagnosticSeverity = 'info' | 'warn' | 'error';
|
|
|
847
862
|
* Closed for this release series, but new codes are added in minor versions:
|
|
848
863
|
* hosts must tolerate codes they do not recognize.
|
|
849
864
|
*/
|
|
850
|
-
type WikiDiagnosticCode = 'ingest_chunk_failed' | 'fact_rejected' | 'task_rejected' | 'fact_deduplicated' | 'edge_dropped' | 'embedding_failed' | 'hook_failed' | 'background_job_failed' | 'heal_skipped' | 'grounding_missing' | 'grounding_failed' | 'classification_low_confidence' | 'classification_invalid' | 'llm_usage' | 'librarian_gate' | 'librarian_op_rejected' | 'contradicts_document' | 'resolve_failed' | 'read_budget' | 'event_retention_held' | 'event_created_at_clamped' | 'event_created_at_restamped' | 'external_deletion_pending' | 'external_deletion_discarded' | 'guidance_too_long' | 'guidance_resolver_failed' | 'source_pointer_unresolved' | 'source_pointer_invalid';
|
|
865
|
+
type WikiDiagnosticCode = 'ingest_chunk_failed' | 'fact_rejected' | 'task_rejected' | 'fact_deduplicated' | 'edge_dropped' | 'embedding_failed' | 'hook_failed' | 'background_job_failed' | 'heal_skipped' | 'grounding_missing' | 'grounding_failed' | 'classification_low_confidence' | 'classification_invalid' | 'llm_usage' | 'librarian_gate' | 'librarian_op_rejected' | 'contradicts_document' | 'resolve_failed' | 'read_budget' | 'event_retention_held' | 'prune_checkpoint_incomplete' | 'erase_secure_delete_off' | 'erase_entity_skipped' | 'erase_retired_vtab_undroppable' | 'erase_retired_remaining' | 'erase_tombstones_remaining' | 'erase_retired_read_failed' | 'erase_registry_sweep_skipped' | 'import_tombstone_skipped' | 'event_created_at_clamped' | 'event_created_at_restamped' | 'external_deletion_pending' | 'external_deletion_discarded' | 'guidance_too_long' | 'guidance_resolver_failed' | 'source_pointer_unresolved' | 'source_pointer_invalid' | 'source_store_source_too_large' | 'source_store_budget_exceeded' | 'source_store_hash_mismatch' | 'source_store_duplicate_hash' | 'source_store_text_not_storable';
|
|
851
866
|
/** The service run that emitted the diagnostic. */
|
|
852
|
-
type WikiDiagnosticOperation = 'ingest' | 'upsertGraph' | 'librarian' | 'heal' | 'ontologyBackfill' | 'reembed' | 'importDump' | 'write' | 'supersede' | 'remember' | 'read' | 'prune' | 'externalDeletion';
|
|
867
|
+
type WikiDiagnosticOperation = 'ingest' | 'upsertGraph' | 'librarian' | 'heal' | 'ontologyBackfill' | 'reembed' | 'importDump' | 'write' | 'supersede' | 'remember' | 'read' | 'prune' | 'externalDeletion' | 'sourceStore' | 'erase';
|
|
853
868
|
/** `'auto'` when a write threshold started the run (auto-librarian / auto-heal); `'call'` when the host did. */
|
|
854
869
|
type WikiDiagnosticTrigger = 'call' | 'auto';
|
|
855
870
|
/** Identifiers only — never titles, bodies, quotes, LLM output, provider messages, or hashes of content. */
|
|
@@ -896,6 +911,8 @@ interface WikiDiagnosticDetail {
|
|
|
896
911
|
guidanceLength?: number;
|
|
897
912
|
/** guidance_too_long only: which configured value was refused. */
|
|
898
913
|
guidanceSource?: 'per_entity' | 'default';
|
|
914
|
+
/** `erase_retired_remaining` only: retired FTS table names still present after reclamation. */
|
|
915
|
+
tables?: string[];
|
|
899
916
|
}
|
|
900
917
|
interface WikiDiagnostic {
|
|
901
918
|
code: WikiDiagnosticCode;
|
|
@@ -1001,16 +1018,33 @@ interface WikiOptions {
|
|
|
1001
1018
|
*/
|
|
1002
1019
|
onDiagnostic?: (diagnostic: WikiDiagnostic) => void;
|
|
1003
1020
|
}
|
|
1021
|
+
/** One windowed stored-source passage in a `read()` `sources` group (spec source-store section 7). */
|
|
1022
|
+
interface SourcePassage {
|
|
1023
|
+
entityId: string;
|
|
1024
|
+
sourceRef: string;
|
|
1025
|
+
sourceHash: string;
|
|
1026
|
+
seq: number;
|
|
1027
|
+
/** UTF-16 offset of `text` within the stored source, inclusive. */
|
|
1028
|
+
startOffset: number;
|
|
1029
|
+
/** UTF-16 offset, exclusive: `storedText.slice(startOffset, endOffset) === text`. */
|
|
1030
|
+
endOffset: number;
|
|
1031
|
+
/** True when `text` is a window cut from a larger passage. */
|
|
1032
|
+
truncated: boolean;
|
|
1033
|
+
text: string;
|
|
1034
|
+
}
|
|
1004
1035
|
interface MemoryBundle {
|
|
1005
1036
|
facts: WikiFact[];
|
|
1037
|
+
/** Present only when `read()` was given the `sources` option. Per-entity groups, never merged. */
|
|
1038
|
+
sources?: SourcePassage[];
|
|
1006
1039
|
tasks: WikiTask[];
|
|
1007
1040
|
events: WikiEvent[];
|
|
1008
1041
|
edges?: WikiEdge[];
|
|
1009
1042
|
/** Entity summary prose for OKF profile ≥ 1 round-trip. Omitted = no summary (Clanker default). */
|
|
1010
1043
|
summary?: string;
|
|
1011
1044
|
/**
|
|
1012
|
-
* The
|
|
1013
|
-
* trusts events at or before it as consolidated at the
|
|
1045
|
+
* The exporting database's librarian position. Set by export only; the
|
|
1046
|
+
* importer trusts events at or before it as consolidated at the exporting
|
|
1047
|
+
* database. (Not the source text store; spec source-store §8 naming note.)
|
|
1014
1048
|
*/
|
|
1015
1049
|
librarian_watermark?: {
|
|
1016
1050
|
at: number;
|
|
@@ -1025,9 +1059,63 @@ interface MemoryBundle {
|
|
|
1025
1059
|
tierFloors?: Record<string, number>;
|
|
1026
1060
|
};
|
|
1027
1061
|
}
|
|
1062
|
+
/** Result of `storeSource` (spec source-store §7). Refusals return `stored: false` with their diagnostics. */
|
|
1063
|
+
type StoreSourceResult = {
|
|
1064
|
+
stored: true;
|
|
1065
|
+
sourceRef: string;
|
|
1066
|
+
sourceHash: string;
|
|
1067
|
+
charCount: number;
|
|
1068
|
+
passageCount: number;
|
|
1069
|
+
storedAt: number;
|
|
1070
|
+
} | {
|
|
1071
|
+
stored: false;
|
|
1072
|
+
diagnostics: WikiDiagnostic[];
|
|
1073
|
+
};
|
|
1074
|
+
/** A stored source's text and metadata, as returned by `getStoredSource`. */
|
|
1075
|
+
interface StoredSource {
|
|
1076
|
+
sourceRef: string;
|
|
1077
|
+
sourceHash: string;
|
|
1078
|
+
text: string;
|
|
1079
|
+
charCount: number;
|
|
1080
|
+
storedAt: number;
|
|
1081
|
+
}
|
|
1082
|
+
/** One entry of `listStoredSources`. */
|
|
1083
|
+
interface StoredSourceSummary {
|
|
1084
|
+
sourceRef: string;
|
|
1085
|
+
sourceHash: string;
|
|
1086
|
+
charCount: number;
|
|
1087
|
+
passageCount: number;
|
|
1088
|
+
storedAt: number;
|
|
1089
|
+
}
|
|
1090
|
+
/** One stored source in a `MemoryDump` (spec source-store §8). Import re-derives passages and `text_hash` from `text`. */
|
|
1091
|
+
interface StoredSourceDump {
|
|
1092
|
+
sourceRef: string;
|
|
1093
|
+
sourceHash: string;
|
|
1094
|
+
text: string;
|
|
1095
|
+
textHash: string;
|
|
1096
|
+
charCount: number;
|
|
1097
|
+
storedAt: number;
|
|
1098
|
+
/** Fidelity only: import ignores this and re-cuts from `text`. */
|
|
1099
|
+
passages: Array<{
|
|
1100
|
+
seq: number;
|
|
1101
|
+
startOffset: number;
|
|
1102
|
+
endOffset: number;
|
|
1103
|
+
}>;
|
|
1104
|
+
}
|
|
1105
|
+
/** Result of `importDump` (spec source-store §8): sources the import refused. */
|
|
1106
|
+
interface ImportDumpResult {
|
|
1107
|
+
skippedSources: Array<{
|
|
1108
|
+
sourceRef: string;
|
|
1109
|
+
code: WikiDiagnosticCode;
|
|
1110
|
+
}>;
|
|
1111
|
+
}
|
|
1112
|
+
/** A dump entity: the bundle plus its stored sources (dump-only; `MemoryBundle` stays the read shape). */
|
|
1113
|
+
type MemoryDumpEntity = MemoryBundle & {
|
|
1114
|
+
storedSources?: StoredSourceDump[];
|
|
1115
|
+
};
|
|
1028
1116
|
interface MemoryDump {
|
|
1029
1117
|
generatedAt: number;
|
|
1030
|
-
entities: Record<string,
|
|
1118
|
+
entities: Record<string, MemoryDumpEntity>;
|
|
1031
1119
|
/**
|
|
1032
1120
|
* Source-pointer parse report (specs/source-pointers §Export, import, and OKF).
|
|
1033
1121
|
* Present ONLY when `parseOkfBundle` dropped a malformed `source_pointer`
|
|
@@ -1076,8 +1164,12 @@ interface EntityStatus {
|
|
|
1076
1164
|
* and `'forget'` were added in v3.0. `'ontologyBackfill'` was added afterward.
|
|
1077
1165
|
* Exhaustive `switch` / narrowing on this type must be updated (or given a
|
|
1078
1166
|
* `default` arm) to compile without errors.
|
|
1167
|
+
*
|
|
1168
|
+
* `'erase'` was added by a MINOR release (forget-erasure spec §2, ruling F).
|
|
1169
|
+
* Exhaustive switches over this type must add a `default` arm; widening this
|
|
1170
|
+
* union rides the MINOR by policy and does not recur as a breaking change.
|
|
1079
1171
|
*/
|
|
1080
|
-
type WikiBusyOperation = 'ingest' | 'librarian' | 'heal' | 'prune' | 'reembed' | 'import' | 'forget' | 'ontologyBackfill';
|
|
1172
|
+
type WikiBusyOperation = 'ingest' | 'librarian' | 'heal' | 'prune' | 'reembed' | 'import' | 'forget' | 'ontologyBackfill' | 'store' | 'erase';
|
|
1081
1173
|
/**
|
|
1082
1174
|
* Thrown when a background mutator is already running for the requested entity.
|
|
1083
1175
|
*/
|
|
@@ -1201,6 +1293,14 @@ declare class WikiTransactionError extends Error {
|
|
|
1201
1293
|
/** Selectors for {@link WikiMemory.forget}. `clearAll` excludes the other selectors. */
|
|
1202
1294
|
interface ForgetParams {
|
|
1203
1295
|
entryId?: string;
|
|
1296
|
+
/**
|
|
1297
|
+
* With `entryId` only: also forget the entry's supersession chain (every
|
|
1298
|
+
* predecessor and successor reached by walking `superseded_by` links, capped
|
|
1299
|
+
* at 100 per direction). The walk is NOT the connected component: with
|
|
1300
|
+
* fan-in A→C←B, forgetting A reaches C but not B. The forward walk deletes
|
|
1301
|
+
* the live current fact. Does not compose with other selectors.
|
|
1302
|
+
*/
|
|
1303
|
+
includeChain?: boolean;
|
|
1204
1304
|
taskId?: string;
|
|
1205
1305
|
sourceRef?: string;
|
|
1206
1306
|
sourceHash?: string;
|
|
@@ -1221,6 +1321,12 @@ interface ForgetResult {
|
|
|
1221
1321
|
events?: number;
|
|
1222
1322
|
};
|
|
1223
1323
|
metadataReset?: boolean;
|
|
1324
|
+
/** With `includeChain`: the chain ids forgotten alongside `entryId` (excludes `entryId`). */
|
|
1325
|
+
chainEntryIds?: string[];
|
|
1326
|
+
/** With `includeChain`: true when the walk hit the depth cap and the chain was cut short. */
|
|
1327
|
+
truncated?: boolean;
|
|
1328
|
+
/** Present with `truncated`: the depth-cap notice. */
|
|
1329
|
+
notice?: string;
|
|
1224
1330
|
}
|
|
1225
1331
|
/**
|
|
1226
1332
|
* Thrown by `runPrune()` after it has finished its other work, when the host's
|
|
@@ -1705,6 +1811,7 @@ declare class EntryRepository extends BaseRepository {
|
|
|
1705
1811
|
id: string;
|
|
1706
1812
|
entity_id: string;
|
|
1707
1813
|
updated_at: number;
|
|
1814
|
+
deleted_at: number | null;
|
|
1708
1815
|
}>>;
|
|
1709
1816
|
findIdById(id: string, entityId: string, tx?: SQLiteAdapter): Promise<string | null>;
|
|
1710
1817
|
findIdsBySource(entityId: string, sourceRef: string | null, sourceHash: string | null, tx?: SQLiteAdapter, includeDeleted?: boolean): Promise<string[]>;
|
|
@@ -1730,7 +1837,9 @@ declare class EntryRepository extends BaseRepository {
|
|
|
1730
1837
|
* Fetch IDs + entity_ids of soft-deleted rows older than cutoff for a given entity.
|
|
1731
1838
|
* Used by runPrune().
|
|
1732
1839
|
*/
|
|
1733
|
-
getPrunableMetadata(entityId: string, cutoff: number, tx?: SQLiteAdapter
|
|
1840
|
+
getPrunableMetadata(entityId: string, cutoff: number, tx?: SQLiteAdapter, opts?: {
|
|
1841
|
+
noCutoff?: boolean;
|
|
1842
|
+
}): Promise<Array<{
|
|
1734
1843
|
id: string;
|
|
1735
1844
|
entity_id: string;
|
|
1736
1845
|
}>>;
|
|
@@ -1738,7 +1847,9 @@ declare class EntryRepository extends BaseRepository {
|
|
|
1738
1847
|
* Fetch all non-deleted entries for an entity, ordered by updated_at DESC.
|
|
1739
1848
|
* Used by _getFullBundle().
|
|
1740
1849
|
*/
|
|
1741
|
-
findAllByEntityId(entityId: string, tx?: SQLiteAdapter
|
|
1850
|
+
findAllByEntityId(entityId: string, tx?: SQLiteAdapter, opts?: {
|
|
1851
|
+
includeDeleted?: boolean;
|
|
1852
|
+
}): Promise<WikiFact[]>;
|
|
1742
1853
|
/**
|
|
1743
1854
|
* Fetch live, mutable entries for an entity — everything heal is allowed to
|
|
1744
1855
|
* downgrade or delete — oldest first, capped at `limit`, skipping anything
|
|
@@ -1780,7 +1891,9 @@ declare class EntryRepository extends BaseRepository {
|
|
|
1780
1891
|
* Fetch all non-deleted entries for an entity with embedding blobs preserved.
|
|
1781
1892
|
* Used by ImportExportService for export/import round-tripping.
|
|
1782
1893
|
*/
|
|
1783
|
-
findAllByEntityIdWithBlobs(entityId: string, tx?: SQLiteAdapter
|
|
1894
|
+
findAllByEntityIdWithBlobs(entityId: string, tx?: SQLiteAdapter, opts?: {
|
|
1895
|
+
includeDeleted?: boolean;
|
|
1896
|
+
}): Promise<WikiFact[]>;
|
|
1784
1897
|
/**
|
|
1785
1898
|
* Count non-deleted entries for the given entities whose embedding_blob dimension
|
|
1786
1899
|
* doesn't match queryVecLength. Used by read() to detect model-switch mismatches.
|
|
@@ -1805,6 +1918,7 @@ declare class EntryRepository extends BaseRepository {
|
|
|
1805
1918
|
bulkDeletePruned(entityId: string, cutoff: number, ids: string[], tx: SQLiteAdapter, opts?: {
|
|
1806
1919
|
keepUnconfirmedRemovals?: boolean;
|
|
1807
1920
|
deletedIds?: string[];
|
|
1921
|
+
noCutoff?: boolean;
|
|
1808
1922
|
}): Promise<number>;
|
|
1809
1923
|
/**
|
|
1810
1924
|
* Mark orphaned entries (never accessed, old) as deleted.
|
|
@@ -1842,9 +1956,25 @@ declare class EntryRepository extends BaseRepository {
|
|
|
1842
1956
|
* entries_temporal_idx.
|
|
1843
1957
|
*/
|
|
1844
1958
|
findNonLiveIdsByEntityIds(entityIds: readonly string[], mode: LiveMode, t: number, tx?: SQLiteAdapter): Promise<Set<string>>;
|
|
1959
|
+
/**
|
|
1960
|
+
* Depth-aware supersession walk for chain forget (spec forget-erasure §3).
|
|
1961
|
+
* Probes `maxDepth + 1` levels so a chain longer than the cap is detectable;
|
|
1962
|
+
* the returned ids are capped to `maxDepth` per direction (successors nearest first; predecessors are returned farthest-first).
|
|
1963
|
+
* No `deleted_at` filter: soft-deleted links still carry the chain.
|
|
1964
|
+
*/
|
|
1965
|
+
findSupersessionChainWalk(entityId: string, factId: string, maxDepth: number, tx?: SQLiteAdapter): Promise<{
|
|
1966
|
+
ids: string[];
|
|
1967
|
+
truncated: boolean;
|
|
1968
|
+
}>;
|
|
1845
1969
|
findSupersessionChainIds(entityId: string, factId: string, maxDepth: number, tx?: SQLiteAdapter): Promise<{
|
|
1846
|
-
predecessors:
|
|
1847
|
-
|
|
1970
|
+
predecessors: Array<{
|
|
1971
|
+
id: string;
|
|
1972
|
+
depth: number;
|
|
1973
|
+
}>;
|
|
1974
|
+
successors: Array<{
|
|
1975
|
+
id: string;
|
|
1976
|
+
depth: number;
|
|
1977
|
+
}>;
|
|
1848
1978
|
}>;
|
|
1849
1979
|
findExpiredIds(entityId: string, cutoff: number, tx?: SQLiteAdapter): Promise<string[]>;
|
|
1850
1980
|
/**
|
|
@@ -1954,6 +2084,11 @@ declare class EntryRepository extends BaseRepository {
|
|
|
1954
2084
|
sourceHash: string | null;
|
|
1955
2085
|
factCount: number;
|
|
1956
2086
|
lastIngestedAt: number;
|
|
2087
|
+
/** Spec source-store §4 three-state: exact pair / stale hash / nothing stored. */
|
|
2088
|
+
stored?: {
|
|
2089
|
+
charCount: number;
|
|
2090
|
+
staleHash?: true;
|
|
2091
|
+
} | null;
|
|
1957
2092
|
}>>;
|
|
1958
2093
|
/**
|
|
1959
2094
|
* Count live entries for an entity across all source_refs/source_hashes.
|
|
@@ -2123,6 +2258,10 @@ type LibrarianWatermark = {
|
|
|
2123
2258
|
at: number;
|
|
2124
2259
|
id: string;
|
|
2125
2260
|
};
|
|
2261
|
+
/** A `wal_checkpoint(TRUNCATE)` that did not fully drain the WAL (erase step 5/8). */
|
|
2262
|
+
declare class CheckpointIncompleteError extends Error {
|
|
2263
|
+
readonly code = "erase_checkpoint_incomplete";
|
|
2264
|
+
}
|
|
2126
2265
|
declare class MetadataRepository extends BaseRepository {
|
|
2127
2266
|
getCheckpoint(entityId: string, tx: SQLiteAdapter): Promise<{
|
|
2128
2267
|
memory?: number;
|
|
@@ -2150,6 +2289,12 @@ declare class MetadataRepository extends BaseRepository {
|
|
|
2150
2289
|
clearDimensionMismatch(tx: SQLiteAdapter): Promise<void>;
|
|
2151
2290
|
tableExists(tableName: string, tx?: SQLiteAdapter): Promise<boolean>;
|
|
2152
2291
|
getTableDdl(tableName: string, tx?: SQLiteAdapter): Promise<string | null>;
|
|
2292
|
+
/**
|
|
2293
|
+
* `PRAGMA wal_checkpoint(TRUNCATE)`, verified: `busy !== 0` or
|
|
2294
|
+
* `log !== checkpointed` means frames survive in the WAL, so a deleted
|
|
2295
|
+
* row's bytes may still be on disk. Non-WAL reports (0,-1,-1) = complete.
|
|
2296
|
+
*/
|
|
2297
|
+
checkpointTruncateVerified(): Promise<void>;
|
|
2153
2298
|
vacuum(): Promise<void>;
|
|
2154
2299
|
/**
|
|
2155
2300
|
* Returns the set of distinct `entity_id` values across entries/tasks/events.
|
|
@@ -2159,8 +2304,16 @@ declare class MetadataRepository extends BaseRepository {
|
|
|
2159
2304
|
* soft-deleted, so the host's maintenance sweep can visit such
|
|
2160
2305
|
* "decommissioned-scope" namespaces and reap the soft-deleted rows. Sorting
|
|
2161
2306
|
* is `entity_id COLLATE BINARY` for stable, locale-independent ordering.
|
|
2162
|
-
|
|
2163
|
-
|
|
2307
|
+
*
|
|
2308
|
+
* With `opts.softDeletedAtOrBefore` the walk is narrowed to entities holding
|
|
2309
|
+
* at least one soft-deleted entry or task with `deleted_at` at or before
|
|
2310
|
+
* that cutoff (erase's hard-delete walk, forget-erasure spec §2). Without
|
|
2311
|
+
* the option the host-facing semantics above are unchanged.
|
|
2312
|
+
*/
|
|
2313
|
+
getDistinctEntityIds(tx?: SQLiteAdapter, opts?: {
|
|
2314
|
+
softDeletedAtOrBefore?: number;
|
|
2315
|
+
softDeletedAll?: boolean;
|
|
2316
|
+
}): Promise<string[]>;
|
|
2164
2317
|
getManifest(entityId: string, tx?: SQLiteAdapter): Promise<{
|
|
2165
2318
|
mode: OntologyMode;
|
|
2166
2319
|
manifest: OntologyManifest;
|
|
@@ -2222,6 +2375,23 @@ interface IndexSearchResult {
|
|
|
2222
2375
|
*/
|
|
2223
2376
|
entity_id: string;
|
|
2224
2377
|
}
|
|
2378
|
+
/**
|
|
2379
|
+
* One passage hit with everything the read window needs. `text` is the whole
|
|
2380
|
+
* passage, sliced in JS from `source_documents.text` at [start_offset,
|
|
2381
|
+
* end_offset) (spec source-store section 7; never SQL substr).
|
|
2382
|
+
*/
|
|
2383
|
+
interface PassageHit {
|
|
2384
|
+
id: string;
|
|
2385
|
+
entity_id: string;
|
|
2386
|
+
document_id: string;
|
|
2387
|
+
score: number;
|
|
2388
|
+
seq: number;
|
|
2389
|
+
start_offset: number;
|
|
2390
|
+
end_offset: number;
|
|
2391
|
+
source_ref: string;
|
|
2392
|
+
source_hash: string;
|
|
2393
|
+
text: string;
|
|
2394
|
+
}
|
|
2225
2395
|
/** One drain turn's shape (spec #280 Change 3 "drain interface"). */
|
|
2226
2396
|
interface DrainOptions$1 {
|
|
2227
2397
|
/** `monotonicNow()` timestamp, checked between chunk transactions. Full mode only; default now + the strategy's budget. */
|
|
@@ -2321,6 +2491,15 @@ interface IndexStrategy {
|
|
|
2321
2491
|
* transactions.
|
|
2322
2492
|
*/
|
|
2323
2493
|
drain?(opts?: DrainOptions$1): Promise<void>;
|
|
2494
|
+
/**
|
|
2495
|
+
* Best-match-first stored-source passage search (spec source-store section 7),
|
|
2496
|
+
* optional like `drain?`. A strategy without it, or the degraded stand-in,
|
|
2497
|
+
* yields no passages.
|
|
2498
|
+
*/
|
|
2499
|
+
searchPassages?(query: string, options: {
|
|
2500
|
+
entityIds: string[];
|
|
2501
|
+
limit: number;
|
|
2502
|
+
}): Promise<PassageHit[]>;
|
|
2324
2503
|
}
|
|
2325
2504
|
|
|
2326
2505
|
interface ScoredRow {
|
|
@@ -2466,6 +2645,37 @@ declare class SearchService {
|
|
|
2466
2645
|
* Executes a keyword search against the active index strategy.
|
|
2467
2646
|
*/
|
|
2468
2647
|
searchKeyword(query: string, entityIds: string[], limit: number): Promise<IndexSearchResult[]>;
|
|
2648
|
+
/**
|
|
2649
|
+
* Post-commit passage index sync (spec source-store section 6). FTS5: drains the
|
|
2650
|
+
* passage ledger (per document, entity-scoped when given). MiniSearch: reloads
|
|
2651
|
+
* the entity's stored passages (all stored entities when omitted: the open-time
|
|
2652
|
+
* pass). Serialized on the sync chain; never rejects, like sync().
|
|
2653
|
+
*/
|
|
2654
|
+
syncPassages(db: SQLiteAdapter, prefix: string, entityId?: string, deadline?: number): Promise<void>;
|
|
2655
|
+
/** Run `fn` on the sync chain; the caller sees its rejection, the chain never rejects. */
|
|
2656
|
+
private chainSurfaced;
|
|
2657
|
+
/** True when the active strategy has both strict erase drains (FTS5); false for MiniSearch / Unavailable. */
|
|
2658
|
+
hasStrictDrain(): boolean;
|
|
2659
|
+
/** Erase step 3: chained passage drain, no deadline, errors surfaced. */
|
|
2660
|
+
drainPassagesSurfaced(): Promise<void>;
|
|
2661
|
+
/** Erase step 4: listed retired FTS tables (empty for strategies without any). */
|
|
2662
|
+
retiredTables(): Promise<string[]>;
|
|
2663
|
+
/** True when the active strategy can DROP retired tables (FTS5); false for MiniSearch / Unavailable. */
|
|
2664
|
+
canReclaimRetired(): boolean;
|
|
2665
|
+
/** Erase step 3: store-wide entries-side fts_pending drain on the sync chain, no deadline, errors surfaced. */
|
|
2666
|
+
drainEntriesLedgerSurfaced(): Promise<void>;
|
|
2667
|
+
/** Erase step 4: reclaim retired tables to completion; errors surfaced. */
|
|
2668
|
+
reclaimRetiredSurfaced(): Promise<void>;
|
|
2669
|
+
/** Erase step 7: FTS optimize on every FTS table that exists. */
|
|
2670
|
+
optimizeSurfaced(): Promise<void>;
|
|
2671
|
+
/** `erase({ rebuild: true })` wiring point; the orchestration (T6) calls it. */
|
|
2672
|
+
rebuildSurfaced(): Promise<void>;
|
|
2673
|
+
/**
|
|
2674
|
+
* Stored-source passage search for ONE entity (spec source-store section 7:
|
|
2675
|
+
* ranking and caps are per entity). Rides the active strategy; a strategy
|
|
2676
|
+
* without passage search yields none.
|
|
2677
|
+
*/
|
|
2678
|
+
searchPassages(query: string, entityId: string, limit: number): Promise<PassageHit[]>;
|
|
2469
2679
|
/**
|
|
2470
2680
|
* Pre-fetches keyword scores for candidate hydration, used during hybrid weighting.
|
|
2471
2681
|
*/
|
|
@@ -2495,7 +2705,7 @@ declare class SearchService {
|
|
|
2495
2705
|
private _compareSearchResults;
|
|
2496
2706
|
}
|
|
2497
2707
|
|
|
2498
|
-
type OperationType = 'prune' | 'librarian' | 'heal' | 'ingest' | 'reembed' | 'global_reembed' | 'import' | 'global_import' | 'forget' | 'ontologyBackfill';
|
|
2708
|
+
type OperationType = 'prune' | 'librarian' | 'heal' | 'ingest' | 'reembed' | 'global_reembed' | 'import' | 'global_import' | 'forget' | 'ontologyBackfill' | 'store' | 'erase';
|
|
2499
2709
|
declare class JobManager {
|
|
2500
2710
|
private prefix;
|
|
2501
2711
|
private activeMaintenanceJobs;
|
|
@@ -2543,15 +2753,17 @@ declare class JobManager {
|
|
|
2543
2753
|
private _pruneKey;
|
|
2544
2754
|
private _reembedKey;
|
|
2545
2755
|
private _globalReembedKey;
|
|
2756
|
+
private _eraseKey;
|
|
2546
2757
|
private _importKey;
|
|
2547
2758
|
private _globalImportKey;
|
|
2548
2759
|
private _forgetKey;
|
|
2549
2760
|
private _librarianKey;
|
|
2761
|
+
private _storeKey;
|
|
2550
2762
|
private _healKey;
|
|
2551
2763
|
private _ontologyBackfillKey;
|
|
2552
2764
|
/**
|
|
2553
2765
|
* Lookup table for acquireLock/releaseLock's dynamic-dispatch branch.
|
|
2554
|
-
* Excludes 'ingest' | 'global_reembed' | 'global_import', which those
|
|
2766
|
+
* Excludes 'ingest' | 'global_reembed' | 'global_import' | 'erase', which those
|
|
2555
2767
|
* methods already handle via explicit if/else branches before reaching
|
|
2556
2768
|
* this table.
|
|
2557
2769
|
*/
|
|
@@ -2572,13 +2784,19 @@ declare class JobManager {
|
|
|
2572
2784
|
*/
|
|
2573
2785
|
isAnyReembedActive(): boolean;
|
|
2574
2786
|
private _isImportActiveFor;
|
|
2787
|
+
private _isStoreActiveFor;
|
|
2575
2788
|
private _isForgetActiveFor;
|
|
2576
2789
|
private _isAnyMaintenanceActiveWithSuffix;
|
|
2577
2790
|
private _hasIngestJob;
|
|
2578
2791
|
private _addIngestJob;
|
|
2579
2792
|
private _removeIngestJob;
|
|
2580
2793
|
private _isIngestActiveFor;
|
|
2581
|
-
|
|
2794
|
+
/**
|
|
2795
|
+
* `owner` is the fourth parameter (the third, `sourceRef`, is ingest-only).
|
|
2796
|
+
* `'erase'` marks the erase() pipeline's own per-entity prune, the only
|
|
2797
|
+
* operation exempt from the universal erase pre-check below.
|
|
2798
|
+
*/
|
|
2799
|
+
acquireLock(operation: OperationType, entityId: string, sourceRef?: string, owner?: 'host' | 'erase'): void;
|
|
2582
2800
|
releaseLock(operation: OperationType, entityId: string, sourceRef?: string): void;
|
|
2583
2801
|
/**
|
|
2584
2802
|
* Returns true if acquireLock(operation, entityId) would throw WikiBusyError.
|
|
@@ -3344,6 +3562,7 @@ declare class TaskRepository extends BaseRepository {
|
|
|
3344
3562
|
id: string;
|
|
3345
3563
|
entity_id: string;
|
|
3346
3564
|
updated_at: number;
|
|
3565
|
+
deleted_at: number | null;
|
|
3347
3566
|
}>>;
|
|
3348
3567
|
/**
|
|
3349
3568
|
* Upsert a WikiTask within the provided transaction.
|
|
@@ -3369,12 +3588,16 @@ declare class TaskRepository extends BaseRepository {
|
|
|
3369
3588
|
* Fetch all non-deleted tasks for an entity, ordered by priority DESC, created_at ASC.
|
|
3370
3589
|
* Used by _getFullBundle().
|
|
3371
3590
|
*/
|
|
3372
|
-
findAllByEntityId(entityId: string, tx?: SQLiteAdapter
|
|
3591
|
+
findAllByEntityId(entityId: string, tx?: SQLiteAdapter, opts?: {
|
|
3592
|
+
includeDeleted?: boolean;
|
|
3593
|
+
}): Promise<WikiTask[]>;
|
|
3373
3594
|
/**
|
|
3374
3595
|
* Bulk delete pruned tasks (already soft-deleted) by cutoff date.
|
|
3375
3596
|
* Used by runPrune(). Returns number of deleted rows.
|
|
3376
3597
|
*/
|
|
3377
|
-
bulkDeletePruned(entityId: string, cutoff: number, tx: SQLiteAdapter
|
|
3598
|
+
bulkDeletePruned(entityId: string, cutoff: number, tx: SQLiteAdapter, opts?: {
|
|
3599
|
+
noCutoff?: boolean;
|
|
3600
|
+
}): Promise<number>;
|
|
3378
3601
|
/**
|
|
3379
3602
|
* Soft-delete a task by ID within a transaction.
|
|
3380
3603
|
* Stages a DELETE outbox entry in the same transaction.
|
|
@@ -3578,6 +3801,48 @@ declare const ONTOLOGY_BACKFILL_RECHECK_MS: number;
|
|
|
3578
3801
|
declare const HEAL_BATCH_SIZE = 25;
|
|
3579
3802
|
/** Cooldown before an already-healed fact is offered again. Matches ontology backfill. */
|
|
3580
3803
|
declare const HEAL_RECHECK_MS: number;
|
|
3804
|
+
/** Report of the erase core (steps 0/1/1b); T6 extends it with the file steps. */
|
|
3805
|
+
interface EraseReport {
|
|
3806
|
+
/** True only when every step ran and the pragma read back ON. */
|
|
3807
|
+
verified: boolean;
|
|
3808
|
+
/** `PRAGMA secure_delete` as read back on the connection (1 = ON). */
|
|
3809
|
+
secureDelete: number | null;
|
|
3810
|
+
sqliteVersion: string;
|
|
3811
|
+
/** Entities step 1 enumerated. */
|
|
3812
|
+
entities: string[];
|
|
3813
|
+
/** External-removal holds, per entity (event-retention holds cannot arise: events are kept). */
|
|
3814
|
+
holds: Array<{
|
|
3815
|
+
entityId: string;
|
|
3816
|
+
deleted: number;
|
|
3817
|
+
deletedTasks: number;
|
|
3818
|
+
failedAt: string;
|
|
3819
|
+
remaining: number;
|
|
3820
|
+
}>;
|
|
3821
|
+
/** Entities skipped because their per-entity prune lock was busy. */
|
|
3822
|
+
skipped: string[];
|
|
3823
|
+
/** Superset of the hard-deleted entry ids, for the step-6 index sync (containment, not equality). */
|
|
3824
|
+
syncedIds: string[];
|
|
3825
|
+
registrySweep: {
|
|
3826
|
+
skipped: boolean;
|
|
3827
|
+
deleted: number;
|
|
3828
|
+
};
|
|
3829
|
+
/** Retired FTS tables left listed (module-less runtime): shadow tables emptied, DROP deferred to an FTS5-capable open. */
|
|
3830
|
+
retiredUndroppable: string[];
|
|
3831
|
+
failedStep: 'secure_delete' | 'vacuum' | 'checkpoint' | 'prune' | 'registry_sweep' | 'passage_drain' | 'retired_reclaim' | 'index_sync' | 'optimize' | 'rebuild' | 'tombstone_gate' | null;
|
|
3832
|
+
/** JS runtime the erase ran on (no overclaiming: this is not a storage-layer guarantee). */
|
|
3833
|
+
runtime: string;
|
|
3834
|
+
/** Every step's outcome, in execution order; a failed step is last. `partial` = ran with skipped entities or holds, or was skipped by design (`registry_sweep` on a pre-v9 store; `tombstone_gate` when holds/skips already account for surviving rows). */
|
|
3835
|
+
steps: Array<{
|
|
3836
|
+
step: string;
|
|
3837
|
+
outcome: 'ok' | 'partial' | 'failed';
|
|
3838
|
+
}>;
|
|
3839
|
+
}
|
|
3840
|
+
/** A failed erase step: carries the partial report (`verified: false`). */
|
|
3841
|
+
declare class EraseStepError extends Error {
|
|
3842
|
+
readonly code: string;
|
|
3843
|
+
readonly report: EraseReport;
|
|
3844
|
+
constructor(code: string, message: string, report: EraseReport, cause?: unknown);
|
|
3845
|
+
}
|
|
3581
3846
|
declare class MaintenanceService {
|
|
3582
3847
|
private db;
|
|
3583
3848
|
private prefix;
|
|
@@ -3600,11 +3865,52 @@ declare class MaintenanceService {
|
|
|
3600
3865
|
retainSoftDeletedFor?: number | null;
|
|
3601
3866
|
retainEventsFor?: number | null;
|
|
3602
3867
|
vacuum?: boolean;
|
|
3868
|
+
syncedIds?: string[];
|
|
3603
3869
|
}): Promise<{
|
|
3604
3870
|
entries: number;
|
|
3605
3871
|
tasks: number;
|
|
3606
3872
|
events: number;
|
|
3607
3873
|
}>;
|
|
3874
|
+
/**
|
|
3875
|
+
* Shared prune body. `owner: 'erase'` lets erase()'s own per-entity prune
|
|
3876
|
+
* through the universal erase fence in JobManager; the public `runPrune`
|
|
3877
|
+
* always passes `'host'`.
|
|
3878
|
+
*/
|
|
3879
|
+
private _runPrune;
|
|
3880
|
+
/** Shared by runPrune and erase step 5. */
|
|
3881
|
+
private _wrappedVacuum;
|
|
3882
|
+
/**
|
|
3883
|
+
* Erase core (forget-erasure spec §2, steps 0 / 1 / 1b). Thin entry: T6
|
|
3884
|
+
* completes the pipeline (FTS, VACUUM, checkpoint, sync). Never reports a
|
|
3885
|
+
* success it cannot verify: a failed step throws {@link EraseStepError}
|
|
3886
|
+
* carrying the partial report with `verified: false`.
|
|
3887
|
+
*/
|
|
3888
|
+
erase(opts?: {
|
|
3889
|
+
rebuild?: boolean;
|
|
3890
|
+
}): Promise<EraseReport>;
|
|
3891
|
+
/**
|
|
3892
|
+
* Step 3: chained, surfaced drains (no deadline). Entries-ledger failures are
|
|
3893
|
+
* the entries/index-sync step (`index_sync`); passage failures `passage_drain`.
|
|
3894
|
+
* N2 guard (probe lives here, strategy-agnostic): a strategy without the strict
|
|
3895
|
+
* drains (Unavailable / MiniSearch) cannot drain, so rows in either FTS ledger
|
|
3896
|
+
* mean text was never drained -> the step fails and erasure is unverified.
|
|
3897
|
+
* Absent or empty ledgers proceed.
|
|
3898
|
+
*/
|
|
3899
|
+
_eraseDrainPassages(report: EraseReport): Promise<void>;
|
|
3900
|
+
/**
|
|
3901
|
+
* Step 4 (and its re-run after step 6): reclaim retired FTS tables to
|
|
3902
|
+
* completion. A module-less runtime cannot DROP a virtual table, so each
|
|
3903
|
+
* retired table's shadow tables are emptied under the pragma and the name
|
|
3904
|
+
* stays listed; a later FTS5-capable open's step 4 completes the DROP.
|
|
3905
|
+
*/
|
|
3906
|
+
_eraseReclaimRetired(report: EraseReport): Promise<void>;
|
|
3907
|
+
/** Retired list straight from metadata (same key Fts5IndexStrategy maintains), independent of the active strategy. */
|
|
3908
|
+
private _retiredList;
|
|
3909
|
+
private sourceTableExists;
|
|
3910
|
+
/** Step 6 sync: `syncEntries` resolving false means the ledger drain failed — a failed step. */
|
|
3911
|
+
_eraseSyncEntries(entityId: string, ids: string[], report: EraseReport): Promise<void>;
|
|
3912
|
+
/** Step 7: FTS optimize on both FTS tables, after syncEntries. */
|
|
3913
|
+
_eraseOptimize(report: EraseReport): Promise<void>;
|
|
3608
3914
|
runLibrarian(entityId: string, options?: {
|
|
3609
3915
|
promptOverride?: string;
|
|
3610
3916
|
}): Promise<void>;
|
|
@@ -3669,6 +3975,8 @@ declare class MaintenanceService {
|
|
|
3669
3975
|
* as WikiMemory.setup() documents.
|
|
3670
3976
|
*/
|
|
3671
3977
|
private sourceRefIndexPresent;
|
|
3978
|
+
/** A never-set-up store has no source-store tables (#316 recovery); nothing to delete there. */
|
|
3979
|
+
private sourceStorePresent;
|
|
3672
3980
|
/**
|
|
3673
3981
|
* Read-only dry-run preview of {@link forget}. Returns the same shape as a
|
|
3674
3982
|
* real call would, without acquiring the lock, opening a transaction, staging
|
|
@@ -3854,17 +4162,35 @@ declare class ImportExportService {
|
|
|
3854
4162
|
private embeddingService;
|
|
3855
4163
|
private options;
|
|
3856
4164
|
private vectorRemoval?;
|
|
3857
|
-
|
|
3858
|
-
|
|
4165
|
+
/** Table prefix for the source store; undefined (unit-test mocks) means no store access. */
|
|
4166
|
+
private prefix?;
|
|
4167
|
+
constructor(db: SQLiteAdapter, entryRepo: EntryRepository, taskRepo: TaskRepository, eventRepo: EventRepository, edgeRepo: EdgeRepository, metadataRepo: MetadataRepository, searchService: SearchService, jobManager: JobManager, embeddingService: EmbeddingService, options?: Pick<WikiOptions, 'onDiagnostic' | 'forceDeleteIgnoreRankerHook' | 'config'>, vectorRemoval?: VectorRemovalService | undefined,
|
|
4168
|
+
/** Table prefix for the source store; undefined (unit-test mocks) means no store access. */
|
|
4169
|
+
prefix?: string | undefined);
|
|
4170
|
+
exportDump(entityIds?: string[], opts?: {
|
|
4171
|
+
includeForgotten?: boolean;
|
|
4172
|
+
}): Promise<MemoryDump>;
|
|
3859
4173
|
importDump(dump: MemoryDump, opts?: {
|
|
3860
4174
|
merge?: boolean;
|
|
3861
|
-
}): Promise<
|
|
4175
|
+
}): Promise<ImportDumpResult>;
|
|
4176
|
+
private storePrefix;
|
|
4177
|
+
private storePresent;
|
|
4178
|
+
/** Spec source-store §8: stored sources for one exported entity; [] when none. */
|
|
4179
|
+
private exportStoredSources;
|
|
4180
|
+
/**
|
|
4181
|
+
* Spec source-store §8/§9 import step, inside the import transaction. One
|
|
4182
|
+
* source at a time; a refusal skips that source only. Uses the
|
|
4183
|
+
* same upsert helper as SourceStoreService.storeSource, inside this transaction. A ref already stored is replaced: the dump is the
|
|
4184
|
+
* truth for that ref (so no hash_mismatch refusal on import).
|
|
4185
|
+
*/
|
|
4186
|
+
private importStoredSources;
|
|
3862
4187
|
getFullBundle(entityId: string, opts?: {
|
|
3863
4188
|
maxEvents?: number;
|
|
3864
4189
|
includeBlobs?: boolean;
|
|
4190
|
+
includeForgotten?: boolean;
|
|
3865
4191
|
}): Promise<MemoryBundle>;
|
|
3866
4192
|
/** Single-entity import transaction + post-processing; package-internal hook for tests. */
|
|
3867
|
-
doImportEntity(entityId: string, bundle:
|
|
4193
|
+
doImportEntity(entityId: string, bundle: MemoryDumpEntity, merge: boolean): Promise<ImportDumpResult['skippedSources']>;
|
|
3868
4194
|
private _warnCrossEntityCollision;
|
|
3869
4195
|
private _normalizeImportedSourceType;
|
|
3870
4196
|
assertNoLegacySourceTypes(): Promise<void>;
|
|
@@ -3879,6 +4205,13 @@ declare class RetrievalService {
|
|
|
3879
4205
|
private searchService;
|
|
3880
4206
|
constructor(options: WikiOptions, entryRepo: EntryRepository, taskRepo: TaskRepository, eventRepo: EventRepository, metadataRepo: MetadataRepository, searchService: SearchService);
|
|
3881
4207
|
read(entityId: string | string[], query: string, options?: ReadOptions): Promise<MemoryBundle>;
|
|
4208
|
+
/**
|
|
4209
|
+
* The `sources` group (spec source-store section 7). One search per entity,
|
|
4210
|
+
* so ranking and caps never cross entities. No model call anywhere.
|
|
4211
|
+
* `charBudget` is per entity: windows are cut in rank order against the
|
|
4212
|
+
* entity's remaining budget, and once it is spent lower-ranked hits are not returned.
|
|
4213
|
+
*/
|
|
4214
|
+
private _readSources;
|
|
3882
4215
|
/**
|
|
3883
4216
|
* Returns entity IDs that will participate in scored retrieval.
|
|
3884
4217
|
* Excludes zero-weight entities unless includeZeroWeightEntities is true.
|
|
@@ -4020,6 +4353,7 @@ declare class WikiMemory {
|
|
|
4020
4353
|
private importExportService;
|
|
4021
4354
|
private retrievalService;
|
|
4022
4355
|
private writeService;
|
|
4356
|
+
private sourceStoreService;
|
|
4023
4357
|
private promptService;
|
|
4024
4358
|
private ontologyService;
|
|
4025
4359
|
private graphTraversalService;
|
|
@@ -4086,9 +4420,13 @@ declare class WikiMemory {
|
|
|
4086
4420
|
* host runs a plain `setup()` outside the lease.
|
|
4087
4421
|
*
|
|
4088
4422
|
* Keyword-index catch-up work is bounded by `config.setupBudgetMs`; anything
|
|
4089
|
-
* left converges on later opens and no-arg `syncSearchIndex()` calls
|
|
4090
|
-
*
|
|
4091
|
-
*
|
|
4423
|
+
* left converges on later opens, and on no-arg `syncSearchIndex()` calls for
|
|
4424
|
+
* the entries ledger. Passage-ledger leftover converges on later opens and on
|
|
4425
|
+
* passage-store writes for the entity (`storeSource`, `forget`,
|
|
4426
|
+
* `importDump`), which drain that entity's rows; no-arg calls do not touch
|
|
4427
|
+
* the passage ledger. Not bounded: an index reset (tokenizer change, re-attach
|
|
4428
|
+
* after detach, a lost or inconsistent index), which runs as one unchunked
|
|
4429
|
+
* transaction.
|
|
4092
4430
|
*/
|
|
4093
4431
|
setup(opts?: {
|
|
4094
4432
|
migrations?: MigrationPolicy;
|
|
@@ -4172,6 +4510,10 @@ declare class WikiMemory {
|
|
|
4172
4510
|
sourceHash: string | null;
|
|
4173
4511
|
factCount: number;
|
|
4174
4512
|
lastIngestedAt: number;
|
|
4513
|
+
stored?: {
|
|
4514
|
+
charCount: number;
|
|
4515
|
+
staleHash?: true;
|
|
4516
|
+
} | null;
|
|
4175
4517
|
}>>;
|
|
4176
4518
|
/**
|
|
4177
4519
|
* Returns the live source_refs for an entity that hold the given source_hash.
|
|
@@ -4211,6 +4553,15 @@ declare class WikiMemory {
|
|
|
4211
4553
|
listEntityIds(options?: {
|
|
4212
4554
|
prefix?: string;
|
|
4213
4555
|
}): Promise<string[]>;
|
|
4556
|
+
/**
|
|
4557
|
+
* Erase everything soft-deleted, store-wide, and verify it (forget-erasure
|
|
4558
|
+
* spec §2). Throws `EraseStepError` (partial report, `verified: false`) when
|
|
4559
|
+
* a step fails; skipped entities report `verified: false`.
|
|
4560
|
+
* `{ rebuild: true }` additionally restarts the FTS rebuild.
|
|
4561
|
+
*/
|
|
4562
|
+
erase(options?: {
|
|
4563
|
+
rebuild?: boolean;
|
|
4564
|
+
}): Promise<EraseReport>;
|
|
4214
4565
|
runPrune(entityId: string, options?: {
|
|
4215
4566
|
retainSoftDeletedFor?: number | null;
|
|
4216
4567
|
retainEventsFor?: number | null;
|
|
@@ -4339,12 +4690,25 @@ declare class WikiMemory {
|
|
|
4339
4690
|
* so the ids stay stashed for the first sync after a re-init (#284 review).
|
|
4340
4691
|
*/
|
|
4341
4692
|
private syncDrained;
|
|
4342
|
-
exportDump(entityIds?: string[]
|
|
4693
|
+
exportDump(entityIds?: string[], opts?: {
|
|
4694
|
+
includeForgotten?: boolean;
|
|
4695
|
+
}): Promise<MemoryDump>;
|
|
4696
|
+
/**
|
|
4697
|
+
* The retention windows `runPrune()` uses when the host runs it (shipped
|
|
4698
|
+
* defaults plus host overrides), for GDPR disclosure. Nothing prunes
|
|
4699
|
+
* automatically; `erase()` ignores `retainSoftDeletedFor`. Days; `null`
|
|
4700
|
+
* means "keep forever". Read-only.
|
|
4701
|
+
*/
|
|
4702
|
+
getRetentionPolicy(): {
|
|
4703
|
+
retainSoftDeletedFor: number;
|
|
4704
|
+
retainEventsFor: number | null;
|
|
4705
|
+
pruneSupersededAfter: number | null;
|
|
4706
|
+
};
|
|
4343
4707
|
/** Entity summary prose persisted from an OKF profile ≥ 1 import; null when none stored. */
|
|
4344
4708
|
getEntitySummary(entityId: string): Promise<string | null>;
|
|
4345
4709
|
importDump(dump: MemoryDump, opts?: {
|
|
4346
4710
|
merge?: boolean;
|
|
4347
|
-
}): Promise<
|
|
4711
|
+
}): Promise<ImportDumpResult>;
|
|
4348
4712
|
/**
|
|
4349
4713
|
* Soft-delete facts and tasks by id, by source, or all of them (`clearAll`).
|
|
4350
4714
|
* `clearAll` also deletes the entity's edges and its source-ref index rows.
|
|
@@ -4366,6 +4730,14 @@ declare class WikiMemory {
|
|
|
4366
4730
|
forget(entityId: string, params: ForgetParams, opts?: {
|
|
4367
4731
|
dryRun?: boolean;
|
|
4368
4732
|
}): Promise<ForgetResult>;
|
|
4733
|
+
/** Store a source's text (spec source-store §7). Refusals return `stored: false`; a busy lock throws. */
|
|
4734
|
+
storeSource(entityId: string, params: {
|
|
4735
|
+
sourceRef: string;
|
|
4736
|
+
sourceHash: string;
|
|
4737
|
+
text: string;
|
|
4738
|
+
}): Promise<StoreSourceResult>;
|
|
4739
|
+
getStoredSource(entityId: string, sourceRef: string): Promise<StoredSource | null>;
|
|
4740
|
+
listStoredSources(entityId: string): Promise<StoredSourceSummary[]>;
|
|
4369
4741
|
/**
|
|
4370
4742
|
* End `oldId`'s validity and link it to its replacement (spec §4.3). One
|
|
4371
4743
|
* transaction. Throws `WikiSupersedeError` for missing, foreign, already
|
|
@@ -4592,5 +4964,5 @@ declare class WikiMemory {
|
|
|
4592
4964
|
setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
|
|
4593
4965
|
}
|
|
4594
4966
|
|
|
4595
|
-
export { HEAL_BATCH_SIZE as H, ONTOLOGY_BACKFILL_BATCH_SIZE as
|
|
4596
|
-
export type {
|
|
4967
|
+
export { CheckpointIncompleteError as C, HEAL_BATCH_SIZE as H, ONTOLOGY_BACKFILL_BATCH_SIZE as U, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as V, ONTOLOGY_BACKFILL_RECHECK_MS as X, RetrievalService as a$, PromptService as a7, PrunePartialFailureError as a8, WikiExternalDeletionError as aB, WikiGraphNodeOwnershipConflict as aD, WikiIngestEmptyError as aE, WikiInvalidReadOptions as aG, WikiMigrationRequiredError as aJ, WikiParseError as aL, WikiSearchUnavailableError as aM, WikiSourceRefHashCollision as aO, WikiStrictOntologyViolation as aP, WikiSupersedeError as aQ, WikiTransactionError as aT, isWikiSearchUnavailableError as aU, validateManifest as aV, EmbeddingService as aW, ImportExportService as aX, IngestionService as aY, JobManager as aZ, MaintenanceService as a_, WikiBusyError as an, WikiDraftNotFound as ax, WikiDuplicateHashError as ay, SearchService as b0, WriteService as b1, WikiMemory as c, EraseStepError as o, HEAL_RECHECK_MS as x, HOOK_TIMEOUT_MARKER as y };
|
|
4968
|
+
export type { OntologyManifest as $, IngestDocumentResult as A, LibrarianConfig as B, DegradedRecord as D, EmbedFactResult as E, FormatContextOptions as F, GraphNeighborhood as G, ImportDumpResult as I, LibrarianGateConfig as J, LockedMaintenanceJob as K, LLMProvider as L, MemoryBundle as M, MaintenanceJob as N, OntologyMode as O, MaintenanceStopReason as P, MemoryDumpEntity as Q, ReadOptions as R, SQLiteAdapter as S, MigrationPolicy as T, WikiOptions as W, OntologyBackfillResult as Y, OntologyConfig as Z, OntologyEdgeType as _, MemoryDump as a, OntologyNodeType as a0, OntologyPromptContext as a1, OntologyUpdates as a2, PendingMaintenance as a3, PendingMigrationWork as a4, PendingSourceStatus as a5, PromptOverrides as a6, ReembedResult as a9, WikiEvent as aA, WikiFact as aC, WikiInstructions as aF, WikiLintReport as aH, WikiMemoryTestAccess as aI, WikiOutboxEvent as aK, WikiSourcePointer as aN, WikiSupersedeReason as aR, WikiTask as aS, RememberInput as aa, RunPendingMaintenanceOptions as ab, RunPendingMaintenanceResult as ac, SourcePassage as ad, StoreSourceResult as ae, StoredSource as af, StoredSourceDump as ag, StoredSourceSummary as ah, SupersedeReplacement as ai, VectorRanker as aj, VectorRankerFallback as ak, VectorRankerRankArgs as al, VectorRankerSemanticResult as am, WikiBusyOperation as ao, WikiCheckpoint as ap, WikiConfig as aq, WikiDiagnostic as ar, WikiDiagnosticCode as as, WikiDiagnosticDetail as at, WikiDiagnosticOperation as au, WikiDiagnosticSeverity as av, WikiDiagnosticTrigger as aw, WikiEdge as az, FormattedMemoryDump as b, ChunkFailure as d, ClassifierAnswer as e, ClassifierQuestion as f, ClassifyRequest as g, ClassifyResponse as h, DraftPage as i, EmbedFailureKind as j, EmbeddingMarkerKind as k, EntityMaintenanceReport as l, EntityStatus as m, EraseReport as n, ExtractedFact as p, ExtractedFactEdge as q, ExtractedFactWithOntology as r, ExtractedTask as s, ForgetParams as t, ForgetResult as u, GraphTraversalOptions as v, GroundingConfig as w, HealResult as z };
|