export interface ProjectIdentity { rootPath: string; remoteUrl?: string; displayName: string; } export interface SessionInput { piSessionPath?: string; parentSessionId?: string; branchName?: string; gitHead?: string; } export type ProgressKind = "progress" | "failure" | "correction" | "checkpoint"; export interface ProgressEvent { id: string; projectId: string; sessionId?: string; parentEventId?: string; kind: ProgressKind; phase?: string; summary: string; evidence?: string; toolName?: string; toolCallId?: string; exitCode?: number; gitHead?: string; branchName?: string; filePaths: string[]; metadata: Record; occurredAt: string; } export type MemoryKind = | "preference" | "fact" | "convention" | "decision" | "lesson" | "failure" | "correction" | "procedure" | "experiment" | "checkpoint" | "handoff"; export type MemoryStatus = "candidate" | "active" | "superseded" | "archived" | "rejected"; export type MemoryScope = "global" | "project" | "session"; export interface MemoryCandidateInput { ownerKey: string; projectId?: string; sessionId?: string; kind: MemoryKind; scope: MemoryScope; title: string; content: string; tags: string[]; confidence: number; importance: number; evidenceKind: "user_stated" | "tool_observed" | "test_verified" | "reviewed" | "inferred"; gitHead?: string; branchName?: string; filePaths: string[]; supersedesId?: string; } export interface MemoryHit { id: string; kind: MemoryKind; scope: MemoryScope; status: MemoryStatus; title: string; content: string; confidence: number; evidenceKind: string; gitHead?: string; branchName?: string; createdAt: string; updatedAt: string; } export interface WorkingState { projectId: string; sessionId?: string; goal: string; phase: string; state: Record; sourceEventId?: string; updatedAt: string; } export interface MemoryPacket { workingState?: WorkingState; hits: MemoryHit[]; recentEvents: ProgressEvent[]; } export interface StoreHealth { ok: boolean; latencyMs: number; error?: string; capabilities: Record; } export interface RetrievalQuery { query: string; mode?: string; scope?: "current-project" | "global" | "all"; limit?: number; includeCandidates?: boolean; includeGlobal?: boolean; } export interface MemoryStore { migrate(signal?: AbortSignal): Promise; health(): Promise; stats(): Promise>; ensureProject(identity: ProjectIdentity): Promise; openSession(projectId: string, input: SessionInput): Promise; closeSession(sessionId: string, reason: string): Promise; appendProgress(event: ProgressEvent): Promise; upsertWorkingState(state: WorkingState): Promise; getResumePacket(projectKey: string, opts?: { includeGlobal?: boolean }): Promise; search(query: RetrievalQuery, projectKey?: string): Promise; createCandidate(input: MemoryCandidateInput): Promise; recordExport(memoryId: string, filePath: string): Promise; promote(id: string): Promise; reject(id: string): Promise; forget(id: string): Promise; close(): Promise; }