@equationalapplications/core-llm-wiki 7.3.0 → 7.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -0
- package/dist/{chunk-IAYO63DQ.mjs → chunk-3P7FAKJA.mjs} +167 -18
- package/dist/chunk-3P7FAKJA.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +252 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -4
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-ht1qOvcD.d.mts → testing-ClpOUiLI.d.mts} +139 -2
- package/dist/{testing-ht1qOvcD.d.ts → testing-ClpOUiLI.d.ts} +139 -2
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +156 -15
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-IAYO63DQ.mjs.map +0 -1
|
@@ -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;
|
|
@@ -269,6 +277,11 @@ interface WikiConfig {
|
|
|
269
277
|
traversalDirection?: 'inbound' | 'outbound' | 'both';
|
|
270
278
|
/** Default source_type dead-end list for discovered traversal nodes. Default []. */
|
|
271
279
|
excludeSourceTypes?: Array<WikiFact['source_type']>;
|
|
280
|
+
/**
|
|
281
|
+
* Engine default for `ReadOptions.excludeDrafts` and
|
|
282
|
+
* `GraphTraversalOptions.excludeDrafts`. Default false (drafts visible).
|
|
283
|
+
*/
|
|
284
|
+
excludeDrafts?: boolean;
|
|
272
285
|
}
|
|
273
286
|
interface ReadOptions {
|
|
274
287
|
maxResults?: number;
|
|
@@ -309,6 +322,12 @@ interface ReadOptions {
|
|
|
309
322
|
* by `tierWeights: 0`, or a floor keyed to an entity not in `entityId`.
|
|
310
323
|
*/
|
|
311
324
|
tierFloors?: Record<string, number>;
|
|
325
|
+
/**
|
|
326
|
+
* When true, facts whose `lifecycle_status` is `'draft'` are excluded before
|
|
327
|
+
* `maxResults`, `tierFloors` and every other cut, on every read path.
|
|
328
|
+
* Resolves call → `WikiConfig.excludeDrafts` → false.
|
|
329
|
+
*/
|
|
330
|
+
excludeDrafts?: boolean;
|
|
312
331
|
}
|
|
313
332
|
interface WikiFact {
|
|
314
333
|
id: string;
|
|
@@ -451,6 +470,12 @@ interface GraphTraversalOptions {
|
|
|
451
470
|
minTraversalConfidence?: 'certain' | 'inferred' | 'tentative';
|
|
452
471
|
/** source_type values to dead-end on for *discovered* nodes. Does not gate the anchor. Default []. */
|
|
453
472
|
excludeSourceTypes?: Array<WikiFact['source_type']>;
|
|
473
|
+
/**
|
|
474
|
+
* When true, draft facts are dead ends for *discovered* nodes (not
|
|
475
|
+
* discovered, not traversed through). Does not gate the anchor.
|
|
476
|
+
* Resolves call → `WikiConfig.excludeDrafts` → false.
|
|
477
|
+
*/
|
|
478
|
+
excludeDrafts?: boolean;
|
|
454
479
|
}
|
|
455
480
|
interface GraphNeighborhood {
|
|
456
481
|
/** Anchor node first, then discovered neighbors ordered by depth ASC, then updated_at DESC. */
|
|
@@ -481,6 +506,8 @@ interface LLMProvider {
|
|
|
481
506
|
/**
|
|
482
507
|
* Generates text using the developer's LLM of choice.
|
|
483
508
|
* Expected to return the raw text response (typically a JSON string).
|
|
509
|
+
* Called with the provider as `this`, so class-based adapters may keep
|
|
510
|
+
* SDK handles and config on the instance.
|
|
484
511
|
*/
|
|
485
512
|
generateText: (params: {
|
|
486
513
|
systemPrompt: string;
|
|
@@ -491,6 +518,8 @@ interface LLMProvider {
|
|
|
491
518
|
* Must return a stable-dimension float array for any input text.
|
|
492
519
|
* Called once per fact on creation/update, and once per `read()` query.
|
|
493
520
|
* When absent or throws, `read()` falls back to MiniSearch.
|
|
521
|
+
* Called with the provider as `this` (never detached), same as
|
|
522
|
+
* `generateText`, so class-based adapters may read their own state.
|
|
494
523
|
*/
|
|
495
524
|
embed?: (text: string) => Promise<number[]>;
|
|
496
525
|
/**
|
|
@@ -504,6 +533,49 @@ interface LLMProvider {
|
|
|
504
533
|
* never trusted as a guarantee.
|
|
505
534
|
*/
|
|
506
535
|
maxOutputTokens?: number;
|
|
536
|
+
/**
|
|
537
|
+
* Optional non-generative classifier (System-One models such as Jev,
|
|
538
|
+
* OpenJev, or a local ONNX classifier). Core never calls it unless the host
|
|
539
|
+
* opts in (e.g. `WikiConfig.ontology.backfillClassifier: 'auto'`); merely
|
|
540
|
+
* providing it changes nothing (REQ-COMPAT-01.5). Output is validated as
|
|
541
|
+
* untrusted.
|
|
542
|
+
*/
|
|
543
|
+
classify?: (request: ClassifyRequest) => Promise<ClassifyResponse>;
|
|
544
|
+
}
|
|
545
|
+
/** One typed question for a classifier. Vendor-neutral (Jev `noul` ↔ `binary`). */
|
|
546
|
+
type ClassifierQuestion = {
|
|
547
|
+
kind: 'choice';
|
|
548
|
+
options: string[];
|
|
549
|
+
instructions?: string;
|
|
550
|
+
} | {
|
|
551
|
+
kind: 'binary';
|
|
552
|
+
instructions: string;
|
|
553
|
+
} | {
|
|
554
|
+
kind: 'score';
|
|
555
|
+
levels: string[];
|
|
556
|
+
instructions?: string;
|
|
557
|
+
};
|
|
558
|
+
/** One state evaluated against a map of questions (many questions per state, one state per call). */
|
|
559
|
+
interface ClassifyRequest {
|
|
560
|
+
state: string;
|
|
561
|
+
questions: Record<string, ClassifierQuestion>;
|
|
562
|
+
}
|
|
563
|
+
type ClassifierAnswer = {
|
|
564
|
+
kind: 'choice';
|
|
565
|
+
choice: string;
|
|
566
|
+
confidence: number;
|
|
567
|
+
probabilities: Record<string, number>;
|
|
568
|
+
} | {
|
|
569
|
+
kind: 'binary';
|
|
570
|
+
probability: number;
|
|
571
|
+
} | {
|
|
572
|
+
kind: 'score';
|
|
573
|
+
score: number;
|
|
574
|
+
confidence: number;
|
|
575
|
+
probabilities: number[];
|
|
576
|
+
};
|
|
577
|
+
interface ClassifyResponse {
|
|
578
|
+
answers: Record<string, ClassifierAnswer>;
|
|
507
579
|
}
|
|
508
580
|
/**
|
|
509
581
|
* Result of semantic ranking for a single fact.
|
|
@@ -942,6 +1014,22 @@ declare class WikiInvalidReadOptions extends Error {
|
|
|
942
1014
|
readonly reason: string;
|
|
943
1015
|
constructor(field: string, reason: string);
|
|
944
1016
|
}
|
|
1017
|
+
/**
|
|
1018
|
+
* Thrown by `promoteDraft` when no live draft with that id exists for the
|
|
1019
|
+
* entity: missing, soft-deleted, owned by another entity, or not a draft.
|
|
1020
|
+
* Contextless for the same reason as {@link WikiGraphNodeOwnershipConflict}.
|
|
1021
|
+
* The `WIKI_` code keeps it clear of `extractSqliteCode`, so it passes through
|
|
1022
|
+
* the serialized transaction wrapper unwrapped.
|
|
1023
|
+
*/
|
|
1024
|
+
declare class WikiDraftNotFound extends Error {
|
|
1025
|
+
readonly code: "WIKI_DRAFT_NOT_FOUND";
|
|
1026
|
+
constructor();
|
|
1027
|
+
}
|
|
1028
|
+
/** One page of `listDrafts`. `nextCursor` is opaque; pass it back unchanged. */
|
|
1029
|
+
interface DraftPage {
|
|
1030
|
+
facts: WikiFact[];
|
|
1031
|
+
nextCursor: string | null;
|
|
1032
|
+
}
|
|
945
1033
|
|
|
946
1034
|
interface WikiOutboxEvent<T = unknown> {
|
|
947
1035
|
id: string;
|
|
@@ -1317,7 +1405,18 @@ declare class EntryRepository extends BaseRepository {
|
|
|
1317
1405
|
}>>;
|
|
1318
1406
|
trackAccess(ids: readonly string[], now: number, tx?: SQLiteAdapter): Promise<void>;
|
|
1319
1407
|
getLegacyMigrationSQL(): string;
|
|
1320
|
-
findRecentByEntityIds(entityIds: readonly string[], limit: number, tx?: SQLiteAdapter
|
|
1408
|
+
findRecentByEntityIds(entityIds: readonly string[], limit: number, tx?: SQLiteAdapter, opts?: {
|
|
1409
|
+
excludeDrafts?: boolean;
|
|
1410
|
+
}): Promise<WikiFact[]>;
|
|
1411
|
+
/** IDs of live draft facts for the given entities (spec §5.1). Callers pass ≤ 100 entity ids. */
|
|
1412
|
+
findDraftIdsByEntityIds(entityIds: readonly string[], tx?: SQLiteAdapter): Promise<Set<string>>;
|
|
1413
|
+
/** Live drafts for one entity, newest first, keyset-paged by (created_at, id). */
|
|
1414
|
+
listDraftsByEntityId(entityId: string, limit: number, after: {
|
|
1415
|
+
createdAt: number;
|
|
1416
|
+
id: string;
|
|
1417
|
+
} | null, tx?: SQLiteAdapter): Promise<WikiFact[]>;
|
|
1418
|
+
/** True iff `entryId` is a live draft owned by `entityId`. */
|
|
1419
|
+
isLiveDraft(entryId: string, entityId: string, tx?: SQLiteAdapter): Promise<boolean>;
|
|
1321
1420
|
/**
|
|
1322
1421
|
* Live untyped facts eligible for ontology backfill, oldest first.
|
|
1323
1422
|
* Skips facts checked within the recheck cooldown (ontology_checked_at > recheckCutoff).
|
|
@@ -1725,6 +1824,14 @@ interface NeighborhoodQueryOptions {
|
|
|
1725
1824
|
minConfidence: 'certain' | 'inferred' | 'tentative';
|
|
1726
1825
|
excludeSourceTypes: string[];
|
|
1727
1826
|
maxNodes: number;
|
|
1827
|
+
/**
|
|
1828
|
+
* When true, draft facts are dead-ends for *discovered* nodes — the recursive
|
|
1829
|
+
* walk will not step onto a draft, and will not step *past* one either, since
|
|
1830
|
+
* a draft's neighbours are unreachable through it. The anchor node is exempt
|
|
1831
|
+
* (it is validated up-front and never gated by this flag), so callers can
|
|
1832
|
+
* intentionally start from a draft. Default false (drafts visible).
|
|
1833
|
+
*/
|
|
1834
|
+
excludeDrafts?: boolean;
|
|
1728
1835
|
}
|
|
1729
1836
|
declare class EdgeRepository extends BaseRepository {
|
|
1730
1837
|
/**
|
|
@@ -2223,6 +2330,7 @@ declare class MaintenanceService {
|
|
|
2223
2330
|
runOntologyBackfill(entityId: string, options?: {
|
|
2224
2331
|
promptOverride?: string;
|
|
2225
2332
|
batchSize?: number;
|
|
2333
|
+
classifier?: 'auto' | 'llm';
|
|
2226
2334
|
}): Promise<OntologyBackfillResult>;
|
|
2227
2335
|
/**
|
|
2228
2336
|
* Re-embed facts, honouring per-row failure markers and exponential backoff.
|
|
@@ -2297,7 +2405,15 @@ declare class MaintenanceService {
|
|
|
2297
2405
|
doRunOntologyBackfill(entityId: string, options?: {
|
|
2298
2406
|
promptOverride?: string;
|
|
2299
2407
|
batchSize?: number;
|
|
2408
|
+
classifier?: 'auto' | 'llm';
|
|
2300
2409
|
}): Promise<OntologyBackfillResult>;
|
|
2410
|
+
/**
|
|
2411
|
+
* Classifier-mode backfill (spec §7.3): one `choice` question per untyped
|
|
2412
|
+
* fact over the effective manifest's node-type slugs. Accepted answers go
|
|
2413
|
+
* through `_applyOntologyBackfillBatch` exactly like LLM classifications.
|
|
2414
|
+
* No edges are proposed.
|
|
2415
|
+
*/
|
|
2416
|
+
private _runClassifierBackfill;
|
|
2301
2417
|
/**
|
|
2302
2418
|
* Applies one parsed backfill batch in its own transaction. Per-batch rather
|
|
2303
2419
|
* than one transaction for the pass, so mergeEmergentUpdates semantics and
|
|
@@ -2374,6 +2490,7 @@ declare class RetrievalService {
|
|
|
2374
2490
|
* Stable tie-break sort: score desc → access_count desc → updated_at desc → id asc.
|
|
2375
2491
|
*/
|
|
2376
2492
|
private _tieBreakSort;
|
|
2493
|
+
private _withoutDrafts;
|
|
2377
2494
|
/**
|
|
2378
2495
|
* Comparator for score + deterministic tie-break fields.
|
|
2379
2496
|
* Negative return means "a ranks ahead of b" for descending score order.
|
|
@@ -2604,6 +2721,7 @@ declare class WikiMemory {
|
|
|
2604
2721
|
runOntologyBackfill(entityId: string, options?: {
|
|
2605
2722
|
promptOverride?: string;
|
|
2606
2723
|
batchSize?: number;
|
|
2724
|
+
classifier?: 'auto' | 'llm';
|
|
2607
2725
|
}): Promise<OntologyBackfillResult>;
|
|
2608
2726
|
runReembed(entityId?: string, opts?: {
|
|
2609
2727
|
force?: boolean;
|
|
@@ -2787,6 +2905,25 @@ declare class WikiMemory {
|
|
|
2787
2905
|
}>): Promise<void>;
|
|
2788
2906
|
/** Set a fact's OKF v0.2 lifecycle status. Does NOT touch `updated_at`. */
|
|
2789
2907
|
setLifecycleStatus(entryId: string, entityId: string, status: 'draft' | 'stable' | 'deprecated'): Promise<void>;
|
|
2908
|
+
/**
|
|
2909
|
+
* Live draft facts for one entity, newest first (spec §5.2). Default page
|
|
2910
|
+
* size 50, clamped to [1, 500]. Pass `nextCursor` back unchanged for the next page.
|
|
2911
|
+
*/
|
|
2912
|
+
listDrafts(entityId: string, options?: {
|
|
2913
|
+
limit?: number;
|
|
2914
|
+
cursor?: string;
|
|
2915
|
+
}): Promise<DraftPage>;
|
|
2916
|
+
/**
|
|
2917
|
+
* Promote a draft to `stable` and record who reviewed it, atomically
|
|
2918
|
+
* (spec §5.2). Metadata writes only: `updated_at` is not bumped and no
|
|
2919
|
+
* outbox event is pushed. Pass `by: 'human:<id>'` so `trustTier` becomes
|
|
2920
|
+
* `'human-reviewed'`.
|
|
2921
|
+
*
|
|
2922
|
+
* @throws WikiDraftNotFound when no live draft with that id exists for the entity.
|
|
2923
|
+
*/
|
|
2924
|
+
promoteDraft(entryId: string, entityId: string, reviewer: {
|
|
2925
|
+
by: string;
|
|
2926
|
+
}): Promise<void>;
|
|
2790
2927
|
/** Set a fact's stale_after (epoch ms) or clear it. Does NOT touch `updated_at`. */
|
|
2791
2928
|
setStaleAfter(entryId: string, entityId: string, date: number | null): Promise<void>;
|
|
2792
2929
|
/** Set a fact's generated_by actor string. Does NOT touch `updated_at`. */
|
|
@@ -2805,4 +2942,4 @@ declare class WikiMemory {
|
|
|
2805
2942
|
setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
|
|
2806
2943
|
}
|
|
2807
2944
|
|
|
2808
|
-
export { type
|
|
2945
|
+
export { type WikiConfig as $, type OntologyNodeType as A, type OntologyPromptContext 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 OntologyUpdates as J, PromptService as K, type LLMProvider as L, type MemoryBundle as M, PrunePartialFailureError as N, ONTOLOGY_BACKFILL_BATCH_SIZE as O, type PromptOverrides as P, type ReembedResult as Q, type ReadOptions as R, type SQLiteAdapter as S, type VectorRankerFallback as T, type VectorRankerRankArgs as U, type VectorRanker as V, type WikiOptions as W, type VectorRankerSemanticResult as X, WikiBusyError as Y, type WikiBusyOperation as Z, type WikiCheckpoint as _, type MemoryDump as a, type WikiDiagnostic as a0, type WikiDiagnosticCode as a1, type WikiDiagnosticDetail as a2, type WikiDiagnosticOperation as a3, type WikiDiagnosticSeverity as a4, type WikiDiagnosticTrigger as a5, WikiDraftNotFound as a6, WikiDuplicateHashError as a7, type WikiEdge as a8, type WikiEvent as a9, type WikiFact as aa, WikiGraphNodeOwnershipConflict as ab, WikiIngestEmptyError as ac, WikiInvalidReadOptions as ad, type WikiMemoryTestAccess as ae, type WikiOutboxEvent as af, WikiParseError as ag, WikiSourceRefHashCollision as ah, WikiStrictOntologyViolation as ai, type WikiTask as aj, WikiTransactionError as ak, validateManifest as al, EmbeddingService as am, ImportExportService as an, IngestionService as ao, JobManager as ap, MaintenanceService as aq, RetrievalService as ar, SearchService as as, WriteService as at, 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, HEAL_RECHECK_MS as q, HOOK_TIMEOUT_MARKER as r, type HealResult as s, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as t, ONTOLOGY_BACKFILL_RECHECK_MS as u, type OntologyBackfillResult as v, type OntologyConfig as w, type OntologyEdgeType as x, type OntologyManifest as y, type OntologyMode 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;
|
|
@@ -269,6 +277,11 @@ interface WikiConfig {
|
|
|
269
277
|
traversalDirection?: 'inbound' | 'outbound' | 'both';
|
|
270
278
|
/** Default source_type dead-end list for discovered traversal nodes. Default []. */
|
|
271
279
|
excludeSourceTypes?: Array<WikiFact['source_type']>;
|
|
280
|
+
/**
|
|
281
|
+
* Engine default for `ReadOptions.excludeDrafts` and
|
|
282
|
+
* `GraphTraversalOptions.excludeDrafts`. Default false (drafts visible).
|
|
283
|
+
*/
|
|
284
|
+
excludeDrafts?: boolean;
|
|
272
285
|
}
|
|
273
286
|
interface ReadOptions {
|
|
274
287
|
maxResults?: number;
|
|
@@ -309,6 +322,12 @@ interface ReadOptions {
|
|
|
309
322
|
* by `tierWeights: 0`, or a floor keyed to an entity not in `entityId`.
|
|
310
323
|
*/
|
|
311
324
|
tierFloors?: Record<string, number>;
|
|
325
|
+
/**
|
|
326
|
+
* When true, facts whose `lifecycle_status` is `'draft'` are excluded before
|
|
327
|
+
* `maxResults`, `tierFloors` and every other cut, on every read path.
|
|
328
|
+
* Resolves call → `WikiConfig.excludeDrafts` → false.
|
|
329
|
+
*/
|
|
330
|
+
excludeDrafts?: boolean;
|
|
312
331
|
}
|
|
313
332
|
interface WikiFact {
|
|
314
333
|
id: string;
|
|
@@ -451,6 +470,12 @@ interface GraphTraversalOptions {
|
|
|
451
470
|
minTraversalConfidence?: 'certain' | 'inferred' | 'tentative';
|
|
452
471
|
/** source_type values to dead-end on for *discovered* nodes. Does not gate the anchor. Default []. */
|
|
453
472
|
excludeSourceTypes?: Array<WikiFact['source_type']>;
|
|
473
|
+
/**
|
|
474
|
+
* When true, draft facts are dead ends for *discovered* nodes (not
|
|
475
|
+
* discovered, not traversed through). Does not gate the anchor.
|
|
476
|
+
* Resolves call → `WikiConfig.excludeDrafts` → false.
|
|
477
|
+
*/
|
|
478
|
+
excludeDrafts?: boolean;
|
|
454
479
|
}
|
|
455
480
|
interface GraphNeighborhood {
|
|
456
481
|
/** Anchor node first, then discovered neighbors ordered by depth ASC, then updated_at DESC. */
|
|
@@ -481,6 +506,8 @@ interface LLMProvider {
|
|
|
481
506
|
/**
|
|
482
507
|
* Generates text using the developer's LLM of choice.
|
|
483
508
|
* Expected to return the raw text response (typically a JSON string).
|
|
509
|
+
* Called with the provider as `this`, so class-based adapters may keep
|
|
510
|
+
* SDK handles and config on the instance.
|
|
484
511
|
*/
|
|
485
512
|
generateText: (params: {
|
|
486
513
|
systemPrompt: string;
|
|
@@ -491,6 +518,8 @@ interface LLMProvider {
|
|
|
491
518
|
* Must return a stable-dimension float array for any input text.
|
|
492
519
|
* Called once per fact on creation/update, and once per `read()` query.
|
|
493
520
|
* When absent or throws, `read()` falls back to MiniSearch.
|
|
521
|
+
* Called with the provider as `this` (never detached), same as
|
|
522
|
+
* `generateText`, so class-based adapters may read their own state.
|
|
494
523
|
*/
|
|
495
524
|
embed?: (text: string) => Promise<number[]>;
|
|
496
525
|
/**
|
|
@@ -504,6 +533,49 @@ interface LLMProvider {
|
|
|
504
533
|
* never trusted as a guarantee.
|
|
505
534
|
*/
|
|
506
535
|
maxOutputTokens?: number;
|
|
536
|
+
/**
|
|
537
|
+
* Optional non-generative classifier (System-One models such as Jev,
|
|
538
|
+
* OpenJev, or a local ONNX classifier). Core never calls it unless the host
|
|
539
|
+
* opts in (e.g. `WikiConfig.ontology.backfillClassifier: 'auto'`); merely
|
|
540
|
+
* providing it changes nothing (REQ-COMPAT-01.5). Output is validated as
|
|
541
|
+
* untrusted.
|
|
542
|
+
*/
|
|
543
|
+
classify?: (request: ClassifyRequest) => Promise<ClassifyResponse>;
|
|
544
|
+
}
|
|
545
|
+
/** One typed question for a classifier. Vendor-neutral (Jev `noul` ↔ `binary`). */
|
|
546
|
+
type ClassifierQuestion = {
|
|
547
|
+
kind: 'choice';
|
|
548
|
+
options: string[];
|
|
549
|
+
instructions?: string;
|
|
550
|
+
} | {
|
|
551
|
+
kind: 'binary';
|
|
552
|
+
instructions: string;
|
|
553
|
+
} | {
|
|
554
|
+
kind: 'score';
|
|
555
|
+
levels: string[];
|
|
556
|
+
instructions?: string;
|
|
557
|
+
};
|
|
558
|
+
/** One state evaluated against a map of questions (many questions per state, one state per call). */
|
|
559
|
+
interface ClassifyRequest {
|
|
560
|
+
state: string;
|
|
561
|
+
questions: Record<string, ClassifierQuestion>;
|
|
562
|
+
}
|
|
563
|
+
type ClassifierAnswer = {
|
|
564
|
+
kind: 'choice';
|
|
565
|
+
choice: string;
|
|
566
|
+
confidence: number;
|
|
567
|
+
probabilities: Record<string, number>;
|
|
568
|
+
} | {
|
|
569
|
+
kind: 'binary';
|
|
570
|
+
probability: number;
|
|
571
|
+
} | {
|
|
572
|
+
kind: 'score';
|
|
573
|
+
score: number;
|
|
574
|
+
confidence: number;
|
|
575
|
+
probabilities: number[];
|
|
576
|
+
};
|
|
577
|
+
interface ClassifyResponse {
|
|
578
|
+
answers: Record<string, ClassifierAnswer>;
|
|
507
579
|
}
|
|
508
580
|
/**
|
|
509
581
|
* Result of semantic ranking for a single fact.
|
|
@@ -942,6 +1014,22 @@ declare class WikiInvalidReadOptions extends Error {
|
|
|
942
1014
|
readonly reason: string;
|
|
943
1015
|
constructor(field: string, reason: string);
|
|
944
1016
|
}
|
|
1017
|
+
/**
|
|
1018
|
+
* Thrown by `promoteDraft` when no live draft with that id exists for the
|
|
1019
|
+
* entity: missing, soft-deleted, owned by another entity, or not a draft.
|
|
1020
|
+
* Contextless for the same reason as {@link WikiGraphNodeOwnershipConflict}.
|
|
1021
|
+
* The `WIKI_` code keeps it clear of `extractSqliteCode`, so it passes through
|
|
1022
|
+
* the serialized transaction wrapper unwrapped.
|
|
1023
|
+
*/
|
|
1024
|
+
declare class WikiDraftNotFound extends Error {
|
|
1025
|
+
readonly code: "WIKI_DRAFT_NOT_FOUND";
|
|
1026
|
+
constructor();
|
|
1027
|
+
}
|
|
1028
|
+
/** One page of `listDrafts`. `nextCursor` is opaque; pass it back unchanged. */
|
|
1029
|
+
interface DraftPage {
|
|
1030
|
+
facts: WikiFact[];
|
|
1031
|
+
nextCursor: string | null;
|
|
1032
|
+
}
|
|
945
1033
|
|
|
946
1034
|
interface WikiOutboxEvent<T = unknown> {
|
|
947
1035
|
id: string;
|
|
@@ -1317,7 +1405,18 @@ declare class EntryRepository extends BaseRepository {
|
|
|
1317
1405
|
}>>;
|
|
1318
1406
|
trackAccess(ids: readonly string[], now: number, tx?: SQLiteAdapter): Promise<void>;
|
|
1319
1407
|
getLegacyMigrationSQL(): string;
|
|
1320
|
-
findRecentByEntityIds(entityIds: readonly string[], limit: number, tx?: SQLiteAdapter
|
|
1408
|
+
findRecentByEntityIds(entityIds: readonly string[], limit: number, tx?: SQLiteAdapter, opts?: {
|
|
1409
|
+
excludeDrafts?: boolean;
|
|
1410
|
+
}): Promise<WikiFact[]>;
|
|
1411
|
+
/** IDs of live draft facts for the given entities (spec §5.1). Callers pass ≤ 100 entity ids. */
|
|
1412
|
+
findDraftIdsByEntityIds(entityIds: readonly string[], tx?: SQLiteAdapter): Promise<Set<string>>;
|
|
1413
|
+
/** Live drafts for one entity, newest first, keyset-paged by (created_at, id). */
|
|
1414
|
+
listDraftsByEntityId(entityId: string, limit: number, after: {
|
|
1415
|
+
createdAt: number;
|
|
1416
|
+
id: string;
|
|
1417
|
+
} | null, tx?: SQLiteAdapter): Promise<WikiFact[]>;
|
|
1418
|
+
/** True iff `entryId` is a live draft owned by `entityId`. */
|
|
1419
|
+
isLiveDraft(entryId: string, entityId: string, tx?: SQLiteAdapter): Promise<boolean>;
|
|
1321
1420
|
/**
|
|
1322
1421
|
* Live untyped facts eligible for ontology backfill, oldest first.
|
|
1323
1422
|
* Skips facts checked within the recheck cooldown (ontology_checked_at > recheckCutoff).
|
|
@@ -1725,6 +1824,14 @@ interface NeighborhoodQueryOptions {
|
|
|
1725
1824
|
minConfidence: 'certain' | 'inferred' | 'tentative';
|
|
1726
1825
|
excludeSourceTypes: string[];
|
|
1727
1826
|
maxNodes: number;
|
|
1827
|
+
/**
|
|
1828
|
+
* When true, draft facts are dead-ends for *discovered* nodes — the recursive
|
|
1829
|
+
* walk will not step onto a draft, and will not step *past* one either, since
|
|
1830
|
+
* a draft's neighbours are unreachable through it. The anchor node is exempt
|
|
1831
|
+
* (it is validated up-front and never gated by this flag), so callers can
|
|
1832
|
+
* intentionally start from a draft. Default false (drafts visible).
|
|
1833
|
+
*/
|
|
1834
|
+
excludeDrafts?: boolean;
|
|
1728
1835
|
}
|
|
1729
1836
|
declare class EdgeRepository extends BaseRepository {
|
|
1730
1837
|
/**
|
|
@@ -2223,6 +2330,7 @@ declare class MaintenanceService {
|
|
|
2223
2330
|
runOntologyBackfill(entityId: string, options?: {
|
|
2224
2331
|
promptOverride?: string;
|
|
2225
2332
|
batchSize?: number;
|
|
2333
|
+
classifier?: 'auto' | 'llm';
|
|
2226
2334
|
}): Promise<OntologyBackfillResult>;
|
|
2227
2335
|
/**
|
|
2228
2336
|
* Re-embed facts, honouring per-row failure markers and exponential backoff.
|
|
@@ -2297,7 +2405,15 @@ declare class MaintenanceService {
|
|
|
2297
2405
|
doRunOntologyBackfill(entityId: string, options?: {
|
|
2298
2406
|
promptOverride?: string;
|
|
2299
2407
|
batchSize?: number;
|
|
2408
|
+
classifier?: 'auto' | 'llm';
|
|
2300
2409
|
}): Promise<OntologyBackfillResult>;
|
|
2410
|
+
/**
|
|
2411
|
+
* Classifier-mode backfill (spec §7.3): one `choice` question per untyped
|
|
2412
|
+
* fact over the effective manifest's node-type slugs. Accepted answers go
|
|
2413
|
+
* through `_applyOntologyBackfillBatch` exactly like LLM classifications.
|
|
2414
|
+
* No edges are proposed.
|
|
2415
|
+
*/
|
|
2416
|
+
private _runClassifierBackfill;
|
|
2301
2417
|
/**
|
|
2302
2418
|
* Applies one parsed backfill batch in its own transaction. Per-batch rather
|
|
2303
2419
|
* than one transaction for the pass, so mergeEmergentUpdates semantics and
|
|
@@ -2374,6 +2490,7 @@ declare class RetrievalService {
|
|
|
2374
2490
|
* Stable tie-break sort: score desc → access_count desc → updated_at desc → id asc.
|
|
2375
2491
|
*/
|
|
2376
2492
|
private _tieBreakSort;
|
|
2493
|
+
private _withoutDrafts;
|
|
2377
2494
|
/**
|
|
2378
2495
|
* Comparator for score + deterministic tie-break fields.
|
|
2379
2496
|
* Negative return means "a ranks ahead of b" for descending score order.
|
|
@@ -2604,6 +2721,7 @@ declare class WikiMemory {
|
|
|
2604
2721
|
runOntologyBackfill(entityId: string, options?: {
|
|
2605
2722
|
promptOverride?: string;
|
|
2606
2723
|
batchSize?: number;
|
|
2724
|
+
classifier?: 'auto' | 'llm';
|
|
2607
2725
|
}): Promise<OntologyBackfillResult>;
|
|
2608
2726
|
runReembed(entityId?: string, opts?: {
|
|
2609
2727
|
force?: boolean;
|
|
@@ -2787,6 +2905,25 @@ declare class WikiMemory {
|
|
|
2787
2905
|
}>): Promise<void>;
|
|
2788
2906
|
/** Set a fact's OKF v0.2 lifecycle status. Does NOT touch `updated_at`. */
|
|
2789
2907
|
setLifecycleStatus(entryId: string, entityId: string, status: 'draft' | 'stable' | 'deprecated'): Promise<void>;
|
|
2908
|
+
/**
|
|
2909
|
+
* Live draft facts for one entity, newest first (spec §5.2). Default page
|
|
2910
|
+
* size 50, clamped to [1, 500]. Pass `nextCursor` back unchanged for the next page.
|
|
2911
|
+
*/
|
|
2912
|
+
listDrafts(entityId: string, options?: {
|
|
2913
|
+
limit?: number;
|
|
2914
|
+
cursor?: string;
|
|
2915
|
+
}): Promise<DraftPage>;
|
|
2916
|
+
/**
|
|
2917
|
+
* Promote a draft to `stable` and record who reviewed it, atomically
|
|
2918
|
+
* (spec §5.2). Metadata writes only: `updated_at` is not bumped and no
|
|
2919
|
+
* outbox event is pushed. Pass `by: 'human:<id>'` so `trustTier` becomes
|
|
2920
|
+
* `'human-reviewed'`.
|
|
2921
|
+
*
|
|
2922
|
+
* @throws WikiDraftNotFound when no live draft with that id exists for the entity.
|
|
2923
|
+
*/
|
|
2924
|
+
promoteDraft(entryId: string, entityId: string, reviewer: {
|
|
2925
|
+
by: string;
|
|
2926
|
+
}): Promise<void>;
|
|
2790
2927
|
/** Set a fact's stale_after (epoch ms) or clear it. Does NOT touch `updated_at`. */
|
|
2791
2928
|
setStaleAfter(entryId: string, entityId: string, date: number | null): Promise<void>;
|
|
2792
2929
|
/** Set a fact's generated_by actor string. Does NOT touch `updated_at`. */
|
|
@@ -2805,4 +2942,4 @@ declare class WikiMemory {
|
|
|
2805
2942
|
setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
|
|
2806
2943
|
}
|
|
2807
2944
|
|
|
2808
|
-
export { type
|
|
2945
|
+
export { type WikiConfig as $, type OntologyNodeType as A, type OntologyPromptContext 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 OntologyUpdates as J, PromptService as K, type LLMProvider as L, type MemoryBundle as M, PrunePartialFailureError as N, ONTOLOGY_BACKFILL_BATCH_SIZE as O, type PromptOverrides as P, type ReembedResult as Q, type ReadOptions as R, type SQLiteAdapter as S, type VectorRankerFallback as T, type VectorRankerRankArgs as U, type VectorRanker as V, type WikiOptions as W, type VectorRankerSemanticResult as X, WikiBusyError as Y, type WikiBusyOperation as Z, type WikiCheckpoint as _, type MemoryDump as a, type WikiDiagnostic as a0, type WikiDiagnosticCode as a1, type WikiDiagnosticDetail as a2, type WikiDiagnosticOperation as a3, type WikiDiagnosticSeverity as a4, type WikiDiagnosticTrigger as a5, WikiDraftNotFound as a6, WikiDuplicateHashError as a7, type WikiEdge as a8, type WikiEvent as a9, type WikiFact as aa, WikiGraphNodeOwnershipConflict as ab, WikiIngestEmptyError as ac, WikiInvalidReadOptions as ad, type WikiMemoryTestAccess as ae, type WikiOutboxEvent as af, WikiParseError as ag, WikiSourceRefHashCollision as ah, WikiStrictOntologyViolation as ai, type WikiTask as aj, WikiTransactionError as ak, validateManifest as al, EmbeddingService as am, ImportExportService as an, IngestionService as ao, JobManager as ap, MaintenanceService as aq, RetrievalService as ar, SearchService as as, WriteService as at, 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, HEAL_RECHECK_MS as q, HOOK_TIMEOUT_MARKER as r, type HealResult as s, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as t, ONTOLOGY_BACKFILL_RECHECK_MS as u, type OntologyBackfillResult as v, type OntologyConfig as w, type OntologyEdgeType as x, type OntologyManifest as y, type OntologyMode as z };
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { am as EmbeddingService, an as ImportExportService, ao as IngestionService, ap as JobManager, ap as JobManagerType, aq as MaintenanceService, ar as RetrievalService, as as SearchService, as as SearchServiceType, ae as WikiMemoryTestAccess, at as WriteService } from './testing-ClpOUiLI.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 { am as EmbeddingService, an as ImportExportService, ao as IngestionService, ap as JobManager, ap as JobManagerType, aq as MaintenanceService, ar as RetrievalService, as as SearchService, as as SearchServiceType, ae as WikiMemoryTestAccess, at as WriteService } from './testing-ClpOUiLI.js';
|
|
2
2
|
import '@equationalapplications/core-okf';
|
|
3
3
|
import 'minisearch';
|