pub struct BrainSession { /* private fields */ }Implementations§
Source§impl BrainSession
impl BrainSession
pub fn config(&self) -> &ProjectConfig
Sourcepub fn resolve_request_floors(&self, request: &mut ContextRequest)
pub fn resolve_request_floors(&self, request: &mut ContextRequest)
Resolve explicit overrides before legacy sentinels. The explicit zero survives a second resolution at the injected/production boundary.
pub fn open(start: &Path) -> KimetsuResult<Self>
pub fn open_readonly(start: &Path) -> KimetsuResult<Self>
pub fn retrieve_context( &self, stage: &str, query: &str, budget_tokens: u32, ) -> KimetsuResult<ContextBundle>
Sourcepub fn retrieve_context_with_request(
&self,
request: ContextRequest,
) -> KimetsuResult<ContextBundle>
pub fn retrieve_context_with_request( &self, request: ContextRequest, ) -> KimetsuResult<ContextBundle>
v0.6: full-request variant used by kimetsu_brain_context MCP tool
and retrieve_context_readonly_with_request to expose tags,
min_score, max_capsules, and prefer_roles.
W3.1: routes through open_embedder_for so the persistent
[embedder] enabled = false config field truly disables the
cosine path (FTS-only retrieval) without relying on the env var.
Sourcepub fn resolved_abstain_evidence(&self) -> f32
pub fn resolved_abstain_evidence(&self) -> f32
v2.7: resolve the absolute abstention floor for this session’s config.
See resolved_abstain_evidence_for.
Sourcepub fn retrieve_proactive(
&self,
request: ContextRequest,
) -> KimetsuResult<ContextBundle>
pub fn retrieve_proactive( &self, request: ContextRequest, ) -> KimetsuResult<ContextBundle>
v0.8: proactive (mid-work) retrieval. Pins [NoopEmbedder] so
it stays lexical-FTS-only — NO embedding model is loaded even in
--features embeddings builds, keeping the per-tool-call hook
cheap. request.kinds should restrict to actionable kinds; the
caller sets a high min_score and max_capsules: 1 so recall is
rare and confident (the human-brain “it comes to you” model).
Sourcepub fn retrieve_context_lexical(
&self,
request: ContextRequest,
) -> KimetsuResult<ContextBundle>
pub fn retrieve_context_lexical( &self, request: ContextRequest, ) -> KimetsuResult<ContextBundle>
v1.0.0: lexical (FTS-only) retrieval honoring the full
ContextRequest. Like Self::retrieve_context_with_request
but pins [NoopEmbedder] so NO embedding model is loaded even in
--features embeddings builds. The UserPromptSubmit context-hook
uses this: it runs in a throwaway per-prompt process that cannot
reuse the long-lived MCP server’s warm model cache, so a cold ONNX
load there can blow the host’s 30s hook timeout. Semantic ANN
recall stays with the warm MCP kimetsu_brain_context tool.
Sourcepub fn retrieve_context_with_injected_embedder(
&self,
request: ContextRequest,
embedder: &dyn Embedder,
) -> KimetsuResult<ContextBundle>
pub fn retrieve_context_with_injected_embedder( &self, request: ContextRequest, embedder: &dyn Embedder, ) -> KimetsuResult<ContextBundle>
v1.0.0: read-only retrieval honoring the full ContextRequest but
with a caller-supplied embedder. The warm embedder daemon uses this
to run cosine/ANN retrieval with ONE long-lived model instead of
opening a fresh embedder per request. The lexical-coverage floor is
applied here too (driven from config unless the caller overrode it).
pub fn repo_root(&self) -> &Path
Sourcepub fn user_conn(&self) -> Option<&Connection>
pub fn user_conn(&self) -> Option<&Connection>
v0.4.1: expose the user-brain connection so callers (e.g.
kimetsu brain status) can report counts/paths without
re-opening the file. Returns None when the user brain is
disabled or unresolvable.