/** Core adapter, scope, and migration types for the memory subsystem. */ // --------------------------------------------------------------------------- // Database adapter // --------------------------------------------------------------------------- export interface RunResult { changes: number; lastInsertRowid: number | bigint | null; } export interface Adapter { exec(sql: string): Promise; run(sql: string, params?: unknown[]): Promise; get>(sql: string, params?: unknown[]): Promise; all>(sql: string, params?: unknown[]): Promise; transaction(fn: (ad: Adapter) => Promise): Promise; /** * Release the underlying database handle. Optional so test fakes that wrap * a real adapter don't have to implement it. Callers must use `adapter.close?.()` * and treat it as best-effort. Required on Windows to avoid `EBUSY: unlink` * when deleting temp directories holding open SQLite files. */ close?(): Promise; } // --------------------------------------------------------------------------- // Scope // --------------------------------------------------------------------------- export interface Scope { root_path: string; project_path: string; branch_name: string; topic: string; feature: string; } export interface ScopeInput { root_path?: string; rootPath?: string; project_path?: string; projectPath?: string; branch_name?: string; branchName?: string; topic?: string; feature?: string; } // --------------------------------------------------------------------------- // Link // --------------------------------------------------------------------------- export interface Link { path: string; line: number | null; label: string; } // --------------------------------------------------------------------------- // Schema / Migrations // --------------------------------------------------------------------------- export interface MigrationSpec { version: number; migrate: (ad: Adapter) => Promise; } export interface MigrationContext { adapter: Adapter; getMeta: (key: string) => Promise; setMeta?: (key: string, value: string) => Promise; }