@equationalapplications/core-llm-wiki 7.4.0 → 7.6.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.
@@ -82,6 +82,14 @@ interface OntologyConfig {
82
82
  manifest: OntologyManifest;
83
83
  mode?: OntologyMode;
84
84
  }>;
85
+ /**
86
+ * Engine default for `runOntologyBackfill`'s `classifier` option.
87
+ * `'auto'` uses `llmProvider.classify` for node typing when present
88
+ * (no edges are proposed); `'llm'` always uses `generateText`. Default `'llm'`.
89
+ */
90
+ backfillClassifier?: 'auto' | 'llm';
91
+ /** Minimum classifier confidence to apply a node type. Finite, in [0, 1]. Default 0.5. */
92
+ classifyMinConfidence?: number;
85
93
  }
86
94
  interface ExtractedFactEdge {
87
95
  edge_type: string;
@@ -207,6 +215,23 @@ interface HealResult {
207
215
  /** Heal candidates inside the recheck cooldown. */
208
216
  deferred: number;
209
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
+ }
210
235
  interface WikiConfig {
211
236
  /**
212
237
  * Prefix applied to every SQL table/index/trigger name. Must match
@@ -274,6 +299,8 @@ interface WikiConfig {
274
299
  * `GraphTraversalOptions.excludeDrafts`. Default false (drafts visible).
275
300
  */
276
301
  excludeDrafts?: boolean;
302
+ /** Evidence check for LLM-authored facts (spec §6). Default off. */
303
+ grounding?: GroundingConfig;
277
304
  }
278
305
  interface ReadOptions {
279
306
  maxResults?: number;
@@ -485,6 +512,8 @@ interface ExtractedFact {
485
512
  body: string;
486
513
  tags: string[];
487
514
  confidence: 'certain' | 'inferred' | 'tentative';
515
+ /** Quotes the model copied from its source; see `WikiConfig.grounding`. Never persisted. */
516
+ evidence?: string[];
488
517
  }
489
518
  interface ExtractedFactWithOntology extends ExtractedFact {
490
519
  okf_type?: string;
@@ -498,6 +527,8 @@ interface LLMProvider {
498
527
  /**
499
528
  * Generates text using the developer's LLM of choice.
500
529
  * Expected to return the raw text response (typically a JSON string).
530
+ * Called with the provider as `this`, so class-based adapters may keep
531
+ * SDK handles and config on the instance.
501
532
  */
502
533
  generateText: (params: {
503
534
  systemPrompt: string;
@@ -508,6 +539,8 @@ interface LLMProvider {
508
539
  * Must return a stable-dimension float array for any input text.
509
540
  * Called once per fact on creation/update, and once per `read()` query.
510
541
  * When absent or throws, `read()` falls back to MiniSearch.
542
+ * Called with the provider as `this` (never detached), same as
543
+ * `generateText`, so class-based adapters may read their own state.
511
544
  */
512
545
  embed?: (text: string) => Promise<number[]>;
513
546
  /**
@@ -521,6 +554,49 @@ interface LLMProvider {
521
554
  * never trusted as a guarantee.
522
555
  */
523
556
  maxOutputTokens?: number;
557
+ /**
558
+ * Optional non-generative classifier (System-One models such as Jev,
559
+ * OpenJev, or a local ONNX classifier). Core never calls it unless the host
560
+ * opts in (e.g. `WikiConfig.ontology.backfillClassifier: 'auto'`); merely
561
+ * providing it changes nothing (REQ-COMPAT-01.5). Output is validated as
562
+ * untrusted.
563
+ */
564
+ classify?: (request: ClassifyRequest) => Promise<ClassifyResponse>;
565
+ }
566
+ /** One typed question for a classifier. Vendor-neutral (Jev `noul` ↔ `binary`). */
567
+ type ClassifierQuestion = {
568
+ kind: 'choice';
569
+ options: string[];
570
+ instructions?: string;
571
+ } | {
572
+ kind: 'binary';
573
+ instructions: string;
574
+ } | {
575
+ kind: 'score';
576
+ levels: string[];
577
+ instructions?: string;
578
+ };
579
+ /** One state evaluated against a map of questions (many questions per state, one state per call). */
580
+ interface ClassifyRequest {
581
+ state: string;
582
+ questions: Record<string, ClassifierQuestion>;
583
+ }
584
+ type ClassifierAnswer = {
585
+ kind: 'choice';
586
+ choice: string;
587
+ confidence: number;
588
+ probabilities: Record<string, number>;
589
+ } | {
590
+ kind: 'binary';
591
+ probability: number;
592
+ } | {
593
+ kind: 'score';
594
+ score: number;
595
+ confidence: number;
596
+ probabilities: number[];
597
+ };
598
+ interface ClassifyResponse {
599
+ answers: Record<string, ClassifierAnswer>;
524
600
  }
525
601
  /**
526
602
  * Result of semantic ranking for a single fact.
@@ -1172,10 +1248,14 @@ declare class EntryRepository extends BaseRepository {
1172
1248
  * fact, not only immutable_document rows, so the source-type restriction has
1173
1249
  * to be applied here, after retrieval.
1174
1250
  */
1175
- findAnchorRowsByIds(entityId: string, ids: readonly string[], tx?: SQLiteAdapter): Promise<Array<{
1251
+ findAnchorRowsByIds(entityId: string, ids: readonly string[], tx?: SQLiteAdapter, opts?: {
1252
+ withBody?: boolean;
1253
+ }): Promise<Array<{
1176
1254
  id: string;
1177
1255
  title: string;
1178
1256
  source_ref: string | null;
1257
+ body?: string;
1258
+ lifecycle_status?: string;
1179
1259
  }>>;
1180
1260
  /**
1181
1261
  * Fetch recent non-deleted entries for an entity (limited), ordered by updated_at DESC.
@@ -1936,9 +2016,29 @@ declare class OntologyService {
1936
2016
  resolveAndPersistEdges(entityId: string, sourceId: string, sourceType: string | null, edges: ExtractedFactEdge[], manifest: OntologyManifest, titleIndex: Map<string, TitleIndexEntry>, tx: SQLiteAdapter, now: number, drops?: EdgeDrop[]): Promise<number>;
1937
2017
  }
1938
2018
 
2019
+ type GroundingWriter = 'ingest' | 'librarian' | 'heal';
2020
+ interface ResolvedGrounding {
2021
+ writers: ReadonlySet<GroundingWriter>;
2022
+ minEvidenceChars: number;
2023
+ maxEvidence: number;
2024
+ maxEvidenceChars: number;
2025
+ }
2026
+ /** Insert-time trust fields. Spread onto a new `WikiFact`; `EntryRepository.upsert` writes them on INSERT only. */
2027
+ interface GroundingTrust {
2028
+ lifecycle_status: 'stable' | 'draft';
2029
+ okf_verified?: OkfVerifiedEntry[];
2030
+ last_verified_at?: number;
2031
+ last_verified_by?: string;
2032
+ }
2033
+
1939
2034
  declare class PromptService {
1940
2035
  private globalOverrides?;
1941
- constructor(globalOverrides?: PromptOverrides | undefined);
2036
+ private grounding;
2037
+ constructor(globalOverrides?: PromptOverrides | undefined, grounding?: ResolvedGrounding | null);
2038
+ /** The resolved grounding config when `writer` is in `grounding.writers`; otherwise null (spec §6.2). */
2039
+ groundingFor(writer: GroundingWriter): ResolvedGrounding | null;
2040
+ /** Appended after any override and after ontology context, so it is always last. */
2041
+ private appendGrounding;
1942
2042
  private hydrate;
1943
2043
  private hasOntologyPlaceholders;
1944
2044
  private buildSystemPrompt;
@@ -1950,6 +2050,7 @@ declare class PromptService {
1950
2050
  buildLibrarianPrompt(events: unknown[], currentFacts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null): {
1951
2051
  systemPrompt: string;
1952
2052
  userPrompt: string;
2053
+ groundingCorpus?: string[];
1953
2054
  };
1954
2055
  /**
1955
2056
  * Heal-prompt level interpretation for the `attemptLevel` ladder.
@@ -1979,6 +2080,7 @@ declare class PromptService {
1979
2080
  userPrompt: string;
1980
2081
  };
1981
2082
  degraded: DegradedRecord[];
2083
+ groundingCorpus?: string[];
1982
2084
  };
1983
2085
  buildOntologyBackfillPrompt(facts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null): {
1984
2086
  systemPrompt: string;
@@ -2085,6 +2187,8 @@ declare class IngestionService {
2085
2187
  buffer: DiagnosticBuffer;
2086
2188
  operation: 'ingest' | 'upsertGraph';
2087
2189
  };
2190
+ /** Insert-time trust by node id. Ingest-only (spec §6.5); the public upsertGraph never passes it, so host nodes are never grounded. */
2191
+ nodeTrust?: ReadonlyMap<string, GroundingTrust>;
2088
2192
  }): Promise<{
2089
2193
  nodesWritten: number;
2090
2194
  edgesWritten: number;
@@ -2275,6 +2379,7 @@ declare class MaintenanceService {
2275
2379
  runOntologyBackfill(entityId: string, options?: {
2276
2380
  promptOverride?: string;
2277
2381
  batchSize?: number;
2382
+ classifier?: 'auto' | 'llm';
2278
2383
  }): Promise<OntologyBackfillResult>;
2279
2384
  /**
2280
2385
  * Re-embed facts, honouring per-row failure markers and exponential backoff.
@@ -2349,7 +2454,15 @@ declare class MaintenanceService {
2349
2454
  doRunOntologyBackfill(entityId: string, options?: {
2350
2455
  promptOverride?: string;
2351
2456
  batchSize?: number;
2457
+ classifier?: 'auto' | 'llm';
2352
2458
  }): Promise<OntologyBackfillResult>;
2459
+ /**
2460
+ * Classifier-mode backfill (spec §7.3): one `choice` question per untyped
2461
+ * fact over the effective manifest's node-type slugs. Accepted answers go
2462
+ * through `_applyOntologyBackfillBatch` exactly like LLM classifications.
2463
+ * No edges are proposed.
2464
+ */
2465
+ private _runClassifierBackfill;
2353
2466
  /**
2354
2467
  * Applies one parsed backfill batch in its own transaction. Per-batch rather
2355
2468
  * than one transaction for the pass, so mergeEmergentUpdates semantics and
@@ -2657,6 +2770,7 @@ declare class WikiMemory {
2657
2770
  runOntologyBackfill(entityId: string, options?: {
2658
2771
  promptOverride?: string;
2659
2772
  batchSize?: number;
2773
+ classifier?: 'auto' | 'llm';
2660
2774
  }): Promise<OntologyBackfillResult>;
2661
2775
  runReembed(entityId?: string, opts?: {
2662
2776
  force?: boolean;
@@ -2877,4 +2991,4 @@ declare class WikiMemory {
2877
2991
  setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
2878
2992
  }
2879
2993
 
2880
- export { type WikiDiagnosticOperation as $, PrunePartialFailureError as A, type ReembedResult 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 VectorRankerFallback as J, type VectorRankerRankArgs as K, type LLMProvider as L, type MemoryBundle as M, type VectorRankerSemanticResult as N, ONTOLOGY_BACKFILL_BATCH_SIZE as O, type PromptOverrides as P, WikiBusyError as Q, type ReadOptions as R, type SQLiteAdapter as S, type WikiBusyOperation as T, type WikiCheckpoint as U, type VectorRanker as V, type WikiOptions as W, type WikiConfig as X, type WikiDiagnostic as Y, type WikiDiagnosticCode as Z, type WikiDiagnosticDetail as _, type MemoryDump as a, type WikiDiagnosticSeverity as a0, type WikiDiagnosticTrigger as a1, WikiDraftNotFound as a2, WikiDuplicateHashError as a3, type WikiEdge as a4, type WikiEvent as a5, type WikiFact as a6, WikiGraphNodeOwnershipConflict as a7, WikiIngestEmptyError as a8, WikiInvalidReadOptions as a9, type WikiMemoryTestAccess as aa, type WikiOutboxEvent as ab, WikiParseError as ac, WikiSourceRefHashCollision as ad, WikiStrictOntologyViolation as ae, type WikiTask as af, WikiTransactionError as ag, validateManifest as ah, EmbeddingService as ai, ImportExportService as aj, IngestionService as ak, JobManager as al, MaintenanceService as am, RetrievalService as an, SearchService as ao, WriteService as ap, type FormattedMemoryDump as b, WikiMemory as c, type DraftPage as d, type EmbedFailureKind as e, type EmbeddingMarkerKind as f, type EntityStatus as g, type ExtractedFact as h, type ExtractedFactEdge as i, type ExtractedFactWithOntology as j, type ExtractedTask as k, type GraphTraversalOptions as l, HEAL_RECHECK_MS as m, HOOK_TIMEOUT_MARKER as n, type HealResult as o, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as p, ONTOLOGY_BACKFILL_RECHECK_MS as q, type OntologyBackfillResult as r, type OntologyConfig as s, type OntologyEdgeType as t, type OntologyManifest as u, type OntologyMode as v, type OntologyNodeType as w, type OntologyPromptContext as x, type OntologyUpdates as y, PromptService as z };
2994
+ export { type WikiCheckpoint 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, PromptService as N, ONTOLOGY_BACKFILL_BATCH_SIZE as O, type PromptOverrides as P, PrunePartialFailureError as Q, type ReadOptions as R, type SQLiteAdapter as S, type ReembedResult as T, type VectorRankerFallback as U, type VectorRanker as V, type WikiOptions as W, type VectorRankerRankArgs as X, type VectorRankerSemanticResult as Y, WikiBusyError as Z, type WikiBusyOperation as _, type MemoryDump as a, type WikiConfig as a0, type WikiDiagnostic as a1, type WikiDiagnosticCode as a2, type WikiDiagnosticDetail as a3, type WikiDiagnosticOperation as a4, type WikiDiagnosticSeverity as a5, type WikiDiagnosticTrigger as a6, WikiDraftNotFound as a7, WikiDuplicateHashError as a8, type WikiEdge as a9, type WikiEvent as aa, type WikiFact as ab, WikiGraphNodeOwnershipConflict as ac, WikiIngestEmptyError as ad, WikiInvalidReadOptions as ae, type WikiMemoryTestAccess as af, type WikiOutboxEvent as ag, WikiParseError as ah, WikiSourceRefHashCollision as ai, WikiStrictOntologyViolation as aj, type WikiTask as ak, WikiTransactionError as al, validateManifest as am, EmbeddingService as an, ImportExportService as ao, IngestionService as ap, JobManager as aq, MaintenanceService as ar, RetrievalService as as, SearchService as at, WriteService as au, 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 };
@@ -82,6 +82,14 @@ interface OntologyConfig {
82
82
  manifest: OntologyManifest;
83
83
  mode?: OntologyMode;
84
84
  }>;
85
+ /**
86
+ * Engine default for `runOntologyBackfill`'s `classifier` option.
87
+ * `'auto'` uses `llmProvider.classify` for node typing when present
88
+ * (no edges are proposed); `'llm'` always uses `generateText`. Default `'llm'`.
89
+ */
90
+ backfillClassifier?: 'auto' | 'llm';
91
+ /** Minimum classifier confidence to apply a node type. Finite, in [0, 1]. Default 0.5. */
92
+ classifyMinConfidence?: number;
85
93
  }
86
94
  interface ExtractedFactEdge {
87
95
  edge_type: string;
@@ -207,6 +215,23 @@ interface HealResult {
207
215
  /** Heal candidates inside the recheck cooldown. */
208
216
  deferred: number;
209
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
+ }
210
235
  interface WikiConfig {
211
236
  /**
212
237
  * Prefix applied to every SQL table/index/trigger name. Must match
@@ -274,6 +299,8 @@ interface WikiConfig {
274
299
  * `GraphTraversalOptions.excludeDrafts`. Default false (drafts visible).
275
300
  */
276
301
  excludeDrafts?: boolean;
302
+ /** Evidence check for LLM-authored facts (spec §6). Default off. */
303
+ grounding?: GroundingConfig;
277
304
  }
278
305
  interface ReadOptions {
279
306
  maxResults?: number;
@@ -485,6 +512,8 @@ interface ExtractedFact {
485
512
  body: string;
486
513
  tags: string[];
487
514
  confidence: 'certain' | 'inferred' | 'tentative';
515
+ /** Quotes the model copied from its source; see `WikiConfig.grounding`. Never persisted. */
516
+ evidence?: string[];
488
517
  }
489
518
  interface ExtractedFactWithOntology extends ExtractedFact {
490
519
  okf_type?: string;
@@ -498,6 +527,8 @@ interface LLMProvider {
498
527
  /**
499
528
  * Generates text using the developer's LLM of choice.
500
529
  * Expected to return the raw text response (typically a JSON string).
530
+ * Called with the provider as `this`, so class-based adapters may keep
531
+ * SDK handles and config on the instance.
501
532
  */
502
533
  generateText: (params: {
503
534
  systemPrompt: string;
@@ -508,6 +539,8 @@ interface LLMProvider {
508
539
  * Must return a stable-dimension float array for any input text.
509
540
  * Called once per fact on creation/update, and once per `read()` query.
510
541
  * When absent or throws, `read()` falls back to MiniSearch.
542
+ * Called with the provider as `this` (never detached), same as
543
+ * `generateText`, so class-based adapters may read their own state.
511
544
  */
512
545
  embed?: (text: string) => Promise<number[]>;
513
546
  /**
@@ -521,6 +554,49 @@ interface LLMProvider {
521
554
  * never trusted as a guarantee.
522
555
  */
523
556
  maxOutputTokens?: number;
557
+ /**
558
+ * Optional non-generative classifier (System-One models such as Jev,
559
+ * OpenJev, or a local ONNX classifier). Core never calls it unless the host
560
+ * opts in (e.g. `WikiConfig.ontology.backfillClassifier: 'auto'`); merely
561
+ * providing it changes nothing (REQ-COMPAT-01.5). Output is validated as
562
+ * untrusted.
563
+ */
564
+ classify?: (request: ClassifyRequest) => Promise<ClassifyResponse>;
565
+ }
566
+ /** One typed question for a classifier. Vendor-neutral (Jev `noul` ↔ `binary`). */
567
+ type ClassifierQuestion = {
568
+ kind: 'choice';
569
+ options: string[];
570
+ instructions?: string;
571
+ } | {
572
+ kind: 'binary';
573
+ instructions: string;
574
+ } | {
575
+ kind: 'score';
576
+ levels: string[];
577
+ instructions?: string;
578
+ };
579
+ /** One state evaluated against a map of questions (many questions per state, one state per call). */
580
+ interface ClassifyRequest {
581
+ state: string;
582
+ questions: Record<string, ClassifierQuestion>;
583
+ }
584
+ type ClassifierAnswer = {
585
+ kind: 'choice';
586
+ choice: string;
587
+ confidence: number;
588
+ probabilities: Record<string, number>;
589
+ } | {
590
+ kind: 'binary';
591
+ probability: number;
592
+ } | {
593
+ kind: 'score';
594
+ score: number;
595
+ confidence: number;
596
+ probabilities: number[];
597
+ };
598
+ interface ClassifyResponse {
599
+ answers: Record<string, ClassifierAnswer>;
524
600
  }
525
601
  /**
526
602
  * Result of semantic ranking for a single fact.
@@ -1172,10 +1248,14 @@ declare class EntryRepository extends BaseRepository {
1172
1248
  * fact, not only immutable_document rows, so the source-type restriction has
1173
1249
  * to be applied here, after retrieval.
1174
1250
  */
1175
- findAnchorRowsByIds(entityId: string, ids: readonly string[], tx?: SQLiteAdapter): Promise<Array<{
1251
+ findAnchorRowsByIds(entityId: string, ids: readonly string[], tx?: SQLiteAdapter, opts?: {
1252
+ withBody?: boolean;
1253
+ }): Promise<Array<{
1176
1254
  id: string;
1177
1255
  title: string;
1178
1256
  source_ref: string | null;
1257
+ body?: string;
1258
+ lifecycle_status?: string;
1179
1259
  }>>;
1180
1260
  /**
1181
1261
  * Fetch recent non-deleted entries for an entity (limited), ordered by updated_at DESC.
@@ -1936,9 +2016,29 @@ declare class OntologyService {
1936
2016
  resolveAndPersistEdges(entityId: string, sourceId: string, sourceType: string | null, edges: ExtractedFactEdge[], manifest: OntologyManifest, titleIndex: Map<string, TitleIndexEntry>, tx: SQLiteAdapter, now: number, drops?: EdgeDrop[]): Promise<number>;
1937
2017
  }
1938
2018
 
2019
+ type GroundingWriter = 'ingest' | 'librarian' | 'heal';
2020
+ interface ResolvedGrounding {
2021
+ writers: ReadonlySet<GroundingWriter>;
2022
+ minEvidenceChars: number;
2023
+ maxEvidence: number;
2024
+ maxEvidenceChars: number;
2025
+ }
2026
+ /** Insert-time trust fields. Spread onto a new `WikiFact`; `EntryRepository.upsert` writes them on INSERT only. */
2027
+ interface GroundingTrust {
2028
+ lifecycle_status: 'stable' | 'draft';
2029
+ okf_verified?: OkfVerifiedEntry[];
2030
+ last_verified_at?: number;
2031
+ last_verified_by?: string;
2032
+ }
2033
+
1939
2034
  declare class PromptService {
1940
2035
  private globalOverrides?;
1941
- constructor(globalOverrides?: PromptOverrides | undefined);
2036
+ private grounding;
2037
+ constructor(globalOverrides?: PromptOverrides | undefined, grounding?: ResolvedGrounding | null);
2038
+ /** The resolved grounding config when `writer` is in `grounding.writers`; otherwise null (spec §6.2). */
2039
+ groundingFor(writer: GroundingWriter): ResolvedGrounding | null;
2040
+ /** Appended after any override and after ontology context, so it is always last. */
2041
+ private appendGrounding;
1942
2042
  private hydrate;
1943
2043
  private hasOntologyPlaceholders;
1944
2044
  private buildSystemPrompt;
@@ -1950,6 +2050,7 @@ declare class PromptService {
1950
2050
  buildLibrarianPrompt(events: unknown[], currentFacts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null): {
1951
2051
  systemPrompt: string;
1952
2052
  userPrompt: string;
2053
+ groundingCorpus?: string[];
1953
2054
  };
1954
2055
  /**
1955
2056
  * Heal-prompt level interpretation for the `attemptLevel` ladder.
@@ -1979,6 +2080,7 @@ declare class PromptService {
1979
2080
  userPrompt: string;
1980
2081
  };
1981
2082
  degraded: DegradedRecord[];
2083
+ groundingCorpus?: string[];
1982
2084
  };
1983
2085
  buildOntologyBackfillPrompt(facts: unknown[], runtimeOverride?: string, ontologyContext?: OntologyPromptContext | null): {
1984
2086
  systemPrompt: string;
@@ -2085,6 +2187,8 @@ declare class IngestionService {
2085
2187
  buffer: DiagnosticBuffer;
2086
2188
  operation: 'ingest' | 'upsertGraph';
2087
2189
  };
2190
+ /** Insert-time trust by node id. Ingest-only (spec §6.5); the public upsertGraph never passes it, so host nodes are never grounded. */
2191
+ nodeTrust?: ReadonlyMap<string, GroundingTrust>;
2088
2192
  }): Promise<{
2089
2193
  nodesWritten: number;
2090
2194
  edgesWritten: number;
@@ -2275,6 +2379,7 @@ declare class MaintenanceService {
2275
2379
  runOntologyBackfill(entityId: string, options?: {
2276
2380
  promptOverride?: string;
2277
2381
  batchSize?: number;
2382
+ classifier?: 'auto' | 'llm';
2278
2383
  }): Promise<OntologyBackfillResult>;
2279
2384
  /**
2280
2385
  * Re-embed facts, honouring per-row failure markers and exponential backoff.
@@ -2349,7 +2454,15 @@ declare class MaintenanceService {
2349
2454
  doRunOntologyBackfill(entityId: string, options?: {
2350
2455
  promptOverride?: string;
2351
2456
  batchSize?: number;
2457
+ classifier?: 'auto' | 'llm';
2352
2458
  }): Promise<OntologyBackfillResult>;
2459
+ /**
2460
+ * Classifier-mode backfill (spec §7.3): one `choice` question per untyped
2461
+ * fact over the effective manifest's node-type slugs. Accepted answers go
2462
+ * through `_applyOntologyBackfillBatch` exactly like LLM classifications.
2463
+ * No edges are proposed.
2464
+ */
2465
+ private _runClassifierBackfill;
2353
2466
  /**
2354
2467
  * Applies one parsed backfill batch in its own transaction. Per-batch rather
2355
2468
  * than one transaction for the pass, so mergeEmergentUpdates semantics and
@@ -2657,6 +2770,7 @@ declare class WikiMemory {
2657
2770
  runOntologyBackfill(entityId: string, options?: {
2658
2771
  promptOverride?: string;
2659
2772
  batchSize?: number;
2773
+ classifier?: 'auto' | 'llm';
2660
2774
  }): Promise<OntologyBackfillResult>;
2661
2775
  runReembed(entityId?: string, opts?: {
2662
2776
  force?: boolean;
@@ -2877,4 +2991,4 @@ declare class WikiMemory {
2877
2991
  setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
2878
2992
  }
2879
2993
 
2880
- export { type WikiDiagnosticOperation as $, PrunePartialFailureError as A, type ReembedResult 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 VectorRankerFallback as J, type VectorRankerRankArgs as K, type LLMProvider as L, type MemoryBundle as M, type VectorRankerSemanticResult as N, ONTOLOGY_BACKFILL_BATCH_SIZE as O, type PromptOverrides as P, WikiBusyError as Q, type ReadOptions as R, type SQLiteAdapter as S, type WikiBusyOperation as T, type WikiCheckpoint as U, type VectorRanker as V, type WikiOptions as W, type WikiConfig as X, type WikiDiagnostic as Y, type WikiDiagnosticCode as Z, type WikiDiagnosticDetail as _, type MemoryDump as a, type WikiDiagnosticSeverity as a0, type WikiDiagnosticTrigger as a1, WikiDraftNotFound as a2, WikiDuplicateHashError as a3, type WikiEdge as a4, type WikiEvent as a5, type WikiFact as a6, WikiGraphNodeOwnershipConflict as a7, WikiIngestEmptyError as a8, WikiInvalidReadOptions as a9, type WikiMemoryTestAccess as aa, type WikiOutboxEvent as ab, WikiParseError as ac, WikiSourceRefHashCollision as ad, WikiStrictOntologyViolation as ae, type WikiTask as af, WikiTransactionError as ag, validateManifest as ah, EmbeddingService as ai, ImportExportService as aj, IngestionService as ak, JobManager as al, MaintenanceService as am, RetrievalService as an, SearchService as ao, WriteService as ap, type FormattedMemoryDump as b, WikiMemory as c, type DraftPage as d, type EmbedFailureKind as e, type EmbeddingMarkerKind as f, type EntityStatus as g, type ExtractedFact as h, type ExtractedFactEdge as i, type ExtractedFactWithOntology as j, type ExtractedTask as k, type GraphTraversalOptions as l, HEAL_RECHECK_MS as m, HOOK_TIMEOUT_MARKER as n, type HealResult as o, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as p, ONTOLOGY_BACKFILL_RECHECK_MS as q, type OntologyBackfillResult as r, type OntologyConfig as s, type OntologyEdgeType as t, type OntologyManifest as u, type OntologyMode as v, type OntologyNodeType as w, type OntologyPromptContext as x, type OntologyUpdates as y, PromptService as z };
2994
+ export { type WikiCheckpoint 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, PromptService as N, ONTOLOGY_BACKFILL_BATCH_SIZE as O, type PromptOverrides as P, PrunePartialFailureError as Q, type ReadOptions as R, type SQLiteAdapter as S, type ReembedResult as T, type VectorRankerFallback as U, type VectorRanker as V, type WikiOptions as W, type VectorRankerRankArgs as X, type VectorRankerSemanticResult as Y, WikiBusyError as Z, type WikiBusyOperation as _, type MemoryDump as a, type WikiConfig as a0, type WikiDiagnostic as a1, type WikiDiagnosticCode as a2, type WikiDiagnosticDetail as a3, type WikiDiagnosticOperation as a4, type WikiDiagnosticSeverity as a5, type WikiDiagnosticTrigger as a6, WikiDraftNotFound as a7, WikiDuplicateHashError as a8, type WikiEdge as a9, type WikiEvent as aa, type WikiFact as ab, WikiGraphNodeOwnershipConflict as ac, WikiIngestEmptyError as ad, WikiInvalidReadOptions as ae, type WikiMemoryTestAccess as af, type WikiOutboxEvent as ag, WikiParseError as ah, WikiSourceRefHashCollision as ai, WikiStrictOntologyViolation as aj, type WikiTask as ak, WikiTransactionError as al, validateManifest as am, EmbeddingService as an, ImportExportService as ao, IngestionService as ap, JobManager as aq, MaintenanceService as ar, RetrievalService as as, SearchService as at, WriteService as au, 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 };
@@ -1,3 +1,3 @@
1
- export { ai as EmbeddingService, aj as ImportExportService, ak as IngestionService, al as JobManager, al as JobManagerType, am as MaintenanceService, an as RetrievalService, ao as SearchService, ao as SearchServiceType, aa as WikiMemoryTestAccess, ap as WriteService } from './testing-Dmh1kfkd.mjs';
1
+ export { an as EmbeddingService, ao as ImportExportService, ap as IngestionService, aq as JobManager, aq as JobManagerType, ar as MaintenanceService, as as RetrievalService, at as SearchService, at as SearchServiceType, af as WikiMemoryTestAccess, au as WriteService } from './testing-d1SrpDvg.mjs';
2
2
  import '@equationalapplications/core-okf';
3
3
  import 'minisearch';
package/dist/testing.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { ai as EmbeddingService, aj as ImportExportService, ak as IngestionService, al as JobManager, al as JobManagerType, am as MaintenanceService, an as RetrievalService, ao as SearchService, ao as SearchServiceType, aa as WikiMemoryTestAccess, ap as WriteService } from './testing-Dmh1kfkd.js';
1
+ export { an as EmbeddingService, ao as ImportExportService, ap as IngestionService, aq as JobManager, aq as JobManagerType, ar as MaintenanceService, as as RetrievalService, at as SearchService, at as SearchServiceType, af as WikiMemoryTestAccess, au as WriteService } from './testing-d1SrpDvg.js';
2
2
  import '@equationalapplications/core-okf';
3
3
  import 'minisearch';