@equationalapplications/core-llm-wiki 9.11.0 → 9.12.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-QUVPQVJ6.mjs → chunk-KB37MGFF.mjs} +196 -22
- package/dist/chunk-KB37MGFF.mjs.map +1 -0
- package/dist/index.d.mts +17 -3
- package/dist/index.d.ts +17 -3
- package/dist/index.js +195 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-DFyghdSG.d.mts → testing-imNjsm-X.d.mts} +26 -6
- package/dist/{testing-DFyghdSG.d.ts → testing-imNjsm-X.d.ts} +26 -6
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +193 -19
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-QUVPQVJ6.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 LLMProvider, N as LibrarianConfig, P as LibrarianGateConfig, Q as LockedMaintenanceJob, T as MaintenanceJob, U as MaintenanceStopReason, V as MemoryDumpEntity, X as MigrationPolicy, Y as ONTOLOGY_ABSTAIN_SENTINEL, Z as ONTOLOGY_BACKFILL_BATCH_SIZE, _ as ONTOLOGY_BACKFILL_RECHECK_MS, $ as OntologyBackfillResult, a0 as OntologyEdgeType, a1 as OntologyManifest, a2 as OntologyNodeType, a3 as OntologyPromptContext, a4 as OntologyUpdates, a5 as PendingMaintenance, a6 as PendingMigrationWork, a7 as PendingSourceStatus, a8 as PromptOverrides, a9 as PromptService, aa as PrunePartialFailureError, ab as ReembedResult, ac as RememberInput, ad as RunPendingMaintenanceOptions, ae as RunPendingMaintenanceResult, af as SourcePassage, ag as StoreSourceResult, ah as StoredSource, ai as StoredSourceDump, aj as StoredSourceSummary, ak as SupersedeReplacement, al as SystemOneConfig, am as SystemOneThresholdSite, an as VectorRanker, ao as VectorRankerFallback, ap as VectorRankerRankArgs, aq as VectorRankerSemanticResult, ar as WikiBusyError, as as WikiBusyOperation, at as WikiCheckpoint, au as WikiDiagnostic, av as WikiDiagnosticCode, aw as WikiDiagnosticDetail, ax as WikiDiagnosticOperation, ay as WikiDiagnosticSeverity, az as WikiDiagnosticTrigger, aA as WikiDraftNotFound, aB as WikiDuplicateHashError, aC as WikiEdge, aD as WikiEvent, aE as WikiExternalDeletionError, aF as WikiFact, aG as WikiGraphNodeOwnershipConflict, aH as WikiIngestEmptyError, aI as WikiInstructions, aJ as WikiInvalidReadOptions, aK as WikiLintReport, aL as WikiMemoryTestAccess, aM as WikiMigrationRequiredError, aN as WikiOutboxEvent, aO as WikiParseError, aP as WikiSearchUnavailableError, aQ as WikiSourcePointer, aR as WikiSourceRefHashCollision, aS as WikiStrictOntologyViolation, aT as WikiSupersedeError, aU as WikiSupersedeReason, aV as WikiTask, aW as WikiTransactionError, aX as isReservedAbstainSlug, aY as isWikiSearchUnavailableError, aZ as validateManifest } from './testing-
|
|
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-imNjsm-X.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 LLMProvider, N as LibrarianConfig, P as LibrarianGateConfig, Q as LockedMaintenanceJob, T as MaintenanceJob, U as MaintenanceStopReason, V as MemoryDumpEntity, X as MigrationPolicy, Y as ONTOLOGY_ABSTAIN_SENTINEL, Z as ONTOLOGY_BACKFILL_BATCH_SIZE, _ as ONTOLOGY_BACKFILL_RECHECK_MS, $ as OntologyBackfillResult, a0 as OntologyEdgeType, a1 as OntologyManifest, a2 as OntologyNodeType, a3 as OntologyPromptContext, a4 as OntologyUpdates, a5 as PendingMaintenance, a6 as PendingMigrationWork, a7 as PendingSourceStatus, a8 as PromptOverrides, a9 as PromptService, aa as PrunePartialFailureError, ab as ReembedResult, ac as RememberInput, ad as RunPendingMaintenanceOptions, ae as RunPendingMaintenanceResult, af as SourcePassage, ag as StoreSourceResult, ah as StoredSource, ai as StoredSourceDump, aj as StoredSourceSummary, ak as SupersedeReplacement, al as SystemOneConfig, am as SystemOneThresholdSite, an as VectorRanker, ao as VectorRankerFallback, ap as VectorRankerRankArgs, aq as VectorRankerSemanticResult, ar as WikiBusyError, as as WikiBusyOperation, at as WikiCheckpoint, au as WikiDiagnostic, av as WikiDiagnosticCode, aw as WikiDiagnosticDetail, ax as WikiDiagnosticOperation, ay as WikiDiagnosticSeverity, az as WikiDiagnosticTrigger, aA as WikiDraftNotFound, aB as WikiDuplicateHashError, aC as WikiEdge, aD as WikiEvent, aE as WikiExternalDeletionError, aF as WikiFact, aG as WikiGraphNodeOwnershipConflict, aH as WikiIngestEmptyError, aI as WikiInstructions, aJ as WikiInvalidReadOptions, aK as WikiLintReport, aL as WikiMemoryTestAccess, aM as WikiMigrationRequiredError, aN as WikiOutboxEvent, aO as WikiParseError, aP as WikiSearchUnavailableError, aQ as WikiSourcePointer, aR as WikiSourceRefHashCollision, aS as WikiStrictOntologyViolation, aT as WikiSupersedeError, aU as WikiSupersedeReason, aV as WikiTask, aW as WikiTransactionError, aX as isReservedAbstainSlug, aY as isWikiSearchUnavailableError, aZ as validateManifest } from './testing-imNjsm-X.mjs';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -234,6 +234,12 @@ declare function warnOnce(message: string): void;
|
|
|
234
234
|
* `??` throughout — falsy config values never participate by accident.
|
|
235
235
|
*/
|
|
236
236
|
declare function resolveSystemOneTyping(config: WikiConfig | undefined, classifierCallOption?: 'auto' | 'llm'): 'auto' | 'llm';
|
|
237
|
+
/**
|
|
238
|
+
* Edge-mode resolution (specs/edge-suggestions-system-one §2): `systemOne.edges`
|
|
239
|
+
* → `'llm'`. A present non-`'auto'`/non-`'llm'` value warns once and is treated
|
|
240
|
+
* as unset. No legacy chain and no call option.
|
|
241
|
+
*/
|
|
242
|
+
declare function resolveSystemOneEdges(config: WikiConfig | undefined): 'auto' | 'llm';
|
|
237
243
|
/** Engine default confidence floor for classifier typing. */
|
|
238
244
|
declare const DEFAULT_TYPING_MIN_CONFIDENCE: 0.5;
|
|
239
245
|
/**
|
|
@@ -243,10 +249,18 @@ declare const DEFAULT_TYPING_MIN_CONFIDENCE: 0.5;
|
|
|
243
249
|
* typing path reads this; call it there, never on the generative path.
|
|
244
250
|
*/
|
|
245
251
|
declare function resolveTypingMinConfidence(config: WikiConfig | undefined): number;
|
|
252
|
+
/**
|
|
253
|
+
* Edge-screen floor (specs/edge-suggestions-system-one §3): returns the
|
|
254
|
+
* `systemOne.minConfidence.edges` floor only when the edge mode resolves
|
|
255
|
+
* `'auto'` and the floor is a finite number in [0.5, 1]. There is no default
|
|
256
|
+
* floor: a missing or out-of-domain value warns once and returns `undefined`
|
|
257
|
+
* (the site then resolves `'llm'`). Under `'llm'` or unset it reads nothing.
|
|
258
|
+
*/
|
|
259
|
+
declare function resolveEdgesMinConfidence(config: WikiConfig | undefined): number | undefined;
|
|
246
260
|
|
|
247
261
|
declare const ONTOLOGY_BACKFILL_SYSTEM_PROMPT = "You are a knowledge classification agent. You will receive existing memory facts that currently have no ontology type. For each input fact { \"id\", \"title\", \"body\", \"tags\" }, assign the best matching okf_type from the ontology manifest and optionally propose edges to related facts by title.\nReturn ONLY a valid JSON object matching this schema:\n{\n \"classifications\": [\n { \"id\": \"string (input fact id, copied verbatim)\", \"okf_type\": \"string (manifest node type slug)\", \"edges\": [{ \"edge_type\": \"string\", \"target_title\": \"string\" }] }\n ]\n}\nIf no manifest type fits a fact, assign the closest type the fact is an example of; omit that fact from \"classifications\" only when no type applies even broadly. Use the manifest slug EXACTLY as spelled (spelling variants are folded to the manifest form).\nWhen echoing an existing fact's title verbatim into \"target_title\", preserve every JSON escape sequence (\\\", \\n, \\\\, \\/) exactly as it appeared in the input body \u2014 do not strip backslashes, do not add unescaped quotes. Do not return markdown, just raw JSON.";
|
|
248
262
|
|
|
249
263
|
declare function createWiki(db: SQLiteAdapter, options: WikiOptions): WikiMemory;
|
|
250
264
|
|
|
251
|
-
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, resolveMaxPromptChars, resolveOntologyJobDefaults, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateLibrarianPromptTemplate, warnOnce };
|
|
265
|
+
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, resolveMaxPromptChars, resolveOntologyJobDefaults, resolveSystemOneEdges, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateLibrarianPromptTemplate, warnOnce };
|
|
252
266
|
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 LLMProvider, N as LibrarianConfig, P as LibrarianGateConfig, Q as LockedMaintenanceJob, T as MaintenanceJob, U as MaintenanceStopReason, V as MemoryDumpEntity, X as MigrationPolicy, Y as ONTOLOGY_ABSTAIN_SENTINEL, Z as ONTOLOGY_BACKFILL_BATCH_SIZE, _ as ONTOLOGY_BACKFILL_RECHECK_MS, $ as OntologyBackfillResult, a0 as OntologyEdgeType, a1 as OntologyManifest, a2 as OntologyNodeType, a3 as OntologyPromptContext, a4 as OntologyUpdates, a5 as PendingMaintenance, a6 as PendingMigrationWork, a7 as PendingSourceStatus, a8 as PromptOverrides, a9 as PromptService, aa as PrunePartialFailureError, ab as ReembedResult, ac as RememberInput, ad as RunPendingMaintenanceOptions, ae as RunPendingMaintenanceResult, af as SourcePassage, ag as StoreSourceResult, ah as StoredSource, ai as StoredSourceDump, aj as StoredSourceSummary, ak as SupersedeReplacement, al as SystemOneConfig, am as SystemOneThresholdSite, an as VectorRanker, ao as VectorRankerFallback, ap as VectorRankerRankArgs, aq as VectorRankerSemanticResult, ar as WikiBusyError, as as WikiBusyOperation, at as WikiCheckpoint, au as WikiDiagnostic, av as WikiDiagnosticCode, aw as WikiDiagnosticDetail, ax as WikiDiagnosticOperation, ay as WikiDiagnosticSeverity, az as WikiDiagnosticTrigger, aA as WikiDraftNotFound, aB as WikiDuplicateHashError, aC as WikiEdge, aD as WikiEvent, aE as WikiExternalDeletionError, aF as WikiFact, aG as WikiGraphNodeOwnershipConflict, aH as WikiIngestEmptyError, aI as WikiInstructions, aJ as WikiInvalidReadOptions, aK as WikiLintReport, aL as WikiMemoryTestAccess, aM as WikiMigrationRequiredError, aN as WikiOutboxEvent, aO as WikiParseError, aP as WikiSearchUnavailableError, aQ as WikiSourcePointer, aR as WikiSourceRefHashCollision, aS as WikiStrictOntologyViolation, aT as WikiSupersedeError, aU as WikiSupersedeReason, aV as WikiTask, aW as WikiTransactionError, aX as isReservedAbstainSlug, aY as isWikiSearchUnavailableError, aZ as validateManifest } from './testing-
|
|
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-imNjsm-X.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 LLMProvider, N as LibrarianConfig, P as LibrarianGateConfig, Q as LockedMaintenanceJob, T as MaintenanceJob, U as MaintenanceStopReason, V as MemoryDumpEntity, X as MigrationPolicy, Y as ONTOLOGY_ABSTAIN_SENTINEL, Z as ONTOLOGY_BACKFILL_BATCH_SIZE, _ as ONTOLOGY_BACKFILL_RECHECK_MS, $ as OntologyBackfillResult, a0 as OntologyEdgeType, a1 as OntologyManifest, a2 as OntologyNodeType, a3 as OntologyPromptContext, a4 as OntologyUpdates, a5 as PendingMaintenance, a6 as PendingMigrationWork, a7 as PendingSourceStatus, a8 as PromptOverrides, a9 as PromptService, aa as PrunePartialFailureError, ab as ReembedResult, ac as RememberInput, ad as RunPendingMaintenanceOptions, ae as RunPendingMaintenanceResult, af as SourcePassage, ag as StoreSourceResult, ah as StoredSource, ai as StoredSourceDump, aj as StoredSourceSummary, ak as SupersedeReplacement, al as SystemOneConfig, am as SystemOneThresholdSite, an as VectorRanker, ao as VectorRankerFallback, ap as VectorRankerRankArgs, aq as VectorRankerSemanticResult, ar as WikiBusyError, as as WikiBusyOperation, at as WikiCheckpoint, au as WikiDiagnostic, av as WikiDiagnosticCode, aw as WikiDiagnosticDetail, ax as WikiDiagnosticOperation, ay as WikiDiagnosticSeverity, az as WikiDiagnosticTrigger, aA as WikiDraftNotFound, aB as WikiDuplicateHashError, aC as WikiEdge, aD as WikiEvent, aE as WikiExternalDeletionError, aF as WikiFact, aG as WikiGraphNodeOwnershipConflict, aH as WikiIngestEmptyError, aI as WikiInstructions, aJ as WikiInvalidReadOptions, aK as WikiLintReport, aL as WikiMemoryTestAccess, aM as WikiMigrationRequiredError, aN as WikiOutboxEvent, aO as WikiParseError, aP as WikiSearchUnavailableError, aQ as WikiSourcePointer, aR as WikiSourceRefHashCollision, aS as WikiStrictOntologyViolation, aT as WikiSupersedeError, aU as WikiSupersedeReason, aV as WikiTask, aW as WikiTransactionError, aX as isReservedAbstainSlug, aY as isWikiSearchUnavailableError, aZ as validateManifest } from './testing-imNjsm-X.js';
|
|
3
3
|
import { OkfFile } from '@equationalapplications/core-okf';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -234,6 +234,12 @@ declare function warnOnce(message: string): void;
|
|
|
234
234
|
* `??` throughout — falsy config values never participate by accident.
|
|
235
235
|
*/
|
|
236
236
|
declare function resolveSystemOneTyping(config: WikiConfig | undefined, classifierCallOption?: 'auto' | 'llm'): 'auto' | 'llm';
|
|
237
|
+
/**
|
|
238
|
+
* Edge-mode resolution (specs/edge-suggestions-system-one §2): `systemOne.edges`
|
|
239
|
+
* → `'llm'`. A present non-`'auto'`/non-`'llm'` value warns once and is treated
|
|
240
|
+
* as unset. No legacy chain and no call option.
|
|
241
|
+
*/
|
|
242
|
+
declare function resolveSystemOneEdges(config: WikiConfig | undefined): 'auto' | 'llm';
|
|
237
243
|
/** Engine default confidence floor for classifier typing. */
|
|
238
244
|
declare const DEFAULT_TYPING_MIN_CONFIDENCE: 0.5;
|
|
239
245
|
/**
|
|
@@ -243,10 +249,18 @@ declare const DEFAULT_TYPING_MIN_CONFIDENCE: 0.5;
|
|
|
243
249
|
* typing path reads this; call it there, never on the generative path.
|
|
244
250
|
*/
|
|
245
251
|
declare function resolveTypingMinConfidence(config: WikiConfig | undefined): number;
|
|
252
|
+
/**
|
|
253
|
+
* Edge-screen floor (specs/edge-suggestions-system-one §3): returns the
|
|
254
|
+
* `systemOne.minConfidence.edges` floor only when the edge mode resolves
|
|
255
|
+
* `'auto'` and the floor is a finite number in [0.5, 1]. There is no default
|
|
256
|
+
* floor: a missing or out-of-domain value warns once and returns `undefined`
|
|
257
|
+
* (the site then resolves `'llm'`). Under `'llm'` or unset it reads nothing.
|
|
258
|
+
*/
|
|
259
|
+
declare function resolveEdgesMinConfidence(config: WikiConfig | undefined): number | undefined;
|
|
246
260
|
|
|
247
261
|
declare const ONTOLOGY_BACKFILL_SYSTEM_PROMPT = "You are a knowledge classification agent. You will receive existing memory facts that currently have no ontology type. For each input fact { \"id\", \"title\", \"body\", \"tags\" }, assign the best matching okf_type from the ontology manifest and optionally propose edges to related facts by title.\nReturn ONLY a valid JSON object matching this schema:\n{\n \"classifications\": [\n { \"id\": \"string (input fact id, copied verbatim)\", \"okf_type\": \"string (manifest node type slug)\", \"edges\": [{ \"edge_type\": \"string\", \"target_title\": \"string\" }] }\n ]\n}\nIf no manifest type fits a fact, assign the closest type the fact is an example of; omit that fact from \"classifications\" only when no type applies even broadly. Use the manifest slug EXACTLY as spelled (spelling variants are folded to the manifest form).\nWhen echoing an existing fact's title verbatim into \"target_title\", preserve every JSON escape sequence (\\\", \\n, \\\\, \\/) exactly as it appeared in the input body \u2014 do not strip backslashes, do not add unescaped quotes. Do not return markdown, just raw JSON.";
|
|
248
262
|
|
|
249
263
|
declare function createWiki(db: SQLiteAdapter, options: WikiOptions): WikiMemory;
|
|
250
264
|
|
|
251
|
-
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, resolveMaxPromptChars, resolveOntologyJobDefaults, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateLibrarianPromptTemplate, warnOnce };
|
|
265
|
+
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, resolveMaxPromptChars, resolveOntologyJobDefaults, resolveSystemOneEdges, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateLibrarianPromptTemplate, warnOnce };
|
|
252
266
|
export type { ContextBudget, FormatOkfBundleOptions, LibrarianOptions, LibrarianPromptVariables, OkfFormatProfile, OkfImportOptions };
|
package/dist/index.js
CHANGED
|
@@ -9163,6 +9163,16 @@ function resolveSystemOneTyping(config, classifierCallOption) {
|
|
|
9163
9163
|
}
|
|
9164
9164
|
return classifierCallOption ?? (systemOneValid ? systemOne.typing : void 0) ?? (legacyValid ? legacy : void 0) ?? "llm";
|
|
9165
9165
|
}
|
|
9166
|
+
function resolveSystemOneEdges(config) {
|
|
9167
|
+
const edges = config?.systemOne?.edges;
|
|
9168
|
+
if (edges !== void 0 && !isTypingMode(edges)) {
|
|
9169
|
+
warnOnce(
|
|
9170
|
+
`[core-llm-wiki] systemOne: \`systemOne.edges\` is ${formatConfigValue(edges)}, which is not 'auto' or 'llm'. The key is treated as unset; the default ('llm') applies.`
|
|
9171
|
+
);
|
|
9172
|
+
return "llm";
|
|
9173
|
+
}
|
|
9174
|
+
return edges ?? "llm";
|
|
9175
|
+
}
|
|
9166
9176
|
var DEFAULT_SHORTLIST_K = 10;
|
|
9167
9177
|
function resolveShortlistK(config) {
|
|
9168
9178
|
const k = config?.ontology?.shortlistK;
|
|
@@ -9192,6 +9202,16 @@ function resolveTypingMinConfidence(config) {
|
|
|
9192
9202
|
}
|
|
9193
9203
|
return (systemOneValid ? systemOneFloor : void 0) ?? (legacyValid ? legacyFloor : void 0) ?? DEFAULT_TYPING_MIN_CONFIDENCE;
|
|
9194
9204
|
}
|
|
9205
|
+
var isEdgesFloor = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0.5 && v <= 1;
|
|
9206
|
+
function resolveEdgesMinConfidence(config) {
|
|
9207
|
+
if (resolveSystemOneEdges(config) !== "auto") return void 0;
|
|
9208
|
+
const floor = config?.systemOne?.minConfidence?.edges;
|
|
9209
|
+
if (isEdgesFloor(floor)) return floor;
|
|
9210
|
+
warnOnce(
|
|
9211
|
+
floor === void 0 ? "[core-llm-wiki] systemOne: `systemOne.minConfidence.edges` is required when `systemOne.edges` is 'auto'. The edge screen is off for this site; edges stay on the generative path." : `[core-llm-wiki] systemOne: \`systemOne.minConfidence.edges\` is ${formatConfigValue(floor)}, which is not a finite number in [0.5, 1]. The edge screen is off for this site; edges stay on the generative path.`
|
|
9212
|
+
);
|
|
9213
|
+
return void 0;
|
|
9214
|
+
}
|
|
9195
9215
|
|
|
9196
9216
|
// src/repositories/VectorRemovalRepository.ts
|
|
9197
9217
|
var CHUNK2 = 500;
|
|
@@ -12334,7 +12354,10 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
12334
12354
|
return { ...zeroed, remaining: counts.eligible, deferred: counts.deferred };
|
|
12335
12355
|
}
|
|
12336
12356
|
const classifierMode = resolveSystemOneTyping(this.options.config, options?.classifier);
|
|
12357
|
+
const edgeMode = resolveSystemOneEdges(this.options.config);
|
|
12337
12358
|
const classify = this.options.llmProvider.classify;
|
|
12359
|
+
const edgeMinConfidence = edgeMode === "auto" && classifierMode === "auto" && typeof classify === "function" ? resolveEdgesMinConfidence(this.options.config) : void 0;
|
|
12360
|
+
const edgeSiteMode = edgeMode === "auto" && typeof edgeMinConfidence === "number" ? "auto" : "llm";
|
|
12338
12361
|
if (classifierMode === "auto" && typeof classify === "function") {
|
|
12339
12362
|
const slugs = effectiveManifest.node_types.map((n) => n.type);
|
|
12340
12363
|
if (slugs.length > 0 && slugs.length + 1 <= CLASSIFIER_MAX_CHOICES && !slugs.some((s) => isReservedAbstainSlug(s))) {
|
|
@@ -12345,16 +12368,29 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
12345
12368
|
now,
|
|
12346
12369
|
recheckCutoff,
|
|
12347
12370
|
options?.meter,
|
|
12348
|
-
trigger
|
|
12371
|
+
trigger,
|
|
12372
|
+
shortlistK,
|
|
12373
|
+
edgeSiteMode,
|
|
12374
|
+
edgeMinConfidence
|
|
12349
12375
|
);
|
|
12350
12376
|
if (classifierRun.abortedOntologyOff || classifierRun.result.budgetStop) {
|
|
12351
12377
|
return classifierRun.result;
|
|
12352
12378
|
}
|
|
12353
|
-
if (classifierRun.escalated.length > 0
|
|
12379
|
+
if (classifierRun.escalated.length > 0) {
|
|
12354
12380
|
const { mode: liveMode } = await ontologyService.getEffectiveState(entityId);
|
|
12355
12381
|
if (liveMode === "off") {
|
|
12356
12382
|
const counts = await this.entryRepo.countUntypedByEntityId(entityId, recheckCutoff);
|
|
12357
|
-
|
|
12383
|
+
const committed = classifierRun.result;
|
|
12384
|
+
return {
|
|
12385
|
+
scanned: committed.scanned,
|
|
12386
|
+
typed: committed.typed,
|
|
12387
|
+
failedValidation: committed.failedValidation,
|
|
12388
|
+
edgesAdded: committed.edgesAdded,
|
|
12389
|
+
abstained: committed.abstained,
|
|
12390
|
+
skipped: committed.skipped,
|
|
12391
|
+
remaining: 0,
|
|
12392
|
+
deferred: counts.deferred
|
|
12393
|
+
};
|
|
12358
12394
|
}
|
|
12359
12395
|
const escalated = classifierRun.escalated;
|
|
12360
12396
|
const generative = await this._runGenerativeBackfill(entityId, escalated, {
|
|
@@ -12364,7 +12400,9 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
12364
12400
|
batchSize: escalated.length,
|
|
12365
12401
|
recheckCutoff,
|
|
12366
12402
|
shortlistK,
|
|
12367
|
-
maxPromptChars
|
|
12403
|
+
maxPromptChars,
|
|
12404
|
+
edgeSiteMode,
|
|
12405
|
+
edgeMinConfidence
|
|
12368
12406
|
});
|
|
12369
12407
|
return {
|
|
12370
12408
|
scanned: classifierRun.result.scanned,
|
|
@@ -12387,7 +12425,9 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
12387
12425
|
trigger,
|
|
12388
12426
|
recheckCutoff,
|
|
12389
12427
|
shortlistK,
|
|
12390
|
-
maxPromptChars
|
|
12428
|
+
maxPromptChars,
|
|
12429
|
+
edgeSiteMode,
|
|
12430
|
+
edgeMinConfidence
|
|
12391
12431
|
});
|
|
12392
12432
|
}
|
|
12393
12433
|
/**
|
|
@@ -12423,6 +12463,9 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
12423
12463
|
if (maxPromptChars === void 0) {
|
|
12424
12464
|
throw new Error("_runGenerativeBackfill: runOpts.maxPromptChars is required (resolved at doRunOntologyBackfill entry)");
|
|
12425
12465
|
}
|
|
12466
|
+
if (runOpts.edgeSiteMode === void 0) {
|
|
12467
|
+
throw new Error("_runGenerativeBackfill: runOpts.edgeSiteMode is required (resolved at doRunOntologyBackfill entry)");
|
|
12468
|
+
}
|
|
12426
12469
|
const ontologyService = this.ontologyService;
|
|
12427
12470
|
const now = Date.now();
|
|
12428
12471
|
const recheckCutoff = runOpts.recheckCutoff;
|
|
@@ -12550,12 +12593,19 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
12550
12593
|
* untyped fact over the effective manifest's node-type slugs plus the
|
|
12551
12594
|
* reserved abstain sentinel. Accepted answers go through
|
|
12552
12595
|
* `_applyOntologyBackfillBatch` exactly like LLM classifications. No edges
|
|
12553
|
-
* are proposed.
|
|
12596
|
+
* are proposed unless `systemOne.edges` is `'auto'`; under `'auto'` the
|
|
12597
|
+
* classifier screens per-fact edge questions against
|
|
12598
|
+
* `systemOne.minConfidence.edges` (an explicit floor; missing → warn and
|
|
12599
|
+
* `'llm'`). Confident "yes" answers (`p > 0.5 && p >= floor`) apply,
|
|
12600
|
+
* confident "no" answers (`p < 0.5 && 1 - p >= floor`) are terminal, and
|
|
12601
|
+
* everything else (including exactly `p = 0.5`) plus invalid edge answers
|
|
12602
|
+
* fall through to the generative step. Edge outcomes are evaluated only for
|
|
12603
|
+
* typing-ACCEPTED facts. Abstains and low-confidence answers are cooldown-stamped
|
|
12554
12604
|
* omissions under `onLowConfidence: 'leave'`; under `'llm'` they are
|
|
12555
12605
|
* returned un-stamped in `escalated` for the generative step. Always
|
|
12556
12606
|
* returns the `OntologyBackfillResult` for its step plus escalation state.
|
|
12557
12607
|
*/
|
|
12558
|
-
async _runClassifierBackfill(entityId, candidates, manifest, now, recheckCutoff, meter, trigger) {
|
|
12608
|
+
async _runClassifierBackfill(entityId, candidates, manifest, now, recheckCutoff, meter, trigger, shortlistK, edgeSiteMode, edgeMinConfidence) {
|
|
12559
12609
|
const minConfidence = resolveTypingMinConfidence(this.options.config);
|
|
12560
12610
|
const rawConcurrency = this.options.config?.chunkConcurrency ?? 1;
|
|
12561
12611
|
const concurrency = Number.isFinite(rawConcurrency) && rawConcurrency >= 1 ? Math.floor(rawConcurrency) : 1;
|
|
@@ -12565,17 +12615,65 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
12565
12615
|
instructions: `Choose the ontology node type that best describes this fact, or choose "${ONTOLOGY_ABSTAIN_SENTINEL}" if none of the listed types fits.
|
|
12566
12616
|
` + manifest.node_types.map((n) => `- ${n.type}: ${n.description}`).join("\n")
|
|
12567
12617
|
};
|
|
12618
|
+
const edgeScreen = /* @__PURE__ */ new Map();
|
|
12619
|
+
if (edgeSiteMode === "auto" && (manifest.edge_types ?? []).length > 0) {
|
|
12620
|
+
const pool = await this.entryRepo.findShortlistRowsByEntityId(entityId);
|
|
12621
|
+
const poolTitleCounts = /* @__PURE__ */ new Map();
|
|
12622
|
+
for (const r of pool) {
|
|
12623
|
+
const k = normalizeTitleKey(r.title);
|
|
12624
|
+
poolTitleCounts.set(k, (poolTitleCounts.get(k) ?? 0) + 1);
|
|
12625
|
+
}
|
|
12626
|
+
const batchTitleKeys = new Set(candidates.map((f) => normalizeTitleKey(f.title)));
|
|
12627
|
+
const collides = (title) => {
|
|
12628
|
+
const k = normalizeTitleKey(title);
|
|
12629
|
+
return (poolTitleCounts.get(k) ?? 0) > 1 || batchTitleKeys.has(k);
|
|
12630
|
+
};
|
|
12631
|
+
const scorer = createShortlistScorer(pool);
|
|
12632
|
+
const edgeTypeNames = [...new Set(manifest.edge_types.map((e) => e.type))];
|
|
12633
|
+
for (const fact of candidates) {
|
|
12634
|
+
const ranked = buildShortlist({ title: fact.title, body: fact.body }, pool, shortlistK, scorer).filter((row) => !collides(row.title));
|
|
12635
|
+
const questions = {};
|
|
12636
|
+
const keyMap = /* @__PURE__ */ new Map();
|
|
12637
|
+
for (const row of ranked) {
|
|
12638
|
+
for (const edgeType of edgeTypeNames) {
|
|
12639
|
+
const definitions = manifest.edge_types.filter(
|
|
12640
|
+
(e) => e.type === edgeType && typeSatisfies(e.target_type, row.okf_type, manifest)
|
|
12641
|
+
);
|
|
12642
|
+
if (definitions.length === 0) continue;
|
|
12643
|
+
const key = `edge:${edgeType}:${row.id}`;
|
|
12644
|
+
const descriptions = [...new Set(definitions.map((d) => d.description))].join(" / ");
|
|
12645
|
+
questions[key] = {
|
|
12646
|
+
kind: "binary",
|
|
12647
|
+
instructions: `Does this fact have the "${edgeType}" relationship (${descriptions}) to the existing fact titled "${row.title}"?`
|
|
12648
|
+
};
|
|
12649
|
+
keyMap.set(key, { definitions, candidate: { id: row.id, title: row.title, okf_type: row.okf_type } });
|
|
12650
|
+
}
|
|
12651
|
+
}
|
|
12652
|
+
if (keyMap.size > 0) edgeScreen.set(fact.id, { questions, keyMap });
|
|
12653
|
+
}
|
|
12654
|
+
}
|
|
12568
12655
|
let stopped;
|
|
12656
|
+
const retriedFacts = /* @__PURE__ */ new Set();
|
|
12569
12657
|
const outcomes = await withConcurrency(
|
|
12570
12658
|
candidates.map((fact) => async () => {
|
|
12571
12659
|
if (stopped) return { fact, kind: "unattempted" };
|
|
12660
|
+
const edgeEntry = edgeScreen.get(fact.id);
|
|
12661
|
+
const ask = (questions) => callClassify(
|
|
12662
|
+
this.options,
|
|
12663
|
+
{ operation: "ontologyBackfill", entityId, trigger, meter },
|
|
12664
|
+
{ state: classifierStateForFact(fact), questions }
|
|
12665
|
+
);
|
|
12572
12666
|
let response;
|
|
12667
|
+
let screened = edgeEntry !== void 0;
|
|
12573
12668
|
try {
|
|
12574
|
-
|
|
12575
|
-
|
|
12576
|
-
|
|
12577
|
-
|
|
12578
|
-
|
|
12669
|
+
try {
|
|
12670
|
+
response = await ask({ okf_type: question, ...edgeEntry?.questions ?? {} });
|
|
12671
|
+
} catch (err) {
|
|
12672
|
+
if (!edgeEntry || err instanceof WikiBudgetExhausted || !isContextOverflowError(err)) throw err;
|
|
12673
|
+
response = await ask({ okf_type: question });
|
|
12674
|
+
screened = false;
|
|
12675
|
+
retriedFacts.add(fact.id);
|
|
12676
|
+
}
|
|
12579
12677
|
} catch (err) {
|
|
12580
12678
|
if (err instanceof WikiBudgetExhausted) {
|
|
12581
12679
|
stopped ?? (stopped = err);
|
|
@@ -12589,17 +12687,54 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
12589
12687
|
if (checked.answer.kind !== "choice") return { fact, kind: "invalid", reason: "kind_mismatch" };
|
|
12590
12688
|
if (isReservedAbstainSlug(checked.answer.choice)) return { fact, kind: "abstain" };
|
|
12591
12689
|
if (checked.answer.confidence < minConfidence) return { fact, kind: "low_confidence" };
|
|
12592
|
-
|
|
12690
|
+
const okfType = checked.answer.choice;
|
|
12691
|
+
if (!screened || !edgeEntry || typeof edgeMinConfidence !== "number") return { fact, kind: "accepted", okfType };
|
|
12692
|
+
const floor = edgeMinConfidence;
|
|
12693
|
+
const edges = [];
|
|
12694
|
+
const edgeCandidateIds = /* @__PURE__ */ Object.create(null);
|
|
12695
|
+
let evaluated = 0;
|
|
12696
|
+
let uncertain = 0;
|
|
12697
|
+
let invalid = 0;
|
|
12698
|
+
let missing = 0;
|
|
12699
|
+
for (const [key, { definitions, candidate }] of edgeEntry.keyMap) {
|
|
12700
|
+
if (!definitions.some((d) => typeSatisfies(d.source_type, okfType, manifest))) continue;
|
|
12701
|
+
evaluated++;
|
|
12702
|
+
const answer = validateClassifierAnswer(response, key, edgeEntry.questions[key]);
|
|
12703
|
+
if (!answer.ok) {
|
|
12704
|
+
if (answer.reason === "missing_answer") missing++;
|
|
12705
|
+
else invalid++;
|
|
12706
|
+
continue;
|
|
12707
|
+
}
|
|
12708
|
+
if (answer.answer.kind !== "binary") {
|
|
12709
|
+
invalid++;
|
|
12710
|
+
continue;
|
|
12711
|
+
}
|
|
12712
|
+
const p = answer.answer.probability;
|
|
12713
|
+
if (p > 0.5 && p >= floor) {
|
|
12714
|
+
edges.push({ edge_type: definitions[0].type, target_title: candidate.title });
|
|
12715
|
+
edgeCandidateIds[normalizeTitleKey(candidate.title)] = candidate.id;
|
|
12716
|
+
} else if (p < 0.5 && 1 - p >= floor) continue;
|
|
12717
|
+
else uncertain++;
|
|
12718
|
+
}
|
|
12719
|
+
const edgeStats = { uncertain, invalid, missing, allMissing: evaluated > 0 && missing === evaluated };
|
|
12720
|
+
if (edgeStats.allMissing) return { fact, kind: "accepted", okfType, edgeStats };
|
|
12721
|
+
if (uncertain > 0 || invalid > 0 || missing > 0) return { fact, kind: "accepted", okfType, fallthrough: true, edgeStats };
|
|
12722
|
+
return { fact, kind: "accepted", okfType, ...edges.length > 0 ? { edges, edgeCandidateIds } : {} };
|
|
12593
12723
|
}),
|
|
12594
12724
|
concurrency
|
|
12595
12725
|
);
|
|
12596
12726
|
const escalate = this.resolveSystemOneOnLowConfidence() === "llm";
|
|
12597
|
-
const
|
|
12598
|
-
const
|
|
12727
|
+
const isEscalated = (o) => o.kind === "accepted" && o.fallthrough === true || escalate && (o.kind === "abstain" || o.kind === "low_confidence");
|
|
12728
|
+
const escalated = outcomes.filter(isEscalated).map((o) => o.fact);
|
|
12599
12729
|
const attempted = outcomes.filter((o) => o.kind !== "threw" && o.kind !== "unattempted" && !isEscalated(o)).map((o) => o.fact);
|
|
12600
12730
|
const unattemptedCount = outcomes.filter((o) => o.kind === "unattempted").length;
|
|
12601
12731
|
const skipped = outcomes.filter((o) => o.kind === "threw" || o.kind === "overflow_skip").length;
|
|
12602
|
-
const classifications = outcomes.filter((o) => o.kind === "accepted").map((o) => ({
|
|
12732
|
+
const classifications = outcomes.filter((o) => o.kind === "accepted" && o.fallthrough !== true).map((o) => ({
|
|
12733
|
+
id: o.fact.id,
|
|
12734
|
+
okf_type: o.okfType,
|
|
12735
|
+
// An outcome carries `edges` only when the site is 'auto'.
|
|
12736
|
+
...o.edges && o.edges.length > 0 ? { edges: o.edges, edgeCandidateIds: o.edgeCandidateIds } : {}
|
|
12737
|
+
}));
|
|
12603
12738
|
const invalidCount = outcomes.filter((o) => o.kind === "invalid").length;
|
|
12604
12739
|
const abstainCount = outcomes.filter((o) => o.kind === "abstain" && !isEscalated(o)).length;
|
|
12605
12740
|
let typed = 0;
|
|
@@ -12624,7 +12759,21 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
12624
12759
|
const diagBuffer = new DiagnosticBuffer();
|
|
12625
12760
|
const diagBase = { entityId, operation: "ontologyBackfill", trigger };
|
|
12626
12761
|
for (const o of outcomes) {
|
|
12627
|
-
if (o.
|
|
12762
|
+
if (retriedFacts.has(o.fact.id)) {
|
|
12763
|
+
diagBuffer.push({ ...diagBase, code: "context_overflow_skipped", detail: { factId: o.fact.id, reason: "edge_screen_overflow_retry" } });
|
|
12764
|
+
}
|
|
12765
|
+
if (o.kind === "accepted" && o.edgeStats) {
|
|
12766
|
+
const { invalid, missing, allMissing } = o.edgeStats;
|
|
12767
|
+
const code = allMissing || invalid > 0 || missing > 0 ? "classification_invalid" : "classification_low_confidence";
|
|
12768
|
+
diagBuffer.push({
|
|
12769
|
+
...diagBase,
|
|
12770
|
+
code,
|
|
12771
|
+
detail: {
|
|
12772
|
+
factId: o.fact.id,
|
|
12773
|
+
reason: allMissing ? "edge_answers_missing" : code === "classification_invalid" ? "edge_answer_invalid" : "edge_uncertain"
|
|
12774
|
+
}
|
|
12775
|
+
});
|
|
12776
|
+
} else if (o.kind === "abstain") {
|
|
12628
12777
|
if (isEscalated(o)) continue;
|
|
12629
12778
|
diagBuffer.push({ ...diagBase, code: "classification_abstained", detail: { factId: o.fact.id, writer: "classifier" } });
|
|
12630
12779
|
} else if (o.kind === "low_confidence") {
|
|
@@ -12759,16 +12908,41 @@ DROP TRIGGER IF EXISTS ${ad};`);
|
|
|
12759
12908
|
});
|
|
12760
12909
|
titleIndex.set(normalizeTitleKey(fact.title), { id: fact.id, okf_type: normalized.okf_type });
|
|
12761
12910
|
if (normalized.edges.length > 0) {
|
|
12762
|
-
pendingEdges.push({
|
|
12911
|
+
pendingEdges.push({
|
|
12912
|
+
sourceId: fact.id,
|
|
12913
|
+
sourceType: normalized.okf_type,
|
|
12914
|
+
edges: normalized.edges,
|
|
12915
|
+
candidateIds: classification.edgeCandidateIds
|
|
12916
|
+
});
|
|
12763
12917
|
}
|
|
12764
12918
|
}
|
|
12765
12919
|
for (const item of pendingEdges) {
|
|
12766
12920
|
const resolveDrops = [];
|
|
12921
|
+
let edgesToResolve = item.edges;
|
|
12922
|
+
const screenedIds = item.candidateIds;
|
|
12923
|
+
if (screenedIds) {
|
|
12924
|
+
edgesToResolve = [];
|
|
12925
|
+
for (const edge of item.edges) {
|
|
12926
|
+
const key = normalizeTitleKey(edge.target_title);
|
|
12927
|
+
const screened = screenedIds[key];
|
|
12928
|
+
if (screened !== void 0 && titleIndex.get(key)?.id !== screened) {
|
|
12929
|
+
resolveDrops.push({
|
|
12930
|
+
reason: "target_not_found",
|
|
12931
|
+
sourceId: item.sourceId,
|
|
12932
|
+
edgeType: edge.edge_type,
|
|
12933
|
+
sourceNodeType: item.sourceType,
|
|
12934
|
+
targetNodeType: null
|
|
12935
|
+
});
|
|
12936
|
+
} else {
|
|
12937
|
+
edgesToResolve.push(edge);
|
|
12938
|
+
}
|
|
12939
|
+
}
|
|
12940
|
+
}
|
|
12767
12941
|
const added = await ontologyService.resolveAndPersistEdges(
|
|
12768
12942
|
entityId,
|
|
12769
12943
|
item.sourceId,
|
|
12770
12944
|
item.sourceType,
|
|
12771
|
-
|
|
12945
|
+
edgesToResolve,
|
|
12772
12946
|
manifest,
|
|
12773
12947
|
titleIndex,
|
|
12774
12948
|
tx,
|
|
@@ -18227,8 +18401,10 @@ exports.parseEmbedding = parseEmbedding;
|
|
|
18227
18401
|
exports.parseOkfBundle = parseOkfBundle;
|
|
18228
18402
|
exports.resolveContextBudget = resolveContextBudget;
|
|
18229
18403
|
exports.resolveDefaultChunkLength = resolveDefaultChunkLength;
|
|
18404
|
+
exports.resolveEdgesMinConfidence = resolveEdgesMinConfidence;
|
|
18230
18405
|
exports.resolveMaxPromptChars = resolveMaxPromptChars;
|
|
18231
18406
|
exports.resolveOntologyJobDefaults = resolveOntologyJobDefaults;
|
|
18407
|
+
exports.resolveSystemOneEdges = resolveSystemOneEdges;
|
|
18232
18408
|
exports.resolveSystemOneTyping = resolveSystemOneTyping;
|
|
18233
18409
|
exports.resolveTypingMinConfidence = resolveTypingMinConfidence;
|
|
18234
18410
|
exports.safeSlice = safeSlice;
|