@equationalapplications/core-llm-wiki 9.16.1 → 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-7DBDJBN3.mjs → chunk-QRGFHMFR.mjs} +173 -62
- 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 +173 -60
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-C8sYdo2S.d.mts → testing-BDYXXgaJ.d.mts} +78 -10
- package/dist/{testing-C8sYdo2S.d.ts → testing-BDYXXgaJ.d.ts} +78 -10
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +778 -667
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-7DBDJBN3.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;
|
|
@@ -557,13 +567,19 @@ var UsageMeter = class {
|
|
|
557
567
|
constructor(budget) {
|
|
558
568
|
this.used = 0;
|
|
559
569
|
this.estimated = false;
|
|
570
|
+
this.heldTokens = 0;
|
|
560
571
|
if (budget !== void 0 && (typeof budget !== "number" || !Number.isFinite(budget) || budget < 0)) {
|
|
561
572
|
throw new TypeError("tokenBudget must be a finite number >= 0");
|
|
562
573
|
}
|
|
563
574
|
this.budget = budget;
|
|
564
575
|
}
|
|
576
|
+
/** Tokens held by in-flight reservations. */
|
|
577
|
+
get reserved() {
|
|
578
|
+
return this.heldTokens;
|
|
579
|
+
}
|
|
580
|
+
/** budget - used - reserved, clamped at 0; Infinity when unbounded. */
|
|
565
581
|
get remaining() {
|
|
566
|
-
return this.budget === void 0 ? Infinity : Math.max(0, this.budget - this.used);
|
|
582
|
+
return this.budget === void 0 ? Infinity : Math.max(0, this.budget - this.used - this.heldTokens);
|
|
567
583
|
}
|
|
568
584
|
fits(estimate) {
|
|
569
585
|
return estimate <= this.remaining;
|
|
@@ -572,6 +588,33 @@ var UsageMeter = class {
|
|
|
572
588
|
this.used += r.inputTokens + r.outputTokens;
|
|
573
589
|
if (r.estimated) this.estimated = true;
|
|
574
590
|
}
|
|
591
|
+
/**
|
|
592
|
+
* Admit a call on `estimate` (throws WikiBudgetExhausted when it does not
|
|
593
|
+
* fit the unreserved remainder) and hold `max(estimate, hold)` tokens until
|
|
594
|
+
* settle/release.
|
|
595
|
+
*/
|
|
596
|
+
reserve(estimate, hold) {
|
|
597
|
+
if (!this.fits(estimate)) throw new WikiBudgetExhausted(estimate, this.remaining);
|
|
598
|
+
const handle = { _brand: "UsageReservation", hold: Math.max(estimate, hold ?? estimate), open: true };
|
|
599
|
+
this.heldTokens += handle.hold;
|
|
600
|
+
return handle;
|
|
601
|
+
}
|
|
602
|
+
/** Free the hold, then charge the real usage. A closed handle is a no-op. */
|
|
603
|
+
settle(handle, actual) {
|
|
604
|
+
if (!this.close(handle)) return;
|
|
605
|
+
this.record(actual);
|
|
606
|
+
}
|
|
607
|
+
/** Free the hold and charge nothing. A closed handle is a no-op. */
|
|
608
|
+
release(handle) {
|
|
609
|
+
this.close(handle);
|
|
610
|
+
}
|
|
611
|
+
close(handle) {
|
|
612
|
+
const h = handle;
|
|
613
|
+
if (!h.open) return false;
|
|
614
|
+
h.open = false;
|
|
615
|
+
this.heldTokens -= h.hold;
|
|
616
|
+
return true;
|
|
617
|
+
}
|
|
575
618
|
};
|
|
576
619
|
var WikiBudgetExhausted = class _WikiBudgetExhausted extends Error {
|
|
577
620
|
constructor(requiredEstimate, remaining) {
|
|
@@ -584,6 +627,7 @@ var WikiBudgetExhausted = class _WikiBudgetExhausted extends Error {
|
|
|
584
627
|
};
|
|
585
628
|
|
|
586
629
|
// src/utils/llmCall.ts
|
|
630
|
+
var CLASSIFY_HOLD_FACTOR = 2;
|
|
587
631
|
function validUsage(u) {
|
|
588
632
|
if (!u || typeof u !== "object") return false;
|
|
589
633
|
const { inputTokens, outputTokens } = u;
|
|
@@ -591,25 +635,29 @@ function validUsage(u) {
|
|
|
591
635
|
}
|
|
592
636
|
async function callLlm(options, ctx, prompts) {
|
|
593
637
|
const promptEstimate = estimateTokens(prompts.systemPrompt) + estimateTokens(prompts.userPrompt);
|
|
594
|
-
if (ctx.meter && !ctx.meter.fits(promptEstimate)) {
|
|
595
|
-
throw new WikiBudgetExhausted(promptEstimate, ctx.meter.remaining);
|
|
596
|
-
}
|
|
597
638
|
const provider = options.llmProvider;
|
|
598
639
|
const params = { systemPrompt: prompts.systemPrompt, userPrompt: prompts.userPrompt };
|
|
599
640
|
let text;
|
|
600
|
-
let
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
641
|
+
let record;
|
|
642
|
+
const reservation = ctx.meter?.reserve(promptEstimate);
|
|
643
|
+
try {
|
|
644
|
+
let reported;
|
|
645
|
+
if (typeof provider.generateTextWithUsage === "function") {
|
|
646
|
+
const result = await provider.generateTextWithUsage(params);
|
|
647
|
+
if (!result || typeof result.text !== "string") {
|
|
648
|
+
throw new TypeError("generateTextWithUsage() must resolve to { text: string, usage? }");
|
|
649
|
+
}
|
|
650
|
+
text = result.text;
|
|
651
|
+
reported = validUsage(result.usage) ? result.usage : void 0;
|
|
652
|
+
} else {
|
|
653
|
+
text = await provider.generateText(params);
|
|
654
|
+
}
|
|
655
|
+
record = reported ? { inputTokens: reported.inputTokens, outputTokens: reported.outputTokens, estimated: false } : { inputTokens: promptEstimate, outputTokens: estimateTokens(text), estimated: true };
|
|
656
|
+
} catch (err) {
|
|
657
|
+
if (ctx.meter && reservation) ctx.meter.release(reservation);
|
|
658
|
+
throw err;
|
|
610
659
|
}
|
|
611
|
-
|
|
612
|
-
ctx.meter?.record(record);
|
|
660
|
+
if (ctx.meter && reservation) ctx.meter.settle(reservation, record);
|
|
613
661
|
if (options.config?.reportLlmUsage === true) {
|
|
614
662
|
emitDiagnostic(options, {
|
|
615
663
|
code: "llm_usage",
|
|
@@ -623,18 +671,23 @@ async function callLlm(options, ctx, prompts) {
|
|
|
623
671
|
}
|
|
624
672
|
async function callClassify(options, ctx, request) {
|
|
625
673
|
const inputEstimate = estimateTokens(request.state) + estimateTokens(JSON.stringify(request.questions));
|
|
626
|
-
if (ctx.meter && !ctx.meter.fits(inputEstimate)) {
|
|
627
|
-
throw new WikiBudgetExhausted(inputEstimate, ctx.meter.remaining);
|
|
628
|
-
}
|
|
629
674
|
const provider = options.llmProvider;
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
675
|
+
let response;
|
|
676
|
+
let record;
|
|
677
|
+
const reservation = ctx.meter?.reserve(inputEstimate, inputEstimate * CLASSIFY_HOLD_FACTOR);
|
|
678
|
+
try {
|
|
679
|
+
if (typeof provider.classify !== "function") {
|
|
680
|
+
throw new TypeError("callClassify requires a provider with classify()");
|
|
681
|
+
}
|
|
682
|
+
response = await provider.classify(request);
|
|
683
|
+
const reported = validUsage(response?.usage) ? response.usage : void 0;
|
|
684
|
+
const outputEstimate = estimateTokens(JSON.stringify(response?.answers ?? {}));
|
|
685
|
+
record = reported ? { inputTokens: reported.inputTokens, outputTokens: reported.outputTokens, estimated: false } : { inputTokens: inputEstimate, outputTokens: outputEstimate, estimated: true };
|
|
686
|
+
} catch (err) {
|
|
687
|
+
if (ctx.meter && reservation) ctx.meter.release(reservation);
|
|
688
|
+
throw err;
|
|
689
|
+
}
|
|
690
|
+
if (ctx.meter && reservation) ctx.meter.settle(reservation, record);
|
|
638
691
|
if (options.config?.reportLlmUsage === true) {
|
|
639
692
|
emitDiagnostic(options, {
|
|
640
693
|
code: "llm_usage",
|
|
@@ -1764,8 +1817,14 @@ function isManifestRepresentable(manifest) {
|
|
|
1764
1817
|
const slugs = manifest.node_types.map((n) => n.type);
|
|
1765
1818
|
return slugs.length > 0 && slugs.length + 1 <= CLASSIFIER_MAX_CHOICES && !slugs.some((s) => isReservedAbstainSlug(s));
|
|
1766
1819
|
}
|
|
1820
|
+
function typingEngages(site, provider, mode, manifest) {
|
|
1821
|
+
return site === "auto" && typeof provider.classify === "function" && mode !== "off" && isManifestRepresentable(manifest);
|
|
1822
|
+
}
|
|
1767
1823
|
function canEngageWriteTyping(config, provider, mode, manifest) {
|
|
1768
|
-
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);
|
|
1769
1828
|
}
|
|
1770
1829
|
function buildTypingQuestion(manifest) {
|
|
1771
1830
|
return {
|
|
@@ -1778,9 +1837,9 @@ function buildTypingQuestion(manifest) {
|
|
|
1778
1837
|
function volunteeredTypeResolves(rawOkfType, manifest) {
|
|
1779
1838
|
return typeof rawOkfType === "string" && resolveNodeTypeMatch(rawOkfType, manifest) !== null;
|
|
1780
1839
|
}
|
|
1781
|
-
async function classifyFactsForWrite(options, ctx, facts, manifest, floor) {
|
|
1840
|
+
async function classifyFactsForWrite(options, ctx, facts, manifest, floor, opts) {
|
|
1782
1841
|
const question = buildTypingQuestion(manifest);
|
|
1783
|
-
const rawConcurrency = options.config?.chunkConcurrency ?? 1;
|
|
1842
|
+
const rawConcurrency = opts?.concurrency ?? options.config?.chunkConcurrency ?? 1;
|
|
1784
1843
|
const concurrency = Number.isFinite(rawConcurrency) && rawConcurrency >= 1 ? Math.floor(rawConcurrency) : 1;
|
|
1785
1844
|
let stopped = false;
|
|
1786
1845
|
return withConcurrency(
|
|
@@ -1811,6 +1870,10 @@ async function classifyFactsForWrite(options, ctx, facts, manifest, floor) {
|
|
|
1811
1870
|
concurrency
|
|
1812
1871
|
);
|
|
1813
1872
|
}
|
|
1873
|
+
function toIngestCounters(c) {
|
|
1874
|
+
const { unattempted: _unattempted, ...rest } = c;
|
|
1875
|
+
return rest;
|
|
1876
|
+
}
|
|
1814
1877
|
function emptyTypingCounters() {
|
|
1815
1878
|
return { asked: 0, typed: 0, abstained: 0, lowConfidence: 0, invalid: 0, skipped: 0, unattempted: 0 };
|
|
1816
1879
|
}
|
|
@@ -8889,7 +8952,9 @@ var IngestionService = class {
|
|
|
8889
8952
|
}
|
|
8890
8953
|
const { chunks: chunks2, truncated } = chunkText(params.documentChunk, maxChunkLength, chunkOverlap);
|
|
8891
8954
|
if (chunks2.length === 0) return zeroChunkResult();
|
|
8892
|
-
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;
|
|
8893
8958
|
const { guidance, diagnostic } = PromptService.resolveGuidance(this.options.config, entityId);
|
|
8894
8959
|
if (diagnostic) {
|
|
8895
8960
|
emitDiagnostic(this.options, {
|
|
@@ -9045,16 +9110,42 @@ var IngestionService = class {
|
|
|
9045
9110
|
chunks: chunks2.length
|
|
9046
9111
|
});
|
|
9047
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
|
+
}
|
|
9048
9139
|
const insertedFacts = [];
|
|
9049
9140
|
const deletedSourceFactIds = [];
|
|
9050
9141
|
try {
|
|
9051
9142
|
if (failedChunks === 0) {
|
|
9052
9143
|
const fullResult = await this.db.withTransactionAsync(async (tx) => {
|
|
9053
|
-
return await this.runFullUpsertGraph(entityId, sourceRef, sourceHash, orderedChunkFacts, tx, diagBuffer, factLedger);
|
|
9144
|
+
return await this.runFullUpsertGraph(entityId, sourceRef, sourceHash, orderedChunkFacts, tx, diagBuffer, factLedger, typing);
|
|
9054
9145
|
});
|
|
9055
9146
|
deletedSourceFactIds.push(...fullResult.deletedSourceFactIds);
|
|
9056
9147
|
insertedFacts.push(...fullResult.insertedFacts);
|
|
9057
|
-
if (
|
|
9148
|
+
if (hoistedState.mode !== "off" && insertedFacts.length === 0 && deletedSourceFactIds.length > 0) {
|
|
9058
9149
|
diagBuffer.push({
|
|
9059
9150
|
entityId,
|
|
9060
9151
|
operation: "ingest",
|
|
@@ -9067,7 +9158,7 @@ var IngestionService = class {
|
|
|
9067
9158
|
const partialResult = await this.db.withTransactionAsync(async (tx) => {
|
|
9068
9159
|
const flat = [];
|
|
9069
9160
|
for (const slot of orderedChunkFacts) flat.push(...slot.facts);
|
|
9070
|
-
return await this.appendPartialFacts(entityId, sourceRef, flat, tx, diagBuffer, factLedger);
|
|
9161
|
+
return await this.appendPartialFacts(entityId, sourceRef, flat, tx, diagBuffer, factLedger, typing);
|
|
9071
9162
|
});
|
|
9072
9163
|
insertedFacts.push(...partialResult.insertedDescriptors);
|
|
9073
9164
|
}
|
|
@@ -9119,6 +9210,7 @@ var IngestionService = class {
|
|
|
9119
9210
|
failedChunks
|
|
9120
9211
|
};
|
|
9121
9212
|
if (failedChunks > 0) result.parseFailures = failures;
|
|
9213
|
+
if (engaged) result.typing = toIngestCounters(typing.counters);
|
|
9122
9214
|
return result;
|
|
9123
9215
|
} finally {
|
|
9124
9216
|
releaseIngestLocks();
|
|
@@ -9328,10 +9420,11 @@ var IngestionService = class {
|
|
|
9328
9420
|
* On the partial path the caller never invokes this method; the empty
|
|
9329
9421
|
* arrays stay empty.
|
|
9330
9422
|
*/
|
|
9331
|
-
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) {
|
|
9332
9424
|
const deletedSourceFactIds = [];
|
|
9333
9425
|
const insertedFacts = [];
|
|
9334
9426
|
const nodeTrust = /* @__PURE__ */ new Map();
|
|
9427
|
+
const diagBase = { entityId, operation: "ingest", trigger: "call" };
|
|
9335
9428
|
deletedSourceFactIds.push(...await this.entryRepo.findIdsBySource(entityId, sourceRef, null, tx, false));
|
|
9336
9429
|
const titleIndex = /* @__PURE__ */ new Map();
|
|
9337
9430
|
const existingFacts = await this.entryRepo.findRecentByEntityId(entityId, 500, tx, sourceRef);
|
|
@@ -9345,6 +9438,7 @@ var IngestionService = class {
|
|
|
9345
9438
|
let { mode, manifest } = ontologyState;
|
|
9346
9439
|
const hostNodes = [];
|
|
9347
9440
|
const rawEdgeRequests = [];
|
|
9441
|
+
const typedAtDoor = [];
|
|
9348
9442
|
const now = Date.now();
|
|
9349
9443
|
for (const { facts, ontology_updates } of orderedChunkFacts) {
|
|
9350
9444
|
if (mode === "emergent" && ontology_updates && this.ontologyService) {
|
|
@@ -9364,14 +9458,15 @@ var IngestionService = class {
|
|
|
9364
9458
|
for (const fact of facts) {
|
|
9365
9459
|
const ontologyFact = fact;
|
|
9366
9460
|
const id = generateId("fact_");
|
|
9367
|
-
const
|
|
9368
|
-
const
|
|
9369
|
-
|
|
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) {
|
|
9370
9465
|
diagBuffer.push(edgeDropDiagnostic(drop, { entityId, operation: "ingest", trigger: "call", sourceRef, factId: id }));
|
|
9371
9466
|
}
|
|
9372
|
-
|
|
9467
|
+
const hostNode = {
|
|
9373
9468
|
id,
|
|
9374
|
-
type:
|
|
9469
|
+
type: "",
|
|
9375
9470
|
title: fact.title,
|
|
9376
9471
|
body: fact.body,
|
|
9377
9472
|
// Forward the LLM-extracted tags/confidence through the
|
|
@@ -9383,18 +9478,20 @@ var IngestionService = class {
|
|
|
9383
9478
|
// 'certain' as documented.
|
|
9384
9479
|
tags: fact.tags,
|
|
9385
9480
|
confidence: fact.confidence
|
|
9386
|
-
}
|
|
9481
|
+
};
|
|
9482
|
+
hostNodes.push(hostNode);
|
|
9483
|
+
typedAtDoor.push({ node: hostNode, fact: ontologyFact, id, outcome, slotType: normalized.okf_type });
|
|
9387
9484
|
const locator = factLedger.get(fact);
|
|
9388
9485
|
if (locator?.verdict) {
|
|
9389
|
-
const
|
|
9390
|
-
nodeTrust.set(id,
|
|
9391
|
-
if (
|
|
9486
|
+
const outcome2 = groundingOutcome(locator.verdict, now);
|
|
9487
|
+
nodeTrust.set(id, outcome2.trust);
|
|
9488
|
+
if (outcome2.diagnostic) {
|
|
9392
9489
|
diagBuffer.push({
|
|
9393
9490
|
entityId,
|
|
9394
9491
|
operation: "ingest",
|
|
9395
9492
|
trigger: "call",
|
|
9396
|
-
code:
|
|
9397
|
-
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 }
|
|
9398
9495
|
});
|
|
9399
9496
|
}
|
|
9400
9497
|
}
|
|
@@ -9405,6 +9502,18 @@ var IngestionService = class {
|
|
|
9405
9502
|
}
|
|
9406
9503
|
}
|
|
9407
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
|
+
}
|
|
9408
9517
|
const hostEdges = [];
|
|
9409
9518
|
for (const req of rawEdgeRequests) {
|
|
9410
9519
|
const resolveDrops = [];
|
|
@@ -9425,6 +9534,7 @@ var IngestionService = class {
|
|
|
9425
9534
|
hostEdges.push({ type: e.edge_type, sourceId: e.source_id, targetId: e.target_id });
|
|
9426
9535
|
}
|
|
9427
9536
|
}
|
|
9537
|
+
for (const receipt of doorReceipts) diagBuffer.push(receipt);
|
|
9428
9538
|
await this.upsertGraphCore(
|
|
9429
9539
|
entityId,
|
|
9430
9540
|
{ sourceRef, sourceHash, nodes: hostNodes, edges: hostEdges },
|
|
@@ -9453,7 +9563,7 @@ var IngestionService = class {
|
|
|
9453
9563
|
* Runs INSIDE the caller's `tx`. Does not open a nested transaction.
|
|
9454
9564
|
* Returns `{ inserted, skippedDuplicate }` for observability.
|
|
9455
9565
|
*/
|
|
9456
|
-
async appendPartialFacts(entityId, sourceRef, dedupedFacts, tx, diagBuffer, factLedger = /* @__PURE__ */ new Map()) {
|
|
9566
|
+
async appendPartialFacts(entityId, sourceRef, dedupedFacts, tx, diagBuffer, factLedger = /* @__PURE__ */ new Map(), typing) {
|
|
9457
9567
|
const liveIds = await this.entryRepo.findIdsBySource(entityId, sourceRef, null, tx, false);
|
|
9458
9568
|
const liveFacts = liveIds.length === 0 ? [] : await this.entryRepo.findByIds(liveIds, void 0, tx);
|
|
9459
9569
|
const liveTitles = new Set(liveFacts.map((f) => normalizeTitleKey(f.title)));
|
|
@@ -9464,6 +9574,7 @@ var IngestionService = class {
|
|
|
9464
9574
|
for (const f of indexedFacts) {
|
|
9465
9575
|
titleIndex.set(normalizeTitleKey(f.title), { id: f.id, okf_type: f.okf_type ?? null });
|
|
9466
9576
|
}
|
|
9577
|
+
const diagBase = { entityId, operation: "ingest", trigger: "call" };
|
|
9467
9578
|
const pendingEdges = [];
|
|
9468
9579
|
let inserted = 0;
|
|
9469
9580
|
let skippedDuplicate = 0;
|
|
@@ -9490,22 +9601,22 @@ var IngestionService = class {
|
|
|
9490
9601
|
});
|
|
9491
9602
|
}
|
|
9492
9603
|
const ontologyFact = fact;
|
|
9493
|
-
const validationDrops =
|
|
9494
|
-
|
|
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
|
+
);
|
|
9495
9613
|
for (const drop of validationDrops) {
|
|
9496
9614
|
diagBuffer.push(edgeDropDiagnostic(drop, { entityId, operation: "ingest", trigger: "call", sourceRef, factId: id }));
|
|
9497
9615
|
}
|
|
9498
|
-
|
|
9499
|
-
|
|
9500
|
-
{ entityId, operation: "ingest", trigger: "call" },
|
|
9501
|
-
id,
|
|
9502
|
-
ontologyFact.okf_type ?? "",
|
|
9503
|
-
normalized.okf_type,
|
|
9504
|
-
normalized.match
|
|
9505
|
-
)) {
|
|
9506
|
-
diagBuffer.push({ ...receipt, detail: { ...receipt.detail, sourceRef } });
|
|
9507
|
-
}
|
|
9616
|
+
for (const receipt of receipts) {
|
|
9617
|
+
diagBuffer.push({ ...receipt, detail: { ...receipt.detail, sourceRef } });
|
|
9508
9618
|
}
|
|
9619
|
+
if (typedByClassifier && typing) typing.counters.typed++;
|
|
9509
9620
|
if (normalized.edges.length > 0) {
|
|
9510
9621
|
pendingEdges.push({ sourceId: id, sourceType: normalized.okf_type, edges: normalized.edges });
|
|
9511
9622
|
}
|
|
@@ -17345,7 +17456,8 @@ var WikiMemory = class {
|
|
|
17345
17456
|
const state = await this.ontologyService.getEffectiveState(entityId);
|
|
17346
17457
|
const engaged = canEngageWriteTyping(this.options.config, this.options.llmProvider, state.mode, state.manifest);
|
|
17347
17458
|
const writeContext = await this.ontologyService.buildWritePromptContext(entityId, { engaged });
|
|
17348
|
-
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;
|
|
17349
17461
|
const backfillContext = await this.ontologyService.buildPromptContext(entityId);
|
|
17350
17462
|
const { guidance, diagnostic } = PromptService.resolveGuidance(this.options.config, entityId);
|
|
17351
17463
|
if (diagnostic) {
|
|
@@ -19153,6 +19265,7 @@ exports.resolveResolveMinConfidence = resolveResolveMinConfidence;
|
|
|
19153
19265
|
exports.resolveSystemOneEdges = resolveSystemOneEdges;
|
|
19154
19266
|
exports.resolveSystemOneHealScreen = resolveSystemOneHealScreen;
|
|
19155
19267
|
exports.resolveSystemOneResolve = resolveSystemOneResolve;
|
|
19268
|
+
exports.resolveSystemOneTypeOnIngest = resolveSystemOneTypeOnIngest;
|
|
19156
19269
|
exports.resolveSystemOneTypeOnWrite = resolveSystemOneTypeOnWrite;
|
|
19157
19270
|
exports.resolveSystemOneTyping = resolveSystemOneTyping;
|
|
19158
19271
|
exports.resolveTypingMinConfidence = resolveTypingMinConfidence;
|