pub struct Situation<'a> {
pub query: Option<&'a str>,
pub last_error: Option<&'a str>,
pub recent_actions: &'a [String],
pub stage: Option<&'a str>,
pub file_context: Option<&'a str>,
}Expand description
The signal bundle that drives intuition. Borrowed and Default-able.
Fields§
§query: Option<&'a str>Explicit question. May be empty/absent for ambient appraisal.
last_error: Option<&'a str>Current or most-recent error text.
recent_actions: &'a [String]The last few actions taken (commands, edits, steps).
stage: Option<&'a str>Task stage (e.g. “merge”, “implement”, “review”).
file_context: Option<&'a str>File type / path summary in scope (e.g. “src/foo.tsx”).
Implementations§
Source§impl<'a> Situation<'a>
impl<'a> Situation<'a>
Sourcepub fn from_query(query: &'a str) -> Self
pub fn from_query(query: &'a str) -> Self
Construct from a bare query — the legacy code path. Used by recall to keep
existing callers’ behaviour identical (degrades to normalize_query).
Sourcepub fn embed_text(&self) -> String
pub fn embed_text(&self) -> String
Resonance path. Join the rich situation into one embed string. Labelled segments keep the embedder from blurring distinct signals together; empty fields are dropped.
A query-only situation returns the query verbatim, so the embedding is byte-identical
to the legacy embed_both(query) path (zero regression for recall).
Sourcepub fn context_key(&self, coarse_keys: &str) -> String
pub fn context_key(&self, coarse_keys: &str) -> String
Calibration path. Hash the coarse signature into a stable context_key.
coarse_keys selects which dimensions enter the signature (default
stage,error_class,file_type). A query-only situation degrades to the legacy
content_hash(normalize_query(query)) so read/write buckets match historical data.
Sourcepub fn coarse_signature(&self, coarse_keys: &str) -> String
pub fn coarse_signature(&self, coarse_keys: &str) -> String
Build the coarse signature string, e.g. stage=merge|err=TypeError|file=tsx.
Only the dimensions named in coarse_keys are included, in a fixed order, so the
key is stable across runs. Never includes raw error text — only the error class.