@equationalapplications/core-llm-wiki 7.3.0 → 7.4.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/README.md +25 -0
- package/dist/{chunk-IAYO63DQ.mjs → chunk-G5OR2VWD.mjs} +28 -11
- package/dist/chunk-G5OR2VWD.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +113 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -4
- package/dist/index.mjs.map +1 -1
- package/dist/{testing-ht1qOvcD.d.mts → testing-Dmh1kfkd.d.mts} +74 -2
- package/dist/{testing-ht1qOvcD.d.ts → testing-Dmh1kfkd.d.ts} +74 -2
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +17 -8
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-IAYO63DQ.mjs.map +0 -1
|
@@ -269,6 +269,11 @@ interface WikiConfig {
|
|
|
269
269
|
traversalDirection?: 'inbound' | 'outbound' | 'both';
|
|
270
270
|
/** Default source_type dead-end list for discovered traversal nodes. Default []. */
|
|
271
271
|
excludeSourceTypes?: Array<WikiFact['source_type']>;
|
|
272
|
+
/**
|
|
273
|
+
* Engine default for `ReadOptions.excludeDrafts` and
|
|
274
|
+
* `GraphTraversalOptions.excludeDrafts`. Default false (drafts visible).
|
|
275
|
+
*/
|
|
276
|
+
excludeDrafts?: boolean;
|
|
272
277
|
}
|
|
273
278
|
interface ReadOptions {
|
|
274
279
|
maxResults?: number;
|
|
@@ -309,6 +314,12 @@ interface ReadOptions {
|
|
|
309
314
|
* by `tierWeights: 0`, or a floor keyed to an entity not in `entityId`.
|
|
310
315
|
*/
|
|
311
316
|
tierFloors?: Record<string, number>;
|
|
317
|
+
/**
|
|
318
|
+
* When true, facts whose `lifecycle_status` is `'draft'` are excluded before
|
|
319
|
+
* `maxResults`, `tierFloors` and every other cut, on every read path.
|
|
320
|
+
* Resolves call → `WikiConfig.excludeDrafts` → false.
|
|
321
|
+
*/
|
|
322
|
+
excludeDrafts?: boolean;
|
|
312
323
|
}
|
|
313
324
|
interface WikiFact {
|
|
314
325
|
id: string;
|
|
@@ -451,6 +462,12 @@ interface GraphTraversalOptions {
|
|
|
451
462
|
minTraversalConfidence?: 'certain' | 'inferred' | 'tentative';
|
|
452
463
|
/** source_type values to dead-end on for *discovered* nodes. Does not gate the anchor. Default []. */
|
|
453
464
|
excludeSourceTypes?: Array<WikiFact['source_type']>;
|
|
465
|
+
/**
|
|
466
|
+
* When true, draft facts are dead ends for *discovered* nodes (not
|
|
467
|
+
* discovered, not traversed through). Does not gate the anchor.
|
|
468
|
+
* Resolves call → `WikiConfig.excludeDrafts` → false.
|
|
469
|
+
*/
|
|
470
|
+
excludeDrafts?: boolean;
|
|
454
471
|
}
|
|
455
472
|
interface GraphNeighborhood {
|
|
456
473
|
/** Anchor node first, then discovered neighbors ordered by depth ASC, then updated_at DESC. */
|
|
@@ -942,6 +959,22 @@ declare class WikiInvalidReadOptions extends Error {
|
|
|
942
959
|
readonly reason: string;
|
|
943
960
|
constructor(field: string, reason: string);
|
|
944
961
|
}
|
|
962
|
+
/**
|
|
963
|
+
* Thrown by `promoteDraft` when no live draft with that id exists for the
|
|
964
|
+
* entity: missing, soft-deleted, owned by another entity, or not a draft.
|
|
965
|
+
* Contextless for the same reason as {@link WikiGraphNodeOwnershipConflict}.
|
|
966
|
+
* The `WIKI_` code keeps it clear of `extractSqliteCode`, so it passes through
|
|
967
|
+
* the serialized transaction wrapper unwrapped.
|
|
968
|
+
*/
|
|
969
|
+
declare class WikiDraftNotFound extends Error {
|
|
970
|
+
readonly code: "WIKI_DRAFT_NOT_FOUND";
|
|
971
|
+
constructor();
|
|
972
|
+
}
|
|
973
|
+
/** One page of `listDrafts`. `nextCursor` is opaque; pass it back unchanged. */
|
|
974
|
+
interface DraftPage {
|
|
975
|
+
facts: WikiFact[];
|
|
976
|
+
nextCursor: string | null;
|
|
977
|
+
}
|
|
945
978
|
|
|
946
979
|
interface WikiOutboxEvent<T = unknown> {
|
|
947
980
|
id: string;
|
|
@@ -1317,7 +1350,18 @@ declare class EntryRepository extends BaseRepository {
|
|
|
1317
1350
|
}>>;
|
|
1318
1351
|
trackAccess(ids: readonly string[], now: number, tx?: SQLiteAdapter): Promise<void>;
|
|
1319
1352
|
getLegacyMigrationSQL(): string;
|
|
1320
|
-
findRecentByEntityIds(entityIds: readonly string[], limit: number, tx?: SQLiteAdapter
|
|
1353
|
+
findRecentByEntityIds(entityIds: readonly string[], limit: number, tx?: SQLiteAdapter, opts?: {
|
|
1354
|
+
excludeDrafts?: boolean;
|
|
1355
|
+
}): Promise<WikiFact[]>;
|
|
1356
|
+
/** IDs of live draft facts for the given entities (spec §5.1). Callers pass ≤ 100 entity ids. */
|
|
1357
|
+
findDraftIdsByEntityIds(entityIds: readonly string[], tx?: SQLiteAdapter): Promise<Set<string>>;
|
|
1358
|
+
/** Live drafts for one entity, newest first, keyset-paged by (created_at, id). */
|
|
1359
|
+
listDraftsByEntityId(entityId: string, limit: number, after: {
|
|
1360
|
+
createdAt: number;
|
|
1361
|
+
id: string;
|
|
1362
|
+
} | null, tx?: SQLiteAdapter): Promise<WikiFact[]>;
|
|
1363
|
+
/** True iff `entryId` is a live draft owned by `entityId`. */
|
|
1364
|
+
isLiveDraft(entryId: string, entityId: string, tx?: SQLiteAdapter): Promise<boolean>;
|
|
1321
1365
|
/**
|
|
1322
1366
|
* Live untyped facts eligible for ontology backfill, oldest first.
|
|
1323
1367
|
* Skips facts checked within the recheck cooldown (ontology_checked_at > recheckCutoff).
|
|
@@ -1725,6 +1769,14 @@ interface NeighborhoodQueryOptions {
|
|
|
1725
1769
|
minConfidence: 'certain' | 'inferred' | 'tentative';
|
|
1726
1770
|
excludeSourceTypes: string[];
|
|
1727
1771
|
maxNodes: number;
|
|
1772
|
+
/**
|
|
1773
|
+
* When true, draft facts are dead-ends for *discovered* nodes — the recursive
|
|
1774
|
+
* walk will not step onto a draft, and will not step *past* one either, since
|
|
1775
|
+
* a draft's neighbours are unreachable through it. The anchor node is exempt
|
|
1776
|
+
* (it is validated up-front and never gated by this flag), so callers can
|
|
1777
|
+
* intentionally start from a draft. Default false (drafts visible).
|
|
1778
|
+
*/
|
|
1779
|
+
excludeDrafts?: boolean;
|
|
1728
1780
|
}
|
|
1729
1781
|
declare class EdgeRepository extends BaseRepository {
|
|
1730
1782
|
/**
|
|
@@ -2374,6 +2426,7 @@ declare class RetrievalService {
|
|
|
2374
2426
|
* Stable tie-break sort: score desc → access_count desc → updated_at desc → id asc.
|
|
2375
2427
|
*/
|
|
2376
2428
|
private _tieBreakSort;
|
|
2429
|
+
private _withoutDrafts;
|
|
2377
2430
|
/**
|
|
2378
2431
|
* Comparator for score + deterministic tie-break fields.
|
|
2379
2432
|
* Negative return means "a ranks ahead of b" for descending score order.
|
|
@@ -2787,6 +2840,25 @@ declare class WikiMemory {
|
|
|
2787
2840
|
}>): Promise<void>;
|
|
2788
2841
|
/** Set a fact's OKF v0.2 lifecycle status. Does NOT touch `updated_at`. */
|
|
2789
2842
|
setLifecycleStatus(entryId: string, entityId: string, status: 'draft' | 'stable' | 'deprecated'): Promise<void>;
|
|
2843
|
+
/**
|
|
2844
|
+
* Live draft facts for one entity, newest first (spec §5.2). Default page
|
|
2845
|
+
* size 50, clamped to [1, 500]. Pass `nextCursor` back unchanged for the next page.
|
|
2846
|
+
*/
|
|
2847
|
+
listDrafts(entityId: string, options?: {
|
|
2848
|
+
limit?: number;
|
|
2849
|
+
cursor?: string;
|
|
2850
|
+
}): Promise<DraftPage>;
|
|
2851
|
+
/**
|
|
2852
|
+
* Promote a draft to `stable` and record who reviewed it, atomically
|
|
2853
|
+
* (spec §5.2). Metadata writes only: `updated_at` is not bumped and no
|
|
2854
|
+
* outbox event is pushed. Pass `by: 'human:<id>'` so `trustTier` becomes
|
|
2855
|
+
* `'human-reviewed'`.
|
|
2856
|
+
*
|
|
2857
|
+
* @throws WikiDraftNotFound when no live draft with that id exists for the entity.
|
|
2858
|
+
*/
|
|
2859
|
+
promoteDraft(entryId: string, entityId: string, reviewer: {
|
|
2860
|
+
by: string;
|
|
2861
|
+
}): Promise<void>;
|
|
2790
2862
|
/** Set a fact's stale_after (epoch ms) or clear it. Does NOT touch `updated_at`. */
|
|
2791
2863
|
setStaleAfter(entryId: string, entityId: string, date: number | null): Promise<void>;
|
|
2792
2864
|
/** Set a fact's generated_by actor string. Does NOT touch `updated_at`. */
|
|
@@ -2805,4 +2877,4 @@ declare class WikiMemory {
|
|
|
2805
2877
|
setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
|
|
2806
2878
|
}
|
|
2807
2879
|
|
|
2808
|
-
export { type
|
|
2880
|
+
export { type WikiDiagnosticOperation as $, PrunePartialFailureError as A, type ReembedResult as B, type ChunkFailure as C, type DegradedRecord as D, type EmbedFactResult as E, type FormatContextOptions as F, type GraphNeighborhood as G, HEAL_BATCH_SIZE as H, type IngestDocumentResult as I, type VectorRankerFallback as J, type VectorRankerRankArgs as K, type LLMProvider as L, type MemoryBundle as M, type VectorRankerSemanticResult as N, ONTOLOGY_BACKFILL_BATCH_SIZE as O, type PromptOverrides as P, WikiBusyError as Q, type ReadOptions as R, type SQLiteAdapter as S, type WikiBusyOperation as T, type WikiCheckpoint as U, type VectorRanker as V, type WikiOptions as W, type WikiConfig as X, type WikiDiagnostic as Y, type WikiDiagnosticCode as Z, type WikiDiagnosticDetail as _, type MemoryDump as a, type WikiDiagnosticSeverity as a0, type WikiDiagnosticTrigger as a1, WikiDraftNotFound as a2, WikiDuplicateHashError as a3, type WikiEdge as a4, type WikiEvent as a5, type WikiFact as a6, WikiGraphNodeOwnershipConflict as a7, WikiIngestEmptyError as a8, WikiInvalidReadOptions as a9, type WikiMemoryTestAccess as aa, type WikiOutboxEvent as ab, WikiParseError as ac, WikiSourceRefHashCollision as ad, WikiStrictOntologyViolation as ae, type WikiTask as af, WikiTransactionError as ag, validateManifest as ah, EmbeddingService as ai, ImportExportService as aj, IngestionService as ak, JobManager as al, MaintenanceService as am, RetrievalService as an, SearchService as ao, WriteService as ap, type FormattedMemoryDump as b, WikiMemory as c, type DraftPage as d, type EmbedFailureKind as e, type EmbeddingMarkerKind as f, type EntityStatus as g, type ExtractedFact as h, type ExtractedFactEdge as i, type ExtractedFactWithOntology as j, type ExtractedTask as k, type GraphTraversalOptions as l, HEAL_RECHECK_MS as m, HOOK_TIMEOUT_MARKER as n, type HealResult as o, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as p, ONTOLOGY_BACKFILL_RECHECK_MS as q, type OntologyBackfillResult as r, type OntologyConfig as s, type OntologyEdgeType as t, type OntologyManifest as u, type OntologyMode as v, type OntologyNodeType as w, type OntologyPromptContext as x, type OntologyUpdates as y, PromptService as z };
|
|
@@ -269,6 +269,11 @@ interface WikiConfig {
|
|
|
269
269
|
traversalDirection?: 'inbound' | 'outbound' | 'both';
|
|
270
270
|
/** Default source_type dead-end list for discovered traversal nodes. Default []. */
|
|
271
271
|
excludeSourceTypes?: Array<WikiFact['source_type']>;
|
|
272
|
+
/**
|
|
273
|
+
* Engine default for `ReadOptions.excludeDrafts` and
|
|
274
|
+
* `GraphTraversalOptions.excludeDrafts`. Default false (drafts visible).
|
|
275
|
+
*/
|
|
276
|
+
excludeDrafts?: boolean;
|
|
272
277
|
}
|
|
273
278
|
interface ReadOptions {
|
|
274
279
|
maxResults?: number;
|
|
@@ -309,6 +314,12 @@ interface ReadOptions {
|
|
|
309
314
|
* by `tierWeights: 0`, or a floor keyed to an entity not in `entityId`.
|
|
310
315
|
*/
|
|
311
316
|
tierFloors?: Record<string, number>;
|
|
317
|
+
/**
|
|
318
|
+
* When true, facts whose `lifecycle_status` is `'draft'` are excluded before
|
|
319
|
+
* `maxResults`, `tierFloors` and every other cut, on every read path.
|
|
320
|
+
* Resolves call → `WikiConfig.excludeDrafts` → false.
|
|
321
|
+
*/
|
|
322
|
+
excludeDrafts?: boolean;
|
|
312
323
|
}
|
|
313
324
|
interface WikiFact {
|
|
314
325
|
id: string;
|
|
@@ -451,6 +462,12 @@ interface GraphTraversalOptions {
|
|
|
451
462
|
minTraversalConfidence?: 'certain' | 'inferred' | 'tentative';
|
|
452
463
|
/** source_type values to dead-end on for *discovered* nodes. Does not gate the anchor. Default []. */
|
|
453
464
|
excludeSourceTypes?: Array<WikiFact['source_type']>;
|
|
465
|
+
/**
|
|
466
|
+
* When true, draft facts are dead ends for *discovered* nodes (not
|
|
467
|
+
* discovered, not traversed through). Does not gate the anchor.
|
|
468
|
+
* Resolves call → `WikiConfig.excludeDrafts` → false.
|
|
469
|
+
*/
|
|
470
|
+
excludeDrafts?: boolean;
|
|
454
471
|
}
|
|
455
472
|
interface GraphNeighborhood {
|
|
456
473
|
/** Anchor node first, then discovered neighbors ordered by depth ASC, then updated_at DESC. */
|
|
@@ -942,6 +959,22 @@ declare class WikiInvalidReadOptions extends Error {
|
|
|
942
959
|
readonly reason: string;
|
|
943
960
|
constructor(field: string, reason: string);
|
|
944
961
|
}
|
|
962
|
+
/**
|
|
963
|
+
* Thrown by `promoteDraft` when no live draft with that id exists for the
|
|
964
|
+
* entity: missing, soft-deleted, owned by another entity, or not a draft.
|
|
965
|
+
* Contextless for the same reason as {@link WikiGraphNodeOwnershipConflict}.
|
|
966
|
+
* The `WIKI_` code keeps it clear of `extractSqliteCode`, so it passes through
|
|
967
|
+
* the serialized transaction wrapper unwrapped.
|
|
968
|
+
*/
|
|
969
|
+
declare class WikiDraftNotFound extends Error {
|
|
970
|
+
readonly code: "WIKI_DRAFT_NOT_FOUND";
|
|
971
|
+
constructor();
|
|
972
|
+
}
|
|
973
|
+
/** One page of `listDrafts`. `nextCursor` is opaque; pass it back unchanged. */
|
|
974
|
+
interface DraftPage {
|
|
975
|
+
facts: WikiFact[];
|
|
976
|
+
nextCursor: string | null;
|
|
977
|
+
}
|
|
945
978
|
|
|
946
979
|
interface WikiOutboxEvent<T = unknown> {
|
|
947
980
|
id: string;
|
|
@@ -1317,7 +1350,18 @@ declare class EntryRepository extends BaseRepository {
|
|
|
1317
1350
|
}>>;
|
|
1318
1351
|
trackAccess(ids: readonly string[], now: number, tx?: SQLiteAdapter): Promise<void>;
|
|
1319
1352
|
getLegacyMigrationSQL(): string;
|
|
1320
|
-
findRecentByEntityIds(entityIds: readonly string[], limit: number, tx?: SQLiteAdapter
|
|
1353
|
+
findRecentByEntityIds(entityIds: readonly string[], limit: number, tx?: SQLiteAdapter, opts?: {
|
|
1354
|
+
excludeDrafts?: boolean;
|
|
1355
|
+
}): Promise<WikiFact[]>;
|
|
1356
|
+
/** IDs of live draft facts for the given entities (spec §5.1). Callers pass ≤ 100 entity ids. */
|
|
1357
|
+
findDraftIdsByEntityIds(entityIds: readonly string[], tx?: SQLiteAdapter): Promise<Set<string>>;
|
|
1358
|
+
/** Live drafts for one entity, newest first, keyset-paged by (created_at, id). */
|
|
1359
|
+
listDraftsByEntityId(entityId: string, limit: number, after: {
|
|
1360
|
+
createdAt: number;
|
|
1361
|
+
id: string;
|
|
1362
|
+
} | null, tx?: SQLiteAdapter): Promise<WikiFact[]>;
|
|
1363
|
+
/** True iff `entryId` is a live draft owned by `entityId`. */
|
|
1364
|
+
isLiveDraft(entryId: string, entityId: string, tx?: SQLiteAdapter): Promise<boolean>;
|
|
1321
1365
|
/**
|
|
1322
1366
|
* Live untyped facts eligible for ontology backfill, oldest first.
|
|
1323
1367
|
* Skips facts checked within the recheck cooldown (ontology_checked_at > recheckCutoff).
|
|
@@ -1725,6 +1769,14 @@ interface NeighborhoodQueryOptions {
|
|
|
1725
1769
|
minConfidence: 'certain' | 'inferred' | 'tentative';
|
|
1726
1770
|
excludeSourceTypes: string[];
|
|
1727
1771
|
maxNodes: number;
|
|
1772
|
+
/**
|
|
1773
|
+
* When true, draft facts are dead-ends for *discovered* nodes — the recursive
|
|
1774
|
+
* walk will not step onto a draft, and will not step *past* one either, since
|
|
1775
|
+
* a draft's neighbours are unreachable through it. The anchor node is exempt
|
|
1776
|
+
* (it is validated up-front and never gated by this flag), so callers can
|
|
1777
|
+
* intentionally start from a draft. Default false (drafts visible).
|
|
1778
|
+
*/
|
|
1779
|
+
excludeDrafts?: boolean;
|
|
1728
1780
|
}
|
|
1729
1781
|
declare class EdgeRepository extends BaseRepository {
|
|
1730
1782
|
/**
|
|
@@ -2374,6 +2426,7 @@ declare class RetrievalService {
|
|
|
2374
2426
|
* Stable tie-break sort: score desc → access_count desc → updated_at desc → id asc.
|
|
2375
2427
|
*/
|
|
2376
2428
|
private _tieBreakSort;
|
|
2429
|
+
private _withoutDrafts;
|
|
2377
2430
|
/**
|
|
2378
2431
|
* Comparator for score + deterministic tie-break fields.
|
|
2379
2432
|
* Negative return means "a ranks ahead of b" for descending score order.
|
|
@@ -2787,6 +2840,25 @@ declare class WikiMemory {
|
|
|
2787
2840
|
}>): Promise<void>;
|
|
2788
2841
|
/** Set a fact's OKF v0.2 lifecycle status. Does NOT touch `updated_at`. */
|
|
2789
2842
|
setLifecycleStatus(entryId: string, entityId: string, status: 'draft' | 'stable' | 'deprecated'): Promise<void>;
|
|
2843
|
+
/**
|
|
2844
|
+
* Live draft facts for one entity, newest first (spec §5.2). Default page
|
|
2845
|
+
* size 50, clamped to [1, 500]. Pass `nextCursor` back unchanged for the next page.
|
|
2846
|
+
*/
|
|
2847
|
+
listDrafts(entityId: string, options?: {
|
|
2848
|
+
limit?: number;
|
|
2849
|
+
cursor?: string;
|
|
2850
|
+
}): Promise<DraftPage>;
|
|
2851
|
+
/**
|
|
2852
|
+
* Promote a draft to `stable` and record who reviewed it, atomically
|
|
2853
|
+
* (spec §5.2). Metadata writes only: `updated_at` is not bumped and no
|
|
2854
|
+
* outbox event is pushed. Pass `by: 'human:<id>'` so `trustTier` becomes
|
|
2855
|
+
* `'human-reviewed'`.
|
|
2856
|
+
*
|
|
2857
|
+
* @throws WikiDraftNotFound when no live draft with that id exists for the entity.
|
|
2858
|
+
*/
|
|
2859
|
+
promoteDraft(entryId: string, entityId: string, reviewer: {
|
|
2860
|
+
by: string;
|
|
2861
|
+
}): Promise<void>;
|
|
2790
2862
|
/** Set a fact's stale_after (epoch ms) or clear it. Does NOT touch `updated_at`. */
|
|
2791
2863
|
setStaleAfter(entryId: string, entityId: string, date: number | null): Promise<void>;
|
|
2792
2864
|
/** Set a fact's generated_by actor string. Does NOT touch `updated_at`. */
|
|
@@ -2805,4 +2877,4 @@ declare class WikiMemory {
|
|
|
2805
2877
|
setGeneratedByTask(taskId: string, entityId: string, actor: string): Promise<void>;
|
|
2806
2878
|
}
|
|
2807
2879
|
|
|
2808
|
-
export { type
|
|
2880
|
+
export { type WikiDiagnosticOperation as $, PrunePartialFailureError as A, type ReembedResult as B, type ChunkFailure as C, type DegradedRecord as D, type EmbedFactResult as E, type FormatContextOptions as F, type GraphNeighborhood as G, HEAL_BATCH_SIZE as H, type IngestDocumentResult as I, type VectorRankerFallback as J, type VectorRankerRankArgs as K, type LLMProvider as L, type MemoryBundle as M, type VectorRankerSemanticResult as N, ONTOLOGY_BACKFILL_BATCH_SIZE as O, type PromptOverrides as P, WikiBusyError as Q, type ReadOptions as R, type SQLiteAdapter as S, type WikiBusyOperation as T, type WikiCheckpoint as U, type VectorRanker as V, type WikiOptions as W, type WikiConfig as X, type WikiDiagnostic as Y, type WikiDiagnosticCode as Z, type WikiDiagnosticDetail as _, type MemoryDump as a, type WikiDiagnosticSeverity as a0, type WikiDiagnosticTrigger as a1, WikiDraftNotFound as a2, WikiDuplicateHashError as a3, type WikiEdge as a4, type WikiEvent as a5, type WikiFact as a6, WikiGraphNodeOwnershipConflict as a7, WikiIngestEmptyError as a8, WikiInvalidReadOptions as a9, type WikiMemoryTestAccess as aa, type WikiOutboxEvent as ab, WikiParseError as ac, WikiSourceRefHashCollision as ad, WikiStrictOntologyViolation as ae, type WikiTask as af, WikiTransactionError as ag, validateManifest as ah, EmbeddingService as ai, ImportExportService as aj, IngestionService as ak, JobManager as al, MaintenanceService as am, RetrievalService as an, SearchService as ao, WriteService as ap, type FormattedMemoryDump as b, WikiMemory as c, type DraftPage as d, type EmbedFailureKind as e, type EmbeddingMarkerKind as f, type EntityStatus as g, type ExtractedFact as h, type ExtractedFactEdge as i, type ExtractedFactWithOntology as j, type ExtractedTask as k, type GraphTraversalOptions as l, HEAL_RECHECK_MS as m, HOOK_TIMEOUT_MARKER as n, type HealResult as o, ONTOLOGY_BACKFILL_MAX_PROMPT_CHARS as p, ONTOLOGY_BACKFILL_RECHECK_MS as q, type OntologyBackfillResult as r, type OntologyConfig as s, type OntologyEdgeType as t, type OntologyManifest as u, type OntologyMode as v, type OntologyNodeType as w, type OntologyPromptContext as x, type OntologyUpdates as y, PromptService as z };
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { ai as EmbeddingService, aj as ImportExportService, ak as IngestionService, al as JobManager, al as JobManagerType, am as MaintenanceService, an as RetrievalService, ao as SearchService, ao as SearchServiceType, aa as WikiMemoryTestAccess, ap as WriteService } from './testing-Dmh1kfkd.mjs';
|
|
2
2
|
import '@equationalapplications/core-okf';
|
|
3
3
|
import 'minisearch';
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { ai as EmbeddingService, aj as ImportExportService, ak as IngestionService, al as JobManager, al as JobManagerType, am as MaintenanceService, an as RetrievalService, ao as SearchService, ao as SearchServiceType, aa as WikiMemoryTestAccess, ap as WriteService } from './testing-Dmh1kfkd.js';
|
|
2
2
|
import '@equationalapplications/core-okf';
|
|
3
3
|
import 'minisearch';
|
package/dist/testing.js
CHANGED
|
@@ -3516,6 +3516,7 @@ function selectWithFloors(sortedRows, floors, maxResults) {
|
|
|
3516
3516
|
}
|
|
3517
3517
|
|
|
3518
3518
|
// src/services/RetrievalService.ts
|
|
3519
|
+
var EMPTY_ID_SET = /* @__PURE__ */ new Set();
|
|
3519
3520
|
var RetrievalService = class {
|
|
3520
3521
|
constructor(options, entryRepo, taskRepo, eventRepo, metadataRepo, searchService) {
|
|
3521
3522
|
this.options = options;
|
|
@@ -3548,6 +3549,7 @@ var RetrievalService = class {
|
|
|
3548
3549
|
}
|
|
3549
3550
|
const rawMaxResults = options?.maxResults ?? config?.maxResults ?? config?.maxFtsResults ?? 10;
|
|
3550
3551
|
const maxResults = Number.isFinite(rawMaxResults) ? Math.max(0, Math.trunc(rawMaxResults)) : 10;
|
|
3552
|
+
const excludeDrafts = (options?.excludeDrafts ?? config?.excludeDrafts ?? false) === true;
|
|
3551
3553
|
const trimmedQuery = query.trim();
|
|
3552
3554
|
const sanitizedTierFloors = trimmedQuery && exposeMetadata ? validateTierFloors(
|
|
3553
3555
|
entityIds,
|
|
@@ -3567,6 +3569,9 @@ var RetrievalService = class {
|
|
|
3567
3569
|
if (maxResults === 0) ; else if (trimmedQuery) {
|
|
3568
3570
|
let usedEmbed = false;
|
|
3569
3571
|
const scoredEntityIds = this._filterScoredEntities(entityIds, sanitizedTierWeights, options?.includeZeroWeightEntities);
|
|
3572
|
+
const draftIds = excludeDrafts && scoredEntityIds.length > 0 ? await this.entryRepo.findDraftIdsByEntityIds(scoredEntityIds) : EMPTY_ID_SET;
|
|
3573
|
+
const draftPad = draftIds.size;
|
|
3574
|
+
const padLimit = (n) => n >= Number.MAX_SAFE_INTEGER ? n : n + draftPad;
|
|
3570
3575
|
if (scoredEntityIds.length === 0) {
|
|
3571
3576
|
usedEmbed = true;
|
|
3572
3577
|
} else if (!skipEmbed && embedFn) {
|
|
@@ -3600,7 +3605,7 @@ var RetrievalService = class {
|
|
|
3600
3605
|
let miniSearchScores;
|
|
3601
3606
|
if (effectivePreFilterLimit !== void 0) {
|
|
3602
3607
|
populateCache = false;
|
|
3603
|
-
const preResults = this.searchService.searchKeyword(trimmedQuery, scoredEntityIds, Number.MAX_SAFE_INTEGER);
|
|
3608
|
+
const preResults = this.searchService.searchKeyword(trimmedQuery, scoredEntityIds, Number.MAX_SAFE_INTEGER).filter((r) => !draftIds.has(r.id));
|
|
3604
3609
|
if (preResults.length === 0) {
|
|
3605
3610
|
candidateRows = null;
|
|
3606
3611
|
} else {
|
|
@@ -3622,9 +3627,9 @@ var RetrievalService = class {
|
|
|
3622
3627
|
}
|
|
3623
3628
|
} else {
|
|
3624
3629
|
if (useRanker) {
|
|
3625
|
-
candidateRows = await this.entryRepo.findMetadataByEntityIds(scoredEntityIds);
|
|
3630
|
+
candidateRows = this._withoutDrafts(await this.entryRepo.findMetadataByEntityIds(scoredEntityIds), draftIds);
|
|
3626
3631
|
} else {
|
|
3627
|
-
candidateRows = await this.entryRepo.findWithEmbeddingsByEntityIds(scoredEntityIds);
|
|
3632
|
+
candidateRows = this._withoutDrafts(await this.entryRepo.findWithEmbeddingsByEntityIds(scoredEntityIds), draftIds);
|
|
3628
3633
|
}
|
|
3629
3634
|
if (weight !== void 0 && weight < 1) {
|
|
3630
3635
|
miniSearchScores = this.searchService.getMiniSearchScores(trimmedQuery, scoredEntityIds);
|
|
@@ -3654,7 +3659,7 @@ var RetrievalService = class {
|
|
|
3654
3659
|
candidateRows: rowsForEntity,
|
|
3655
3660
|
weight,
|
|
3656
3661
|
miniSearchScores,
|
|
3657
|
-
limit: Math.max(maxResults * 2, maxResults + 50)
|
|
3662
|
+
limit: padLimit(Math.max(maxResults * 2, maxResults + 50))
|
|
3658
3663
|
});
|
|
3659
3664
|
return ranked.map((row) => ({ ...row, entity_id: scopedEntityId }));
|
|
3660
3665
|
})
|
|
@@ -3868,7 +3873,7 @@ var RetrievalService = class {
|
|
|
3868
3873
|
});
|
|
3869
3874
|
} else if (policy === "keyword") {
|
|
3870
3875
|
const hasActiveFloorsKeywordFallback = sanitizedTierFloors !== void 0 && Object.values(sanitizedTierFloors).some((f) => f > 0);
|
|
3871
|
-
const keywordOversampledLimit = hasActiveFloorsKeywordFallback ? Number.MAX_SAFE_INTEGER : Math.max(maxResults * 2, maxResults + 50);
|
|
3876
|
+
const keywordOversampledLimit = hasActiveFloorsKeywordFallback ? Number.MAX_SAFE_INTEGER : padLimit(Math.max(maxResults * 2, maxResults + 50));
|
|
3872
3877
|
const preFilteredIds = effectivePreFilterLimit !== void 0 ? new Set(candidateRows.map((r) => r.id)) : void 0;
|
|
3873
3878
|
const keywordResults = this.searchService.searchKeyword(trimmedQuery, scoredEntityIds, keywordOversampledLimit);
|
|
3874
3879
|
const topResults = preFilteredIds === void 0 ? keywordResults : keywordResults.filter((r) => preFilteredIds.has(r.id));
|
|
@@ -3909,6 +3914,7 @@ var RetrievalService = class {
|
|
|
3909
3914
|
// read() re-sorts after applying tier weights
|
|
3910
3915
|
});
|
|
3911
3916
|
}
|
|
3917
|
+
if (draftPad > 0) scored = scored.filter((s) => !draftIds.has(s.id));
|
|
3912
3918
|
if (scored.length > 0) {
|
|
3913
3919
|
scored = scored.map((row) => ({
|
|
3914
3920
|
...row,
|
|
@@ -3971,8 +3977,8 @@ var RetrievalService = class {
|
|
|
3971
3977
|
}
|
|
3972
3978
|
if (!usedEmbed && scoredEntityIds.length > 0) {
|
|
3973
3979
|
const hasActiveFloors = sanitizedTierFloors !== void 0 && Object.values(sanitizedTierFloors).some((f) => f > 0);
|
|
3974
|
-
const fallbackOversampledLimit = hasActiveFloors ? Number.MAX_SAFE_INTEGER : Math.max(maxResults * 2, maxResults + 50);
|
|
3975
|
-
const results = this.searchService.searchKeyword(trimmedQuery, scoredEntityIds, fallbackOversampledLimit);
|
|
3980
|
+
const fallbackOversampledLimit = hasActiveFloors ? Number.MAX_SAFE_INTEGER : padLimit(Math.max(maxResults * 2, maxResults + 50));
|
|
3981
|
+
const results = this.searchService.searchKeyword(trimmedQuery, scoredEntityIds, fallbackOversampledLimit).filter((r) => !draftIds.has(r.id));
|
|
3976
3982
|
const candidates = results.map((r) => ({
|
|
3977
3983
|
id: r.id,
|
|
3978
3984
|
entity_id: r.entity_id,
|
|
@@ -3996,7 +4002,7 @@ var RetrievalService = class {
|
|
|
3996
4002
|
await this.entryRepo.trackAccess(ids, now);
|
|
3997
4003
|
}
|
|
3998
4004
|
} else {
|
|
3999
|
-
facts = await this.entryRepo.findRecentByEntityIds(entityIds, maxResults);
|
|
4005
|
+
facts = excludeDrafts ? await this.entryRepo.findRecentByEntityIds(entityIds, maxResults, void 0, { excludeDrafts: true }) : await this.entryRepo.findRecentByEntityIds(entityIds, maxResults);
|
|
4000
4006
|
}
|
|
4001
4007
|
const eventsLimit = Math.min(10 * entityIds.length, 100);
|
|
4002
4008
|
const [tasks, events] = await Promise.all([
|
|
@@ -4032,6 +4038,9 @@ var RetrievalService = class {
|
|
|
4032
4038
|
_tieBreakSort(items) {
|
|
4033
4039
|
items.sort((a, b) => this._compareScoredRows(a, b));
|
|
4034
4040
|
}
|
|
4041
|
+
_withoutDrafts(rows, draftIds) {
|
|
4042
|
+
return draftIds.size === 0 ? rows : rows.filter((row) => !draftIds.has(row.id));
|
|
4043
|
+
}
|
|
4035
4044
|
/**
|
|
4036
4045
|
* Comparator for score + deterministic tie-break fields.
|
|
4037
4046
|
* Negative return means "a ranks ahead of b" for descending score order.
|