RFC #26: Add session signals and commit tracking (revised per RFC #17)#29
Conversation
Implements data enrichment for deeper session analysis: - Add session outcome detection (success/abandoned/frustrated/unknown) - Add session_commits junction table with timing metadata - Add satisfaction scoring based on error rates and patterns - Add 3 new MCP tools: query_outcomes, update_outcomes, get_session_commits - Add 3 new CLI commands: outcomes, update-outcomes, session-commits - Add --project filter to new CLI commands for consistency - Track session_commits_errors in correlate_git_with_sessions return - Add failed_sessions list to update_session_outcomes return - Add DEBUG logging to get_col helper for migration debugging Closes #26 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PR Review: RFC #26 Session Outcome Detection and EnrichmentOverall this is a solid implementation of session outcome tracking. The code is well-structured, follows existing patterns, and includes comprehensive tests (202 passing). Here's my detailed feedback: ✅ Strengths
🔧 Suggestions for Improvement1. SQL Injection Risk in CLI (Medium Priority) In project_filter = "AND s.project_path LIKE ?"
params.append(f"%{project}%")This is actually safe (parameterized), but the f-string construction is in the WHERE clause. Consider using the existing 2. Missing The CLI @mcp.tool()
def query_outcomes(days: int = 7, min_events: int = 5, project: str | None = None) -> dict:3. Unused The
4. Potential performance concern in The function makes individual
5. Confidence score calculation quirk In confidence = 1.0 - max_score # Lower confidence when scores are lowThis means when 6. Missing validation for If min_events = max(1, min_events)📝 Minor Nits
🔒 SecurityNo security concerns identified. SQL queries use parameterized statements throughout. 📊 PerformanceThe queries are well-indexed (indexes on Summary: This PR is ready to merge with minor improvements. The implementation follows project conventions, has good test coverage, and implements a useful feature. The suggestions above are mostly enhancements rather than blockers. |
Per RFC #17: "Raw data with light structure beats heavily processed summaries. The LLM can handle context." This refactor removes pre-computed interpretation fields and surfaces raw signals instead: Removed: - outcome column (success/abandoned/frustrated/unknown) - outcome_confidence column - satisfaction_score column - detect_session_outcomes() → replaced with get_session_signals() - update_session_outcomes() → removed entirely - query_outcomes MCP tool → replaced with get_session_signals - update_outcomes MCP tool → removed - outcomes CLI command → replaced with signals Added: - get_session_signals(): Returns raw metrics for LLM interpretation (error_count, error_rate, edit_count, commit_count, has_rework, has_pr_activity, duration_minutes) - Design Philosophy section in CLAUDE.md documenting the principle Kept (observable data): - session_commits junction table with timing data - context_switch_count field - get_session_commits MCP tool and CLI command 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Refactored: Applied RFC #17 'Don't Over-Distill' PrincipleThis PR has been refactored to align with the design principle from RFC #17:
What ChangedRemoved (pre-computed interpretation):
Added (raw signals):
Kept (observable data):
Raw Signal Output Example{
"event_count": 50,
"error_count": 2,
"error_rate": 0.04,
"edit_count": 10,
"git_count": 5,
"commit_count": 2,
"has_rework": False,
"has_pr_activity": True,
"duration_minutes": 45.0
}The consuming LLM can interpret these signals with its fuller context rather than us pre-computing labels. 🤖 Generated with Claude Code |
PR Review: RFC #26 - Session Outcome Detection and EnrichmentThanks for this well-structured PR implementing session outcome tracking! The implementation follows the project's design philosophy nicely. Here's my detailed review: ✅ Strengths1. Excellent adherence to RFC #17 "Don't over-distill" principle 2. Clean schema migration 3. Good test coverage
4. Consistent API design
|
| Aspect | Rating |
|---|---|
| Code Quality | ⭐⭐⭐⭐ |
| Test Coverage | ⭐⭐⭐⭐⭐ |
| Security | ⭐⭐⭐⭐ (minor SQL pattern concern) |
| Performance | ⭐⭐⭐⭐ (acceptable, room for optimization) |
| Documentation | ⭐⭐⭐⭐⭐ |
Recommendation: Approve with minor suggestions. The core implementation is solid and follows project conventions well.
API improvements for LLM data analysis workflows: 1. Add session_id filter to query_timeline and get_user_journey - Allows drilling into a specific session's full trace - Enables: discover sessions → get signals → drill into session 2. Change min_events default from 5 to 1 in get_session_signals - 36% of sessions were being filtered out (premature optimization) - Per RFC #17: let the LLM decide what's meaningful based on event_count - Users can still pass --min-events=5 if they want filtering 3. Update CLAUDE.md with Session Discovery and Drill-In Flow docs New CLI option: session-analytics-cli journey --session-id <id> New MCP parameters: query_timeline(session_id=...) get_user_journey(session_id=...) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Additional Improvements: Session Discovery and Drill-In FlowBased on API gap analysis, added improvements for LLM data analysis workflows: 1. Session ID Filters
2. Fixed min_events Default
3. Documentation
Tests: All 200 passing. |
PR Review: RFC #26 - Session Signals and Commit TrackingOverall, this is a well-structured PR that follows the project's design philosophy. The adherence to RFC #17 ("Don't over-distill") is evident throughout. Here's my detailed review: ✅ Strengths1. Design Philosophy Alignment
2. Schema Migration
3. Test Coverage
4. API Design
|
The discovery flow (query_sessions → get_session_signals → drill-in) was documented in CLAUDE.md but not in guide.md, which is exposed as the MCP resource `session-analytics://guide` for LLM callers. - Add "Session Discovery and Drill-In" section to guide.md with examples - Add maintainer note to CLAUDE.md to keep both doc surfaces in sync 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PR Review: RFC #26 - Session Signals and Commit TrackingThis is a well-structured implementation that follows the project's design philosophy. The revision per RFC #17 ("Don't over-distill") is a sound architectural decision. StrengthsArchitecture & Design
Code Quality
Test Coverage
Minor Suggestions
Security
Performance
SummaryRecommendation: Approve This PR is well-implemented and follows the project's established patterns. The revision to use raw signals instead of pre-computed outcomes is the right call given the stated design philosophy. The code is clean, well-tested, and properly documented. The minor suggestions above are non-blocking improvements that could be addressed in follow-up work if desired. |
- Add `make restart` to reload LaunchAgent after code changes - Add "When to restart" table to CLAUDE.md clarifying which changes need a restart (MCP tools, queries, storage) vs which don't (CLI, tests, docs) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code Review: RFC #26 Session Signals and Commit TrackingOverall, this is a well-structured PR that implements session signals and commit tracking while adhering to the RFC #17 "Don't over-distill" design philosophy. The implementation is clean, well-tested (197 tests), and the documentation updates are thorough. ✅ Strengths
🔍 Suggestions for Consideration
📋 Minor Observations
🏁 SummaryThis PR is ready to merge. The implementation is solid, well-tested, and follows the project design principles. The only substantive suggestion is adding the project parameter to the MCP get_session_signals tool for consistency with the CLI. 🤖 Review generated with Claude Code |
Align session-analytics API with claude-event-bus conventions: **Tool renames (query_* → list_*/get_*)**: - query_tool_frequency → get_tool_frequency - query_command_frequency → get_command_frequency - query_sessions → list_sessions - query_timeline → get_session_events - query_tokens → get_token_usage - query_sequences → get_tool_sequences - query_permission_gaps → get_permission_gaps - query_outcomes → get_session_signals (revised per RFC #17) **Argument standardization**: - threshold → min_count (consistency) - min_events → min_count (consistency) - hours → days (fractional: 0.5 = 12 hours) - count → limit (alignment with event-bus) **Documentation**: - Add Suggested Workflows section to guide.md with flowcharts - Update CLAUDE.md tool table - Add MCP API Naming Conventions section 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
API Naming StandardizationAdded commit to align MCP API naming with claude-event-bus conventions: Tool Renames
Argument Standardization
Documentation
All 200 tests pass. |
PR Review: RFC #26 - Session Signals and Commit TrackingThis is a well-structured implementation that adds valuable session analytics capabilities while adhering to the RFC #17 "Don't over-distill" design principle. Here's my detailed review: ✅ Strengths1. Excellent Design Philosophy Adherence 2. Clean Schema Migration
3. Comprehensive Test Coverage
4. CLI/MCP Tool Naming Consistency
5. Good Documentation
|
Summary
Implements RFC #26 "Data enrichment for deeper session analysis" with raw session signals and commit tracking capabilities.
Revised per RFC #17 principle: "Don't over-distill - raw data with light structure beats heavily processed summaries."
Key Features
get_session_signals,get_session_commitssignals,session-commitswith--projectfilterWhat's NOT Included (by design)
Per RFC #17, we intentionally do NOT pre-compute interpretations:
outcomeclassification (success/abandoned/frustrated)outcome_confidencescoressatisfaction_scoreestimatesThe consuming LLM has context we lack (user intent, conversation history) and should interpret the raw signals itself.
Technical Details
Testing
Test plan
make check(fmt, lint, 197 tests pass)signals,session-commits🤖 Generated with Claude Code