/** * AssociationDiscovery — vector-based cross-reference discovery. * * Uses cosine similarity on BGE embeddings to find semantically related entries. * Replaces the previous keyword/lexical-overlap approach. * * Entries without embeddings are gracefully skipped. */ import type { KnowledgeEntry } from '../types/index.js'; import type { KnowledgeRepository } from '../repository/index.js'; import type { AssociationType } from './association-types.js'; import { AssociationStore } from './association-store.js'; export interface DiscoveryCandidate { sourceId: string; targetId: string; type: AssociationType; strength: number; reason: string; } export interface DiscoveryOptions { /** Cosine similarity threshold (default: 0.75) */ similarityThreshold?: number; maxCandidates?: number; maxScanEntries?: number; autoCommit?: boolean; /** Pre-loaded embeddings map: entryId → Float32Array vector */ embeddings?: Map; } /** * Compute cosine similarity between two vectors. * Returns 0 if either vector is zero-length or has zero magnitude. */ export declare function cosineSimilarity(a: Float32Array, b: Float32Array): number; export declare class AssociationDiscovery { private readonly repository; private readonly store; constructor(repository: KnowledgeRepository, store: AssociationStore); /** * Discover semantically related entries using cosine similarity on embeddings. * * Requires embeddings to be provided via options.embeddings (pre-loaded from DB). * Entries without embeddings are skipped. */ discoverForEntry(entry: KnowledgeEntry, options?: DiscoveryOptions): Promise; /** * Batch discovery: find all semantic associations across all entries. * More efficient than calling discoverForEntry one by one. */ discoverAll(options?: DiscoveryOptions): Promise; /** * Classify the association type based on semantic similarity and entry metadata. * * - similarity >= 0.9 + same domain + same type + newer → supersedes * - similarity >= 0.85 + same domain + same type → conflicts (potential duplicate) * - similarity >= 0.75 + same domain → supplements * - similarity >= 0.75 (cross-domain) → depends_on (semantic dependency) */ private classifyAssociation; } //# sourceMappingURL=association-discovery.d.ts.map