Skip to content
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
df0aefa
feat(retrieval): add event time-decay ranking
cocolord Sep 20, 2026
2b2fc1b
Merge origin/main and fix time-decay retrieval
cocolord Sep 20, 2026
3deca3e
fix(retrieval): preserve time-decay compatibility
cocolord Sep 20, 2026
71bc58f
fix(retrieval): simplify event time-decay ranking
cocolord Sep 21, 2026
30cf993
Merge remote-tracking branch 'origin/main' into codex/event-time-decay
cocolord Sep 21, 2026
a02abf8
chore: keep main formatting after merge
cocolord Sep 21, 2026
8a1616d
fix(retrieval): keep time decay out of reindex
cocolord Sep 21, 2026
a975dac
Merge remote-tracking branch 'origin/main' into HEAD
cocolord Sep 21, 2026
df38044
fix(retrieval): expose time decay score details
cocolord Sep 21, 2026
2dbbca5
refactor(retrieval): simplify event time decay
cocolord Sep 21, 2026
ac110e4
feat(retrieval): apply event time decay in cloud and find
cocolord Sep 22, 2026
32e98bd
Merge remote-tracking branch 'origin/main' into codex/pr5214-finalize
cocolord Sep 22, 2026
1b5f0c1
fix(retrieval): simplify cloud time-decay routing
cocolord Sep 22, 2026
af88342
Merge remote-tracking branch 'origin/main' into codex/pr5214-finalize
cocolord Sep 22, 2026
f477a90
fix(retrieval): recall event memories by indexed type tags
cocolord Sep 22, 2026
95488a2
fix(retrieval): use nullable protection for multiplicative event decay
cocolord Sep 23, 2026
3237628
test(memory): cover extracted peer event updates
cocolord Sep 23, 2026
43ac1db
fix(search): align event time decay behavior
cocolord Sep 23, 2026
8ae941d
docs(retrieval): document find decay protection
cocolord Sep 23, 2026
791faa0
fix(retrieval): finalize event time decay contract
cocolord Sep 23, 2026
29d6ce6
fix(retrieval): align event decay with tag routing contract
cocolord Sep 24, 2026
48d4486
Merge remote-tracking branch 'origin/main' into codex/pr5214-chat-ali…
cocolord Sep 24, 2026
21971fc
Merge remote-tracking branch 'origin/main' into codex/pr5214-chat-ali…
cocolord Sep 24, 2026
42db2f9
Merge remote-tracking branch 'origin/main' into codex/pr5214-chat-ali…
cocolord Sep 24, 2026
703cef2
fix(retrieval): align extracted tags and account decay routing
cocolord Sep 24, 2026
ac61332
Merge origin/main into event time-decay implementation
cocolord Sep 28, 2026
193beec
fix: rank bounded time-decay candidates inside vector engines
cocolord Sep 28, 2026
9fba4c3
fix(retrieval): align event decay with global reranking
cocolord Sep 29, 2026
097b90e
refactor(retrieval): drop unused event URI classifiers
cocolord Sep 29, 2026
0d3b66c
fix(retrieval): remove stale hotness test and align decay contracts
cocolord Sep 29, 2026
8d77bfb
fix(retrieval): run deferred decay fusion in native engine
cocolord Sep 29, 2026
c9d0afb
Merge remote-tracking branch 'origin/main' into feat/decay-global-ali…
cocolord Sep 29, 2026
0205e74
fix(retrieval): apply event decay during vector recall
cocolord Sep 29, 2026
1e0f129
refactor(retrieval): remove redundant decay plumbing and tests
cocolord Sep 29, 2026
c32534c
test(retrieval): consolidate event time-decay coverage
qin-ctx Sep 29, 2026
8c824d7
refactor(storage): remove redundant search result processing
cocolord Sep 29, 2026
da071d9
refactor(retrieval): leave openGauss decay options unprocessed
cocolord Sep 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/ov_cli/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ impl HttpClient {
context_type: Option<Vec<String>>,
tags: Option<Vec<String>>,
read_content: bool,
events_time_decay_protection: Option<String>,
) -> Result<serde_json::Value> {
let image_url = normalize_image_input(image)?;
let mut body = serde_json::json!({
Expand All @@ -738,6 +739,7 @@ impl HttpClient {
"context_type": context_type,
"tags": tags,
"read_content": read_content.then_some(true),
"events_time_decay_protection": events_time_decay_protection,
});
compact_request_body(&mut body);
self.post("/api/v1/search/find", &body).await
Expand All @@ -758,6 +760,7 @@ impl HttpClient {
context_type: Option<Vec<String>>,
tags: Option<Vec<String>>,
read_content: bool,
events_time_decay_protection: Option<String>,
) -> Result<serde_json::Value> {
let image_url = normalize_image_input(image)?;
let mut body = serde_json::json!({
Expand All @@ -774,6 +777,7 @@ impl HttpClient {
"context_type": context_type,
"tags": tags,
"read_content": read_content.then_some(true),
"events_time_decay_protection": events_time_decay_protection,
});
compact_request_body(&mut body);
self.post("/api/v1/search/search", &body).await
Expand Down
57 changes: 54 additions & 3 deletions crates/ov_cli/src/commands/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ pub async fn find(
context_type: Option<Vec<String>>,
tags: Option<Vec<String>>,
read_content: bool,
events_time_decay_protection: Option<String>,
output_format: OutputFormat,
compact: bool,
) -> Result<()> {
Expand All @@ -147,6 +148,7 @@ pub async fn find(
context_type,
tags,
read_content,
events_time_decay_protection,
)
.await?;
output_search_results(
Expand All @@ -173,6 +175,7 @@ pub async fn search(
context_type: Option<Vec<String>>,
tags: Option<Vec<String>>,
read_content: bool,
events_time_decay_protection: Option<String>,
output_format: OutputFormat,
compact: bool,
) -> Result<()> {
Expand All @@ -191,6 +194,7 @@ pub async fn search(
context_type,
tags,
read_content,
events_time_decay_protection,
)
.await?;
output_search_results(
Expand Down Expand Up @@ -425,7 +429,7 @@ fn render_search_result_card(
metadata.push(theme::value(level).bold().to_string());
}

if let Some(score) = search_result_score(object) {
for score in search_result_scores(object) {
metadata.push(theme::warning(score).bold().to_string());
}
}
Expand Down Expand Up @@ -598,13 +602,40 @@ fn normalize_level_value(level: &str) -> &str {
}

fn search_result_score(object: Option<&serde_json::Map<String, Value>>) -> Option<String> {
let value = object?.get("score")?;
parse_score(object?.get("score")?).map(|score| format!("score {score:.3}"))
}

fn search_result_scores(object: Option<&serde_json::Map<String, Value>>) -> Vec<String> {
let Some(object) = object else {
return Vec::new();
};
if !object.contains_key("origin_score") && !object.contains_key("time_score") {
return search_result_score(Some(object)).into_iter().collect();
}

[
("semantic", object.get("origin_score")),
("time", object.get("time_score")),
("final", object.get("score")),
]
.into_iter()
.map(|(label, value)| {
let value = value
.and_then(parse_score)
.map(|score| format!("{score:.3}"))
.unwrap_or_else(|| "not provided".to_string());
format!("{label} {value}")
})
.collect()
}

fn parse_score(value: &Value) -> Option<f64> {
let score = value.as_f64().or_else(|| {
value
.as_str()
.and_then(|value| value.trim().parse::<f64>().ok())
})?;
Some(format!("score {score:.3}"))
Some(score)
}

fn search_result_uri(object: Option<&serde_json::Map<String, Value>>) -> Option<&str> {
Expand Down Expand Up @@ -921,6 +952,26 @@ mod tests {
assert!(!rendered.contains("context_type uri"));
}

#[test]
fn search_result_cards_explain_time_decay_scores() {
let results = json!([
{
"context_type": "memory",
"uri": "viking://user/default/memories/events/recent.md",
"score": 0.675,
"origin_score": 0.6,
"time_score": 0.9,
"abstract": "Recent event."
}
]);

let rendered = strip_ansi(&render_search_results_for_table(&results).expect("cards"));

assert!(rendered.contains("1. memory · semantic 0.600 · time 0.900 · final 0.675"));
assert!(!rendered.contains("origin_score"));
assert!(!rendered.contains("time_score"));
}

#[test]
fn search_result_cards_wrap_and_truncate_long_mixed_language_abstracts() {
let results = json!([
Expand Down
10 changes: 10 additions & 0 deletions crates/ov_cli/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,7 @@ pub async fn handle_find(
context_type: Option<Vec<String>>,
tags: Option<Vec<String>>,
read_content: bool,
events_time_decay_protection: Option<String>,
ctx: CliContext,
) -> Result<()> {
let query = query.unwrap_or_default();
Expand Down Expand Up @@ -1528,6 +1529,9 @@ pub async fn handle_find(
if read_content {
params.push("--read-content".to_string());
}
if let Some(ref protection) = events_time_decay_protection {
params.push(format!("--events-time-decay-protection {}", protection));
}
params.push(format!("\"{}\"", query));
print_command_echo("ov find", &params.join(" "), ctx.config.echo_command);
let client = ctx.get_client();
Expand All @@ -1545,6 +1549,7 @@ pub async fn handle_find(
context_type,
tags,
read_content,
events_time_decay_protection,
ctx.output_format,
ctx.compact,
)
Expand All @@ -1564,6 +1569,7 @@ pub async fn handle_search(
context_type: Option<Vec<String>>,
tags: Option<Vec<String>>,
read_content: bool,
events_time_decay_protection: Option<String>,
ctx: CliContext,
) -> Result<()> {
let query = query.unwrap_or_default();
Expand Down Expand Up @@ -1601,6 +1607,9 @@ pub async fn handle_search(
if read_content {
params.push("--read-content".to_string());
}
if let Some(ref protection) = events_time_decay_protection {
params.push(format!("--events-time-decay-protection {}", protection));
}
params.push(format!("\"{}\"", query));
print_command_echo("ov search", &params.join(" "), ctx.config.echo_command);
let client = ctx.get_client();
Expand All @@ -1619,6 +1628,7 @@ pub async fn handle_search(
context_type,
tags,
read_content,
events_time_decay_protection,
ctx.output_format,
ctx.compact,
)
Expand Down
97 changes: 97 additions & 0 deletions crates/ov_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,35 @@ use std::{
io::{self, IsTerminal},
};

const MAX_TIME_DECAY_DURATION_DAYS: u128 = 3000 * 365;

fn parse_event_time_decay_protection(value: &str) -> std::result::Result<String, String> {
if value == "0" {
return Ok(value.to_string());
}
let Some((amount, unit)) = value.split_at_checked(value.len().saturating_sub(1)) else {
return Err("must be '0' or a non-negative integer followed by m, h, or d".to_string());
};
if amount.is_empty() || !amount.bytes().all(|byte| byte.is_ascii_digit()) {
return Err("must be '0' or a non-negative integer followed by m, h, or d".to_string());
}
let amount = amount
.parse::<u128>()
.map_err(|_| "exceeds the maximum duration of 1095000d".to_string())?;
let duration_minutes = match unit {
"m" => amount,
"h" => amount.saturating_mul(60),
"d" => amount.saturating_mul(24 * 60),
_ => {
return Err("must be '0' or a non-negative integer followed by m, h, or d".to_string());
}
};
if duration_minutes > MAX_TIME_DECAY_DURATION_DAYS * 24 * 60 {
return Err("exceeds the maximum duration of 1095000d".to_string());
}
Ok(value.to_string())
}

/// CLI context shared across commands
#[derive(Debug, Clone)]
pub struct CliContext {
Expand Down Expand Up @@ -851,6 +880,14 @@ enum Commands {
/// Include the full visible content for every matched URI
#[arg(long, help_heading = "Advanced options")]
read_content: bool,
/// Enable event decay with protection duration: 0 (immediate) or Xm/Xh/Xd
#[arg(
long,
alias = "events_time_decay_protection",
value_parser = parse_event_time_decay_protection,
help_heading = "Advanced options"
)]
events_time_decay_protection: Option<String>,
},
/// [Experimental][Data] Run context-aware retrieval
Search {
Expand Down Expand Up @@ -923,6 +960,14 @@ enum Commands {
/// Include the full visible content for every matched URI
#[arg(long, help_heading = "Advanced options")]
read_content: bool,
/// Enable event decay with protection duration: 0 (immediate) or Xm/Xh/Xd
#[arg(
long,
alias = "events_time_decay_protection",
value_parser = parse_event_time_decay_protection,
help_heading = "Advanced options"
)]
events_time_decay_protection: Option<String>,
},
/// [Data] Run content pattern search
Grep {
Expand Down Expand Up @@ -3767,6 +3812,7 @@ async fn main() {
context_type,
tags,
read_content,
events_time_decay_protection,
} => {
handlers::handle_find(
query,
Expand All @@ -3780,6 +3826,7 @@ async fn main() {
context_type,
tags,
read_content,
events_time_decay_protection,
ctx,
)
.await
Expand All @@ -3797,6 +3844,7 @@ async fn main() {
context_type,
tags,
read_content,
events_time_decay_protection,
} => {
handlers::handle_search(
query,
Expand All @@ -3811,6 +3859,7 @@ async fn main() {
context_type,
tags,
read_content,
events_time_decay_protection,
ctx,
)
.await
Expand Down Expand Up @@ -4054,6 +4103,54 @@ mod tests {
}
}

#[test]
fn cli_search_decay_protection_aliases_reject_duplicates() {
for flag in [
"--events-time-decay-protection",
"--events_time_decay_protection",
] {
let cli = Cli::try_parse_from(["ov", "search", "event", flag, "30m"]).unwrap();
match cli.command {
Commands::Search {
events_time_decay_protection,
..
} => assert_eq!(events_time_decay_protection.as_deref(), Some("30m")),
_ => panic!("expected search command"),
}
}
assert!(
Cli::try_parse_from([
"ov",
"search",
"event",
"--events-time-decay-protection",
"0",
"--events_time_decay_protection",
"30m"
])
.is_err()
);
}

#[test]
fn cli_rejects_invalid_decay_protection_before_sending_requests() {
for command in ["find", "search"] {
for value in ["", "1w", "-1d", "1095001d"] {
assert!(
Cli::try_parse_from([
"ov",
command,
"event",
"--events-time-decay-protection",
value,
])
.is_err(),
"{command} accepted invalid protection {value:?}"
);
}
}
}

#[test]
fn cli_parses_search_image_with_query() {
let cli = Cli::try_parse_from(["ov", "search", "poster", "--image", "viking://x.png"])
Expand Down
Loading
Loading