feat(AI): 推理闸门双优先级 — 前台插队、后台按 token 让位;暴露统计与后端标签
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
28
康康Tests/InferencePriorityTests.swift
Normal file
28
康康Tests/InferencePriorityTests.swift
Normal file
@@ -0,0 +1,28 @@
|
||||
import Testing
|
||||
@testable import 康康
|
||||
|
||||
struct InferencePriorityTests {
|
||||
|
||||
@Test func interactiveJumpsAheadOfBackground() {
|
||||
let idx = AIRuntime.gateInsertionIndex(of: .interactive,
|
||||
in: [.interactive, .background, .background])
|
||||
#expect(idx == 1)
|
||||
}
|
||||
|
||||
@Test func interactiveKeepsFIFOAmongInteractive() {
|
||||
let idx = AIRuntime.gateInsertionIndex(of: .interactive,
|
||||
in: [.interactive, .interactive])
|
||||
#expect(idx == 2)
|
||||
}
|
||||
|
||||
@Test func backgroundAlwaysAppends() {
|
||||
let idx = AIRuntime.gateInsertionIndex(of: .background,
|
||||
in: [.interactive, .background])
|
||||
#expect(idx == 2)
|
||||
}
|
||||
|
||||
@Test func emptyQueueInsertsAtZero() {
|
||||
#expect(AIRuntime.gateInsertionIndex(of: .interactive, in: []) == 0)
|
||||
#expect(AIRuntime.gateInsertionIndex(of: .background, in: []) == 0)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user