MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / session_memory_digest

Function session_memory_digest

src/hooks/memory_inject.rs:376–387  ·  view source on GitHub ↗

Builds the session-start memory digest for `root`, or `None` when injection is disabled, the project has no initialized store, or no injectable facts exist. When `session_id` is present the injected fact ids are recorded so per-prompt recall does not repeat them.

(root: &Path, session_id: Option<&str>)

Source from the content-addressed store, hash-verified

374/// injectable facts exist. When `session_id` is present the injected fact ids
375/// are recorded so per-prompt recall does not repeat them.
376pub async fn session_memory_digest(root: &Path, session_id: Option<&str>) -> Option<String> {
377 if !memory_injection_enabled() {
378 return None;
379 }
380 if !crate::tracedecay::TraceDecay::has_initialized_store(root).await {
381 return None;
382 }
383 let facts = select_digest_facts(digest_candidates(root).await, SESSION_DIGEST_FACT_COUNT);
384 let (text, included) = render_fact_block(DIGEST_HEADER, &facts, SESSION_DIGEST_CHAR_BUDGET)?;
385 record_injected_facts(root, session_id, &included);
386 Some(text)
387}
388
389/// Builds a prompt-relevance-gated recall block for a `UserPromptSubmit`-style
390/// event, or `None` when injection is disabled, the prompt is trivial, or no

Callers 3

hook_codex_session_startFunction · 0.85

Calls 5

memory_injection_enabledFunction · 0.85
digest_candidatesFunction · 0.85
render_fact_blockFunction · 0.85
record_injected_factsFunction · 0.85
select_digest_factsFunction · 0.70

Tested by

no test coverage detected