use harn_vm::llm::cache_conformance::{
classify_cache_conformance_fixture, CacheVerdict, PromptCacheSupportStatus,
};
const ANTHROPIC_FIXTURE: &str =
include_str!("fixtures/cache_conformance/anthropic_cache_capable.json");
const NO_CACHE_FIXTURE: &str = include_str!("fixtures/cache_conformance/local_no_cache.json");
#[test]
fn anthropic_repeat_run_reads_from_cache() {
let report = classify_cache_conformance_fixture("", "", ANTHROPIC_FIXTURE)
.expect("anthropic fixture classifies");
assert_eq!(
report.support.status,
PromptCacheSupportStatus::CacheSupported
);
assert!(report.support.profile.prompt_caching);
assert!(report.support.profile.min_useful_prefix_tokens.is_some());
assert!(report.support.profile.ttl_notes.is_some());
assert_eq!(
report.support.profile.cache_read_usage_field,
"usage.cache_read_input_tokens"
);
assert_eq!(report.verdict, CacheVerdict::CacheEffective);
assert!(!report.dogfood_failure);
assert_eq!(report.bucket_counts.cache_effective, 1);
let warm = &report.runs[1];
assert_eq!(warm.usage.cache_read_tokens, 3800);
assert_eq!(warm.usage.fresh_input_tokens, 40);
}
#[test]
fn non_cache_route_classifies_unsupported_without_failing_dogfood() {
let report = classify_cache_conformance_fixture("", "", NO_CACHE_FIXTURE)
.expect("no-cache fixture classifies");
assert_eq!(
report.support.status,
PromptCacheSupportStatus::CacheUnsupported
);
assert!(!report.support.profile.prompt_caching);
assert_eq!(report.verdict, CacheVerdict::UnsupportedZero);
assert!(!report.dogfood_failure);
assert_eq!(report.bucket_counts.unsupported_zero, 2);
for run in &report.runs {
assert!(run
.usage
.missing_fields
.contains(&"cache_read_tokens".to_string()));
}
}