Skip to main content

Module context

Module context 

Source
Expand description

Graph-aware AI context assembly with token budgeting.

Pipeline used by crate::Brain::context_for_prompt:

  1. Ranked FTS seeds (crate::query) with stopword-aware query rewrite
  2. Optional CSR k-hop expansion from .brain/graph.mmap (doc seeds preferred)
  3. Score fusion (seed score × edge weight × hop decay) + symbol quality filters
  4. Pack nodes with body excerpts until the approximate character/token budget is exhausted

Token accounting is intentionally simple (chars / 4). It is good enough for agent prompt packing, not for billing-grade tokenizer parity.

Structs§

ContextOptions
Options controlling assemble_context and crate::Brain::context_for_prompt_with.
WorkspaceHit
Multi-workspace ranked hit (workspace path + hit).

Functions§

assemble_context
Assemble a graph-aware context bundle for an agent prompt.
hits_to_nodes
Convert ranked hits to nodes (helper for CLI / adapters).