mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-14 15:03:19 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
|
|
@ -0,0 +1,68 @@
|
|||
import Foundation
|
||||
import Testing
|
||||
@testable import OpenClaw
|
||||
|
||||
@Suite(.serialized)
|
||||
@MainActor
|
||||
struct VoiceWakeOverlayControllerTests {
|
||||
@Test func `overlay controller lifecycle without UI`() async {
|
||||
let controller = VoiceWakeOverlayController(enableUI: false)
|
||||
let token = controller.startSession(
|
||||
source: .wakeWord,
|
||||
transcript: "hello",
|
||||
attributed: nil,
|
||||
forwardEnabled: true,
|
||||
isFinal: false)
|
||||
|
||||
#expect(controller.snapshot().token == token)
|
||||
#expect(controller.snapshot().isVisible == true)
|
||||
|
||||
controller.updatePartial(token: token, transcript: "hello world")
|
||||
#expect(controller.snapshot().text == "hello world")
|
||||
|
||||
controller.updateLevel(token: token, -0.5)
|
||||
#expect(controller.model.level == 0)
|
||||
try? await Task.sleep(nanoseconds: 120_000_000)
|
||||
controller.updateLevel(token: token, 2.0)
|
||||
#expect(controller.model.level == 1)
|
||||
|
||||
controller.dismiss(token: token, reason: .explicit, outcome: .empty)
|
||||
#expect(controller.snapshot().isVisible == false)
|
||||
#expect(controller.snapshot().token == nil)
|
||||
}
|
||||
|
||||
@Test func `evaluate token drops mismatch and no active`() {
|
||||
let active = UUID()
|
||||
#expect(VoiceWakeOverlayController.evaluateToken(active: nil, incoming: active) == .dropNoActive)
|
||||
#expect(VoiceWakeOverlayController.evaluateToken(active: active, incoming: UUID()) == .dropMismatch)
|
||||
#expect(VoiceWakeOverlayController.evaluateToken(active: active, incoming: active) == .accept)
|
||||
#expect(VoiceWakeOverlayController.evaluateToken(active: active, incoming: nil) == .accept)
|
||||
}
|
||||
|
||||
@Test func `update level throttles rapid changes`() async {
|
||||
let controller = VoiceWakeOverlayController(enableUI: false)
|
||||
let token = controller.startSession(
|
||||
source: .wakeWord,
|
||||
transcript: "level test",
|
||||
attributed: nil,
|
||||
forwardEnabled: false,
|
||||
isFinal: false)
|
||||
|
||||
controller.updateLevel(token: token, 0.25)
|
||||
let first = controller.model.level
|
||||
|
||||
controller.updateLevel(token: token, 0.9)
|
||||
#expect(controller.model.level == first)
|
||||
|
||||
controller.updateLevel(token: token, 0)
|
||||
#expect(controller.model.level == 0)
|
||||
|
||||
try? await Task.sleep(nanoseconds: 120_000_000)
|
||||
controller.updateLevel(token: token, 0.9)
|
||||
#expect(controller.model.level == 0.9)
|
||||
}
|
||||
|
||||
@Test func `overlay controller exercises helpers`() async {
|
||||
await VoiceWakeOverlayController.exerciseForTesting()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue