/**
 * Base palace document types.
 *
 * Products extend these with product-specific fields
 * (e.g. sourceWorkspaceId for NoteLett, sourceBrainId for MindLyst).
 */

// ── Wing (top-level grouping — workspace/brain/project) ────────────

export interface BasePalaceWingDoc {
  id: string;
  productId: string;
  userId: string;
  name: string;
  description?: string;
  memoryCount: number;
  l1Cache?: string;
  l1CacheUpdatedAt?: string;
  createdAt: string;
  updatedAt: string;
}

// ── Room (topic within a wing) ─────────────────────────────────────

export interface BasePalaceRoomDoc {
  id: string;
  productId: string;
  userId: string;
  wingId: string;
  name: string;
  description?: string;
  memoryCount: number;
  createdAt: string;
  updatedAt: string;
}

// ── Memory (core unit — one fact/decision/event/etc.) ──────────────

export interface BasePalaceMemoryDoc {
  id: string;
  productId: string;
  userId: string;
  wingId: string;
  roomId: string;
  hall: string;
  content: string;
  relevance: number;
  embedding?: number[];
  sourceId?: string;
  createdAt: string;
  updatedAt: string;
}

// ── Tunnel (cross-room/cross-wing link) ────────────────────────────

export interface BasePalaceTunnelDoc {
  id: string;
  productId: string;
  userId: string;
  fromMemoryId: string;
  fromWingId: string;
  toMemoryId: string;
  toWingId: string;
  relationship: string;
  strength: number;
  createdAt: string;
}

// ── Knowledge Graph Triple ─────────────────────────────────────────

export interface BasePalaceKGTripleDoc {
  id: string;
  productId: string;
  userId: string;
  wingId: string;
  subject: string;
  predicate: string;
  object: string;
  confidence: number;
  validFrom: string;
  validTo?: string;
  sourceMemoryId?: string;
  createdAt: string;
}

// ── Diary Entry ────────────────────────────────────────────────────

export interface BasePalaceDiaryDoc {
  id: string;
  productId: string;
  userId: string;
  roleId: string;
  wingId?: string;
  entry: string;
  createdAt: string;
}

// ── Extracted memory (output of extraction pipeline) ───────────────

export interface ExtractedMemory {
  hall: string;
  content: string;
  roomSlug: string;
  entities: string[];
}
