@equationalapplications/core-llm-wiki 9.16.2 → 9.17.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/dist/{chunk-64ZKSSY6.mjs → chunk-QRGFHMFR.mjs} +103 -35
- package/dist/chunk-QRGFHMFR.mjs.map +1 -0
- package/dist/index.d.mts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +103 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-DNSqIkkv.d.mts → testing-BDYXXgaJ.d.mts} +46 -8
- package/dist/{testing-DNSqIkkv.d.ts → testing-BDYXXgaJ.d.ts} +46 -8
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +699 -631
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-64ZKSSY6.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyMode, W as WikiConfig, R as ReadOptions, c as OntologyConfig, S as SQLiteAdapter, d as WikiOptions, e as WikiMemory } from './testing-
|
|
2
|
-
export { C as CLASSIFIER_MAX_CHOICES, f as CheckpointIncompleteError, g as ChunkFailure, h as ClassifierAnswer, i as ClassifierQuestion, j as ClassifyRequest, k as ClassifyResponse, D as DegradedRecord, l as DraftPage, E as EmbedFactResult, m as EmbedFailureKind, n as EmbeddingMarkerKind, o as EntityMaintenanceReport, p as EntityStatus, q as EraseReport, r as EraseStepError, s as ExtractedFact, t as ExtractedFactEdge, u as ExtractedFactWithOntology, v as ExtractedTask, w as ForgetParams, x as ForgetResult, y as GraphTraversalOptions, z as GroundingConfig, H as HEAL_BATCH_SIZE, A as HEAL_RECHECK_MS, B as HOOK_TIMEOUT_MARKER, I as HealResult, J as ImportDumpResult, K as IngestDocumentResult, L as
|
|
1
|
+
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyMode, W as WikiConfig, R as ReadOptions, c as OntologyConfig, S as SQLiteAdapter, d as WikiOptions, e as WikiMemory } from './testing-BDYXXgaJ.mjs';
|
|
2
|
+
export { C as CLASSIFIER_MAX_CHOICES, f as CheckpointIncompleteError, g as ChunkFailure, h as ClassifierAnswer, i as ClassifierQuestion, j as ClassifyRequest, k as ClassifyResponse, D as DegradedRecord, l as DraftPage, E as EmbedFactResult, m as EmbedFailureKind, n as EmbeddingMarkerKind, o as EntityMaintenanceReport, p as EntityStatus, q as EraseReport, r as EraseStepError, s as ExtractedFact, t as ExtractedFactEdge, u as ExtractedFactWithOntology, v as ExtractedTask, w as ForgetParams, x as ForgetResult, y as GraphTraversalOptions, z as GroundingConfig, H as HEAL_BATCH_SIZE, A as HEAL_RECHECK_MS, B as HOOK_TIMEOUT_MARKER, I as HealResult, J as ImportDumpResult, K as IngestDocumentResult, L as IngestTypingCounters, N as LLMProvider, P as LibrarianConfig, Q as LibrarianGateConfig, T as LockedMaintenanceJob, U as MaintenanceJob, V as MaintenanceStopReason, X as MemoryDumpEntity, Y as MigrationPolicy, Z as ONTOLOGY_ABSTAIN_SENTINEL, _ as ONTOLOGY_BACKFILL_BATCH_SIZE, $ as ONTOLOGY_BACKFILL_RECHECK_MS, a0 as OntologyBackfillResult, a1 as OntologyEdgeType, a2 as OntologyManifest, a3 as OntologyNodeType, a4 as OntologyPromptContext, a5 as OntologyUpdates, a6 as PendingMaintenance, a7 as PendingMigrationWork, a8 as PendingSourceStatus, a9 as PromptOverrides, aa as PromptService, ab as PrunePartialFailureError, ac as ReembedResult, ad as RememberInput, ae as RunPendingMaintenanceOptions, af as RunPendingMaintenanceResult, ag as SourcePassage, ah as StoreSourceResult, ai as StoredSource, aj as StoredSourceDump, ak as StoredSourceSummary, al as SupersedeReplacement, am as SystemOneConfig, an as SystemOneThresholdSite, ao as VectorRanker, ap as VectorRankerFallback, aq as VectorRankerRankArgs, ar as VectorRankerSemanticResult, as as WikiBusyError, at as WikiBusyOperation, au as WikiCheckpoint, av as WikiDiagnostic, aw as WikiDiagnosticCode, ax as WikiDiagnosticDetail, ay as WikiDiagnosticOperation, az as WikiDiagnosticSeverity, aA as WikiDiagnosticTrigger, aB as WikiDraftNotFound, aC as WikiDuplicateHashError, aD as WikiEdge, aE as WikiEvent, aF as WikiExternalDeletionError, aG as WikiFact, aH as WikiGraphNodeOwnershipConflict, aI as WikiIngestEmptyError, aJ as WikiInstructions, aK as WikiInvalidReadOptions, aL as WikiLintReport, aM as WikiMemoryTestAccess, aN as WikiMigrationRequiredError, aO as WikiOutboxEvent, aP as WikiParseError, aQ as WikiSearchUnavailableError, aR as WikiSourcePointer, aS as WikiSourceRefHashCollision, aT as WikiStrictOntologyViolation, aU as WikiSupersedeError, aV as WikiSupersedeReason, aW as WikiTask, aX as WikiTransactionError, aY as WriteOntologyPromptContext, aZ as isReservedAbstainSlug, a_ as isWikiSearchUnavailableError, a$ as validateManifest } from './testing-BDYXXgaJ.mjs';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -285,6 +285,13 @@ declare function resolveSystemOneHealScreen(config: WikiConfig | undefined): 'au
|
|
|
285
285
|
* existing `'typing'` floor (`resolveTypingMinConfidence`).
|
|
286
286
|
*/
|
|
287
287
|
declare function resolveSystemOneTypeOnWrite(config: WikiConfig | undefined): 'auto' | 'llm';
|
|
288
|
+
/**
|
|
289
|
+
* Ingest-time typing mode (specs/ingest-time-typing §1): `systemOne.typeOnIngest`,
|
|
290
|
+
* `'llm'` when unset. A present invalid value warns once and is treated as
|
|
291
|
+
* unset. No legacy chain and no call option. The ingest site reads the
|
|
292
|
+
* existing `'typing'` floor (`resolveTypingMinConfidence`).
|
|
293
|
+
*/
|
|
294
|
+
declare function resolveSystemOneTypeOnIngest(config: WikiConfig | undefined): 'auto' | 'llm';
|
|
288
295
|
/**
|
|
289
296
|
* Heal-screen floor (specs/heal-screening-system-one §3): returns the
|
|
290
297
|
* `systemOne.minConfidence.healScreen` floor only when the heal-screen mode
|
|
@@ -299,5 +306,5 @@ declare const ONTOLOGY_BACKFILL_SYSTEM_PROMPT = "You are a knowledge classificat
|
|
|
299
306
|
|
|
300
307
|
declare function createWiki(db: SQLiteAdapter, options: WikiOptions): WikiMemory;
|
|
301
308
|
|
|
302
|
-
export { DEFAULT_CHUNK_OVERLAP, DEFAULT_LIBRARIAN_SYNTHESIS_PROMPT, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DEFAULT_ONTOLOGY_JOB_BATCH_SIZE, DEFAULT_SETUP_BUDGET_MS, DEFAULT_TYPING_MIN_CONFIDENCE, EMBED_CHARS_CEILING, FormatContextOptions, FormattedMemoryDump, GraphNeighborhood, HEAL_ANCHORS_PER_CANDIDATE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, MemoryBundle, MemoryDump, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, OntologyConfig, OntologyMode, ReadOptions, SQLiteAdapter, WikiConfig, WikiMemory, WikiOptions, buildOntologyPromptAppendix, chunkText, configureRandomSource, createWiki, estimateTokensWith, formatContext, formatGraphContext, formatMemoryDump, formatOkfBundle, hydrateLibrarianPrompt, mapLibrarianOptionsToReadOptions, parseEmbedding, parseOkfBundle, resolveContextBudget, resolveDefaultChunkLength, resolveEdgesMinConfidence, resolveHealScreenMinConfidence, resolveMaxPromptChars, resolveOntologyJobDefaults, resolveResolveMinConfidence, resolveSystemOneEdges, resolveSystemOneHealScreen, resolveSystemOneResolve, resolveSystemOneTypeOnWrite, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateLibrarianPromptTemplate, warnOnce };
|
|
309
|
+
export { DEFAULT_CHUNK_OVERLAP, DEFAULT_LIBRARIAN_SYNTHESIS_PROMPT, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DEFAULT_ONTOLOGY_JOB_BATCH_SIZE, DEFAULT_SETUP_BUDGET_MS, DEFAULT_TYPING_MIN_CONFIDENCE, EMBED_CHARS_CEILING, FormatContextOptions, FormattedMemoryDump, GraphNeighborhood, HEAL_ANCHORS_PER_CANDIDATE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, MemoryBundle, MemoryDump, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, OntologyConfig, OntologyMode, ReadOptions, SQLiteAdapter, WikiConfig, WikiMemory, WikiOptions, buildOntologyPromptAppendix, chunkText, configureRandomSource, createWiki, estimateTokensWith, formatContext, formatGraphContext, formatMemoryDump, formatOkfBundle, hydrateLibrarianPrompt, mapLibrarianOptionsToReadOptions, parseEmbedding, parseOkfBundle, resolveContextBudget, resolveDefaultChunkLength, resolveEdgesMinConfidence, resolveHealScreenMinConfidence, resolveMaxPromptChars, resolveOntologyJobDefaults, resolveResolveMinConfidence, resolveSystemOneEdges, resolveSystemOneHealScreen, resolveSystemOneResolve, resolveSystemOneTypeOnIngest, resolveSystemOneTypeOnWrite, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateLibrarianPromptTemplate, warnOnce };
|
|
303
310
|
export type { ContextBudget, FormatOkfBundleOptions, LibrarianOptions, LibrarianPromptVariables, OkfFormatProfile, OkfImportOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyMode, W as WikiConfig, R as ReadOptions, c as OntologyConfig, S as SQLiteAdapter, d as WikiOptions, e as WikiMemory } from './testing-
|
|
2
|
-
export { C as CLASSIFIER_MAX_CHOICES, f as CheckpointIncompleteError, g as ChunkFailure, h as ClassifierAnswer, i as ClassifierQuestion, j as ClassifyRequest, k as ClassifyResponse, D as DegradedRecord, l as DraftPage, E as EmbedFactResult, m as EmbedFailureKind, n as EmbeddingMarkerKind, o as EntityMaintenanceReport, p as EntityStatus, q as EraseReport, r as EraseStepError, s as ExtractedFact, t as ExtractedFactEdge, u as ExtractedFactWithOntology, v as ExtractedTask, w as ForgetParams, x as ForgetResult, y as GraphTraversalOptions, z as GroundingConfig, H as HEAL_BATCH_SIZE, A as HEAL_RECHECK_MS, B as HOOK_TIMEOUT_MARKER, I as HealResult, J as ImportDumpResult, K as IngestDocumentResult, L as
|
|
1
|
+
import { M as MemoryBundle, F as FormatContextOptions, G as GraphNeighborhood, a as MemoryDump, b as FormattedMemoryDump, O as OntologyMode, W as WikiConfig, R as ReadOptions, c as OntologyConfig, S as SQLiteAdapter, d as WikiOptions, e as WikiMemory } from './testing-BDYXXgaJ.js';
|
|
2
|
+
export { C as CLASSIFIER_MAX_CHOICES, f as CheckpointIncompleteError, g as ChunkFailure, h as ClassifierAnswer, i as ClassifierQuestion, j as ClassifyRequest, k as ClassifyResponse, D as DegradedRecord, l as DraftPage, E as EmbedFactResult, m as EmbedFailureKind, n as EmbeddingMarkerKind, o as EntityMaintenanceReport, p as EntityStatus, q as EraseReport, r as EraseStepError, s as ExtractedFact, t as ExtractedFactEdge, u as ExtractedFactWithOntology, v as ExtractedTask, w as ForgetParams, x as ForgetResult, y as GraphTraversalOptions, z as GroundingConfig, H as HEAL_BATCH_SIZE, A as HEAL_RECHECK_MS, B as HOOK_TIMEOUT_MARKER, I as HealResult, J as ImportDumpResult, K as IngestDocumentResult, L as IngestTypingCounters, N as LLMProvider, P as LibrarianConfig, Q as LibrarianGateConfig, T as LockedMaintenanceJob, U as MaintenanceJob, V as MaintenanceStopReason, X as MemoryDumpEntity, Y as MigrationPolicy, Z as ONTOLOGY_ABSTAIN_SENTINEL, _ as ONTOLOGY_BACKFILL_BATCH_SIZE, $ as ONTOLOGY_BACKFILL_RECHECK_MS, a0 as OntologyBackfillResult, a1 as OntologyEdgeType, a2 as OntologyManifest, a3 as OntologyNodeType, a4 as OntologyPromptContext, a5 as OntologyUpdates, a6 as PendingMaintenance, a7 as PendingMigrationWork, a8 as PendingSourceStatus, a9 as PromptOverrides, aa as PromptService, ab as PrunePartialFailureError, ac as ReembedResult, ad as RememberInput, ae as RunPendingMaintenanceOptions, af as RunPendingMaintenanceResult, ag as SourcePassage, ah as StoreSourceResult, ai as StoredSource, aj as StoredSourceDump, ak as StoredSourceSummary, al as SupersedeReplacement, am as SystemOneConfig, an as SystemOneThresholdSite, ao as VectorRanker, ap as VectorRankerFallback, aq as VectorRankerRankArgs, ar as VectorRankerSemanticResult, as as WikiBusyError, at as WikiBusyOperation, au as WikiCheckpoint, av as WikiDiagnostic, aw as WikiDiagnosticCode, ax as WikiDiagnosticDetail, ay as WikiDiagnosticOperation, az as WikiDiagnosticSeverity, aA as WikiDiagnosticTrigger, aB as WikiDraftNotFound, aC as WikiDuplicateHashError, aD as WikiEdge, aE as WikiEvent, aF as WikiExternalDeletionError, aG as WikiFact, aH as WikiGraphNodeOwnershipConflict, aI as WikiIngestEmptyError, aJ as WikiInstructions, aK as WikiInvalidReadOptions, aL as WikiLintReport, aM as WikiMemoryTestAccess, aN as WikiMigrationRequiredError, aO as WikiOutboxEvent, aP as WikiParseError, aQ as WikiSearchUnavailableError, aR as WikiSourcePointer, aS as WikiSourceRefHashCollision, aT as WikiStrictOntologyViolation, aU as WikiSupersedeError, aV as WikiSupersedeReason, aW as WikiTask, aX as WikiTransactionError, aY as WriteOntologyPromptContext, aZ as isReservedAbstainSlug, a_ as isWikiSearchUnavailableError, a$ as validateManifest } from './testing-BDYXXgaJ.js';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -285,6 +285,13 @@ declare function resolveSystemOneHealScreen(config: WikiConfig | undefined): 'au
|
|
|
285
285
|
* existing `'typing'` floor (`resolveTypingMinConfidence`).
|
|
286
286
|
*/
|
|
287
287
|
declare function resolveSystemOneTypeOnWrite(config: WikiConfig | undefined): 'auto' | 'llm';
|
|
288
|
+
/**
|
|
289
|
+
* Ingest-time typing mode (specs/ingest-time-typing §1): `systemOne.typeOnIngest`,
|
|
290
|
+
* `'llm'` when unset. A present invalid value warns once and is treated as
|
|
291
|
+
* unset. No legacy chain and no call option. The ingest site reads the
|
|
292
|
+
* existing `'typing'` floor (`resolveTypingMinConfidence`).
|
|
293
|
+
*/
|
|
294
|
+
declare function resolveSystemOneTypeOnIngest(config: WikiConfig | undefined): 'auto' | 'llm';
|
|
288
295
|
/**
|
|
289
296
|
* Heal-screen floor (specs/heal-screening-system-one §3): returns the
|
|
290
297
|
* `systemOne.minConfidence.healScreen` floor only when the heal-screen mode
|
|
@@ -299,5 +306,5 @@ declare const ONTOLOGY_BACKFILL_SYSTEM_PROMPT = "You are a knowledge classificat
|
|
|
299
306
|
|
|
300
307
|
declare function createWiki(db: SQLiteAdapter, options: WikiOptions): WikiMemory;
|
|
301
308
|
|
|
302
|
-
export { DEFAULT_CHUNK_OVERLAP, DEFAULT_LIBRARIAN_SYNTHESIS_PROMPT, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DEFAULT_ONTOLOGY_JOB_BATCH_SIZE, DEFAULT_SETUP_BUDGET_MS, DEFAULT_TYPING_MIN_CONFIDENCE, EMBED_CHARS_CEILING, FormatContextOptions, FormattedMemoryDump, GraphNeighborhood, HEAL_ANCHORS_PER_CANDIDATE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, MemoryBundle, MemoryDump, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, OntologyConfig, OntologyMode, ReadOptions, SQLiteAdapter, WikiConfig, WikiMemory, WikiOptions, buildOntologyPromptAppendix, chunkText, configureRandomSource, createWiki, estimateTokensWith, formatContext, formatGraphContext, formatMemoryDump, formatOkfBundle, hydrateLibrarianPrompt, mapLibrarianOptionsToReadOptions, parseEmbedding, parseOkfBundle, resolveContextBudget, resolveDefaultChunkLength, resolveEdgesMinConfidence, resolveHealScreenMinConfidence, resolveMaxPromptChars, resolveOntologyJobDefaults, resolveResolveMinConfidence, resolveSystemOneEdges, resolveSystemOneHealScreen, resolveSystemOneResolve, resolveSystemOneTypeOnWrite, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateLibrarianPromptTemplate, warnOnce };
|
|
309
|
+
export { DEFAULT_CHUNK_OVERLAP, DEFAULT_LIBRARIAN_SYNTHESIS_PROMPT, DEFAULT_MAX_CHUNK_LENGTH, DEFAULT_MAX_EMBED_CHARS, DEFAULT_ONTOLOGY_JOB_BATCH_SIZE, DEFAULT_SETUP_BUDGET_MS, DEFAULT_TYPING_MIN_CONFIDENCE, EMBED_CHARS_CEILING, FormatContextOptions, FormattedMemoryDump, GraphNeighborhood, HEAL_ANCHORS_PER_CANDIDATE, HEAL_MAX_FACT_BODY_CHARS_L3, HEAL_MAX_TASKS, MemoryBundle, MemoryDump, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS, ONTOLOGY_BACKFILL_SYSTEM_PROMPT, OntologyConfig, OntologyMode, ReadOptions, SQLiteAdapter, WikiConfig, WikiMemory, WikiOptions, buildOntologyPromptAppendix, chunkText, configureRandomSource, createWiki, estimateTokensWith, formatContext, formatGraphContext, formatMemoryDump, formatOkfBundle, hydrateLibrarianPrompt, mapLibrarianOptionsToReadOptions, parseEmbedding, parseOkfBundle, resolveContextBudget, resolveDefaultChunkLength, resolveEdgesMinConfidence, resolveHealScreenMinConfidence, resolveMaxPromptChars, resolveOntologyJobDefaults, resolveResolveMinConfidence, resolveSystemOneEdges, resolveSystemOneHealScreen, resolveSystemOneResolve, resolveSystemOneTypeOnIngest, resolveSystemOneTypeOnWrite, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateLibrarianPromptTemplate, warnOnce };
|
|
303
310
|
export type { ContextBudget, FormatOkfBundleOptions, LibrarianOptions, LibrarianPromptVariables, OkfFormatProfile, OkfImportOptions };
|
package/dist/index.js
CHANGED
|
@@ -253,6 +253,16 @@ function resolveSystemOneTypeOnWrite(config) {
|
|
|
253
253
|
}
|
|
254
254
|
return typeOnWrite ?? "llm";
|
|
255
255
|
}
|
|
256
|
+
function resolveSystemOneTypeOnIngest(config) {
|
|
257
|
+
const typeOnIngest = config?.systemOne?.typeOnIngest;
|
|
258
|
+
if (typeOnIngest !== void 0 && !isTypingMode(typeOnIngest)) {
|
|
259
|
+
warnOnce(
|
|
260
|
+
`[core-llm-wiki] systemOne: \`systemOne.typeOnIngest\` is ${formatConfigValue(typeOnIngest)}, which is not 'auto' or 'llm'. The key is treated as unset; the default ('llm') applies.`
|
|
261
|
+
);
|
|
262
|
+
return "llm";
|
|
263
|
+
}
|
|
264
|
+
return typeOnIngest ?? "llm";
|
|
265
|
+
}
|
|
256
266
|
function resolveHealScreenMinConfidence(config) {
|
|
257
267
|
if (resolveSystemOneHealScreen(config) !== "auto") return void 0;
|
|
258
268
|
const floor = config?.systemOne?.minConfidence?.healScreen;
|
|
@@ -1807,8 +1817,14 @@ function isManifestRepresentable(manifest) {
|
|
|
1807
1817
|
const slugs = manifest.node_types.map((n) => n.type);
|
|
1808
1818
|
return slugs.length > 0 && slugs.length + 1 <= CLASSIFIER_MAX_CHOICES && !slugs.some((s) => isReservedAbstainSlug(s));
|
|
1809
1819
|
}
|
|
1820
|
+
function typingEngages(site, provider, mode, manifest) {
|
|
1821
|
+
return site === "auto" && typeof provider.classify === "function" && mode !== "off" && isManifestRepresentable(manifest);
|
|
1822
|
+
}
|
|
1810
1823
|
function canEngageWriteTyping(config, provider, mode, manifest) {
|
|
1811
|
-
return resolveSystemOneTypeOnWrite(config)
|
|
1824
|
+
return typingEngages(resolveSystemOneTypeOnWrite(config), provider, mode, manifest);
|
|
1825
|
+
}
|
|
1826
|
+
function canEngageIngestTyping(config, provider, mode, manifest) {
|
|
1827
|
+
return typingEngages(resolveSystemOneTypeOnIngest(config), provider, mode, manifest);
|
|
1812
1828
|
}
|
|
1813
1829
|
function buildTypingQuestion(manifest) {
|
|
1814
1830
|
return {
|
|
@@ -1821,9 +1837,9 @@ function buildTypingQuestion(manifest) {
|
|
|
1821
1837
|
function volunteeredTypeResolves(rawOkfType, manifest) {
|
|
1822
1838
|
return typeof rawOkfType === "string" && resolveNodeTypeMatch(rawOkfType, manifest) !== null;
|
|
1823
1839
|
}
|
|
1824
|
-
async function classifyFactsForWrite(options, ctx, facts, manifest, floor) {
|
|
1840
|
+
async function classifyFactsForWrite(options, ctx, facts, manifest, floor, opts) {
|
|
1825
1841
|
const question = buildTypingQuestion(manifest);
|
|
1826
|
-
const rawConcurrency = options.config?.chunkConcurrency ?? 1;
|
|
1842
|
+
const rawConcurrency = opts?.concurrency ?? options.config?.chunkConcurrency ?? 1;
|
|
1827
1843
|
const concurrency = Number.isFinite(rawConcurrency) && rawConcurrency >= 1 ? Math.floor(rawConcurrency) : 1;
|
|
1828
1844
|
let stopped = false;
|
|
1829
1845
|
return withConcurrency(
|
|
@@ -1854,6 +1870,10 @@ async function classifyFactsForWrite(options, ctx, facts, manifest, floor) {
|
|
|
1854
1870
|
concurrency
|
|
1855
1871
|
);
|
|
1856
1872
|
}
|
|
1873
|
+
function toIngestCounters(c) {
|
|
1874
|
+
const { unattempted: _unattempted, ...rest } = c;
|
|
1875
|
+
return rest;
|
|
1876
|
+
}
|
|
1857
1877
|
function emptyTypingCounters() {
|
|
1858
1878
|
return { asked: 0, typed: 0, abstained: 0, lowConfidence: 0, invalid: 0, skipped: 0, unattempted: 0 };
|
|
1859
1879
|
}
|
|
@@ -8932,7 +8952,9 @@ var IngestionService = class {
|
|
|
8932
8952
|
}
|
|
8933
8953
|
const { chunks: chunks2, truncated } = chunkText(params.documentChunk, maxChunkLength, chunkOverlap);
|
|
8934
8954
|
if (chunks2.length === 0) return zeroChunkResult();
|
|
8935
|
-
const
|
|
8955
|
+
const hoistedState = await this.ontologyService?.getEffectiveState(entityId) ?? { mode: "off", manifest: { node_types: [], edge_types: [] } };
|
|
8956
|
+
const engaged = this.ontologyService !== void 0 && canEngageIngestTyping(this.options.config, this.options.llmProvider, hoistedState.mode, hoistedState.manifest);
|
|
8957
|
+
const ontologyContext = await this.ontologyService?.buildWritePromptContext(entityId, { engaged }) ?? null;
|
|
8936
8958
|
const { guidance, diagnostic } = PromptService.resolveGuidance(this.options.config, entityId);
|
|
8937
8959
|
if (diagnostic) {
|
|
8938
8960
|
emitDiagnostic(this.options, {
|
|
@@ -9088,16 +9110,42 @@ var IngestionService = class {
|
|
|
9088
9110
|
chunks: chunks2.length
|
|
9089
9111
|
});
|
|
9090
9112
|
}
|
|
9113
|
+
const typing = { outcomes: /* @__PURE__ */ new Map(), counters: emptyTypingCounters() };
|
|
9114
|
+
let hashHeldElsewhere = false;
|
|
9115
|
+
if (engaged && failedChunks === 0 && onDuplicateHash === "ingest") {
|
|
9116
|
+
const holder = await this.sourceRefIndexRepo.findActiveByEntityAndHash(entityId, sourceHash);
|
|
9117
|
+
hashHeldElsewhere = holder !== null && holder !== sourceRef;
|
|
9118
|
+
}
|
|
9119
|
+
if (engaged && !hashHeldElsewhere) {
|
|
9120
|
+
const asked = [];
|
|
9121
|
+
for (const slot of orderedChunkFacts) {
|
|
9122
|
+
for (const fact of slot.facts) {
|
|
9123
|
+
if (!volunteeredTypeResolves(fact.okf_type, hoistedState.manifest)) asked.push(fact);
|
|
9124
|
+
}
|
|
9125
|
+
}
|
|
9126
|
+
const outcomes = await classifyFactsForWrite(
|
|
9127
|
+
this.options,
|
|
9128
|
+
{ entityId, trigger: "call", operation: "ingest" },
|
|
9129
|
+
asked,
|
|
9130
|
+
hoistedState.manifest,
|
|
9131
|
+
resolveTypingMinConfidence(this.options.config),
|
|
9132
|
+
{ concurrency: chunkConcurrency }
|
|
9133
|
+
);
|
|
9134
|
+
asked.forEach((fact, i) => {
|
|
9135
|
+
typing.outcomes.set(fact, outcomes[i]);
|
|
9136
|
+
tallyTypingOutcome(typing.counters, outcomes[i]);
|
|
9137
|
+
});
|
|
9138
|
+
}
|
|
9091
9139
|
const insertedFacts = [];
|
|
9092
9140
|
const deletedSourceFactIds = [];
|
|
9093
9141
|
try {
|
|
9094
9142
|
if (failedChunks === 0) {
|
|
9095
9143
|
const fullResult = await this.db.withTransactionAsync(async (tx) => {
|
|
9096
|
-
return await this.runFullUpsertGraph(entityId, sourceRef, sourceHash, orderedChunkFacts, tx, diagBuffer, factLedger);
|
|
9144
|
+
return await this.runFullUpsertGraph(entityId, sourceRef, sourceHash, orderedChunkFacts, tx, diagBuffer, factLedger, typing);
|
|
9097
9145
|
});
|
|
9098
9146
|
deletedSourceFactIds.push(...fullResult.deletedSourceFactIds);
|
|
9099
9147
|
insertedFacts.push(...fullResult.insertedFacts);
|
|
9100
|
-
if (
|
|
9148
|
+
if (hoistedState.mode !== "off" && insertedFacts.length === 0 && deletedSourceFactIds.length > 0) {
|
|
9101
9149
|
diagBuffer.push({
|
|
9102
9150
|
entityId,
|
|
9103
9151
|
operation: "ingest",
|
|
@@ -9110,7 +9158,7 @@ var IngestionService = class {
|
|
|
9110
9158
|
const partialResult = await this.db.withTransactionAsync(async (tx) => {
|
|
9111
9159
|
const flat = [];
|
|
9112
9160
|
for (const slot of orderedChunkFacts) flat.push(...slot.facts);
|
|
9113
|
-
return await this.appendPartialFacts(entityId, sourceRef, flat, tx, diagBuffer, factLedger);
|
|
9161
|
+
return await this.appendPartialFacts(entityId, sourceRef, flat, tx, diagBuffer, factLedger, typing);
|
|
9114
9162
|
});
|
|
9115
9163
|
insertedFacts.push(...partialResult.insertedDescriptors);
|
|
9116
9164
|
}
|
|
@@ -9162,6 +9210,7 @@ var IngestionService = class {
|
|
|
9162
9210
|
failedChunks
|
|
9163
9211
|
};
|
|
9164
9212
|
if (failedChunks > 0) result.parseFailures = failures;
|
|
9213
|
+
if (engaged) result.typing = toIngestCounters(typing.counters);
|
|
9165
9214
|
return result;
|
|
9166
9215
|
} finally {
|
|
9167
9216
|
releaseIngestLocks();
|
|
@@ -9371,10 +9420,11 @@ var IngestionService = class {
|
|
|
9371
9420
|
* On the partial path the caller never invokes this method; the empty
|
|
9372
9421
|
* arrays stay empty.
|
|
9373
9422
|
*/
|
|
9374
|
-
async runFullUpsertGraph(entityId, sourceRef, sourceHash, orderedChunkFacts, tx, diagBuffer, factLedger = /* @__PURE__ */ new Map()) {
|
|
9423
|
+
async runFullUpsertGraph(entityId, sourceRef, sourceHash, orderedChunkFacts, tx, diagBuffer, factLedger = /* @__PURE__ */ new Map(), typing) {
|
|
9375
9424
|
const deletedSourceFactIds = [];
|
|
9376
9425
|
const insertedFacts = [];
|
|
9377
9426
|
const nodeTrust = /* @__PURE__ */ new Map();
|
|
9427
|
+
const diagBase = { entityId, operation: "ingest", trigger: "call" };
|
|
9378
9428
|
deletedSourceFactIds.push(...await this.entryRepo.findIdsBySource(entityId, sourceRef, null, tx, false));
|
|
9379
9429
|
const titleIndex = /* @__PURE__ */ new Map();
|
|
9380
9430
|
const existingFacts = await this.entryRepo.findRecentByEntityId(entityId, 500, tx, sourceRef);
|
|
@@ -9388,6 +9438,7 @@ var IngestionService = class {
|
|
|
9388
9438
|
let { mode, manifest } = ontologyState;
|
|
9389
9439
|
const hostNodes = [];
|
|
9390
9440
|
const rawEdgeRequests = [];
|
|
9441
|
+
const typedAtDoor = [];
|
|
9391
9442
|
const now = Date.now();
|
|
9392
9443
|
for (const { facts, ontology_updates } of orderedChunkFacts) {
|
|
9393
9444
|
if (mode === "emergent" && ontology_updates && this.ontologyService) {
|
|
@@ -9407,14 +9458,15 @@ var IngestionService = class {
|
|
|
9407
9458
|
for (const fact of facts) {
|
|
9408
9459
|
const ontologyFact = fact;
|
|
9409
9460
|
const id = generateId("fact_");
|
|
9410
|
-
const
|
|
9411
|
-
const
|
|
9412
|
-
|
|
9461
|
+
const outcome = typing?.outcomes.get(fact);
|
|
9462
|
+
const slot = normalizeForWrite(this.ontologyService, ontologyFact, manifest, mode, outcome, diagBase, id);
|
|
9463
|
+
const normalized = slot.normalized;
|
|
9464
|
+
for (const drop of slot.drops) {
|
|
9413
9465
|
diagBuffer.push(edgeDropDiagnostic(drop, { entityId, operation: "ingest", trigger: "call", sourceRef, factId: id }));
|
|
9414
9466
|
}
|
|
9415
|
-
|
|
9467
|
+
const hostNode = {
|
|
9416
9468
|
id,
|
|
9417
|
-
type:
|
|
9469
|
+
type: "",
|
|
9418
9470
|
title: fact.title,
|
|
9419
9471
|
body: fact.body,
|
|
9420
9472
|
// Forward the LLM-extracted tags/confidence through the
|
|
@@ -9426,18 +9478,20 @@ var IngestionService = class {
|
|
|
9426
9478
|
// 'certain' as documented.
|
|
9427
9479
|
tags: fact.tags,
|
|
9428
9480
|
confidence: fact.confidence
|
|
9429
|
-
}
|
|
9481
|
+
};
|
|
9482
|
+
hostNodes.push(hostNode);
|
|
9483
|
+
typedAtDoor.push({ node: hostNode, fact: ontologyFact, id, outcome, slotType: normalized.okf_type });
|
|
9430
9484
|
const locator = factLedger.get(fact);
|
|
9431
9485
|
if (locator?.verdict) {
|
|
9432
|
-
const
|
|
9433
|
-
nodeTrust.set(id,
|
|
9434
|
-
if (
|
|
9486
|
+
const outcome2 = groundingOutcome(locator.verdict, now);
|
|
9487
|
+
nodeTrust.set(id, outcome2.trust);
|
|
9488
|
+
if (outcome2.diagnostic) {
|
|
9435
9489
|
diagBuffer.push({
|
|
9436
9490
|
entityId,
|
|
9437
9491
|
operation: "ingest",
|
|
9438
9492
|
trigger: "call",
|
|
9439
|
-
code:
|
|
9440
|
-
detail: { factId: id, sourceRef, chunkIndex: locator.chunkIndex, itemIndex: locator.itemIndex, reason:
|
|
9493
|
+
code: outcome2.diagnostic.code,
|
|
9494
|
+
detail: { factId: id, sourceRef, chunkIndex: locator.chunkIndex, itemIndex: locator.itemIndex, reason: outcome2.diagnostic.reason }
|
|
9441
9495
|
});
|
|
9442
9496
|
}
|
|
9443
9497
|
}
|
|
@@ -9448,6 +9502,18 @@ var IngestionService = class {
|
|
|
9448
9502
|
}
|
|
9449
9503
|
}
|
|
9450
9504
|
}
|
|
9505
|
+
const doorReceipts = [];
|
|
9506
|
+
for (const { node, fact, id, outcome, slotType } of typedAtDoor) {
|
|
9507
|
+
const final = normalizeForWrite(this.ontologyService, fact, manifest, mode, outcome, diagBase, id);
|
|
9508
|
+
for (const receipt of final.receipts) {
|
|
9509
|
+
doorReceipts.push({ ...receipt, detail: { ...receipt.detail, sourceRef } });
|
|
9510
|
+
}
|
|
9511
|
+
node.type = final.normalized.okf_type ?? "";
|
|
9512
|
+
if (final.typedByClassifier && typing) typing.counters.typed++;
|
|
9513
|
+
if (outcome?.kind === "accepted" && final.normalized.okf_type !== slotType) {
|
|
9514
|
+
titleIndex.set(normalizeTitleKey(fact.title), { id, okf_type: final.normalized.okf_type });
|
|
9515
|
+
}
|
|
9516
|
+
}
|
|
9451
9517
|
const hostEdges = [];
|
|
9452
9518
|
for (const req of rawEdgeRequests) {
|
|
9453
9519
|
const resolveDrops = [];
|
|
@@ -9468,6 +9534,7 @@ var IngestionService = class {
|
|
|
9468
9534
|
hostEdges.push({ type: e.edge_type, sourceId: e.source_id, targetId: e.target_id });
|
|
9469
9535
|
}
|
|
9470
9536
|
}
|
|
9537
|
+
for (const receipt of doorReceipts) diagBuffer.push(receipt);
|
|
9471
9538
|
await this.upsertGraphCore(
|
|
9472
9539
|
entityId,
|
|
9473
9540
|
{ sourceRef, sourceHash, nodes: hostNodes, edges: hostEdges },
|
|
@@ -9496,7 +9563,7 @@ var IngestionService = class {
|
|
|
9496
9563
|
* Runs INSIDE the caller's `tx`. Does not open a nested transaction.
|
|
9497
9564
|
* Returns `{ inserted, skippedDuplicate }` for observability.
|
|
9498
9565
|
*/
|
|
9499
|
-
async appendPartialFacts(entityId, sourceRef, dedupedFacts, tx, diagBuffer, factLedger = /* @__PURE__ */ new Map()) {
|
|
9566
|
+
async appendPartialFacts(entityId, sourceRef, dedupedFacts, tx, diagBuffer, factLedger = /* @__PURE__ */ new Map(), typing) {
|
|
9500
9567
|
const liveIds = await this.entryRepo.findIdsBySource(entityId, sourceRef, null, tx, false);
|
|
9501
9568
|
const liveFacts = liveIds.length === 0 ? [] : await this.entryRepo.findByIds(liveIds, void 0, tx);
|
|
9502
9569
|
const liveTitles = new Set(liveFacts.map((f) => normalizeTitleKey(f.title)));
|
|
@@ -9507,6 +9574,7 @@ var IngestionService = class {
|
|
|
9507
9574
|
for (const f of indexedFacts) {
|
|
9508
9575
|
titleIndex.set(normalizeTitleKey(f.title), { id: f.id, okf_type: f.okf_type ?? null });
|
|
9509
9576
|
}
|
|
9577
|
+
const diagBase = { entityId, operation: "ingest", trigger: "call" };
|
|
9510
9578
|
const pendingEdges = [];
|
|
9511
9579
|
let inserted = 0;
|
|
9512
9580
|
let skippedDuplicate = 0;
|
|
@@ -9533,22 +9601,22 @@ var IngestionService = class {
|
|
|
9533
9601
|
});
|
|
9534
9602
|
}
|
|
9535
9603
|
const ontologyFact = fact;
|
|
9536
|
-
const validationDrops =
|
|
9537
|
-
|
|
9604
|
+
const { normalized, drops: validationDrops, receipts, typedByClassifier } = normalizeForWrite(
|
|
9605
|
+
this.ontologyService,
|
|
9606
|
+
ontologyFact,
|
|
9607
|
+
manifest,
|
|
9608
|
+
mode,
|
|
9609
|
+
typing?.outcomes.get(fact),
|
|
9610
|
+
diagBase,
|
|
9611
|
+
id
|
|
9612
|
+
);
|
|
9538
9613
|
for (const drop of validationDrops) {
|
|
9539
9614
|
diagBuffer.push(edgeDropDiagnostic(drop, { entityId, operation: "ingest", trigger: "call", sourceRef, factId: id }));
|
|
9540
9615
|
}
|
|
9541
|
-
|
|
9542
|
-
|
|
9543
|
-
{ entityId, operation: "ingest", trigger: "call" },
|
|
9544
|
-
id,
|
|
9545
|
-
ontologyFact.okf_type ?? "",
|
|
9546
|
-
normalized.okf_type,
|
|
9547
|
-
normalized.match
|
|
9548
|
-
)) {
|
|
9549
|
-
diagBuffer.push({ ...receipt, detail: { ...receipt.detail, sourceRef } });
|
|
9550
|
-
}
|
|
9616
|
+
for (const receipt of receipts) {
|
|
9617
|
+
diagBuffer.push({ ...receipt, detail: { ...receipt.detail, sourceRef } });
|
|
9551
9618
|
}
|
|
9619
|
+
if (typedByClassifier && typing) typing.counters.typed++;
|
|
9552
9620
|
if (normalized.edges.length > 0) {
|
|
9553
9621
|
pendingEdges.push({ sourceId: id, sourceType: normalized.okf_type, edges: normalized.edges });
|
|
9554
9622
|
}
|
|
@@ -17388,7 +17456,8 @@ var WikiMemory = class {
|
|
|
17388
17456
|
const state = await this.ontologyService.getEffectiveState(entityId);
|
|
17389
17457
|
const engaged = canEngageWriteTyping(this.options.config, this.options.llmProvider, state.mode, state.manifest);
|
|
17390
17458
|
const writeContext = await this.ontologyService.buildWritePromptContext(entityId, { engaged });
|
|
17391
|
-
const
|
|
17459
|
+
const ingestEngaged = canEngageIngestTyping(this.options.config, this.options.llmProvider, state.mode, state.manifest);
|
|
17460
|
+
const ingestContext = ingestEngaged ? null : engaged ? await this.ontologyService.buildWritePromptContext(entityId, { engaged: false }) : writeContext;
|
|
17392
17461
|
const backfillContext = await this.ontologyService.buildPromptContext(entityId);
|
|
17393
17462
|
const { guidance, diagnostic } = PromptService.resolveGuidance(this.options.config, entityId);
|
|
17394
17463
|
if (diagnostic) {
|
|
@@ -19196,6 +19265,7 @@ exports.resolveResolveMinConfidence = resolveResolveMinConfidence;
|
|
|
19196
19265
|
exports.resolveSystemOneEdges = resolveSystemOneEdges;
|
|
19197
19266
|
exports.resolveSystemOneHealScreen = resolveSystemOneHealScreen;
|
|
19198
19267
|
exports.resolveSystemOneResolve = resolveSystemOneResolve;
|
|
19268
|
+
exports.resolveSystemOneTypeOnIngest = resolveSystemOneTypeOnIngest;
|
|
19199
19269
|
exports.resolveSystemOneTypeOnWrite = resolveSystemOneTypeOnWrite;
|
|
19200
19270
|
exports.resolveSystemOneTyping = resolveSystemOneTyping;
|
|
19201
19271
|
exports.resolveTypingMinConfidence = resolveTypingMinConfidence;
|