feat(AI): 推理闸门双优先级 — 前台插队、后台按 token 让位;暴露统计与后端标签

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
link2026
2026-06-10 06:42:59 +08:00
parent 070e016f81
commit 8494e51823
2 changed files with 102 additions and 9 deletions

View 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)
}
}