@equationalapplications/core-llm-wiki 4.20.0 → 4.22.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 +35 -0
- package/dist/{chunk-HKB5FEJG.mjs → chunk-LCAU6NYC.mjs} +270 -94
- package/dist/chunk-LCAU6NYC.mjs.map +1 -0
- package/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +328 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +126 -11
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-BVN_g414.d.mts → testing-Bk8J6QLX.d.mts} +100 -7
- package/dist/{testing-BVN_g414.d.ts → testing-Bk8J6QLX.d.ts} +100 -7
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +167 -6
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-HKB5FEJG.mjs.map +0 -1
|
@@ -29,6 +29,7 @@ interface PromptOverrides {
|
|
|
29
29
|
ingestSystemPrompt?: string;
|
|
30
30
|
librarianSystemPrompt?: string;
|
|
31
31
|
healSystemPrompt?: string;
|
|
32
|
+
ontologyBackfillSystemPrompt?: string;
|
|
32
33
|
}
|
|
33
34
|
type OntologyMode = 'strict' | 'emergent' | 'off';
|
|
34
35
|
interface OntologyNodeType {
|
|
@@ -78,6 +79,24 @@ interface OntologyPromptContext {
|
|
|
78
79
|
ontologyManifest: string;
|
|
79
80
|
ontologyModeInstructions: string;
|
|
80
81
|
}
|
|
82
|
+
/** Result of a single ontology backfill run. Omissions (facts the model declined
|
|
83
|
+
* to classify) are derivable as scanned − typed − failedValidation. */
|
|
84
|
+
interface OntologyBackfillResult {
|
|
85
|
+
/** Untyped facts sent to the model this run. */
|
|
86
|
+
scanned: number;
|
|
87
|
+
/** Facts that received an okf_type. */
|
|
88
|
+
typed: number;
|
|
89
|
+
/** Model classifications rejected (unknown/duplicate id, non-manifest type). */
|
|
90
|
+
failedValidation: number;
|
|
91
|
+
/** Edges persisted. */
|
|
92
|
+
edgesAdded: number;
|
|
93
|
+
/** Untyped facts still eligible after this run — safe host convergence signal: loop while > 0.
|
|
94
|
+
* Always 0 when ontology mode is 'off' (nothing is eligible for typing while
|
|
95
|
+
* disabled), so 0 does not imply queue exhaustion in that mode. */
|
|
96
|
+
remaining: number;
|
|
97
|
+
/** Untyped facts inside the recheck cooldown. */
|
|
98
|
+
deferred: number;
|
|
99
|
+
}
|
|
81
100
|
interface WikiConfig {
|
|
82
101
|
/**
|
|
83
102
|
* Prefix applied to every SQL table/index/trigger name. Must match
|
|
@@ -465,10 +484,11 @@ interface EntityStatus {
|
|
|
465
484
|
*
|
|
466
485
|
* @remarks **Breaking change from v2.x** — the union previously only contained
|
|
467
486
|
* `'ingest' | 'librarian' | 'heal' | 'prune' | 'reembed'`. The values `'import'`
|
|
468
|
-
* and `'forget'` were added in v3.0.
|
|
469
|
-
* must be updated (or given a
|
|
487
|
+
* and `'forget'` were added in v3.0. `'ontologyBackfill'` was added afterward.
|
|
488
|
+
* Exhaustive `switch` / narrowing on this type must be updated (or given a
|
|
489
|
+
* `default` arm) to compile without errors.
|
|
470
490
|
*/
|
|
471
|
-
type WikiBusyOperation = 'ingest' | 'librarian' | 'heal' | 'prune' | 'reembed' | 'import' | 'forget';
|
|
491
|
+
type WikiBusyOperation = 'ingest' | 'librarian' | 'heal' | 'prune' | 'reembed' | 'import' | 'forget' | 'ontologyBackfill';
|
|
472
492
|
/**
|
|
473
493
|
* Thrown when a background mutator is already running for the requested entity.
|
|
474
494
|
*/
|
|
@@ -717,6 +737,42 @@ declare class EntryRepository extends BaseRepository {
|
|
|
717
737
|
trackAccess(ids: readonly string[], now: number, tx?: SQLiteAdapter): Promise<void>;
|
|
718
738
|
getLegacyMigrationSQL(): string;
|
|
719
739
|
findRecentByEntityIds(entityIds: readonly string[], limit: number, tx?: SQLiteAdapter): Promise<WikiFact[]>;
|
|
740
|
+
/**
|
|
741
|
+
* Live untyped facts eligible for ontology backfill, oldest first.
|
|
742
|
+
* Skips facts checked within the recheck cooldown (ontology_checked_at > recheckCutoff).
|
|
743
|
+
*/
|
|
744
|
+
findUntypedByEntityId(entityId: string, limit: number, recheckCutoff: number, tx?: SQLiteAdapter): Promise<WikiFact[]>;
|
|
745
|
+
/** Counts live untyped facts: eligible (past cooldown) vs deferred (in cooldown). */
|
|
746
|
+
countUntypedByEntityId(entityId: string, recheckCutoff: number, tx?: SQLiteAdapter): Promise<{
|
|
747
|
+
eligible: number;
|
|
748
|
+
deferred: number;
|
|
749
|
+
}>;
|
|
750
|
+
/**
|
|
751
|
+
* Sets okf_type only when currently NULL — additive by construction: a
|
|
752
|
+
* concurrently-typed fact is never overwritten. Returns changes for the caller
|
|
753
|
+
* to distinguish applied vs skipped.
|
|
754
|
+
*/
|
|
755
|
+
updateOkfType(id: string, entityId: string, okfType: string, tx: SQLiteAdapter): Promise<{
|
|
756
|
+
changes: number;
|
|
757
|
+
}>;
|
|
758
|
+
/**
|
|
759
|
+
* Stamps the backfill recheck cooldown. NEVER touches updated_at — import
|
|
760
|
+
* merge resolution is last-write-wins on updated_at and a bump here would
|
|
761
|
+
* make an unchanged local fact beat a genuinely newer remote edit.
|
|
762
|
+
*/
|
|
763
|
+
markOntologyChecked(ids: string[], entityId: string, now: number, tx: SQLiteAdapter): Promise<void>;
|
|
764
|
+
/**
|
|
765
|
+
* Lightweight full-breadth title index (id, title, okf_type) over all live
|
|
766
|
+
* typed facts. Used by ontology backfill edge resolution — a recent-N window
|
|
767
|
+
* would miss an old fact's contemporaries. Untyped rows are excluded: they
|
|
768
|
+
* can never pass the edge target-type check, and batch facts typed during
|
|
769
|
+
* the run are re-added to the in-memory index by the caller.
|
|
770
|
+
*/
|
|
771
|
+
findTitleIndexByEntityId(entityId: string, tx?: SQLiteAdapter): Promise<Array<{
|
|
772
|
+
id: string;
|
|
773
|
+
title: string;
|
|
774
|
+
okf_type: string | null;
|
|
775
|
+
}>>;
|
|
720
776
|
}
|
|
721
777
|
|
|
722
778
|
declare class MetadataRepository extends BaseRepository {
|
|
@@ -823,7 +879,7 @@ declare class SearchService {
|
|
|
823
879
|
private _compareScoredRows;
|
|
824
880
|
}
|
|
825
881
|
|
|
826
|
-
type OperationType = 'prune' | 'librarian' | 'heal' | 'ingest' | 'reembed' | 'global_reembed' | 'import' | 'global_import' | 'forget';
|
|
882
|
+
type OperationType = 'prune' | 'librarian' | 'heal' | 'ingest' | 'reembed' | 'global_reembed' | 'import' | 'global_import' | 'forget' | 'ontologyBackfill';
|
|
827
883
|
declare class JobManager {
|
|
828
884
|
private prefix;
|
|
829
885
|
private activeMaintenanceJobs;
|
|
@@ -838,6 +894,7 @@ declare class JobManager {
|
|
|
838
894
|
private _forgetKey;
|
|
839
895
|
private _librarianKey;
|
|
840
896
|
private _healKey;
|
|
897
|
+
private _ontologyBackfillKey;
|
|
841
898
|
/**
|
|
842
899
|
* Lookup table for acquireLock/releaseLock's dynamic-dispatch branch.
|
|
843
900
|
* Excludes 'ingest' | 'global_reembed' | 'global_import', which those
|
|
@@ -908,9 +965,10 @@ interface NeighborhoodQueryOptions {
|
|
|
908
965
|
declare class EdgeRepository extends BaseRepository {
|
|
909
966
|
/**
|
|
910
967
|
* Insert an edge, silently skipping on primary-key or uniqueness conflicts.
|
|
968
|
+
* Returns true when a row was inserted, false when skipped as a duplicate.
|
|
911
969
|
* Throws when the insert was skipped due to an id collision with a different edge tuple.
|
|
912
970
|
*/
|
|
913
|
-
addIgnoreDuplicate(edge: WikiEdge, tx?: SQLiteAdapter): Promise<
|
|
971
|
+
addIgnoreDuplicate(edge: WikiEdge, tx?: SQLiteAdapter): Promise<boolean>;
|
|
914
972
|
getByEntityId(entityId: string, tx?: SQLiteAdapter): Promise<WikiEdge[]>;
|
|
915
973
|
/** Hard delete — edges have no soft-delete concept, only presence/absence. `tx` is REQUIRED. */
|
|
916
974
|
bulkDeleteByEntityId(entityId: string, tx: SQLiteAdapter): Promise<void>;
|
|
@@ -952,7 +1010,7 @@ declare class OntologyService {
|
|
|
952
1010
|
okf_type: string | null;
|
|
953
1011
|
edges: ExtractedFactEdge[];
|
|
954
1012
|
};
|
|
955
|
-
resolveAndPersistEdges(entityId: string, sourceId: string, sourceType: string | null, edges: ExtractedFactEdge[], manifest: OntologyManifest, titleIndex: Map<string, TitleIndexEntry>, tx: SQLiteAdapter, now: number): Promise<
|
|
1013
|
+
resolveAndPersistEdges(entityId: string, sourceId: string, sourceType: string | null, edges: ExtractedFactEdge[], manifest: OntologyManifest, titleIndex: Map<string, TitleIndexEntry>, tx: SQLiteAdapter, now: number): Promise<number>;
|
|
956
1014
|
}
|
|
957
1015
|
|
|
958
1016
|
declare class PromptService {
|
|
@@ -974,6 +1032,10 @@ declare class PromptService {
|
|
|
974
1032
|
systemPrompt: string;
|
|
975
1033
|
userPrompt: string;
|
|
976
1034
|
};
|
|
1035
|
+
buildOntologyBackfillPrompt(facts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null): {
|
|
1036
|
+
systemPrompt: string;
|
|
1037
|
+
userPrompt: string;
|
|
1038
|
+
};
|
|
977
1039
|
}
|
|
978
1040
|
|
|
979
1041
|
declare class IngestionService {
|
|
@@ -1094,6 +1156,9 @@ declare class EventRepository extends BaseRepository {
|
|
|
1094
1156
|
getByEntityId(entityId: string, limit?: number): Promise<WikiEvent[]>;
|
|
1095
1157
|
}
|
|
1096
1158
|
|
|
1159
|
+
declare const ONTOLOGY_BACKFILL_BATCH_SIZE = 25;
|
|
1160
|
+
declare const ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS = 40000;
|
|
1161
|
+
declare const ONTOLOGY_BACKFILL_RECHECK_MS: number;
|
|
1097
1162
|
declare class MaintenanceService {
|
|
1098
1163
|
private db;
|
|
1099
1164
|
private prefix;
|
|
@@ -1123,6 +1188,10 @@ declare class MaintenanceService {
|
|
|
1123
1188
|
runHeal(entityId: string, options?: {
|
|
1124
1189
|
promptOverride?: string;
|
|
1125
1190
|
}): Promise<void>;
|
|
1191
|
+
runOntologyBackfill(entityId: string, options?: {
|
|
1192
|
+
promptOverride?: string;
|
|
1193
|
+
batchSize?: number;
|
|
1194
|
+
}): Promise<OntologyBackfillResult>;
|
|
1126
1195
|
runReembed(entityId?: string, opts?: {
|
|
1127
1196
|
force?: boolean;
|
|
1128
1197
|
skipExisting?: boolean;
|
|
@@ -1147,6 +1216,11 @@ declare class MaintenanceService {
|
|
|
1147
1216
|
doRunLibrarian(entityId: string, promptOverride?: string): Promise<void>;
|
|
1148
1217
|
/** Core heal pass (locks handled by {@link runHeal}). Package-internal orchestration hook. */
|
|
1149
1218
|
doRunHeal(entityId: string, promptOverride?: string): Promise<void>;
|
|
1219
|
+
/** Core ontology backfill pass (locks handled by {@link runOntologyBackfill}). Package-internal orchestration hook. */
|
|
1220
|
+
doRunOntologyBackfill(entityId: string, options?: {
|
|
1221
|
+
promptOverride?: string;
|
|
1222
|
+
batchSize?: number;
|
|
1223
|
+
}): Promise<OntologyBackfillResult>;
|
|
1150
1224
|
private _validatePruneDuration;
|
|
1151
1225
|
private _sanitizeRankerError;
|
|
1152
1226
|
}
|
|
@@ -1313,6 +1387,25 @@ declare class WikiMemory {
|
|
|
1313
1387
|
runHeal(entityId: string, options?: {
|
|
1314
1388
|
promptOverride?: string;
|
|
1315
1389
|
}): Promise<void>;
|
|
1390
|
+
/**
|
|
1391
|
+
* Types already-persisted untyped facts (okf_type IS NULL) in place via one
|
|
1392
|
+
* librarian-style LLM call. Strictly additive: never creates, deletes, or
|
|
1393
|
+
* rewrites facts; never overwrites an existing okf_type. Free when there is
|
|
1394
|
+
* nothing to do (ontology off, or zero eligible untyped facts).
|
|
1395
|
+
*
|
|
1396
|
+
* Hosts own the trigger cadence (e.g. after each sync); loop `while
|
|
1397
|
+
* result.remaining > 0` for convergence. Throws WikiBusyError when another
|
|
1398
|
+
* backfill (or conflicting maintenance op) is running for the entity.
|
|
1399
|
+
*
|
|
1400
|
+
* @param options.promptOverride - Applies only to this call. For persistent
|
|
1401
|
+
* customization set `options.config.prompts.ontologyBackfillSystemPrompt`.
|
|
1402
|
+
* @param options.batchSize - Facts per run (default 25) for providers with
|
|
1403
|
+
* tighter context limits.
|
|
1404
|
+
*/
|
|
1405
|
+
runOntologyBackfill(entityId: string, options?: {
|
|
1406
|
+
promptOverride?: string;
|
|
1407
|
+
batchSize?: number;
|
|
1408
|
+
}): Promise<OntologyBackfillResult>;
|
|
1316
1409
|
runReembed(entityId?: string, opts?: {
|
|
1317
1410
|
force?: boolean;
|
|
1318
1411
|
skipExisting?: boolean;
|
|
@@ -1387,4 +1480,4 @@ declare class WikiMemory {
|
|
|
1387
1480
|
}): Promise<void>;
|
|
1388
1481
|
}
|
|
1389
1482
|
|
|
1390
|
-
export { type
|
|
1483
|
+
export { WriteService as $, type WikiConfig as A, type WikiEdge as B, type WikiEvent as C, type WikiFact as D, type EntityStatus as E, type FormatContextOptions as F, type GraphNeighborhood as G, HOOK_TIMEOUT_MARKER as H, type WikiMemoryTestAccess as I, type WikiOutboxEvent as J, type WikiTask as K, type LLMProvider as L, type MemoryBundle as M, WikiTransactionError as N, type OntologyManifest as O, type PromptOverrides as P, EmbeddingService as Q, type ReadOptions as R, type SQLiteAdapter as S, ImportExportService as T, IngestionService as U, type VectorRanker as V, type WikiOptions as W, JobManager as X, MaintenanceService as Y, RetrievalService as Z, SearchService as _, type MemoryDump as a, type FormattedMemoryDump as b, WikiMemory as c, type ExtractedFact as d, type ExtractedFactEdge as e, type ExtractedFactWithOntology as f, type ExtractedTask as g, type GraphTraversalOptions as h, ONTOLOGY_BACKFILL_BATCH_SIZE as i, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as j, ONTOLOGY_BACKFILL_RECHECK_MS as k, type OntologyBackfillResult as l, type OntologyConfig as m, type OntologyEdgeType as n, type OntologyMode as o, type OntologyNodeType as p, type OntologyPromptContext as q, type OntologyUpdates as r, PromptService as s, PrunePartialFailureError as t, type VectorRankerFallback as u, type VectorRankerRankArgs as v, type VectorRankerSemanticResult as w, WikiBusyError as x, type WikiBusyOperation as y, type WikiCheckpoint as z };
|
|
@@ -29,6 +29,7 @@ interface PromptOverrides {
|
|
|
29
29
|
ingestSystemPrompt?: string;
|
|
30
30
|
librarianSystemPrompt?: string;
|
|
31
31
|
healSystemPrompt?: string;
|
|
32
|
+
ontologyBackfillSystemPrompt?: string;
|
|
32
33
|
}
|
|
33
34
|
type OntologyMode = 'strict' | 'emergent' | 'off';
|
|
34
35
|
interface OntologyNodeType {
|
|
@@ -78,6 +79,24 @@ interface OntologyPromptContext {
|
|
|
78
79
|
ontologyManifest: string;
|
|
79
80
|
ontologyModeInstructions: string;
|
|
80
81
|
}
|
|
82
|
+
/** Result of a single ontology backfill run. Omissions (facts the model declined
|
|
83
|
+
* to classify) are derivable as scanned − typed − failedValidation. */
|
|
84
|
+
interface OntologyBackfillResult {
|
|
85
|
+
/** Untyped facts sent to the model this run. */
|
|
86
|
+
scanned: number;
|
|
87
|
+
/** Facts that received an okf_type. */
|
|
88
|
+
typed: number;
|
|
89
|
+
/** Model classifications rejected (unknown/duplicate id, non-manifest type). */
|
|
90
|
+
failedValidation: number;
|
|
91
|
+
/** Edges persisted. */
|
|
92
|
+
edgesAdded: number;
|
|
93
|
+
/** Untyped facts still eligible after this run — safe host convergence signal: loop while > 0.
|
|
94
|
+
* Always 0 when ontology mode is 'off' (nothing is eligible for typing while
|
|
95
|
+
* disabled), so 0 does not imply queue exhaustion in that mode. */
|
|
96
|
+
remaining: number;
|
|
97
|
+
/** Untyped facts inside the recheck cooldown. */
|
|
98
|
+
deferred: number;
|
|
99
|
+
}
|
|
81
100
|
interface WikiConfig {
|
|
82
101
|
/**
|
|
83
102
|
* Prefix applied to every SQL table/index/trigger name. Must match
|
|
@@ -465,10 +484,11 @@ interface EntityStatus {
|
|
|
465
484
|
*
|
|
466
485
|
* @remarks **Breaking change from v2.x** — the union previously only contained
|
|
467
486
|
* `'ingest' | 'librarian' | 'heal' | 'prune' | 'reembed'`. The values `'import'`
|
|
468
|
-
* and `'forget'` were added in v3.0.
|
|
469
|
-
* must be updated (or given a
|
|
487
|
+
* and `'forget'` were added in v3.0. `'ontologyBackfill'` was added afterward.
|
|
488
|
+
* Exhaustive `switch` / narrowing on this type must be updated (or given a
|
|
489
|
+
* `default` arm) to compile without errors.
|
|
470
490
|
*/
|
|
471
|
-
type WikiBusyOperation = 'ingest' | 'librarian' | 'heal' | 'prune' | 'reembed' | 'import' | 'forget';
|
|
491
|
+
type WikiBusyOperation = 'ingest' | 'librarian' | 'heal' | 'prune' | 'reembed' | 'import' | 'forget' | 'ontologyBackfill';
|
|
472
492
|
/**
|
|
473
493
|
* Thrown when a background mutator is already running for the requested entity.
|
|
474
494
|
*/
|
|
@@ -717,6 +737,42 @@ declare class EntryRepository extends BaseRepository {
|
|
|
717
737
|
trackAccess(ids: readonly string[], now: number, tx?: SQLiteAdapter): Promise<void>;
|
|
718
738
|
getLegacyMigrationSQL(): string;
|
|
719
739
|
findRecentByEntityIds(entityIds: readonly string[], limit: number, tx?: SQLiteAdapter): Promise<WikiFact[]>;
|
|
740
|
+
/**
|
|
741
|
+
* Live untyped facts eligible for ontology backfill, oldest first.
|
|
742
|
+
* Skips facts checked within the recheck cooldown (ontology_checked_at > recheckCutoff).
|
|
743
|
+
*/
|
|
744
|
+
findUntypedByEntityId(entityId: string, limit: number, recheckCutoff: number, tx?: SQLiteAdapter): Promise<WikiFact[]>;
|
|
745
|
+
/** Counts live untyped facts: eligible (past cooldown) vs deferred (in cooldown). */
|
|
746
|
+
countUntypedByEntityId(entityId: string, recheckCutoff: number, tx?: SQLiteAdapter): Promise<{
|
|
747
|
+
eligible: number;
|
|
748
|
+
deferred: number;
|
|
749
|
+
}>;
|
|
750
|
+
/**
|
|
751
|
+
* Sets okf_type only when currently NULL — additive by construction: a
|
|
752
|
+
* concurrently-typed fact is never overwritten. Returns changes for the caller
|
|
753
|
+
* to distinguish applied vs skipped.
|
|
754
|
+
*/
|
|
755
|
+
updateOkfType(id: string, entityId: string, okfType: string, tx: SQLiteAdapter): Promise<{
|
|
756
|
+
changes: number;
|
|
757
|
+
}>;
|
|
758
|
+
/**
|
|
759
|
+
* Stamps the backfill recheck cooldown. NEVER touches updated_at — import
|
|
760
|
+
* merge resolution is last-write-wins on updated_at and a bump here would
|
|
761
|
+
* make an unchanged local fact beat a genuinely newer remote edit.
|
|
762
|
+
*/
|
|
763
|
+
markOntologyChecked(ids: string[], entityId: string, now: number, tx: SQLiteAdapter): Promise<void>;
|
|
764
|
+
/**
|
|
765
|
+
* Lightweight full-breadth title index (id, title, okf_type) over all live
|
|
766
|
+
* typed facts. Used by ontology backfill edge resolution — a recent-N window
|
|
767
|
+
* would miss an old fact's contemporaries. Untyped rows are excluded: they
|
|
768
|
+
* can never pass the edge target-type check, and batch facts typed during
|
|
769
|
+
* the run are re-added to the in-memory index by the caller.
|
|
770
|
+
*/
|
|
771
|
+
findTitleIndexByEntityId(entityId: string, tx?: SQLiteAdapter): Promise<Array<{
|
|
772
|
+
id: string;
|
|
773
|
+
title: string;
|
|
774
|
+
okf_type: string | null;
|
|
775
|
+
}>>;
|
|
720
776
|
}
|
|
721
777
|
|
|
722
778
|
declare class MetadataRepository extends BaseRepository {
|
|
@@ -823,7 +879,7 @@ declare class SearchService {
|
|
|
823
879
|
private _compareScoredRows;
|
|
824
880
|
}
|
|
825
881
|
|
|
826
|
-
type OperationType = 'prune' | 'librarian' | 'heal' | 'ingest' | 'reembed' | 'global_reembed' | 'import' | 'global_import' | 'forget';
|
|
882
|
+
type OperationType = 'prune' | 'librarian' | 'heal' | 'ingest' | 'reembed' | 'global_reembed' | 'import' | 'global_import' | 'forget' | 'ontologyBackfill';
|
|
827
883
|
declare class JobManager {
|
|
828
884
|
private prefix;
|
|
829
885
|
private activeMaintenanceJobs;
|
|
@@ -838,6 +894,7 @@ declare class JobManager {
|
|
|
838
894
|
private _forgetKey;
|
|
839
895
|
private _librarianKey;
|
|
840
896
|
private _healKey;
|
|
897
|
+
private _ontologyBackfillKey;
|
|
841
898
|
/**
|
|
842
899
|
* Lookup table for acquireLock/releaseLock's dynamic-dispatch branch.
|
|
843
900
|
* Excludes 'ingest' | 'global_reembed' | 'global_import', which those
|
|
@@ -908,9 +965,10 @@ interface NeighborhoodQueryOptions {
|
|
|
908
965
|
declare class EdgeRepository extends BaseRepository {
|
|
909
966
|
/**
|
|
910
967
|
* Insert an edge, silently skipping on primary-key or uniqueness conflicts.
|
|
968
|
+
* Returns true when a row was inserted, false when skipped as a duplicate.
|
|
911
969
|
* Throws when the insert was skipped due to an id collision with a different edge tuple.
|
|
912
970
|
*/
|
|
913
|
-
addIgnoreDuplicate(edge: WikiEdge, tx?: SQLiteAdapter): Promise<
|
|
971
|
+
addIgnoreDuplicate(edge: WikiEdge, tx?: SQLiteAdapter): Promise<boolean>;
|
|
914
972
|
getByEntityId(entityId: string, tx?: SQLiteAdapter): Promise<WikiEdge[]>;
|
|
915
973
|
/** Hard delete — edges have no soft-delete concept, only presence/absence. `tx` is REQUIRED. */
|
|
916
974
|
bulkDeleteByEntityId(entityId: string, tx: SQLiteAdapter): Promise<void>;
|
|
@@ -952,7 +1010,7 @@ declare class OntologyService {
|
|
|
952
1010
|
okf_type: string | null;
|
|
953
1011
|
edges: ExtractedFactEdge[];
|
|
954
1012
|
};
|
|
955
|
-
resolveAndPersistEdges(entityId: string, sourceId: string, sourceType: string | null, edges: ExtractedFactEdge[], manifest: OntologyManifest, titleIndex: Map<string, TitleIndexEntry>, tx: SQLiteAdapter, now: number): Promise<
|
|
1013
|
+
resolveAndPersistEdges(entityId: string, sourceId: string, sourceType: string | null, edges: ExtractedFactEdge[], manifest: OntologyManifest, titleIndex: Map<string, TitleIndexEntry>, tx: SQLiteAdapter, now: number): Promise<number>;
|
|
956
1014
|
}
|
|
957
1015
|
|
|
958
1016
|
declare class PromptService {
|
|
@@ -974,6 +1032,10 @@ declare class PromptService {
|
|
|
974
1032
|
systemPrompt: string;
|
|
975
1033
|
userPrompt: string;
|
|
976
1034
|
};
|
|
1035
|
+
buildOntologyBackfillPrompt(facts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null): {
|
|
1036
|
+
systemPrompt: string;
|
|
1037
|
+
userPrompt: string;
|
|
1038
|
+
};
|
|
977
1039
|
}
|
|
978
1040
|
|
|
979
1041
|
declare class IngestionService {
|
|
@@ -1094,6 +1156,9 @@ declare class EventRepository extends BaseRepository {
|
|
|
1094
1156
|
getByEntityId(entityId: string, limit?: number): Promise<WikiEvent[]>;
|
|
1095
1157
|
}
|
|
1096
1158
|
|
|
1159
|
+
declare const ONTOLOGY_BACKFILL_BATCH_SIZE = 25;
|
|
1160
|
+
declare const ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS = 40000;
|
|
1161
|
+
declare const ONTOLOGY_BACKFILL_RECHECK_MS: number;
|
|
1097
1162
|
declare class MaintenanceService {
|
|
1098
1163
|
private db;
|
|
1099
1164
|
private prefix;
|
|
@@ -1123,6 +1188,10 @@ declare class MaintenanceService {
|
|
|
1123
1188
|
runHeal(entityId: string, options?: {
|
|
1124
1189
|
promptOverride?: string;
|
|
1125
1190
|
}): Promise<void>;
|
|
1191
|
+
runOntologyBackfill(entityId: string, options?: {
|
|
1192
|
+
promptOverride?: string;
|
|
1193
|
+
batchSize?: number;
|
|
1194
|
+
}): Promise<OntologyBackfillResult>;
|
|
1126
1195
|
runReembed(entityId?: string, opts?: {
|
|
1127
1196
|
force?: boolean;
|
|
1128
1197
|
skipExisting?: boolean;
|
|
@@ -1147,6 +1216,11 @@ declare class MaintenanceService {
|
|
|
1147
1216
|
doRunLibrarian(entityId: string, promptOverride?: string): Promise<void>;
|
|
1148
1217
|
/** Core heal pass (locks handled by {@link runHeal}). Package-internal orchestration hook. */
|
|
1149
1218
|
doRunHeal(entityId: string, promptOverride?: string): Promise<void>;
|
|
1219
|
+
/** Core ontology backfill pass (locks handled by {@link runOntologyBackfill}). Package-internal orchestration hook. */
|
|
1220
|
+
doRunOntologyBackfill(entityId: string, options?: {
|
|
1221
|
+
promptOverride?: string;
|
|
1222
|
+
batchSize?: number;
|
|
1223
|
+
}): Promise<OntologyBackfillResult>;
|
|
1150
1224
|
private _validatePruneDuration;
|
|
1151
1225
|
private _sanitizeRankerError;
|
|
1152
1226
|
}
|
|
@@ -1313,6 +1387,25 @@ declare class WikiMemory {
|
|
|
1313
1387
|
runHeal(entityId: string, options?: {
|
|
1314
1388
|
promptOverride?: string;
|
|
1315
1389
|
}): Promise<void>;
|
|
1390
|
+
/**
|
|
1391
|
+
* Types already-persisted untyped facts (okf_type IS NULL) in place via one
|
|
1392
|
+
* librarian-style LLM call. Strictly additive: never creates, deletes, or
|
|
1393
|
+
* rewrites facts; never overwrites an existing okf_type. Free when there is
|
|
1394
|
+
* nothing to do (ontology off, or zero eligible untyped facts).
|
|
1395
|
+
*
|
|
1396
|
+
* Hosts own the trigger cadence (e.g. after each sync); loop `while
|
|
1397
|
+
* result.remaining > 0` for convergence. Throws WikiBusyError when another
|
|
1398
|
+
* backfill (or conflicting maintenance op) is running for the entity.
|
|
1399
|
+
*
|
|
1400
|
+
* @param options.promptOverride - Applies only to this call. For persistent
|
|
1401
|
+
* customization set `options.config.prompts.ontologyBackfillSystemPrompt`.
|
|
1402
|
+
* @param options.batchSize - Facts per run (default 25) for providers with
|
|
1403
|
+
* tighter context limits.
|
|
1404
|
+
*/
|
|
1405
|
+
runOntologyBackfill(entityId: string, options?: {
|
|
1406
|
+
promptOverride?: string;
|
|
1407
|
+
batchSize?: number;
|
|
1408
|
+
}): Promise<OntologyBackfillResult>;
|
|
1316
1409
|
runReembed(entityId?: string, opts?: {
|
|
1317
1410
|
force?: boolean;
|
|
1318
1411
|
skipExisting?: boolean;
|
|
@@ -1387,4 +1480,4 @@ declare class WikiMemory {
|
|
|
1387
1480
|
}): Promise<void>;
|
|
1388
1481
|
}
|
|
1389
1482
|
|
|
1390
|
-
export { type
|
|
1483
|
+
export { WriteService as $, type WikiConfig as A, type WikiEdge as B, type WikiEvent as C, type WikiFact as D, type EntityStatus as E, type FormatContextOptions as F, type GraphNeighborhood as G, HOOK_TIMEOUT_MARKER as H, type WikiMemoryTestAccess as I, type WikiOutboxEvent as J, type WikiTask as K, type LLMProvider as L, type MemoryBundle as M, WikiTransactionError as N, type OntologyManifest as O, type PromptOverrides as P, EmbeddingService as Q, type ReadOptions as R, type SQLiteAdapter as S, ImportExportService as T, IngestionService as U, type VectorRanker as V, type WikiOptions as W, JobManager as X, MaintenanceService as Y, RetrievalService as Z, SearchService as _, type MemoryDump as a, type FormattedMemoryDump as b, WikiMemory as c, type ExtractedFact as d, type ExtractedFactEdge as e, type ExtractedFactWithOntology as f, type ExtractedTask as g, type GraphTraversalOptions as h, ONTOLOGY_BACKFILL_BATCH_SIZE as i, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as j, ONTOLOGY_BACKFILL_RECHECK_MS as k, type OntologyBackfillResult as l, type OntologyConfig as m, type OntologyEdgeType as n, type OntologyMode as o, type OntologyNodeType as p, type OntologyPromptContext as q, type OntologyUpdates as r, PromptService as s, PrunePartialFailureError as t, type VectorRankerFallback as u, type VectorRankerRankArgs as v, type VectorRankerSemanticResult as w, WikiBusyError as x, type WikiBusyOperation as y, type WikiCheckpoint as z };
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Q as EmbeddingService, T as ImportExportService, U as IngestionService, X as JobManager, X as JobManagerType, Y as MaintenanceService, Z as RetrievalService, _ as SearchService, _ as SearchServiceType, I as WikiMemoryTestAccess, $ as WriteService } from './testing-Bk8J6QLX.mjs';
|
|
2
2
|
import 'minisearch';
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Q as EmbeddingService, T as ImportExportService, U as IngestionService, X as JobManager, X as JobManagerType, Y as MaintenanceService, Z as RetrievalService, _ as SearchService, _ as SearchServiceType, I as WikiMemoryTestAccess, $ as WriteService } from './testing-Bk8J6QLX.js';
|
|
2
2
|
import 'minisearch';
|