Skip to content

fix(search): use effective-time fallback (mentioned_at, occurred_end) for recency scoring - #2197

Merged
nicoloboschi merged 3 commits into
vectorize-io:mainfrom
r266-tech:fix-recency-effective-time-2192
Jun 15, 2026
Merged

nicoloboschi merged 3 commits into
vectorize-io:mainfrom
r266-tech:fix-recency-effective-time-2192

Conversation

@r266-tech

Copy link
Copy Markdown
Contributor

Problem

apply_combined_scoring (reranking.py) derives the recency boost from occurred_start only — when occurred_start is None, recency stays at the neutral 0.5 even if the memory carries a usable mentioned_at / occurred_end. Temporal retrieval already treats effective time as COALESCE(occurred_start, mentioned_at, occurred_end) via _coalesce_date (retrieval.py), so recency scoring is the one place that ignores the fallback.

Memories that intentionally lack occurred_start (conversation facts, ongoing states — mentioned_at set, occurred_start None per retain/types.py) therefore lose correct recency ordering in recall. This is most acute in slim / passthrough (RRFPassthroughCrossEncoder) deployments, where recency is the only signal modulating RRF rank.

Fix

Derive recency from the same effective-time COALESCE order used by _coalesce_date: occurred_start → mentioned_at → occurred_end. The existing naive→UTC normalization and 365-day linear decay are unchanged and now apply to whichever timestamp is selected.

Tests

test_combined_scoring.py: extended _make_result to accept mentioned_at / occurred_end, reworded the no-date test to reflect "no effective time at all → neutral", and added coverage for the mentioned_at-only path, the occurred_end last-fallback, and occurred_start precedence (matching _coalesce_date). The new tests fail on the prior occurred_start-only implementation.

Closes #2192.

Clears verify-generated-files CI: ruff format collapses the recency
effective-time fallback (reranking.py) and a main-drift one-liner in
consolidator.py that both fit the 120-char line length.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align recency scoring with the effective timestamp fallback

2 participants