@equationalapplications/core-llm-wiki 7.6.0 → 7.7.1
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 +64 -0
- package/dist/{chunk-YBWE26XR.mjs → chunk-NWODQRSM.mjs} +52 -18
- package/dist/chunk-NWODQRSM.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +250 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +203 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-d1SrpDvg.d.mts → testing-A4Sofxyo.d.mts} +85 -2
- package/dist/{testing-d1SrpDvg.d.ts → testing-A4Sofxyo.d.ts} +85 -2
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +45 -15
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-YBWE26XR.mjs.map +0 -1
|
@@ -277,7 +277,11 @@ interface WikiConfig {
|
|
|
277
277
|
* Default: undefined (pure semantic when embed provided).
|
|
278
278
|
*/
|
|
279
279
|
hybridWeight?: number;
|
|
280
|
-
/**
|
|
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
|
+
*/
|
|
281
285
|
prompts?: PromptOverrides;
|
|
282
286
|
/**
|
|
283
287
|
* When true, entry and task mutations append an event to the internal outbox table.
|
|
@@ -1051,6 +1055,43 @@ interface DraftPage {
|
|
|
1051
1055
|
facts: WikiFact[];
|
|
1052
1056
|
nextCursor: string | null;
|
|
1053
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
|
+
}
|
|
1054
1095
|
|
|
1055
1096
|
interface WikiOutboxEvent<T = unknown> {
|
|
1056
1097
|
id: string;
|
|
@@ -1384,6 +1425,15 @@ declare class EntryRepository extends BaseRepository {
|
|
|
1384
1425
|
* Empty input is a synchronous early return with zero SQL calls.
|
|
1385
1426
|
*/
|
|
1386
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
|
+
}>>;
|
|
1387
1437
|
/**
|
|
1388
1438
|
* Return the live source_refs for an entity that hold the given source_hash.
|
|
1389
1439
|
* Used by the ingestDocument duplicate-hash guard and by hosts auditing
|
|
@@ -2086,6 +2136,13 @@ declare class PromptService {
|
|
|
2086
2136
|
systemPrompt: string;
|
|
2087
2137
|
userPrompt: string;
|
|
2088
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;
|
|
2089
2146
|
}
|
|
2090
2147
|
|
|
2091
2148
|
declare class IngestionService {
|
|
@@ -2630,6 +2687,8 @@ declare class WikiMemory {
|
|
|
2630
2687
|
private promptService;
|
|
2631
2688
|
private ontologyService;
|
|
2632
2689
|
private graphTraversalService;
|
|
2690
|
+
private lintRepo;
|
|
2691
|
+
private lintService;
|
|
2633
2692
|
private readonly okfTrustWrites;
|
|
2634
2693
|
constructor(db: SQLiteAdapter, options: WikiOptions);
|
|
2635
2694
|
/**
|
|
@@ -2657,6 +2716,30 @@ declare class WikiMemory {
|
|
|
2657
2716
|
changed: boolean;
|
|
2658
2717
|
duplicateOf?: string;
|
|
2659
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>;
|
|
2660
2743
|
/**
|
|
2661
2744
|
* Returns the live source_refs for an entity, one row per ref, with the most
|
|
2662
2745
|
* recently-updated live `source_hash` and a live fact count. Refs are sorted
|
|
@@ -2991,4 +3074,4 @@ declare class WikiMemory {
|
|
|
2991
3074
|
setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
|
|
2992
3075
|
}
|
|
2993
3076
|
|
|
2994
|
-
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 };
|
|
@@ -277,7 +277,11 @@ interface WikiConfig {
|
|
|
277
277
|
* Default: undefined (pure semantic when embed provided).
|
|
278
278
|
*/
|
|
279
279
|
hybridWeight?: number;
|
|
280
|
-
/**
|
|
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
|
+
*/
|
|
281
285
|
prompts?: PromptOverrides;
|
|
282
286
|
/**
|
|
283
287
|
* When true, entry and task mutations append an event to the internal outbox table.
|
|
@@ -1051,6 +1055,43 @@ interface DraftPage {
|
|
|
1051
1055
|
facts: WikiFact[];
|
|
1052
1056
|
nextCursor: string | null;
|
|
1053
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
|
+
}
|
|
1054
1095
|
|
|
1055
1096
|
interface WikiOutboxEvent<T = unknown> {
|
|
1056
1097
|
id: string;
|
|
@@ -1384,6 +1425,15 @@ declare class EntryRepository extends BaseRepository {
|
|
|
1384
1425
|
* Empty input is a synchronous early return with zero SQL calls.
|
|
1385
1426
|
*/
|
|
1386
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
|
+
}>>;
|
|
1387
1437
|
/**
|
|
1388
1438
|
* Return the live source_refs for an entity that hold the given source_hash.
|
|
1389
1439
|
* Used by the ingestDocument duplicate-hash guard and by hosts auditing
|
|
@@ -2086,6 +2136,13 @@ declare class PromptService {
|
|
|
2086
2136
|
systemPrompt: string;
|
|
2087
2137
|
userPrompt: string;
|
|
2088
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;
|
|
2089
2146
|
}
|
|
2090
2147
|
|
|
2091
2148
|
declare class IngestionService {
|
|
@@ -2630,6 +2687,8 @@ declare class WikiMemory {
|
|
|
2630
2687
|
private promptService;
|
|
2631
2688
|
private ontologyService;
|
|
2632
2689
|
private graphTraversalService;
|
|
2690
|
+
private lintRepo;
|
|
2691
|
+
private lintService;
|
|
2633
2692
|
private readonly okfTrustWrites;
|
|
2634
2693
|
constructor(db: SQLiteAdapter, options: WikiOptions);
|
|
2635
2694
|
/**
|
|
@@ -2657,6 +2716,30 @@ declare class WikiMemory {
|
|
|
2657
2716
|
changed: boolean;
|
|
2658
2717
|
duplicateOf?: string;
|
|
2659
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>;
|
|
2660
2743
|
/**
|
|
2661
2744
|
* Returns the live source_refs for an entity, one row per ref, with the most
|
|
2662
2745
|
* recently-updated live `source_hash` and a live fact count. Refs are sorted
|
|
@@ -2991,4 +3074,4 @@ declare class WikiMemory {
|
|
|
2991
3074
|
setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
|
|
2992
3075
|
}
|
|
2993
3076
|
|
|
2994
|
-
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';
|
package/dist/testing.js
CHANGED
|
@@ -1774,6 +1774,21 @@ ${JSON.stringify(facts, null, 2)}`
|
|
|
1774
1774
|
${JSON.stringify(facts, null, 2)}`
|
|
1775
1775
|
};
|
|
1776
1776
|
}
|
|
1777
|
+
/**
|
|
1778
|
+
* The system prompt each writer would send, without hydrating data (spec
|
|
1779
|
+
* §8.3). `buildSystemPrompt` with no variables hydrates only ontology
|
|
1780
|
+
* placeholders and leaves data placeholders verbatim; heal never receives
|
|
1781
|
+
* ontology context, matching `buildHealPrompt`.
|
|
1782
|
+
*/
|
|
1783
|
+
buildInstructionTemplates(ontologyContext) {
|
|
1784
|
+
const o = this.globalOverrides;
|
|
1785
|
+
return {
|
|
1786
|
+
ingest: this.appendGrounding(this.buildSystemPrompt(o?.ingestSystemPrompt ?? INGEST_SYSTEM_PROMPT, {}, ontologyContext), "ingest"),
|
|
1787
|
+
librarian: this.appendGrounding(this.buildSystemPrompt(o?.librarianSystemPrompt ?? LIBRARIAN_SYSTEM_PROMPT, {}, ontologyContext), "librarian"),
|
|
1788
|
+
heal: this.appendGrounding(o?.healSystemPrompt ?? HEAL_SYSTEM_PROMPT, "heal"),
|
|
1789
|
+
ontologyBackfill: this.buildSystemPrompt(o?.ontologyBackfillSystemPrompt ?? ONTOLOGY_BACKFILL_SYSTEM_PROMPT, {}, ontologyContext)
|
|
1790
|
+
};
|
|
1791
|
+
}
|
|
1777
1792
|
};
|
|
1778
1793
|
function applyBodyTruncation(candidates, attemptLevel, bodyTruncationChars) {
|
|
1779
1794
|
if (attemptLevel < 3) {
|
|
@@ -1956,11 +1971,16 @@ var IngestionService = class {
|
|
|
1956
1971
|
let ingestedChunks = 0;
|
|
1957
1972
|
let failedChunks = 0;
|
|
1958
1973
|
const failures = [];
|
|
1959
|
-
const
|
|
1960
|
-
const orderedChunkFacts = [];
|
|
1961
|
-
const groundingLedger = /* @__PURE__ */ new Map();
|
|
1974
|
+
const winners = /* @__PURE__ */ new Map();
|
|
1962
1975
|
const diagBuffer = new DiagnosticBuffer();
|
|
1963
1976
|
const diagBase = { entityId, operation: "ingest", trigger: "call" };
|
|
1977
|
+
const pushDeduplicated = (chunkIndex, itemIndex) => {
|
|
1978
|
+
diagBuffer.push({
|
|
1979
|
+
...diagBase,
|
|
1980
|
+
code: "fact_deduplicated",
|
|
1981
|
+
detail: { sourceRef, chunkIndex, itemIndex, reason: "exact_title" }
|
|
1982
|
+
});
|
|
1983
|
+
};
|
|
1964
1984
|
for (const [chunkIndex, slot] of chunkResults.entries()) {
|
|
1965
1985
|
if (slot.status === "failed") {
|
|
1966
1986
|
failedChunks++;
|
|
@@ -1971,22 +1991,32 @@ var IngestionService = class {
|
|
|
1971
1991
|
for (const r of slot.rejected) {
|
|
1972
1992
|
diagBuffer.push({ ...diagBase, code: "fact_rejected", detail: { sourceRef, chunkIndex, itemIndex: r.itemIndex, reason: r.reason } });
|
|
1973
1993
|
}
|
|
1974
|
-
const dedupedFacts = [];
|
|
1975
1994
|
slot.facts.forEach((fact, k) => {
|
|
1976
|
-
const
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1995
|
+
const key = normalizeTitleKey(fact.title);
|
|
1996
|
+
const candidate = { chunkIndex, k, itemIndex: slot.itemIndexes[k], rank: slot.verdicts[k]?.status === "grounded" ? 1 : 0 };
|
|
1997
|
+
const current = winners.get(key);
|
|
1998
|
+
if (!current) {
|
|
1999
|
+
winners.set(key, candidate);
|
|
2000
|
+
} else if (candidate.rank > current.rank) {
|
|
2001
|
+
pushDeduplicated(current.chunkIndex, current.itemIndex);
|
|
2002
|
+
winners.set(key, candidate);
|
|
1981
2003
|
} else {
|
|
1982
|
-
|
|
1983
|
-
...diagBase,
|
|
1984
|
-
code: "fact_deduplicated",
|
|
1985
|
-
detail: { sourceRef, chunkIndex, itemIndex: slot.itemIndexes[k], reason: "exact_title" }
|
|
1986
|
-
});
|
|
2004
|
+
pushDeduplicated(candidate.chunkIndex, candidate.itemIndex);
|
|
1987
2005
|
}
|
|
1988
2006
|
});
|
|
1989
|
-
|
|
2007
|
+
}
|
|
2008
|
+
const orderedChunkFacts = [];
|
|
2009
|
+
const groundingLedger = /* @__PURE__ */ new Map();
|
|
2010
|
+
for (const [chunkIndex, slot] of chunkResults.entries()) {
|
|
2011
|
+
if (slot.status === "failed") continue;
|
|
2012
|
+
const keptFacts = [];
|
|
2013
|
+
slot.facts.forEach((fact, k) => {
|
|
2014
|
+
const winner = winners.get(normalizeTitleKey(fact.title));
|
|
2015
|
+
if (winner?.chunkIndex !== chunkIndex || winner.k !== k) return;
|
|
2016
|
+
keptFacts.push(fact);
|
|
2017
|
+
if (ingestGrounding) groundingLedger.set(fact, { verdict: slot.verdicts[k], chunkIndex, itemIndex: winner.itemIndex });
|
|
2018
|
+
});
|
|
2019
|
+
orderedChunkFacts.push({ facts: keptFacts, ontology_updates: slot.ontology_updates });
|
|
1990
2020
|
}
|
|
1991
2021
|
for (const reason of ["parse", "llm"]) {
|
|
1992
2022
|
const ofReason = failures.filter((f) => f.source === reason);
|