Integrate exact user-authorized correct03 720 debug assets with isolated admission
This commit is contained in:
@@ -4,11 +4,12 @@ Android EGL/codec/music/record confirmations are doubles; no device or sockets.
|
||||
"""
|
||||
from pathlib import Path
|
||||
import ast,subprocess,tempfile,json,hashlib
|
||||
import argparse
|
||||
import argparse, zipfile
|
||||
parser=argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--apk',type=Path,required=True)
|
||||
parser.add_argument('--sha256',required=True)
|
||||
parser.add_argument('--startup-loader',action='store_true',help='Production background repository over actual APK bytes, isolated private receipt, no rendering/connection')
|
||||
parser.add_argument('--user-asset-candidate',action='store_true',help='Exact user-authorized correct03 APK: network dance disabled; local media callbacks are doubles')
|
||||
args=parser.parse_args()
|
||||
assert hashlib.sha256(args.apk.read_bytes()).hexdigest()==args.sha256, 'APK hash drift'
|
||||
ROOT=Path(__file__).resolve().parents[1];script=ROOT/'scripts/check-reply-regressions.py'
|
||||
@@ -93,6 +94,19 @@ object BuildConfig { const val AVATAR_STARTUP_FIX=false;const val DEBUG=true;con
|
||||
const val EMOTION_MANIFEST_SHA="987e125a7d7a2cde99121b5f5246c82f4dbe36c4899d3d49eaffd1a68bafb887"
|
||||
const val NATURAL_MANIFEST_SHA="0a3c4918ba746019cf1df885bec66e5858a8950997dac4f64e7d37094be64dad"
|
||||
}'''
|
||||
if args.user_asset_candidate:
|
||||
import importlib.util
|
||||
spec=importlib.util.spec_from_file_location('user_startup',ROOT/'scripts/prepare-user-avatar-startup.py');asset_config=importlib.util.module_from_spec(spec);spec.loader.exec_module(asset_config)
|
||||
with zipfile.ZipFile(args.apk) as archive:
|
||||
raw=archive.read('assets/'+asset_config.ASSET_ROOT+'manifest.json');assert hashlib.sha256(raw).hexdigest()==asset_config.PIN
|
||||
index=json.loads(raw);refs=[p['runtimeManifest'] for p in index['conversationPackages']]+[e['mouthRuntimeManifest'] for e in index['edges'] if 'mouthRuntimeManifest' in e]
|
||||
patch_count=sum(len(json.loads(archive.read('assets/'+asset_config.ASSET_ROOT+r['path']))['patches'])*5 for r in refs)
|
||||
build=build.replace('const val EMOTION_MANIFEST_SHA="987e125a7d7a2cde99121b5f5246c82f4dbe36c4899d3d49eaffd1a68bafb887"','const val EMOTION_MANIFEST_SHA="'+asset_config.PIN+'"')
|
||||
build=build.replace('const val AVATAR_STARTUP_FIX=false','const val AVATAR_STARTUP_FIX=true')
|
||||
build=build.replace('object BuildConfig {','object BuildConfig { const val AVATAR_USER_ASSET_CANDIDATE=true;const val EMOTION_ASSET_ROOT="'+asset_config.ASSET_ROOT+'";const val STARTUP_ASSET_ROOT="'+asset_config.BASIC_ROOT+'";const val STARTUP_MANIFEST_SHA="'+hashlib.sha256((ROOT/'manifests/startup-black-tulle-correct03.json').read_bytes()).hexdigest()+'";')
|
||||
else:
|
||||
patch_count=3185
|
||||
build=build.replace('object BuildConfig {','object BuildConfig { const val AVATAR_USER_ASSET_CANDIDATE=false;const val EMOTION_ASSET_ROOT="avatar/a01-expression-action-v1/";const val STARTUP_ASSET_ROOT="avatar/startup-white-01/";const val STARTUP_MANIFEST_SHA="461f5cfc10036de5f10ca3ce765fb8d9998697d3fd035aa9b1862d2ccfc3eaa2";')
|
||||
main=r'''
|
||||
import com.gorios.lanvoice.avatar.*
|
||||
import com.gorios.lanvoice.dialogue.*
|
||||
@@ -107,7 +121,7 @@ fun main(args: Array<String>) {
|
||||
println("LOADER|status=${pack.motionStatus}|full=${pack.emotionAction!=null}|actions=${pack.emotionAction?.actionPack?.assets?.size}")
|
||||
val index=checkNotNull(pack.emotionAction)
|
||||
fun rig(): Triple<EmotionActionAvatarView,AvatarMediaBinding,MutableList<Pair<Long,VideoPresentation>>> {
|
||||
TestScheduler.reset();CodecFixture.reset();MediaPlayer.created.clear();CodecFixture.emitNativeSurface=true
|
||||
TestScheduler.reset();CodecFixture.reset();CodecFixture.width=pack.continuous!!.body.width;CodecFixture.height=pack.continuous!!.body.height;MediaPlayer.created.clear();CodecFixture.emitNativeSurface=true
|
||||
index.packages.values.forEach { CodecFixture.timelines[it.root+it.body.path]=it.body.ptsUs }
|
||||
index.edges.mapNotNull { it.mouthRuntime }.forEach { CodecFixture.timelines[it.root+it.body.path]=it.body.ptsUs }
|
||||
index.actionPack?.assets?.mapNotNull { it.media }?.forEach { CodecFixture.timelines[it.root+it.path]=it.ptsUs;CodecFixture.audioPaths.add(it.root+it.path) }
|
||||
@@ -179,7 +193,7 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
check(textures[3].alpha==1f && textures.take(3).all { it.alpha==0f })
|
||||
}
|
||||
println("DANCE_OWNER|initial=${initial.wire}|frames=241|music_visible=241|conversation_visible=0|state=${binding.diagnosticState}")
|
||||
println("DANCE_OWNER|initial=${initial.wire}|frames=${index.actionPack.assets.first().media!!.ptsUs.size}|music_visible=${index.actionPack.assets.first().media!!.ptsUs.size}|conversation_visible=0|state=${binding.diagnosticState}")
|
||||
TestScheduler.advanceBy(50);movie.completion!!(movie);TestScheduler.until(15000) { statuses.last().status!="started" }
|
||||
println("DANCE|ended=${statuses.last().status}|released=${movie.released}|return=${binding.currentPackageId}")
|
||||
printTrace("dance_${initial.wire}",trace);check(statuses.last().status=="completed");check(binding.currentPackageId=="neutral-01");view.dispose();TestScheduler.advanceBy(100)
|
||||
@@ -212,11 +226,12 @@ fun main(args: Array<String>) {
|
||||
with tempfile.TemporaryDirectory(prefix='baji-runtime-audit-') as td:
|
||||
tmp=Path(td);files=[]
|
||||
for path in (ROOT/'tests/avatar').glob('*.kt'):
|
||||
if path.name not in ('Pack.kt','Context.kt','Graphics.kt') and not(args.startup_loader and path.name=='Clock.kt'):files.append(path)
|
||||
if path.name not in ('Pack.kt','Context.kt','Graphics.kt','BuildConfig.kt') and not(args.startup_loader and path.name=='Clock.kt'):files.append(path)
|
||||
if args.startup_loader:
|
||||
clock=(ROOT/'tests/avatar/Clock.kt').read_text().replace('fun getMainLooper() = main','private val owner=Thread.currentThread();fun myLooper(): Looper?=if(Thread.currentThread()===owner) main else null;fun getMainLooper() = main')
|
||||
clock=clock.replace(' fun add(', ' @Synchronized fun add(').replace(' fun remove(', ' @Synchronized fun remove(').replace(' fun advanceBy(', ' @Synchronized fun advanceBy(')
|
||||
p=tmp/'Clock.kt';p.write_text(clock);files.append(p)
|
||||
startup_main=startup_main.replace("3185",str(patch_count))
|
||||
for name,txt in [('Json.kt',json_adapter),('Context.kt',context),('Graphics.kt',graphics),('BuildConfig.kt',build),('Audit.kt',startup_main if args.startup_loader else main)]:
|
||||
p=tmp/name;p.write_text(txt);files.append(p)
|
||||
files+=real+[ROOT/'app/src/main/java/com/gorios/lanvoice'/p for p in ('avatar/AvatarPack.kt','avatar/StartupAvatarView.kt','avatar/StartupLoadCache.kt','diag/StartupTrace.kt')]
|
||||
|
||||
@@ -35,9 +35,11 @@ parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--suite', choices=[name for name, _, _ in suites])
|
||||
parser.add_argument('--runtime-manifest',type=Path,help='Additionally exercise real continuous parser with actual offline manifest metadata')
|
||||
parser.add_argument('--index-manifest',type=Path,help='Additionally admit an exact offline v2 index and each referenced runtime through production parsers; no activation')
|
||||
parser.add_argument('--user-authorized-debug-sha',help='Explicit exact user-authorized parent index for debug candidate admission; not Pi publication or network actions')
|
||||
parser.add_argument('--metadata-only',action='store_true',help='Only the actual manifest admission, without repeating fixtures')
|
||||
parser.add_argument('--rejection-report',type=Path,help='New bounded structural field report; no raw values')
|
||||
args = parser.parse_args()
|
||||
if args.user_authorized_debug_sha and (not args.index_manifest or args.user_authorized_debug_sha!='208f703ed92bf795bfeb78a1cef89b67bed2e45da80038a56157fd1ecd4cfa93'): parser.error('Exact authorized correct03 index required')
|
||||
if args.index_manifest and args.runtime_manifest: parser.error('Choose runtime or index manifest, not both')
|
||||
if args.metadata_only and not (args.index_manifest or args.runtime_manifest): parser.error('Actual manifest required')
|
||||
if args.rejection_report and (not args.index_manifest or args.rejection_report.exists()): parser.error('Index and new rejection report required')
|
||||
@@ -79,6 +81,7 @@ for name, main, real in suites:
|
||||
else:
|
||||
index_path=args.index_manifest.resolve(strict=True)
|
||||
raw=index_path.read_bytes();digest=hashlib.sha256(raw).hexdigest()
|
||||
if args.user_authorized_debug_sha and digest!=args.user_authorized_debug_sha: raise ValueError('User authorized index drift')
|
||||
data=json.loads(raw);runtimes={};hashes={}
|
||||
references=[row['runtimeManifest'] for row in data['conversationPackages']]
|
||||
references += [edge['mouthRuntimeManifest'] for edge in data['edges'] if 'mouthRuntimeManifest' in edge]
|
||||
@@ -95,7 +98,7 @@ for name, main, real in suites:
|
||||
'fun main() {\nval root='+index_literal+'\nval runtimes='+runtime_literal+'\nval hashes='+hash_literal+'\n'+
|
||||
'val parsed=runtimes.mapValues { (path,value) ->\nval hash=hashes.getValue(path) as String\n'+
|
||||
'@Suppress("UNCHECKED_CAST")\nContinuousAvatarManifest.read(value as Map<String,Any?>,hash,hash,true,"fixture/"+path.substringBeforeLast(47.toChar())+"/",'+
|
||||
'onReject={ field -> println("REJECT_FIELD|"+path+"|"+field) })\n}\n'+
|
||||
'onReject={ field -> println("REJECT_FIELD|"+path+"|"+field) },userAuthorizedDebug='+str(bool(args.user_authorized_debug_sha)).lower()+')\n}\n'+
|
||||
'val index=checkNotNull(EmotionActionManifest.read(root,"'+digest+'","'+digest+'","fixture/",'+
|
||||
'onReject={ field -> println("REJECT_FIELD|manifest.json|"+field) }) { path,hash ->\n'+
|
||||
'check(hashes[path]==hash)\nparsed[path]\n})\n'+
|
||||
|
||||
@@ -114,7 +114,7 @@ def probe_music_clip(path):
|
||||
'nearFullScaleSamples':sum(abs(x)>=0.999 for x in samples),'humanListening':'not_run'}
|
||||
|
||||
|
||||
def check_bundle(manifest,expected,output):
|
||||
def check_bundle(manifest,expected,output,user_authorized_debug=False):
|
||||
manifest=manifest.resolve(strict=True);root=manifest.parent
|
||||
require(re.fullmatch('[0-9a-f]{64}',expected) and file_sha(manifest)==expected,'candidate index drift')
|
||||
index=read_json(manifest)
|
||||
@@ -175,14 +175,15 @@ def check_bundle(manifest,expected,output):
|
||||
require(p.stat().st_size==row['bytes'] and p.stat().st_size<=128_000_000 and file_sha(p)==row['sha256'],'declared file mismatch: '+name)
|
||||
table[name]={'sha256':row['sha256'],'bytes':row['bytes']}
|
||||
require(all(table.get(name)==row for name,row in files.items()),'inventory missing/mismatching referenced file')
|
||||
require(not user_authorized_debug or expected=='208f703ed92bf795bfeb78a1cef89b67bed2e45da80038a56157fd1ecd4cfa93','exact user-authorized debug index required')
|
||||
log=output/'production-index-tests.txt'
|
||||
with log.open('x') as f:
|
||||
result=subprocess.run([sys.executable,str(ROOT/'scripts/check-reply-regressions.py'),'--suite','avatar','--index-manifest',str(manifest)],stdout=f,stderr=subprocess.STDOUT,timeout=180)
|
||||
result=subprocess.run([sys.executable,str(ROOT/'scripts/check-reply-regressions.py'),'--suite','avatar','--index-manifest',str(manifest),*(['--user-authorized-debug-sha',expected] if user_authorized_debug else [])],stdout=f,stderr=subprocess.STDOUT,timeout=180)
|
||||
require(result.returncode==0 and 'PASS: actual exported v2 index parsed' in log.read_text(),'production index admission failed; see '+str(log))
|
||||
files['manifest.json']={'sha256':expected,'bytes':manifest.stat().st_size}
|
||||
for name,row in files.items(): require(file_sha(locate(root,name))==row['sha256'],'bundle changed during gate')
|
||||
report={'status':'passed','scope':'read_only_machine_gate_no_approval_no_activation','manifest_sha256':expected,
|
||||
'runtime_packages':runtimes,'combined_rgba_bytes':rgba,'referenced_files':len(files),'preview_files_not_packaged':len(table.keys()-files.keys()),
|
||||
'user_authorized_debug':user_authorized_debug,'runtime_packages':runtimes,'combined_rgba_bytes':rgba,'referenced_files':len(files),'preview_files_not_packaged':len(table.keys()-files.keys()),
|
||||
'edge_count':len(index['edges']),'action_count':len(actions),'dance_available':False,
|
||||
'candidate_dance_validated':bool(actions),'action_measurements':action_measurements,'production_kotlin_index':'passed',
|
||||
'naturalness':'not_certified','real_device':'not_run','files':files}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Exact user-authorized correct03 debug import/build; no Pi spoof or network dance admission.
|
||||
Keep the separate Pi-reviewed white publication workflow unchanged. Owner media is read-only.
|
||||
"""
|
||||
import argparse, importlib.util, json, re, shutil, subprocess, urllib.request, zipfile
|
||||
from pathlib import Path
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
def module(name,path):
|
||||
spec=importlib.util.spec_from_file_location(name,path);obj=importlib.util.module_from_spec(spec);spec.loader.exec_module(obj);return obj
|
||||
pack=module('pack',ROOT/'scripts/package-avatar-emotion.py')
|
||||
startup=module('startup',ROOT/'scripts/prepare-user-avatar-startup.py')
|
||||
PIN=startup.PIN
|
||||
WHITE_PIN=pack.RUNTIME_FIX_PIN
|
||||
OLD=ROOT/'artifacts/lan-voice-v0711-camera-matrix-code29-arm64-debug.apk'
|
||||
OLD_SHA='34905e98534d3b93b769717dd895183e2b06a87e70b564c0ac50c856f8ffa8de'
|
||||
require=pack.require
|
||||
|
||||
def authorization(pin,pi_pin=None,registry=None):
|
||||
require(pin==PIN,'exact user authorization required')
|
||||
require(pi_pin is None and registry is None,'user debug path cannot label Pi approval or install a dance registry')
|
||||
return {'authorization':'user_exact_revision_debug_integration','manifest_sha256':PIN,
|
||||
'independent_pi_pin':False,'network_dance_available':False,'music_listening':'not_run','device':'not_run'}
|
||||
|
||||
def verify_apk(apk,report):
|
||||
require(pack.file_sha(OLD)==OLD_SHA,'code29 rollback drift')
|
||||
with zipfile.ZipFile(OLD) as old,zipfile.ZipFile(apk) as new:
|
||||
paths=lambda z:{n for n in z.namelist() if n.startswith('assets/avatar/') and not n.endswith('/')}
|
||||
retained={n for n in paths(old) if not n.startswith(('assets/'+pack.ASSET_ROOT,'assets/avatar/startup-white-01/'))}
|
||||
actual={'assets/'+startup.ASSET_ROOT+n for n in report['files']}
|
||||
basic={'assets/'+startup.BASIC_ROOT+n for n in ('manifest.json','poster.png')}
|
||||
require(paths(new)==retained|actual|basic,'unreferenced/missing avatar files')
|
||||
for n in retained:require(new.read(n)==old.read(n),'rollback asset changed: '+n)
|
||||
for n,row in report['files'].items():
|
||||
data=new.read('assets/'+startup.ASSET_ROOT+n)
|
||||
require(len(data)==row['bytes'] and pack.sha(data)==row['sha256'],'packaged hash/bytes mismatch: '+n)
|
||||
meta=(ROOT/'manifests/startup-black-tulle-correct03.json').read_bytes();m=json.loads(meta)
|
||||
require(new.read('assets/'+startup.BASIC_ROOT+'manifest.json')==meta and m['sourceIndexSha256']==PIN,'bootstrap index mismatch')
|
||||
require(pack.sha(new.read('assets/'+startup.BASIC_ROOT+'poster.png'))==m['posterSha256'],'poster mismatch')
|
||||
for n in paths(new):
|
||||
if n.endswith('.mp4'):require(new.getinfo(n).compress_type==zipfile.ZIP_STORED,'compressed video')
|
||||
return {'runtime_referenced_files':len(actual),'retained_legacy_avatar_files':len(retained),'bootstrap_files':2,'all_avatar_files':len(paths(new)),'review_files_packaged':0}
|
||||
|
||||
def publish(report,output,version):
|
||||
checks=pack.read_json(ROOT/'logs/black-tulle-correct03/checks.json')
|
||||
require(checks['status']=='passed' and checks['jvm_entry_points']==11 and checks['gateway_passed']>=110 and checks['gateway_skipped']==1 and checks['packaging_passed']>=48 and checks['gles_cases']>=200,'actual completed regression evidence required')
|
||||
for name,digest in checks['hashes'].items():require(pack.file_sha(ROOT/name)==digest,'untested source: '+name)
|
||||
require(version>=30 and version>=pack.next_version((ROOT/'artifacts').glob('*.apk')),'version occupied')
|
||||
flags=['-PavatarUserAssetCandidate=true','-PavatarActionCandidate=true','-PavatarNatural=true','-PavatarMouthCandidate=true',
|
||||
'-PnaturalManifestSha='+pack.LEGACY_PIN,'-PemotionManifestSha='+PIN,'-PactionVersionCode='+str(version)]
|
||||
flags += ['-P'+name+'=true' for name in ('avatarFullActionCandidate','avatarPlaybackClockFix','avatarStartupFix','presenceCandidate','faceDiagnosticsFix','cameraCompatibilityFix','cameraDirectYuv','cameraPreviewStream','cameraProbeDiagnostic')]
|
||||
subprocess.run([str(ROOT/'scripts/build.sh'),'assembleDebug','compileDebugAndroidTestKotlin',*flags],check=True,cwd=ROOT)
|
||||
built=ROOT/'app/build/outputs/apk/debug/app-debug.apk';badge=pack.badging(built)
|
||||
for value in ("name='com.gorios.lanvoice'",f"versionCode='{version}'","versionName='0.7.12'","sdkVersion:'26'","targetSdkVersion:'34'"):
|
||||
require(value in badge,'APK metadata: '+value)
|
||||
require(re.search(r'^native-code: (.+)$',badge,re.M)[1].strip()=="'arm64-v8a'",'APK ABI')
|
||||
cert=subprocess.check_output([str(pack.TOOLS/'apksigner'),'verify','--verbose','--print-certs',str(built)],text=True)
|
||||
require(re.search(r'Signer #1 certificate SHA-256 digest: (\w+)',cert)[1]==pack.CERT,'same debug certificate required')
|
||||
inventory=verify_apk(built,report)
|
||||
config=(ROOT/'app/build/generated/source/buildConfig/debug/com/gorios/lanvoice/BuildConfig.java').read_text()
|
||||
for value in ('AVATAR_USER_ASSET_CANDIDATE = true','AVATAR_STARTUP_FIX = true','EMOTION_MANIFEST_SHA = "'+PIN+'"','EMOTION_ASSET_ROOT = "'+startup.ASSET_ROOT+'"','STARTUP_MANIFEST_SHA = "'+pack.file_sha(ROOT/'manifests/startup-black-tulle-correct03.json')+'"'):
|
||||
require(value in config,'BuildConfig mismatch: '+value)
|
||||
artifact=ROOT/f'artifacts/lan-voice-v0712-black-tulle-correct03-code{version}-arm64-debug.apk'
|
||||
with artifact.open('xb') as f,built.open('rb') as source:shutil.copyfileobj(source,f)
|
||||
digest=pack.file_sha(artifact);checksum=f'{digest} {artifact.name}\n'.encode()
|
||||
with artifact.with_suffix('.apk.sha256').open('xb') as f:f.write(checksum)
|
||||
url='http://192.168.31.124:8080/'+artifact.name
|
||||
opener=urllib.request.build_opener(urllib.request.ProxyHandler({}))
|
||||
with opener.open(url,timeout=30) as r:require(r.status==200 and pack.sha(r.read())==digest,'HTTP bytes mismatch')
|
||||
with opener.open(url+'.sha256',timeout=15) as r:require(r.status==200 and r.read()==checksum,'HTTP checksum mismatch')
|
||||
delivery={'status':'user_authorized_debug_asset_candidate','version_name':'0.7.12','version_code':version,'url':url,'sha256':digest,
|
||||
'certificate_sha256':pack.CERT,**authorization(PIN),**inventory,'combined_rgba_bytes':report['combined_rgba_bytes'],
|
||||
'http_bytes_verified':True,'gateway_deployed':False,'paid_calls':0,'naturalness':'not_certified'}
|
||||
(output/'delivery.json').write_text(json.dumps(delivery,indent=2)+'\n');return delivery
|
||||
|
||||
def main():
|
||||
parser=argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--manifest',type=Path,required=True);parser.add_argument('--user-authorized-sha',required=True)
|
||||
parser.add_argument('--output',type=Path,required=True);parser.add_argument('--import-only',action='store_true');parser.add_argument('--build',action='store_true')
|
||||
parser.add_argument('--version-code',type=int,default=30);args=parser.parse_args()
|
||||
auth=authorization(args.user_authorized_sha);manifest=args.manifest.resolve(strict=True);out=args.output.resolve()
|
||||
require(not out.exists() and not out.is_relative_to(manifest.parent),'fresh evidence outside owner storage required')
|
||||
out.mkdir(parents=True)
|
||||
report=pack.check_bundle(manifest,PIN,out,user_authorized_debug=True)
|
||||
if args.import_only or args.build:
|
||||
pack.import_files(manifest.parent,report['files'],ROOT/'app/src/main/assets'/startup.ASSET_ROOT)
|
||||
basic=startup.prepare(manifest.parent)
|
||||
(out/'import.json').write_text(json.dumps({**auth,'files':len(report['files']),'asset_root':startup.ASSET_ROOT,'bootstrap':basic},indent=2)+'\n')
|
||||
result=publish(report,out,args.version_code) if args.build else report
|
||||
print(json.dumps({k:v for k,v in result.items() if k not in ('files','runtime_packages')},indent=2))
|
||||
if __name__=='__main__':
|
||||
try:main()
|
||||
except Exception as e:raise SystemExit('FAIL: user asset integration: '+str(e))
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Derive a bounded poster/bootstrap from the exact user-authorized immutable pack.
|
||||
CPU decode only. Portrait outputs stay ignored; the metadata records exact provenance.
|
||||
"""
|
||||
import argparse, hashlib, io, json, subprocess
|
||||
from pathlib import Path
|
||||
from PIL import Image
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
PIN='208f703ed92bf795bfeb78a1cef89b67bed2e45da80038a56157fd1ecd4cfa93'
|
||||
ASSET_ROOT='avatar/a01-black-tulle-roomy720-correct03/'
|
||||
BASIC_ROOT='avatar/startup-black-tulle-correct03/'
|
||||
sha=lambda data:hashlib.sha256(data).hexdigest()
|
||||
|
||||
def derive(source):
|
||||
index=source/'manifest.json';assert sha(index.read_bytes())==PIN,'exact index drift'
|
||||
m=json.loads(index.read_bytes());row=next(r for r in m['conversationPackages'] if r['id']==m['fallbackPackageId'])
|
||||
runtime=source/row['runtimeManifest']['path'];assert sha(runtime.read_bytes())==row['runtimeManifest']['sha256']
|
||||
body=json.loads(runtime.read_bytes())['body'];name=str(Path(row['runtimeManifest']['path']).parent/body['path'])
|
||||
path=source/name;assert sha(path.read_bytes())==body['sha256']
|
||||
assert (body['width'],body['height'])==(720,1280) and body['ptsUs'][0]==0 and body['hasAudio'] is False
|
||||
native=subprocess.check_output(['/home/ubuntu/gori-bin/ffmpeg','-v','error','-i',str(path),'-frames:v','1','-f','image2pipe','-vcodec','png','-'],timeout=30)
|
||||
image=Image.open(io.BytesIO(native)).convert('RGB').resize((180,320),Image.Resampling.LANCZOS)
|
||||
out=io.BytesIO();image.save(out,format='PNG',optimize=True);poster=out.getvalue();assert len(poster)<=100_000
|
||||
meta={'schemaVersion':1,'sourceIndexSha256':PIN,'posterSha256':sha(poster),'posterWidth':180,'posterHeight':320,
|
||||
'provenance':'Exact decoded neutral source frame0; CPU downsample, no generated media; user-authorized debug integration, not Pi certification',
|
||||
'body':{**body,'path':ASSET_ROOT+name}}
|
||||
return (json.dumps(meta,indent=2)+'\n').encode(),poster
|
||||
|
||||
def prepare(source,verify_only=False):
|
||||
raw,poster=derive(source)
|
||||
outputs={ROOT/'manifests/startup-black-tulle-correct03.json':raw,
|
||||
ROOT/'app/src/main/assets'/BASIC_ROOT/'manifest.json':raw,
|
||||
ROOT/'app/src/main/assets'/BASIC_ROOT/'poster.png':poster,
|
||||
ROOT/'app/src/main/res/drawable-nodpi/startup_black_tulle_poster.png':poster}
|
||||
for path,data in outputs.items():
|
||||
if path.exists():assert path.read_bytes()==data,'Unknown bootstrap bytes preserved: '+str(path)
|
||||
else:
|
||||
assert not verify_only,'missing bootstrap: '+str(path)
|
||||
path.parent.mkdir(parents=True,exist_ok=True);path.write_bytes(data)
|
||||
return {'status':'passed','index_sha256':PIN,'bootstrap_sha256':sha(raw),'poster_sha256':sha(poster),'poster_bytes':len(poster),'paid_calls':0}
|
||||
if __name__=='__main__':
|
||||
parser=argparse.ArgumentParser(description=__doc__);parser.add_argument('--source',type=Path,required=True);parser.add_argument('--verify-only',action='store_true')
|
||||
args=parser.parse_args();print(json.dumps(prepare(args.source,args.verify_only),indent=2))
|
||||
Reference in New Issue
Block a user