Validate isolated public action followup calling path
This commit is contained in:
@@ -13,6 +13,7 @@ fun main() {
|
||||
actualMediaViewCheck()
|
||||
mediaBoundaryCheck()
|
||||
idleVariantCheck()
|
||||
fullActionGraphCheck()
|
||||
checkContinuous()
|
||||
checkEngineering()
|
||||
checkSafeDriver()
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import com.gorios.lanvoice.avatar.*
|
||||
|
||||
/** Expected five bodies/eight TALK bridges/two dances, synthetic metadata only. */
|
||||
fun fullActionGraphCheck() {
|
||||
val pin="b".repeat(64)
|
||||
val bodies=listOf("neutral","happy","sad","idle-breathe","idle-shift").associateWith { id->
|
||||
val sha=java.security.MessageDigest.getInstance("SHA-256").digest(id.toByteArray()).joinToString("") { "%02x".format(it) }
|
||||
dynamicPack(if(id=="sad") 49 else 97,24,sha)
|
||||
}
|
||||
fun clip(pack: ContinuousAvatarPack,path: String,audio: Boolean=false)=mapOf<String,Any?>(
|
||||
"path" to path,"sha256" to pack.body.sha256,"width" to 480,"height" to 848,"hasAudio" to audio,
|
||||
"frameCount" to pack.body.frameCount,"ptsUs" to pack.body.ptsUs,"durationUs" to pack.body.durationUs,
|
||||
"fpsNumerator" to pack.body.fpsNumerator,"fpsDenominator" to pack.body.fpsDenominator)
|
||||
val rows=bodies.map { (id,body)->mapOf<String,Any?>("id" to id,
|
||||
"emotion" to if(id.startsWith("idle")) "neutral" else id,"visualIntensity" to if(id in setOf("happy","sad")) 1 else 0,
|
||||
"mouthBodySha256" to body.body.sha256,"runtimeManifest" to mapOf("path" to "$id/manifest.json","sha256" to body.manifestSha),
|
||||
"entryAnchor" to "A","exitAnchor" to "A","legalExitFrames" to listOf(body.body.frameCount-1),"loopEdge" to "$id-loop") }
|
||||
val mouths=linkedMapOf<String,ContinuousAvatarPack>()
|
||||
val loops=bodies.map { (id,body)->mapOf<String,Any?>("id" to "$id-loop","from" to id,"to" to id,
|
||||
"fromFrame" to body.body.frameCount-1,"fromPtsUs" to body.body.ptsUs.last(),"toFrame" to 0,"toPtsUs" to 0L,
|
||||
"fromAnchor" to "A","toAnchor" to "A","nativeLoop" to true,"clip" to clip(body,"$id/body.mp4")) }
|
||||
val bridges=bodies.keys.filter { it!="neutral" }.flatMap { id->listOf("neutral" to id,id to "neutral").map { (from,to)->
|
||||
val name="$from-$to";val sha=java.security.MessageDigest.getInstance("SHA-256").digest(name.toByteArray()).joinToString("") { "%02x".format(it) }
|
||||
val own=dynamicPack(25,24,sha);mouths[name]=own
|
||||
mapOf<String,Any?>("id" to name,"from" to from,"to" to to,"fromFrame" to bodies.getValue(from).body.frameCount-1,
|
||||
"fromPtsUs" to bodies.getValue(from).body.ptsUs.last(),"toFrame" to 0,"toPtsUs" to 0L,"fromAnchor" to "A","toAnchor" to "A",
|
||||
"mouthAllowed" to true,"mouthRuntimeManifest" to mapOf("path" to "$name/manifest.json","sha256" to own.manifestSha),
|
||||
"clip" to clip(own,"$name/body.mp4"))
|
||||
} }
|
||||
val dance=dynamicPack(241,24,"f".repeat(64))
|
||||
val actions=listOf("asset_01","asset_02").map { id->mapOf<String,Any?>("id" to id,"kind" to "dance",
|
||||
"mouthAllowed" to false,"disallowTALK" to true,"entryAnchor" to "A","returnAnchor" to "A",
|
||||
"sourcePackageId" to "neutral","sourceFrame" to 96,"sourcePtsUs" to 4_000_000L,
|
||||
"returnPackageId" to "neutral","returnFrame" to 0,"returnPtsUs" to 0L,
|
||||
"clip" to clip(dance,"$id.mp4",true),"audioEndUs" to 10_000_000L) }
|
||||
val root=mapOf<String,Any?>("schemaVersion" to 2,"identityId" to "a01","packId" to "a01-expression-action-v1",
|
||||
"fallbackPackageId" to "neutral","conversationPackages" to rows,"edges" to loops+bridges,"actions" to actions)
|
||||
fun read(meta: Map<String,Any?> = root,bodyData: Map<String,ContinuousAvatarPack> = bodies,
|
||||
bridgeData: Map<String,ContinuousAvatarPack> = mouths)=EmotionActionManifest.read(meta,pin,pin) { path,hash->
|
||||
(bodyData[path.substringBefore('/')] ?: bridgeData[path.substringBefore('/')])?.takeIf { it.manifestSha==hash }
|
||||
}
|
||||
val index=checkNotNull(read());var assertions=0
|
||||
check(index.packages.size==5 && index.edges.size==13 && index.edges.count { it.mouthRuntime!=null }==8);assertions++
|
||||
check(index.actionPack?.assets?.size==2 && index.actionPack.assets.all { it.media?.ptsUs?.size==241 });assertions++
|
||||
val bytes=index.packages.values.sumOf { it.rgbaBytes }+index.edges.mapNotNull { it.mouthRuntime }.sumOf { it.rgbaBytes }
|
||||
check(bytes==bodies.values.sumOf { it.rgbaBytes }+mouths.values.sumOf { it.rgbaBytes } && bytes<=BodyTimeline.MAX_PACK_CACHE_BYTES);assertions++
|
||||
for(change in listOf(mapOf("sourceFrame" to 0),mapOf("sourcePtsUs" to 0L),mapOf("returnPtsUs" to 1L),
|
||||
mapOf("sourcePackageId" to "idle-breathe"),mapOf("returnPackageId" to "idle-shift"))) {
|
||||
check(read(root+("actions" to listOf(actions[0]+change,actions[1])))==null);assertions++
|
||||
}
|
||||
for(name in mouths.keys) {
|
||||
val wrong=mouths.getValue(name).copy(body=mouths.getValue(name).body.copy(sha256=bodies.getValue("neutral").body.sha256))
|
||||
check(read(bridgeData=mouths+(name to wrong))==null);assertions++
|
||||
}
|
||||
val inflated=bodies.mapValues { (_,body)->body.copy(patches=body.patches.map { it.copy(width=80,height=44) }) }
|
||||
check(inflated.values.all { it.rgbaBytes<=BodyTimeline.MAX_RGBA_BYTES } && read(bodyData=inflated)==null);assertions++
|
||||
println("PASS: $assertions full5-body/13-edge/8-own-bridge/two241-frame-action parser assertions; RGBA=$bytes bytes, source96/4s/return binding and total-cache rejection; fixtures only")
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.gorios.lanvoice.avatar.*
|
||||
import com.gorios.lanvoice.net.*
|
||||
|
||||
fun checkActionSession() {
|
||||
checkActionFollowupSession()
|
||||
val sha="a".repeat(64);val states=mutableListOf<VoiceUiState>()
|
||||
val prepared=mutableListOf<com.gorios.lanvoice.dialogue.ReplyEmotion?>()
|
||||
var plays=0;var stopped=0;var ended: ((ActionEnd)->Unit)?=null
|
||||
@@ -54,3 +55,50 @@ fun checkActionSession() {
|
||||
session.release();AudioCapture.confirmStopsAutomatically=true
|
||||
println("PASS: actual VoiceSession action plan→capture cleanup fence→player, queued mic/downlink dropped, prepare-only/old-turn, no voice barge, background cancel; doubles only")
|
||||
}
|
||||
|
||||
/** Client consumes the same pre-turn→action→new after-turn order as the socket probe. */
|
||||
fun checkActionFollowupSession() {
|
||||
val sha="a".repeat(64);val states=mutableListOf<VoiceUiState>();var finish: ((ActionEnd)->Unit)?=null
|
||||
val player=object: ActionPlayer {
|
||||
override fun play(asset: ActionAsset,finished: (ActionEnd)->Unit,failed: ()->Unit) { finish=finished }
|
||||
override fun stop(released: ()->Unit) { released() }
|
||||
}
|
||||
val session=VoiceSession("localhost",5011,states::add,
|
||||
reviewedActionPack=ReviewedActionPack(sha,listOf(ActionAsset("asset_01",1000),ActionAsset("asset_02",1000))),actionPlayer=player)
|
||||
fun field(name: String)=session.javaClass.getDeclaredField(name).apply { isAccessible=true }
|
||||
val dialogue=field("dialogue").get(session) as DialogueClient
|
||||
val socket=FakeSocket();dialogue.setField("socket",socket);dialogue.setField("ready",true)
|
||||
field("foreground").set(session,true);field("state").set(session,VoiceUiState(connection=ConnectionStatus.CONNECTED))
|
||||
val method=session.javaClass.getDeclaredMethod("onEvent",ServerEvent::class.java).apply { isAccessible=true }
|
||||
fun event(type: String,kind: EventKind,turn: Long,fields: Map<String,Any> = emptyMap()) {
|
||||
method.invoke(session,ServerEvent(type,kind,Payload(turn=turn,state=fields["state"] as? String ?: "",
|
||||
reason=fields["reason"] as? String ?: "",fields=fields)))
|
||||
}
|
||||
val frame=session.javaClass.getDeclaredMethod("onFrame",DownlinkFrame::class.java).apply { isAccessible=true }
|
||||
session.startVoice();event("listen",EventKind.LISTEN,7,mapOf("state" to "start"))
|
||||
frame.invoke(session,DownlinkFrame(7));checkNotNull(AudioPlayback.lastDrained)(7,0);Handler.drain()
|
||||
event("action.plan",EventKind.ACTION,7,mapOf("action_id" to "y".repeat(24),"pack_sha256" to sha,"ttl_ms" to 10000L))
|
||||
Handler.drain();check(states.last().actionActive && finish!=null)
|
||||
event("reply.emotion",EventKind.REPLY_EMOTION,8,mapOf("seq" to 30L,"emotion" to "sad","intensity" to 2,"source" to "model"))
|
||||
check(states.last().replyEmotion.turnId==null) // No future after expression during ACTION.
|
||||
val controller=field("actions").get(session) as ActionController
|
||||
controller.javaClass.getDeclaredField("started").apply { isAccessible=true }.setLong(controller,android.os.SystemClock.elapsedRealtime()-1001)
|
||||
finish!!(ActionEnd(true,true,true));Handler.drain();check(!states.last().actionActive)
|
||||
event("abort",EventKind.ABORT,8,mapOf("reason" to "action_followup"))
|
||||
event("speech.start",EventKind.SPEECH,8,mapOf("origin" to "after_action"))
|
||||
event("tts",EventKind.TTS,8,mapOf("state" to "start"))
|
||||
event("reply.emotion",EventKind.REPLY_EMOTION,8,mapOf("seq" to 33L,"emotion" to "sad","intensity" to 2,"source" to "model"))
|
||||
check(states.last().replyEmotion.turnId==8L && states.last().replyEmotion.intensity==2)
|
||||
val before=AudioPlayback.enqueued;frame.invoke(session,DownlinkFrame(8))
|
||||
check(AudioPlayback.enqueued==before+1 && states.last().phase==VoicePhase.ANSWERING)
|
||||
frame.invoke(session,DownlinkFrame(7))
|
||||
event("reply.emotion",EventKind.REPLY_EMOTION,7,mapOf("seq" to 99L,"emotion" to "happy","intensity" to 1,"source" to "model"))
|
||||
check(AudioPlayback.enqueued==before+1 && states.last().replyEmotion.turnId==8L)
|
||||
AudioPlayback.activityFence={turn,_->turn==8L}
|
||||
checkNotNull(AudioPlayback.lastDrained)(7,0);Handler.drain();check(states.last().replyEmotion.turnId==8L)
|
||||
checkNotNull(AudioPlayback.lastDrained)(8,0);Handler.drain()
|
||||
check(states.last().replyEmotion.turnId==null && states.last().phase==VoicePhase.LISTENING)
|
||||
val messages=socket.sent.size;finish!!(ActionEnd(true,true,true));Handler.drain();check(socket.sent.size==messages)
|
||||
session.release();AudioPlayback.activityFence=null
|
||||
println("PASS: client normal action completion/new server speech turn accepted, future after emotion hidden, retired pre audio/emotion/drain rejected, independent after drain and duplicate completion fence; deterministic doubles only")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user