@equationalapplications/core-llm-wiki 9.13.0 → 9.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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-DkKZcrhE.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-DkKZcrhE.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-BclOvn3q.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-BclOvn3q.mjs';
3
3
  import { OkfFile } from '@equationalapplications/core-okf';
4
4
 
5
5
  /**
@@ -272,10 +272,25 @@ declare function resolveEdgesMinConfidence(config: WikiConfig | undefined): numb
272
272
  * The floor is mandatory because a wrong NOOP drops a live fact.
273
273
  */
274
274
  declare function resolveResolveMinConfidence(config: WikiConfig | undefined): number | undefined;
275
+ /**
276
+ * Heal-screen mode resolution (specs/heal-screening-system-one §2):
277
+ * `systemOne.healScreen` → `'llm'`. A present non-`'auto'`/non-`'llm'` value
278
+ * warns once and is treated as unset. No legacy chain and no call option.
279
+ */
280
+ declare function resolveSystemOneHealScreen(config: WikiConfig | undefined): 'auto' | 'llm';
281
+ /**
282
+ * Heal-screen floor (specs/heal-screening-system-one §3): returns the
283
+ * `systemOne.minConfidence.healScreen` floor only when the heal-screen mode
284
+ * resolves `'auto'` and the floor is a finite number in [0.5, 1]. There is no
285
+ * default floor: a missing or out-of-domain value warns once and returns
286
+ * `undefined` (the site then resolves `'llm'`). Under `'llm'` or unset it
287
+ * reads nothing.
288
+ */
289
+ declare function resolveHealScreenMinConfidence(config: WikiConfig | undefined): number | undefined;
275
290
 
276
291
  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.";
277
292
 
278
293
  declare function createWiki(db: SQLiteAdapter, options: WikiOptions): WikiMemory;
279
294
 
280
- 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, resolveResolveMinConfidence, resolveSystemOneEdges, resolveSystemOneResolve, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateLibrarianPromptTemplate, warnOnce };
295
+ 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, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateLibrarianPromptTemplate, warnOnce };
281
296
  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-DkKZcrhE.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-DkKZcrhE.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-BclOvn3q.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-BclOvn3q.js';
3
3
  import { OkfFile } from '@equationalapplications/core-okf';
4
4
 
5
5
  /**
@@ -272,10 +272,25 @@ declare function resolveEdgesMinConfidence(config: WikiConfig | undefined): numb
272
272
  * The floor is mandatory because a wrong NOOP drops a live fact.
273
273
  */
274
274
  declare function resolveResolveMinConfidence(config: WikiConfig | undefined): number | undefined;
275
+ /**
276
+ * Heal-screen mode resolution (specs/heal-screening-system-one §2):
277
+ * `systemOne.healScreen` → `'llm'`. A present non-`'auto'`/non-`'llm'` value
278
+ * warns once and is treated as unset. No legacy chain and no call option.
279
+ */
280
+ declare function resolveSystemOneHealScreen(config: WikiConfig | undefined): 'auto' | 'llm';
281
+ /**
282
+ * Heal-screen floor (specs/heal-screening-system-one §3): returns the
283
+ * `systemOne.minConfidence.healScreen` floor only when the heal-screen mode
284
+ * resolves `'auto'` and the floor is a finite number in [0.5, 1]. There is no
285
+ * default floor: a missing or out-of-domain value warns once and returns
286
+ * `undefined` (the site then resolves `'llm'`). Under `'llm'` or unset it
287
+ * reads nothing.
288
+ */
289
+ declare function resolveHealScreenMinConfidence(config: WikiConfig | undefined): number | undefined;
275
290
 
276
291
  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.";
277
292
 
278
293
  declare function createWiki(db: SQLiteAdapter, options: WikiOptions): WikiMemory;
279
294
 
280
- 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, resolveResolveMinConfidence, resolveSystemOneEdges, resolveSystemOneResolve, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateLibrarianPromptTemplate, warnOnce };
295
+ 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, resolveSystemOneTyping, resolveTypingMinConfidence, safeSlice, validUsage, validateLibrarianPromptTemplate, warnOnce };
281
296
  export type { ContextBudget, FormatOkfBundleOptions, LibrarianOptions, LibrarianPromptVariables, OkfFormatProfile, OkfImportOptions };
package/dist/index.js CHANGED
@@ -26,6 +26,8 @@ var SEVERITY = {
26
26
  hook_failed: "warn",
27
27
  background_job_failed: "error",
28
28
  heal_skipped: "warn",
29
+ heal_deleted: "info",
30
+ heal_downgraded: "info",
29
31
  grounding_missing: "warn",
30
32
  grounding_failed: "warn",
31
33
  classification_low_confidence: "info",
@@ -79,6 +81,8 @@ var MESSAGE = {
79
81
  hook_failed: "A host hook threw or rejected.",
80
82
  background_job_failed: "A background maintenance job failed.",
81
83
  heal_skipped: "Heal skipped a candidate fact, or the whole LLM pass when keyword search is unavailable.",
84
+ heal_deleted: "Heal soft-deleted a fact (or withheld the delete below the confidence floor).",
85
+ heal_downgraded: "Heal downgraded a fact to tentative (or withheld the downgrade below the confidence floor).",
82
86
  grounding_missing: "A fact carried no qualifying evidence and was stored as a draft.",
83
87
  grounding_failed: "A fact carried evidence not found in its source and was stored as a draft.",
84
88
  classification_low_confidence: "A classifier answer was below the confidence threshold and was not applied.",
@@ -7548,10 +7552,11 @@ Keep facts concise. Do not return markdown, just raw JSON.`;
7548
7552
  var HEAL_SYSTEM_PROMPT = `You are a memory grooming agent. Your job is to review a full dump of facts and recent events to resolve contradictions, downgrade stale claims, and flag obsolete facts for deletion.
7549
7553
  Return ONLY a valid JSON object matching this schema:
7550
7554
  {
7551
- "downgraded": ["string (fact IDs)"],
7552
- "deleted": ["string (fact IDs)"],
7555
+ "downgraded": [{ "id": "string (fact ID)", "confidence": "number 0-1" }],
7556
+ "deleted": [{ "id": "string (fact ID)", "confidence": "number 0-1" }],
7553
7557
  "newFacts": [{ "title": "string (max 80 chars)", "body": "string (max 800 chars)", "tags": ["string"], "confidence": "certain|inferred|tentative" }]
7554
7558
  }
7559
+ For downgraded and deleted entries, "confidence" is your confidence in that verdict.
7555
7560
  Do not return markdown, just raw JSON.`;
7556
7561
  var INGEST_SYSTEM_PROMPT = `You are a document ingestion agent. Your job is to extract factual knowledge from the provided document chunk.
7557
7562
  Return ONLY a valid JSON object matching this schema:
@@ -9231,6 +9236,25 @@ function resolveResolveMinConfidence(config) {
9231
9236
  );
9232
9237
  return void 0;
9233
9238
  }
9239
+ function resolveSystemOneHealScreen(config) {
9240
+ const healScreen = config?.systemOne?.healScreen;
9241
+ if (healScreen !== void 0 && !isTypingMode(healScreen)) {
9242
+ warnOnce(
9243
+ `[core-llm-wiki] systemOne: \`systemOne.healScreen\` is ${formatConfigValue(healScreen)}, which is not 'auto' or 'llm'. The key is treated as unset; the default ('llm') applies.`
9244
+ );
9245
+ return "llm";
9246
+ }
9247
+ return healScreen ?? "llm";
9248
+ }
9249
+ function resolveHealScreenMinConfidence(config) {
9250
+ if (resolveSystemOneHealScreen(config) !== "auto") return void 0;
9251
+ const floor = config?.systemOne?.minConfidence?.healScreen;
9252
+ if (isEdgesFloor(floor)) return floor;
9253
+ warnOnce(
9254
+ floor === void 0 ? "[core-llm-wiki] systemOne: `systemOne.minConfidence.healScreen` is required when `systemOne.healScreen` is 'auto'. The heal screen is off for this site; heal stays ungated." : `[core-llm-wiki] systemOne: \`systemOne.minConfidence.healScreen\` is ${formatConfigValue(floor)}, which is not a finite number in [0.5, 1]. The heal screen is off for this site; heal stays ungated.`
9255
+ );
9256
+ return void 0;
9257
+ }
9234
9258
 
9235
9259
  // src/repositories/VectorRemovalRepository.ts
9236
9260
  var CHUNK2 = 500;
@@ -9816,6 +9840,8 @@ var CONTEXT_OVERFLOW_PATTERNS = [
9816
9840
  // classify as input overflow (it would split the batch and stamp a cooldown).
9817
9841
  /(input|prompt).{0,40}exceed(s|ed)? .{0,30}(context|maximum)/i,
9818
9842
  /context limit/i,
9843
+ // llama.rn (RNLlamaJSI.cpp): prompt >= n_ctx with ctx_shift off
9844
+ /\bcontext is full\b/i,
9819
9845
  /too long for (the )?requested model/i,
9820
9846
  // vLLM dual-match wording (errata E2 ruling): the regex ENFORCES the dual-match —
9821
9847
  // "max_tokens ... too large" PLUS a context clause; a bare message is NOT overflow
@@ -12143,6 +12169,17 @@ DROP TRIGGER IF EXISTS ${ad};`);
12143
12169
  * `result.remaining > 0` for convergence — see {@link HealResult.remaining}
12144
12170
  * for what convergence means here, and for the no-progress flags
12145
12171
  * (`searchUnavailable`, `budgetStop`) a loop must also stop on.
12172
+ *
12173
+ * Heal screen (`systemOne.healScreen: 'auto'` + `minConfidence.healScreen`):
12174
+ * a model-directed delete or downgrade whose valid `confidence` is below the
12175
+ * floor is withheld from every reader (apply, sync, removals, counts, id
12176
+ * lists); a missing or invalid confidence is applied unscreened. Each
12177
+ * model-directed move emits a `heal_deleted` / `heal_downgraded` receipt
12178
+ * after commit (`applied`, `applied_unscreened`, or `below_floor`), in every
12179
+ * mode. An `applied` receipt records that the model VERDICT was applied
12180
+ * (`downgradeByIds` runs unconditionally): a fact that was already at
12181
+ * reduced confidence still gets an `applied` receipt. A withheld delete paired with a restating `newFact` leaves the fact
12182
+ * live and the restatement is skipped as `fact_deduplicated`.
12146
12183
  */
12147
12184
  async doRunHeal(entityId, options) {
12148
12185
  const promptOverride = options?.promptOverride;
@@ -12156,6 +12193,7 @@ DROP TRIGGER IF EXISTS ${ad};`);
12156
12193
  if (!Number.isInteger(bodyTruncationChars) || bodyTruncationChars < 1) {
12157
12194
  throw new Error("Invalid bodyTruncationChars: must be an integer >= 1");
12158
12195
  }
12196
+ const healFloor = resolveHealScreenMinConfidence(this.options.config);
12159
12197
  const now = Date.now();
12160
12198
  const recheckCutoff = now - HEAL_RECHECK_MS;
12161
12199
  const orphanAfterDays = this.options.config?.orphanAfterDays !== void 0 ? this.options.config?.orphanAfterDays : 30;
@@ -12194,6 +12232,8 @@ DROP TRIGGER IF EXISTS ${ad};`);
12194
12232
  downgraded: staleDowngradedIds.length,
12195
12233
  deleted: orphanedIds.length,
12196
12234
  newFactsCreated: 0,
12235
+ downgradedIds: Array.from(new Set(staleDowngradedIds)),
12236
+ deletedIds: Array.from(new Set(orphanedIds)),
12197
12237
  skipped: [],
12198
12238
  degraded: [],
12199
12239
  remaining: counts2.eligible,
@@ -12244,10 +12284,30 @@ DROP TRIGGER IF EXISTS ${ad};`);
12244
12284
  call: (prompts) => callLlm(this.options, { operation: "heal", entityId, trigger, meter: options?.meter }, prompts),
12245
12285
  parse: (responseText, batch, prompts) => {
12246
12286
  const result = parseJsonResponse(responseText);
12287
+ const normalize = (raw) => {
12288
+ const ids = [];
12289
+ const confidence = /* @__PURE__ */ new Map();
12290
+ if (!Array.isArray(raw)) return { ids, confidence };
12291
+ for (const entry of raw) {
12292
+ const id = typeof entry === "string" ? entry : entry?.id;
12293
+ if (typeof id !== "string") continue;
12294
+ ids.push(id);
12295
+ const c = typeof entry === "object" && entry !== null ? entry.confidence : void 0;
12296
+ if (typeof c === "number" && Number.isFinite(c) && c >= 0 && c <= 1) {
12297
+ const prev = confidence.get(id);
12298
+ if (prev === void 0 || c < prev) confidence.set(id, c);
12299
+ }
12300
+ }
12301
+ return { ids, confidence };
12302
+ };
12303
+ const down = normalize(result.downgraded);
12304
+ const del = normalize(result.deleted);
12247
12305
  return {
12248
12306
  batch,
12249
- downgraded: Array.isArray(result.downgraded) ? result.downgraded : [],
12250
- deleted: Array.isArray(result.deleted) ? result.deleted : [],
12307
+ downgraded: down.ids,
12308
+ deleted: del.ids,
12309
+ downgradedConfidence: down.confidence,
12310
+ deletedConfidence: del.confidence,
12251
12311
  newFacts: Array.isArray(result.newFacts) ? result.newFacts : [],
12252
12312
  corpus: corpusByPrompt.get(prompts) ?? null
12253
12313
  };
@@ -12287,8 +12347,42 @@ DROP TRIGGER IF EXISTS ${ad};`);
12287
12347
  newFactCorpora.push(batchResult.corpus);
12288
12348
  });
12289
12349
  }
12350
+ const downgradeConfidence = /* @__PURE__ */ new Map();
12351
+ const deleteConfidence = /* @__PURE__ */ new Map();
12352
+ const mergeLowest = (into, id, c) => {
12353
+ if (c === void 0) return;
12354
+ const prev = into.get(id);
12355
+ if (prev === void 0 || c < prev) into.set(id, c);
12356
+ };
12357
+ for (const batchResult of outcome.results) {
12358
+ const mutableIds = new Set(batchResult.batch.map((f) => f.id));
12359
+ for (const id of batchResult.downgraded) if (mutableIds.has(id)) mergeLowest(downgradeConfidence, id, batchResult.downgradedConfidence.get(id));
12360
+ for (const id of batchResult.deleted) if (mutableIds.has(id)) mergeLowest(deleteConfidence, id, batchResult.deletedConfidence.get(id));
12361
+ }
12290
12362
  const safeDowngraded = Array.from(safeDowngradedSet);
12291
12363
  const safeDeleted = Array.from(safeDeletedSet);
12364
+ const withheldDowngraded = /* @__PURE__ */ new Map();
12365
+ const withheldDeleted = /* @__PURE__ */ new Map();
12366
+ let appliedDowngraded = safeDowngraded;
12367
+ let appliedDeleted = safeDeleted;
12368
+ if (healFloor !== void 0) {
12369
+ const screen = (ids, confidences, withheld) => {
12370
+ const applied = [];
12371
+ for (const id of ids) {
12372
+ const c = confidences.get(id);
12373
+ if (c !== void 0 && c < healFloor) withheld.set(id, c);
12374
+ else applied.push(id);
12375
+ }
12376
+ return applied;
12377
+ };
12378
+ appliedDowngraded = screen(safeDowngraded, downgradeConfidence, withheldDowngraded);
12379
+ appliedDeleted = screen(safeDeleted, deleteConfidence, withheldDeleted);
12380
+ if (appliedDowngraded.some((id) => !downgradeConfidence.has(id)) || appliedDeleted.some((id) => !deleteConfidence.has(id))) {
12381
+ warnOnce(
12382
+ '[core-llm-wiki] systemOne: heal returned downgraded/deleted verdicts without a valid `confidence` (out-of-range or non-numeric), so the heal screen could not gate them and they were applied. Restore the schema \u2014 or a `healSystemPrompt` override \u2014 to the `{ "id", "confidence" }` entry contract with confidences in 0-1 (see HEAL_SYSTEM_PROMPT).'
12383
+ );
12384
+ }
12385
+ }
12292
12386
  const diagBuffer = new DiagnosticBuffer();
12293
12387
  const validNewFacts = [];
12294
12388
  const validNewFactItemIndexes = [];
@@ -12305,10 +12399,10 @@ DROP TRIGGER IF EXISTS ${ad};`);
12305
12399
  }
12306
12400
  });
12307
12401
  const insertedFacts = [];
12308
- const uniqueDeletedFactIds = Array.from(new Set(safeDeleted));
12402
+ const uniqueDeletedFactIds = Array.from(new Set(appliedDeleted));
12309
12403
  await this.db.withTransactionAsync(async (tx) => {
12310
- await this.entryRepo.downgradeByIds(safeDowngraded, entityId, tx);
12311
- await this.entryRepo.softDeleteByIds(safeDeleted, entityId, tx);
12404
+ await this.entryRepo.downgradeByIds(appliedDowngraded, entityId, tx);
12405
+ await this.entryRepo.softDeleteByIds(appliedDeleted, entityId, tx);
12312
12406
  const healFactsForDedupe = await this.entryRepo.findInferredTitlesByEntityId(entityId, tx);
12313
12407
  for (const [k, fact] of validNewFacts.entries()) {
12314
12408
  const newTokens = titleTokens(fact.title);
@@ -12372,11 +12466,29 @@ DROP TRIGGER IF EXISTS ${ad};`);
12372
12466
  for (const { item, reason } of outcome.skipped) {
12373
12467
  diagBuffer.push({ ...diagBase, code: "heal_skipped", detail: { factId: item.id, reason } });
12374
12468
  }
12469
+ const pushReceipts = (code, applied, confidences, withheld) => {
12470
+ for (const factId of applied) {
12471
+ if (healFloor !== void 0 && !confidences.has(factId)) {
12472
+ diagBuffer.push({ ...diagBase, code, detail: { factId, reason: "applied_unscreened" } });
12473
+ } else {
12474
+ diagBuffer.push({ ...diagBase, code, detail: { factId, reason: "applied" } });
12475
+ }
12476
+ }
12477
+ for (const [factId, confidence] of withheld) {
12478
+ diagBuffer.push({
12479
+ ...diagBase,
12480
+ code,
12481
+ detail: { factId, reason: "below_floor", confidence }
12482
+ });
12483
+ }
12484
+ };
12485
+ pushReceipts("heal_downgraded", appliedDowngraded, downgradeConfidence, withheldDowngraded);
12486
+ pushReceipts("heal_deleted", appliedDeleted, deleteConfidence, withheldDeleted);
12375
12487
  diagBuffer.flush(this.options);
12376
12488
  const healSyncIds = Array.from(/* @__PURE__ */ new Set([
12377
12489
  ...orphanedIds,
12378
12490
  ...staleDowngradedIds,
12379
- ...safeDowngraded,
12491
+ ...appliedDowngraded,
12380
12492
  ...uniqueDeletedFactIds,
12381
12493
  ...insertedFacts.map((f) => f.id)
12382
12494
  ]));
@@ -12395,13 +12507,15 @@ DROP TRIGGER IF EXISTS ${ad};`);
12395
12507
  }
12396
12508
  let scanned = outcome.skipped.length;
12397
12509
  for (const batchResult of outcome.results) scanned += batchResult.batch.length;
12398
- const allDowngraded = /* @__PURE__ */ new Set([...staleDowngradedIds, ...safeDowngraded]);
12510
+ const allDowngraded = /* @__PURE__ */ new Set([...staleDowngradedIds, ...appliedDowngraded]);
12399
12511
  const allDeleted = /* @__PURE__ */ new Set([...orphanedIds, ...uniqueDeletedFactIds]);
12400
12512
  const counts = await this.entryRepo.countHealCandidatesByEntityId(entityId, recheckCutoff);
12401
12513
  return {
12402
12514
  scanned,
12403
12515
  downgraded: allDowngraded.size,
12404
12516
  deleted: allDeleted.size,
12517
+ downgradedIds: Array.from(allDowngraded),
12518
+ deletedIds: Array.from(allDeleted),
12405
12519
  newFactsCreated: insertedFacts.length,
12406
12520
  skipped: outcome.skipped.map(({ item, reason }) => ({ id: item.id, reason })),
12407
12521
  degraded: healedDegraded,
@@ -18491,10 +18605,12 @@ exports.parseOkfBundle = parseOkfBundle;
18491
18605
  exports.resolveContextBudget = resolveContextBudget;
18492
18606
  exports.resolveDefaultChunkLength = resolveDefaultChunkLength;
18493
18607
  exports.resolveEdgesMinConfidence = resolveEdgesMinConfidence;
18608
+ exports.resolveHealScreenMinConfidence = resolveHealScreenMinConfidence;
18494
18609
  exports.resolveMaxPromptChars = resolveMaxPromptChars;
18495
18610
  exports.resolveOntologyJobDefaults = resolveOntologyJobDefaults;
18496
18611
  exports.resolveResolveMinConfidence = resolveResolveMinConfidence;
18497
18612
  exports.resolveSystemOneEdges = resolveSystemOneEdges;
18613
+ exports.resolveSystemOneHealScreen = resolveSystemOneHealScreen;
18498
18614
  exports.resolveSystemOneResolve = resolveSystemOneResolve;
18499
18615
  exports.resolveSystemOneTyping = resolveSystemOneTyping;
18500
18616
  exports.resolveTypingMinConfidence = resolveTypingMinConfidence;