Integrate reviewed full action pack admission and bounded idle scheduling
This commit is contained in:
@@ -43,6 +43,16 @@ fun actionCheck() {
|
||||
now+=10001;controller.tick();release!!();check(statuses.last().status=="failed")
|
||||
check(controller.offer(plan(3)));confirm!!(false);release!!()
|
||||
check(statuses.last().status=="failed" && controller.active && picked.size==4)
|
||||
val repeated=mutableListOf<String>()
|
||||
var done: ((ActionEnd)->Unit)?=null
|
||||
val randomPlayer=object: ActionPlayer {
|
||||
override fun play(asset: ActionAsset,finished: (ActionEnd)->Unit,failed: ()->Unit) { repeated.add(asset.id);done=finished }
|
||||
override fun stop(released: ()->Unit) { released() }
|
||||
}
|
||||
val random=ActionController(pack,randomPlayer,{now},{it(true)},{},choose={it-1})
|
||||
check(random.offer(plan(20)));now+=1200;done!!(ActionEnd(true,true,true))
|
||||
check(random.offer(plan(21)));now+=1200;done!!(ActionEnd(true,true,true))
|
||||
check(repeated==listOf("asset_02","asset_02")) // Repeat is possible, not forced exact alternation.
|
||||
val missing=ActionController(null,player,{now},{confirm=it},{statuses.add(it)})
|
||||
check(missing.capability==null && !missing.offer(plan(5)))
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ fun fullActionGraphCheck() {
|
||||
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") }
|
||||
"entryAnchor" to "A","exitAnchor" to "A","legalExitFrames" to if(id=="neutral") listOf(0,96) else 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,
|
||||
@@ -30,8 +30,8 @@ fun fullActionGraphCheck() {
|
||||
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,
|
||||
"sourcePackageId" to "neutral","sourceFrame" to 0,"sourcePtsUs" to 0L,
|
||||
"returnPackageId" to "neutral","returnFrame" to 96,"returnPtsUs" to 4_000_000L,
|
||||
"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)
|
||||
@@ -44,7 +44,7 @@ fun fullActionGraphCheck() {
|
||||
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),
|
||||
for(change in listOf(mapOf("sourceFrame" to 95),mapOf("sourcePtsUs" to 1L),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++
|
||||
}
|
||||
@@ -54,5 +54,5 @@ fun fullActionGraphCheck() {
|
||||
}
|
||||
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")
|
||||
println("PASS: $assertions full5-body/13-edge/8-own-bridge/two241-frame-action parser assertions; RGBA=$bytes bytes, source0/return96/4s binding and total-cache rejection; fixtures only")
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -144,14 +144,14 @@ fun actualMediaViewCheck() {
|
||||
val (idleView,idleBinding,idleTrace)=rig(idleIndex)
|
||||
TestScheduler.advanceBy(3000)
|
||||
check(idleTrace.all { it.actual=="body_neutral" });cases++
|
||||
TestScheduler.until { idleBinding.currentPackageId in setOf("happy","sad") }
|
||||
TestScheduler.until(15_000) { idleBinding.currentPackageId in setOf("happy","sad") }
|
||||
val firstIdle=idleBinding.currentPackageId
|
||||
check(idleTrace.any { it.actual=="bridge" } && idleBinding.visualStatus=="neutral_idle_variant");cases++
|
||||
TestScheduler.until { idleBinding.currentPackageId=="neutral" }
|
||||
TestScheduler.until { idleBinding.currentPackageId in setOf("happy","sad") }
|
||||
TestScheduler.until(15_000) { idleBinding.currentPackageId=="neutral" }
|
||||
TestScheduler.until(15_000) { idleBinding.currentPackageId in setOf("happy","sad") }
|
||||
check(idleBinding.currentPackageId!=firstIdle && idleTrace.none { it.actual=="media_failed" });cases++
|
||||
idleBinding.intent(mediaReply(RoleEmotion.NEUTRAL),true)
|
||||
TestScheduler.until { idleBinding.currentPackageId=="neutral" }
|
||||
TestScheduler.until(15_000) { idleBinding.currentPackageId=="neutral" }
|
||||
val speechStart=idleTrace.size;TestScheduler.advanceBy(9000)
|
||||
check(idleTrace.drop(speechStart).all { it.actual=="body_neutral" });cases++
|
||||
val beforeDispose=idleTrace.size;idleView.dispose();TestScheduler.advanceBy(1000)
|
||||
|
||||
@@ -120,6 +120,16 @@ class PackageTests(unittest.TestCase):
|
||||
self.assertNotEqual(result.returncode,0);self.assertIn('read-only gate supported',result.stderr)
|
||||
self.assertFalse(out.exists())
|
||||
|
||||
def test_reviewed_full_admission_exact_duration_pin(self):
|
||||
index=self.dance_index();pin='a'*64;registry=self.base/'approved.json'
|
||||
registry.write_text(json.dumps({pin:{'asset_01':1000,'asset_02':1000}}))
|
||||
self.assertEqual(pack.reviewed_actions(index,pin,registry),{'asset_01':1000,'asset_02':1000})
|
||||
with self.assertRaisesRegex(ValueError,'pin/duration'): pack.reviewed_actions(index,'b'*64,registry)
|
||||
registry.write_text(json.dumps({pin:{'asset_01':999,'asset_02':1000}}))
|
||||
with self.assertRaisesRegex(ValueError,'pin/duration'): pack.reviewed_actions(index,pin,registry)
|
||||
index['actions'][0]['mouthAllowed']=True
|
||||
with self.assertRaisesRegex(ValueError,'dance shape'): pack.reviewed_actions(index,pin,registry)
|
||||
|
||||
def test_paths(self):
|
||||
for name in ('../x','x/../y','x//y','/x','x/./y','https://host/x','x\\y'):
|
||||
with self.subTest(name=name),self.assertRaises(ValueError): pack.relative(name)
|
||||
|
||||
Reference in New Issue
Block a user