Skip to main content

Module scoring

Module scoring 

Source
Expand description

Composite memory scoring — ported from the archived internal service (v1 archive).

Provides a fully-tunable scoring pipeline:

  1. ScoringConfig — all knobs, all pub, all serde-friendly for agent sweeps.
  2. calculate_score — multiplicative formula: w_rel × relevance × (1 + w_temp × recency) × (1 + w_imp × salience).
  3. ScoreAdjustment — declarative conditional rules applied after the base formula.
  4. normalize_rrf_scores / normalize_rank_fusion_scores — RRF and raw-cosine normalization.
  5. normalize_min_score — dual-scale input (0.0–1.0 fraction or 0–100 integer).
  6. is_meaningful_query — noise gate before embedding compute.
  7. contains_cjk — CJK routing decision.

Structs§

CandidateContext
Context passed to condition evaluation — properties of the candidate + query.
ScoreAdjustment
A conditional score adjustment: if condition matches, apply operation.
ScoreInput
Input data for calculate_score — groups per-candidate fields to stay within clippy’s 7-argument limit.
ScoringConfig
Complete, fully-tunable scoring configuration for the memory recall pipeline.
ScoringWeights
Weights for the combined memory score (multiplicative model).

Enums§

AdjustmentCondition
A condition that determines whether a score adjustment applies to a candidate.
AdjustmentOp
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 true when >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 true if c is a CJK character (Unified, Extension A/B, Hiragana, Katakana, Hangul).
is_meaningful_query
Returns true if the query has enough semantic content to produce meaningful recall.
normalize_min_score
Normalize min_score from caller-supplied value.
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.