Add bounded avatar rejection fields and task music ASR audit
This commit is contained in:
@@ -33,6 +33,12 @@ fun conversationPackageCheck() {
|
||||
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)
|
||||
val rejectFields=mutableListOf<String>()
|
||||
val badCursor=meta+("edges" to listOf(graph[0]+("toPtsUs" to 1L))+graph.drop(1))
|
||||
check(EmotionActionManifest.read(badCursor,pin,pin,onReject=rejectFields::add) { path,hash ->
|
||||
packs[path.substringBefore('/')]?.takeIf { it.manifestSha==hash }
|
||||
}==null)
|
||||
check(rejectFields==listOf("edges[0].toPtsUs"))
|
||||
var rejected=0
|
||||
fun invalid(change: Map<String,Any?>) { check(read(meta+change)==null);rejected++ }
|
||||
invalid(mapOf("edges" to graph.filterNot { it["id"]=="sad-neutral" }))
|
||||
|
||||
@@ -71,6 +71,14 @@ fun dynamicBodyCheck() {
|
||||
invalid(root+("patches" to listOf(patches[0]+("levels" to listOf(levels[0],levels[1]+("path" to levels[0]["path"]))+levels.drop(2)))+patches.drop(1)))
|
||||
val states=root["mouthStates"] as List<Map<String,Any?>>
|
||||
invalid(root+("mouthStates" to listOf(states[0]+("ptsUs" to listOf(0L)))+states.drop(1)))
|
||||
for((stateIndex,key,value) in listOf(Triple(1,"frameCount",count),Triple(2,"ptsUs",listOf(0L)))) {
|
||||
val changed=states.mapIndexed { i,s -> if(i==stateIndex) s+(key to value) else s }
|
||||
val fields=mutableListOf<String>()
|
||||
check(ContinuousAvatarManifest.read(root+("mouthStates" to changed),sha,sha,true,"fixture/",fields::add)==null)
|
||||
check(fields==listOf("mouthStates[$stateIndex].$key"));boundaries++
|
||||
}
|
||||
val acceptedFields=mutableListOf<String>()
|
||||
check(ContinuousAvatarManifest.read(root,sha,sha,true,"fixture/",acceptedFields::add)!=null && acceptedFields.isEmpty())
|
||||
check(runCatching { ContinuousFramePresenter(pack).decoded(pack.body.ptsUs[1]) }.isFailure)
|
||||
check(runCatching { selectMouthPatch(pack,count,.5f) }.isFailure)
|
||||
if(fpsD==1) {
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
"""Actual parser field reports and finite WAV transport; no model calls or asset mutation."""
|
||||
import copy
|
||||
import importlib.util
|
||||
import io
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import unittest
|
||||
import wave
|
||||
|
||||
ROOT=Path(__file__).resolve().parents[2]
|
||||
sys.path.insert(0,str(Path(__file__).parent))
|
||||
import test_emotion_package as fixture
|
||||
|
||||
def load(name,path):
|
||||
spec=importlib.util.spec_from_file_location(name,ROOT/path)
|
||||
module=importlib.util.module_from_spec(spec);spec.loader.exec_module(module);return module
|
||||
|
||||
diagnostic=load('diagnostic','scripts/diagnose-avatar-candidate.py')
|
||||
music=load('music_probe','scripts/probe-task-music-asr.py')
|
||||
|
||||
|
||||
class DiagnosticTests(unittest.TestCase):
|
||||
def test_actual_curve_reject_and_bounded_artifact(self):
|
||||
fixture.PackageTests.setUpClass()
|
||||
try:
|
||||
runtime=copy.deepcopy(fixture.PackageTests.runtime)
|
||||
runtime['mouthStates'][0]['frameCount']=97
|
||||
runtime['mouthStates'][0]['ptsUs']=runtime['body']['ptsUs']
|
||||
path=fixture.PackageTests.source/'neutral/manifest.json';path.write_text(json.dumps(runtime))
|
||||
index=copy.deepcopy(fixture.PackageTests.index)
|
||||
index['conversationPackages'][0]['runtimeManifest']['sha256']=diagnostic.pack.file_sha(path)
|
||||
fixture.PackageTests.manifest.write_text(json.dumps(index))
|
||||
report=diagnostic.diagnose(fixture.PackageTests.manifest,diagnostic.pack.file_sha(fixture.PackageTests.manifest),fixture.PackageTests.base/'diagnostic')
|
||||
self.assertEqual(report['status'],'rejected');self.assertEqual(report['production_metadata'],'rejected')
|
||||
self.assertIn({'file':'neutral/manifest.json','field':'mouthStates[0].frameCount','code':'production_metadata_rejected'},report['rejects'])
|
||||
self.assertTrue(any(r['code']=='curve_pts_count_mismatch' for r in report['rejects']))
|
||||
self.assertLessEqual(len(report['rejects']),128);self.assertFalse(report['dance_available'])
|
||||
self.assertEqual(runtime,json.loads(path.read_bytes()))
|
||||
with self.assertRaises(ValueError):
|
||||
diagnostic.diagnose(fixture.PackageTests.manifest,'0'*64,fixture.PackageTests.base/'wrong-hash')
|
||||
self.assertFalse((fixture.PackageTests.base/'wrong-hash').exists())
|
||||
with self.assertRaises(ValueError):
|
||||
diagnostic.diagnose(fixture.PackageTests.manifest,diagnostic.pack.file_sha(fixture.PackageTests.manifest),fixture.PackageTests.source/'owner-output')
|
||||
self.assertFalse((fixture.PackageTests.source/'owner-output').exists())
|
||||
finally:fixture.PackageTests.tearDownClass()
|
||||
|
||||
def test_music_finite_wav_header_and_full_payload(self):
|
||||
pcm=b'\x01\x00'*160085
|
||||
with wave.open(io.BytesIO(music.finite_wav(pcm))) as wav:
|
||||
self.assertEqual((wav.getframerate(),wav.getnchannels(),wav.getsampwidth()),(16000,1,2))
|
||||
self.assertEqual(wav.getnframes(),160085)
|
||||
self.assertEqual(wav.readframes(wav.getnframes()),pcm)
|
||||
for invalid in (b'',b'x',b'\0'*(16000*15*2+2)):
|
||||
with self.subTest(size=len(invalid)),self.assertRaises(ValueError):music.finite_wav(invalid)
|
||||
|
||||
|
||||
if __name__=='__main__':unittest.main(verbosity=2)
|
||||
Reference in New Issue
Block a user