-- Migration 008: RLM Schema -- Creates tables for Recursive Language Models (RLM) integration -- Provides chunking, buffering, and execution history storage -- Use test namespace and database USE NS test_rlm_e2e DB test_rlm_e2e; -- RLM Chunks table (from documents) -- Note: Using SCHEMALESS instead of SCHEMAFULL because: -- 1. SurrealDB auto-generates `id` field for all records -- 2. Explicit `id` field definition in SCHEMAFULL causes conflicts with CREATE queries -- 3. SCHEMALESS provides flexibility while still allowing indexes DEFINE TABLE rlm_chunks SCHEMALESS; -- Indexes for efficient queries (work with SCHEMALESS tables) DEFINE INDEX idx_rlm_chunks_chunk_id ON TABLE rlm_chunks COLUMNS chunk_id UNIQUE; DEFINE INDEX idx_rlm_chunks_doc_id ON TABLE rlm_chunks COLUMNS doc_id; -- RLM Buffers table (pass-by-reference for large contexts) DEFINE TABLE rlm_buffers SCHEMALESS; -- Indexes for buffers DEFINE INDEX idx_rlm_buffers_buffer_id ON TABLE rlm_buffers COLUMNS buffer_id UNIQUE; -- RLM Execution History table (for learning) DEFINE TABLE rlm_executions SCHEMALESS; -- Indexes for execution history DEFINE INDEX idx_rlm_executions_execution_id ON TABLE rlm_executions COLUMNS execution_id UNIQUE; DEFINE INDEX idx_rlm_executions_doc_id ON TABLE rlm_executions COLUMNS doc_id;