/** * Memory Graph Service * * Orchestration layer that coordinates graph operations triggered * by memory lifecycle events (store, search, delete). * * This service owns the composition of GraphStore, RelationExtractor, * and GraphQueries. Tools and other services interact with the graph * exclusively through this service, keeping them decoupled from * graph internals. * * Uses `getGraphStore()` (the factory) so the active backend is selected * by `DATABASE_URL` — PostgreSQL or PostgreSQL — rather than hardcoding the * PostgreSQL singleton (structural gap #14). */ import { MemoryRelationType, MemoryEdge, GraphQueryOptions, ContradictionPair } from "@massa-th0th/shared"; import type { RelatedMemory, MemoryRow } from "./types.js"; export type { GraphQueryOptions, ContradictionPair, RelatedMemory, MemoryRow }; export declare class MemoryGraphService { private static instance; private readonly store; private readonly extractor; private readonly queries; private constructor(); static getInstance(): MemoryGraphService; /** * Called after a memory is successfully stored. * Creates explicit links and triggers background relation extraction. */ onMemoryStored(memoryId: string, linkTo?: string[]): Promise; /** * Called when a memory is deleted. * Cleans up all connected edges. */ onMemoryDeleted(memoryId: string): Promise; /** * Get memories related to a given memory via graph traversal. */ getRelatedContext(memoryId: string, options?: GraphQueryOptions): Promise; /** * Find the shortest path between two memories. */ findPath(fromId: string, toId: string, maxDepth?: number): Promise; /** * Detect contradictions in the memory graph. */ findContradictions(limit?: number): Promise; /** * Follow the decision chain leading to a memory. */ getDecisionChain(memoryId: string, maxDepth?: number): Promise; /** * Get hub memories (most connected nodes). */ getHubMemories(limit?: number): Promise<{ memory: MemoryRow; degree: number; }[]>; /** * Get a human-readable summary of a memory's neighborhood. * Useful for injecting into LLM context alongside search results. */ getNeighborhoodSummary(memoryId: string): Promise; /** * Create a manual edge between two memories. */ linkMemories(sourceId: string, targetId: string, relationType: MemoryRelationType, options?: { weight?: number; evidence?: string; }): Promise; /** * Remove an edge by ID. */ unlinkMemories(edgeId: string): Promise; /** * Get all edges for a memory. */ getEdges(memoryId: string): Promise; /** * Get graph-level statistics. */ getStats(): Promise<{ totalEdges: number; byRelation: Record; autoExtracted: number; avgWeight: number; }>; /** * Get degree centrality for a specific memory. */ getDegree(memoryId: string): Promise<{ in: number; out: number; total: number; }>; } //# sourceMappingURL=memory-graph.service.d.ts.map