feat(memory): add MemGuard type-aware retrieval composition - #6226
Merged
Conversation
bug-ops
force-pushed
the
feat/issue-6086/memguard-type-aware-retrieval
branch
2 times, most recently
from
July 13, 2026 17:18
927da20 to
88ad8e2
Compare
bug-ops
enabled auto-merge (squash)
July 13, 2026 17:18
Add a retrieval-only, fetch-time gate on context assembly so a turn can compose only the functionally relevant memory types instead of always fetching all sources. Introduces a FunctionalType enum spanning the existing per-collection/per-table memory sources (episodic, user facts, behavioral rules, reasoning strategies, cross-session summaries, graph facts) and gates five of the six ContextAssembler fetchers on the active set; corrections stay unconditionally composed as a safety-critical invariant. No new storage, no write-path change, and the feature is a byte-for-byte no-op when disabled (the default). Closes #6086
bug-ops
force-pushed
the
feat/issue-6086/memguard-type-aware-retrieval
branch
from
July 13, 2026 17:19
88ad8e2 to
8f6683d
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
ContextAssembler::schedule_context_fetchersso a turn can compose evidence from only the functionally relevant memory type(s), instead of always fetching every source unconditionally.FunctionalTypeenum (episodic/user_fact/behavioral_rule/reasoning_strategy/cross_session_summary/graph_fact) maps onto the existing per-collection/per-table memory sources — no new storage, no write-path change,categorypayload left dead/untouched.fetch_corrections(behavioral rules / past corrections) stays unconditionally composed as a documented safety-critical invariant.[memory.type_aware_compose]config section,enabled = falseby default — a byte-for-byte no-op identical to pre-change behavior. Optionalintent_scopedwidening reuses the existing heuristic memory router; no new LLM call in v1.config/default.tomladvisory block,--initwizard prompts,--migrate-configstep, CHANGELOG entry.Background
Code-grounded audit found Zeph already had functional-type isolation at the storage layer (six Qdrant collections, several dedicated SQLite tables) but no equivalent selectivity at retrieval time — every turn composed all memory types regardless of need. The design went through two adversarial critique rounds before implementation: round 1 (critical) corrected an initial premise that assumed a single undifferentiated vector pool; round 2 (significant) dropped an underspecified new trait method in favor of gating the existing per-slot fetchers directly, and corrected the user-fact source mapping. See
.local/specs/064-memguard-type-aware-memory-retrieval/spec.mdfor the full spec and revision history (not included in this diff —.local/is gitignored).Closes #6086
Test plan
cargo +nightly fmt --checkcargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warningscargo nextest run --config-file .github/nextest.toml --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins(13456+ passed)cargo test --docon all touched cratesRUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links") clean, full workspacefetch_document_ragmust survive Episodic exclusion)PreparedContexttype-exclusion at thegather()level (not just fetcher count)