import type Database from 'better-sqlite3'; import type { CallGraphEdge, Interaction, InteractionDefinitionLink, InteractionSource, InteractionWithPaths } from '../schema.js'; export interface InteractionInsertOptions { direction?: 'uni' | 'bi'; weight?: number; pattern?: 'utility' | 'business' | 'test-internal'; symbols?: string[]; semantic?: string; source?: InteractionSource; confidence?: 'high' | 'medium'; } export interface InteractionUpdateOptions { direction?: 'uni' | 'bi'; pattern?: 'utility' | 'business' | 'test-internal'; symbols?: string[]; semantic?: string; } export interface InteractionStats { totalCount: number; businessCount: number; utilityCount: number; biDirectionalCount: number; } /** * Repository for interaction (module-to-module edge) operations. */ export declare class InteractionRepository { private db; constructor(db: Database.Database); /** * Insert a new interaction. * Throws if an interaction between these modules already exists. */ insert(fromModuleId: number, toModuleId: number, options?: InteractionInsertOptions): number; /** * Upsert an interaction (insert or update on conflict). */ upsert(fromModuleId: number, toModuleId: number, options?: InteractionInsertOptions): number; /** * Get interaction by ID. */ getById(id: number): Interaction | null; /** * Get interaction by module pair. */ getByModules(fromModuleId: number, toModuleId: number): Interaction | null; /** * Get all interactions with module paths. */ getAll(): InteractionWithPaths[]; /** * Get interactions by pattern. */ getByPattern(pattern: 'utility' | 'business'): InteractionWithPaths[]; /** * Get interactions from a specific module. */ getFromModule(moduleId: number): InteractionWithPaths[]; /** * Get interactions to a specific module. */ getToModule(moduleId: number): InteractionWithPaths[]; /** * Get interactions TO a module where any of the given symbol names appears in the symbols JSON array. * Used for symbol-level incoming interaction filtering. */ getIncomingForSymbols(moduleId: number, symbolNames: string[]): InteractionWithPaths[]; /** * Get interactions FROM a module where any of the given called symbol names appears in the symbols JSON array. * Used for symbol-level outgoing interaction filtering. */ getOutgoingForSymbols(moduleId: number, calledSymbolNames: string[]): InteractionWithPaths[]; /** * Update an interaction. */ update(id: number, updates: InteractionUpdateOptions): boolean; /** * Delete an interaction. */ delete(id: number): boolean; /** * Delete all interactions. */ clear(): number; /** * Get count of interactions. */ getCount(): number; /** * Get interaction statistics. */ getStats(): InteractionStats; /** * Get interactions by source type. */ getBySource(source: InteractionSource): InteractionWithPaths[]; /** * Get count of interactions by source type. */ getCountBySource(source: InteractionSource): number; /** * Remove all llm-inferred interactions targeting a specific module. * Used by fan-in anomaly detection to bulk-remove hallucinated connections. */ removeInferredToModule(targetModuleId: number): number; /** * Delete interactions where BOTH endpoints are in the dirty module set. * Interactions with one clean endpoint are preserved (will be updated via upsert). */ deleteForModulePairsBothDirty(moduleIds: number[]): number; /** * Get all interactions involving any of the given modules (as source or target). */ getForModules(moduleIds: number[]): InteractionWithPaths[]; /** * Get the definition-level call graph (not aggregated to modules). * Returns edges from caller definition to called definition. */ getDefinitionCallGraph(): CallGraphEdge[]; /** * Get the definition-level call graph as a Map for efficient lookups. * Maps from_definition_id to array of to_definition_ids. */ getDefinitionCallGraphMap(): Map; /** * Get all non-type-only, internal file import edges. * Used to build the import graph for process group detection. */ getRuntimeImportEdges(): Array<{ fromFileId: number; toFileId: number; }>; /** * Get file-to-module mapping via module_members → definitions → files. * Returns a Map from fileId to moduleId. */ getFileToModuleMap(): Map; /** * Get module pairs connected by imports but with no existing interaction. * Fills the gap between call-graph detection (calls only) and the full import graph. */ getImportOnlyModulePairs(): Array<{ fromModuleId: number; toModuleId: number; symbols: string[]; weight: number; isTypeOnly: boolean; }>; /** * Get module pairs connected by file-level imports (regardless of symbol resolution). * This is a fallback for getImportOnlyModulePairs() — it joins through files instead * of symbols.definition_id, catching imports where symbol resolution failed * (complex re-exports, dynamic imports, etc.). * Only returns pairs that have no existing interaction. */ getFileLevelImportModulePairs(): Array<{ fromModuleId: number; toModuleId: number; importCount: number; isTypeOnly: boolean; }>; /** * Check if any file in fromModule imports from any file in toModule. * Join: module_members → definitions → files → imports → files → definitions → module_members */ hasModuleImportPath(fromModuleId: number, toModuleId: number): boolean; /** * Get actual symbols that fromModule imports from toModule. * Returns symbol names and kinds for enriching prompts and deriving `symbols` field. */ getModuleImportedSymbols(fromModuleId: number, toModuleId: number): Array<{ name: string; kind: string; }>; /** * Insert a definition-level link for a contract-matched interaction. */ insertDefinitionLink(interactionId: number, fromDefinitionId: number, toDefinitionId: number, contractId: number): void; /** * Get all definition links for a specific interaction. */ getDefinitionLinksForInteraction(interactionId: number): InteractionDefinitionLink[]; /** * Get all definition links originating from definitions in a specific module. * Used by FlowTracer for contract-aware bridge traversal. */ getDefinitionLinksFromModule(moduleId: number): Array; /** * Get all definition links with target module ID and interaction source. * Used by FlowTracer for definition-level bridge precision. */ getAllDefinitionLinks(): Array; private getCallGraphInternal; } //# sourceMappingURL=interaction-repository.d.ts.map