/** * Mem0-style 4-Way Memory Deduplication Manager * * 새 메모리 생성 전 기존 메모리와 비교하여 최적의 동작 결정: * - ADD: 유사 메모리 없음 → 새로 생성 * - UPDATE: 유사도 > 0.8 → 기존 메모리 내용 병합/갱신 * - DELETE: 새 정보가 기존을 무효화 → 기존 삭제 후 새로 생성 * - NOOP: 유사도 > 0.95 → 완전 중복, 무시 */ import type { Memory, MemoryCategory } from '../types/index.js'; export type DedupAction = 'ADD' | 'UPDATE' | 'DELETE' | 'NOOP'; export interface DedupDecision { action: DedupAction; /** UPDATE/DELETE 시 대상 메모리 */ targetMemory?: Memory; /** 유사도 점수 (0~1) */ similarity: number; /** 판단 근거 */ reason: string; } export declare class DedupManager { /** * 4-Way 판단: 새 콘텐츠를 기존 메모리와 비교 * * @param newContent 새로 저장할 콘텐츠 * @param existingMemories 비교 대상 기존 메모리 (동일 프로젝트+카테고리) * @param newEmbedding 새 콘텐츠의 임베딩 (있으면 코사인 유사도 사용) */ decide(newContent: string, existingMemories: Memory[], newEmbedding?: number[]): DedupDecision; /** * 두 메모리 콘텐츠를 병합 (UPDATE용) * 기존 콘텐츠 + 새 정보 추가 * * #104 (ADR-057): 더 이상 **자르지 않는다**. 상한을 넘기면 `truncated: true`만 알리고 * 판단은 호출부에 맡긴다(호출부는 UPDATE를 포기하고 신규 저장으로 강등한다). * * 이전에는 `merged.slice(0, MERGE_CONTENT_MAX_CHARS)`를 반환했고 호출부가 그 값으로 * target을 덮어쓴 뒤 **신규 메모리를 저장하지 않았다** — target은 잘리고 신규는 소멸하는 * 구조였다. `consolidation.ts`의 같은 결함(ADR-057)과 동일 클래스이며, 이쪽은 * **매 PostToolUse**마다 후보 판정을 하므로 빈도가 훨씬 높다. * * @returns `truncated`가 true면 `content`를 저장하면 안 된다 — 그 값이 곧 손실이다. */ mergeContent(existingContent: string, newContent: string): { content: string; truncated: boolean; wouldBeLength: number; }; /** * 기존 메모리에서 유사한 것들을 찾아 비교 대상 목록 구성 */ findCandidates(memories: Memory[], category: MemoryCategory, projectPath?: string, limit?: number): Memory[]; } //# sourceMappingURL=dedup-manager.d.ts.map