Integrate reviewed full action pack admission and bounded idle scheduling

This commit is contained in:
zenord
2026-10-13 07:19:34 +08:00
parent 97f87e2409
commit f0620ddd65
21 changed files with 285 additions and 75 deletions
+16 -4
View File
@@ -28,11 +28,13 @@ fun idleVariantCheck() {
override fun close(released: ()->Unit) { released() }
}
val ports=mutableListOf<Port>();val trace=mutableListOf<String>()
val driver=ConversationMediaDriver(index,{ Port().also(ports::add) },music,{}, { phase,_->trace.add(phase) },chooseIdle={0})
val driver=ConversationMediaDriver(index,{ Port().also(ports::add) },music,{}, { phase,_->trace.add(phase) },chooseIdle={0},chooseIdleCycles={2})
driver.beginTurn(7);driver.start();val fallback=ports.single()
(0..95).forEach { fallback.emit(it) }
check(ports.size==1);checks++ // No arbitrary phase departure.
fallback.emit(96);check(ports.size==3 && trace.contains("idle_variant_queued"));checks++
fallback.emit(96);check(ports.size==1);checks++
(0..95).forEach { fallback.emit(it,1) };check(ports.size==1);checks++
fallback.emit(96,1);check(ports.size==3 && trace.contains("idle_variant_queued"));checks++
fun bridgeTo(target: Port,bridge: Port) {
target.emit(0);bridge.emit(0)
check(trace.last()=="bridge" && !bridge.loop);checks++
@@ -42,9 +44,13 @@ fun idleVariantCheck() {
val idle1=ports[1];bridgeTo(idle1,ports[2])
check(driver.currentPackageId=="happy" && driver.visualStatus=="neutral_idle_variant");checks++
(1 until idle1.pack.body.frameCount).forEach { idle1.emit(it) }
check(ports.size==3);checks++
(0 until idle1.pack.body.frameCount).forEach { idle1.emit(it,1) }
check(trace.contains("idle_variant_return_queued") && ports.size==5);checks++
val returned=ports[3];bridgeTo(returned,ports[4])
(1..96).forEach { returned.emit(it) }
check(ports.size==5);checks++
(0..96).forEach { returned.emit(it,1) }
val idle2=ports[5];bridgeTo(idle2,ports[6])
check(driver.currentPackageId=="sad");checks++ // Pick0 still excludes previous idle1.
driver.intent(mediaReply(RoleEmotion.NEUTRAL),true)
@@ -57,15 +63,21 @@ fun idleVariantCheck() {
driver.stop {};val count=trace.size
idle2.emit(0);ports[8].ended();check(trace.size==count && ports.all { it.closed });checks++
val three=mutableListOf<Port>()
val slow=ConversationMediaDriver(index,{ Port().also(three::add) },music,{},chooseIdle={0},chooseIdleCycles={3})
slow.beginTurn(7);slow.start()
repeat(2) { cycle -> (0..96).forEach { three[0].emit(it,cycle.toLong()) };check(three.size==1);checks++ }
(0..95).forEach { three[0].emit(it,2) };check(three.size==1);checks++
three[0].emit(96,2);check(three.size==3);checks++;slow.stop {}
// Missing bridge mouth prevents idle activation even with valid own body layers.
val noMouth=index.copy(edges=index.edges.map { if(it.nativeLoop) it else it.copy(mouthRuntime=null) })
val guarded=mutableListOf<Port>()
val other=ConversationMediaDriver(noMouth,{ Port().also(guarded::add) },music,{},chooseIdle={0})
val other=ConversationMediaDriver(noMouth,{ Port().also(guarded::add) },music,{},chooseIdle={0},chooseIdleCycles={2})
other.beginTurn(7);other.start();(0..96).forEach { guarded[0].emit(it) }
check(guarded.size==1);checks++;other.stop {}
// A retained happy/sad expression must not turn neutral when speech ends.
val expressive=mutableListOf<Port>()
val retained=ConversationMediaDriver(base,{ Port().also(expressive::add) },music,{},chooseIdle={0})
val retained=ConversationMediaDriver(base,{ Port().also(expressive::add) },music,{},chooseIdle={0},chooseIdleCycles={2})
retained.beginTurn(7);retained.start();retained.intent(mediaReply(RoleEmotion.HAPPY),false)
(0..96).forEach { expressive[0].emit(it) };expressive[1].emit(0);expressive[2].emit(0)
expressive[2].emit(1);expressive[2].emit(2);expressive[2].ended()