Skip to content

refactor(conversation-memory): V3 redesign - 3-hook architecture - #463

Merged
baleen37 merged 3 commits into
mainfrom
chore-claude-mem3-pr
Feb 9, 2026
Merged

refactor(conversation-memory): V3 redesign - 3-hook architecture#463
baleen37 merged 3 commits into
mainfrom
chore-claude-mem3-pr

Conversation

@baleen37

@baleen37 baleen37 commented Feb 9, 2026

Copy link
Copy Markdown
Owner

Summary

Complete redesign of conversation-memory plugin from complex observer daemon architecture to simplified 3-hook architecture.

Key Changes

Architecture Simplification:

  • Removed observer daemon that polled DB every 1s
  • Eliminated dual storage (exchanges + observations)
  • Simplified observations schema from 10+ fields to just title + content
  • Reduced token injection from ~900 tokens to budgeted 500 tokens

New Components:

  • db.v3.ts - Clean slate database schema (pending_events + observations)
  • compress.ts - Rule-based tool compression (no LLM)
  • observations.v3.ts - Simplified CRUD operations
  • batch-extract-prompt.ts - LLM batch extraction for Stop hook
  • search.v3.ts - Observation-only search
  • post-tool-use.ts - Hook to store compressed events
  • stop.ts - Hook for batch LLM extraction at session end
  • session-start.ts - Hook for token-budgeted injection
  • read.ts - Raw conversation access from JSONL

Legacy Files Deleted:
49 files (~16,000 lines) including:

  • parser.ts, sync.ts, tool-compress.ts
  • observer.ts, observation-prompt.ts
  • round-robin-provider.ts
  • All associated tests

3 New Hooks:

  1. PostToolUse - Stores compressed tool events (async, no LLM)
  2. Stop - Batch LLM extraction from pending_events (10-20 events per batch)
  3. SessionStart - Token-budgeted injection of recent observations

MCP Server Simplified to 3 Tools:

  1. search - Single query, returns compact observations (Layer 1)
  2. get_observations - Full details by ID array (Layer 2)
  3. read - Raw conversation from JSONL (Layer 3)

Test Plan

  • All 603+ tests passing
  • 18 integration tests covering end-to-end workflows
  • All components have unit tests
  • CI tests passing

Breaking Changes

Config file format changed:
Old format:

{
  "provider": "gemini",
  "gemini": {
    "apiKeys": ["key1", "key2"],
    "model": "gemini-2.0-flash"
  }
}

New format:

{
  "apiKey": "your-gemini-api-key",
  "model": "gemini-2.0-flash"
}

Database migration:

  • Old database file deleted on first run (no migration)
  • Clean slate with new schema

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Expanded integration test coverage for V3 architecture, including end-to-end workflows, session management, search functionality, and error handling scenarios.

Test User and others added 3 commits February 9, 2026 16:47
… architecture

Adds end-to-end integration tests covering:
- PostToolUse → pending_events → Stop → observations workflow
- SessionStart hook injection with token budgeting
- MCP tools (search, get_observations) with V3 database
- Full lifecycle from tool events to observations to search/injection
- Batch processing with context carryover between batches
- Multi-project isolation and concurrent session handling
- Error handling (LLM failures, malformed responses, rate limits)

Test coverage:
- 18 new integration tests
- 603 total tests passing
- All component interactions verified

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix mock setup for LLM provider to properly type vitest mock function
- Remove unused imports: searchObservationsV3, getPendingEventCountV3, mockEmbedding

The mock function now returns a type that includes both LLMProvider and the
vitest mock function properties, allowing proper access to mock.calls.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use __mockFn.mock.calls instead of __mockFn.calls to properly
access vitest mock call history.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Feb 9, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

A comprehensive integration test suite for the V3 architecture is added, exercising end-to-end workflows, session injections, MCP tool integration, batch processing, threshold-based extraction, filtering, and error handling scenarios with mocked LLM providers and in-memory SQLite.

Changes

Cohort / File(s) Summary
V3 Integration Test Suite
plugins/conversation-memory/src/integration.v3.test.ts
New comprehensive test file (778 lines) covering end-to-end workflows, session start hook injection with token budgeting, MCP tool search and retrieval, batch processing, threshold-based extraction, cross-project isolation, and error handling. Includes setup/teardown with in-memory SQLite database, mocked LLM provider and embeddings module, and extensive verification of observations, session injections, and search results.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested labels

enhancement

Poem

🐰 A burrow of tests now guards the v3 way,
Mocking LLMs and checking day by day,
Sessions injected, observations flow free,
Cross-project isolation—secure as can be! 🔒✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore-claude-mem3-pr

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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