feat: add session memory tracking, proactive hints, and context recovery#150
Open
maplenk wants to merge 12 commits intoDeusData:mainfrom
Open
feat: add session memory tracking, proactive hints, and context recovery#150maplenk wants to merge 12 commits intoDeusData:mainfrom
maplenk wants to merge 12 commits intoDeusData:mainfrom
Conversation
Account for optional signatures in the search_graph and trace_call_path size estimators, and improve compact trace chains to report omitted-node counts. This also documents the normal-path output enrichment introduced with Task 4: search_graph results now include file_path, start_line, end_line, and signature, and trace_call_path hop items now include file_path, start_line, and signature.
Prefer non-test symbol matches before pagerank for ambiguous short names. Batch-load visited node metadata and pagerank scores to remove per-node query loops during impact analysis. Hide test counts from the public summary when include_tests=false, and add max_tokens truncation support to get_impact_analysis with MCP coverage.
Add the impact-analysis store API declaration, expose get_impact_analysis in CLI help text, and cover the tool with the existing integration fixture.
Phase 5: Three new compound MCP tools (explore, understand, prepare_change) that bundle multiple graph queries into single-call responses: - explore: area search with matches, dependencies, hotspots, entry points - understand: symbol deep-dive with 3-tier resolution (exact QN, exact name with auto-pick, QN suffix with suggestions), callers, callees, source, connected symbols, is_key_symbol flag - prepare_change: wraps impact analysis with review_scope (must_review, should_review, tests) and include_tests=false support - All three support max_tokens budget with progressive truncation - Wire qn_pattern in store search (completing pre-existing API contract) Bug fixes across all committed phases: - Fix REQUIRE_STORE leaking heap args in 5 handlers (get_key_symbols, get_impact_analysis, explore, understand, prepare_change) - Fix markdown_builder_reserve infinite loop on OOM (NULL check after safe_realloc) - Fix SQLite bind parameter limit in impact_fetch_nodes_with_scores (chunk into batches of 900) - Fix cbm_mcp_text_result(NULL) crash on OOM (guard with empty string) - Fix POSIX regex: remove invalid PCRE (?i) prefix from contains pattern - Fix search degree filter: set min_degree/max_degree to -1 (disabled) in compound search helpers - Fix summary_count_nodes returning -1 on SQL error (return 0 instead) - Fix explore total_results overcounting unfiltered hotspots - Fix qsort(NULL, 0) undefined behavior in explore - Fix handle_understand early return leaking search outputs (use goto) - Refactor handle_prepare_change to use goto cleanup pattern Output enrichment (non-breaking): - search_graph results now include start_line, end_line, signature - trace_call_path hops now include file_path, start_line, signature Tests: 2639 passed (+44 new), 0 failures Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Track files read/edited, symbols queried, areas explored, and impact analyses across the MCP session. New get_session_context tool returns accumulated state plus related_untouched: graph neighbors of touched symbols ranked by PageRank that haven't been examined yet. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Enrich search_graph, explore, understand, prepare_change, and get_impact_analysis responses with session-aware hints when actionable: - Area re-exploration overlap with new/already-seen result counts - Symbol re-query detection with unexamined neighbor suggestions - Blast radius overlap with already-edited files warning - High-PageRank untouched symbol suggestion after 10+ queries Hints are budget-aware (skipped if response near max_tokens) and non-breaking (optional session_hint string field in JSON response). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use HINT_SNPRINTF macro consistently across all hint builders and initialize buf[0] to match sibling functions (post-review P2 fixes). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New MCP tool returns a compact markdown summary of the session: files touched (read/edited), symbols investigated with PageRank enrichment, impact analyses run, areas explored, and suggested next steps (unexamined graph neighbors ranked by PageRank). Designed for context recovery after Claude Code compaction — call get_session_summary to instantly restore the full session picture. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
maplenk
added a commit
to maplenk/codebase-memory-mcp
that referenced
this pull request
Mar 26, 2026
All install paths, download URLs, self-update checks, CI workflows, and documentation now reference maplenk/codebase-memory-mcp so the fork can operate independently with its own releases while upstream PRs (DeusData#147-DeusData#150) are pending. Upstream attribution in README fork section and LICENSE preserved. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Owner
|
Thanks @maplenk — session memory and context recovery would improve the multi-session experience significantly. Will review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds session-level memory that tracks what the agent touched during a session, enriches tool responses with proactive hints, and provides a summary tool for context recovery after compaction.
Motivation
GrapeRoot (graperoot.dev) benchmarked 13 points higher than a reactive graph tool by pre-loading relevant context based on session history. Their finding: "proactive context beats reactive querying." This PR brings session awareness to codebase-memory-mcp.
New tools
get_session_context— Returns files read, symbols queried, areas explored, andrelated_untouched: graph neighbors of touched nodes that haven't been examined yet, ranked by PageRank. Answers "what should I look at next?"get_session_summary— Compact markdown summary of the entire session: files touched, symbols investigated, areas explored, key findings, suggested next steps. Designed for context recovery after Claude Code compacts its context window.Enhanced tools (proactive hints)
5 existing tools now include a
session_hintfield when relevant:Implementation
session_state_t— hash sets for files/symbols/areas, initialized on first tool call, reset on server restart (matches MCP session lifecycle). Not persisted to SQLite.related_untouchedcomputed via 1-hop graph query on touched symbols, filtered by already-read files, ranked by PageRank.max_tokens.Tests
18 new tests across phases 7A/7B/7C. Total: 2657 passing, ASan/UBSan clean.
Part 4 of a 4-PR series. Depends on #149 → #148 → #147.
Built with OpenAI Codex and Claude Code.