fix(routing): 对齐缓存亲和力硬规则与审计
This commit is contained in:
@@ -13,16 +13,19 @@ func TestAttemptMetricsIncludesCacheAffinityCoefficient(t *testing.T) {
|
||||
PlatformID: "deepseek-platform",
|
||||
PlatformPriority: 100,
|
||||
CacheAffinity: store.RuntimeCandidateCacheAffinity{
|
||||
Key: "conversation:test",
|
||||
RequestCount: 2,
|
||||
CachedInputTokens: 7296,
|
||||
EMAHitRatio: 0.91,
|
||||
LastHitRatio: 0.92,
|
||||
Confidence: 1,
|
||||
Score: 1.74,
|
||||
Boost: 20,
|
||||
AdjustedPriority: 80,
|
||||
Applied: true,
|
||||
Key: "prompt_lcp_v2:test",
|
||||
RequestCount: 2,
|
||||
CachedInputTokens: 7296,
|
||||
EMAHitRatio: 0.91,
|
||||
LastHitRatio: 0.92,
|
||||
Confidence: 1,
|
||||
Score: 1.74,
|
||||
Boost: 20,
|
||||
AdjustedPriority: 80,
|
||||
MatchedPrefixDepth: 4,
|
||||
CandidateCount: 2,
|
||||
OverrideReason: "different_effective_priority_tier",
|
||||
Applied: true,
|
||||
},
|
||||
}, 1, false)
|
||||
|
||||
@@ -35,4 +38,10 @@ func TestAttemptMetricsIncludesCacheAffinityCoefficient(t *testing.T) {
|
||||
if metrics["cacheAffinityHitRatio"] != 0.91 || metrics["cacheAffinityLastHitRatio"] != 0.92 {
|
||||
t.Fatalf("expected hit ratios in attempt metrics, got %+v", metrics)
|
||||
}
|
||||
if metrics["cacheAffinityMatched"] != true ||
|
||||
metrics["cacheAffinityMatchedPrefixDepth"] != 4 ||
|
||||
metrics["cacheAffinityCandidateCount"] != 2 ||
|
||||
metrics["cacheAffinityOverrideReason"] != "different_effective_priority_tier" {
|
||||
t.Fatalf("expected cache affinity routing diagnostics in attempt metrics, got %+v", metrics)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user