feat: session-level enrichment — decisions, corrections, learnings#16
Conversation
…om full conversations Upgrade enrichment from chunk-level to session-level analysis: - Conversation reconstruction from ordered chunks with role prefixes - Single-pass LLM analysis extracting 12 structured fields (summary, intent, outcome, decisions, corrections, learnings, mistakes, patterns, tags, etc.) - Hybrid schema: flat columns for filterable fields + JSON for variable arrays - FTS5 full-text search on session narratives - CLI: `brainlayer enrich-sessions` with Rich progress bar and --stats mode - MCP: `brainlayer_session_summary` tool (#14) + session context in search results - 33 TDD tests covering schema, CRUD, reconstruction, parsing, and full pipeline Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (7)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
- Apply `since` filter to session_context discovery path (Method 1) - Remove unused `projects` variable in enrich_session - Copy dict before JSON serialization to avoid mutating caller's input - Remove unused `batch_size` CLI parameter Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 4 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| if total_chars > MAX_CONVERSATION_CHARS: | ||
| conversation_parts.append( | ||
| f"\n[... {len(chunks) - len(conversation_parts)} more chunks truncated]" | ||
| ) |
There was a problem hiding this comment.
Truncation count miscalculates remaining chunks
Low Severity
The truncation message formula len(chunks) - len(conversation_parts) is incorrect. conversation_parts only counts non-noise chunks (those not skipped by the continue at line 107), while len(chunks) includes all chunks. This inflates the reported count by the number of noise chunks already processed, and also includes the just-appended truncation message in the count. The resulting message sent to the LLM overstates how much content remains.
| ) | ||
| """) | ||
| cursor.execute("CREATE INDEX IF NOT EXISTS idx_session_enrichments_session ON session_enrichments(session_id)") | ||
| cursor.execute("CREATE INDEX IF NOT EXISTS idx_session_enrichments_project ON session_enrichments(primary_intent)") |
There was a problem hiding this comment.
Index named "project" actually indexes primary_intent column
Low Severity
The index idx_session_enrichments_project is created on the primary_intent column, not on any project column (which doesn't exist in session_enrichments). The name is misleading and could cause confusion when inspecting the schema or when someone assumes project-based lookups on this table are already indexed.
| if rows: | ||
| session_cache[session_id] = { | ||
| "session_summary": rows[0][0], | ||
| "session_intent": rows[0][1], |
There was a problem hiding this comment.
Session intent enrichment data fetched but never consumed
Low Severity
enrich_results_with_session_context fetches primary_intent from the database and adds it to metadata as session_intent, but the _search function in the MCP layer never reads meta.get("session_intent"). The other three enrichment fields (session_summary, session_outcome, session_quality) are all consumed — this one is silently dropped. Either the field is missing from the search output or it's dead code.
Additional Locations (1)
|
|
||
| except Exception as e: | ||
| rprint(f"[bold red]Error:[/] {e}") | ||
| raise typer.Exit(1) |
There was a problem hiding this comment.
Store connection leaked when exceptions escape enrichment loop
Low Severity
The VectorStore created at line 954 is closed manually at lines 967, 976, and 1015, but if an exception occurs in list_sessions_for_enrichment (line 970), during Progress initialization (line 984), or from any unhandled error path, the outer except at line 1019 catches it without calling store.close(). A try/finally or context manager would ensure cleanup on all paths.


Summary
brainlayer enrich-sessionswith Rich progress bar, project/date filters, and--statsmodebrainlayer_session_summary(tool feat: MLX auto-detection, stall detection, current_context fix #14) returns formatted session analysis + session context enrichment in search resultsWhat Changed
src/brainlayer/vector_store.pysrc/brainlayer/pipeline/session_enrichment.pysrc/brainlayer/cli/__init__.pyenrich-sessionscommand with Rich progresssrc/brainlayer/mcp/__init__.pybrainlayer_session_summarytool + session context in searchtests/test_session_enrichment.pytests/test_think_recall_integration.pyCLAUDE.mdTest plan
🤖 Generated with Claude Code
Note
Medium Risk
Adds new DB schema (new tables + indexes + FTS5) and integrates it into search/CLI/MCP paths, which can impact runtime behavior and persistence despite being largely additive.
Overview
Adds session-level enrichment (Phase 7) that reconstructs full conversations, runs an LLM once per session, and persists structured outputs (summary/intent/outcome/scores plus decisions/corrections/learnings/etc.) in a new
session_enrichmentsSQLite table with FTS5 support.Introduces a new
brainlayer enrich-sessionsCLI command (including--project/--since/--maxfilters and--stats) and extends the MCP server withbrainlayer_session_summary; search results are now optionally annotated with session-level summary/outcome/quality when available. Docs and tests are updated/added to cover the new pipeline, DB CRUD/stats, and MCP tool count wiring.Written by Cursor Bugbot for commit 2e7f653. This will update automatically on new commits. Configure here.