Skip to content

Conversation

@sanggggg
Copy link
Collaborator

@sanggggg sanggggg commented Jan 2, 2026

Summary

Implements a hierarchical summarization layer with turn summaries and session summaries, enabling better organization and semantic search across chat sessions.

Changes

Schema & Models

  • Add migration 018 for turn_summaries and session_summaries tables
  • Create TurnSummary model with message boundaries and LLM-generated content
  • Create SessionSummary model for session-level aggregation
  • Add FTS5 virtual tables for semantic search

Repositories

  • TurnSummaryRepository with CRUD + FTS search
  • SessionSummaryRepository with CRUD + FTS search

Services

  • TurnDetector: Detects turn boundaries (User message starts a turn)
  • TurnSummarizer: LLM-based summarization of individual turns
  • SessionSummarizer: Aggregates turn summaries into session summaries

CLI

  • Add summarize turns [--session <ID>] [--all] command
  • Add summarize sessions [--session <ID>] [--all] command
  • Add summarize status command to check summarization progress

Architecture

Session
  └── Turn Summaries (per user-initiated turn)
        └── Session Summary (aggregated from turns)

Turn Detection Rules:

  • New turn starts with User message (SimpleMessage or SlashCommand)
  • Includes all following messages until next User message
  • Tool results from User don't start new turns

Test plan

  • All 209 unit tests pass
  • Clippy passes with -D warnings
  • Manual testing of CLI commands with real sessions

Related Issues

Closes #106

🤖 Generated with Claude Code

sanggggg and others added 3 commits January 2, 2026 15:02
…aries

Add hierarchical summarization layer for chat sessions:

Schema & Models:
- Add migration 018 for turn_summaries and session_summaries tables
- Create TurnSummary model with message boundaries and LLM-generated content
- Create SessionSummary model for session-level aggregation
- Add FTS5 virtual tables for semantic search

Repositories:
- TurnSummaryRepository with CRUD + FTS search
- SessionSummaryRepository with CRUD + FTS search

Services:
- TurnDetector: Detects turn boundaries (User message starts a turn)
- TurnSummarizer: LLM-based summarization of individual turns
- SessionSummarizer: Aggregates turn summaries into session summaries

CLI:
- Add `summarize turns` command for turn-level summarization
- Add `summarize sessions` command for session-level summarization
- Add `summarize status` command to check summarization progress

Closes #106

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

Co-Authored-By: Claude Opus 4.5 <[email protected]>
1. Fix Unicode truncation panic in truncate_content:
   - Use char_indices() for safe multi-byte UTF-8 character handling
   - Add tests for emoji, CJK, and mixed Unicode content

2. Fix type inconsistency (String vs Uuid for session_id):
   - Change repository methods to accept &Uuid instead of &str
   - Update all callers to use Uuid directly
   - Update tests to use proper UUIDs

3. Fix silent error suppression in parsing:
   - Add tracing::warn() logs when turn_type/outcome parsing fails
   - Use and_then() instead of map().flatten() per clippy

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

Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@sanggggg sanggggg merged commit a1fc65c into main Jan 2, 2026
5 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.

Hierarchical Storage Migration Plan

2 participants