Skip to content

feat: Add compaction aggregation and pre-compaction pattern analysis (closes #81)#82

Merged
evansenter merged 5 commits into
mainfrom
feat/efficiency-improvements
Jan 10, 2026
Merged

feat: Add compaction aggregation and pre-compaction pattern analysis (closes #81)#82
evansenter merged 5 commits into
mainfrom
feat/efficiency-improvements

Conversation

@evansenter

Copy link
Copy Markdown
Owner

Summary

  • Add aggregate parameter to get_compaction_events() for session-level grouping
  • Add new analyze_pre_compaction_patterns() endpoint identifying antipatterns before compactions
  • Full CLI/MCP parity with --aggregate flag and pre-compaction-patterns command

Test plan

  • All 378 tests pass
  • New tests for aggregate mode and pattern analysis
  • Manual verification of CLI commands
  • Verify benchmark includes new endpoints

🤖 Generated with Claude Code

evansenter and others added 4 commits January 10, 2026 14:44
## Issue #77: Limit parameters for verbose endpoints
- Add `limit` parameter to get_tool_sequences (default: 50)
- Add `limit` parameter to get_compaction_events (default: 50)
- Add `limit` parameter to get_session_efficiency (default: 50)
- Return total_patterns/total_compaction_count for pagination awareness
- Use parameterized queries for LIMIT clauses (SQL injection prevention)

## Issue #78: Efficiency metrics in analyze_trends
- Add compactions, avg_compactions_per_session to trend comparison
- Add files_read_multiple_times as rework indicator
- Add avg_result_mb_per_session for context consumption tracking

## Issue #79: Efficiency metrics in classify_sessions
- Add efficiency object to each session with:
  - compaction_count, total_result_mb, files_read_multiple_times
  - burn_rate: "high" (>2/hr), "medium" (0.5-2/hr), "low" (<0.5/hr)

## Additional improvements
- Filter non-actionable commands (pwd, cd, echo, etc.) from permission gaps
- Update guide.md with new parameters and efficiency documentation
- Add 6 new tests for all new functionality

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Address reviewer feedback from claude-review:
- Add --limit parameter to sequences, compactions, efficiency commands
- Show truncation info in formatters ("Showing X of Y total")
- Maintain CLI/MCP parity as required by CLAUDE.md

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…loses #81)

RFC #81 implementation:
- Add `aggregate` parameter to `get_compaction_events()` for session-level grouping
- Add new `analyze_pre_compaction_patterns()` endpoint to identify antipatterns
  (consecutive reads, file rework, large results) before compactions
- Update CLI with --aggregate flag and new pre-compaction-patterns command
- Add benchmark entries for new functionality
- Update guide.md documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Resolve conflicts after main updated with PR #76 changes.

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

claude Bot commented Jan 10, 2026

Copy link
Copy Markdown

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

Code Review

Summary

Adds aggregation mode to get_compaction_events() and a new analyze_pre_compaction_patterns() endpoint per RFC #81. Includes CLI/MCP parity with formatters, documentation updates, and comprehensive tests.

Issues Found

Critical

None

Important

None

Suggestions

  • queries.py:2456-2458 - The read:edit ratio recommendation only triggers when edit_count > 0. When there are zero edits (all reads), the ratio would be infinite, which is arguably the most concerning case, but no recommendation is generated. Consider adding a check for edit_count == 0 and read_count > threshold to catch the "all reads, no edits" scenario.

Verdict

REQUEST_CHANGES - One suggestion for handling the edge case where edit_count is zero in the read:edit ratio check.


Automated review by Claude Code

Addresses claude-review feedback: when edit_count is 0 but reads > 10,
this now generates a "pure exploration pattern" recommendation instead
of silently skipping the check.

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

Copy link
Copy Markdown
Owner Author

Feedback Addressed

Implemented

  • [Suggestion] queries.py:2456-2458 - Handle zero-edit case in read:edit ratio check - Added detection for "pure exploration pattern" when edit_count == 0 and read_count > 10

@claude

claude Bot commented Jan 10, 2026

Copy link
Copy Markdown

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

Code Review

Summary

This PR adds an aggregate parameter to get_compaction_events() for session-level grouping and introduces a new analyze_pre_compaction_patterns() endpoint that identifies antipatterns before compactions (consecutive reads, re-read files, large results). Full CLI/MCP parity is maintained with formatters, documentation, and comprehensive tests.

Issues Found

Critical

None

Important

None

Suggestions

None

Verdict

APPROVE - Clean implementation addressing all requirements from RFC #81. Previous review feedback (zero-edit handling) has been addressed. Tests are comprehensive, documentation is updated, and benchmark includes both new endpoints.


Automated review by Claude Code

@evansenter evansenter merged commit a25f2bc into main Jan 10, 2026
3 checks passed
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.

1 participant