Skip to main content

BrokerSection

Struct BrokerSection 

Source
pub struct BrokerSection {
Show 18 fields pub default_budget_tokens: u32, pub weights: BrokerWeights, pub max_capsules: usize, pub min_semantic_score: f32, pub min_lexical_coverage: f32, pub fusion: String, pub normalization: String, pub abstain_min_score: f32, pub rerank_min_score: f32, pub explicit_fact_guard: bool, pub budget_floor_tokens: u32, pub budget_run_cap_tokens: u32, pub ambient: bool, pub compress_capsules: bool, pub session_dedupe: bool, pub warm_start: bool, pub answer_grade_min_score: f32, pub proactive_prefetch: bool,
}

Fields§

§default_budget_tokens: u32

Flat per-stage budget (tokens). Used as a fallback when task_size == 0 (broker disabled or task-size signal unavailable) and as the compat default for pre-F3 project.toml files. For live runs the adaptive budget (adaptive_budget) supersedes this.

§weights: BrokerWeights§max_capsules: usize

D1f: hard cap on capsules rendered into a model prompt. The broker may surface more capsules than this (up to the token budget), but the pipeline render step truncates to this cap so a tighter, higher-precision capsule set isn’t silently padded back to a larger number. 0 = disabled (budget-only limit).

Default 8: lower than the old hard-coded 12 so precision from D1e wins; operators can raise it per-project in project.toml. #[serde(default)] keeps pre-D1f project.toml files loading.

§min_semantic_score: f32

D1e: absolute minimum cosine similarity between the query embedding and a candidate embedding required for the candidate to survive budgeting. When > 0.0, candidates whose cosine is strictly below this threshold are dropped BEFORE the MMR pass so a genuinely-irrelevant corpus hits the zero-capsule skipped path more often. Inert on lean (NoopEmbedder) builds because there is no query embedding to compare against.

Default -1.0 = AUTO (v1.0.0): the right floor is MODEL-DEPENDENT, because cosine scales differ per embedder. bge-family cosines for related pairs sit well above ~0.5 with noise below ~0.4, so auto resolves to 0.35 there. jina-v2 cosines run lower — the remote benchmark showed a 0.35 floor KILLING relevant results outright (MRR 0.90 → 0.77, recall@2 == recall@4) — and that model’s own precision already keeps noise low (~1.2 vs bge’s ~4.0 capsules on no-answer queries, floors off), so auto resolves to 0.0 (disabled) for non-bge models. Set an explicit value to override auto in either direction; 0.0 disables. #[serde(default = …)] keeps older configs loading with auto.

§min_lexical_coverage: f32

v1.0.0: absolute lexical relevance floor for memory candidates, expressed as the fraction of the query’s IDF-weighted discriminating power a memory must lexically cover to survive. Unlike min_semantic_score (which needs a query embedding and is therefore inert on the FTS-only UserPromptSubmit hook path), this floor works on lexical retrieval — closing the gap where a broad conceptual query (“what’s the idea of the repo”) surfaces unrelated memories that only share a corpus-ubiquitous token like the project name.

Mechanics: query tokens are stripped of stopwords; each remaining token is IDF-weighted over the memory corpus (so the project name, present in nearly every memory, contributes ~0). A memory is dropped when the IDF-weighted share of the query it covers is below this floor AND it has no semantic support. Repo-file/manifest capsules pass through untouched (their FTS match on file content is itself the relevance signal, and overview queries want the README).

Default 0.5 = “must cover the more-discriminating half of the query.” 0.0 disables the floor. #[serde(default = …)] keeps older configs loading with the floor active.

§fusion: String

v2.6: how the broker merges candidate lists from different retrieval strategies (lexical FTS, semantic ANN, graph traversal).

  • "linear" (default) — union the lists, keeping each memory’s best raw_relevance, itself a linear blend of BM25 and cosine at α = 0.5. Kimetsu’s behaviour through v2.5.
  • "rrf" — reciprocal rank fusion. Uses only each candidate’s rank in each list, so the fact that BM25 is unbounded and corpus-dependent while cosine is bounded and tightly clustered stops mattering, and a memory both lists rank highly beats one a single list loves.

Defaults to linear because the house rule is that every claim ships with a measurement, and “RRF is the 2026 default” is not one for this corpus. kimetsu brain tune sweeps both against your own query history. Unknown values fall back to linear.

§normalization: String

v2.6: how a candidate’s raw relevance is normalized into the relevance term of the composite score.

  • "per_kind" (default) — normalize within each capsule kind, so the best memory and the best repo_file each land at relevance = 1.0 however good either is. Kimetsu’s behaviour through v2.5.
  • "global" — one max across every candidate, so relevance means the same thing across kinds and the best of an irrelevant kind stays low.

Per-kind normalization is the reason the lexical and semantic floors have to exist: they prune weak candidates before normalization can flatter them to 1.0. Global is the more principled rule, and it is still not the default, because a ranking change ships with a measurement on a corpus and not with an argument. Unknown values fall back to per_kind.

§abstain_min_score: f32

Abstention floor for the whole retrieval, on the ABSOLUTE evidence scale (v2.7): the best raw query-cosine any memory candidate achieved. When set above zero and no cosine-backed memory candidate clears it — and the bundle would contain only memory capsules — the context bundle comes back empty (skipped) so the reader abstains instead of answering from weak matches. Lean builds and cross-model rows have no comparable cosine verdict and are exempt rather than judged on a lexical scale.

History: v2.5 introduced this as a floor on the NORMALIZED composite, which could never fire — normalization hands the top candidate relevance 1.0, putting the composite’s floor at ~0.57 regardless of match quality (the workflow benchmark measured false-injection 1.00 at a 60-memory corpus). The evidence scale is corpus-size-independent. For jina-v2/bge-family embedders, genuinely-relevant matches typically sit at raw cosine 0.6+, unrelated dev text at 0.35-0.55. 0.0 disables; -1.0 = per-model AUTO (0.55 for jina-v2 — swept on the workflow benchmark — and bge provisionally; off for uncalibrated families, the same rule as min_semantic_score). The band one width below the floor is arbitrated by the cross-encoder where one is available. KIMETSU_ABSTAIN_EVIDENCE overrides at retrieval time (sweeps). #[serde(default = …)] keeps older project.toml files loading unchanged (off).

§rerank_min_score: f32

Final cross-encoder admission floor. Scores are model-specific, not calibrated probabilities. Zero disables this floor (not cosine gating).

§explicit_fact_guard: bool

Require visible value evidence for recognized explicit configuration questions. Experimental, opt-in English/Spanish rules; not a general entailment check. Unsupported wording retains normal retrieval.

§budget_floor_tokens: u32

F3: floor for the adaptive per-stage brain budget. Small tasks receive at least this many tokens so the brain is never starved. #[serde(default)] keeps pre-F3 project.toml files loading cleanly.

§budget_run_cap_tokens: u32

F3: per-run global ceiling on brain-injected tokens across ALL stages combined. Later stages receive only the remaining capacity once earlier stages have been charged via the RunRecallLedger. #[serde(default)] keeps pre-F3 project.toml files loading cleanly.

§ambient: bool

W3.2: persistent ambient-context off-switch. When false, the workspace fingerprint (branch, recent files, dirty status) is not collected or appended to the retrieval query. Precedence: KIMETSU_BRAIN_AMBIENT env override > this field > default (true). #[serde(default = "default_true")] keeps pre-W3 project.toml files loading unchanged.

§compress_capsules: bool

v1.5 (Story 2.1): render-time capsule compression. When true (default), capsule summaries are compressed with [compress_for_render] before being injected into hook stdout or MCP tool responses. Compression strips [tags: ...] / (context: ...) annotations and caps at 3 sentences. Ranking is NEVER affected — compression runs only after retrieval and reranking. Set false to inject full memory text (useful for debugging or when summaries are already concise).

#[serde(default = "default_true")] keeps pre-v1.5 project.toml files loading cleanly (they get compression ON).

§session_dedupe: bool

v1.5 (Story 2.3): session-scoped cross-turn capsule dedupe. When true (default), the UserPromptSubmit context hook skips capsules whose expansion_handle was already injected earlier in the same session (tracked via the proactive-state sidecar). A soft policy: skipping only happens when at least one NEW capsule remains — if dedupe would empty the injection entirely, all capsules are injected anyway (a repeated top memory may still be the right context). Set false to disable session dedupe and always inject the full ranked set.

#[serde(default = "default_true")] keeps pre-v1.5 project.toml files loading cleanly (they get session dedupe ON).

§warm_start: bool

Flagship 1 / Pass B: inject the repo digest + work-resume context at SessionStart. When true (default), kimetsu brain session-start-hook prints additionalContext JSON combining the ~400-token repo digest (1.1) and the episodic resume (Pass A). Set false to suppress the warm-start injection entirely — useful when the host already provides repo context or the digest is not yet built.

#[serde(default = "default_true")] keeps pre-Flagship-1 project.toml files loading cleanly (they get warm_start ON — the feature is additive and defaults to enabled so fresh installs get it immediately).

§answer_grade_min_score: f32

Flagship 3 / Pass B (3.3): minimum composite broker score for a capsule to receive the “Verified answer from project memory:” prefix at render time. This prefix signals to the model that it can act in one turn rather than re-verifying the information.

STRICTLY ADDITIVE: only changes the rendered prefix of an already-top capsule. Ranking, floors, and capsule selection are NEVER affected.

The threshold is deliberately conservative (0.92 default) so the marker is rare and only fires on genuinely unambiguous matches. Tune with kimetsu brain bench data (Epic S2) before lowering. Set to 1.1 (above the maximum achievable score) to disable entirely, or 0.0 to always mark any top capsule (not recommended — wait for regret data first).

Regret guard: if the capsule’s memory was recently dropped by floors in another retrieval context (appears in the dropped sidecar), the prefix is suppressed regardless of this threshold, preventing overconfident labelling of inconsistently-scored memories.

#[serde(default = …)] keeps all pre-F3 project.toml files loading unchanged (they get the conservative default).

§proactive_prefetch: bool

Flagship 3 / Pass B (3.5): opt-in proactive pre-fetch at PreToolUse.

When true, the PreToolUse hook does a LIGHTWEIGHT relevance warm based on the current tool’s file path (in addition to the command text), surfacing a relevant memory before the agent edits or reads a file. The existing floors (min_score, max_capsules, session dedupe, refractory throttle) all apply — this is additive only.

Default false (OFF): the PreToolUse hook behaviour is identical to before this flag existed.

v2.6: graduating to default-on has always been stated to depend on evidence that file-path-augmented queries do not increase noise — and nothing was recording which hook surface an injection came from, so that evidence could not accumulate and the flag could not graduate on any timescale. Injections now carry their surface (inject_policy::Surface), and kimetsu brain policy reports acceptance per surface, so the prefetch surface can be compared against the ones that react to something observed rather than predicted. The default stays off until that comparison is made on a real brain; the point of this change is that it is now makeable. Enable per-project in project.toml meanwhile.

#[serde(default)] keeps all pre-F3 project.toml files loading with the feature OFF (zero behaviour change for existing users).

Trait Implementations§

Source§

impl Clone for BrokerSection

Source§

fn clone(&self) -> BrokerSection

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BrokerSection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BrokerSection

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for BrokerSection

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for BrokerSection

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V