Skip to content

feat(#352): salience + recency dual-axis recall ranking - #387

Merged
ajianaz merged 5 commits into
developfrom
feat/352-salience-recency
Jun 19, 2026
Merged

ajianaz merged 5 commits into
developfrom
feat/352-salience-recency

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Closes #352. See CHANGELOG entry for full details. All tests pass, clippy + fmt clean.

Add two orthogonal, opt-in boost axes for recall: salience (mattering)
and recency (freshness). Both are computed from existing memory fields —
zero LLM.

Core (uteke-core):
  - New salience_recency.rs module:
    - salience_score(): 0..=1 blend of access_count, importance, pinned
    - recency_score(): per-type exponential decay (exp(-age/half_life))
    - type_half_life_days(): Decision/Preference 365d, Fact/Reference 180d,
      Insight 240d, Event 30d, default 90d
    - apply_boosts(): additive fusion of base score + salience + recency
    - SalienceRecencyConfig with sanitized() clamp + is_noop() check
  - Uteke::set_salience_recency_config() for per-query overrides
  - Boosts applied AFTER recall cache lookup so cache stays time-independent

CLI (uteke-cli):
  - --salience / --recency flags on 'recall'
  - [recall] config: salience_weight (0.15), recency_weight (0.15)

Tests (+12 new):
  - salience: zero access, pinned bonus, high access climbs, clamped to 1
  - recency: brand new ~1, decays with age, per-type half-life ordering
  - type_half_life: known types + unknown fallback
  - apply_boosts: noop when weights zero, raises score when active
  - config: sanitized() clamps, is_noop()

Closes #352
@ajianaz ajianaz added this to the v0.2.1 — DX & Ecosystem milestone Jun 18, 2026
@ajianaz ajianaz added enhancement New feature or request scope:core Core engine work scope:cli CLI and UX type:feature New feature priority:medium Fix soon labels Jun 18, 2026
@github-actions

github-actions Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-cli · BYOK · MIT

CodeCora #387: set_salience_recency_config() mutates shared state on
Uteke instance. In server / MCP mode where one Uteke instance serves
multiple requests, a --salience / --recency override would leak into
later recalls that didn't request those flags.

Fix: add Uteke::reset_salience_recency_config() and call it after each
recall_hybrid / recall_related / recall_at_time returns. The CLI recall
command now resets the boost config as soon as the results are fetched,
before any post-processing.
}
};

// #352: dual-axis salience/recency boost. Opt-in per query via
CodeCora #387 noted: the recency formula uses exp(-age_days / half_life),
which yields ~0.37 (1/e) at age_days == half_life. A true half-life
yields 0.5 at that point. The math was intentional (exponential time
constant), but the terminology was wrong.

Fix: rename doc comments to 'time constant (τ)' and clarify that a true
half-life would require multiplying by ln(2) ≈ 0.693. Function names
unchanged for backward compat.
ajianaz added 2 commits June 19, 2026 07:45
CodeCora #387: set_salience_recency_config() was called before the
recall closure, but reset only ran on the success path. Early returns
from parse_from_rfc3339 or '--at and --related' conflict left the boost
config active on the shared Uteke instance.

Fix: wrap recall logic in an IIFE closure that returns Result. The
closure captures all ? early-return paths, then reset runs
unconditionally before unwrapping the result.

Also: CHANGELOG updated to use 'time constant (τ)' instead of
'half-life' for the recency decay formula.
Develop added #349 (memory types) section to CHANGELOG. This branch
adds #352 (salience/recency). Merged both sections in chronological
order.
@ajianaz
ajianaz merged commit dacf248 into develop Jun 19, 2026
8 checks passed
@ajianaz
ajianaz deleted the feat/352-salience-recency branch July 9, 2026 14:28
ajianaz added a commit that referenced this pull request Aug 13, 2026
* feat(#352): salience + recency dual-axis recall ranking

Add two orthogonal, opt-in boost axes for recall: salience (mattering)
and recency (freshness). Both are computed from existing memory fields —
zero LLM.

Core (uteke-core):
  - New salience_recency.rs module:
    - salience_score(): 0..=1 blend of access_count, importance, pinned
    - recency_score(): per-type exponential decay (exp(-age/half_life))
    - type_half_life_days(): Decision/Preference 365d, Fact/Reference 180d,
      Insight 240d, Event 30d, default 90d
    - apply_boosts(): additive fusion of base score + salience + recency
    - SalienceRecencyConfig with sanitized() clamp + is_noop() check
  - Uteke::set_salience_recency_config() for per-query overrides
  - Boosts applied AFTER recall cache lookup so cache stays time-independent

CLI (uteke-cli):
  - --salience / --recency flags on 'recall'
  - [recall] config: salience_weight (0.15), recency_weight (0.15)

Tests (+12 new):
  - salience: zero access, pinned bonus, high access climbs, clamped to 1
  - recency: brand new ~1, decays with age, per-type half-life ordering
  - type_half_life: known types + unknown fallback
  - apply_boosts: noop when weights zero, raises score when active
  - config: sanitized() clamps, is_noop()

Closes #352

* fix(#352): reset salience/recency config after each recall

CodeCora #387: set_salience_recency_config() mutates shared state on
Uteke instance. In server / MCP mode where one Uteke instance serves
multiple requests, a --salience / --recency override would leak into
later recalls that didn't request those flags.

Fix: add Uteke::reset_salience_recency_config() and call it after each
recall_hybrid / recall_related / recall_at_time returns. The CLI recall
command now resets the boost config as soon as the results are fetched,
before any post-processing.

* docs(#352): clarify 'half-life' terminology (it's actually τ)

CodeCora #387 noted: the recency formula uses exp(-age_days / half_life),
which yields ~0.37 (1/e) at age_days == half_life. A true half-life
yields 0.5 at that point. The math was intentional (exponential time
constant), but the terminology was wrong.

Fix: rename doc comments to 'time constant (τ)' and clarify that a true
half-life would require multiplying by ln(2) ≈ 0.693. Function names
unchanged for backward compat.

* fix(#352): prevent boost config leak on recall error paths

CodeCora #387: set_salience_recency_config() was called before the
recall closure, but reset only ran on the success path. Early returns
from parse_from_rfc3339 or '--at and --related' conflict left the boost
config active on the shared Uteke instance.

Fix: wrap recall logic in an IIFE closure that returns Result. The
closure captures all ? early-return paths, then reset runs
unconditionally before unwrapping the result.

Also: CHANGELOG updated to use 'time constant (τ)' instead of
'half-life' for the recency decay formula.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request priority:medium Fix soon scope:cli CLI and UX scope:core Core engine work type:feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: salience + recency dual-axis recall ranking

2 participants