import { type EntityAlias, type EntityNode, type EntityObservation, type EntityTimelineEvent } from './types.js'; export interface EntityStoreAdapter { prepare(sql: string): { run(...params: unknown[]): { changes: number; lastInsertRowid: number | bigint; }; get(...params: unknown[]): unknown; all(...params: unknown[]): unknown[]; }; } export declare class EntityMergeError extends Error { readonly code: string; constructor(code: string, message: string); } declare const OBSERVATION_CONTEXT_KEY_COLUMNS: readonly ["workspace_context_key", "channel_context_key", "thread_context_key", "actor_context_key"]; type CreateEntityNodeInput = Omit; type AttachEntityAliasInput = Omit; type ObservationContextKeyColumn = (typeof OBSERVATION_CONTEXT_KEY_COLUMNS)[number]; type UpsertEntityObservationInput = Omit & Partial>; type AppendEntityTimelineEventInput = { event: Omit & { id?: string; created_at?: number; }; adapter?: EntityStoreAdapter; }; export interface UpsertEntityObservationResult { id: string; created: boolean; } export declare function clearEntityTableColumnCache(adapter: EntityStoreAdapter): void; export declare function parseObservationRow(row: Record): EntityObservation; export declare function createEntityNode(input: CreateEntityNodeInput): Promise; export declare function getEntityNode(id: string, adapter?: EntityStoreAdapter): EntityNode | null; export declare function listEntityNodes(): EntityNode[]; export declare function attachEntityAlias(input: AttachEntityAliasInput): Promise; export declare function listEntityAliases(entityId: string, adapter?: EntityStoreAdapter): EntityAlias[]; export declare function upsertEntityObservation(input: UpsertEntityObservationInput): Promise; export declare function upsertEntityObservations(inputs: UpsertEntityObservationInput[]): Promise; export declare function appendEntityTimelineEvent(input: AppendEntityTimelineEventInput): Promise; /** * Walks the `entity_nodes.merged_into` chain from the given id and returns the * terminal (unmerged) entity id. Detects cycles and caps depth. Read-only. * * Matches the read-time chain-walking approach described in the canonical * entity ontology implementation plan. */ export declare function resolveCanonicalEntityId(adapter: EntityStoreAdapter, id: string): string; export interface MergeEntityNodesInput { adapter: EntityStoreAdapter; source_id: string; target_id: string; actor_type: 'system' | 'user' | 'agent'; actor_id: string; reason: string; candidate_id: string | null; evidence_json: string; } export interface MergeEntityNodesResult { merge_action_id: string; timeline_event_id: string; merged_at: number; } /** * Marks `source_id` as merged into `target_id`, emits a timeline event, and * inserts the entity_merge_actions audit row with both entity IDs populated. * * Intentionally NOT wrapped in its own transaction — the caller is expected * to wrap the call in `adapter.transaction(...)` so the candidate status * update and this merge land atomically (Policy B1, hard transaction). * * Validates: source != target, both exist, both active/unmerged, same kind, * same scope. Throws `EntityMergeError` with a stable `code` on any violation. */ export declare function mergeEntityNodes(input: MergeEntityNodesInput): MergeEntityNodesResult; export {}; //# sourceMappingURL=store.d.ts.map