Skip to content

feat(memory): add MemCoT SemanticStateAccumulator and Zoom-In/Out recall views#3592

Merged
bug-ops merged 2 commits intomainfrom
3574-memcot-semantic-state
May 4, 2026
Merged

feat(memory): add MemCoT SemanticStateAccumulator and Zoom-In/Out recall views#3592
bug-ops merged 2 commits intomainfrom
3574-memcot-semantic-state

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented May 4, 2026

Summary

All features gated by memory.memcot.enabled = false (default) — zero overhead when disabled.

Architectural notes

Test plan

  • 9016 unit tests pass (cargo nextest run --workspace --lib --bins --features "desktop,ide,server,chat,scheduler,profiling,task-metrics,sandbox,self-check")
  • 28 doc-tests pass (cargo test --doc -p zeph-core --features "task-metrics")
  • 4 insta snapshot tests: head_view, zoom_in_view, zoom_out_view, sa_head_view
  • No-op invariant: memory.memcot.enabled = false verified by CountingProvider test (chat_calls == 0)
  • Debug dump: memcot_state_written_to_dump_when_present + memcot_state_null_when_absent
  • 7 new GraphStore method tests

Closes #3574
Closes #3575

@github-actions github-actions Bot added documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes core zeph-core crate dependencies Dependency updates enhancement New feature or request size/XL Extra large PR (500+ lines) labels May 4, 2026
bug-ops added 2 commits May 4, 2026 21:12
…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.
@bug-ops bug-ops force-pushed the 3574-memcot-semantic-state branch from f7c477e to 1c78fe8 Compare May 4, 2026 19:22
@github-actions github-actions Bot added the tests Test-related changes label May 4, 2026
@bug-ops bug-ops enabled auto-merge (squash) May 4, 2026 19:24
@bug-ops bug-ops merged commit a52deab into main May 4, 2026
32 checks passed
@bug-ops bug-ops deleted the 3574-memcot-semantic-state branch May 4, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate dependencies Dependency updates documentation Improvements or additions to documentation enhancement New feature or request memory zeph-memory crate (SQLite) rust Rust code changes size/XL Extra large PR (500+ lines) tests Test-related changes

Projects

None yet

1 participant