91 lines
6.0 KiB
Python
91 lines
6.0 KiB
Python
#!/usr/bin/env python3
|
||
"""Freeze the exact authorized Liam intake as a new revision; never edit owner input.
|
||
Only HANDOFF inventory, measured dance AAC presentation end, and local pose metadata
|
||
are corrected. No synthesis, video re-encode, runtimeReady override or gateway admission.
|
||
"""
|
||
import argparse
|
||
import hashlib
|
||
import importlib.util
|
||
import json
|
||
from pathlib import Path
|
||
import shutil
|
||
|
||
ROOT=Path(__file__).resolve().parents[1]
|
||
SOURCE_PIN='1f7b33e145e68476f3a9b1f15a3380d56cef3040fcd798a4ca19d027ea4c5ad9'
|
||
POSES={
|
||
'suit-adjust':('pose-source/revisions/poses-r02/media/suit-adjust.mp4',1914915,'d849ca16945d951821d315f5c76f2a6466656d8093584b2004eb0ae794bf1fb9'),
|
||
'knuckle-check':('pose-source/revisions/poses-r01/media/knuckle-check.mp4',1525851,'c88655e370ad164cb028d1e11f4f6b5ae7aff695f26f9ecf7068349a3f25f761')}
|
||
|
||
def digest(p):return hashlib.sha256(p.read_bytes()).hexdigest()
|
||
def write(p,data):p.write_text(json.dumps(data,indent=2,ensure_ascii=False)+'\n')
|
||
def derive(intake,output):
|
||
source=intake/'expressions-r02';manifest=source/'manifest.json'
|
||
assert digest(manifest)==SOURCE_PIN,'wrong intake index'
|
||
assert not output.exists() and not output.resolve().is_relative_to(intake.resolve()),'new external revision required'
|
||
assert not any(p.is_symlink() for p in intake.rglob('*')),'symlink input'
|
||
m=json.loads(manifest.read_bytes());bad=[]
|
||
for r in m['files']:
|
||
p=source/r['path'];assert p.resolve().is_relative_to(source.resolve()) and p.is_file()
|
||
if digest(p)!=r['sha256'] or p.stat().st_size!=r['bytes']:bad.append(r['path'])
|
||
assert bad==['HANDOFF.md'],'unexpected inventory mismatch'
|
||
spec=importlib.util.spec_from_file_location('gate',ROOT/'scripts/package-avatar-emotion.py')
|
||
gate=importlib.util.module_from_spec(spec);spec.loader.exec_module(gate)
|
||
measurements={key:gate.probe_clip(intake/row[0]) for key,row in POSES.items()}
|
||
for key,(name,size,sha) in POSES.items():
|
||
p=intake/name;v=measurements[key]
|
||
assert p.stat().st_size==size and digest(p)==sha
|
||
assert v['shape']==(720,1280) and len(v['ptsUs'])==193 and v['fps']==24 and abs(v['durationUs']-8041667)<=2
|
||
shutil.copytree(source,output)
|
||
corrections=[]
|
||
for a in m['actions']:
|
||
clip=a['clip'];actual=gate.probe_music_clip(source/clip['path'])
|
||
if actual['audioEndUs']!=a['audioEndUs']:
|
||
corrections.append({'field':a['id']+'.audioEndUs','source':a['audioEndUs'],'measured':actual['audioEndUs']})
|
||
a['audioEndUs']=actual['audioEndUs']
|
||
poses=[]
|
||
for key,(name,size,sha) in POSES.items():
|
||
v=measurements[key];path='waiting-poses/'+key+'.mp4';dest=output/path;dest.parent.mkdir(exist_ok=True);shutil.copyfile(intake/name,dest)
|
||
poses.append({'id':key,'kind':'waiting_pose','mouthAllowed':False,'entryAnchor':'A','returnAnchor':'A',
|
||
'sourcePackageId':'neutral','sourceFrame':0,'sourcePtsUs':0,'returnPackageId':'neutral','returnFrame':0,'returnPtsUs':0,
|
||
'clip':{'path':path,'sha256':sha,'width':720,'height':1280,'frameCount':193,'durationUs':v['durationUs'],
|
||
'fpsNumerator':24,'fpsDenominator':1,'ptsUs':v['ptsUs'],'hasAudio':False}})
|
||
m['revision']='char-waiting-poses-r01'
|
||
m['waiting']={'schemaVersion':1,'idlePackageId':'neutral','talkPackageId':'neutral',
|
||
'microphoneAllowed':False,'ttsAllowed':False,'mouthAllowed':False,'poses':poses}
|
||
provenance={'sourceIndexSha256':SOURCE_PIN,'revision':m['revision'],'authorization':'user_20261015_liam_local_waiting_poses',
|
||
'sourceInventoryMismatches':bad,'metadataCorrections':corrections,'runtimeReadyOverridden':False,
|
||
'talkIdle':'existing neutral145 with its own five-level patches','gatewayAdmission':'pending_new_exact_pin',
|
||
'poseMedia':{k:{'sha256':v[2],'bytes':v[1]} for k,v in POSES.items()},'generationCalls':0}
|
||
write(output/'PACKAGING_REVISION.json',provenance)
|
||
(output/'HANDOFF.md').write_text('# Liam waiting poses: immutable application revision\n\n'
|
||
'Source index: '+SOURCE_PIN+'\n\n'
|
||
'The source HANDOFF inventory was stale. This revision corrects that row and '
|
||
'measures AAC presentation ends without changing media bytes. All original runtimeReady '
|
||
'flags remain unchanged; exact user-authorized debug admission requires the production checker.\n\n'
|
||
'neutral (145 frames, own N×5 patches) is the dedicated TALK idle. During silent waiting, '
|
||
'rotate ordinary idle and two local waiting poses. Before a pose, confirm actual AudioRecord '
|
||
'stop. No ASR input, TTS, audio track or mouth patches during pose. Return only after actual '
|
||
'final video frame, decoder release and actual composed neutral frame0. '
|
||
'This is separate from transparent expression patch intervals, where TTS may continue.\n\n'
|
||
'Both original dance videos are byte-identical. New exact index gateway registration is pending; '
|
||
'this packaging does not authorize network dance, installation or production deployment.\n')
|
||
table={r['path']:r for r in m['files']}
|
||
refs=[r['runtimeManifest'] for r in m['conversationPackages']]+[e['mouthRuntimeManifest'] for e in m['edges'] if 'mouthRuntimeManifest' in e]
|
||
omitted=[]
|
||
for ref in refs:
|
||
p=source/ref['path'];assert digest(p)==ref['sha256'],'runtime reference hash drift'
|
||
if ref['path'] not in table:
|
||
omitted.append(ref['path']);table[ref['path']]={'path':ref['path'],'sha256':digest(p),'bytes':p.stat().st_size}
|
||
provenance['sourceInventoryOmissions']=omitted
|
||
write(output/'PACKAGING_REVISION.json',provenance)
|
||
for name in ['HANDOFF.md','PACKAGING_REVISION.json',*[p['clip']['path'] for p in poses]]:
|
||
p=output/name;table[name]={'path':name,'sha256':digest(p),'bytes':p.stat().st_size}
|
||
m['files']=[table[k] for k in sorted(table)];write(output/'manifest.json',m)
|
||
assert 'manifest.sha256' not in table,'self-pin must be external to index files'
|
||
(output/'manifest.sha256').write_text(digest(output/'manifest.json')+' manifest.json\n')
|
||
return {**provenance,'indexSha256':digest(output/'manifest.json'),'files':len(m['files'])}
|
||
|
||
if __name__=='__main__':
|
||
p=argparse.ArgumentParser(description=__doc__);p.add_argument('--intake',type=Path,required=True);p.add_argument('--output',type=Path,required=True)
|
||
a=p.parse_args();print(json.dumps(derive(a.intake,a.output),indent=2))
|