import com.gorios.lanvoice.avatar.* import com.gorios.lanvoice.dialogue.RoleEmotion /** Synthetic metadata invokes production admission/routing, never asset approval. */ @Suppress("UNCHECKED_CAST") fun conversationPackageCheck() { val pin="b".repeat(64) val packs=linkedMapOf("neutral" to dynamicPack(97,24,"c".repeat(64)), "happy" to dynamicPack(121,30,"d".repeat(64)),"sad" to dynamicPack(49,24,"e".repeat(64))) fun row(id: String,pack: ContinuousAvatarPack)=mapOf("id" to id, "emotion" to if(id=="neutral") "neutral" else if(id=="sad") "sad" else "happy", "visualIntensity" to if(id=="neutral") 0 else 1,"mouthBodySha256" to pack.body.sha256, "runtimeManifest" to mapOf("path" to "$id/manifest.json","sha256" to pack.manifestSha), "entryAnchor" to "A","exitAnchor" to "A","legalExitFrames" to listOf(pack.body.frameCount-1),"loopEdge" to "$id-loop") val clip=mapOf("path" to "clips/bridge.mp4","sha256" to pin,"hasAudio" to false, "width" to 480,"height" to 848,"fpsNumerator" to 24,"fpsDenominator" to 1, "frameCount" to 12,"ptsUs" to List(12) { it*1_000_000L/24 },"durationUs" to 500_000L) fun edges(data: Map): List> { fun edge(id: String,from: String,to: String)=mapOf("id" to id,"from" to from,"to" to to, "fromAnchor" to "A","toAnchor" to "A","fromFrame" to data.getValue(from).body.frameCount-1,"toFrame" to 0, "fromPtsUs" to data.getValue(from).body.ptsUs.last(),"toPtsUs" to 0L,"clip" to clip) return data.keys.map { edge("$it-loop",it,it) }+data.keys.filter { it!="neutral" }.flatMap { listOf(edge("neutral-$it","neutral",it),edge("$it-neutral",it,"neutral")) } } fun root(data: Map)=mapOf("schemaVersion" to 2,"identityId" to "a01", "packId" to "a01-expression-action-v1","fallbackPackageId" to "neutral", "conversationPackages" to data.map { row(it.key,it.value) },"edges" to edges(data),"actions" to emptyList()) fun read(meta: Map,data: Map = packs)=EmotionActionManifest.read(meta,pin,pin) { path,hash -> data[path.substringBefore('/')]?.takeIf { it.manifestSha==hash } } val meta=root(packs);val index=checkNotNull(read(meta)) check(index.packages.values.map { it.body.frameCount }==listOf(97,121,49) && index.actionPack==null) check(index.edges.size==7 && index.edges.all { it.clip.ptsUs.size==12 && it.clip.sha256==pin }) val graph=edges(packs) var rejected=0 fun invalid(change: Map) { check(read(meta+change)==null);rejected++ } invalid(mapOf("edges" to graph.filterNot { it["id"]=="sad-neutral" })) for(change in listOf(mapOf("fromFrame" to 1),mapOf("fromPtsUs" to 99L),mapOf("toPtsUs" to 1L), mapOf("toFrame" to 49),mapOf("clip" to clip+("hasAudio" to true)), mapOf("clip" to clip+("frameCount" to 4_294_967_308L)),mapOf("clip" to clip+("fpsNumerator" to 4_294_967_320L)), mapOf("clip" to clip+("path" to "../bridge.mp4")),mapOf("clip" to clip+("ptsUs" to listOf(0L))))) { invalid(mapOf("edges" to listOf(graph[0]+change)+graph.drop(1))) } val rows=packs.map { row(it.key,it.value) } for(change in listOf(mapOf("mouthBodySha256" to pin),mapOf("emotion" to "angry"),mapOf("emotion" to "curious"), mapOf("visualIntensity" to 2))) invalid(mapOf("conversationPackages" to listOf(rows[0],rows[1]+change,rows[2]))) val largeRoot=dynamicRuntimeFixture(100,24,1,"f".repeat(64)) val largePatches=(largeRoot["patches"] as List>).map { it+mapOf("width" to 80,"height" to 44) } val large=checkNotNull(ContinuousAvatarManifest.read(largeRoot+("patches" to largePatches),"f".repeat(64),"f".repeat(64),true,"large/")) check(large.rgbaBytes