Skip to main content

Module recency

Module recency 

Source
Expand description

Recency scoring for hybrid search based on git commit timestamps

This module provides repository-relative recency scoring for Stage 3 hybrid search. Scores are normalized to [0.0, 1.0] where 1.0 = newest file, 0.0 = oldest file.

§Design Principles

  • Deterministic: Same repo state → same scores (no wall-clock dependency)
  • Relative scoring: Normalized against repo’s own history
  • Local-only: Uses local git history (no network operations, always safe in offline mode)
  • Graceful fallback: Returns neutral 0.5 when git unavailable

§Example

use sqry_core::git::recency::RecencyIndex;
use std::path::Path;

let repo = Path::new("/path/to/repo");
let index = RecencyIndex::from_repo(repo)?;

let score = index.score_for_file(Path::new("src/main.rs"));
println!("Recency score: {score}"); // 0.0 (oldest) to 1.0 (newest)

Structs§

RecencyIndex
Recency index that normalizes file timestamps relative to repository history