Skip to content

feat: Add event-bus integration for cross-session insights#59

Merged
evansenter merged 1 commit into
mainfrom
issue-54-event-bus-integration
Jan 8, 2026
Merged

feat: Add event-bus integration for cross-session insights#59
evansenter merged 1 commit into
mainfrom
issue-54-event-bus-integration

Conversation

@evansenter

Copy link
Copy Markdown
Owner

Summary

  • Ingest events from claude-event-bus for queryable cross-session insights
  • Add ingest_bus_events() and get_bus_events() MCP tools
  • Add bus-events CLI command
  • Integrate with get_insights() for /improve-workflow

Changes

File Changes
storage.py +BusEvent dataclass, migration v6
bus_ingest.py NEW - incremental ingestion
queries.py +query_bus_events()
server.py +2 MCP tools
cli.py +bus-events command, fix formatter collision
patterns.py +cross_session_activity in insights
guide.md +Event-Bus Integration docs
docs/event-bus-integration.md NEW - detailed documentation

Test plan

  • All 293 tests pass
  • Migration v6 runs successfully
  • CLI bus-events command works
  • MCP tools functional

Closes #54

🤖 Generated with Claude Code

Ingest events from claude-event-bus for queryable cross-session learnings.

New MCP tools:
- ingest_bus_events(days) - incremental ingestion from event-bus DB
- get_bus_events(days, event_type, session_id, repo, limit) - query events

New CLI command:
- session-analytics-cli bus-events [--days N] [--event-type TYPE] [--repo NAME]

Integration:
- get_insights() now includes cross_session_activity counts
- Supports gotcha_discovered, pattern_found, help_needed, task_completed events

Schema: Migration v6 adds bus_events table with indexes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@claude

claude Bot commented Jan 8, 2026

Copy link
Copy Markdown

Prompt: evansenter/dotfiles/.../claude-review.md

Code Review

Summary

This PR adds event-bus integration to session-analytics, enabling ingestion and querying of cross-session events (gotchas, patterns, help requests) from the claude-event-bus database. It includes a new bus_events table (migration v6), ingestion logic, query functions, MCP tools, and CLI commands.

Issues Found

Critical

None

Important

  • bus_ingest.py:110 - Uses storage._connect() directly, violating project conventions. CLAUDE.md states: "Storage API: Use storage.execute_query() / execute_write(); avoid _connect()". Consider adding an execute_many() method to storage.py or use execute_write() in a loop.

  • queries.py:1887 - Logic bug in type breakdown query. When only the timestamp filter is present, where_parts[:-1] becomes an empty list, and " AND ".join([]) produces an empty string, making the WHERE clause invalid (WHERE GROUP BY...). This will cause a SQL syntax error when querying with default parameters.

  • server.py:736 - ingest_bus_events MCP tool unconditionally wraps result with {"status": "ok", **result}, but the underlying function already returns {"status": "skipped", ...} or {"status": "error", ...}. This duplicates the status key. Should check the result status and return it directly without wrapping when status is not "ok".

  • Missing tests - No tests were added for the new functionality (bus_ingest.py, query_bus_events(), MCP tools, CLI command). The PR description claims "All 293 tests pass" but no new tests cover the new code paths (incremental ingestion, error handling, type breakdown query, etc.).

Suggestions

  • queries.py:1883-1891 - The type breakdown query rebuilds the WHERE clause by slicing where_parts[:-1]. This is fragile and assumes the last element is always the limit condition (which isn't added to where_parts, it's just appended to params). Consider building the base where clause once and reusing it for both queries to avoid this complexity.

  • docs/event-bus-integration.md:136 - Documentation mentions "type_breakdown" in the response but queries.py:1899 uses "event_types" as the key. The documentation and code should be consistent.

Verdict

REQUEST_CHANGES - There's a SQL syntax bug in the type breakdown query that will crash with default parameters, a project convention violation with _connect(), a response status wrapping issue, and missing test coverage for all new functionality.


Automated review by Claude Code

@evansenter evansenter merged commit 8519bde into main Jan 8, 2026
3 checks passed
@evansenter evansenter deleted the issue-54-event-bus-integration branch January 8, 2026 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ingest event-bus events for queryable gotchas and learning propagation

1 participant