@equationalapplications/core-llm-wiki 9.10.0 → 9.11.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/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-DnYjL2QD.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_MAX_PROMPT_CHARS, $ 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 isReservedAbstainSlug, aZ as isWikiSearchUnavailableError, a_ as validateManifest } from './testing-DnYjL2QD.mjs';
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-DFyghdSG.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-DFyghdSG.mjs';
3
3
  import { OkfFile } from '@equationalapplications/core-okf';
4
4
 
5
5
  /**
@@ -47,21 +47,6 @@ declare function chunkText(input: string, maxChunkLength: number, overlap: numbe
47
47
  truncated: boolean;
48
48
  };
49
49
 
50
- /** Per-candidate anchor ratio used at L0: `min(HEAL_MAX_ANCHORS, batch.length * HEAL_ANCHORS_PER_CANDIDATE)`. */
51
- declare const HEAL_ANCHORS_PER_CANDIDATE = 4;
52
- /**
53
- * Default body truncation cap applied at L3 only. A fact whose body is at or
54
- * below this cap passes through unchanged; a fact above it is sliced to this
55
- * length with a `...[truncated at N chars, original was M]` marker.
56
- */
57
- declare const HEAL_MAX_FACT_BODY_CHARS_L3 = 4000;
58
- /**
59
- * Hard ceiling on the `allTasks` slice fed to the heal prompt at L0. Tasks
60
- * are entity-global (not batch-local), so this is a constant rather than a
61
- * function of batch length.
62
- */
63
- declare const HEAL_MAX_TASKS = 50;
64
-
65
50
  /**
66
51
  * Default maximum characters per chunk that `ingestDocument` uses when a
67
52
  * caller doesn't override `maxChunkLength` (directly or via
@@ -78,6 +63,24 @@ declare const DEFAULT_MAX_CHUNK_LENGTH = 12000;
78
63
  */
79
64
  declare const DEFAULT_CHUNK_OVERLAP = 400;
80
65
 
66
+ /** Input bound for the ontology-backfill generative prompt (was `MaintenanceService.ts`). */
67
+ declare const ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS = 40000;
68
+
69
+ /** Per-candidate anchor ratio used at L0: `min(HEAL_MAX_ANCHORS, batch.length * HEAL_ANCHORS_PER_CANDIDATE)`. */
70
+ declare const HEAL_ANCHORS_PER_CANDIDATE = 4;
71
+ /**
72
+ * Default body truncation cap applied at L3 only. A fact whose body is at or
73
+ * below this cap passes through unchanged; a fact above it is sliced to this
74
+ * length with a `...[truncated at N chars, original was M]` marker.
75
+ */
76
+ declare const HEAL_MAX_FACT_BODY_CHARS_L3 = 4000;
77
+ /**
78
+ * Hard ceiling on the `allTasks` slice fed to the heal prompt at L0. Tasks
79
+ * are entity-global (not batch-local), so this is a constant rather than a
80
+ * function of batch length.
81
+ */
82
+ declare const HEAL_MAX_TASKS = 50;
83
+
81
84
  declare function formatContext(bundle: MemoryBundle, options?: FormatContextOptions): string;
82
85
 
83
86
  /**
@@ -148,7 +151,7 @@ interface ContextBudget {
148
151
  }
149
152
  declare function estimateTokensWith(budget: ContextBudget, text: string): number;
150
153
 
151
- type ContextBudgetOp = 'resolve' | 'heal' | 'extract';
154
+ type ContextBudgetOp = 'resolve' | 'heal' | 'extract' | 'backfill';
152
155
  declare function resolveContextBudget(config: WikiConfig | undefined): ContextBudget;
153
156
  declare function resolveMaxPromptChars(budget: ContextBudget, op: ContextBudgetOp): number;
154
157
  /** The ingest chunk default stays 12000 in both modes (ruling R2). */
@@ -245,5 +248,5 @@ declare const ONTOLOGY_BACKFILL_SYSTEM_PROMPT = "You are a knowledge classificat
245
248
 
246
249
  declare function createWiki(db: SQLiteAdapter, options: WikiOptions): WikiMemory;
247
250
 
248
- 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_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 };
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 };
249
252
  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-DnYjL2QD.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_MAX_PROMPT_CHARS, $ 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 isReservedAbstainSlug, aZ as isWikiSearchUnavailableError, a_ as validateManifest } from './testing-DnYjL2QD.js';
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-DFyghdSG.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-DFyghdSG.js';
3
3
  import { OkfFile } from '@equationalapplications/core-okf';
4
4
 
5
5
  /**
@@ -47,21 +47,6 @@ declare function chunkText(input: string, maxChunkLength: number, overlap: numbe
47
47
  truncated: boolean;
48
48
  };
49
49
 
50
- /** Per-candidate anchor ratio used at L0: `min(HEAL_MAX_ANCHORS, batch.length * HEAL_ANCHORS_PER_CANDIDATE)`. */
51
- declare const HEAL_ANCHORS_PER_CANDIDATE = 4;
52
- /**
53
- * Default body truncation cap applied at L3 only. A fact whose body is at or
54
- * below this cap passes through unchanged; a fact above it is sliced to this
55
- * length with a `...[truncated at N chars, original was M]` marker.
56
- */
57
- declare const HEAL_MAX_FACT_BODY_CHARS_L3 = 4000;
58
- /**
59
- * Hard ceiling on the `allTasks` slice fed to the heal prompt at L0. Tasks
60
- * are entity-global (not batch-local), so this is a constant rather than a
61
- * function of batch length.
62
- */
63
- declare const HEAL_MAX_TASKS = 50;
64
-
65
50
  /**
66
51
  * Default maximum characters per chunk that `ingestDocument` uses when a
67
52
  * caller doesn't override `maxChunkLength` (directly or via
@@ -78,6 +63,24 @@ declare const DEFAULT_MAX_CHUNK_LENGTH = 12000;
78
63
  */
79
64
  declare const DEFAULT_CHUNK_OVERLAP = 400;
80
65
 
66
+ /** Input bound for the ontology-backfill generative prompt (was `MaintenanceService.ts`). */
67
+ declare const ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS = 40000;
68
+
69
+ /** Per-candidate anchor ratio used at L0: `min(HEAL_MAX_ANCHORS, batch.length * HEAL_ANCHORS_PER_CANDIDATE)`. */
70
+ declare const HEAL_ANCHORS_PER_CANDIDATE = 4;
71
+ /**
72
+ * Default body truncation cap applied at L3 only. A fact whose body is at or
73
+ * below this cap passes through unchanged; a fact above it is sliced to this
74
+ * length with a `...[truncated at N chars, original was M]` marker.
75
+ */
76
+ declare const HEAL_MAX_FACT_BODY_CHARS_L3 = 4000;
77
+ /**
78
+ * Hard ceiling on the `allTasks` slice fed to the heal prompt at L0. Tasks
79
+ * are entity-global (not batch-local), so this is a constant rather than a
80
+ * function of batch length.
81
+ */
82
+ declare const HEAL_MAX_TASKS = 50;
83
+
81
84
  declare function formatContext(bundle: MemoryBundle, options?: FormatContextOptions): string;
82
85
 
83
86
  /**
@@ -148,7 +151,7 @@ interface ContextBudget {
148
151
  }
149
152
  declare function estimateTokensWith(budget: ContextBudget, text: string): number;
150
153
 
151
- type ContextBudgetOp = 'resolve' | 'heal' | 'extract';
154
+ type ContextBudgetOp = 'resolve' | 'heal' | 'extract' | 'backfill';
152
155
  declare function resolveContextBudget(config: WikiConfig | undefined): ContextBudget;
153
156
  declare function resolveMaxPromptChars(budget: ContextBudget, op: ContextBudgetOp): number;
154
157
  /** The ingest chunk default stays 12000 in both modes (ruling R2). */
@@ -245,5 +248,5 @@ declare const ONTOLOGY_BACKFILL_SYSTEM_PROMPT = "You are a knowledge classificat
245
248
 
246
249
  declare function createWiki(db: SQLiteAdapter, options: WikiOptions): WikiMemory;
247
250
 
248
- 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_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 };
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 };
249
252
  export type { ContextBudget, FormatOkfBundleOptions, LibrarianOptions, LibrarianPromptVariables, OkfFormatProfile, OkfImportOptions };
package/dist/index.js CHANGED
@@ -7974,6 +7974,7 @@ var DEFAULT_CHUNK_OVERLAP = 400;
7974
7974
 
7975
7975
  // src/utils/contextCaps.ts
7976
7976
  var OPS_RESOLVE_MAX_PROMPT_CHARS = 4e4;
7977
+ var ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS = 4e4;
7977
7978
  var HEAL_MAX_PROMPT_CHARS = 4e4;
7978
7979
  var OPS_MAX_EXTRACT_CHARS = 24e3;
7979
7980
 
@@ -7984,7 +7985,8 @@ var DEFAULT_OUTPUT_RESERVE_TOKENS = 4e3;
7984
7985
  var OP_FLOOR = {
7985
7986
  resolve: OPS_RESOLVE_MAX_PROMPT_CHARS,
7986
7987
  heal: HEAL_MAX_PROMPT_CHARS,
7987
- extract: OPS_MAX_EXTRACT_CHARS
7988
+ extract: OPS_MAX_EXTRACT_CHARS,
7989
+ backfill: ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS
7988
7990
  };
7989
7991
  function bad(key, value, why) {
7990
7992
  return new Error(`[core-llm-wiki] config.context.${key} must be ${why}; received ${JSON.stringify(value)}`);
@@ -8022,12 +8024,11 @@ function declaredPromptCap(budget, op) {
8022
8024
  const derived = Math.floor(
8023
8025
  (budget.contextWindowTokens - budget.outputReserveTokens) * budget.safetyFraction * budget.charsPerToken
8024
8026
  );
8025
- if (op === "resolve") return Math.max(OP_FLOOR.resolve, derived);
8026
- return Math.max(OP_FLOOR.heal, derived);
8027
+ return Math.max(OP_FLOOR[op], derived);
8027
8028
  }
8028
8029
  function resolveMaxPromptChars(budget, op) {
8029
8030
  if (budget.mode !== "declared") {
8030
- return op === "resolve" ? OP_FLOOR.resolve : op === "heal" ? OP_FLOOR.heal : OP_FLOOR.extract;
8031
+ return OP_FLOOR[op];
8031
8032
  }
8032
8033
  if (op === "extract") {
8033
8034
  const resolveDerived = declaredPromptCap(budget, "resolve");
@@ -10837,7 +10838,6 @@ async function runLibrarianStrategy(deps, ctx) {
10837
10838
  // src/services/MaintenanceService.ts
10838
10839
  var CHAIN_TRUNCATED_NOTICE = `includeChain walk stopped at the depth cap (${HISTORY_MAX_DEPTH} links per direction); the chain is longer than the ids listed. Run forget again on a remaining chain id to continue.`;
10839
10840
  var ONTOLOGY_BACKFILL_BATCH_SIZE = 25;
10840
- var ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS = 4e4;
10841
10841
  var ONTOLOGY_BACKFILL_RECHECK_MS = 7 * 24 * 60 * 60 * 1e3;
10842
10842
  var CLASSIFIER_MAX_CHOICES = 255;
10843
10843
  var HEAL_ANCHOR_SEARCH_OVERFETCH = 4;
@@ -12314,6 +12314,7 @@ DROP TRIGGER IF EXISTS ${ad};`);
12314
12314
  throw new TypeError(`Invalid classifier option: ${JSON.stringify(options.classifier)} \u2014 must be 'auto' or 'llm'`);
12315
12315
  }
12316
12316
  const shortlistK = resolveShortlistK(this.options.config);
12317
+ const maxPromptChars = resolveMaxPromptChars(resolveContextBudget(this.options.config), "backfill");
12317
12318
  const trigger = options?.trigger ?? "call";
12318
12319
  const now = Date.now();
12319
12320
  const recheckCutoff = options?.recheckCheckedBefore ?? now - ONTOLOGY_BACKFILL_RECHECK_MS;
@@ -12362,7 +12363,8 @@ DROP TRIGGER IF EXISTS ${ad};`);
12362
12363
  trigger,
12363
12364
  batchSize: escalated.length,
12364
12365
  recheckCutoff,
12365
- shortlistK
12366
+ shortlistK,
12367
+ maxPromptChars
12366
12368
  });
12367
12369
  return {
12368
12370
  scanned: classifierRun.result.scanned,
@@ -12384,7 +12386,8 @@ DROP TRIGGER IF EXISTS ${ad};`);
12384
12386
  meter: options?.meter,
12385
12387
  trigger,
12386
12388
  recheckCutoff,
12387
- shortlistK
12389
+ shortlistK,
12390
+ maxPromptChars
12388
12391
  });
12389
12392
  }
12390
12393
  /**
@@ -12416,6 +12419,10 @@ DROP TRIGGER IF EXISTS ${ad};`);
12416
12419
  if (shortlistK === void 0) {
12417
12420
  throw new Error("_runGenerativeBackfill: runOpts.shortlistK is required (resolved at doRunOntologyBackfill entry)");
12418
12421
  }
12422
+ const maxPromptChars = runOpts.maxPromptChars;
12423
+ if (maxPromptChars === void 0) {
12424
+ throw new Error("_runGenerativeBackfill: runOpts.maxPromptChars is required (resolved at doRunOntologyBackfill entry)");
12425
+ }
12419
12426
  const ontologyService = this.ontologyService;
12420
12427
  const now = Date.now();
12421
12428
  const recheckCutoff = runOpts.recheckCutoff;
@@ -12454,7 +12461,7 @@ DROP TRIGGER IF EXISTS ${ad};`);
12454
12461
  };
12455
12462
  },
12456
12463
  maxOutputTokens: this.options.llmProvider.maxOutputTokens,
12457
- maxPromptChars: ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS,
12464
+ maxPromptChars,
12458
12465
  onSkip: (fact, err) => {
12459
12466
  if (isContextOverflowError(err)) {
12460
12467
  emitDiagnostic(this.options, {