Fix Liam waiting rotation and capability ready acknowledgement
This commit is contained in:
@@ -209,10 +209,49 @@ class VoiceSession(
|
|||||||
)
|
)
|
||||||
|
|
||||||
init { waitingPlayer?.waitingListener(::offerPose) }
|
init { waitingPlayer?.waitingListener(::offerPose) }
|
||||||
private fun waitingSafe()=isActive() && hasTurn && blockedTurn!=currentTurn && !poseActive && !actions.active && !presenceSpeech &&
|
private enum class WaitingBlock {
|
||||||
presenceRequest==null && state.phase==VoicePhase.LISTENING && capturing && !state.microphoneMuted &&
|
DISABLED, RELEASED, BACKGROUND, DISCONNECTED, VOICE_INACTIVE, NO_TURN, BLOCKED_TURN,
|
||||||
preparedPlaybackTurn?.let { drainedTurn!=it }!=true && talkPreparing==null &&
|
POSE_OWNER, ACTION_OWNER, USER_SPEAKING, PRESENCE_REQUEST, NOT_LISTENING, MUTED,
|
||||||
SystemClock.elapsedRealtime()-lastSpeechAt>=800
|
CAPTURE_INACTIVE, PLAYBACK_PENDING, TALK_PREPARING, QUIET_WINDOW, READY
|
||||||
|
}
|
||||||
|
private var waitingLogged: WaitingBlock?=null
|
||||||
|
private var waitingLoggedAt=Long.MIN_VALUE
|
||||||
|
private fun waitingBlock(): WaitingBlock = when {
|
||||||
|
waitingPlayer?.waitingContract!=true -> WaitingBlock.DISABLED
|
||||||
|
released -> WaitingBlock.RELEASED
|
||||||
|
!foreground -> WaitingBlock.BACKGROUND
|
||||||
|
state.connection!=ConnectionStatus.CONNECTED -> WaitingBlock.DISCONNECTED
|
||||||
|
!state.voiceActive -> WaitingBlock.VOICE_INACTIVE
|
||||||
|
!hasTurn -> WaitingBlock.NO_TURN
|
||||||
|
blockedTurn==currentTurn -> WaitingBlock.BLOCKED_TURN
|
||||||
|
poseActive -> WaitingBlock.POSE_OWNER
|
||||||
|
actions.active -> WaitingBlock.ACTION_OWNER
|
||||||
|
presenceSpeech -> WaitingBlock.USER_SPEAKING
|
||||||
|
presenceRequest!=null -> WaitingBlock.PRESENCE_REQUEST
|
||||||
|
state.phase!=VoicePhase.LISTENING -> WaitingBlock.NOT_LISTENING
|
||||||
|
state.microphoneMuted -> WaitingBlock.MUTED
|
||||||
|
!capturing -> WaitingBlock.CAPTURE_INACTIVE
|
||||||
|
preparedPlaybackTurn?.let { drainedTurn!=it }==true -> WaitingBlock.PLAYBACK_PENDING
|
||||||
|
talkPreparing!=null -> WaitingBlock.TALK_PREPARING
|
||||||
|
SystemClock.elapsedRealtime()-lastSpeechAt<800 -> WaitingBlock.QUIET_WINDOW
|
||||||
|
else -> WaitingBlock.READY
|
||||||
|
}
|
||||||
|
private fun waitingSafe()=waitingBlock()==WaitingBlock.READY
|
||||||
|
private fun refreshWaitingEligibility() {
|
||||||
|
val block=waitingBlock();waitingPlayer?.waitingEligible(block==WaitingBlock.READY)
|
||||||
|
if(waitingPlayer?.waitingContract!=true) return
|
||||||
|
val now=SystemClock.elapsedRealtime()
|
||||||
|
if(block!=waitingLogged || now-waitingLoggedAt>=10_000) {
|
||||||
|
waitingLogged=block;waitingLoggedAt=now
|
||||||
|
val message="enabled=true eligible=${block==WaitingBlock.READY} block=${block.name.lowercase()} turn=$currentTurn has_turn=$hasTurn phase=${state.phase.name.lowercase()} capture=$capturing capture_frame=${state.captureActive} muted=${state.microphoneMuted} quiet_ms=${(now-lastSpeechAt).coerceIn(0,600_000)}"
|
||||||
|
com.gorios.lanvoice.diag.DiagnosticLog.record("waiting_gate",message)
|
||||||
|
Log.i("LanVoiceWaiting",message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private fun waitingDiagnostic(message: String) {
|
||||||
|
diagnostic(message)
|
||||||
|
Log.i("LanVoiceWaiting",message)
|
||||||
|
}
|
||||||
|
|
||||||
private fun offerPose(pose: WaitingPose) {
|
private fun offerPose(pose: WaitingPose) {
|
||||||
if(!waitingSafe()) { waitingPlayer?.cancelWaitingPose {};return }
|
if(!waitingSafe()) { waitingPlayer?.cancelWaitingPose {};return }
|
||||||
@@ -221,19 +260,19 @@ class VoiceSession(
|
|||||||
cancelPresence(reset=true);captureEpoch++;capturing=false
|
cancelPresence(reset=true);captureEpoch++;capturing=false
|
||||||
playback.interrupt()
|
playback.interrupt()
|
||||||
update(state.copy(waitingPoseActive=true,captureActive=false,playbackActivity=null,playbackRunning=false))
|
update(state.copy(waitingPoseActive=true,captureActive=false,playbackActivity=null,playbackRunning=false))
|
||||||
diagnostic("waiting state=capture_stop_pending pose=${pose.id} epoch=$token")
|
waitingDiagnostic("waiting state=capture_stop_pending pose=${pose.id} epoch=$token")
|
||||||
poseTimeout=Runnable { if(token==poseEpoch && poseActive) stopVoice(cancelReason="pose_capture_timeout") }
|
poseTimeout=Runnable { if(token==poseEpoch && poseActive) stopVoice(cancelReason="pose_capture_timeout") }
|
||||||
.also { main.postDelayed(it,5_000) }
|
.also { main.postDelayed(it,5_000) }
|
||||||
capture.stopAndConfirm { stopped -> main.post {
|
capture.stopAndConfirm { stopped -> main.post {
|
||||||
if(token!=poseEpoch || !poseActive || !isActive()) return@post
|
if(token!=poseEpoch || !poseActive || !isActive()) return@post
|
||||||
poseTimeout?.let { main.removeCallbacks(it) };poseTimeout=null
|
poseTimeout?.let { main.removeCallbacks(it) };poseTimeout=null
|
||||||
diagnostic("waiting state=${if(stopped) "capture_stopped" else "capture_failed"} pose=${pose.id} epoch=$token")
|
waitingDiagnostic("waiting state=${if(stopped) "capture_stopped" else "capture_failed"} pose=${pose.id} epoch=$token")
|
||||||
if(!stopped) { stopVoice(cancelReason="pose_capture_failed");return@post }
|
if(!stopped) { stopVoice(cancelReason="pose_capture_failed");return@post }
|
||||||
waitingPlayer?.playWaitingPose(pose,{ main.post {
|
waitingPlayer?.playWaitingPose(pose,{ main.post {
|
||||||
if(token==poseEpoch && poseActive && isActive()) {
|
if(token==poseEpoch && poseActive && isActive()) {
|
||||||
poseEpoch++;poseActive=false
|
poseEpoch++;poseActive=false
|
||||||
update(state.copy(waitingPoseActive=false))
|
update(state.copy(waitingPoseActive=false))
|
||||||
diagnostic("waiting state=restored_idle pose=${pose.id} epoch=$token")
|
waitingDiagnostic("waiting state=restored_idle pose=${pose.id} epoch=$token")
|
||||||
if(dialogue.listen(true)) { update(state.copy(phase=VoicePhase.LISTENING));startCapture() }
|
if(dialogue.listen(true)) { update(state.copy(phase=VoicePhase.LISTENING));startCapture() }
|
||||||
else stopVoice(cancelReason="pose_resume_failed")
|
else stopVoice(cancelReason="pose_resume_failed")
|
||||||
}
|
}
|
||||||
@@ -517,7 +556,7 @@ class VoiceSession(
|
|||||||
if (clearObservation) faceCue = FaceCueObservation()
|
if (clearObservation) faceCue = FaceCueObservation()
|
||||||
}
|
}
|
||||||
|
|
||||||
val runtimeProtocolState: String get() = "hello=${dialogue.actionNegotiation} connection=${state.connection.name.lowercase()} turn=$currentTurn drained=$drainedTurn action=${actions.active} capture=$capturing capture_epoch=$captureEpoch presence=$presenceEnabled/$presenceCamera/$presenceSupported/${presenceRequest?.kind?.wire ?: "none"}"
|
val runtimeProtocolState: String get() = "hello=${dialogue.actionNegotiation} connection=${state.connection.name.lowercase()} turn=$currentTurn drained=$drainedTurn action=${actions.active} capture=$capturing capture_epoch=$captureEpoch presence=$presenceEnabled/$presenceCamera/$presenceSupported/${presenceRequest?.kind?.wire ?: "none"} waiting_enabled=${waitingPlayer?.waitingContract==true} waiting_block=${waitingBlock().name.lowercase()}"
|
||||||
fun faceDiagnosticsSnapshot() = faceDiagnostics.snapshot()
|
fun faceDiagnosticsSnapshot() = faceDiagnostics.snapshot()
|
||||||
|
|
||||||
private fun sendFaceContext() {
|
private fun sendFaceContext() {
|
||||||
@@ -592,7 +631,7 @@ class VoiceSession(
|
|||||||
onFrame = { pcm ->
|
onFrame = { pcm ->
|
||||||
main.post {
|
main.post {
|
||||||
if (epoch == captureEpoch && captureTurn == currentTurn && capturing && isActive() && !poseActive) {
|
if (epoch == captureEpoch && captureTurn == currentTurn && capturing && isActive() && !poseActive) {
|
||||||
waitingPlayer?.waitingEligible(waitingSafe())
|
refreshWaitingEligibility()
|
||||||
// First real recorder frame, rather than a listen command or permission.
|
// First real recorder frame, rather than a listen command or permission.
|
||||||
if(!state.captureActive) update(state.copy(captureActive = true))
|
if(!state.captureActive) update(state.copy(captureActive = true))
|
||||||
if (dialogue.sendAudio(pcm, captureTurn, sequence)) {
|
if (dialogue.sendAudio(pcm, captureTurn, sequence)) {
|
||||||
@@ -898,7 +937,7 @@ class VoiceSession(
|
|||||||
val changed = state.replyEmotion != next.replyEmotion
|
val changed = state.replyEmotion != next.replyEmotion
|
||||||
state = next
|
state = next
|
||||||
onState(next)
|
onState(next)
|
||||||
waitingPlayer?.waitingEligible(waitingSafe())
|
refreshWaitingEligibility()
|
||||||
if (changed) emotionObserver.onReplyEmotion(next.replyEmotion)
|
if (changed) emotionObserver.onReplyEmotion(next.replyEmotion)
|
||||||
}
|
}
|
||||||
private fun checkMainThread() {
|
private fun checkMainThread() {
|
||||||
|
|||||||
@@ -32,6 +32,17 @@ class ConversationMediaDriver(private val index: EmotionActionIndex,
|
|||||||
override val waitingContract get()=index.waiting!=null
|
override val waitingContract get()=index.waiting!=null
|
||||||
private var offerWaiting: (WaitingPose)->Unit={}
|
private var offerWaiting: (WaitingPose)->Unit={}
|
||||||
private var waitingEnabled=false
|
private var waitingEnabled=false
|
||||||
|
private var waitingChoiceKind="none"
|
||||||
|
private var waitingChoiceId="none"
|
||||||
|
// Derive only existing neutral packages with reviewed own-mouth routes both ways.
|
||||||
|
// The index/pin and all media bytes remain unchanged.
|
||||||
|
private val waitingIdlePackages=index.waiting?.let { config ->
|
||||||
|
listOf(config.idlePackage)+index.visuals.filter { p ->
|
||||||
|
p.id!=config.idlePackage && p.emotion==com.gorios.lanvoice.dialogue.RoleEmotion.NEUTRAL && p.approvedEdges &&
|
||||||
|
index.edges.any { it.from==config.idlePackage && it.to==p.id && it.mouthRuntime!=null } &&
|
||||||
|
index.edges.any { it.from==p.id && it.to==config.idlePackage && it.mouthRuntime!=null }
|
||||||
|
}.map { it.id }
|
||||||
|
}.orEmpty()
|
||||||
private var queuedPose: WaitingPose?=null
|
private var queuedPose: WaitingPose?=null
|
||||||
private var heldPose: WaitingPose?=null
|
private var heldPose: WaitingPose?=null
|
||||||
private var pose: WaitingPose?=null
|
private var pose: WaitingPose?=null
|
||||||
@@ -120,8 +131,8 @@ class ConversationMediaDriver(private val index: EmotionActionIndex,
|
|||||||
private var musicPresented=false
|
private var musicPresented=false
|
||||||
private var ignoredCallbacks=0L
|
private var ignoredCallbacks=0L
|
||||||
/** Fixed metadata only; frames are sampled in reports, never logged per callback. */
|
/** Fixed metadata only; frames are sampled in reports, never logged per callback. */
|
||||||
val diagnosticState: String get() = "owner=${layerOwner.name.lowercase()} turn=$turn seq=$seq gen=$generation epoch=$musicEpoch requested=${selection?.selectedEmotion?.wire ?: "unset"} selected=$selectedId visual=${currentPackageId ?: "none"} edge=${edge?.id ?: "none"} idle_goal=${idleTarget ?: "none"} cycles=$idleCycles/$idleCycleGoal talk=$talk pose=${pose?.id ?: heldPose?.id ?: "none"} pose_stage=${if(poseReturning) "restoring" else if(poseStarted) "playing" else if(pose!=null) "preparing" else if(heldPose!=null) "capture_barrier" else "none"} speech_gate=$speechRequested action=${when { returning -> "returning";musicPresented -> "presented";actionStarted -> "await_frame";action!=null -> "routing";else -> "none" }} ignored=$ignoredCallbacks frame=${visible?.key?.index ?: -1} loop=${visible?.key?.loopOrdinal ?: -1} pts=${visible?.key?.ptsUs ?: -1}"
|
val diagnosticState: String get() = "owner=${layerOwner.name.lowercase()} turn=$turn seq=$seq gen=$generation epoch=$musicEpoch requested=${selection?.selectedEmotion?.wire ?: "unset"} selected=$selectedId visual=${currentPackageId ?: "none"} edge=${edge?.id ?: "none"} idle_goal=${idleTarget ?: "none"} cycles=$idleCycles/$idleCycleGoal talk=$talk pose=${pose?.id ?: heldPose?.id ?: "none"} pose_stage=${if(poseReturning) "restoring" else if(poseStarted) "playing" else if(pose!=null) "preparing" else if(heldPose!=null) "capture_barrier" else "none"} speech_gate=$speechRequested action=${when { returning -> "returning";musicPresented -> "presented";actionStarted -> "await_frame";action!=null -> "routing";else -> "none" }} waiting_policy=${index.waiting!=null} waiting_enabled=$waitingEnabled choice_kind=$waitingChoiceKind choice_id=$waitingChoiceId ignored=$ignoredCallbacks frame=${visible?.key?.index ?: -1} loop=${visible?.key?.loopOrdinal ?: -1} pts=${visible?.key?.ptsUs ?: -1}"
|
||||||
val diagnosticSignature: String get() = "$layerOwner/$turn/$seq/$generation/$selectedId/${visible?.packageId}/${edge?.id}/$idleTarget/$talk/$actionStarted/$returning/$musicPresented/$active/${pose?.id}/$poseReturning/$speechRequested"
|
val diagnosticSignature: String get() = "$layerOwner/$turn/$seq/$generation/$selectedId/${visible?.packageId}/${edge?.id}/$idleTarget/$talk/$actionStarted/$returning/$musicPresented/$active/${pose?.id}/$poseReturning/$speechRequested/$waitingEnabled/$waitingChoiceKind/$waitingChoiceId"
|
||||||
private var musicEpoch=0L
|
private var musicEpoch=0L
|
||||||
private var closing=0
|
private var closing=0
|
||||||
private val releaseWaiters=mutableListOf<()->Unit>()
|
private val releaseWaiters=mutableListOf<()->Unit>()
|
||||||
@@ -230,14 +241,25 @@ class ConversationMediaDriver(private val index: EmotionActionIndex,
|
|||||||
private fun chooseIdleAtLoopEnd(slot: Slot,key: BodyFrameKey,previous: BodyFrameKey?) {
|
private fun chooseIdleAtLoopEnd(slot: Slot,key: BodyFrameKey,previous: BodyFrameKey?) {
|
||||||
if(index.waiting!=null) {
|
if(index.waiting!=null) {
|
||||||
if(!waitingEnabled || pose!=null || action!=null || speechRequested || talk || inBridge || edge!=null ||
|
if(!waitingEnabled || pose!=null || action!=null || speechRequested || talk || inBridge || edge!=null ||
|
||||||
revealing!=null || key==previous || key.index!=slot.pack.body.frameCount-1 || slot.packageId!=index.waiting.idlePackage) return
|
revealing!=null || queuedPose!=null || idleTarget?.let { it!=slot.packageId }==true ||
|
||||||
|
key==previous || key.index!=slot.pack.body.frameCount-1 || slot.packageId !in waitingIdlePackages) return
|
||||||
idleCycles++
|
idleCycles++
|
||||||
if(idleCycles>=idleCycleGoal) {
|
if(idleCycles>=idleCycleGoal) {
|
||||||
resetIdleCycles()
|
resetIdleCycles()
|
||||||
val picked=chooseIdle(index.waiting.poses.size+1)
|
val count=waitingIdlePackages.size+index.waiting.poses.size
|
||||||
check(picked in 0..index.waiting.poses.size)
|
val picked=chooseIdle(count);check(picked in 0 until count)
|
||||||
queuedPose=if(picked==0) null else index.waiting.poses[picked-1]
|
if(picked<waitingIdlePackages.size) {
|
||||||
report("waiting_choice_${queuedPose?.id ?: "idle"}",key)
|
queuedPose=null;idleTarget=waitingIdlePackages[picked]
|
||||||
|
waitingChoiceKind=if(idleTarget==index.waiting.idlePackage) "idle" else "variant"
|
||||||
|
waitingChoiceId=checkNotNull(idleTarget)
|
||||||
|
} else {
|
||||||
|
queuedPose=index.waiting.poses[picked-waitingIdlePackages.size]
|
||||||
|
// A pose is authored against idle frame0. A variant must first
|
||||||
|
// finish its real return bridge, never jump directly into the pose.
|
||||||
|
idleTarget=index.waiting.idlePackage
|
||||||
|
waitingChoiceKind="pose";waitingChoiceId=checkNotNull(queuedPose).id
|
||||||
|
}
|
||||||
|
report("waiting_choice_$waitingChoiceId",key)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -276,7 +298,7 @@ class ConversationMediaDriver(private val index: EmotionActionIndex,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
val wanted=if(action!=null) checkNotNull(action?.media).sourcePackage else index.waiting?.let {
|
val wanted=if(action!=null) checkNotNull(action?.media).sourcePackage else index.waiting?.let {
|
||||||
if(speechRequested) it.talkPackage else it.idlePackage
|
if(speechRequested) it.talkPackage else idleTarget ?: it.idlePackage
|
||||||
} ?: idleTarget ?: selectedId
|
} ?: idleTarget ?: selectedId
|
||||||
var reviewedLoop: ConversationEdge?=null
|
var reviewedLoop: ConversationEdge?=null
|
||||||
if(source.packageId==wanted) {
|
if(source.packageId==wanted) {
|
||||||
|
|||||||
@@ -86,7 +86,10 @@ class EmotionActionAvatarView(context: Context,private val pack: AvatarPack,
|
|||||||
}
|
}
|
||||||
},{ phase,key ->
|
},{ phase,key ->
|
||||||
driver?.let { value -> DiagnosticLog.state("avatar_media", value.diagnosticSignature,
|
driver?.let { value -> DiagnosticLog.state("avatar_media", value.diagnosticSignature,
|
||||||
"event=$phase layer=${visibleLayer ?: -1} ${value.diagnosticState}") }
|
"event=$phase layer=${visibleLayer ?: -1} ${value.diagnosticState}")
|
||||||
|
if(phase.startsWith("waiting_choice_") || phase.startsWith("pose_") && key?.index==0)
|
||||||
|
android.util.Log.i("LanVoiceWaiting","event=$phase ${value.diagnosticState}")
|
||||||
|
}
|
||||||
report(VideoPresentation(actual=phase,reason="reviewed_media_path",
|
report(VideoPresentation(actual=phase,reason="reviewed_media_path",
|
||||||
clipId=key?.let { "f${it.index}_loop${it.loopOrdinal}" } ?: "")) },holdInitial=startupHold)
|
clipId=key?.let { "f${it.index}_loop${it.loopOrdinal}" } ?: "")) },holdInitial=startupHold)
|
||||||
driver=current;main.removeCallbacks(summary);main.postDelayed(summary,10_000);current.start();binding.attach(current) { if(active && !released) { current.start();binding.attach(current) } };fitMovie()
|
driver=current;main.removeCallbacks(summary);main.postDelayed(summary,10_000);current.start();binding.attach(current) { if(active && !released) { current.start();binding.attach(current) } };fitMovie()
|
||||||
|
|||||||
@@ -110,10 +110,9 @@ object DialogueProtocol {
|
|||||||
val payload = JSONObject(text)
|
val payload = JSONObject(text)
|
||||||
val type = payload.opt("type") as? String
|
val type = payload.opt("type") as? String
|
||||||
require(!type.isNullOrBlank()) { "Event is missing a string type" }
|
require(!type.isNullOrBlank()) { "Event is missing a string type" }
|
||||||
val kind = if (type.startsWith("reply.emotion.prepare")) EventKind.EXPRESSION_PREPARE else if (type == "reply.emotion") EventKind.REPLY_EMOTION else when (type.substringBefore('.')) {
|
val kind = if (type=="client.capabilities") EventKind.CAPABILITIES else if (type.startsWith("reply.emotion.prepare")) EventKind.EXPRESSION_PREPARE else if (type == "reply.emotion") EventKind.REPLY_EMOTION else when (type.substringBefore('.')) {
|
||||||
"auth" -> EventKind.AUTH
|
"auth" -> EventKind.AUTH
|
||||||
"hello" -> EventKind.HELLO
|
"hello" -> EventKind.HELLO
|
||||||
"client.capabilities" -> EventKind.CAPABILITIES
|
|
||||||
"history" -> EventKind.HISTORY
|
"history" -> EventKind.HISTORY
|
||||||
"listen" -> EventKind.LISTEN
|
"listen" -> EventKind.LISTEN
|
||||||
"vad" -> EventKind.VAD
|
"vad" -> EventKind.VAD
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
# Liam code41:等待轮替与联网舞蹈
|
||||||
|
|
||||||
|
基线 `654630dea51af6fce86a0d2a168c442eea16ba86` / code40;开始时工作树干净,remote main 相同。此次交付仅为 Liam 测试 APK;未安装设备、生成素材、修改或重启 gateway/registry,未改杨密/吕布的等待策略、构图、媒体或历史 APK。
|
||||||
|
|
||||||
|
## 修复与不变的媒体身份
|
||||||
|
|
||||||
|
`ConversationMediaDriver` 旧 waiting 分支只能从普通 neutral 选择 pose,且 `plan()` 总把等待目标强制为 neutral,导致已有 neutral-v03 不可达。现在从已验证 index 推导等待集合:普通 neutral,以及具备往返 neutral 的自身嘴层桥、approvedEdges 成立的 neutral 变体,再加独立 waiting_pose。本包实际四项为 neutral、neutral-v03、suit-adjust、knuckle-check;每完成2–3个自然循环随机选择一次。变体仍走真实桥和索引锚点;从变体选择 pose 时先经自身桥回 neutral,再等实际 frame0 停采确认。没有修改媒体、桥、PNG、runtime manifest 或 `runtimeReady:false`,也没有把 pose 当作 dance 或伪造嘴层。
|
||||||
|
|
||||||
|
TALK 仍只使用 neutral145 专用 talk-idle及自身嘴层;真实 playback.drained 后收口再回等待。pose仍要求实际 `AudioCapture.stopAndConfirm` ACK 后才能进入,无 TTS、无上行采音、无嘴层;结束必须释放 decoder并实际合成 neutral frame0后才恢复。旧轮音频/回调、取消和后台 epoch防护保持。
|
||||||
|
|
||||||
|
`char-waiting-poses-r01` 的可信构建配置开启 `networkActionsAllowed`,最低新版本为41。index无需变更,冻结为code40相同原始字节:
|
||||||
|
|
||||||
|
`25de3d199ad6122bf7840005d581b3ae2b4a1ffc10ceecd95793f636e3fd4ed8`
|
||||||
|
|
||||||
|
精确原始JSON(507,910B,HTTP下载复算同SHA):
|
||||||
|
|
||||||
|
<http://192.168.31.124:8080/liam-waiting-code41-index-25de3d199ad6122bf7840005d581b3ae2b4a1ffc10ceecd95793f636e3fd4ed8.json>
|
||||||
|
|
||||||
|
同次联合回放还复现了生产协议解析缺陷:旧 `DialogueProtocol.parseEvent()` 对 `type.substringBefore('.')` 分发,却匹配 `client.capabilities`,该分支不可达。表现为 pending HELLO后收到真实类型ACK也不能将客户端协商状态转为accepted;修前回放明确报 `ready_ack_not_accepted`。现先精确匹配 `client.capabilities`,保留同socket/同pin/once能力更新门禁,无重连或新一轮LLM请求。
|
||||||
|
|
||||||
|
## gateway只读取证与语言边界
|
||||||
|
|
||||||
|
协调者/gateway owner已登记上述精确pin,asset_01/asset_02各8042ms;本任务没有代登记。只读取得其当前registry快照,SHA256为 `a0994c0306502017cbd99f1e8673218501ce6300e6b030e6463d4009c95b7d9f`,共5pin,核对了原表与快照SHA相同。
|
||||||
|
|
||||||
|
gateway owner回报:真实WS直接HELLO返回action_available=true;pending HELLO返回false/pending=true,ready后ACK为client.capabilities,action_available=true、完整相同pin,探测后busy释放,0 ASR/LLM/TTS调用。本地另用当前受控源码/registry只读快照做隔离ASGI核验,未触碰live服务。
|
||||||
|
|
||||||
|
当前受控Liam lore language为 `zh-en`,不同于旧快照的 `en`。协调者已确认这是其pane另行获批的双语变更;不回退。APK只发persona=liam,不发language、voice_id或旧conversation_id。测试读取受控lore的确切语言值,并核验服务端persona/声音锁定;没有为通过测试放宽pin、voice或session隔离。owner另回报其gateway侧119项测试通过,此项为owner证据,并非本机运行结果。
|
||||||
|
|
||||||
|
## 已完成验证
|
||||||
|
|
||||||
|
- Gradle assembleDebug与compileDebugAndroidTestKotlin通过;arm64-v8a、min26/target34、原debug签名保持。instrumentation只编译,未在设备运行。
|
||||||
|
- 11组JVM/UI/相机生命周期回归通过,包括757旧报告时钟、103 native失败/取消断言及58项VoiceSession pose断言;83项包装回归通过,默认/吕布与旧bundle配置保持。
|
||||||
|
- 严格生产Kotlin index/runtime parser、整包files/SHA/bytes、十套独立N×5嘴层绑定、所有媒体完整解码/N/PTS/AAC终点、两pose无音轨检查通过。十套运行嘴层合计27,632,640B,单包≤8MB、合计≤32MB;400项真实离屏GLES嘴层像素比较与18项pose body-only像素比较通过。
|
||||||
|
- 新APK实际ZIP交给生产loader、View/driver/renderers回放通过;cold loader的2570嘴层读取在worker,main资产读取0,同process重复读取0,receipt模式嘴层读取0。APK的3,192个assets与code40文件集、逐项字节完全一致,包括两dance、两pose、bootstrap、原回退资源。index中两份源侧文档仍按既有运行清单过滤,生产loader和精确APK checker均通过。
|
||||||
|
- 联合回放使用实际新APK资产、生产VoiceSession/DialogueClient/DialogueProtocol/Binding/View/driver/renderers:正常HELLO和pending→ready两条路径各连续120,000ms静音640B PCM。只控制随机输入,不直接设置目标/queuedPose/owner;每条回放实际组合回调出现neutral1912帧、neutral-v03 294帧、suit-adjust386帧、knuckle-check193帧、3次pose回A。随机策略在真机不保证任意120秒必出全部四项。
|
||||||
|
- 从neutral-v03收到TALK/model happy时,实际播放先回neutral,真实drained后收口回等待。两dance分别经过action.plan、延迟capture-stop ACK、实际索引帧回调、自然音频结束/释放、实际neutral回A、completed、after_action新轮和独立drained;旧轮PCM拒绝。
|
||||||
|
- 延迟停采ACK前pose帧=0;pose期间晚到mic/TTS/listen不能上传、enqueue或抢层。自然退出、取消、后台、重复旧ACK/PCM,以及取消后重新开始、后台新socket/renderer返回后再次pose与聆听恢复均验证。
|
||||||
|
- 新pin当前快照上6条生产Android HELLO与8个canonical ASGI WS握手通过,覆盖ready/pending/ready ACK、精确pin、声音/语言锁定、新CID、旧socket和断连busy释放。旧未登记快照另9条Android HELLO/11个ASGI握手确认新pin被拒绝。错误pin的ACK和已断开的旧socket ACK不能升级能力。
|
||||||
|
- 本机gateway源码测试在隔离临时目录、合成persona音色配置下114项中113通过、1跳过(本机没有Silero ONNX,不下载/加载模型);未把初次缺私有配置/模型的环境错误算通过。无真实推理调用或live gateway写入。
|
||||||
|
|
||||||
|
证据位于忽略目录 `logs/liam-code41/` 和 `logs/avatar-safe-061/`,原始媒体、报告、运行日志、私有配置均不入Git。联合回放的Android录音、AudioTrack、codec/EGL、音乐设备和服务端transport有明确doubles;离屏GLES将OES替换为2D解码纹理。这些不等于真实手机出帧、实际麦克风停止或音乐听审完成。
|
||||||
|
|
||||||
|
## 现场最小元数据诊断
|
||||||
|
|
||||||
|
窄日志标签 `LanVoiceWaiting`,原因变化或10秒摘要才输出;500条内存ring随现有设置“发送诊断报告”导出,无新增录音/截图/正文。
|
||||||
|
|
||||||
|
- `waiting_gate`:enabled、eligible、block、turn、has_turn、phase、capture、capture_frame、muted、quiet_ms;capture为当前采音请求/epoch状态,capture_frame为本轮已收到实际录音帧,真正pose入口仍以stopAndConfirm ACK为准。
|
||||||
|
- block固定枚举:disabled/released/background/disconnected/voice_inactive/no_turn/blocked_turn/pose_owner/action_owner/user_speaking/presence_request/not_listening/muted/capture_inactive/playback_pending/talk_preparing/quiet_window/ready。按顺序报告第一个成立条件;pose主动封锁旧轮时blocked_turn可先于pose_owner出现,要结合owner/pose_stage看,不能单凭该值断言新故障。
|
||||||
|
- `waiting_choice_<id>`及runtime快照:waiting_policy/waiting_enabled、choice_kind/choice_id、idle_goal、visual、edge、owner、frame/loop/PTS。
|
||||||
|
- `waiting state=capture_stop_pending/capture_stopped/capture_failed/restored_idle`,以及pose进入/return实际frame0。报告 `avatar_runtime.action_protocol`还含waiting_enabled/waiting_block,`avatar_runtime.state`含当前选择/显示层/采样帧。
|
||||||
|
|
||||||
|
协调者可只读取当前PID的窄日志,不必重启、录音或截图:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
adb -s 0123456789ABCDEF logcat -d -v monotonic --pid=当前PID LanVoiceWaiting:I '*:S'
|
||||||
|
```
|
||||||
|
|
||||||
|
正常launcher在已授权时可启动既有麦克风/相机;本轮没有执行。安装后应分别核验安静等待的四项随机可达性、pose期间状态指示隐藏/不采音、恢复聆听、TALK neutral专用嘴层、两dance完整画面/音乐/返回/after_action,以及后台回来无旧音频或旧owner抢层。code40现场具体waitingSafe阻挡原因仍未知,本次未将其归因于假设的同turn恢复。
|
||||||
|
|
||||||
|
## 产物与回退
|
||||||
|
|
||||||
|
- 文件:`lan-voice-v0714-liam-test-code41-arm64-debug.apk`
|
||||||
|
- URL:<http://192.168.31.124:8080/lan-voice-v0714-liam-test-code41-arm64-debug.apk>
|
||||||
|
- SHA256:`45840a3f9df422bd6304e50808a79cda4e7243ae592152aa6a0bdbea5732b931`
|
||||||
|
- applicationId:`com.gorios.lanvoice.liamtest`;versionName:`0.7.14-liam-test`;versionCode:41;60,562,700B。
|
||||||
|
- 证书SHA256:`b9608336bc1ed1de3269bb4594f9fe718daaa5439511c5187aa385d2b799dcf1`。
|
||||||
|
- code40原产物SHA仍为 `5aa64ca37aac218ab10d9b41b832d7574f9aa1b399c455ddf744d80c138ff644`;主包/吕布/camera-probe及其他Liam旧产物保留。回退由协调者选择既有旧APK并按其USB流程处理,本轮未降级、清数据或安装。
|
||||||
|
|
||||||
|
真机GPU/前台随机等待/实际对话和声音、舞蹈接缝/音乐听审均待协调者验收;未宣称设备闭环完成。
|
||||||
@@ -82,14 +82,14 @@
|
|||||||
"assetRoot": "avatar/char-waiting-poses-r01/",
|
"assetRoot": "avatar/char-waiting-poses-r01/",
|
||||||
"indexSha256": "25de3d199ad6122bf7840005d581b3ae2b4a1ffc10ceecd95793f636e3fd4ed8",
|
"indexSha256": "25de3d199ad6122bf7840005d581b3ae2b4a1ffc10ceecd95793f636e3fd4ed8",
|
||||||
"userAuthorizedDebug": true,
|
"userAuthorizedDebug": true,
|
||||||
"networkActionsAllowed": false,
|
"networkActionsAllowed": true,
|
||||||
"minimumVersionCode": 40,
|
"minimumVersionCode": 41,
|
||||||
"bootstrapRoot": "avatar/startup-char-waiting-poses-r01/",
|
"bootstrapRoot": "avatar/startup-char-waiting-poses-r01/",
|
||||||
"bootstrapSha256": "097113985ee279f0360fe4817dd91f4aabea6a5bf32a6fd86e290dc8c381a941",
|
"bootstrapSha256": "097113985ee279f0360fe4817dd91f4aabea6a5bf32a6fd86e290dc8c381a941",
|
||||||
"bootstrapMetadata": "manifests/startup-char-waiting-poses-r01.json",
|
"bootstrapMetadata": "manifests/startup-char-waiting-poses-r01.json",
|
||||||
"resourceDirectory": "app/src/characterAssets/char-waiting-poses-r01/res",
|
"resourceDirectory": "app/src/characterAssets/char-waiting-poses-r01/res",
|
||||||
"posterResource": "startup_char_waiting_poses_r01_poster",
|
"posterResource": "startup_char_waiting_poses_r01_poster",
|
||||||
"settingsNote": "Liam 英语人设;neutral 专用 TALK、两段本地无声等待 pose(停采音、不讲、不叠嘴)。新 pin 联网舞蹈待登记;两段舞蹈字节保留。",
|
"settingsNote": "Liam 英语人设;neutral 专用 TALK;neutral/neutral-v03 与两段无声等待 pose 轮替(pose 停采音、不讲、不叠嘴)。联网舞蹈须精确 pin 经服务器准入。",
|
||||||
"waitingContract": true
|
"waitingContract": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,11 +9,13 @@ parser=argparse.ArgumentParser(description=__doc__)
|
|||||||
parser.add_argument('--apk',type=Path,required=True)
|
parser.add_argument('--apk',type=Path,required=True)
|
||||||
parser.add_argument('--sha256',required=True)
|
parser.add_argument('--sha256',required=True)
|
||||||
parser.add_argument('--startup-loader',action='store_true',help='Production background repository over actual APK bytes, isolated private receipt, no rendering/connection')
|
parser.add_argument('--startup-loader',action='store_true',help='Production background repository over actual APK bytes, isolated private receipt, no rendering/connection')
|
||||||
|
parser.add_argument('--waiting-session',action='store_true',help='Actual APK + production session/protocol/View/renderer, synthetic transport/audio/native APIs; finite waiting/TALK/dance replay')
|
||||||
parser.add_argument('--user-asset-candidate',action='store_true',help='Exact user-authorized correct03 APK; this offline replay uses local media callback doubles and does not assert network admission')
|
parser.add_argument('--user-asset-candidate',action='store_true',help='Exact user-authorized correct03 APK; this offline replay uses local media callback doubles and does not assert network admission')
|
||||||
parser.add_argument('--media-bundle',default='black-correct03',help='Trusted user-debug bundle, when --user-asset-candidate is set')
|
parser.add_argument('--media-bundle',default='black-correct03',help='Trusted user-debug bundle, when --user-asset-candidate is set')
|
||||||
parser.add_argument('--framing-zoom',type=float,default=1)
|
parser.add_argument('--framing-zoom',type=float,default=1)
|
||||||
parser.add_argument('--framing-center-y',type=float,default=.5)
|
parser.add_argument('--framing-center-y',type=float,default=.5)
|
||||||
args=parser.parse_args()
|
args=parser.parse_args()
|
||||||
|
assert not(args.startup_loader and args.waiting_session)
|
||||||
assert hashlib.sha256(args.apk.read_bytes()).hexdigest()==args.sha256, 'APK hash drift'
|
assert hashlib.sha256(args.apk.read_bytes()).hexdigest()==args.sha256, 'APK hash drift'
|
||||||
ROOT=Path(__file__).resolve().parents[1];script=ROOT/'scripts/check-reply-regressions.py'
|
ROOT=Path(__file__).resolve().parents[1];script=ROOT/'scripts/check-reply-regressions.py'
|
||||||
tree=ast.parse(script.read_text());nodes=[]
|
tree=ast.parse(script.read_text());nodes=[]
|
||||||
@@ -25,7 +27,7 @@ java,compiler,cp=ns['JAVA'],ns['compiler'],ns['cp'];real=next(x[2] for x in ns['
|
|||||||
json_adapter=r'''
|
json_adapter=r'''
|
||||||
package org.json
|
package org.json
|
||||||
private fun wrap(v: Any?): Any? = when(v) { is Map<*,*> -> JSONObject(v as Map<String,Any?>); is List<*> -> JSONArray(v); null -> JSONObject.NULL;else ->v }
|
private fun wrap(v: Any?): Any? = when(v) { is Map<*,*> -> JSONObject(v as Map<String,Any?>); is List<*> -> JSONArray(v); null -> JSONObject.NULL;else ->v }
|
||||||
class JSONObject(private val map: Map<String,Any?>) {
|
class JSONObject(private val map: Map<String,Any?> = linkedMapOf()) {
|
||||||
constructor(raw: String):this(Parser(raw).value() as Map<String,Any?>)
|
constructor(raw: String):this(Parser(raw).value() as Map<String,Any?>)
|
||||||
fun keys()=map.keys.iterator()
|
fun keys()=map.keys.iterator()
|
||||||
fun get(k: String): Any? = wrap(map.getValue(k))
|
fun get(k: String): Any? = wrap(map.getValue(k))
|
||||||
@@ -35,13 +37,27 @@ class JSONObject(private val map: Map<String,Any?>) {
|
|||||||
fun getInt(k: String)=(map.getValue(k) as Number).toInt()
|
fun getInt(k: String)=(map.getValue(k) as Number).toInt()
|
||||||
fun getBoolean(k: String)=map.getValue(k) as Boolean
|
fun getBoolean(k: String)=map.getValue(k) as Boolean
|
||||||
fun getJSONArray(k: String)=JSONArray(map.getValue(k) as List<*>)
|
fun getJSONArray(k: String)=JSONArray(map.getValue(k) as List<*>)
|
||||||
|
fun put(k: String,v: Any?): JSONObject { (map as MutableMap<String,Any?>)[k]=v;return this }
|
||||||
|
fun opt(k: String)=if(k in map) wrap(map[k]) else null
|
||||||
|
fun optString(k: String,fallback: String="")=map[k] as? String ?: fallback
|
||||||
|
fun optBoolean(k: String,fallback: Boolean=false)=map[k] as? Boolean ?: fallback
|
||||||
|
fun optInt(k: String,fallback: Int=0)=(map[k] as? Number)?.toInt() ?: fallback
|
||||||
|
fun optJSONObject(k: String)=opt(k) as? JSONObject
|
||||||
|
override fun toString()=map.entries.joinToString(",","{","}") { (k,v)->encode(k)+":"+encode(v) }
|
||||||
companion object { val NULL=Any() }
|
companion object { val NULL=Any() }
|
||||||
}
|
}
|
||||||
class JSONArray(private val values: List<*>) {
|
class JSONArray(private val values: List<*> = mutableListOf<Any?>()) {
|
||||||
fun length()=values.size
|
fun length()=values.size
|
||||||
fun get(i: Int): Any? =wrap(values[i])
|
fun get(i: Int): Any? =wrap(values[i])
|
||||||
fun getJSONObject(i: Int)=get(i) as JSONObject
|
fun getJSONObject(i: Int)=get(i) as JSONObject
|
||||||
fun getLong(i: Int)=(values[i] as Number).toLong()
|
fun getLong(i: Int)=(values[i] as Number).toLong()
|
||||||
|
fun put(v: String): JSONArray { (values as MutableList<Any?>).add(v);return this }
|
||||||
|
override fun toString()=values.joinToString(",","[","]",transform=::encode)
|
||||||
|
}
|
||||||
|
private fun encode(v: Any?): String=when(v) {
|
||||||
|
null,JSONObject.NULL->"null"
|
||||||
|
is String->"\""+v.replace("\\","\\\\").replace("\"","\\\"").replace("\n","\\n")+"\""
|
||||||
|
else->v.toString()
|
||||||
}
|
}
|
||||||
private class Parser(val s: String) {
|
private class Parser(val s: String) {
|
||||||
var i=0
|
var i=0
|
||||||
@@ -297,16 +313,25 @@ if args.user_asset_candidate and index.get('waiting'):
|
|||||||
with tempfile.TemporaryDirectory(prefix='baji-runtime-audit-') as td:
|
with tempfile.TemporaryDirectory(prefix='baji-runtime-audit-') as td:
|
||||||
tmp=Path(td);files=[]
|
tmp=Path(td);files=[]
|
||||||
for path in (ROOT/'tests/avatar').glob('*.kt'):
|
for path in (ROOT/'tests/avatar').glob('*.kt'):
|
||||||
if path.name not in ('Pack.kt','Context.kt','Graphics.kt','BuildConfig.kt') and not(args.startup_loader and path.name=='Clock.kt'):files.append(path)
|
if path.name not in ('Pack.kt','Context.kt','Graphics.kt','BuildConfig.kt') and not((args.startup_loader or args.waiting_session) and path.name=='Clock.kt') and not(args.waiting_session and path.name=='AndroidLog.kt'):files.append(path)
|
||||||
if args.startup_loader:
|
if args.startup_loader:
|
||||||
clock=(ROOT/'tests/avatar/Clock.kt').read_text().replace('fun getMainLooper() = main','private val owner=Thread.currentThread();fun myLooper(): Looper?=if(Thread.currentThread()===owner) main else null;fun getMainLooper() = main')
|
clock=(ROOT/'tests/avatar/Clock.kt').read_text().replace('fun getMainLooper() = main','private val owner=Thread.currentThread();fun myLooper(): Looper?=if(Thread.currentThread()===owner) main else null;fun getMainLooper() = main')
|
||||||
clock=clock.replace(' fun add(', ' @Synchronized fun add(').replace(' fun remove(', ' @Synchronized fun remove(').replace(' fun advanceBy(', ' @Synchronized fun advanceBy(')
|
clock=clock.replace(' fun add(', ' @Synchronized fun add(').replace(' fun remove(', ' @Synchronized fun remove(').replace(' fun advanceBy(', ' @Synchronized fun advanceBy(')
|
||||||
p=tmp/'Clock.kt';p.write_text(clock);files.append(p)
|
p=tmp/'Clock.kt';p.write_text(clock);files.append(p)
|
||||||
|
if args.waiting_session:
|
||||||
|
assert args.user_asset_candidate and index.get('waiting')
|
||||||
|
main=(ROOT/'tests/runtime/WaitingConversationReplay.kt').read_text()
|
||||||
|
clock=(ROOT/'tests/avatar/Clock.kt').read_text().replace('fun getMainLooper() = main','fun myLooper()=main;fun getMainLooper() = main')
|
||||||
|
p=tmp/'Clock.kt';p.write_text(clock);files.append(p)
|
||||||
|
files += [ROOT/'tests/session'/name for name in ('AudioDoubles.kt','DebugUploadDouble.kt','AndroidLog.kt')]
|
||||||
|
files += next(x[2] for x in ns['suites'] if x[0]=='session')
|
||||||
|
files += [ROOT/'app/src/main/java/com/gorios/lanvoice'/name for name in ('net/DialogueProtocol.kt','expression/PresenceRules.kt')]
|
||||||
startup_main=startup_main.replace("3185",str(patch_count))
|
startup_main=startup_main.replace("3185",str(patch_count))
|
||||||
for name,txt in [('Json.kt',json_adapter),('Context.kt',context),('Graphics.kt',graphics),('BuildConfig.kt',build),('Audit.kt',startup_main if args.startup_loader else main)]:
|
for name,txt in [('Json.kt',json_adapter),('Context.kt',context),('Graphics.kt',graphics),('BuildConfig.kt',build),('Audit.kt',startup_main if args.startup_loader else main)]:
|
||||||
p=tmp/name;p.write_text(txt);files.append(p)
|
p=tmp/name;p.write_text(txt);files.append(p)
|
||||||
files+=real+[ROOT/'app/src/main/java/com/gorios/lanvoice'/p for p in ('avatar/AvatarPack.kt','avatar/StartupAvatarView.kt','avatar/StartupLoadCache.kt','diag/StartupTrace.kt')]
|
files+=real+[ROOT/'app/src/main/java/com/gorios/lanvoice'/p for p in ('avatar/AvatarPack.kt','avatar/StartupAvatarView.kt','avatar/StartupLoadCache.kt','diag/StartupTrace.kt')]
|
||||||
if args.startup_loader: files.append(ROOT/'app/src/main/java/com/gorios/lanvoice/avatar/StartupAvatarRepository.kt')
|
if args.startup_loader: files.append(ROOT/'app/src/main/java/com/gorios/lanvoice/avatar/StartupAvatarRepository.kt')
|
||||||
|
files=list(dict.fromkeys(files))
|
||||||
subprocess.run([java,'-cp',compiler,'org.jetbrains.kotlin.cli.jvm.K2JVMCompiler','-no-stdlib','-no-reflect','-jvm-target','17','-nowarn','-classpath',cp,'-d',str(tmp),*map(str,files)],check=True)
|
subprocess.run([java,'-cp',compiler,'org.jetbrains.kotlin.cli.jvm.K2JVMCompiler','-no-stdlib','-no-reflect','-jvm-target','17','-nowarn','-classpath',cp,'-d',str(tmp),*map(str,files)],check=True)
|
||||||
if args.startup_loader:
|
if args.startup_loader:
|
||||||
receipt=tmp/'private';receipt.mkdir()
|
receipt=tmp/'private';receipt.mkdir()
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ resolver=ast.parse((gateway_root/'persona_resolver.py').read_text())
|
|||||||
registered=next(ast.literal_eval(n.value) for n in resolver.body if isinstance(n,ast.Assign) and
|
registered=next(ast.literal_eval(n.value) for n in resolver.body if isinstance(n,ast.Assign) and
|
||||||
any(isinstance(t,ast.Name) and t.id=='PERSONAS' for t in n.targets))
|
any(isinstance(t,ast.Name) and t.id=='PERSONAS' for t in n.targets))
|
||||||
personas=['default','lvbu']+(['liam'] if 'liam' in registered else [])
|
personas=['default','lvbu']+(['liam'] if 'liam' in registered else [])
|
||||||
|
languages={p:json.loads((gateway_root/'personas'/registered[p][0]).read_bytes()).get('language','zh')
|
||||||
|
for p in personas if p!='default'}
|
||||||
|
assert all(value in ('zh','en','zh-en') for value in languages.values())
|
||||||
tree=ast.parse((ROOT/'scripts/check-reply-regressions.py').read_text())
|
tree=ast.parse((ROOT/'scripts/check-reply-regressions.py').read_text())
|
||||||
nodes=[]
|
nodes=[]
|
||||||
for node in tree.body:
|
for node in tree.body:
|
||||||
@@ -122,7 +125,15 @@ for hello in hellos:
|
|||||||
assert ack['conversation_id'] not in ids;ids.append(ack['conversation_id'])
|
assert ack['conversation_id'] not in ids;ids.append(ack['conversation_id'])
|
||||||
assert ws.receive_json()['type']=='history'
|
assert ws.receive_json()['type']=='history'
|
||||||
assert sessions[-1]==('yangmi_fiction' if persona=='default' else persona,
|
assert sessions[-1]==('yangmi_fiction' if persona=='default' else persona,
|
||||||
'en' if persona=='liam' else 'zh',expected_voice)
|
LANGUAGES.get(persona,'zh'),expected_voice)
|
||||||
|
if hello.get('action_pending_pack_sha256'):
|
||||||
|
pin=hello['action_pending_pack_sha256']
|
||||||
|
ws.send_json(dict(type='client.capabilities.ready',action_protocol=1,action_pack_sha256=pin,action_kinds=['dance']))
|
||||||
|
ready=ws.receive_json()
|
||||||
|
assert ready['type']=='client.capabilities'
|
||||||
|
assert ready['action_available']==bool(pending_pin(hello,configured_packs()))
|
||||||
|
assert ready['action_pack_sha256']==(pin if pending_pin(hello,configured_packs()) else '')
|
||||||
|
assert all(k in ready for k in ('turn_id','seq','server_ms'))
|
||||||
assert state.busy is False, 'disconnect did not release existing gateway busy owner'
|
assert state.busy is False, 'disconnect did not release existing gateway busy owner'
|
||||||
# A non-default persona stays server-locked even if a caller offers another voice/CID.
|
# A non-default persona stays server-locked even if a caller offers another voice/CID.
|
||||||
for persona in sorted({x['persona'] for x in hellos}-{'default'}):
|
for persona in sorted({x['persona'] for x in hellos}-{'default'}):
|
||||||
@@ -135,6 +146,6 @@ for persona in sorted({x['persona'] for x in hellos}-{'default'}):
|
|||||||
assert ack['voice_id']=='synthetic-'+persona and ack['conversation_id'] not in ids
|
assert ack['voice_id']=='synthetic-'+persona and ack['conversation_id'] not in ids
|
||||||
ws.receive_json();ids.append(ack['conversation_id'])
|
ws.receive_json();ids.append(ack['conversation_id'])
|
||||||
assert state.busy is False
|
assert state.busy is False
|
||||||
print('PASS: '+str(len(ids))+' canonical ASGI WS handshakes from actual Android HELLO; personas='+','.join(sorted({x["persona"] for x in hellos}))+'; explicit persona ignores active_profile, server-locks voice/language, fresh CID, ready/pending exact pin and disconnect busy cleanup; 0 ASR/LLM/TTS calls, synthetic-only')
|
print('PASS: '+str(len(ids))+' canonical ASGI WS handshakes from actual Android HELLO; personas='+','.join(sorted({x["persona"] for x in hellos}))+'; server_languages='+json.dumps(LANGUAGES,sort_keys=True)+'; explicit persona ignores active_profile, server-locks voice/language, fresh CID, ready/pending exact pin, pending-to-ready ACK and disconnect busy cleanup; 0 ASR/LLM/TTS calls, synthetic-only')
|
||||||
'''.replace('UNREVIEWED',repr(args.unreviewed_index_sha)).replace('REVIEWED',repr(args.reviewed_index_sha))
|
'''.replace('UNREVIEWED',repr(args.unreviewed_index_sha)).replace('REVIEWED',repr(args.reviewed_index_sha)).replace('LANGUAGES',repr(languages))
|
||||||
subprocess.run([sys.executable,'-c',runner],cwd=stage,check=True,timeout=30)
|
subprocess.run([sys.executable,'-c',runner],cwd=stage,check=True,timeout=30)
|
||||||
|
|||||||
@@ -43,11 +43,17 @@ fun main() {
|
|||||||
check(client.actionNegotiation=="pending_pack")
|
check(client.actionNegotiation=="pending_pack")
|
||||||
readyPin=pin;check(client.capabilitiesReady())
|
readyPin=pin;check(client.capabilitiesReady())
|
||||||
check(socket.sent.last()==DialogueProtocol.capabilitiesReady(pin))
|
check(socket.sent.last()==DialogueProtocol.capabilitiesReady(pin))
|
||||||
|
receive("""{"type":"client.capabilities","action_available":true,"action_pack_sha256":"${"f".repeat(64)}"}""")
|
||||||
|
check(client.actionNegotiation=="pending_pack")
|
||||||
|
receive("""{"type":"client.capabilities","action_available":true,"action_pack_sha256":"$pin","turn_id":0,"seq":1,"server_ms":1}""")
|
||||||
|
check(client.actionNegotiation=="accepted")
|
||||||
} else check(client.actionNegotiation=="accepted")
|
} else check(client.actionNegotiation=="accepted")
|
||||||
client.disconnect()
|
client.disconnect()
|
||||||
old.onMessage(socket,"""{"type":"auth","state":"ok"}""")
|
old.onMessage(socket,"""{"type":"auth","state":"ok"}""")
|
||||||
old.onMessage(socket,"""{"type":"hello","action_available":true}""");Handler.drain()
|
old.onMessage(socket,"""{"type":"hello","action_available":true}""");Handler.drain()
|
||||||
|
old.onMessage(socket,"""{"type":"client.capabilities","action_available":true,"action_pack_sha256":"$pin"}""");Handler.drain()
|
||||||
check(socket.cancelled && statuses.last()==ConnectionStatus.DISCONNECTED)
|
check(socket.cancelled && statuses.last()==ConnectionStatus.DISCONNECTED)
|
||||||
|
check(client.actionNegotiation=="disconnected")
|
||||||
val count=socket.sent.size
|
val count=socket.sent.size
|
||||||
old.onMessage(Socket(),"""{"type":"auth","state":"ok"}""");Handler.drain()
|
old.onMessage(Socket(),"""{"type":"auth","state":"ok"}""");Handler.drain()
|
||||||
check(socket.sent.size==count)
|
check(socket.sent.size==count)
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package org.json
|
package org.json
|
||||||
|
|
||||||
// Bounded flat AUTH/HELLO response adapter. Outbound JSON uses production protocol.
|
// Bounded flat AUTH/HELLO/capability response adapter. Outbound JSON uses production protocol.
|
||||||
// This does not exercise Android's JSON parser, which the APK build compiles.
|
// This does not exercise Android's JSON parser, which the APK build compiles.
|
||||||
class JSONObject() {
|
class JSONObject() {
|
||||||
private val fields=linkedMapOf<String,Any>()
|
private val fields=linkedMapOf<String,Any>()
|
||||||
constructor(text: String):this() {
|
constructor(text: String):this() {
|
||||||
check(text.length<2048 && text.startsWith("{") && text.endsWith("}"))
|
check(text.length<2048 && text.startsWith("{") && text.endsWith("}"))
|
||||||
val entries=Regex("\"([a-z_]+)\":(\"[a-z_]+\"|true|false|[0-9]+)").findAll(text)
|
val entries=Regex("\"([a-z0-9_]+)\"\\s*:\\s*(\"[a-z0-9_.-]*\"|true|false|[0-9]+)").findAll(text)
|
||||||
entries.forEach {
|
entries.forEach {
|
||||||
val raw=it.groupValues[2]
|
val raw=it.groupValues[2]
|
||||||
fields[it.groupValues[1]]=when {
|
fields[it.groupValues[1]]=when {
|
||||||
|
|||||||
@@ -201,9 +201,9 @@ class WaitingPackTests(unittest.TestCase):
|
|||||||
for r in m['conversationPackages']:
|
for r in m['conversationPackages']:
|
||||||
runtime=json.loads((a/r['runtimeManifest']['path']).read_bytes())
|
runtime=json.loads((a/r['runtimeManifest']['path']).read_bytes())
|
||||||
self.assertIs(runtime['runtimeReady'],False)
|
self.assertIs(runtime['runtimeReady'],False)
|
||||||
self.assertFalse(new['networkActionsAllowed'])
|
self.assertTrue(new['networkActionsAllowed'])
|
||||||
self.assertTrue(old['networkActionsAllowed'])
|
self.assertTrue(old['networkActionsAllowed'])
|
||||||
self.assertEqual(new['minimumVersionCode'],40)
|
self.assertEqual(new['minimumVersionCode'],41)
|
||||||
|
|
||||||
def test_pose_corruption_is_rejected(self):
|
def test_pose_corruption_is_rejected(self):
|
||||||
row=select.catalog()['mediaBundles']['char-waiting-poses-r01']
|
row=select.catalog()['mediaBundles']['char-waiting-poses-r01']
|
||||||
|
|||||||
@@ -0,0 +1,212 @@
|
|||||||
|
import com.gorios.lanvoice.avatar.*
|
||||||
|
import com.gorios.lanvoice.audio.*
|
||||||
|
import com.gorios.lanvoice.net.*
|
||||||
|
import android.os.*
|
||||||
|
import android.media.*
|
||||||
|
import okhttp3.*
|
||||||
|
import okio.ByteString
|
||||||
|
import org.json.JSONObject
|
||||||
|
import java.nio.ByteBuffer
|
||||||
|
import java.nio.ByteOrder
|
||||||
|
|
||||||
|
private fun field(obj:Any,name:String)=obj.javaClass.getDeclaredField(name).apply { isAccessible=true }
|
||||||
|
private class WaitingSocket(val control:(JSONObject)->Unit):WebSocket {
|
||||||
|
val sent=mutableListOf<JSONObject>();var audioFrames=0;var cancelled=false
|
||||||
|
override fun request()=Request.Builder().url("https://localhost/ws/dialogue").build()
|
||||||
|
override fun queueSize()=0L
|
||||||
|
override fun send(text:String):Boolean { val value=JSONObject(text);sent.add(value);control(value);return true }
|
||||||
|
override fun send(bytes:ByteString):Boolean {audioFrames++;return true}
|
||||||
|
override fun close(code:Int,reason:String?)=true
|
||||||
|
override fun cancel() {cancelled=true}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Real production session + protocol + view/driver/renderers; only Android I/O and server are doubles. */
|
||||||
|
private class WaitingRig(val pack:AvatarPack,val pending:Boolean=false) {
|
||||||
|
val index=checkNotNull(pack.emotionAction)
|
||||||
|
val binding=AvatarMediaBinding(true)
|
||||||
|
val trace=mutableListOf<Pair<Long,VideoPresentation>>()
|
||||||
|
var state=VoiceUiState();var turn=0L
|
||||||
|
lateinit var socket:WaitingSocket
|
||||||
|
lateinit var listener:WebSocketListener
|
||||||
|
val session=VoiceSession("localhost",5011,onState={
|
||||||
|
state=it;binding.beginTurn(it.turnId)
|
||||||
|
binding.intent(it.replyEmotion.takeIf { r->r.turnId!=null },it.playbackActivity?.audible==true && !it.actionActive && !it.waitingPoseActive)
|
||||||
|
},reviewedActionPack=if(pending) null else index.actionPack,pendingActionPackSha={index.actionPack!!.manifestSha},
|
||||||
|
actionPlayer=binding,waitingPlayer=binding,onPrepareExpression=binding::prepare,persona="liam",keepPermissionConnection=false)
|
||||||
|
val view:EmotionActionAvatarView
|
||||||
|
var running=true
|
||||||
|
init {
|
||||||
|
CodecFixture.reset();CodecFixture.width=720;CodecFixture.height=1280;CodecFixture.emitNativeSurface=true;MediaPlayer.created.clear()
|
||||||
|
index.packages.values.forEach { CodecFixture.timelines[it.root+it.body.path]=it.body.ptsUs }
|
||||||
|
index.edges.mapNotNull { it.mouthRuntime }.forEach { CodecFixture.timelines[it.root+it.body.path]=it.body.ptsUs }
|
||||||
|
index.waiting!!.poses.forEach { CodecFixture.timelines[index.root+it.clip.path]=it.clip.ptsUs }
|
||||||
|
index.actionPack!!.assets.mapNotNull { it.media }.forEach { CodecFixture.timelines[it.root+it.path]=it.ptsUs;CodecFixture.audioPaths.add(it.root+it.path) }
|
||||||
|
socket=WaitingSocket { value -> Handler(Looper.getMainLooper()).postDelayed({
|
||||||
|
when(value.optString("type")) {
|
||||||
|
"hello"->event("hello",fields=mapOf("action_available" to !pending,"action_pending" to pending))
|
||||||
|
"client.capabilities.ready"->event("client.capabilities",fields=mapOf("action_available" to true,"action_pack_sha256" to index.actionPack.manifestSha))
|
||||||
|
"listen"->if(value.optString("state")=="start") {
|
||||||
|
turn++;event("abort",turn,mapOf("reason" to "listen_start"));event("listen",turn,mapOf("state" to "start"))
|
||||||
|
} else event("listen",turn,mapOf("state" to "stop"))
|
||||||
|
}
|
||||||
|
},1) }
|
||||||
|
val dialogue=field(session,"dialogue").get(session) as DialogueClient
|
||||||
|
field(dialogue,"socket").set(dialogue,socket)
|
||||||
|
session.foreground(false)
|
||||||
|
listener=dialogue.javaClass.getDeclaredMethod("listener",Long::class.javaPrimitiveType).apply {isAccessible=true}.invoke(dialogue,0L) as WebSocketListener
|
||||||
|
event("auth",fields=mapOf("state" to "ok"));TestScheduler.advanceBy(2)
|
||||||
|
check(state.connection==ConnectionStatus.CONNECTED)
|
||||||
|
val hello=socket.sent.single {it.optString("type")=="hello"}
|
||||||
|
check(hello.optString("persona")=="liam")
|
||||||
|
check(hello.optString(if(pending) "action_pending_pack_sha256" else "action_pack_sha256")==index.actionPack.manifestSha)
|
||||||
|
if(pending) {session.installReviewedActions(index.actionPack);TestScheduler.advanceBy(2)}
|
||||||
|
check(dialogue.actionNegotiation=="accepted") {"ready_ack_not_accepted"}
|
||||||
|
view=EmotionActionAvatarView(android.content.Context(),pack,binding,{trace.add(TestScheduler.now to it)})
|
||||||
|
view.render(true)
|
||||||
|
controlledChoices()
|
||||||
|
session.startVoice()
|
||||||
|
val mic=object:Runnable {override fun run() {
|
||||||
|
if(!running)return
|
||||||
|
if(field(session,"capturing").getBoolean(session)) AudioCapture.lastFrame?.invoke(ByteArray(640))
|
||||||
|
Handler(Looper.getMainLooper()).postDelayed(this,20)
|
||||||
|
}}
|
||||||
|
Handler(Looper.getMainLooper()).post(mic)
|
||||||
|
TestScheduler.advanceBy(2)
|
||||||
|
}
|
||||||
|
private fun controlledChoices() {
|
||||||
|
val driver=field(view,"driver").get(view) as ConversationMediaDriver
|
||||||
|
// Control the random input, never queued poses, selected targets or ownership.
|
||||||
|
var choice=0
|
||||||
|
field(driver,"chooseIdle").set(driver,{ count:Int->(choice++%4).also {check(count==4)} })
|
||||||
|
field(driver,"chooseIdleCycles").set(driver,{2});field(driver,"idleCycleGoal").setInt(driver,2)
|
||||||
|
}
|
||||||
|
fun returnFromBackground() {
|
||||||
|
val dialogue=field(session,"dialogue").get(session) as DialogueClient
|
||||||
|
// Transport adapter supplies a new authenticated socket, without opening a
|
||||||
|
// real health/WS request. Session/renderer ownership and waiting gates stay real.
|
||||||
|
field(dialogue,"authReceived").setBoolean(dialogue,false)
|
||||||
|
field(dialogue,"helloSent").setBoolean(dialogue,false)
|
||||||
|
field(dialogue,"pendingOffered").set(dialogue,null)
|
||||||
|
field(dialogue,"readyUpdateSent").setBoolean(dialogue,false)
|
||||||
|
socket=WaitingSocket { value -> Handler(Looper.getMainLooper()).postDelayed({
|
||||||
|
when(value.optString("type")) {
|
||||||
|
"hello"->event("hello",fields=mapOf("action_available" to true,"action_pending" to false))
|
||||||
|
"listen"->if(value.optString("state")=="start") {
|
||||||
|
turn++;event("abort",turn,mapOf("reason" to "listen_start"));event("listen",turn,mapOf("state" to "start"))
|
||||||
|
} else event("listen",turn,mapOf("state" to "stop"))
|
||||||
|
}
|
||||||
|
},1) }
|
||||||
|
field(dialogue,"socket").set(dialogue,socket)
|
||||||
|
val epoch=field(dialogue,"generation").getLong(dialogue)
|
||||||
|
listener=dialogue.javaClass.getDeclaredMethod("listener",Long::class.javaPrimitiveType).apply {isAccessible=true}.invoke(dialogue,epoch) as WebSocketListener
|
||||||
|
session.foreground(false);event("auth",fields=mapOf("state" to "ok"));TestScheduler.advanceBy(2)
|
||||||
|
check(state.connection==ConnectionStatus.CONNECTED && dialogue.actionNegotiation=="accepted")
|
||||||
|
view.render(true);controlledChoices();session.startVoice();TestScheduler.advanceBy(2)
|
||||||
|
}
|
||||||
|
fun event(type:String,id:Long?=null,fields:Map<String,Any> = emptyMap()) {
|
||||||
|
val value=JSONObject().put("type",type);if(id!=null)value.put("turn_id",id)
|
||||||
|
fields.forEach {(k,v)->value.put(k,v)}
|
||||||
|
listener.onMessage(socket,value.toString())
|
||||||
|
}
|
||||||
|
fun pcm(id:Long=turn) {
|
||||||
|
val bytes=ByteBuffer.allocate(12+1920).order(ByteOrder.BIG_ENDIAN)
|
||||||
|
.put('L'.code.toByte()).put('V'.code.toByte()).put(1.toByte()).put(2.toByte()).putInt(id.toInt()).putInt(1).put(ByteArray(1920)).array()
|
||||||
|
listener.onMessage(socket,ByteString.of(*bytes))
|
||||||
|
}
|
||||||
|
fun tts() {
|
||||||
|
event("tts",turn,mapOf("state" to "start"))
|
||||||
|
event("reply.emotion",turn,mapOf("seq" to 3,"emotion" to "happy","intensity" to 1,"source" to "model"))
|
||||||
|
pcm();event("tts",turn,mapOf("state" to "done"));TestScheduler.advanceBy(0)
|
||||||
|
}
|
||||||
|
fun playAndDrain() {
|
||||||
|
val before=AudioPlayback.enqueued;tts()
|
||||||
|
TestScheduler.until(10_000) {AudioPlayback.enqueued>before}
|
||||||
|
check(binding.currentPackageId=="neutral")
|
||||||
|
AudioPlayback.lastPlaying!!(turn,0,true);AudioPlayback.lastActivity!!(PlaybackActivity(turn,0,true,960,1920));TestScheduler.advanceBy(0)
|
||||||
|
check(state.voiceIndicator==VoiceIndicatorState.SPEAKING)
|
||||||
|
TestScheduler.advanceBy(100);AudioPlayback.lastDrained!!(turn,0);TestScheduler.advanceBy(200)
|
||||||
|
check(state.phase==VoicePhase.LISTENING)
|
||||||
|
check(socket.sent.any {it.optString("type")=="playback.drained" && it.getLong("turn_id")==turn})
|
||||||
|
}
|
||||||
|
fun close() {running=false;session.release();view.dispose();TestScheduler.advanceBy(100);AudioCapture.confirmStopsAutomatically=true}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun main(args:Array<String>) {
|
||||||
|
android.content.Archive.zip=java.util.zip.ZipFile(args.single())
|
||||||
|
val pack=checkNotNull(AvatarPack.load(android.content.Context()))
|
||||||
|
check(pack.emotionAdmission=="accepted")
|
||||||
|
println("SESSION_LOADER|actual_apk=true|pin=${pack.emotionAction!!.actionPack!!.manifestSha}")
|
||||||
|
for(pending in listOf(false,true)) {
|
||||||
|
TestScheduler.reset();val rig=WaitingRig(pack,pending)
|
||||||
|
val start=TestScheduler.now
|
||||||
|
TestScheduler.advanceBy(120_000)
|
||||||
|
val phases=rig.trace.map {it.second.actual}
|
||||||
|
check(listOf("body_neutral","body_neutral-v03","pose_suit-adjust","pose_knuckle-check").all {it in phases})
|
||||||
|
check(phases.none {it=="media_failed"})
|
||||||
|
check(rig.trace.filter {it.second.actual.startsWith("pose_") && it.second.actual!="pose_return_a"}.size>=386)
|
||||||
|
check(rig.trace.count {it.second.actual=="pose_return_a"}>=2)
|
||||||
|
println("WAIT_120S|pending=$pending|ms=${TestScheduler.now-start}|neutral=${phases.count {it=="body_neutral"}}|variant=${phases.count {it=="body_neutral-v03"}}|suit=${phases.count {it=="pose_suit-adjust"}}|knuckle=${phases.count {it=="pose_knuckle-check"}}|returns=${phases.count {it=="pose_return_a"}}|controlled_rng=true|device=false")
|
||||||
|
TestScheduler.until(90_000) {rig.binding.currentPackageId=="neutral-v03"}
|
||||||
|
rig.playAndDrain()
|
||||||
|
check(rig.state.replyEmotion.turnId==null)
|
||||||
|
println("TALK_FROM_VARIANT|actual=neutral|model=happy|drained=true|closed_to_wait=true")
|
||||||
|
for(action in 0..1) {
|
||||||
|
val controller=field(rig.session,"actions").get(rig.session) as ActionController
|
||||||
|
field(controller,"choose").set(controller,{_:Int->0})
|
||||||
|
val id="replay_action_${action}_0123456789"
|
||||||
|
AudioCapture.confirmStopsAutomatically=false
|
||||||
|
val oldPlayers=MediaPlayer.created.size
|
||||||
|
rig.event("action.plan",rig.turn,mapOf("action_id" to id,"pack_sha256" to rig.index.actionPack!!.manifestSha,"ttl_ms" to 120_000))
|
||||||
|
TestScheduler.advanceBy(0);check(MediaPlayer.created.size==oldPlayers)
|
||||||
|
AudioCapture.lastStopped!!(true);TestScheduler.advanceBy(0);AudioCapture.confirmStopsAutomatically=true
|
||||||
|
val movie=MediaPlayer.created.last();movie.prepared!!(movie)
|
||||||
|
TestScheduler.until(20_000) {movie.started}
|
||||||
|
TestScheduler.advanceBy(8100);movie.completion!!(movie)
|
||||||
|
TestScheduler.until(10_000) {rig.socket.sent.any {it.optString("type")=="action.status" && it.optString("action_id")==id && it.optString("status")=="completed"}}
|
||||||
|
check(movie.released && rig.binding.currentPackageId=="neutral")
|
||||||
|
val status=rig.socket.sent.last {it.optString("type")=="action.status"}
|
||||||
|
check(status.optBoolean("mic_stopped") && status.optBoolean("video_ended") && status.optBoolean("audio_stopped") && status.optBoolean("idle_restored"))
|
||||||
|
val previous=rig.turn;rig.turn++
|
||||||
|
rig.event("abort",rig.turn,mapOf("reason" to "action_followup"));rig.event("speech.start",rig.turn,mapOf("origin" to "after_action"));TestScheduler.advanceBy(0)
|
||||||
|
rig.playAndDrain();val before=AudioPlayback.enqueued;rig.pcm(previous);TestScheduler.advanceBy(0);check(AudioPlayback.enqueued==before)
|
||||||
|
println("WS_DANCE_AFTER|pending=$pending|asset=${status.optString("asset_id")}|capture_ack=true|native_audio_end=true|restored_actual_A=true|after_turn=${rig.turn}|after_drained=true|old_pcm_rejected=true")
|
||||||
|
}
|
||||||
|
rig.close()
|
||||||
|
}
|
||||||
|
for(exit in listOf("complete","cancel","background")) {
|
||||||
|
TestScheduler.reset();val rig=WaitingRig(pack);AudioCapture.confirmStopsAutomatically=false
|
||||||
|
TestScheduler.until(90_000) {rig.state.waitingPoseActive}
|
||||||
|
check(rig.trace.none {it.second.actual.startsWith("pose_")})
|
||||||
|
val ack=checkNotNull(AudioCapture.lastStopped);val lateMic=checkNotNull(AudioCapture.lastFrame)
|
||||||
|
val audio=AudioPlayback.enqueued;val uplink=rig.socket.audioFrames;val oldTurn=rig.turn
|
||||||
|
lateMic(ByteArray(640));rig.pcm();rig.event("tts",rig.turn,mapOf("state" to "done"));rig.event("listen",rig.turn+1,mapOf("state" to "start"));TestScheduler.advanceBy(100)
|
||||||
|
check(rig.socket.audioFrames==uplink && AudioPlayback.enqueued==audio)
|
||||||
|
ack(true);TestScheduler.until(1000) {rig.trace.any {it.second.actual.startsWith("pose_")}}
|
||||||
|
repeat(40) {lateMic(ByteArray(640));rig.pcm(oldTurn)};TestScheduler.advanceBy(100)
|
||||||
|
check(rig.socket.audioFrames==uplink && AudioPlayback.enqueued==audio && rig.state.voiceIndicator==VoiceIndicatorState.IDLE)
|
||||||
|
when(exit) {
|
||||||
|
"complete"->{TestScheduler.until(10_000) {!rig.state.waitingPoseActive};AudioCapture.confirmStopsAutomatically=true;TestScheduler.advanceBy(1000);check(rig.state.voiceIndicator==VoiceIndicatorState.LISTENING)}
|
||||||
|
"cancel"->{rig.session.stopVoice();TestScheduler.advanceBy(1000);check(!rig.state.voiceActive && !rig.state.waitingPoseActive)}
|
||||||
|
"background"->{rig.session.background();rig.view.render(false);TestScheduler.advanceBy(1000);check(!rig.state.voiceActive && rig.socket.cancelled)}
|
||||||
|
}
|
||||||
|
ack(true);rig.pcm(oldTurn);TestScheduler.advanceBy(0);check(AudioPlayback.enqueued==audio)
|
||||||
|
if(exit!="complete") {
|
||||||
|
val oldSocket=rig.socket;val oldListener=rig.listener
|
||||||
|
AudioCapture.confirmStopsAutomatically=true
|
||||||
|
val before=rig.trace.size
|
||||||
|
if(exit=="cancel") rig.session.startVoice() else rig.returnFromBackground()
|
||||||
|
TestScheduler.until(90_000) {rig.trace.drop(before).any {it.second.actual=="pose_suit-adjust" || it.second.actual=="pose_knuckle-check"}}
|
||||||
|
check(rig.trace.drop(before).any {it.second.actual=="pose_suit-adjust" || it.second.actual=="pose_knuckle-check"})
|
||||||
|
if(exit=="background") {
|
||||||
|
oldListener.onMessage(oldSocket,"""{"type":"tts","state":"start","turn_id":$oldTurn}""")
|
||||||
|
TestScheduler.advanceBy(0);check(AudioPlayback.enqueued==audio)
|
||||||
|
}
|
||||||
|
TestScheduler.until(10_000) {!rig.state.waitingPoseActive}
|
||||||
|
TestScheduler.until(1_000) {rig.state.voiceIndicator==VoiceIndicatorState.LISTENING}
|
||||||
|
check(rig.state.voiceActive && rig.state.voiceIndicator==VoiceIndicatorState.LISTENING)
|
||||||
|
}
|
||||||
|
println("POSE_FENCES|exit=$exit|delayed_capture_ack=true|before_ack_pose_frames=0|late_mic_tts_listen_rejected=true|actual_restore=true|reschedules_after_restart=${exit!="complete"}|device=false")
|
||||||
|
rig.close()
|
||||||
|
}
|
||||||
|
println("PASS: actual APK production session/protocol/View/renderer 120s four-way waiting, dedicated TALK, delayed recorder ACK, old callback/cancel/background, ready+pending HELLO, both dance/completed/after_action; Android audio/codec/EGL/server doubled, no live inference")
|
||||||
|
}
|
||||||
@@ -30,14 +30,20 @@ fun checkWaitingPoseSession() {
|
|||||||
fun event(kind:EventKind,action:String,turn:Long=7)=ev.invoke(session,ServerEvent(kind.name.lowercase(),kind,Payload(turn=turn,state=action,reason=if(kind==EventKind.ABORT) "listen_start" else "")))
|
fun event(kind:EventKind,action:String,turn:Long=7)=ev.invoke(session,ServerEvent(kind.name.lowercase(),kind,Payload(turn=turn,state=action,reason=if(kind==EventKind.ABORT) "listen_start" else "")))
|
||||||
val fm=session.javaClass.getDeclaredMethod("onFrame",DownlinkFrame::class.java).apply { isAccessible=true }
|
val fm=session.javaClass.getDeclaredMethod("onFrame",DownlinkFrame::class.java).apply { isAccessible=true }
|
||||||
session.startVoice();event(EventKind.LISTEN,"start")
|
session.startVoice();event(EventKind.LISTEN,"start")
|
||||||
|
check(session.runtimeProtocolState.contains("waiting_enabled=true"));assertions++
|
||||||
|
session.setMicrophoneMuted(true)
|
||||||
|
check(session.runtimeProtocolState.contains("waiting_block=muted"));assertions++
|
||||||
|
session.setMicrophoneMuted(false)
|
||||||
field("lastSpeechAt").setLong(session,0)
|
field("lastSpeechAt").setLong(session,0)
|
||||||
checkNotNull(AudioCapture.lastFrame)(ByteArray(640));Handler.drain()
|
checkNotNull(AudioCapture.lastFrame)(ByteArray(640));Handler.drain()
|
||||||
check(player.eligible);assertions++
|
check(player.eligible);assertions++
|
||||||
|
check(session.runtimeProtocolState.contains("waiting_block=ready"));assertions++
|
||||||
AudioCapture.confirmStopsAutomatically=false
|
AudioCapture.confirmStopsAutomatically=false
|
||||||
val lateMic=checkNotNull(AudioCapture.lastFrame);val beforeUp=DialogueProtocol.uplinks.size;val beforeAudio=AudioPlayback.enqueued
|
val lateMic=checkNotNull(AudioCapture.lastFrame);val beforeUp=DialogueProtocol.uplinks.size;val beforeAudio=AudioPlayback.enqueued
|
||||||
player.offer(pose)
|
player.offer(pose)
|
||||||
val ack=checkNotNull(AudioCapture.lastStopped)
|
val ack=checkNotNull(AudioCapture.lastStopped)
|
||||||
check(player.plays==0 && states.last().waitingPoseActive && states.last().voiceIndicator==VoiceIndicatorState.IDLE);assertions++
|
check(player.plays==0 && states.last().waitingPoseActive && states.last().voiceIndicator==VoiceIndicatorState.IDLE);assertions++
|
||||||
|
check(session.runtimeProtocolState.contains("waiting_block=blocked_turn"));assertions++
|
||||||
lateMic(ByteArray(640));fm.invoke(session,DownlinkFrame(7));event(EventKind.TTS,"start");event(EventKind.TTS,"done");event(EventKind.LISTEN,"start",8);Handler.drain()
|
lateMic(ByteArray(640));fm.invoke(session,DownlinkFrame(7));event(EventKind.TTS,"start");event(EventKind.TTS,"done");event(EventKind.LISTEN,"start",8);Handler.drain()
|
||||||
check(DialogueProtocol.uplinks.size==beforeUp && AudioPlayback.enqueued==beforeAudio && states.last().turnId==7L);assertions++
|
check(DialogueProtocol.uplinks.size==beforeUp && AudioPlayback.enqueued==beforeAudio && states.last().turnId==7L);assertions++
|
||||||
if(exit=="timeout") {
|
if(exit=="timeout") {
|
||||||
|
|||||||
Reference in New Issue
Block a user