mirror of
https://github.com/openai/codex.git
synced 2026-11-13 06:45:07 +00:00
## What changed - Track the 50 most recently invoked skills for each thread and evaluate them as the `lru_v1` shadow-selection method. - Filter stale and duplicate entries while preserving recency order. - Increase the shadow result limit to 50 and add a `21_50` rank bucket. ## Testing - Add unit coverage for recency refresh, eviction, filtering, limits, and rank buckets. - Add an extension test showing that `lru_v1` recovers a skill invoked on an earlier turn. GitOrigin-RevId: 7aa56514db57cf180cc3f57b4d493dee3304e766
28 lines
859 B
Rust
28 lines
859 B
Rust
use pretty_assertions::assert_eq;
|
|
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn recent_invocations_refresh_recency_and_evict_old_skills() {
|
|
let history = RecentSkillInvocations::default();
|
|
for index in 0..=MAX_SHADOW_RESULTS {
|
|
history.record(format!("skill-{index}"));
|
|
}
|
|
history.record("skill-1".to_string());
|
|
|
|
let recent = history.snapshot();
|
|
|
|
assert_eq!(MAX_SHADOW_RESULTS, recent.len());
|
|
assert_eq!(Some("skill-1"), recent.first().map(String::as_str));
|
|
assert_eq!(Some("skill-2"), recent.last().map(String::as_str));
|
|
assert!(!recent.iter().any(|skill| skill == "skill-0"));
|
|
}
|
|
|
|
#[test]
|
|
fn rank_buckets_distinguish_results_above_twenty() {
|
|
assert_eq!("11_20", rank_bucket(Some(20)));
|
|
assert_eq!("21_50", rank_bucket(Some(21)));
|
|
assert_eq!("21_50", rank_bucket(Some(50)));
|
|
assert_eq!("miss", rank_bucket(Some(51)));
|
|
}
|