Files
baji-vc/tests/avatar/EngineeringCheck.kt
T
zenord 9ea5eb31c1 feat: deliver clean avatar home in 0.6.2 UI debug candidate
Keep the avatar mounted while all connection, permission, privacy and diagnostic controls live in a settings sheet. Save the tested continuous-body renderer, safe transition driver and foreground HELLO/permission workflow from this session. Pin runtime03 for the code14 UI-only candidate; mouth deformation remains unresolved. Add source UI contracts, an optional sensor-free device probe, exact asset import and candidate packaging checks. Portrait binaries and diagnostics remain private and untracked.
2026-10-12 22:19:56 +08:00

70 lines
4.9 KiB
Kotlin

import com.gorios.lanvoice.avatar.*
private class TestPort : AnchorVideoPort {
private lateinit var listener: AnchorVideoPort.Listener
private var held: DisplayedVideoFrame? = null
private var serial=0L
override fun prepare(clip: SafeAvatarClip, entry: AnchorInterval, listener: AnchorVideoPort.Listener) { this.listener=listener }
fun frame(ms: Long, index: Int) { held=DisplayedVideoFrame(ms,index,0,++serial); listener.frame(checkNotNull(held)) }
override fun displayed()=held
override fun advance() { held=null }
override fun close() { held=null }
}
fun engineeringFixture(): Map<String,Any?> {
val ids=listOf("idle","opening","talk1","talk2","end-talk")
val rows=ids.map { id ->
val bridge=id in setOf("opening","end-talk")
mapOf("id" to id,"path" to "controlled-01/delivery/$id.mp4","frameCount" to if(bridge) 6 else 12,
"durationMs" to if(bridge) 250.0 else 500.0,"fpsNumerator" to 24,"fpsDenominator" to 1,
"width" to 480,"height" to 848,"hasAudio" to false,
"entryAnchor" to if(id in setOf("idle","opening")) "A" else "B",
"exitAnchor" to if(id in setOf("idle","end-talk")) "A" else "B")
}
val pairs=listOf("idle" to "idle","idle" to "opening","opening" to "talk1","opening" to "talk2",
"opening" to "end-talk","talk1" to "talk1","talk1" to "talk2","talk2" to "talk1",
"talk2" to "talk2","talk1" to "end-talk","talk2" to "end-talk","end-talk" to "idle")
return mapOf("schemaVersion" to 1,"packId" to "a01-neutral-graph-v1-controlled-01","identityId" to "a01",
"publishApproval" to false,"naturalQualityStatus" to "not_approved",
"safeTransitions" to mapOf("version" to 1,"reviewStatus" to "pending","transitions" to emptyList<Any>()),"assets" to rows,
"candidateGraph" to mapOf("exitPolicy" to "complete_candidate_node_at_shared_rendered_anchor",
"earliestExitFrames" to ids.associateWith { if(it in setOf("opening","end-talk")) 5 else 11 },
"edges" to pairs.map { (s,t) -> mapOf("source" to s,"target" to t,"anchor" to if(s in setOf("idle","end-talk")) "A" else "B") }))
}
@Suppress("UNCHECKED_CAST")
fun checkEngineering() {
val root=engineeringFixture(); val hash=EngineeringGraphAdmission.MANIFEST_SHA
check(EngineeringGraphAdmission.read(root,hash,false)==null)
check(EngineeringGraphAdmission.read(root,"0".repeat(64),true)==null)
val graph=checkNotNull(EngineeringGraphAdmission.read(root,hash,true))
check(graph.review==AnchorReview.TECHNICAL_DEBUG && NeutralGraphContract.missing(graph).isEmpty())
check(graph.clips.values.all { it.mouthStateWindows.isEmpty() })
check(NeutralGraphContract.missing(graph.copy(review=AnchorReview.APPROVED)).isNotEmpty())
check(!graph.copy(review=AnchorReview.APPROVED).approved(graph.edges.first()))
check(SafeAvatarManifest.read(root,hash,setOf(hash)).status==SafetyManifestStatus.REVIEW_PENDING)
for(edge in graph.edges) check(NeutralGraphContract.missing(graph.copy(edges=graph.edges-edge)).isNotEmpty() || edge.source=="opening" && edge.target=="end-talk")
val candidate=root["candidateGraph"] as Map<String,Any?>
fun changed(c: Map<String,Any?>) = EngineeringGraphAdmission.read(root+("candidateGraph" to (candidate+c)),hash,true)
check(changed(mapOf("earliestExitFrames" to mapOf("idle" to 10)))==null)
check(changed(mapOf("edges" to (candidate["edges"] as List<*>).drop(1)))==null)
check(changed(mapOf("exitPolicy" to "force_cut"))==null)
val assets=root["assets"] as List<Map<String,Any?>>
for(change in listOf(mapOf("path" to "../other.mp4"),mapOf("hasAudio" to true),mapOf("durationMs" to 500.5),mapOf("entryAnchor" to "B")))
check(EngineeringGraphAdmission.read(root+("assets" to listOf(assets.first()+change)+assets.drop(1)),hash,true)==null)
// Real driver with held-frame ports uses the exact technical graph, not a mock planner.
var now=0L; val created=mutableListOf<TestPort>(); val shown=mutableListOf<Int>()
val driver=SafeVideoDriver(graph,{ TestPort().also { created+=it } },{shown+=it},{},{now},{},chooseVariant={0})
driver.start(); created.first().frame(0,0)
driver.desire(SafeClipRole.TALK,1)
created.last().frame(0,0)
created.first().frame(417,10); check(shown.size==1)
now=458; created.first().frame(458,11); check(shown.size==2 && driver.sample().clipId=="opening")
driver.stop(); check(driver.sample().mouthActiveLagMs==null)
check(OfflineAvatarTrace.at(0).mode==AvatarMode.IDLE)
check(OfflineAvatarTrace.at(1200).mode==AvatarMode.TALK)
check(OfflineAvatarTrace.at(7100).mode==AvatarMode.IDLE)
check(OfflineAvatarTrace.at(12500).generation>OfflineAvatarTrace.at(12499).generation)
check(OfflineAvatarTrace.at(20000).generation>OfflineAvatarTrace.at(19999).generation)
println("PASS: pinned debug-only admission, production pending preserved, last-frame gates, all edges, no forged perceived mouth evidence, offline synthetic reversal/abort generations")
}