@equationalapplications/core-llm-wiki 7.5.0 → 7.7.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 +93 -0
- package/dist/{chunk-3P7FAKJA.mjs → chunk-VOSMYISQ.mjs} +243 -41
- package/dist/chunk-VOSMYISQ.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +434 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +196 -5
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-ClpOUiLI.d.mts → testing-A4Sofxyo.d.mts} +136 -4
- package/dist/{testing-ClpOUiLI.d.ts → testing-A4Sofxyo.d.ts} +136 -4
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +236 -38
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-3P7FAKJA.mjs.map +0 -1
|
@@ -215,6 +215,23 @@ interface HealResult {
|
|
|
215
215
|
/** Heal candidates inside the recheck cooldown. */
|
|
216
216
|
deferred: number;
|
|
217
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Opt-in evidence check for LLM-authored facts (spec §6). Default off: 7.x
|
|
220
|
+
* write behavior is unchanged. In `'draft'` mode, writers in `writers` must
|
|
221
|
+
* quote their source; a fact whose quotes are missing or not found is stored
|
|
222
|
+
* as a `draft` instead of being rejected.
|
|
223
|
+
*/
|
|
224
|
+
interface GroundingConfig {
|
|
225
|
+
mode: 'off' | 'draft';
|
|
226
|
+
/** Default `['ingest']`. The librarian and heal synthesize across events; measure their pass rates before opting them in. */
|
|
227
|
+
writers?: Array<'ingest' | 'librarian' | 'heal'>;
|
|
228
|
+
/** Quotes shorter than this (after whitespace normalization) count as absent. Default 20. */
|
|
229
|
+
minEvidenceChars?: number;
|
|
230
|
+
/** Quotes retained per fact. Retention only; every quote is checked. Default 3. */
|
|
231
|
+
maxEvidence?: number;
|
|
232
|
+
/** Characters retained per quote. Default 300. */
|
|
233
|
+
maxEvidenceChars?: number;
|
|
234
|
+
}
|
|
218
235
|
interface WikiConfig {
|
|
219
236
|
/**
|
|
220
237
|
* Prefix applied to every SQL table/index/trigger name. Must match
|
|
@@ -260,7 +277,11 @@ interface WikiConfig {
|
|
|
260
277
|
* Default: undefined (pure semantic when embed provided).
|
|
261
278
|
*/
|
|
262
279
|
hybridWeight?: number;
|
|
263
|
-
/**
|
|
280
|
+
/**
|
|
281
|
+
* Global prompt overrides for text generation calls (`ingestDocument`, `runLibrarian`, `runHeal`). Does not affect embedding generation. Runtime overrides on individual method calls take precedence.
|
|
282
|
+
*
|
|
283
|
+
* Returned verbatim by `getInstructions` and the `wiki_get_instructions` tool (`memory:read`): never put secrets, API keys or private data here.
|
|
284
|
+
*/
|
|
264
285
|
prompts?: PromptOverrides;
|
|
265
286
|
/**
|
|
266
287
|
* When true, entry and task mutations append an event to the internal outbox table.
|
|
@@ -282,6 +303,8 @@ interface WikiConfig {
|
|
|
282
303
|
* `GraphTraversalOptions.excludeDrafts`. Default false (drafts visible).
|
|
283
304
|
*/
|
|
284
305
|
excludeDrafts?: boolean;
|
|
306
|
+
/** Evidence check for LLM-authored facts (spec §6). Default off. */
|
|
307
|
+
grounding?: GroundingConfig;
|
|
285
308
|
}
|
|
286
309
|
interface ReadOptions {
|
|
287
310
|
maxResults?: number;
|
|
@@ -493,6 +516,8 @@ interface ExtractedFact {
|
|
|
493
516
|
body: string;
|
|
494
517
|
tags: string[];
|
|
495
518
|
confidence: 'certain' | 'inferred' | 'tentative';
|
|
519
|
+
/** Quotes the model copied from its source; see `WikiConfig.grounding`. Never persisted. */
|
|
520
|
+
evidence?: string[];
|
|
496
521
|
}
|
|
497
522
|
interface ExtractedFactWithOntology extends ExtractedFact {
|
|
498
523
|
okf_type?: string;
|
|
@@ -1030,6 +1055,43 @@ interface DraftPage {
|
|
|
1030
1055
|
facts: WikiFact[];
|
|
1031
1056
|
nextCursor: string | null;
|
|
1032
1057
|
}
|
|
1058
|
+
/**
|
|
1059
|
+
* `pendingSources` status (spec §8.2). `partial`: live rows exist for the ref
|
|
1060
|
+
* but none carries a hash, which is the intended retry state after a partial
|
|
1061
|
+
* ingest. `current` is exactly the case where `hasChanged` returns false.
|
|
1062
|
+
*/
|
|
1063
|
+
type PendingSourceStatus = 'new' | 'changed' | 'partial' | 'current';
|
|
1064
|
+
/** Read-only maintenance report for one entity (spec §8.1). Counts cover live rows only. */
|
|
1065
|
+
interface WikiLintReport {
|
|
1066
|
+
/** Edges whose source or target is missing, soft-deleted, or owned by another entity. */
|
|
1067
|
+
danglingEdges: number;
|
|
1068
|
+
/** Live-endpoint edges whose (source type, edge type, target type) is not in the effective manifest. 0 when ontology is off or the manifest is empty. */
|
|
1069
|
+
manifestViolations: number;
|
|
1070
|
+
/** Live facts with `okf_type` NULL. */
|
|
1071
|
+
untypedFacts: number;
|
|
1072
|
+
/** Live facts with `lifecycle_status = 'draft'`. */
|
|
1073
|
+
drafts: number;
|
|
1074
|
+
/** Live `librarian_inferred` facts with an empty `okf_verified`. */
|
|
1075
|
+
unverifiedInferred: number;
|
|
1076
|
+
/** Up to 20 ids each, ascending. */
|
|
1077
|
+
sample: {
|
|
1078
|
+
danglingEdgeIds: string[];
|
|
1079
|
+
manifestViolationEdgeIds: string[];
|
|
1080
|
+
};
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Effective system prompts (spec §8.3): defaults with `WikiConfig.prompts`
|
|
1084
|
+
* overrides applied and the ontology block appended. Templates only: data
|
|
1085
|
+
* placeholders such as `{{documentChunk}}` stay verbatim, and no events,
|
|
1086
|
+
* chunks or facts are ever included. Overrides are returned as written, so
|
|
1087
|
+
* never put secrets or private data in `WikiConfig.prompts`.
|
|
1088
|
+
*/
|
|
1089
|
+
interface WikiInstructions {
|
|
1090
|
+
ingest: string;
|
|
1091
|
+
librarian: string;
|
|
1092
|
+
heal: string;
|
|
1093
|
+
ontologyBackfill: string;
|
|
1094
|
+
}
|
|
1033
1095
|
|
|
1034
1096
|
interface WikiOutboxEvent<T = unknown> {
|
|
1035
1097
|
id: string;
|
|
@@ -1227,10 +1289,14 @@ declare class EntryRepository extends BaseRepository {
|
|
|
1227
1289
|
* fact, not only immutable_document rows, so the source-type restriction has
|
|
1228
1290
|
* to be applied here, after retrieval.
|
|
1229
1291
|
*/
|
|
1230
|
-
findAnchorRowsByIds(entityId: string, ids: readonly string[], tx?: SQLiteAdapter
|
|
1292
|
+
findAnchorRowsByIds(entityId: string, ids: readonly string[], tx?: SQLiteAdapter, opts?: {
|
|
1293
|
+
withBody?: boolean;
|
|
1294
|
+
}): Promise<Array<{
|
|
1231
1295
|
id: string;
|
|
1232
1296
|
title: string;
|
|
1233
1297
|
source_ref: string | null;
|
|
1298
|
+
body?: string;
|
|
1299
|
+
lifecycle_status?: string;
|
|
1234
1300
|
}>>;
|
|
1235
1301
|
/**
|
|
1236
1302
|
* Fetch recent non-deleted entries for an entity (limited), ordered by updated_at DESC.
|
|
@@ -1359,6 +1425,15 @@ declare class EntryRepository extends BaseRepository {
|
|
|
1359
1425
|
* Empty input is a synchronous early return with zero SQL calls.
|
|
1360
1426
|
*/
|
|
1361
1427
|
findLatestSourceHashes(entityId: string, sourceRefs: readonly string[], tx?: SQLiteAdapter): Promise<Map<string, string | null>>;
|
|
1428
|
+
/**
|
|
1429
|
+
* Per source ref, the hash of the latest live row (same ordering as
|
|
1430
|
+
* {@link findLatestSourceHashes}) and whether ANY live row carries a hash.
|
|
1431
|
+
* Refs with no live row are absent. Chunked under the bind-variable limit.
|
|
1432
|
+
*/
|
|
1433
|
+
findSourceStates(entityId: string, sourceRefs: readonly string[], tx?: SQLiteAdapter): Promise<Map<string, {
|
|
1434
|
+
latestHash: string | null;
|
|
1435
|
+
anyHashed: boolean;
|
|
1436
|
+
}>>;
|
|
1362
1437
|
/**
|
|
1363
1438
|
* Return the live source_refs for an entity that hold the given source_hash.
|
|
1364
1439
|
* Used by the ingestDocument duplicate-hash guard and by hosts auditing
|
|
@@ -1991,9 +2066,29 @@ declare class OntologyService {
|
|
|
1991
2066
|
resolveAndPersistEdges(entityId: string, sourceId: string, sourceType: string | null, edges: ExtractedFactEdge[], manifest: OntologyManifest, titleIndex: Map<string, TitleIndexEntry>, tx: SQLiteAdapter, now: number, drops?: EdgeDrop[]): Promise<number>;
|
|
1992
2067
|
}
|
|
1993
2068
|
|
|
2069
|
+
type GroundingWriter = 'ingest' | 'librarian' | 'heal';
|
|
2070
|
+
interface ResolvedGrounding {
|
|
2071
|
+
writers: ReadonlySet<GroundingWriter>;
|
|
2072
|
+
minEvidenceChars: number;
|
|
2073
|
+
maxEvidence: number;
|
|
2074
|
+
maxEvidenceChars: number;
|
|
2075
|
+
}
|
|
2076
|
+
/** Insert-time trust fields. Spread onto a new `WikiFact`; `EntryRepository.upsert` writes them on INSERT only. */
|
|
2077
|
+
interface GroundingTrust {
|
|
2078
|
+
lifecycle_status: 'stable' | 'draft';
|
|
2079
|
+
okf_verified?: OkfVerifiedEntry[];
|
|
2080
|
+
last_verified_at?: number;
|
|
2081
|
+
last_verified_by?: string;
|
|
2082
|
+
}
|
|
2083
|
+
|
|
1994
2084
|
declare class PromptService {
|
|
1995
2085
|
private globalOverrides?;
|
|
1996
|
-
|
|
2086
|
+
private grounding;
|
|
2087
|
+
constructor(globalOverrides?: PromptOverrides | undefined, grounding?: ResolvedGrounding | null);
|
|
2088
|
+
/** The resolved grounding config when `writer` is in `grounding.writers`; otherwise null (spec §6.2). */
|
|
2089
|
+
groundingFor(writer: GroundingWriter): ResolvedGrounding | null;
|
|
2090
|
+
/** Appended after any override and after ontology context, so it is always last. */
|
|
2091
|
+
private appendGrounding;
|
|
1997
2092
|
private hydrate;
|
|
1998
2093
|
private hasOntologyPlaceholders;
|
|
1999
2094
|
private buildSystemPrompt;
|
|
@@ -2005,6 +2100,7 @@ declare class PromptService {
|
|
|
2005
2100
|
buildLibrarianPrompt(events: unknown[], currentFacts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null): {
|
|
2006
2101
|
systemPrompt: string;
|
|
2007
2102
|
userPrompt: string;
|
|
2103
|
+
groundingCorpus?: string[];
|
|
2008
2104
|
};
|
|
2009
2105
|
/**
|
|
2010
2106
|
* Heal-prompt level interpretation for the `attemptLevel` ladder.
|
|
@@ -2034,11 +2130,19 @@ declare class PromptService {
|
|
|
2034
2130
|
userPrompt: string;
|
|
2035
2131
|
};
|
|
2036
2132
|
degraded: DegradedRecord[];
|
|
2133
|
+
groundingCorpus?: string[];
|
|
2037
2134
|
};
|
|
2038
2135
|
buildOntologyBackfillPrompt(facts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null): {
|
|
2039
2136
|
systemPrompt: string;
|
|
2040
2137
|
userPrompt: string;
|
|
2041
2138
|
};
|
|
2139
|
+
/**
|
|
2140
|
+
* The system prompt each writer would send, without hydrating data (spec
|
|
2141
|
+
* §8.3). `buildSystemPrompt` with no variables hydrates only ontology
|
|
2142
|
+
* placeholders and leaves data placeholders verbatim; heal never receives
|
|
2143
|
+
* ontology context, matching `buildHealPrompt`.
|
|
2144
|
+
*/
|
|
2145
|
+
buildInstructionTemplates(ontologyContext: OntologyPromptContext | null): WikiInstructions;
|
|
2042
2146
|
}
|
|
2043
2147
|
|
|
2044
2148
|
declare class IngestionService {
|
|
@@ -2140,6 +2244,8 @@ declare class IngestionService {
|
|
|
2140
2244
|
buffer: DiagnosticBuffer;
|
|
2141
2245
|
operation: 'ingest' | 'upsertGraph';
|
|
2142
2246
|
};
|
|
2247
|
+
/** Insert-time trust by node id. Ingest-only (spec §6.5); the public upsertGraph never passes it, so host nodes are never grounded. */
|
|
2248
|
+
nodeTrust?: ReadonlyMap<string, GroundingTrust>;
|
|
2143
2249
|
}): Promise<{
|
|
2144
2250
|
nodesWritten: number;
|
|
2145
2251
|
edgesWritten: number;
|
|
@@ -2581,6 +2687,8 @@ declare class WikiMemory {
|
|
|
2581
2687
|
private promptService;
|
|
2582
2688
|
private ontologyService;
|
|
2583
2689
|
private graphTraversalService;
|
|
2690
|
+
private lintRepo;
|
|
2691
|
+
private lintService;
|
|
2584
2692
|
private readonly okfTrustWrites;
|
|
2585
2693
|
constructor(db: SQLiteAdapter, options: WikiOptions);
|
|
2586
2694
|
/**
|
|
@@ -2608,6 +2716,30 @@ declare class WikiMemory {
|
|
|
2608
2716
|
changed: boolean;
|
|
2609
2717
|
duplicateOf?: string;
|
|
2610
2718
|
}>>;
|
|
2719
|
+
/**
|
|
2720
|
+
* Batch pending state per source (spec §8.2). `current` exactly when
|
|
2721
|
+
* `hasChanged` is false; `partial` when live rows exist but none carries a
|
|
2722
|
+
* hash (a first ingest with a failed chunk, or imported rows without a
|
|
2723
|
+
* hash). A failed re-ingest of an already-hashed ref reports `changed`. Validation and raw-ref echo match
|
|
2724
|
+
* batched `hasChanged`. Input order and duplicates are preserved. A
|
|
2725
|
+
* non-array `sources`, or an entry that is not an object (including a hole
|
|
2726
|
+
* in a sparse array), throws a `TypeError` before any SQL runs.
|
|
2727
|
+
*/
|
|
2728
|
+
pendingSources(entityId: string, sources: Array<{
|
|
2729
|
+
sourceRef: string;
|
|
2730
|
+
sourceHash: string;
|
|
2731
|
+
}>): Promise<Array<{
|
|
2732
|
+
sourceRef: string;
|
|
2733
|
+
status: PendingSourceStatus;
|
|
2734
|
+
}>>;
|
|
2735
|
+
/** Read-only maintenance report for one entity (spec §8.1). Reports, never repairs. */
|
|
2736
|
+
lint(entityId: string): Promise<WikiLintReport>;
|
|
2737
|
+
/**
|
|
2738
|
+
* Effective system prompts for ingest, librarian, heal and ontology backfill
|
|
2739
|
+
* (spec §8.3). Backs the `wiki_get_instructions` tool. Templates only;
|
|
2740
|
+
* overrides are returned verbatim, so keep secrets out of `WikiConfig.prompts`.
|
|
2741
|
+
*/
|
|
2742
|
+
getInstructions(entityId: string): Promise<WikiInstructions>;
|
|
2611
2743
|
/**
|
|
2612
2744
|
* Returns the live source_refs for an entity, one row per ref, with the most
|
|
2613
2745
|
* recently-updated live `source_hash` and a live fact count. Refs are sorted
|
|
@@ -2942,4 +3074,4 @@ declare class WikiMemory {
|
|
|
2942
3074
|
setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
|
|
2943
3075
|
}
|
|
2944
3076
|
|
|
2945
|
-
export { type
|
|
3077
|
+
export { type WikiBusyOperation as $, type OntologyMode as A, type OntologyNodeType as B, type ChunkFailure as C, type DegradedRecord as D, type EmbedFactResult as E, type FormatContextOptions as F, type GraphNeighborhood as G, HEAL_BATCH_SIZE as H, type IngestDocumentResult as I, type OntologyPromptContext as J, type OntologyUpdates as K, type LLMProvider as L, type MemoryBundle as M, type PromptOverrides as N, ONTOLOGY_BACKFILL_BATCH_SIZE as O, type PendingSourceStatus as P, PromptService as Q, type ReadOptions as R, type SQLiteAdapter as S, PrunePartialFailureError as T, type ReembedResult as U, type VectorRanker as V, type WikiOptions as W, type VectorRankerFallback as X, type VectorRankerRankArgs as Y, type VectorRankerSemanticResult as Z, WikiBusyError as _, type MemoryDump as a, type WikiCheckpoint as a0, type WikiConfig as a1, type WikiDiagnostic as a2, type WikiDiagnosticCode as a3, type WikiDiagnosticDetail as a4, type WikiDiagnosticOperation as a5, type WikiDiagnosticSeverity as a6, type WikiDiagnosticTrigger as a7, WikiDraftNotFound as a8, WikiDuplicateHashError as a9, type WikiEdge as aa, type WikiEvent as ab, type WikiFact as ac, WikiGraphNodeOwnershipConflict as ad, WikiIngestEmptyError as ae, type WikiInstructions as af, WikiInvalidReadOptions as ag, type WikiLintReport as ah, type WikiMemoryTestAccess as ai, type WikiOutboxEvent as aj, WikiParseError as ak, WikiSourceRefHashCollision as al, WikiStrictOntologyViolation as am, type WikiTask as an, WikiTransactionError as ao, validateManifest as ap, EmbeddingService as aq, ImportExportService as ar, IngestionService as as, JobManager as at, MaintenanceService as au, RetrievalService as av, SearchService as aw, WriteService as ax, type FormattedMemoryDump as b, WikiMemory as c, type ClassifierAnswer as d, type ClassifierQuestion as e, type ClassifyRequest as f, type ClassifyResponse as g, type DraftPage as h, type EmbedFailureKind as i, type EmbeddingMarkerKind as j, type EntityStatus as k, type ExtractedFact as l, type ExtractedFactEdge as m, type ExtractedFactWithOntology as n, type ExtractedTask as o, type GraphTraversalOptions as p, type GroundingConfig as q, HEAL_RECHECK_MS as r, HOOK_TIMEOUT_MARKER as s, type HealResult as t, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as u, ONTOLOGY_BACKFILL_RECHECK_MS as v, type OntologyBackfillResult as w, type OntologyConfig as x, type OntologyEdgeType as y, type OntologyManifest as z };
|
|
@@ -215,6 +215,23 @@ interface HealResult {
|
|
|
215
215
|
/** Heal candidates inside the recheck cooldown. */
|
|
216
216
|
deferred: number;
|
|
217
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Opt-in evidence check for LLM-authored facts (spec §6). Default off: 7.x
|
|
220
|
+
* write behavior is unchanged. In `'draft'` mode, writers in `writers` must
|
|
221
|
+
* quote their source; a fact whose quotes are missing or not found is stored
|
|
222
|
+
* as a `draft` instead of being rejected.
|
|
223
|
+
*/
|
|
224
|
+
interface GroundingConfig {
|
|
225
|
+
mode: 'off' | 'draft';
|
|
226
|
+
/** Default `['ingest']`. The librarian and heal synthesize across events; measure their pass rates before opting them in. */
|
|
227
|
+
writers?: Array<'ingest' | 'librarian' | 'heal'>;
|
|
228
|
+
/** Quotes shorter than this (after whitespace normalization) count as absent. Default 20. */
|
|
229
|
+
minEvidenceChars?: number;
|
|
230
|
+
/** Quotes retained per fact. Retention only; every quote is checked. Default 3. */
|
|
231
|
+
maxEvidence?: number;
|
|
232
|
+
/** Characters retained per quote. Default 300. */
|
|
233
|
+
maxEvidenceChars?: number;
|
|
234
|
+
}
|
|
218
235
|
interface WikiConfig {
|
|
219
236
|
/**
|
|
220
237
|
* Prefix applied to every SQL table/index/trigger name. Must match
|
|
@@ -260,7 +277,11 @@ interface WikiConfig {
|
|
|
260
277
|
* Default: undefined (pure semantic when embed provided).
|
|
261
278
|
*/
|
|
262
279
|
hybridWeight?: number;
|
|
263
|
-
/**
|
|
280
|
+
/**
|
|
281
|
+
* Global prompt overrides for text generation calls (`ingestDocument`, `runLibrarian`, `runHeal`). Does not affect embedding generation. Runtime overrides on individual method calls take precedence.
|
|
282
|
+
*
|
|
283
|
+
* Returned verbatim by `getInstructions` and the `wiki_get_instructions` tool (`memory:read`): never put secrets, API keys or private data here.
|
|
284
|
+
*/
|
|
264
285
|
prompts?: PromptOverrides;
|
|
265
286
|
/**
|
|
266
287
|
* When true, entry and task mutations append an event to the internal outbox table.
|
|
@@ -282,6 +303,8 @@ interface WikiConfig {
|
|
|
282
303
|
* `GraphTraversalOptions.excludeDrafts`. Default false (drafts visible).
|
|
283
304
|
*/
|
|
284
305
|
excludeDrafts?: boolean;
|
|
306
|
+
/** Evidence check for LLM-authored facts (spec §6). Default off. */
|
|
307
|
+
grounding?: GroundingConfig;
|
|
285
308
|
}
|
|
286
309
|
interface ReadOptions {
|
|
287
310
|
maxResults?: number;
|
|
@@ -493,6 +516,8 @@ interface ExtractedFact {
|
|
|
493
516
|
body: string;
|
|
494
517
|
tags: string[];
|
|
495
518
|
confidence: 'certain' | 'inferred' | 'tentative';
|
|
519
|
+
/** Quotes the model copied from its source; see `WikiConfig.grounding`. Never persisted. */
|
|
520
|
+
evidence?: string[];
|
|
496
521
|
}
|
|
497
522
|
interface ExtractedFactWithOntology extends ExtractedFact {
|
|
498
523
|
okf_type?: string;
|
|
@@ -1030,6 +1055,43 @@ interface DraftPage {
|
|
|
1030
1055
|
facts: WikiFact[];
|
|
1031
1056
|
nextCursor: string | null;
|
|
1032
1057
|
}
|
|
1058
|
+
/**
|
|
1059
|
+
* `pendingSources` status (spec §8.2). `partial`: live rows exist for the ref
|
|
1060
|
+
* but none carries a hash, which is the intended retry state after a partial
|
|
1061
|
+
* ingest. `current` is exactly the case where `hasChanged` returns false.
|
|
1062
|
+
*/
|
|
1063
|
+
type PendingSourceStatus = 'new' | 'changed' | 'partial' | 'current';
|
|
1064
|
+
/** Read-only maintenance report for one entity (spec §8.1). Counts cover live rows only. */
|
|
1065
|
+
interface WikiLintReport {
|
|
1066
|
+
/** Edges whose source or target is missing, soft-deleted, or owned by another entity. */
|
|
1067
|
+
danglingEdges: number;
|
|
1068
|
+
/** Live-endpoint edges whose (source type, edge type, target type) is not in the effective manifest. 0 when ontology is off or the manifest is empty. */
|
|
1069
|
+
manifestViolations: number;
|
|
1070
|
+
/** Live facts with `okf_type` NULL. */
|
|
1071
|
+
untypedFacts: number;
|
|
1072
|
+
/** Live facts with `lifecycle_status = 'draft'`. */
|
|
1073
|
+
drafts: number;
|
|
1074
|
+
/** Live `librarian_inferred` facts with an empty `okf_verified`. */
|
|
1075
|
+
unverifiedInferred: number;
|
|
1076
|
+
/** Up to 20 ids each, ascending. */
|
|
1077
|
+
sample: {
|
|
1078
|
+
danglingEdgeIds: string[];
|
|
1079
|
+
manifestViolationEdgeIds: string[];
|
|
1080
|
+
};
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Effective system prompts (spec §8.3): defaults with `WikiConfig.prompts`
|
|
1084
|
+
* overrides applied and the ontology block appended. Templates only: data
|
|
1085
|
+
* placeholders such as `{{documentChunk}}` stay verbatim, and no events,
|
|
1086
|
+
* chunks or facts are ever included. Overrides are returned as written, so
|
|
1087
|
+
* never put secrets or private data in `WikiConfig.prompts`.
|
|
1088
|
+
*/
|
|
1089
|
+
interface WikiInstructions {
|
|
1090
|
+
ingest: string;
|
|
1091
|
+
librarian: string;
|
|
1092
|
+
heal: string;
|
|
1093
|
+
ontologyBackfill: string;
|
|
1094
|
+
}
|
|
1033
1095
|
|
|
1034
1096
|
interface WikiOutboxEvent<T = unknown> {
|
|
1035
1097
|
id: string;
|
|
@@ -1227,10 +1289,14 @@ declare class EntryRepository extends BaseRepository {
|
|
|
1227
1289
|
* fact, not only immutable_document rows, so the source-type restriction has
|
|
1228
1290
|
* to be applied here, after retrieval.
|
|
1229
1291
|
*/
|
|
1230
|
-
findAnchorRowsByIds(entityId: string, ids: readonly string[], tx?: SQLiteAdapter
|
|
1292
|
+
findAnchorRowsByIds(entityId: string, ids: readonly string[], tx?: SQLiteAdapter, opts?: {
|
|
1293
|
+
withBody?: boolean;
|
|
1294
|
+
}): Promise<Array<{
|
|
1231
1295
|
id: string;
|
|
1232
1296
|
title: string;
|
|
1233
1297
|
source_ref: string | null;
|
|
1298
|
+
body?: string;
|
|
1299
|
+
lifecycle_status?: string;
|
|
1234
1300
|
}>>;
|
|
1235
1301
|
/**
|
|
1236
1302
|
* Fetch recent non-deleted entries for an entity (limited), ordered by updated_at DESC.
|
|
@@ -1359,6 +1425,15 @@ declare class EntryRepository extends BaseRepository {
|
|
|
1359
1425
|
* Empty input is a synchronous early return with zero SQL calls.
|
|
1360
1426
|
*/
|
|
1361
1427
|
findLatestSourceHashes(entityId: string, sourceRefs: readonly string[], tx?: SQLiteAdapter): Promise<Map<string, string | null>>;
|
|
1428
|
+
/**
|
|
1429
|
+
* Per source ref, the hash of the latest live row (same ordering as
|
|
1430
|
+
* {@link findLatestSourceHashes}) and whether ANY live row carries a hash.
|
|
1431
|
+
* Refs with no live row are absent. Chunked under the bind-variable limit.
|
|
1432
|
+
*/
|
|
1433
|
+
findSourceStates(entityId: string, sourceRefs: readonly string[], tx?: SQLiteAdapter): Promise<Map<string, {
|
|
1434
|
+
latestHash: string | null;
|
|
1435
|
+
anyHashed: boolean;
|
|
1436
|
+
}>>;
|
|
1362
1437
|
/**
|
|
1363
1438
|
* Return the live source_refs for an entity that hold the given source_hash.
|
|
1364
1439
|
* Used by the ingestDocument duplicate-hash guard and by hosts auditing
|
|
@@ -1991,9 +2066,29 @@ declare class OntologyService {
|
|
|
1991
2066
|
resolveAndPersistEdges(entityId: string, sourceId: string, sourceType: string | null, edges: ExtractedFactEdge[], manifest: OntologyManifest, titleIndex: Map<string, TitleIndexEntry>, tx: SQLiteAdapter, now: number, drops?: EdgeDrop[]): Promise<number>;
|
|
1992
2067
|
}
|
|
1993
2068
|
|
|
2069
|
+
type GroundingWriter = 'ingest' | 'librarian' | 'heal';
|
|
2070
|
+
interface ResolvedGrounding {
|
|
2071
|
+
writers: ReadonlySet<GroundingWriter>;
|
|
2072
|
+
minEvidenceChars: number;
|
|
2073
|
+
maxEvidence: number;
|
|
2074
|
+
maxEvidenceChars: number;
|
|
2075
|
+
}
|
|
2076
|
+
/** Insert-time trust fields. Spread onto a new `WikiFact`; `EntryRepository.upsert` writes them on INSERT only. */
|
|
2077
|
+
interface GroundingTrust {
|
|
2078
|
+
lifecycle_status: 'stable' | 'draft';
|
|
2079
|
+
okf_verified?: OkfVerifiedEntry[];
|
|
2080
|
+
last_verified_at?: number;
|
|
2081
|
+
last_verified_by?: string;
|
|
2082
|
+
}
|
|
2083
|
+
|
|
1994
2084
|
declare class PromptService {
|
|
1995
2085
|
private globalOverrides?;
|
|
1996
|
-
|
|
2086
|
+
private grounding;
|
|
2087
|
+
constructor(globalOverrides?: PromptOverrides | undefined, grounding?: ResolvedGrounding | null);
|
|
2088
|
+
/** The resolved grounding config when `writer` is in `grounding.writers`; otherwise null (spec §6.2). */
|
|
2089
|
+
groundingFor(writer: GroundingWriter): ResolvedGrounding | null;
|
|
2090
|
+
/** Appended after any override and after ontology context, so it is always last. */
|
|
2091
|
+
private appendGrounding;
|
|
1997
2092
|
private hydrate;
|
|
1998
2093
|
private hasOntologyPlaceholders;
|
|
1999
2094
|
private buildSystemPrompt;
|
|
@@ -2005,6 +2100,7 @@ declare class PromptService {
|
|
|
2005
2100
|
buildLibrarianPrompt(events: unknown[], currentFacts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null): {
|
|
2006
2101
|
systemPrompt: string;
|
|
2007
2102
|
userPrompt: string;
|
|
2103
|
+
groundingCorpus?: string[];
|
|
2008
2104
|
};
|
|
2009
2105
|
/**
|
|
2010
2106
|
* Heal-prompt level interpretation for the `attemptLevel` ladder.
|
|
@@ -2034,11 +2130,19 @@ declare class PromptService {
|
|
|
2034
2130
|
userPrompt: string;
|
|
2035
2131
|
};
|
|
2036
2132
|
degraded: DegradedRecord[];
|
|
2133
|
+
groundingCorpus?: string[];
|
|
2037
2134
|
};
|
|
2038
2135
|
buildOntologyBackfillPrompt(facts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null): {
|
|
2039
2136
|
systemPrompt: string;
|
|
2040
2137
|
userPrompt: string;
|
|
2041
2138
|
};
|
|
2139
|
+
/**
|
|
2140
|
+
* The system prompt each writer would send, without hydrating data (spec
|
|
2141
|
+
* §8.3). `buildSystemPrompt` with no variables hydrates only ontology
|
|
2142
|
+
* placeholders and leaves data placeholders verbatim; heal never receives
|
|
2143
|
+
* ontology context, matching `buildHealPrompt`.
|
|
2144
|
+
*/
|
|
2145
|
+
buildInstructionTemplates(ontologyContext: OntologyPromptContext | null): WikiInstructions;
|
|
2042
2146
|
}
|
|
2043
2147
|
|
|
2044
2148
|
declare class IngestionService {
|
|
@@ -2140,6 +2244,8 @@ declare class IngestionService {
|
|
|
2140
2244
|
buffer: DiagnosticBuffer;
|
|
2141
2245
|
operation: 'ingest' | 'upsertGraph';
|
|
2142
2246
|
};
|
|
2247
|
+
/** Insert-time trust by node id. Ingest-only (spec §6.5); the public upsertGraph never passes it, so host nodes are never grounded. */
|
|
2248
|
+
nodeTrust?: ReadonlyMap<string, GroundingTrust>;
|
|
2143
2249
|
}): Promise<{
|
|
2144
2250
|
nodesWritten: number;
|
|
2145
2251
|
edgesWritten: number;
|
|
@@ -2581,6 +2687,8 @@ declare class WikiMemory {
|
|
|
2581
2687
|
private promptService;
|
|
2582
2688
|
private ontologyService;
|
|
2583
2689
|
private graphTraversalService;
|
|
2690
|
+
private lintRepo;
|
|
2691
|
+
private lintService;
|
|
2584
2692
|
private readonly okfTrustWrites;
|
|
2585
2693
|
constructor(db: SQLiteAdapter, options: WikiOptions);
|
|
2586
2694
|
/**
|
|
@@ -2608,6 +2716,30 @@ declare class WikiMemory {
|
|
|
2608
2716
|
changed: boolean;
|
|
2609
2717
|
duplicateOf?: string;
|
|
2610
2718
|
}>>;
|
|
2719
|
+
/**
|
|
2720
|
+
* Batch pending state per source (spec §8.2). `current` exactly when
|
|
2721
|
+
* `hasChanged` is false; `partial` when live rows exist but none carries a
|
|
2722
|
+
* hash (a first ingest with a failed chunk, or imported rows without a
|
|
2723
|
+
* hash). A failed re-ingest of an already-hashed ref reports `changed`. Validation and raw-ref echo match
|
|
2724
|
+
* batched `hasChanged`. Input order and duplicates are preserved. A
|
|
2725
|
+
* non-array `sources`, or an entry that is not an object (including a hole
|
|
2726
|
+
* in a sparse array), throws a `TypeError` before any SQL runs.
|
|
2727
|
+
*/
|
|
2728
|
+
pendingSources(entityId: string, sources: Array<{
|
|
2729
|
+
sourceRef: string;
|
|
2730
|
+
sourceHash: string;
|
|
2731
|
+
}>): Promise<Array<{
|
|
2732
|
+
sourceRef: string;
|
|
2733
|
+
status: PendingSourceStatus;
|
|
2734
|
+
}>>;
|
|
2735
|
+
/** Read-only maintenance report for one entity (spec §8.1). Reports, never repairs. */
|
|
2736
|
+
lint(entityId: string): Promise<WikiLintReport>;
|
|
2737
|
+
/**
|
|
2738
|
+
* Effective system prompts for ingest, librarian, heal and ontology backfill
|
|
2739
|
+
* (spec §8.3). Backs the `wiki_get_instructions` tool. Templates only;
|
|
2740
|
+
* overrides are returned verbatim, so keep secrets out of `WikiConfig.prompts`.
|
|
2741
|
+
*/
|
|
2742
|
+
getInstructions(entityId: string): Promise<WikiInstructions>;
|
|
2611
2743
|
/**
|
|
2612
2744
|
* Returns the live source_refs for an entity, one row per ref, with the most
|
|
2613
2745
|
* recently-updated live `source_hash` and a live fact count. Refs are sorted
|
|
@@ -2942,4 +3074,4 @@ declare class WikiMemory {
|
|
|
2942
3074
|
setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
|
|
2943
3075
|
}
|
|
2944
3076
|
|
|
2945
|
-
export { type
|
|
3077
|
+
export { type WikiBusyOperation as $, type OntologyMode as A, type OntologyNodeType as B, type ChunkFailure as C, type DegradedRecord as D, type EmbedFactResult as E, type FormatContextOptions as F, type GraphNeighborhood as G, HEAL_BATCH_SIZE as H, type IngestDocumentResult as I, type OntologyPromptContext as J, type OntologyUpdates as K, type LLMProvider as L, type MemoryBundle as M, type PromptOverrides as N, ONTOLOGY_BACKFILL_BATCH_SIZE as O, type PendingSourceStatus as P, PromptService as Q, type ReadOptions as R, type SQLiteAdapter as S, PrunePartialFailureError as T, type ReembedResult as U, type VectorRanker as V, type WikiOptions as W, type VectorRankerFallback as X, type VectorRankerRankArgs as Y, type VectorRankerSemanticResult as Z, WikiBusyError as _, type MemoryDump as a, type WikiCheckpoint as a0, type WikiConfig as a1, type WikiDiagnostic as a2, type WikiDiagnosticCode as a3, type WikiDiagnosticDetail as a4, type WikiDiagnosticOperation as a5, type WikiDiagnosticSeverity as a6, type WikiDiagnosticTrigger as a7, WikiDraftNotFound as a8, WikiDuplicateHashError as a9, type WikiEdge as aa, type WikiEvent as ab, type WikiFact as ac, WikiGraphNodeOwnershipConflict as ad, WikiIngestEmptyError as ae, type WikiInstructions as af, WikiInvalidReadOptions as ag, type WikiLintReport as ah, type WikiMemoryTestAccess as ai, type WikiOutboxEvent as aj, WikiParseError as ak, WikiSourceRefHashCollision as al, WikiStrictOntologyViolation as am, type WikiTask as an, WikiTransactionError as ao, validateManifest as ap, EmbeddingService as aq, ImportExportService as ar, IngestionService as as, JobManager as at, MaintenanceService as au, RetrievalService as av, SearchService as aw, WriteService as ax, type FormattedMemoryDump as b, WikiMemory as c, type ClassifierAnswer as d, type ClassifierQuestion as e, type ClassifyRequest as f, type ClassifyResponse as g, type DraftPage as h, type EmbedFailureKind as i, type EmbeddingMarkerKind as j, type EntityStatus as k, type ExtractedFact as l, type ExtractedFactEdge as m, type ExtractedFactWithOntology as n, type ExtractedTask as o, type GraphTraversalOptions as p, type GroundingConfig as q, HEAL_RECHECK_MS as r, HOOK_TIMEOUT_MARKER as s, type HealResult as t, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as u, ONTOLOGY_BACKFILL_RECHECK_MS as v, type OntologyBackfillResult as w, type OntologyConfig as x, type OntologyEdgeType as y, type OntologyManifest as z };
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { aq as EmbeddingService, ar as ImportExportService, as as IngestionService, at as JobManager, at as JobManagerType, au as MaintenanceService, av as RetrievalService, aw as SearchService, aw as SearchServiceType, ai as WikiMemoryTestAccess, ax as WriteService } from './testing-A4Sofxyo.mjs';
|
|
2
2
|
import '@equationalapplications/core-okf';
|
|
3
3
|
import 'minisearch';
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { aq as EmbeddingService, ar as ImportExportService, as as IngestionService, at as JobManager, at as JobManagerType, au as MaintenanceService, av as RetrievalService, aw as SearchService, aw as SearchServiceType, ai as WikiMemoryTestAccess, ax as WriteService } from './testing-A4Sofxyo.js';
|
|
2
2
|
import '@equationalapplications/core-okf';
|
|
3
3
|
import 'minisearch';
|