feat: real-time indexing hooks — per-message prompt/response pairing#86
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughIntroduces a comprehensive real-time indexing system for capturing user prompts, pairing them with assistant responses, and persisting indexed content to a SQLite database with automatic fallback to JSONL file queueing. Includes three hook scripts, a core Changes
Sequence DiagramsequenceDiagram
participant User as User
participant Prompt as Prompt Capture<br/>(Hook)
participant Response as Response Index<br/>(Hook)
participant Indexer as RealtimeIndexer
participant SQLite as SQLite DB
participant Queue as JSONL Queue
User->>Prompt: Send prompt payload (session_id)
Prompt->>Indexer: capture_prompt()
Indexer->>Indexer: Store prompt in memory
User->>Response: Send response payload (session_id, message)
Response->>Indexer: index_response()
Indexer->>Indexer: Retrieve pending prompt<br/>Pair with response<br/>Generate content hash & chunk_id
alt DB Available
Indexer->>SQLite: Insert chunk record
SQLite-->>Indexer: Success
Indexer->>Indexer: Clear pending prompt
else DB Unavailable
Indexer->>Queue: Write JSONL entry
Queue-->>Indexer: Queued
end
Indexer-->>Response: Return chunk_id
Response-->>User: Confirm indexing
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Claude Code hooks for real-time BrainLayer indexing: - UserPromptSubmit → capture user prompt to pending file - Stop → pair with last_assistant_message, store to DB - PostCompact → create chapter boundary marker Core library (src/brainlayer/hooks/indexer.py): - RealtimeIndexer: in-memory prompt correlation, content-hash dedup - Chapters table for compact event boundaries - Stale prompt cleanup (5min TTL) - Fallback queue when DB unavailable Production DB compatible: uses id, conversation_id, metadata JSON, source_file (NOT NULL), source='realtime'. 14 tests, all passing. Live-tested against 312K chunk production DB. Based on Research 10 architecture: daemon-centric pairing, session_id + content_hash dedup, two-phase enrichment design. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
c9bc11b to
2773ab5
Compare
Summary
session_id + SHA256) prevents duplicate indexing during batch→realtime migrationBased on Research 10 architecture.
Components
src/brainlayer/hooks/indexer.pyhooks/brainbar-stop-index.pylast_assistant_message, pairs with pending prompt, stores to production DBhooks/brainbar-prompt-capture.pyhooks/brainbar-postcompact.pytests/test_realtime_hooks.pyArchitecture
Test plan
source='realtime'source_file(silent INSERT OR IGNORE failure)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests