feat(memory): add MemCoT SemanticStateAccumulator and Zoom-In/Out recall views#3592
Merged
feat(memory): add MemCoT SemanticStateAccumulator and Zoom-In/Out recall views#3592
Conversation
…all views Implements issues #3574 and #3575 from the MemCoT paper (arXiv:2604.08216). SemanticStateAccumulator (zeph-core): - Summarizes conceptual state after each LLM turn via a fast-tier provider - Accumulates semantic deltas across the conversation - Background distillation with tokio::time::timeout bound; cost-gated by min_assistant_chars, min_distill_interval_secs, and max_distills_per_session - Feeds enriched query context into ReasoningMemory recall via [state] prefix fusion (capped at 2x query length to prevent query poisoning) - Metrics: memcot_distill_{total,timeout_total,error_total,skipped_total} - Span: core.memcot.distill with result=ok|timeout|error attribute - Soft fast-tier provider validator at Config::validate startup RecallView + recall_graph_view (zeph-memory): - New RecallView enum: Head | ZoomIn | ZoomOut - SemanticMemory::recall_graph_view unifies SA and non-SA graph recall paths - ZoomIn: head edge + provenance source message (reduces chunk boundary noise) - ZoomOut: head edge + 1-hop BFS neighbor expansion for causal context - Three new GraphStore methods: source_message_ids_for_edges, source_entity_id_for_edge, bfs_edges_at_depth - GraphFact.edge_id: Option<i64> added across all four retrieval backends Config: - New [memory.memcot] TOML section: enabled (default false), distill_provider, distill_timeout_secs, min_assistant_chars, min_distill_interval_secs, max_distills_per_session, recall_view Debug dump: - RequestDebugDump::memcot_state: Option<&str> populated when accumulator has non-empty state, satisfying #3574 AC#2 All features are completely invisible when memory.memcot.enabled = false: no LLM calls, no allocations, no latency overhead. RecallView defaults to Head view (byte-identical to prior behavior). Note: #3575 title references ReasoningMemory::recall — this method does not exist; the correct integration surface is SemanticMemory::recall_graph_view as specified in APEX-MEM spec §14.1. No rename of ReasoningMemory. AC#3 of #3575 (LoCoMo fixture) deferred to follow-up issue F1 (LoCoMo benchmark dataset not present in repo); covered by insta snapshot tests. Closes #3574 Closes #3575
…and clippy warnings New ContextAssemblyView fields pushed async state machine size over the clippy::large_futures threshold in all test files that await agent.run(). Add #![allow(clippy::large_futures)] to the affected test modules. Fix doc-test compile error in LlmConfig::warn_non_fast_tier_provider (LlmConfig has no Default impl — mark no_run). Fix field_reassign_with_default in accumulator tests: use struct update syntax for MemCotConfig construction.
f7c477e to
1c78fe8
Compare
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
SemanticStateAccumulatoradded toTurnContextinzeph-core— distills semantic state after each LLM turn via a fast-tier provider, feeds enriched query context into graph recallRecallViewenum +SemanticMemory::recall_graph_viewinzeph-memory— unified Head/ZoomIn/ZoomOut recall pipeline covering both SA and non-SA pathsRequestDebugDump::memcot_stateexposes accumulator buffer in debug dumpsGraphFact.edge_idand three newGraphStoremethods support the ZoomIn/ZoomOut enrichment pipelineAll features gated by
memory.memcot.enabled = false(default) — zero overhead when disabled.Architectural notes
ReasoningMemory::recallreinterpretation: issue feat(memory): extend ReasoningMemory recall with MemCoT Zoom-In evidence localization #3575 title references a method that does not exist. Per APEX-MEM spec §14.1, the correct integration surface isSemanticMemory::recall_graph_view. No rename ofReasoningMemory.Test plan
cargo nextest run --workspace --lib --bins --features "desktop,ide,server,chat,scheduler,profiling,task-metrics,sandbox,self-check")cargo test --doc -p zeph-core --features "task-metrics")head_view,zoom_in_view,zoom_out_view,sa_head_viewmemory.memcot.enabled = falseverified byCountingProvidertest (chat_calls == 0)memcot_state_written_to_dump_when_present+memcot_state_null_when_absentGraphStoremethod testsCloses #3574
Closes #3575