@equationalapplications/core-llm-wiki 9.10.0 → 9.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,20 +4,33 @@ import { OkfSource, OkfVerifiedEntry, OkfSourceUsageWindow } from '@equationalap
4
4
  * System-One config surface (specs/system-one-config §1, §10).
5
5
  *
6
6
  * Boundary: S1-0 owns exactly `typing`, `minConfidence` (with the `'typing'`
7
- * member), and `onLowConfidence`. Later PRs add more threshold sites
8
- * (`'edges'`, `'resolve'`, `'healScreen'`) — each as one new line in
7
+ * member), and `onLowConfidence`; the edge-suggestions step adds `edges` and
8
+ * the `'edges'` member. Later PRs add more threshold sites
9
+ * (`'resolve'`, `'healScreen'`) — each as one new line in
9
10
  * `SystemOneThresholdSite`, so sibling PRs merge cleanly. Nothing outside
10
11
  * that boundary belongs here.
11
12
  */
12
- /** Sites a System-One threshold can apply to. Exactly one member today (§10 fence). */
13
- type SystemOneThresholdSite = 'typing';
13
+ /** Sites a System-One threshold can apply to. Exactly two members today: `'typing'` and `'edges'` (§10 fence). */
14
+ type SystemOneThresholdSite = 'typing' | 'edges';
14
15
  interface SystemOneConfig {
15
16
  /**
16
17
  * Typing mode for ontology backfill. `'auto'` uses
17
- * `llmProvider.classify` when present (no edges proposed); `'llm'`
18
+ * `llmProvider.classify` when present (no edges proposed, unless `systemOne.edges: 'auto'`); `'llm'`
18
19
  * always uses the generative path. Default `'llm'`.
19
20
  */
20
21
  typing?: 'auto' | 'llm';
22
+ /**
23
+ * Edge mode for ontology backfill. `'llm'` (default) keeps edge proposal
24
+ * on the generative path exactly as today. `'auto'` engages the classifier
25
+ * edge screen (§4) when the classifier step runs AND an explicit
26
+ * `minConfidence.edges` floor is set (§3 — missing floor under `'auto'`
27
+ * warns once and the site resolves `'llm'`); answers at or above the
28
+ * floor apply the edge, confident "no" answers are terminal, and facts
29
+ * whose edge answers land in the uncertain band fall through to the
30
+ * generative step of the same pass (§3, §5). There is no `'off'`: this PR
31
+ * adds no configuration that can silently discard a model-proposed edge.
32
+ */
33
+ edges?: 'auto' | 'llm';
21
34
  /** Per-site minimum confidence. Only the classifier path reads a floor. */
22
35
  minConfidence?: Partial<Record<SystemOneThresholdSite, number>>;
23
36
  /**
@@ -3989,7 +4002,7 @@ interface LibrarianResult {
3989
4002
  }
3990
4003
 
3991
4004
  declare const ONTOLOGY_BACKFILL_BATCH_SIZE = 25;
3992
- declare const ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS = 40000;
4005
+
3993
4006
  declare const ONTOLOGY_BACKFILL_RECHECK_MS: number;
3994
4007
  /**
3995
4008
  * Upper bound on one classifier choice question (specs/system-one-config §5):
@@ -4328,7 +4341,14 @@ declare class MaintenanceService {
4328
4341
  * untyped fact over the effective manifest's node-type slugs plus the
4329
4342
  * reserved abstain sentinel. Accepted answers go through
4330
4343
  * `_applyOntologyBackfillBatch` exactly like LLM classifications. No edges
4331
- * are proposed. Abstains and low-confidence answers are cooldown-stamped
4344
+ * are proposed unless `systemOne.edges` is `'auto'`; under `'auto'` the
4345
+ * classifier screens per-fact edge questions against
4346
+ * `systemOne.minConfidence.edges` (an explicit floor; missing → warn and
4347
+ * `'llm'`). Confident "yes" answers (`p > 0.5 && p >= floor`) apply,
4348
+ * confident "no" answers (`p < 0.5 && 1 - p >= floor`) are terminal, and
4349
+ * everything else (including exactly `p = 0.5`) plus invalid edge answers
4350
+ * fall through to the generative step. Edge outcomes are evaluated only for
4351
+ * typing-ACCEPTED facts. Abstains and low-confidence answers are cooldown-stamped
4332
4352
  * omissions under `onLowConfidence: 'leave'`; under `'llm'` they are
4333
4353
  * returned un-stamped in `escalated` for the generative step. Always
4334
4354
  * returns the `OntologyBackfillResult` for its step plus escalation state.
@@ -5252,5 +5272,5 @@ declare class WikiMemory {
5252
5272
  setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
5253
5273
  }
5254
5274
 
5255
- export { ONTOLOGY_BACKFILL_RECHECK_MS as $, HEAL_RECHECK_MS as A, HOOK_TIMEOUT_MARKER as B, CLASSIFIER_MAX_CHOICES as C, HEAL_BATCH_SIZE as H, ONTOLOGY_ABSTAIN_SENTINEL as Y, ONTOLOGY_BACKFILL_BATCH_SIZE as Z, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as _, EmbeddingService as a$, WikiDraftNotFound as aB, WikiDuplicateHashError as aC, WikiExternalDeletionError as aF, WikiGraphNodeOwnershipConflict as aH, WikiIngestEmptyError as aI, WikiInvalidReadOptions as aK, WikiMigrationRequiredError as aN, WikiParseError as aP, WikiSearchUnavailableError as aQ, WikiSourceRefHashCollision as aS, WikiStrictOntologyViolation as aT, WikiSupersedeError as aU, WikiTransactionError as aX, isReservedAbstainSlug as aY, isWikiSearchUnavailableError as aZ, validateManifest as a_, PromptService as aa, PrunePartialFailureError as ab, WikiBusyError as as, ImportExportService as b0, IngestionService as b1, JobManager as b2, MaintenanceService as b3, RetrievalService as b4, SearchService as b5, WriteService as b6, WikiMemory as e, CheckpointIncompleteError as f, EraseStepError as r };
5256
- export type { DegradedRecord as D, EmbedFactResult as E, FormatContextOptions as F, GraphNeighborhood as G, HealResult as I, ImportDumpResult as J, IngestDocumentResult as K, LLMProvider as L, MemoryBundle as M, LibrarianConfig as N, OntologyMode as O, LibrarianGateConfig as P, LockedMaintenanceJob as Q, ReadOptions as R, SQLiteAdapter as S, MaintenanceJob as T, MaintenanceStopReason as U, MemoryDumpEntity as V, WikiConfig as W, MigrationPolicy as X, MemoryDump as a, OntologyBackfillResult as a0, OntologyEdgeType as a1, OntologyManifest as a2, OntologyNodeType as a3, OntologyPromptContext as a4, OntologyUpdates as a5, PendingMaintenance as a6, PendingMigrationWork as a7, PendingSourceStatus as a8, PromptOverrides as a9, WikiDiagnosticTrigger as aA, WikiEdge as aD, WikiEvent as aE, WikiFact as aG, WikiInstructions as aJ, WikiLintReport as aL, WikiMemoryTestAccess as aM, WikiOutboxEvent as aO, WikiSourcePointer as aR, WikiSupersedeReason as aV, WikiTask as aW, ReembedResult as ac, RememberInput as ad, RunPendingMaintenanceOptions as ae, RunPendingMaintenanceResult as af, SourcePassage as ag, StoreSourceResult as ah, StoredSource as ai, StoredSourceDump as aj, StoredSourceSummary as ak, SupersedeReplacement as al, SystemOneConfig as am, SystemOneThresholdSite as an, VectorRanker as ao, VectorRankerFallback as ap, VectorRankerRankArgs as aq, VectorRankerSemanticResult as ar, WikiBusyOperation as at, WikiCheckpoint as au, WikiDiagnostic as av, WikiDiagnosticCode as aw, WikiDiagnosticDetail as ax, WikiDiagnosticOperation as ay, WikiDiagnosticSeverity as az, FormattedMemoryDump as b, OntologyConfig as c, WikiOptions as d, ChunkFailure as g, ClassifierAnswer as h, ClassifierQuestion as i, ClassifyRequest as j, ClassifyResponse as k, DraftPage as l, EmbedFailureKind as m, EmbeddingMarkerKind as n, EntityMaintenanceReport as o, EntityStatus as p, EraseReport as q, ExtractedFact as s, ExtractedFactEdge as t, ExtractedFactWithOntology as u, ExtractedTask as v, ForgetParams as w, ForgetResult as x, GraphTraversalOptions as y, GroundingConfig as z };
5275
+ export { HEAL_RECHECK_MS as A, HOOK_TIMEOUT_MARKER as B, CLASSIFIER_MAX_CHOICES as C, HEAL_BATCH_SIZE as H, ONTOLOGY_ABSTAIN_SENTINEL as Y, ONTOLOGY_BACKFILL_BATCH_SIZE as Z, ONTOLOGY_BACKFILL_RECHECK_MS as _, ImportExportService as a$, PromptService as a9, WikiDraftNotFound as aA, WikiDuplicateHashError as aB, WikiExternalDeletionError as aE, WikiGraphNodeOwnershipConflict as aG, WikiIngestEmptyError as aH, WikiInvalidReadOptions as aJ, WikiMigrationRequiredError as aM, WikiParseError as aO, WikiSearchUnavailableError as aP, WikiSourceRefHashCollision as aR, WikiStrictOntologyViolation as aS, WikiSupersedeError as aT, WikiTransactionError as aW, isReservedAbstainSlug as aX, isWikiSearchUnavailableError as aY, validateManifest as aZ, EmbeddingService as a_, PrunePartialFailureError as aa, WikiBusyError as ar, IngestionService as b0, JobManager as b1, MaintenanceService as b2, RetrievalService as b3, SearchService as b4, WriteService as b5, WikiMemory as e, CheckpointIncompleteError as f, EraseStepError as r };
5276
+ export type { OntologyBackfillResult as $, DegradedRecord as D, EmbedFactResult as E, FormatContextOptions as F, GraphNeighborhood as G, HealResult as I, ImportDumpResult as J, IngestDocumentResult as K, LLMProvider as L, MemoryBundle as M, LibrarianConfig as N, OntologyMode as O, LibrarianGateConfig as P, LockedMaintenanceJob as Q, ReadOptions as R, SQLiteAdapter as S, MaintenanceJob as T, MaintenanceStopReason as U, MemoryDumpEntity as V, WikiConfig as W, MigrationPolicy as X, MemoryDump as a, OntologyEdgeType as a0, OntologyManifest as a1, OntologyNodeType as a2, OntologyPromptContext as a3, OntologyUpdates as a4, PendingMaintenance as a5, PendingMigrationWork as a6, PendingSourceStatus as a7, PromptOverrides as a8, WikiEdge as aC, WikiEvent as aD, WikiFact as aF, WikiInstructions as aI, WikiLintReport as aK, WikiMemoryTestAccess as aL, WikiOutboxEvent as aN, WikiSourcePointer as aQ, WikiSupersedeReason as aU, WikiTask as aV, ReembedResult as ab, RememberInput as ac, RunPendingMaintenanceOptions as ad, RunPendingMaintenanceResult as ae, SourcePassage as af, StoreSourceResult as ag, StoredSource as ah, StoredSourceDump as ai, StoredSourceSummary as aj, SupersedeReplacement as ak, SystemOneConfig as al, SystemOneThresholdSite as am, VectorRanker as an, VectorRankerFallback as ao, VectorRankerRankArgs as ap, VectorRankerSemanticResult as aq, WikiBusyOperation as as, WikiCheckpoint as at, WikiDiagnostic as au, WikiDiagnosticCode as av, WikiDiagnosticDetail as aw, WikiDiagnosticOperation as ax, WikiDiagnosticSeverity as ay, WikiDiagnosticTrigger as az, FormattedMemoryDump as b, OntologyConfig as c, WikiOptions as d, ChunkFailure as g, ClassifierAnswer as h, ClassifierQuestion as i, ClassifyRequest as j, ClassifyResponse as k, DraftPage as l, EmbedFailureKind as m, EmbeddingMarkerKind as n, EntityMaintenanceReport as o, EntityStatus as p, EraseReport as q, ExtractedFact as s, ExtractedFactEdge as t, ExtractedFactWithOntology as u, ExtractedTask as v, ForgetParams as w, ForgetResult as x, GraphTraversalOptions as y, GroundingConfig as z };
@@ -4,20 +4,33 @@ import { OkfSource, OkfVerifiedEntry, OkfSourceUsageWindow } from '@equationalap
4
4
  * System-One config surface (specs/system-one-config §1, §10).
5
5
  *
6
6
  * Boundary: S1-0 owns exactly `typing`, `minConfidence` (with the `'typing'`
7
- * member), and `onLowConfidence`. Later PRs add more threshold sites
8
- * (`'edges'`, `'resolve'`, `'healScreen'`) — each as one new line in
7
+ * member), and `onLowConfidence`; the edge-suggestions step adds `edges` and
8
+ * the `'edges'` member. Later PRs add more threshold sites
9
+ * (`'resolve'`, `'healScreen'`) — each as one new line in
9
10
  * `SystemOneThresholdSite`, so sibling PRs merge cleanly. Nothing outside
10
11
  * that boundary belongs here.
11
12
  */
12
- /** Sites a System-One threshold can apply to. Exactly one member today (§10 fence). */
13
- type SystemOneThresholdSite = 'typing';
13
+ /** Sites a System-One threshold can apply to. Exactly two members today: `'typing'` and `'edges'` (§10 fence). */
14
+ type SystemOneThresholdSite = 'typing' | 'edges';
14
15
  interface SystemOneConfig {
15
16
  /**
16
17
  * Typing mode for ontology backfill. `'auto'` uses
17
- * `llmProvider.classify` when present (no edges proposed); `'llm'`
18
+ * `llmProvider.classify` when present (no edges proposed, unless `systemOne.edges: 'auto'`); `'llm'`
18
19
  * always uses the generative path. Default `'llm'`.
19
20
  */
20
21
  typing?: 'auto' | 'llm';
22
+ /**
23
+ * Edge mode for ontology backfill. `'llm'` (default) keeps edge proposal
24
+ * on the generative path exactly as today. `'auto'` engages the classifier
25
+ * edge screen (§4) when the classifier step runs AND an explicit
26
+ * `minConfidence.edges` floor is set (§3 — missing floor under `'auto'`
27
+ * warns once and the site resolves `'llm'`); answers at or above the
28
+ * floor apply the edge, confident "no" answers are terminal, and facts
29
+ * whose edge answers land in the uncertain band fall through to the
30
+ * generative step of the same pass (§3, §5). There is no `'off'`: this PR
31
+ * adds no configuration that can silently discard a model-proposed edge.
32
+ */
33
+ edges?: 'auto' | 'llm';
21
34
  /** Per-site minimum confidence. Only the classifier path reads a floor. */
22
35
  minConfidence?: Partial<Record<SystemOneThresholdSite, number>>;
23
36
  /**
@@ -3989,7 +4002,7 @@ interface LibrarianResult {
3989
4002
  }
3990
4003
 
3991
4004
  declare const ONTOLOGY_BACKFILL_BATCH_SIZE = 25;
3992
- declare const ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS = 40000;
4005
+
3993
4006
  declare const ONTOLOGY_BACKFILL_RECHECK_MS: number;
3994
4007
  /**
3995
4008
  * Upper bound on one classifier choice question (specs/system-one-config §5):
@@ -4328,7 +4341,14 @@ declare class MaintenanceService {
4328
4341
  * untyped fact over the effective manifest's node-type slugs plus the
4329
4342
  * reserved abstain sentinel. Accepted answers go through
4330
4343
  * `_applyOntologyBackfillBatch` exactly like LLM classifications. No edges
4331
- * are proposed. Abstains and low-confidence answers are cooldown-stamped
4344
+ * are proposed unless `systemOne.edges` is `'auto'`; under `'auto'` the
4345
+ * classifier screens per-fact edge questions against
4346
+ * `systemOne.minConfidence.edges` (an explicit floor; missing → warn and
4347
+ * `'llm'`). Confident "yes" answers (`p > 0.5 && p >= floor`) apply,
4348
+ * confident "no" answers (`p < 0.5 && 1 - p >= floor`) are terminal, and
4349
+ * everything else (including exactly `p = 0.5`) plus invalid edge answers
4350
+ * fall through to the generative step. Edge outcomes are evaluated only for
4351
+ * typing-ACCEPTED facts. Abstains and low-confidence answers are cooldown-stamped
4332
4352
  * omissions under `onLowConfidence: 'leave'`; under `'llm'` they are
4333
4353
  * returned un-stamped in `escalated` for the generative step. Always
4334
4354
  * returns the `OntologyBackfillResult` for its step plus escalation state.
@@ -5252,5 +5272,5 @@ declare class WikiMemory {
5252
5272
  setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
5253
5273
  }
5254
5274
 
5255
- export { ONTOLOGY_BACKFILL_RECHECK_MS as $, HEAL_RECHECK_MS as A, HOOK_TIMEOUT_MARKER as B, CLASSIFIER_MAX_CHOICES as C, HEAL_BATCH_SIZE as H, ONTOLOGY_ABSTAIN_SENTINEL as Y, ONTOLOGY_BACKFILL_BATCH_SIZE as Z, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as _, EmbeddingService as a$, WikiDraftNotFound as aB, WikiDuplicateHashError as aC, WikiExternalDeletionError as aF, WikiGraphNodeOwnershipConflict as aH, WikiIngestEmptyError as aI, WikiInvalidReadOptions as aK, WikiMigrationRequiredError as aN, WikiParseError as aP, WikiSearchUnavailableError as aQ, WikiSourceRefHashCollision as aS, WikiStrictOntologyViolation as aT, WikiSupersedeError as aU, WikiTransactionError as aX, isReservedAbstainSlug as aY, isWikiSearchUnavailableError as aZ, validateManifest as a_, PromptService as aa, PrunePartialFailureError as ab, WikiBusyError as as, ImportExportService as b0, IngestionService as b1, JobManager as b2, MaintenanceService as b3, RetrievalService as b4, SearchService as b5, WriteService as b6, WikiMemory as e, CheckpointIncompleteError as f, EraseStepError as r };
5256
- export type { DegradedRecord as D, EmbedFactResult as E, FormatContextOptions as F, GraphNeighborhood as G, HealResult as I, ImportDumpResult as J, IngestDocumentResult as K, LLMProvider as L, MemoryBundle as M, LibrarianConfig as N, OntologyMode as O, LibrarianGateConfig as P, LockedMaintenanceJob as Q, ReadOptions as R, SQLiteAdapter as S, MaintenanceJob as T, MaintenanceStopReason as U, MemoryDumpEntity as V, WikiConfig as W, MigrationPolicy as X, MemoryDump as a, OntologyBackfillResult as a0, OntologyEdgeType as a1, OntologyManifest as a2, OntologyNodeType as a3, OntologyPromptContext as a4, OntologyUpdates as a5, PendingMaintenance as a6, PendingMigrationWork as a7, PendingSourceStatus as a8, PromptOverrides as a9, WikiDiagnosticTrigger as aA, WikiEdge as aD, WikiEvent as aE, WikiFact as aG, WikiInstructions as aJ, WikiLintReport as aL, WikiMemoryTestAccess as aM, WikiOutboxEvent as aO, WikiSourcePointer as aR, WikiSupersedeReason as aV, WikiTask as aW, ReembedResult as ac, RememberInput as ad, RunPendingMaintenanceOptions as ae, RunPendingMaintenanceResult as af, SourcePassage as ag, StoreSourceResult as ah, StoredSource as ai, StoredSourceDump as aj, StoredSourceSummary as ak, SupersedeReplacement as al, SystemOneConfig as am, SystemOneThresholdSite as an, VectorRanker as ao, VectorRankerFallback as ap, VectorRankerRankArgs as aq, VectorRankerSemanticResult as ar, WikiBusyOperation as at, WikiCheckpoint as au, WikiDiagnostic as av, WikiDiagnosticCode as aw, WikiDiagnosticDetail as ax, WikiDiagnosticOperation as ay, WikiDiagnosticSeverity as az, FormattedMemoryDump as b, OntologyConfig as c, WikiOptions as d, ChunkFailure as g, ClassifierAnswer as h, ClassifierQuestion as i, ClassifyRequest as j, ClassifyResponse as k, DraftPage as l, EmbedFailureKind as m, EmbeddingMarkerKind as n, EntityMaintenanceReport as o, EntityStatus as p, EraseReport as q, ExtractedFact as s, ExtractedFactEdge as t, ExtractedFactWithOntology as u, ExtractedTask as v, ForgetParams as w, ForgetResult as x, GraphTraversalOptions as y, GroundingConfig as z };
5275
+ export { HEAL_RECHECK_MS as A, HOOK_TIMEOUT_MARKER as B, CLASSIFIER_MAX_CHOICES as C, HEAL_BATCH_SIZE as H, ONTOLOGY_ABSTAIN_SENTINEL as Y, ONTOLOGY_BACKFILL_BATCH_SIZE as Z, ONTOLOGY_BACKFILL_RECHECK_MS as _, ImportExportService as a$, PromptService as a9, WikiDraftNotFound as aA, WikiDuplicateHashError as aB, WikiExternalDeletionError as aE, WikiGraphNodeOwnershipConflict as aG, WikiIngestEmptyError as aH, WikiInvalidReadOptions as aJ, WikiMigrationRequiredError as aM, WikiParseError as aO, WikiSearchUnavailableError as aP, WikiSourceRefHashCollision as aR, WikiStrictOntologyViolation as aS, WikiSupersedeError as aT, WikiTransactionError as aW, isReservedAbstainSlug as aX, isWikiSearchUnavailableError as aY, validateManifest as aZ, EmbeddingService as a_, PrunePartialFailureError as aa, WikiBusyError as ar, IngestionService as b0, JobManager as b1, MaintenanceService as b2, RetrievalService as b3, SearchService as b4, WriteService as b5, WikiMemory as e, CheckpointIncompleteError as f, EraseStepError as r };
5276
+ export type { OntologyBackfillResult as $, DegradedRecord as D, EmbedFactResult as E, FormatContextOptions as F, GraphNeighborhood as G, HealResult as I, ImportDumpResult as J, IngestDocumentResult as K, LLMProvider as L, MemoryBundle as M, LibrarianConfig as N, OntologyMode as O, LibrarianGateConfig as P, LockedMaintenanceJob as Q, ReadOptions as R, SQLiteAdapter as S, MaintenanceJob as T, MaintenanceStopReason as U, MemoryDumpEntity as V, WikiConfig as W, MigrationPolicy as X, MemoryDump as a, OntologyEdgeType as a0, OntologyManifest as a1, OntologyNodeType as a2, OntologyPromptContext as a3, OntologyUpdates as a4, PendingMaintenance as a5, PendingMigrationWork as a6, PendingSourceStatus as a7, PromptOverrides as a8, WikiEdge as aC, WikiEvent as aD, WikiFact as aF, WikiInstructions as aI, WikiLintReport as aK, WikiMemoryTestAccess as aL, WikiOutboxEvent as aN, WikiSourcePointer as aQ, WikiSupersedeReason as aU, WikiTask as aV, ReembedResult as ab, RememberInput as ac, RunPendingMaintenanceOptions as ad, RunPendingMaintenanceResult as ae, SourcePassage as af, StoreSourceResult as ag, StoredSource as ah, StoredSourceDump as ai, StoredSourceSummary as aj, SupersedeReplacement as ak, SystemOneConfig as al, SystemOneThresholdSite as am, VectorRanker as an, VectorRankerFallback as ao, VectorRankerRankArgs as ap, VectorRankerSemanticResult as aq, WikiBusyOperation as as, WikiCheckpoint as at, WikiDiagnostic as au, WikiDiagnosticCode as av, WikiDiagnosticDetail as aw, WikiDiagnosticOperation as ax, WikiDiagnosticSeverity as ay, WikiDiagnosticTrigger as az, FormattedMemoryDump as b, OntologyConfig as c, WikiOptions as d, ChunkFailure as g, ClassifierAnswer as h, ClassifierQuestion as i, ClassifyRequest as j, ClassifyResponse as k, DraftPage as l, EmbedFailureKind as m, EmbeddingMarkerKind as n, EntityMaintenanceReport as o, EntityStatus as p, EraseReport as q, ExtractedFact as s, ExtractedFactEdge as t, ExtractedFactWithOntology as u, ExtractedTask as v, ForgetParams as w, ForgetResult as x, GraphTraversalOptions as y, GroundingConfig as z };
@@ -1,2 +1,2 @@
1
- export { a$ as EmbeddingService, b0 as ImportExportService, b1 as IngestionService, b2 as JobManager, b2 as JobManagerType, b3 as MaintenanceService, b4 as RetrievalService, b5 as SearchService, b5 as SearchServiceType, aM as WikiMemoryTestAccess, b6 as WriteService } from './testing-DnYjL2QD.mjs';
1
+ export { a_ as EmbeddingService, a$ as ImportExportService, b0 as IngestionService, b1 as JobManager, b1 as JobManagerType, b2 as MaintenanceService, b3 as RetrievalService, b4 as SearchService, b4 as SearchServiceType, aL as WikiMemoryTestAccess, b5 as WriteService } from './testing-imNjsm-X.mjs';
2
2
  import '@equationalapplications/core-okf';
package/dist/testing.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { a$ as EmbeddingService, b0 as ImportExportService, b1 as IngestionService, b2 as JobManager, b2 as JobManagerType, b3 as MaintenanceService, b4 as RetrievalService, b5 as SearchService, b5 as SearchServiceType, aM as WikiMemoryTestAccess, b6 as WriteService } from './testing-DnYjL2QD.js';
1
+ export { a_ as EmbeddingService, a$ as ImportExportService, b0 as IngestionService, b1 as JobManager, b1 as JobManagerType, b2 as MaintenanceService, b3 as RetrievalService, b4 as SearchService, b4 as SearchServiceType, aL as WikiMemoryTestAccess, b5 as WriteService } from './testing-imNjsm-X.js';
2
2
  import '@equationalapplications/core-okf';
package/dist/testing.js CHANGED
@@ -2945,6 +2945,7 @@ var DEFAULT_CHUNK_OVERLAP = 400;
2945
2945
 
2946
2946
  // src/utils/contextCaps.ts
2947
2947
  var OPS_RESOLVE_MAX_PROMPT_CHARS = 4e4;
2948
+ var ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS = 4e4;
2948
2949
  var HEAL_MAX_PROMPT_CHARS = 4e4;
2949
2950
  var OPS_MAX_EXTRACT_CHARS = 24e3;
2950
2951
 
@@ -2955,7 +2956,8 @@ var DEFAULT_OUTPUT_RESERVE_TOKENS = 4e3;
2955
2956
  var OP_FLOOR = {
2956
2957
  resolve: OPS_RESOLVE_MAX_PROMPT_CHARS,
2957
2958
  heal: HEAL_MAX_PROMPT_CHARS,
2958
- extract: OPS_MAX_EXTRACT_CHARS
2959
+ extract: OPS_MAX_EXTRACT_CHARS,
2960
+ backfill: ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS
2959
2961
  };
2960
2962
  function bad(key, value, why) {
2961
2963
  return new Error(`[core-llm-wiki] config.context.${key} must be ${why}; received ${JSON.stringify(value)}`);
@@ -2993,12 +2995,11 @@ function declaredPromptCap(budget, op) {
2993
2995
  const derived = Math.floor(
2994
2996
  (budget.contextWindowTokens - budget.outputReserveTokens) * budget.safetyFraction * budget.charsPerToken
2995
2997
  );
2996
- if (op === "resolve") return Math.max(OP_FLOOR.resolve, derived);
2997
- return Math.max(OP_FLOOR.heal, derived);
2998
+ return Math.max(OP_FLOOR[op], derived);
2998
2999
  }
2999
3000
  function resolveMaxPromptChars(budget, op) {
3000
3001
  if (budget.mode !== "declared") {
3001
- return op === "resolve" ? OP_FLOOR.resolve : op === "heal" ? OP_FLOOR.heal : OP_FLOOR.extract;
3002
+ return OP_FLOOR[op];
3002
3003
  }
3003
3004
  if (op === "extract") {
3004
3005
  const resolveDerived = declaredPromptCap(budget, "resolve");
@@ -4115,6 +4116,16 @@ function resolveSystemOneTyping(config, classifierCallOption) {
4115
4116
  }
4116
4117
  return classifierCallOption ?? (systemOneValid ? systemOne.typing : void 0) ?? (legacyValid ? legacy : void 0) ?? "llm";
4117
4118
  }
4119
+ function resolveSystemOneEdges(config) {
4120
+ const edges = config?.systemOne?.edges;
4121
+ if (edges !== void 0 && !isTypingMode(edges)) {
4122
+ warnOnce(
4123
+ `[core-llm-wiki] systemOne: \`systemOne.edges\` is ${formatConfigValue(edges)}, which is not 'auto' or 'llm'. The key is treated as unset; the default ('llm') applies.`
4124
+ );
4125
+ return "llm";
4126
+ }
4127
+ return edges ?? "llm";
4128
+ }
4118
4129
  var DEFAULT_SHORTLIST_K = 10;
4119
4130
  function resolveShortlistK(config) {
4120
4131
  const k = config?.ontology?.shortlistK;
@@ -4144,6 +4155,16 @@ function resolveTypingMinConfidence(config) {
4144
4155
  }
4145
4156
  return (systemOneValid ? systemOneFloor : void 0) ?? (legacyValid ? legacyFloor : void 0) ?? DEFAULT_TYPING_MIN_CONFIDENCE;
4146
4157
  }
4158
+ var isEdgesFloor = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0.5 && v <= 1;
4159
+ function resolveEdgesMinConfidence(config) {
4160
+ if (resolveSystemOneEdges(config) !== "auto") return void 0;
4161
+ const floor = config?.systemOne?.minConfidence?.edges;
4162
+ if (isEdgesFloor(floor)) return floor;
4163
+ warnOnce(
4164
+ floor === void 0 ? "[core-llm-wiki] systemOne: `systemOne.minConfidence.edges` is required when `systemOne.edges` is 'auto'. The edge screen is off for this site; edges stay on the generative path." : `[core-llm-wiki] systemOne: \`systemOne.minConfidence.edges\` is ${formatConfigValue(floor)}, which is not a finite number in [0.5, 1]. The edge screen is off for this site; edges stay on the generative path.`
4165
+ );
4166
+ return void 0;
4167
+ }
4147
4168
 
4148
4169
  // src/utils/embedding.ts
4149
4170
  function parseEmbedding(blob, text) {
@@ -5927,7 +5948,6 @@ async function runLibrarianStrategy(deps, ctx) {
5927
5948
  // src/services/MaintenanceService.ts
5928
5949
  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.`;
5929
5950
  var ONTOLOGY_BACKFILL_BATCH_SIZE = 25;
5930
- var ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS = 4e4;
5931
5951
  var ONTOLOGY_BACKFILL_RECHECK_MS = 7 * 24 * 60 * 60 * 1e3;
5932
5952
  var CLASSIFIER_MAX_CHOICES = 255;
5933
5953
  var HEAL_ANCHOR_SEARCH_OVERFETCH = 4;
@@ -7404,6 +7424,7 @@ DROP TRIGGER IF EXISTS ${ad};`);
7404
7424
  throw new TypeError(`Invalid classifier option: ${JSON.stringify(options.classifier)} \u2014 must be 'auto' or 'llm'`);
7405
7425
  }
7406
7426
  const shortlistK = resolveShortlistK(this.options.config);
7427
+ const maxPromptChars = resolveMaxPromptChars(resolveContextBudget(this.options.config), "backfill");
7407
7428
  const trigger = options?.trigger ?? "call";
7408
7429
  const now = Date.now();
7409
7430
  const recheckCutoff = options?.recheckCheckedBefore ?? now - ONTOLOGY_BACKFILL_RECHECK_MS;
@@ -7423,7 +7444,10 @@ DROP TRIGGER IF EXISTS ${ad};`);
7423
7444
  return { ...zeroed, remaining: counts.eligible, deferred: counts.deferred };
7424
7445
  }
7425
7446
  const classifierMode = resolveSystemOneTyping(this.options.config, options?.classifier);
7447
+ const edgeMode = resolveSystemOneEdges(this.options.config);
7426
7448
  const classify = this.options.llmProvider.classify;
7449
+ const edgeMinConfidence = edgeMode === "auto" && classifierMode === "auto" && typeof classify === "function" ? resolveEdgesMinConfidence(this.options.config) : void 0;
7450
+ const edgeSiteMode = edgeMode === "auto" && typeof edgeMinConfidence === "number" ? "auto" : "llm";
7427
7451
  if (classifierMode === "auto" && typeof classify === "function") {
7428
7452
  const slugs = effectiveManifest.node_types.map((n) => n.type);
7429
7453
  if (slugs.length > 0 && slugs.length + 1 <= CLASSIFIER_MAX_CHOICES && !slugs.some((s) => isReservedAbstainSlug(s))) {
@@ -7434,16 +7458,29 @@ DROP TRIGGER IF EXISTS ${ad};`);
7434
7458
  now,
7435
7459
  recheckCutoff,
7436
7460
  options?.meter,
7437
- trigger
7461
+ trigger,
7462
+ shortlistK,
7463
+ edgeSiteMode,
7464
+ edgeMinConfidence
7438
7465
  );
7439
7466
  if (classifierRun.abortedOntologyOff || classifierRun.result.budgetStop) {
7440
7467
  return classifierRun.result;
7441
7468
  }
7442
- if (classifierRun.escalated.length > 0 && this.resolveSystemOneOnLowConfidence() === "llm") {
7469
+ if (classifierRun.escalated.length > 0) {
7443
7470
  const { mode: liveMode } = await ontologyService.getEffectiveState(entityId);
7444
7471
  if (liveMode === "off") {
7445
7472
  const counts = await this.entryRepo.countUntypedByEntityId(entityId, recheckCutoff);
7446
- return { ...zeroed, remaining: 0, deferred: counts.deferred };
7473
+ const committed = classifierRun.result;
7474
+ return {
7475
+ scanned: committed.scanned,
7476
+ typed: committed.typed,
7477
+ failedValidation: committed.failedValidation,
7478
+ edgesAdded: committed.edgesAdded,
7479
+ abstained: committed.abstained,
7480
+ skipped: committed.skipped,
7481
+ remaining: 0,
7482
+ deferred: counts.deferred
7483
+ };
7447
7484
  }
7448
7485
  const escalated = classifierRun.escalated;
7449
7486
  const generative = await this._runGenerativeBackfill(entityId, escalated, {
@@ -7452,7 +7489,10 @@ DROP TRIGGER IF EXISTS ${ad};`);
7452
7489
  trigger,
7453
7490
  batchSize: escalated.length,
7454
7491
  recheckCutoff,
7455
- shortlistK
7492
+ shortlistK,
7493
+ maxPromptChars,
7494
+ edgeSiteMode,
7495
+ edgeMinConfidence
7456
7496
  });
7457
7497
  return {
7458
7498
  scanned: classifierRun.result.scanned,
@@ -7474,7 +7514,10 @@ DROP TRIGGER IF EXISTS ${ad};`);
7474
7514
  meter: options?.meter,
7475
7515
  trigger,
7476
7516
  recheckCutoff,
7477
- shortlistK
7517
+ shortlistK,
7518
+ maxPromptChars,
7519
+ edgeSiteMode,
7520
+ edgeMinConfidence
7478
7521
  });
7479
7522
  }
7480
7523
  /**
@@ -7506,6 +7549,13 @@ DROP TRIGGER IF EXISTS ${ad};`);
7506
7549
  if (shortlistK === void 0) {
7507
7550
  throw new Error("_runGenerativeBackfill: runOpts.shortlistK is required (resolved at doRunOntologyBackfill entry)");
7508
7551
  }
7552
+ const maxPromptChars = runOpts.maxPromptChars;
7553
+ if (maxPromptChars === void 0) {
7554
+ throw new Error("_runGenerativeBackfill: runOpts.maxPromptChars is required (resolved at doRunOntologyBackfill entry)");
7555
+ }
7556
+ if (runOpts.edgeSiteMode === void 0) {
7557
+ throw new Error("_runGenerativeBackfill: runOpts.edgeSiteMode is required (resolved at doRunOntologyBackfill entry)");
7558
+ }
7509
7559
  const ontologyService = this.ontologyService;
7510
7560
  const now = Date.now();
7511
7561
  const recheckCutoff = runOpts.recheckCutoff;
@@ -7544,7 +7594,7 @@ DROP TRIGGER IF EXISTS ${ad};`);
7544
7594
  };
7545
7595
  },
7546
7596
  maxOutputTokens: this.options.llmProvider.maxOutputTokens,
7547
- maxPromptChars: ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS,
7597
+ maxPromptChars,
7548
7598
  onSkip: (fact, err) => {
7549
7599
  if (isContextOverflowError(err)) {
7550
7600
  emitDiagnostic(this.options, {
@@ -7633,12 +7683,19 @@ DROP TRIGGER IF EXISTS ${ad};`);
7633
7683
  * untyped fact over the effective manifest's node-type slugs plus the
7634
7684
  * reserved abstain sentinel. Accepted answers go through
7635
7685
  * `_applyOntologyBackfillBatch` exactly like LLM classifications. No edges
7636
- * are proposed. Abstains and low-confidence answers are cooldown-stamped
7686
+ * are proposed unless `systemOne.edges` is `'auto'`; under `'auto'` the
7687
+ * classifier screens per-fact edge questions against
7688
+ * `systemOne.minConfidence.edges` (an explicit floor; missing → warn and
7689
+ * `'llm'`). Confident "yes" answers (`p > 0.5 && p >= floor`) apply,
7690
+ * confident "no" answers (`p < 0.5 && 1 - p >= floor`) are terminal, and
7691
+ * everything else (including exactly `p = 0.5`) plus invalid edge answers
7692
+ * fall through to the generative step. Edge outcomes are evaluated only for
7693
+ * typing-ACCEPTED facts. Abstains and low-confidence answers are cooldown-stamped
7637
7694
  * omissions under `onLowConfidence: 'leave'`; under `'llm'` they are
7638
7695
  * returned un-stamped in `escalated` for the generative step. Always
7639
7696
  * returns the `OntologyBackfillResult` for its step plus escalation state.
7640
7697
  */
7641
- async _runClassifierBackfill(entityId, candidates, manifest, now, recheckCutoff, meter, trigger) {
7698
+ async _runClassifierBackfill(entityId, candidates, manifest, now, recheckCutoff, meter, trigger, shortlistK, edgeSiteMode, edgeMinConfidence) {
7642
7699
  const minConfidence = resolveTypingMinConfidence(this.options.config);
7643
7700
  const rawConcurrency = this.options.config?.chunkConcurrency ?? 1;
7644
7701
  const concurrency = Number.isFinite(rawConcurrency) && rawConcurrency >= 1 ? Math.floor(rawConcurrency) : 1;
@@ -7648,17 +7705,65 @@ DROP TRIGGER IF EXISTS ${ad};`);
7648
7705
  instructions: `Choose the ontology node type that best describes this fact, or choose "${ONTOLOGY_ABSTAIN_SENTINEL}" if none of the listed types fits.
7649
7706
  ` + manifest.node_types.map((n) => `- ${n.type}: ${n.description}`).join("\n")
7650
7707
  };
7708
+ const edgeScreen = /* @__PURE__ */ new Map();
7709
+ if (edgeSiteMode === "auto" && (manifest.edge_types ?? []).length > 0) {
7710
+ const pool = await this.entryRepo.findShortlistRowsByEntityId(entityId);
7711
+ const poolTitleCounts = /* @__PURE__ */ new Map();
7712
+ for (const r of pool) {
7713
+ const k = normalizeTitleKey(r.title);
7714
+ poolTitleCounts.set(k, (poolTitleCounts.get(k) ?? 0) + 1);
7715
+ }
7716
+ const batchTitleKeys = new Set(candidates.map((f) => normalizeTitleKey(f.title)));
7717
+ const collides = (title) => {
7718
+ const k = normalizeTitleKey(title);
7719
+ return (poolTitleCounts.get(k) ?? 0) > 1 || batchTitleKeys.has(k);
7720
+ };
7721
+ const scorer = createShortlistScorer(pool);
7722
+ const edgeTypeNames = [...new Set(manifest.edge_types.map((e) => e.type))];
7723
+ for (const fact of candidates) {
7724
+ const ranked = buildShortlist({ title: fact.title, body: fact.body }, pool, shortlistK, scorer).filter((row) => !collides(row.title));
7725
+ const questions = {};
7726
+ const keyMap = /* @__PURE__ */ new Map();
7727
+ for (const row of ranked) {
7728
+ for (const edgeType of edgeTypeNames) {
7729
+ const definitions = manifest.edge_types.filter(
7730
+ (e) => e.type === edgeType && typeSatisfies(e.target_type, row.okf_type, manifest)
7731
+ );
7732
+ if (definitions.length === 0) continue;
7733
+ const key = `edge:${edgeType}:${row.id}`;
7734
+ const descriptions = [...new Set(definitions.map((d) => d.description))].join(" / ");
7735
+ questions[key] = {
7736
+ kind: "binary",
7737
+ instructions: `Does this fact have the "${edgeType}" relationship (${descriptions}) to the existing fact titled "${row.title}"?`
7738
+ };
7739
+ keyMap.set(key, { definitions, candidate: { id: row.id, title: row.title, okf_type: row.okf_type } });
7740
+ }
7741
+ }
7742
+ if (keyMap.size > 0) edgeScreen.set(fact.id, { questions, keyMap });
7743
+ }
7744
+ }
7651
7745
  let stopped;
7746
+ const retriedFacts = /* @__PURE__ */ new Set();
7652
7747
  const outcomes = await withConcurrency(
7653
7748
  candidates.map((fact) => async () => {
7654
7749
  if (stopped) return { fact, kind: "unattempted" };
7750
+ const edgeEntry = edgeScreen.get(fact.id);
7751
+ const ask = (questions) => callClassify(
7752
+ this.options,
7753
+ { operation: "ontologyBackfill", entityId, trigger, meter },
7754
+ { state: classifierStateForFact(fact), questions }
7755
+ );
7655
7756
  let response;
7757
+ let screened = edgeEntry !== void 0;
7656
7758
  try {
7657
- response = await callClassify(
7658
- this.options,
7659
- { operation: "ontologyBackfill", entityId, trigger, meter },
7660
- { state: classifierStateForFact(fact), questions: { okf_type: question } }
7661
- );
7759
+ try {
7760
+ response = await ask({ okf_type: question, ...edgeEntry?.questions ?? {} });
7761
+ } catch (err) {
7762
+ if (!edgeEntry || err instanceof WikiBudgetExhausted || !isContextOverflowError(err)) throw err;
7763
+ response = await ask({ okf_type: question });
7764
+ screened = false;
7765
+ retriedFacts.add(fact.id);
7766
+ }
7662
7767
  } catch (err) {
7663
7768
  if (err instanceof WikiBudgetExhausted) {
7664
7769
  stopped ?? (stopped = err);
@@ -7672,17 +7777,54 @@ DROP TRIGGER IF EXISTS ${ad};`);
7672
7777
  if (checked.answer.kind !== "choice") return { fact, kind: "invalid", reason: "kind_mismatch" };
7673
7778
  if (isReservedAbstainSlug(checked.answer.choice)) return { fact, kind: "abstain" };
7674
7779
  if (checked.answer.confidence < minConfidence) return { fact, kind: "low_confidence" };
7675
- return { fact, kind: "accepted", okfType: checked.answer.choice };
7780
+ const okfType = checked.answer.choice;
7781
+ if (!screened || !edgeEntry || typeof edgeMinConfidence !== "number") return { fact, kind: "accepted", okfType };
7782
+ const floor = edgeMinConfidence;
7783
+ const edges = [];
7784
+ const edgeCandidateIds = /* @__PURE__ */ Object.create(null);
7785
+ let evaluated = 0;
7786
+ let uncertain = 0;
7787
+ let invalid = 0;
7788
+ let missing = 0;
7789
+ for (const [key, { definitions, candidate }] of edgeEntry.keyMap) {
7790
+ if (!definitions.some((d) => typeSatisfies(d.source_type, okfType, manifest))) continue;
7791
+ evaluated++;
7792
+ const answer = validateClassifierAnswer(response, key, edgeEntry.questions[key]);
7793
+ if (!answer.ok) {
7794
+ if (answer.reason === "missing_answer") missing++;
7795
+ else invalid++;
7796
+ continue;
7797
+ }
7798
+ if (answer.answer.kind !== "binary") {
7799
+ invalid++;
7800
+ continue;
7801
+ }
7802
+ const p = answer.answer.probability;
7803
+ if (p > 0.5 && p >= floor) {
7804
+ edges.push({ edge_type: definitions[0].type, target_title: candidate.title });
7805
+ edgeCandidateIds[normalizeTitleKey(candidate.title)] = candidate.id;
7806
+ } else if (p < 0.5 && 1 - p >= floor) continue;
7807
+ else uncertain++;
7808
+ }
7809
+ const edgeStats = { uncertain, invalid, missing, allMissing: evaluated > 0 && missing === evaluated };
7810
+ if (edgeStats.allMissing) return { fact, kind: "accepted", okfType, edgeStats };
7811
+ if (uncertain > 0 || invalid > 0 || missing > 0) return { fact, kind: "accepted", okfType, fallthrough: true, edgeStats };
7812
+ return { fact, kind: "accepted", okfType, ...edges.length > 0 ? { edges, edgeCandidateIds } : {} };
7676
7813
  }),
7677
7814
  concurrency
7678
7815
  );
7679
7816
  const escalate = this.resolveSystemOneOnLowConfidence() === "llm";
7680
- const escalated = escalate ? outcomes.filter((o) => o.kind === "abstain" || o.kind === "low_confidence").map((o) => o.fact) : [];
7681
- const isEscalated = (o) => escalate && (o.kind === "abstain" || o.kind === "low_confidence");
7817
+ const isEscalated = (o) => o.kind === "accepted" && o.fallthrough === true || escalate && (o.kind === "abstain" || o.kind === "low_confidence");
7818
+ const escalated = outcomes.filter(isEscalated).map((o) => o.fact);
7682
7819
  const attempted = outcomes.filter((o) => o.kind !== "threw" && o.kind !== "unattempted" && !isEscalated(o)).map((o) => o.fact);
7683
7820
  const unattemptedCount = outcomes.filter((o) => o.kind === "unattempted").length;
7684
7821
  const skipped = outcomes.filter((o) => o.kind === "threw" || o.kind === "overflow_skip").length;
7685
- const classifications = outcomes.filter((o) => o.kind === "accepted").map((o) => ({ id: o.fact.id, okf_type: o.okfType }));
7822
+ const classifications = outcomes.filter((o) => o.kind === "accepted" && o.fallthrough !== true).map((o) => ({
7823
+ id: o.fact.id,
7824
+ okf_type: o.okfType,
7825
+ // An outcome carries `edges` only when the site is 'auto'.
7826
+ ...o.edges && o.edges.length > 0 ? { edges: o.edges, edgeCandidateIds: o.edgeCandidateIds } : {}
7827
+ }));
7686
7828
  const invalidCount = outcomes.filter((o) => o.kind === "invalid").length;
7687
7829
  const abstainCount = outcomes.filter((o) => o.kind === "abstain" && !isEscalated(o)).length;
7688
7830
  let typed = 0;
@@ -7707,7 +7849,21 @@ DROP TRIGGER IF EXISTS ${ad};`);
7707
7849
  const diagBuffer = new DiagnosticBuffer();
7708
7850
  const diagBase = { entityId, operation: "ontologyBackfill", trigger };
7709
7851
  for (const o of outcomes) {
7710
- if (o.kind === "abstain") {
7852
+ if (retriedFacts.has(o.fact.id)) {
7853
+ diagBuffer.push({ ...diagBase, code: "context_overflow_skipped", detail: { factId: o.fact.id, reason: "edge_screen_overflow_retry" } });
7854
+ }
7855
+ if (o.kind === "accepted" && o.edgeStats) {
7856
+ const { invalid, missing, allMissing } = o.edgeStats;
7857
+ const code = allMissing || invalid > 0 || missing > 0 ? "classification_invalid" : "classification_low_confidence";
7858
+ diagBuffer.push({
7859
+ ...diagBase,
7860
+ code,
7861
+ detail: {
7862
+ factId: o.fact.id,
7863
+ reason: allMissing ? "edge_answers_missing" : code === "classification_invalid" ? "edge_answer_invalid" : "edge_uncertain"
7864
+ }
7865
+ });
7866
+ } else if (o.kind === "abstain") {
7711
7867
  if (isEscalated(o)) continue;
7712
7868
  diagBuffer.push({ ...diagBase, code: "classification_abstained", detail: { factId: o.fact.id, writer: "classifier" } });
7713
7869
  } else if (o.kind === "low_confidence") {
@@ -7842,16 +7998,41 @@ DROP TRIGGER IF EXISTS ${ad};`);
7842
7998
  });
7843
7999
  titleIndex.set(normalizeTitleKey(fact.title), { id: fact.id, okf_type: normalized.okf_type });
7844
8000
  if (normalized.edges.length > 0) {
7845
- pendingEdges.push({ sourceId: fact.id, sourceType: normalized.okf_type, edges: normalized.edges });
8001
+ pendingEdges.push({
8002
+ sourceId: fact.id,
8003
+ sourceType: normalized.okf_type,
8004
+ edges: normalized.edges,
8005
+ candidateIds: classification.edgeCandidateIds
8006
+ });
7846
8007
  }
7847
8008
  }
7848
8009
  for (const item of pendingEdges) {
7849
8010
  const resolveDrops = [];
8011
+ let edgesToResolve = item.edges;
8012
+ const screenedIds = item.candidateIds;
8013
+ if (screenedIds) {
8014
+ edgesToResolve = [];
8015
+ for (const edge of item.edges) {
8016
+ const key = normalizeTitleKey(edge.target_title);
8017
+ const screened = screenedIds[key];
8018
+ if (screened !== void 0 && titleIndex.get(key)?.id !== screened) {
8019
+ resolveDrops.push({
8020
+ reason: "target_not_found",
8021
+ sourceId: item.sourceId,
8022
+ edgeType: edge.edge_type,
8023
+ sourceNodeType: item.sourceType,
8024
+ targetNodeType: null
8025
+ });
8026
+ } else {
8027
+ edgesToResolve.push(edge);
8028
+ }
8029
+ }
8030
+ }
7850
8031
  const added = await ontologyService.resolveAndPersistEdges(
7851
8032
  entityId,
7852
8033
  item.sourceId,
7853
8034
  item.sourceType,
7854
- item.edges,
8035
+ edgesToResolve,
7855
8036
  manifest,
7856
8037
  titleIndex,
7857
8038
  tx,