@equationalapplications/core-llm-wiki 9.12.0 → 9.14.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-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';
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
  /**
@@ -240,6 +240,12 @@ declare function resolveSystemOneTyping(config: WikiConfig | undefined, classifi
240
240
  * as unset. No legacy chain and no call option.
241
241
  */
242
242
  declare function resolveSystemOneEdges(config: WikiConfig | undefined): 'auto' | 'llm';
243
+ /**
244
+ * Resolve-mode resolution (specs/resolution-system-one §2): `systemOne.resolve`
245
+ * → `'llm'`. A present non-`'auto'`/non-`'llm'` value warns once and is treated
246
+ * as unset. No legacy chain and no call option.
247
+ */
248
+ declare function resolveSystemOneResolve(config: WikiConfig | undefined): 'auto' | 'llm';
243
249
  /** Engine default confidence floor for classifier typing. */
244
250
  declare const DEFAULT_TYPING_MIN_CONFIDENCE: 0.5;
245
251
  /**
@@ -257,10 +263,34 @@ declare function resolveTypingMinConfidence(config: WikiConfig | undefined): num
257
263
  * (the site then resolves `'llm'`). Under `'llm'` or unset it reads nothing.
258
264
  */
259
265
  declare function resolveEdgesMinConfidence(config: WikiConfig | undefined): number | undefined;
266
+ /**
267
+ * Resolution-screen floor (specs/resolution-system-one §3): returns the
268
+ * `systemOne.minConfidence.resolve` floor only when the resolve mode resolves
269
+ * `'auto'` and the floor is a finite number in [0.5, 1]. There is no default
270
+ * floor: a missing or out-of-domain value warns once and returns `undefined`
271
+ * (the site then resolves `'llm'`). Under `'llm'` or unset it reads nothing.
272
+ * The floor is mandatory because a wrong NOOP drops a live fact.
273
+ */
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;
260
290
 
261
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.";
262
292
 
263
293
  declare function createWiki(db: SQLiteAdapter, options: WikiOptions): WikiMemory;
264
294
 
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 };
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 };
266
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-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';
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
  /**
@@ -240,6 +240,12 @@ declare function resolveSystemOneTyping(config: WikiConfig | undefined, classifi
240
240
  * as unset. No legacy chain and no call option.
241
241
  */
242
242
  declare function resolveSystemOneEdges(config: WikiConfig | undefined): 'auto' | 'llm';
243
+ /**
244
+ * Resolve-mode resolution (specs/resolution-system-one §2): `systemOne.resolve`
245
+ * → `'llm'`. A present non-`'auto'`/non-`'llm'` value warns once and is treated
246
+ * as unset. No legacy chain and no call option.
247
+ */
248
+ declare function resolveSystemOneResolve(config: WikiConfig | undefined): 'auto' | 'llm';
243
249
  /** Engine default confidence floor for classifier typing. */
244
250
  declare const DEFAULT_TYPING_MIN_CONFIDENCE: 0.5;
245
251
  /**
@@ -257,10 +263,34 @@ declare function resolveTypingMinConfidence(config: WikiConfig | undefined): num
257
263
  * (the site then resolves `'llm'`). Under `'llm'` or unset it reads nothing.
258
264
  */
259
265
  declare function resolveEdgesMinConfidence(config: WikiConfig | undefined): number | undefined;
266
+ /**
267
+ * Resolution-screen floor (specs/resolution-system-one §3): returns the
268
+ * `systemOne.minConfidence.resolve` floor only when the resolve mode resolves
269
+ * `'auto'` and the floor is a finite number in [0.5, 1]. There is no default
270
+ * floor: a missing or out-of-domain value warns once and returns `undefined`
271
+ * (the site then resolves `'llm'`). Under `'llm'` or unset it reads nothing.
272
+ * The floor is mandatory because a wrong NOOP drops a live fact.
273
+ */
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;
260
290
 
261
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.";
262
292
 
263
293
  declare function createWiki(db: SQLiteAdapter, options: WikiOptions): WikiMemory;
264
294
 
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 };
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 };
266
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:
@@ -9173,6 +9178,16 @@ function resolveSystemOneEdges(config) {
9173
9178
  }
9174
9179
  return edges ?? "llm";
9175
9180
  }
9181
+ function resolveSystemOneResolve(config) {
9182
+ const resolve = config?.systemOne?.resolve;
9183
+ if (resolve !== void 0 && !isTypingMode(resolve)) {
9184
+ warnOnce(
9185
+ `[core-llm-wiki] systemOne: \`systemOne.resolve\` is ${formatConfigValue(resolve)}, which is not 'auto' or 'llm'. The key is treated as unset; the default ('llm') applies.`
9186
+ );
9187
+ return "llm";
9188
+ }
9189
+ return resolve ?? "llm";
9190
+ }
9176
9191
  var DEFAULT_SHORTLIST_K = 10;
9177
9192
  function resolveShortlistK(config) {
9178
9193
  const k = config?.ontology?.shortlistK;
@@ -9212,6 +9227,34 @@ function resolveEdgesMinConfidence(config) {
9212
9227
  );
9213
9228
  return void 0;
9214
9229
  }
9230
+ function resolveResolveMinConfidence(config) {
9231
+ if (resolveSystemOneResolve(config) !== "auto") return void 0;
9232
+ const floor = config?.systemOne?.minConfidence?.resolve;
9233
+ if (isEdgesFloor(floor)) return floor;
9234
+ warnOnce(
9235
+ floor === void 0 ? "[core-llm-wiki] systemOne: `systemOne.minConfidence.resolve` is required when `systemOne.resolve` is 'auto'. A wrong NOOP drops a live fact, so there is no default floor. The resolution screen is off; resolution stays on the generative path." : `[core-llm-wiki] systemOne: \`systemOne.minConfidence.resolve\` is ${formatConfigValue(floor)}, which is not a finite number in [0.5, 1]. A wrong NOOP drops a live fact, so the resolution screen is off; resolution stays on the generative path.`
9236
+ );
9237
+ return void 0;
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
+ }
9215
9258
 
9216
9259
  // src/repositories/VectorRemovalRepository.ts
9217
9260
  var CHUNK2 = 500;
@@ -10492,6 +10535,46 @@ async function gateCandidates(deps, ctx, candidates, cfg) {
10492
10535
  }
10493
10536
 
10494
10537
  // src/services/librarian/ops/resolve.ts
10538
+ async function screenResolveCandidates(ambiguous, mode, floor, ask) {
10539
+ const whole = (warnReason) => warnReason ? { settled: /* @__PURE__ */ new Map(), rest: ambiguous, warnReason } : { settled: /* @__PURE__ */ new Map(), rest: ambiguous };
10540
+ if (mode !== "auto") return whole();
10541
+ if (floor === void 0) return whole("no-floor");
10542
+ if (!ask) return whole("no-classifier");
10543
+ const settled = /* @__PURE__ */ new Map();
10544
+ const rest = [];
10545
+ for (const g of ambiguous) {
10546
+ const best = g.neighbours[0];
10547
+ if (!best) {
10548
+ rest.push(g);
10549
+ continue;
10550
+ }
10551
+ const question = {
10552
+ kind: "binary",
10553
+ instructions: `Does this candidate add NO information beyond neighbour ${best.ref} (a pure duplicate: same claims, no new content)?
10554
+ Neighbour ${best.ref} title: ${best.title}
10555
+ Neighbour ${best.ref} body: ${safeSlice(best.body, 0, OPS_NEIGHBOUR_BODY_CHARS)}`
10556
+ };
10557
+ let response;
10558
+ try {
10559
+ response = await ask({
10560
+ state: classifierStateForFact({ title: g.candidate.fact.title, body: g.candidate.fact.body, tags: [] }),
10561
+ questions: { [best.ref]: question }
10562
+ });
10563
+ } catch (err) {
10564
+ if (err instanceof WikiBudgetExhausted) {
10565
+ return { settled: /* @__PURE__ */ new Map(), rest: ambiguous, budgetStop: { requiredEstimate: err.requiredEstimate } };
10566
+ }
10567
+ return whole("classifier-threw");
10568
+ }
10569
+ const checked = validateClassifierAnswer(response, best.ref, question);
10570
+ if (checked.ok && checked.answer.kind === "binary" && checked.answer.probability >= floor) {
10571
+ settled.set(g, { op: "NOOP", targetId: best.id });
10572
+ } else {
10573
+ rest.push(g);
10574
+ }
10575
+ }
10576
+ return { settled, rest };
10577
+ }
10495
10578
  function validateOp(raw, aliases) {
10496
10579
  if (!raw || typeof raw !== "object") return null;
10497
10580
  const r = raw;
@@ -10511,11 +10594,31 @@ function validateOp(raw, aliases) {
10511
10594
  }
10512
10595
  var aliasMapOf = (g) => new Map(g.neighbours.map((n) => [n.ref, n.id]));
10513
10596
  async function runResolve(deps, ctx, ambiguous, budget) {
10514
- const out = { ops: /* @__PURE__ */ new Map(), rejected: [], failed: [], overflowSkipped: [] };
10597
+ const out = { ops: /* @__PURE__ */ new Map(), rejected: [], failed: [], overflowSkipped: [], classifierSettled: [] };
10515
10598
  if (ambiguous.length === 0) return out;
10516
10599
  const { entityId, trigger } = ctx;
10600
+ const mode = resolveSystemOneResolve(deps.options.config);
10601
+ const floor = resolveResolveMinConfidence(deps.options.config);
10602
+ const provider = deps.options.llmProvider;
10603
+ const ask = mode === "auto" && typeof provider.classify === "function" ? (request) => callClassify(deps.options, { operation: "librarian", entityId, trigger, meter: ctx.meter }, request) : void 0;
10604
+ const screen = await screenResolveCandidates(ambiguous, mode, floor, ask);
10605
+ if (screen.budgetStop) return { ...out, budgetStop: screen.budgetStop };
10606
+ if (screen.warnReason === "no-classifier") {
10607
+ warnOnce(
10608
+ "[core-llm-wiki] systemOne: `systemOne.resolve` is 'auto' but the provider has no classify(); ambiguous candidates fall through to the generative resolve."
10609
+ );
10610
+ } else if (screen.warnReason === "classifier-threw") {
10611
+ warnOnce(
10612
+ "[core-llm-wiki] systemOne: `systemOne.resolve` is 'auto' but classify() threw during the resolve screen; ambiguous candidates fall through to the generative resolve."
10613
+ );
10614
+ }
10615
+ for (const [g, op] of screen.settled) {
10616
+ out.ops.set(g, op);
10617
+ out.classifierSettled.push(g.candidate.index);
10618
+ }
10619
+ if (screen.rest.length === 0) return out;
10517
10620
  const outcome = await runBatched({
10518
- items: ambiguous,
10621
+ items: screen.rest,
10519
10622
  buildPrompt: (batch) => deps.promptService.buildOpsResolvePrompt(
10520
10623
  batch.map((g, i) => ({
10521
10624
  item: i,
@@ -10804,6 +10907,16 @@ var runOpsLibrarianPass = async (deps, ctx) => {
10804
10907
  // (index into the merged extract batch)
10805
10908
  });
10806
10909
  }
10910
+ for (const itemIndex of res.classifierSettled) {
10911
+ diagnostics.push({
10912
+ entityId,
10913
+ operation: "librarian",
10914
+ trigger,
10915
+ code: "fact_deduplicated",
10916
+ detail: { itemIndex, reason: "classifier" }
10917
+ // (index into the merged extract batch)
10918
+ });
10919
+ }
10807
10920
  if (res.budgetStop) {
10808
10921
  diagnostics.discard();
10809
10922
  return { processedThrough: null, factsWritten: 0, budgetStop: res.budgetStop };
@@ -12054,12 +12167,24 @@ DROP TRIGGER IF EXISTS ${ad};`);
12054
12167
  * `result.remaining > 0` for convergence — see {@link HealResult.remaining}
12055
12168
  * for what convergence means here, and for the no-progress flags
12056
12169
  * (`searchUnavailable`, `budgetStop`) a loop must also stop on.
12170
+ *
12171
+ * Heal screen (`systemOne.healScreen: 'auto'` + `minConfidence.healScreen`):
12172
+ * a model-directed delete or downgrade whose valid `confidence` is below the
12173
+ * floor is withheld from every reader (apply, sync, removals, counts, id
12174
+ * lists); a missing or invalid confidence is applied unscreened. Each
12175
+ * model-directed move emits a `heal_deleted` / `heal_downgraded` receipt
12176
+ * after commit (`applied`, `applied_unscreened`, or `below_floor`), in every
12177
+ * mode. An `applied` receipt records that the model VERDICT was applied
12178
+ * (`downgradeByIds` runs unconditionally): a fact that was already at
12179
+ * reduced confidence still gets an `applied` receipt. A withheld delete paired with a restating `newFact` leaves the fact
12180
+ * live and the restatement is skipped as `fact_deduplicated`.
12057
12181
  */
12058
12182
  async doRunHeal(entityId, options) {
12059
12183
  const promptOverride = options?.promptOverride;
12060
12184
  const batchSize = options?.batchSize ?? HEAL_BATCH_SIZE;
12061
12185
  const trigger = options?.trigger ?? "call";
12062
12186
  const diagBase = { entityId, operation: "heal", trigger };
12187
+ const healFloor = resolveHealScreenMinConfidence(this.options.config);
12063
12188
  if (!Number.isInteger(batchSize) || batchSize < 1) {
12064
12189
  throw new Error("Invalid batchSize: must be an integer >= 1");
12065
12190
  }
@@ -12105,6 +12230,8 @@ DROP TRIGGER IF EXISTS ${ad};`);
12105
12230
  downgraded: staleDowngradedIds.length,
12106
12231
  deleted: orphanedIds.length,
12107
12232
  newFactsCreated: 0,
12233
+ downgradedIds: Array.from(new Set(staleDowngradedIds)),
12234
+ deletedIds: Array.from(new Set(orphanedIds)),
12108
12235
  skipped: [],
12109
12236
  degraded: [],
12110
12237
  remaining: counts2.eligible,
@@ -12155,10 +12282,30 @@ DROP TRIGGER IF EXISTS ${ad};`);
12155
12282
  call: (prompts) => callLlm(this.options, { operation: "heal", entityId, trigger, meter: options?.meter }, prompts),
12156
12283
  parse: (responseText, batch, prompts) => {
12157
12284
  const result = parseJsonResponse(responseText);
12285
+ const normalize = (raw) => {
12286
+ const ids = [];
12287
+ const confidence = /* @__PURE__ */ new Map();
12288
+ if (!Array.isArray(raw)) return { ids, confidence };
12289
+ for (const entry of raw) {
12290
+ const id = typeof entry === "string" ? entry : entry?.id;
12291
+ if (typeof id !== "string") continue;
12292
+ ids.push(id);
12293
+ const c = typeof entry === "object" && entry !== null ? entry.confidence : void 0;
12294
+ if (typeof c === "number" && Number.isFinite(c) && c >= 0 && c <= 1) {
12295
+ const prev = confidence.get(id);
12296
+ if (prev === void 0 || c < prev) confidence.set(id, c);
12297
+ }
12298
+ }
12299
+ return { ids, confidence };
12300
+ };
12301
+ const down = normalize(result.downgraded);
12302
+ const del = normalize(result.deleted);
12158
12303
  return {
12159
12304
  batch,
12160
- downgraded: Array.isArray(result.downgraded) ? result.downgraded : [],
12161
- deleted: Array.isArray(result.deleted) ? result.deleted : [],
12305
+ downgraded: down.ids,
12306
+ deleted: del.ids,
12307
+ downgradedConfidence: down.confidence,
12308
+ deletedConfidence: del.confidence,
12162
12309
  newFacts: Array.isArray(result.newFacts) ? result.newFacts : [],
12163
12310
  corpus: corpusByPrompt.get(prompts) ?? null
12164
12311
  };
@@ -12198,8 +12345,42 @@ DROP TRIGGER IF EXISTS ${ad};`);
12198
12345
  newFactCorpora.push(batchResult.corpus);
12199
12346
  });
12200
12347
  }
12348
+ const downgradeConfidence = /* @__PURE__ */ new Map();
12349
+ const deleteConfidence = /* @__PURE__ */ new Map();
12350
+ const mergeLowest = (into, id, c) => {
12351
+ if (c === void 0) return;
12352
+ const prev = into.get(id);
12353
+ if (prev === void 0 || c < prev) into.set(id, c);
12354
+ };
12355
+ for (const batchResult of outcome.results) {
12356
+ const mutableIds = new Set(batchResult.batch.map((f) => f.id));
12357
+ for (const id of batchResult.downgraded) if (mutableIds.has(id)) mergeLowest(downgradeConfidence, id, batchResult.downgradedConfidence.get(id));
12358
+ for (const id of batchResult.deleted) if (mutableIds.has(id)) mergeLowest(deleteConfidence, id, batchResult.deletedConfidence.get(id));
12359
+ }
12201
12360
  const safeDowngraded = Array.from(safeDowngradedSet);
12202
12361
  const safeDeleted = Array.from(safeDeletedSet);
12362
+ const withheldDowngraded = /* @__PURE__ */ new Map();
12363
+ const withheldDeleted = /* @__PURE__ */ new Map();
12364
+ let appliedDowngraded = safeDowngraded;
12365
+ let appliedDeleted = safeDeleted;
12366
+ if (healFloor !== void 0) {
12367
+ const screen = (ids, confidences, withheld) => {
12368
+ const applied = [];
12369
+ for (const id of ids) {
12370
+ const c = confidences.get(id);
12371
+ if (c !== void 0 && c < healFloor) withheld.set(id, c);
12372
+ else applied.push(id);
12373
+ }
12374
+ return applied;
12375
+ };
12376
+ appliedDowngraded = screen(safeDowngraded, downgradeConfidence, withheldDowngraded);
12377
+ appliedDeleted = screen(safeDeleted, deleteConfidence, withheldDeleted);
12378
+ if (appliedDowngraded.some((id) => !downgradeConfidence.has(id)) || appliedDeleted.some((id) => !deleteConfidence.has(id))) {
12379
+ warnOnce(
12380
+ '[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).'
12381
+ );
12382
+ }
12383
+ }
12203
12384
  const diagBuffer = new DiagnosticBuffer();
12204
12385
  const validNewFacts = [];
12205
12386
  const validNewFactItemIndexes = [];
@@ -12216,10 +12397,10 @@ DROP TRIGGER IF EXISTS ${ad};`);
12216
12397
  }
12217
12398
  });
12218
12399
  const insertedFacts = [];
12219
- const uniqueDeletedFactIds = Array.from(new Set(safeDeleted));
12400
+ const uniqueDeletedFactIds = Array.from(new Set(appliedDeleted));
12220
12401
  await this.db.withTransactionAsync(async (tx) => {
12221
- await this.entryRepo.downgradeByIds(safeDowngraded, entityId, tx);
12222
- await this.entryRepo.softDeleteByIds(safeDeleted, entityId, tx);
12402
+ await this.entryRepo.downgradeByIds(appliedDowngraded, entityId, tx);
12403
+ await this.entryRepo.softDeleteByIds(appliedDeleted, entityId, tx);
12223
12404
  const healFactsForDedupe = await this.entryRepo.findInferredTitlesByEntityId(entityId, tx);
12224
12405
  for (const [k, fact] of validNewFacts.entries()) {
12225
12406
  const newTokens = titleTokens(fact.title);
@@ -12283,11 +12464,29 @@ DROP TRIGGER IF EXISTS ${ad};`);
12283
12464
  for (const { item, reason } of outcome.skipped) {
12284
12465
  diagBuffer.push({ ...diagBase, code: "heal_skipped", detail: { factId: item.id, reason } });
12285
12466
  }
12467
+ const pushReceipts = (code, applied, confidences, withheld) => {
12468
+ for (const factId of applied) {
12469
+ if (healFloor !== void 0 && !confidences.has(factId)) {
12470
+ diagBuffer.push({ ...diagBase, code, detail: { factId, reason: "applied_unscreened" } });
12471
+ } else {
12472
+ diagBuffer.push({ ...diagBase, code, detail: { factId, reason: "applied" } });
12473
+ }
12474
+ }
12475
+ for (const [factId, confidence] of withheld) {
12476
+ diagBuffer.push({
12477
+ ...diagBase,
12478
+ code,
12479
+ detail: { factId, reason: "below_floor", ...confidence !== void 0 ? { confidence } : {} }
12480
+ });
12481
+ }
12482
+ };
12483
+ pushReceipts("heal_downgraded", appliedDowngraded, downgradeConfidence, withheldDowngraded);
12484
+ pushReceipts("heal_deleted", appliedDeleted, deleteConfidence, withheldDeleted);
12286
12485
  diagBuffer.flush(this.options);
12287
12486
  const healSyncIds = Array.from(/* @__PURE__ */ new Set([
12288
12487
  ...orphanedIds,
12289
12488
  ...staleDowngradedIds,
12290
- ...safeDowngraded,
12489
+ ...appliedDowngraded,
12291
12490
  ...uniqueDeletedFactIds,
12292
12491
  ...insertedFacts.map((f) => f.id)
12293
12492
  ]));
@@ -12306,13 +12505,15 @@ DROP TRIGGER IF EXISTS ${ad};`);
12306
12505
  }
12307
12506
  let scanned = outcome.skipped.length;
12308
12507
  for (const batchResult of outcome.results) scanned += batchResult.batch.length;
12309
- const allDowngraded = /* @__PURE__ */ new Set([...staleDowngradedIds, ...safeDowngraded]);
12508
+ const allDowngraded = /* @__PURE__ */ new Set([...staleDowngradedIds, ...appliedDowngraded]);
12310
12509
  const allDeleted = /* @__PURE__ */ new Set([...orphanedIds, ...uniqueDeletedFactIds]);
12311
12510
  const counts = await this.entryRepo.countHealCandidatesByEntityId(entityId, recheckCutoff);
12312
12511
  return {
12313
12512
  scanned,
12314
12513
  downgraded: allDowngraded.size,
12315
12514
  deleted: allDeleted.size,
12515
+ downgradedIds: Array.from(allDowngraded),
12516
+ deletedIds: Array.from(allDeleted),
12316
12517
  newFactsCreated: insertedFacts.length,
12317
12518
  skipped: outcome.skipped.map(({ item, reason }) => ({ id: item.id, reason })),
12318
12519
  degraded: healedDegraded,
@@ -18402,9 +18603,13 @@ exports.parseOkfBundle = parseOkfBundle;
18402
18603
  exports.resolveContextBudget = resolveContextBudget;
18403
18604
  exports.resolveDefaultChunkLength = resolveDefaultChunkLength;
18404
18605
  exports.resolveEdgesMinConfidence = resolveEdgesMinConfidence;
18606
+ exports.resolveHealScreenMinConfidence = resolveHealScreenMinConfidence;
18405
18607
  exports.resolveMaxPromptChars = resolveMaxPromptChars;
18406
18608
  exports.resolveOntologyJobDefaults = resolveOntologyJobDefaults;
18609
+ exports.resolveResolveMinConfidence = resolveResolveMinConfidence;
18407
18610
  exports.resolveSystemOneEdges = resolveSystemOneEdges;
18611
+ exports.resolveSystemOneHealScreen = resolveSystemOneHealScreen;
18612
+ exports.resolveSystemOneResolve = resolveSystemOneResolve;
18408
18613
  exports.resolveSystemOneTyping = resolveSystemOneTyping;
18409
18614
  exports.resolveTypingMinConfidence = resolveTypingMinConfidence;
18410
18615
  exports.safeSlice = safeSlice;