Add bounded avatar rejection fields and task music ASR audit
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Bounded read-only rejection fields; does not import, approve, or replace the full gate."""
|
||||
from pathlib import Path
|
||||
import argparse
|
||||
import importlib.util
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
spec=importlib.util.spec_from_file_location('pack',ROOT/'scripts/package-avatar-emotion.py')
|
||||
pack=importlib.util.module_from_spec(spec);spec.loader.exec_module(pack)
|
||||
|
||||
|
||||
def diagnose(manifest,expected,output):
|
||||
manifest=Path(manifest).resolve(strict=True);output=Path(output).resolve()
|
||||
pack.require(not output.exists() and not output.is_relative_to(manifest.parent),'new evidence outside owner directory required')
|
||||
pack.require(pack.file_sha(manifest)==expected,'candidate index drift')
|
||||
index=pack.read_json(manifest);root=manifest.parent
|
||||
pack.require(1<=len(index['conversationPackages'])<=12 and len(index['edges'])<=100 and len(index['actions'])<=2,'diagnostic graph bounds')
|
||||
output.mkdir(parents=True)
|
||||
rejects=[];streams=[]
|
||||
def reject(file,field,code,**counts):
|
||||
if len(rejects)<128: rejects.append({'file':file,'field':field,'code':code,**counts})
|
||||
references=[row['runtimeManifest'] for row in index['conversationPackages']]
|
||||
references += [edge['mouthRuntimeManifest'] for edge in index['edges'] if 'mouthRuntimeManifest' in edge]
|
||||
for ref in references:
|
||||
try:
|
||||
path=pack.locate(root,ref['path'])
|
||||
pack.require(pack.file_sha(path)==ref['sha256'],'runtime hash drift')
|
||||
data=pack.read_json(path)
|
||||
for i,state in enumerate(data['mouthStates']):
|
||||
alpha=len(state['globalAlphaByFrame']);pts=len(state.get('ptsUs',[]))
|
||||
if state['frameCount']!=alpha:
|
||||
reject(ref['path'],f'mouthStates[{i}].frameCount','curve_frame_count_mismatch',declared=state['frameCount'],expected=alpha)
|
||||
if data['schemaVersion']==2 and pts!=alpha:
|
||||
reject(ref['path'],f'mouthStates[{i}].ptsUs','curve_pts_count_mismatch',declared=pts,expected=alpha)
|
||||
except (ValueError,KeyError,TypeError,OSError):
|
||||
reject('manifest.json','runtimeManifest','runtime_reference_invalid')
|
||||
for i,action in enumerate(index['actions']):
|
||||
field=f'actions[{i}].clip'
|
||||
try:
|
||||
clip=action['clip'];path=pack.locate(root,clip['path'])
|
||||
pack.require(pack.file_sha(path)==clip['sha256'],'action hash drift')
|
||||
run=subprocess.run(['/home/ubuntu/miniconda3/envs/gori-speech/bin/ffprobe','-v','error','-show_streams','-of','json',str(path)],capture_output=True,check=True,timeout=30)
|
||||
observed=json.loads(run.stdout)['streams']
|
||||
# No tags, lyrics, filenames beyond validated task-relative paths, or raw model output.
|
||||
rows=[{k:s[k] for k in ('index','codec_type','codec_name','duration','sample_rate','channels') if k in s} |
|
||||
{'attached_pic':s.get('disposition',{}).get('attached_pic',0)} for s in observed]
|
||||
streams.append({'field':field,'file':clip['path'],'streams':rows})
|
||||
if len(rows)!=2 or sorted(s['codec_type'] for s in rows)!=['audio','video'] or any(s['attached_pic'] for s in rows):
|
||||
reject('manifest.json',field+'.path','dance_stream_layout_requires_video_audio_without_cover',clip_path=clip['path'])
|
||||
except (ValueError,KeyError,TypeError,OSError,subprocess.SubprocessError):
|
||||
reject('manifest.json',field,'action_probe_failed')
|
||||
parser_report=output/'production-parser.json'
|
||||
run=subprocess.run([sys.executable,str(ROOT/'scripts/check-reply-regressions.py'),'--suite','avatar',
|
||||
'--index-manifest',str(manifest),'--metadata-only','--rejection-report',str(parser_report)],capture_output=True,timeout=180)
|
||||
if parser_report.exists():
|
||||
parsed=json.loads(parser_report.read_bytes());rejects.extend(parsed['rejects'][:128-len(rejects)])
|
||||
else:
|
||||
parsed={'status':'not_completed'}
|
||||
reject('manifest.json','$','production_parser_execution_failed')
|
||||
pack.require(pack.file_sha(manifest)==expected,'candidate drift during diagnostics')
|
||||
report={'status':'rejected' if rejects or run.returncode else 'no_reject_found',
|
||||
'manifest_sha256':expected,'scope':'read_only_rejection_diagnostics_not_full_media_gate',
|
||||
'production_metadata':parsed['status'],'rejects':rejects,'action_streams':streams,
|
||||
'dance_available':False,'naturalness':'not_certified','human_listening':'not_run','device':'not_run',
|
||||
'source_hashes':{name:pack.file_sha(ROOT/name) for name in ('scripts/diagnose-avatar-candidate.py',
|
||||
'scripts/check-reply-regressions.py','app/src/main/java/com/gorios/lanvoice/avatar/ContinuousAvatarManifest.kt',
|
||||
'app/src/main/java/com/gorios/lanvoice/avatar/EmotionActionManifest.kt')}}
|
||||
with (output/'reject-details.json').open('x') as f:json.dump(report,f,indent=2);f.write('\n')
|
||||
return report
|
||||
|
||||
|
||||
def main():
|
||||
parser=argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--manifest',type=Path,required=True);parser.add_argument('--sha256',required=True)
|
||||
parser.add_argument('--output',type=Path,required=True);args=parser.parse_args()
|
||||
report=diagnose(args.manifest,args.sha256,args.output)
|
||||
print(json.dumps({'status':report['status'],'reject_count':len(report['rejects']),'report':str(args.output/'reject-details.json')}))
|
||||
return 1 if report['status']=='rejected' else 0
|
||||
|
||||
|
||||
if __name__=='__main__':raise SystemExit(main())
|
||||
Reference in New Issue
Block a user