/** * Graph Store — PostgreSQL implementation. * * CRUD operations for memory edges in the knowledge graph using Prisma ORM. * Natively async. * * Implements the backend-agnostic `IGraphStore` contract (structural gap #14). * Method names are normalized to match the PostgreSQL store so `getGraphStore()` * can return an `IGraphStore` without backend-specific dispatch. */ import { MemoryEdge, MemoryRelationType } from "@massa-th0th/shared"; import type { EdgeCreateInput, EdgeFilter, IGraphStore } from "./types.js"; export declare class GraphStorePg implements IGraphStore { private static instance; static getInstance(): GraphStorePg; constructor(); /** * Create a new edge between two memories. * Automatically updates weight if edge already exists. * * Accepts the canonical `EdgeCreateInput` (single object) so it satisfies * `IGraphStore.createEdge` exactly like the PostgreSQL store. */ createEdge(edge: EdgeCreateInput): Promise; /** * Get edge by (sourceId, targetId, relationType) triple. * IGraphStore-conformant alias; the PG schema stores edges by from/to/type. */ getEdge(sourceId: string, targetId: string, relationType: MemoryRelationType): Promise; /** * Find edges matching filters. * Kept as a non-contract helper (contract callers use getAllEdges). */ findEdges(filter: EdgeFilter): Promise; /** * Get all edges from a source memory. * Not on the contract; used internally by bfsNeighbors. */ getOutgoingEdges(sourceId: string, limit?: number): Promise; /** * Get all edges to a target memory. */ getIncomingEdges(targetId: string, limit?: number): Promise; /** * Phase 7c: async BFS over outgoing edges (mirror of GraphStore.bfsNeighbors). */ bfsNeighbors(seedIds: string[], depth: number): Promise; /** * Get all edges connected to a memory (both incoming and outgoing). * IGraphStore-conformant; replaces the legacy `getConnectedEdges` name. */ getAllEdges(memoryId: string, filter?: EdgeFilter): Promise; /** * Update edge weight (set). IGraphStore-conformant alias for updateEdgeWeight. */ updateWeight(id: string, weight: number): Promise; /** * Legacy alias kept for callers that used the PG-specific name. */ updateEdgeWeight(id: string, weight: number): Promise; /** * Atomically increment edge weight by delta, capped at maxWeight. * IGraphStore-conformant; the single UPDATE prevents lost increments when * multiple reinforcement calls race. */ incrementEdgeWeight(sourceId: string, targetId: string, relationType: MemoryRelationType, delta: number, maxWeight?: number): Promise; /** * Delete an edge by ID. */ deleteEdge(id: string): Promise; /** * Delete all edges connected to a memory. * IGraphStore-conformant alias; replaces the legacy `deleteEdgesByMemory` name. */ deleteEdgesForMemory(memoryId: string): Promise; /** * Legacy alias kept for callers that used the PG-specific name. */ deleteEdgesByMemory(memoryId: string): Promise; /** * Batch create edges. */ batchCreateEdges(edges: EdgeCreateInput[]): Promise; /** * Degree centrality for a memory (in + out + total). * IGraphStore-conformant. */ getDegree(memoryId: string): Promise<{ in: number; out: number; total: number; }>; /** * Find memories with the most connections (hub nodes). * IGraphStore-conformant. Uses raw grouping since Prisma has no direct * UNION+GROUP BY helper; falls back to client-side aggregation over a * bounded scan. */ getHubMemories(limit?: number): Promise<{ memoryId: string; degree: number; }[]>; /** * Get statistics about the graph. * IGraphStore-conformant alias for getGraphStats, normalizing the return * shape to match the PostgreSQL store (byRelation/autoExtracted/avgWeight). */ getStats(): Promise<{ totalEdges: number; byRelation: Record; autoExtracted: number; avgWeight: number; }>; /** * Find paths between two memories (BFS, up to maxDepth) */ findPaths(fromId: string, toId: string, maxDepth?: number): Promise>; /** * Clear all edges (for testing) */ clear(): Promise; } export declare const graphStorePg: GraphStorePg; //# sourceMappingURL=graph-store-pg.d.ts.map