Expand description
Composite memory scoring — ported from the archived internal service (v1 archive).
Provides a fully-tunable scoring pipeline:
ScoringConfig— all knobs, allpub, all serde-friendly for agent sweeps.calculate_score— multiplicative formula:w_rel × relevance × (1 + w_temp × recency) × (1 + w_imp × salience).ScoreAdjustment— declarative conditional rules applied after the base formula.normalize_rrf_scores/normalize_rank_fusion_scores— RRF and raw-cosine normalization.normalize_min_score— dual-scale input (0.0–1.0 fraction or 0–100 integer).is_meaningful_query— noise gate before embedding compute.contains_cjk— CJK routing decision.
Structs§
- Candidate
Context - Context passed to condition evaluation — properties of the candidate + query.
- Score
Adjustment - A conditional score adjustment: if
conditionmatches, applyoperation. - Score
Input - Input data for
calculate_score— groups per-candidate fields to stay within clippy’s 7-argument limit. - Scoring
Config - Complete, tunable scoring configuration for the memory recall pipeline. DoS caps: max_recall_candidates≤500, default_token_budget≤16000, default_recall_limit≤200.
- Scoring
Weights - Weights for the combined memory score:
score = w_rel × relevance × (1 + w_temp × recency) × (1 + w_imp × salience).
Enums§
- Adjustment
Condition - A condition that determines whether a score adjustment applies to a candidate.
- Adjustment
Op - The operation to apply when a condition matches.
Constants§
- MAX_
RECALL_ CANDIDATES - Maximum candidates a caller may request (server-side cap).
- MAX_
RECALL_ LIMIT - Maximum result limit a caller may request (server-side cap).
- MAX_
TOKEN_ BUDGET - Maximum token budget a caller may request (server-side cap).
Functions§
- calculate_
score - Composite score for a single memory candidate.
- contains_
cjk - Returns
truewhen >15% of the query’s characters are CJK. - default_
adjustments - Default score adjustments: episodic recency bonus, semantic age penalty, entity boost.
- is_
cjk_ char - Returns
trueifcis a CJK character (Unified, Extension A/B, Hiragana, Katakana, Hangul). - is_
meaningful_ query - Returns
trueif the query has enough semantic content for meaningful recall. - normalize_
min_ score - Normalize
min_score: 0–1 passes through, 1–100 divides by 100, others return Err. - normalize_
rank_ fusion_ scores - Normalize raw-cosine or BM25 scores (single-source) into a calibrated relevance band.
- normalize_
rrf_ scores - Normalize RRF-fused scores (dual-source) into a calibrated relevance band.