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.
This commit is contained in:
@@ -2,17 +2,18 @@
|
||||
# Production Kotlin with local deterministic media/transport doubles, no real capture.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
mkdir -p logs/avatar-060
|
||||
python3 scripts/check-reply-regressions.py > logs/avatar-060/client-tests.txt 2>&1
|
||||
./scripts/check-expression-rules.sh > logs/avatar-060/expression-tests.txt 2>&1
|
||||
mkdir -p logs/avatar-safe-061
|
||||
python3 scripts/check-reply-regressions.py > logs/avatar-safe-061/client-tests.txt 2>&1
|
||||
./scripts/check-expression-rules.sh > logs/avatar-safe-061/expression-tests.txt 2>&1
|
||||
python3 scripts/check-avatar-ui.py > logs/avatar-safe-061/ui-contract-tests.txt 2>&1
|
||||
python3 - <<'PY'
|
||||
from pathlib import Path
|
||||
import hashlib,json
|
||||
root=Path.cwd()
|
||||
paths=list((root/'app/src/main/java').rglob('*.kt'))+list((root/'tests').rglob('*.kt'))
|
||||
paths += [root/'scripts/check-reply-regressions.py',root/'scripts/check-expression-rules.sh',root/'scripts/check-avatar-regressions.sh']
|
||||
result={'status':'passed','jvm_entry_points':9,'real_device':'pending',
|
||||
paths=list((root/'app/src/main/java').rglob('*.kt'))+list((root/'app/src/androidTest').rglob('*.kt'))+list((root/'tests').rglob('*.kt'))
|
||||
paths += [root/p for p in ('app/build.gradle','scripts/check-reply-regressions.py','scripts/check-expression-rules.sh','scripts/check-avatar-regressions.sh','scripts/check-avatar-ui.py','scripts/import-avatar-graph.py','scripts/package-avatar-safe-release.sh','scripts/package-avatar-safe-release.py','scripts/package-avatar-engineering.py','scripts/package-avatar-natural.py','scripts/package-avatar-ui.py')]
|
||||
result={'status':'passed','jvm_entry_points':9,'uiSourceContracts':'passed','uiDeviceInstrumentation':'not_run','real_device':'pending',
|
||||
'hashes':{str(p.relative_to(root)):hashlib.sha256(p.read_bytes()).hexdigest() for p in sorted(paths)}}
|
||||
(root/'logs/avatar-060/client-tests.json').write_text(json.dumps(result,indent=2)+'\n')
|
||||
(root/'logs/avatar-safe-061/client-tests.json').write_text(json.dumps(result,indent=2)+'\n')
|
||||
print('PASS: nine JVM entry points, including avatar/native-head activity and call lifecycle; no real phone capture')
|
||||
PY
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Clean-home source contracts. Complements compiled UI and optional real-device probe;
|
||||
this does not claim to run Compose or prove device appearance/lifecycle."""
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
source=(ROOT/'app/src/main/java/com/gorios/lanvoice/avatar/CallScreen.kt').read_text()
|
||||
# Blank comments/strings without changing offsets, so nested lambdas can be inspected.
|
||||
pattern=r'"""[\s\S]*?"""|"(?:\\.|[^"\\])*"|//[^\n]*|/\*[\s\S]*?\*/'
|
||||
clean=re.sub(pattern,lambda m:' '*len(m[0]),source)
|
||||
|
||||
def block(marker,within=None):
|
||||
start,end=within or (0,len(source))
|
||||
at=clean.index(marker,start,end)
|
||||
left=clean.index('{',at+len(marker),end)
|
||||
depth=1;right=left+1
|
||||
while depth:
|
||||
assert right<end,'Unclosed Kotlin block'
|
||||
depth+=(clean[right]=='{')-(clean[right]=='}');right+=1
|
||||
return left+1,right-1
|
||||
|
||||
def text(span): return source[slice(*span)]
|
||||
def no_calls(span,names):
|
||||
for name in names:
|
||||
assert not re.search(r'\b'+name+r'\s*\(',clean[slice(*span)]),f'Forbidden {name} outside settings'
|
||||
|
||||
scaffold=block('fun CleanAvatarScaffold')
|
||||
home=block('Box(',scaffold)
|
||||
sheet=block('if(settingsOpen)',scaffold)
|
||||
assert text(home).count('avatar()')==1
|
||||
assert text(home).count('IconButton(')==1
|
||||
assert 'Alignment.BottomEnd' in text(home) and 'size(48.dp)' in text(home)
|
||||
assert 'WindowInsets.safeDrawing' in text(home)
|
||||
assert 'settingsOpen=true' in text(home)
|
||||
no_calls(home,['Text','TextButton','Button','OutlinedButton','AvatarDiagnostics','ExpressionControls','settings'])
|
||||
assert 'rememberSaveable { mutableStateOf(false) }' in text(scaffold)
|
||||
assert text(sheet).count('settings()')==1 and text(sheet).count('settingsOpen=false')==2
|
||||
no_calls(sheet,['avatar','AvatarPortrait','ContinuousPortrait','dial','render','startVoice','setContent'])
|
||||
assert 'LaunchedEffect' not in text(scaffold) and 'DisposableEffect' not in text(scaffold)
|
||||
for name in ('CallScreen','EngineeringPreviewScreen'):
|
||||
fn=block('fun '+name)
|
||||
avatar=block('CleanAvatarScaffold(avatar=',fn);settings=block('},settings=',fn)
|
||||
assert text(avatar).count('AvatarPortrait(')==1
|
||||
no_calls(avatar,['Text','AvatarDiagnostics','ExpressionControls','Button','TextButton'])
|
||||
assert 'AvatarDiagnostics(pack,video)' in text(settings)
|
||||
assert 'settingsOpen' not in text(fn)
|
||||
if name=='CallScreen':
|
||||
for expected in ('正在连接','重试连接','permissionMessage','onAuthorizeMic','onMute','onCamera','ExpressionControls','请求表达','onReport'):
|
||||
assert expected in text(settings)
|
||||
else:
|
||||
for expected in ('离线 avatar','Idle','Talk','Abort','Trace'):
|
||||
assert expected in text(settings)
|
||||
for name in ('AvatarPortrait','ContinuousPortrait'):
|
||||
fn=text(block('fun '+name))
|
||||
assert 'remember(pack)' in fn and 'DisposableEffect(view)' in fn
|
||||
assert 'settingsOpen' not in fn
|
||||
activity=(ROOT/'app/src/main/java/com/gorios/lanvoice/MainActivity.kt').read_text()
|
||||
offline=activity[activity.index('if (offlineAvatarPreview) {'):activity.index('audioOutput = AudioOutputGate')]
|
||||
assert 'EngineeringPreviewScreen' in offline and 'return' in offline
|
||||
for forbidden in ('VoiceSession(', 'ExpressionController(', 'permission.launch(', '.dial('): assert forbidden not in offline
|
||||
assert '本版仅修复界面;嘴层沿用 runtime03,变形问题尚未修复' in source
|
||||
print('PASS: clean home has persistent avatar + one 48dp safe-inset gear; normal/offline text and controls are sheet-only; sheet state never keys renderer/session; offline construction bypasses sensors/network. Source contracts only; real-device probe pending.')
|
||||
@@ -3,6 +3,8 @@
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
import argparse
|
||||
import json
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
CACHE = Path('/home/ubuntu/android-build/gradle-home/caches/modules-2/files-2.1')
|
||||
@@ -25,13 +27,38 @@ source = ROOT/'app/src/main/java/com/gorios/lanvoice'
|
||||
suites = [
|
||||
('session','ConnectionCheckKt', [source/'audio/PlaybackActivity.kt', source/'audio/VoiceSession.kt', source/'dialogue/ReplyEmotion.kt', source/'net/DialogueClient.kt', source/'expression/FaceCueRules.kt', source/'expression/ExpressionRules.kt', source/'expression/FaceDiagnostics.kt']),
|
||||
('playback','PlaybackCheckKt', [source/'audio/AudioPlayback.kt', source/'audio/PlaybackActivity.kt']),
|
||||
('avatar','AvatarCheckKt', [source/'avatar/AvatarController.kt', source/'avatar/CallIntent.kt', source/'avatar/AvatarVideoView.kt', source/'audio/PlaybackActivity.kt', source/'dialogue/ReplyEmotion.kt']),
|
||||
('avatar','AvatarCheckKt', [source/'avatar/ContinuousAvatarManifest.kt', source/'avatar/ContinuousMouth.kt', source/'avatar/ContinuousFramePresenter.kt', source/'avatar/ContinuousBodyRenderer.kt', source/'avatar/EngineeringGraphAdmission.kt', source/'avatar/OfflineAvatarTrace.kt', source/'avatar/NeutralGraphContract.kt', source/'avatar/SafeVideoDriver.kt', source/'avatar/CodecAnchorVideoPort.kt', source/'avatar/AutoConversation.kt', source/'avatar/SafeAvatarGraph.kt', source/'avatar/SafeTransitionPlanner.kt', source/'avatar/SafeAvatarManifest.kt', source/'avatar/TransitionDiagnostics.kt', source/'avatar/AvatarController.kt', source/'avatar/CallIntent.kt', source/'avatar/AvatarVideoView.kt', source/'audio/PlaybackActivity.kt', source/'dialogue/ReplyEmotion.kt']),
|
||||
('capture','CaptureCheckKt', [source/'audio/AudioCapture.kt']),
|
||||
('protocol','ProtocolCheckKt', [source/'net/DialogueProtocol.kt', source/'dialogue/ReplyEmotion.kt', source/'expression/FaceCueRules.kt', source/'expression/ExpressionRules.kt']),
|
||||
]
|
||||
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')
|
||||
args = parser.parse_args()
|
||||
for name, main, real in suites:
|
||||
if args.suite and name != args.suite: continue
|
||||
with tempfile.TemporaryDirectory(prefix=f'lan-voice-{name}-') as out:
|
||||
files = list((ROOT/'tests'/name).glob('*.kt')) + real
|
||||
if name == 'avatar' and args.runtime_manifest:
|
||||
def kotlin(value):
|
||||
if value is None: return 'null'
|
||||
if isinstance(value,bool): return str(value).lower()
|
||||
if isinstance(value,str): return json.dumps(value,ensure_ascii=False).replace('$','\\$')
|
||||
if isinstance(value,int): return str(value)+'L'
|
||||
if isinstance(value,float): return repr(value)
|
||||
if isinstance(value,list): return 'listOf<Any?>('+','.join(map(kotlin,value))+')'
|
||||
if isinstance(value,dict): return 'mapOf<String,Any?>('+','.join(kotlin(k)+' to '+kotlin(v) for k,v in value.items())+')'
|
||||
raise TypeError(type(value))
|
||||
import hashlib
|
||||
raw=args.runtime_manifest.read_bytes();digest=hashlib.sha256(raw).hexdigest()
|
||||
extra=Path(out)/'ActualRuntimeCheck.kt'
|
||||
extra.write_text('import com.gorios.lanvoice.avatar.*\nfun main() {\nval root='+kotlin(json.loads(raw))+'\n'+
|
||||
'val pack=checkNotNull(ContinuousAvatarManifest.read(root,"'+digest+'","'+digest+'",true,"runtime/"))\n'+
|
||||
'check(pack.patches.size==97 && pack.body.frameCount==97 && pack.curves.size==5)\n'+
|
||||
'println("PASS: actual exported runtime manifest parsed by production Kotlin, exact hash '+digest+'; 97 body/patch frames and five authored curves/routing")\n}\n')
|
||||
files.append(extra)
|
||||
subprocess.run([JAVA,'-cp',compiler,'org.jetbrains.kotlin.cli.jvm.K2JVMCompiler','-no-stdlib',
|
||||
'-no-reflect','-jvm-target','17','-nowarn','-classpath',cp,'-d',out, *map(str,files)],check=True,cwd=ROOT)
|
||||
subprocess.run([JAVA,'-cp',out+':'+cp,main],check=True,cwd=ROOT,timeout=30)
|
||||
if name == 'avatar' and args.runtime_manifest:
|
||||
subprocess.run([JAVA,'-cp',out+':'+cp,'ActualRuntimeCheckKt'],check=True,cwd=ROOT,timeout=30)
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Import an exact coordinator-reviewed neutral graph; runtime SHA allowlist is independent."""
|
||||
from pathlib import Path
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
PACK = 'a01-neutral-graph-v1'
|
||||
|
||||
def sha(data):
|
||||
return hashlib.sha256(data).hexdigest()
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('source', type=Path)
|
||||
parser.add_argument('--approved-manifest-sha', required=True)
|
||||
parser.add_argument('--verify-only', action='store_true')
|
||||
args = parser.parse_args()
|
||||
source = args.source.resolve(strict=True)
|
||||
raw = (source/'manifest.json').read_bytes()
|
||||
assert len(raw) <= 256_000
|
||||
assert re.fullmatch('[0-9a-f]{64}', args.approved_manifest_sha)
|
||||
assert sha(raw) == args.approved_manifest_sha, 'Manifest bytes differ from reviewed hash'
|
||||
manifest = json.loads(raw)
|
||||
assert manifest['schemaVersion'] == 1 and manifest['packId'] == PACK and manifest['identityId'] == 'a01'
|
||||
graph = manifest['safeTransitions']
|
||||
assert graph['version'] == 1 and graph['reviewStatus'] == 'approved'
|
||||
assert len(graph['clips']) == 5
|
||||
assert len(manifest['assets']) == 5
|
||||
files = {'manifest.json': raw}
|
||||
|
||||
def read(name, expected, maximum, pattern):
|
||||
assert re.fullmatch(pattern, name), f'Invalid delivery path: {name}'
|
||||
path = (source/name).resolve(strict=True)
|
||||
assert path.is_relative_to(source), 'Path escaped source pack'
|
||||
assert path.stat().st_size <= maximum
|
||||
data = path.read_bytes()
|
||||
assert sha(data) == expected, f'Asset hash mismatch: {name}'
|
||||
assert name not in files
|
||||
files[name] = data
|
||||
|
||||
ids = set()
|
||||
for row in manifest['assets']:
|
||||
assert row['id'] not in ids
|
||||
ids.add(row['id'])
|
||||
assert row['emotion'] == 'neutral' and row['intensity'] == 0 and row['hasAudio'] is False
|
||||
read(row['path'], row['sha256'], 16_000_000, r'(videos|delivery)/[A-Za-z0-9_.-]+\.mp4')
|
||||
assert {row['assetId'] for row in graph['clips']} == ids
|
||||
assert sum(map(len, files.values())) <= 128_000_000
|
||||
read(manifest['staticFallbackPath'], manifest['staticFallbackSha256'], 8_000_000, r'frames/[A-Za-z0-9_.-]+\.png')
|
||||
target = ROOT/'app/src/main/assets/avatar'/PACK
|
||||
# Preflight every existing byte before writing anything. Never erase another pack.
|
||||
for name, data in files.items():
|
||||
dest = target/name
|
||||
assert not dest.exists() or sha(dest.read_bytes()) == sha(data), f'Unknown existing file: {dest}'
|
||||
if not args.verify_only:
|
||||
for name, data in files.items():
|
||||
dest = target/name
|
||||
dest.parent.mkdir(parents=True, exist_ok=True, mode=0o700)
|
||||
fd, temporary = tempfile.mkstemp(prefix='.import-', dir=dest.parent)
|
||||
try:
|
||||
with os.fdopen(fd, 'wb') as stream:
|
||||
stream.write(data)
|
||||
os.chmod(temporary, 0o600)
|
||||
os.replace(temporary, dest)
|
||||
finally:
|
||||
if os.path.exists(temporary): os.unlink(temporary)
|
||||
print(json.dumps({'pack': PACK, 'manifestSha256': sha(raw), 'imported': not args.verify_only,
|
||||
'runtimeActivation': 'requires exact SHA allowlist plus complete approved graph validation',
|
||||
'rightsStatus': manifest.get('rightsStatus', 'unverified')}, indent=2))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Import a pinned accepted reference, or review motion bytes without activating them."""
|
||||
from pathlib import Path
|
||||
import argparse, hashlib, json, re
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
STILL_SHA = '5dd89c63879f250d05745b506bb79329aa69171b2f6d1660879af85cea926329'
|
||||
|
||||
def sha(data): return hashlib.sha256(data).hexdigest()
|
||||
|
||||
def review_motion(source):
|
||||
raw=(source/'manifest.json').read_bytes()
|
||||
assert len(raw)<=256000
|
||||
manifest=json.loads(raw)
|
||||
assert manifest['schemaVersion']==1 and manifest['identityId']=='a01'
|
||||
rows=manifest['assets']; assert isinstance(rows,list) and len(rows)<=32
|
||||
total=0
|
||||
for row in rows:
|
||||
name=row['path']; assert re.fullmatch(r'(videos|delivery)/[A-Za-z0-9_.-]+\.mp4',name)
|
||||
path=(source/name).resolve(strict=True); assert path.is_relative_to(source)
|
||||
data=path.read_bytes(); assert len(data)<=16000000 and sha(data)==row['sha256']
|
||||
assert row['emotion']=='neutral' and row['intensity']==0 and row['hasAudio'] is False
|
||||
total+=len(data); assert total<=128000000
|
||||
ext=manifest.get('safeTransitions',{})
|
||||
print(json.dumps({'manifestSha256':sha(raw),'reviewStatus':ext.get('reviewStatus','unknown'),
|
||||
'edgesDeclared':len(ext.get('transitions',[])),'activated':False,
|
||||
'note':'Read-only byte/hash review. No import/approval; runtime allowlist remains explicit and empty until coordinator approval.'},indent=2))
|
||||
|
||||
def main():
|
||||
parser=argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('source',type=Path)
|
||||
parser.add_argument('--review-motion-only',action='store_true')
|
||||
parser.add_argument('--arms-reference',action='store_true',help='SOURCE is the exact accepted original crossed-arms PNG')
|
||||
args=parser.parse_args(); source=args.source.resolve(strict=True)
|
||||
if args.arms_reference:
|
||||
assert not args.review_motion_only
|
||||
expected='36a078ad9e1d2929612e9baa2af524bda90dafceddc4515dd448fc08121d7dd2'
|
||||
assert source.is_file() and source.stat().st_size<=8_000_000
|
||||
data=source.read_bytes(); assert sha(data)==expected
|
||||
dest=ROOT/'app/src/main/assets/avatar/a01-standing-arms-reference/frames/reference.png'
|
||||
assert not dest.exists() or sha(dest.read_bytes())==expected, 'Unknown existing static asset'
|
||||
dest.parent.mkdir(parents=True,exist_ok=True,mode=0o700)
|
||||
dest.write_bytes(data); dest.chmod(0o600)
|
||||
print(json.dumps({'staticReferenceSha256':expected,'motionActivated':False,'rightsStatus':'unverified'}))
|
||||
return
|
||||
if args.review_motion_only: review_motion(source); return
|
||||
raw=(source/'reference-manifest.json').read_bytes(); manifest=json.loads(raw)
|
||||
assert manifest['schemaVersion']==1 and manifest['packId']=='a01-standing-v2' and manifest['identityId']=='a01'
|
||||
assert manifest['referencePath']=='frames/standing-reference.png' and manifest['sha256']==STILL_SHA
|
||||
image=(source/manifest['referencePath']).resolve(strict=True); assert image.is_relative_to(source)
|
||||
data=image.read_bytes(); assert len(data)<=8000000 and sha(data)==STILL_SHA
|
||||
target=ROOT/'app/src/main/assets/avatar/a01-standing-v2'
|
||||
files={'frames/standing-reference.png':data,'reference-manifest.json':raw}
|
||||
for name,contents in files.items():
|
||||
dest=target/name
|
||||
assert not dest.exists() or sha(dest.read_bytes())==sha(contents),f'Unknown existing asset: {dest}'
|
||||
for name,contents in files.items():
|
||||
dest=target/name; dest.parent.mkdir(parents=True,exist_ok=True,mode=0o700)
|
||||
dest.write_bytes(contents); dest.chmod(0o600)
|
||||
print(json.dumps({'pack':'a01-standing-v2','staticIdentityApproval':'user confirmed this exact image for testing',
|
||||
'sha256':STILL_SHA,'motionActivated':False,'rightsStatus':'unverified'},indent=2))
|
||||
|
||||
if __name__=='__main__': main()
|
||||
@@ -0,0 +1,135 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Pinned controlled01 internal debug experiment. Never grants production approval."""
|
||||
from pathlib import Path
|
||||
import argparse, hashlib, json, os, re, subprocess, tempfile, urllib.request, zipfile
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SOURCE = ROOT/'.runtime/avatar-imports/a01-neutral-graph-v1'
|
||||
PACK = ROOT/'app/src/main/assets/avatar/a01-neutral-graph-v1'
|
||||
LOG = ROOT/'logs/avatar-engineering-061'
|
||||
ARTIFACT = ROOT/'artifacts/lan-voice-v061-engineering-arm64-debug.apk'
|
||||
TOOLS = Path('/home/ubuntu/android-build/sdk/build-tools/34.0.0')
|
||||
PIN = 'e6b6e9a6e555cafb3ca7e0878600c23c4d76f13fb15d98d5f0cd8e5b192a3a09'
|
||||
OLD = '37f789820e86ac1656bda546f47ece3e4533ff8fc54614b171fd8a42accaa52e'
|
||||
sha = lambda data: hashlib.sha256(data).hexdigest()
|
||||
|
||||
def run(args, name):
|
||||
result = subprocess.run(list(map(str,args)),cwd=ROOT,text=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
|
||||
(LOG/name).write_text(result.stdout)
|
||||
assert result.returncode == 0, f'{args[0]} failed: {LOG/name}'
|
||||
return result.stdout
|
||||
|
||||
def import_pack():
|
||||
raw = (SOURCE/'manifest.json').read_bytes()
|
||||
assert sha(raw) == PIN, 'Authorized manifest drift: stop, do not admit another hash'
|
||||
m = json.loads(raw)
|
||||
assert m['publishApproval'] is False and m['safeTransitions']['reviewStatus'] == 'pending'
|
||||
assert m['naturalQualityStatus'] == 'not_approved' and not m['approvedEdges'] and not m['safeExits']
|
||||
files={'manifest.json':raw}
|
||||
rows=m['assets']; assert len(rows)==5
|
||||
assert {r['id'] for r in rows}=={'idle','opening','talk1','talk2','end-talk'}
|
||||
for row in rows + [m['anchorImages'][0]]:
|
||||
name=row['path']
|
||||
assert name==('controlled-01/delivery/'+row['id']+'.mp4' if row['id']!='A' else 'anchors/A.png')
|
||||
source=(SOURCE/name).resolve(strict=True)
|
||||
assert source.is_relative_to(SOURCE.resolve()) and source.stat().st_size <= 16_000_000
|
||||
data=source.read_bytes(); assert sha(data)==row['sha256']
|
||||
files[name]=data
|
||||
# Preflight every destination; preserve unknown files rather than overwrite them.
|
||||
for name,data in files.items():
|
||||
dest=PACK/name
|
||||
assert not dest.exists() or dest.read_bytes()==data, f'Unknown import at {dest}'
|
||||
for name,data in files.items():
|
||||
dest=PACK/name; dest.parent.mkdir(parents=True,exist_ok=True,mode=0o700)
|
||||
if not dest.exists():
|
||||
fd,tmp=tempfile.mkstemp(prefix='.engineering-',dir=dest.parent)
|
||||
try:
|
||||
with os.fdopen(fd,'wb') as stream: stream.write(data)
|
||||
os.chmod(tmp,0o600); os.replace(tmp,dest)
|
||||
finally:
|
||||
if os.path.exists(tmp): os.unlink(tmp)
|
||||
assert (SOURCE/'manifest.json').read_bytes()==raw
|
||||
return m,files
|
||||
|
||||
def decode(m):
|
||||
evidence={}
|
||||
for row in m['assets']:
|
||||
path=PACK/row['path']
|
||||
output=run(['/home/ubuntu/miniconda3/envs/gori-speech/bin/ffprobe','-v','error','-show_streams','-show_frames','-of','json',path],f"probe-{row['id']}.json")
|
||||
probe=json.loads(output); assert len(probe['streams'])==1
|
||||
stream=probe['streams'][0]; frames=probe['frames']
|
||||
assert stream['codec_type']=='video' and stream['codec_name']=='h264' and stream['pix_fmt']=='yuv420p'
|
||||
assert stream['width']==480 and stream['height']==848 and stream['r_frame_rate']=='24/1'
|
||||
assert len(frames)==row['frameCount']
|
||||
pts=[float(f['best_effort_timestamp_time']) for f in frames]
|
||||
assert all(abs(t-i/24)<0.00001 for i,t in enumerate(pts))
|
||||
assert frames[0]['key_frame']==1
|
||||
run(['/home/ubuntu/gori-bin/ffmpeg','-hide_banner','-v','error','-xerror','-i',path,'-map','0:v:0','-f','null','-'],f"decode-{row['id']}.txt")
|
||||
evidence[row['id']]={'frames':len(frames),'ptsUs':[round(t*1e6) for t in pts],'sha256':row['sha256'],'entryFrame':0,'exitFrame':m['candidateGraph']['earliestExitFrames'][row['id']]}
|
||||
(LOG/'decode-evidence.json').write_text(json.dumps(evidence,indent=2)+'\n')
|
||||
|
||||
def tested():
|
||||
tests=json.loads((ROOT/'logs/avatar-safe-061/client-tests.json').read_text())
|
||||
assert tests['status']=='passed' and tests['jvm_entry_points']==9
|
||||
for name,digest in tests['hashes'].items(): assert sha((ROOT/name).read_bytes())==digest, f'Untested source: {name}'
|
||||
assert re.search(r'Ran 74 tests .*\n\nOK\s*$',(ROOT/'logs/avatar-safe-061/gateway-tests.txt').read_text())
|
||||
assert sha((ROOT/'artifacts/lan-voice-v060-arm64-debug.apk').read_bytes())==OLD
|
||||
loader=(ROOT/'app/src/main/java/com/gorios/lanvoice/avatar/AvatarPack.kt').read_text()
|
||||
assert 'APPROVED_MOTION_HASHES = emptySet<String>()' in loader
|
||||
assert 'BuildConfig.DEBUG && BuildConfig.AVATAR_ENGINEERING' in loader
|
||||
|
||||
def verify(apk,files):
|
||||
badge=run([TOOLS/'aapt','dump','badging',apk],'badging.txt')
|
||||
for s in ("name='com.gorios.lanvoice'","versionCode='12'","versionName='0.6.1-dev'","sdkVersion:'26'","targetSdkVersion:'34'"):
|
||||
assert s in badge,s
|
||||
assert re.search(r'^native-code: (.+)$',badge,re.M)[1].strip()=="'arm64-v8a'"
|
||||
signature=run([TOOLS/'apksigner','verify','--verbose','--print-certs',apk],'signature.txt')
|
||||
pattern=r'Signer #1 certificate SHA-256 digest: (\w+)'
|
||||
cert=re.search(pattern,signature)[1]
|
||||
for version in ('051','052','060'):
|
||||
other=run([TOOLS/'apksigner','verify','--print-certs',ROOT/f'artifacts/lan-voice-v{version}-arm64-debug.apk'],f'signature-{version}.txt')
|
||||
assert re.search(pattern,other)[1]==cert
|
||||
expected={'assets/avatar/a01-neutral-graph-v1/'+n:d for n,d in files.items()}
|
||||
still='assets/avatar/a01-standing-arms-reference/frames/reference.png'
|
||||
data=(ROOT/'app/src/main'/still).read_bytes()
|
||||
assert sha(data)=='36a078ad9e1d2929612e9baa2af524bda90dafceddc4515dd448fc08121d7dd2'
|
||||
expected[still]=data
|
||||
with zipfile.ZipFile(apk) as z:
|
||||
actual={n for n in z.namelist() if n.startswith('assets/avatar/') and not n.endswith('/')}
|
||||
assert actual==set(expected),f'Unexpected APK avatar assets: {actual-set(expected)}'
|
||||
for name,data in expected.items():
|
||||
assert z.read(name)==data,name
|
||||
if name.endswith('.mp4'): assert z.getinfo(name).compress_type==zipfile.ZIP_STORED
|
||||
return cert
|
||||
|
||||
def main():
|
||||
parser=argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--import-only',action='store_true')
|
||||
parser.add_argument('--verify-existing',action='store_true')
|
||||
args=parser.parse_args(); LOG.mkdir(parents=True,exist_ok=True)
|
||||
m,files=import_pack()
|
||||
if args.import_only:
|
||||
decode(m); print('PASS: exact pending manifest imported unchanged, five CFR clips fully decoded, final-frame technical gates only'); return
|
||||
tested()
|
||||
if args.verify_existing: assert ARTIFACT.is_file(); cert=verify(ARTIFACT,files)
|
||||
else:
|
||||
assert not ARTIFACT.exists(),'Engineering artifact already exists; do not overwrite'
|
||||
run([ROOT/'scripts/build.sh','assembleDebug','-PavatarEngineering=true'],'assemble.txt')
|
||||
built=ROOT/'app/build/outputs/apk/debug/app-debug.apk'; cert=verify(built,files)
|
||||
with ARTIFACT.open('xb') as stream: stream.write(built.read_bytes())
|
||||
digest=sha(ARTIFACT.read_bytes()); checksum=f'{digest} {ARTIFACT.name}\n'.encode()
|
||||
sidecar=ARTIFACT.with_suffix('.apk.sha256')
|
||||
assert not sidecar.exists() or sidecar.read_bytes()==checksum
|
||||
sidecar.write_bytes(checksum)
|
||||
url='http://192.168.31.124:8080/'+ARTIFACT.name
|
||||
opener=urllib.request.build_opener(urllib.request.ProxyHandler({}))
|
||||
with opener.open(url,timeout=15) as response:
|
||||
data=response.read(); assert response.status==200 and len(data)==ARTIFACT.stat().st_size and sha(data)==digest
|
||||
with opener.open(url+'.sha256',timeout=15) as response: assert response.status==200 and response.read()==checksum
|
||||
assert sha((ROOT/'artifacts/lan-voice-v060-arm64-debug.apk').read_bytes())==OLD
|
||||
result={'scope':'engineering_debug_only','version':'0.6.1-dev','versionCode':12,'apk':str(ARTIFACT),'bytes':ARTIFACT.stat().st_size,'sha256':digest,
|
||||
'url':url,'sameCertificateSha256':cert,'manifestSha256':PIN,'productionApproval':False,'naturalQuality':'not_approved','deviceTests':'pending',
|
||||
'perceivedMouthLatencyMs':None,'compliance1s':'not_measured','httpBytesVerified':True,'gitCommitPush':False}
|
||||
(LOG/'delivery.json').write_text(json.dumps(result,indent=2)+'\n'); print(json.dumps(result,indent=2))
|
||||
|
||||
if __name__=='__main__': main()
|
||||
@@ -0,0 +1,162 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Pinned runtime03 natural engineering candidate; no final approval, overwrite or device action."""
|
||||
from pathlib import Path
|
||||
import argparse, hashlib, importlib.util, json, os, re, subprocess, tempfile, urllib.request, zipfile
|
||||
from PIL import Image
|
||||
import numpy as np
|
||||
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
SOURCE=ROOT/'.runtime/avatar-imports/a01-neutral-graph-v1/runtime-03'
|
||||
PACK=ROOT/'app/src/main/assets/avatar/a01-neutral-graph-v1/runtime-03'
|
||||
LOG=ROOT/'logs/avatar-natural-061'
|
||||
ARTIFACT=ROOT/'artifacts/lan-voice-v061-natural-engineering-arm64-debug.apk'
|
||||
PIN='87ad2b2ad0e96fe64943692da363c856939ad4aad57073c589d53130c2f2073c'
|
||||
BASELINE='9fcfd258a214be0fbe4a3ebd8141221f078ba0e6af0aaf6955437d725eecf814'
|
||||
TOOLS=Path('/home/ubuntu/android-build/sdk/build-tools/34.0.0')
|
||||
sha=lambda data:hashlib.sha256(data).hexdigest()
|
||||
|
||||
def run(args,name):
|
||||
result=subprocess.run(list(map(str,args)),cwd=ROOT,text=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
|
||||
(LOG/name).write_text(result.stdout)
|
||||
assert result.returncode==0,f'{args[0]} failed: {LOG/name}'
|
||||
return result.stdout
|
||||
|
||||
def import_runtime():
|
||||
raw=(SOURCE/'manifest.json').read_bytes();assert sha(raw)==PIN,'Runtime manifest drift; stop admission'
|
||||
m=json.loads(raw)
|
||||
assert m['runtimeReady'] is True and m['publishApproval'] is False
|
||||
assert m['safeTransitions']['reviewStatus']=='pending' and not m['approvedEdges']
|
||||
assert m['naturalQualityStatus']=='pending' and m['deviceTestStatus']=='pending'
|
||||
body=m['body'];assert body['frameCount']==97 and body['durationUs']==4041667 and body['hasAudio'] is False
|
||||
assert body['width']==480 and body['height']==848 and body['fpsNumerator']==24 and body['fpsDenominator']==1
|
||||
assert m['patchFormat']['alphaEncoding']=='straight_unassociated'
|
||||
files={'manifest.json':raw};patches=m['patches'];assert len(patches)==97
|
||||
size=0
|
||||
for index,row in enumerate([body]+patches):
|
||||
name=row['path']
|
||||
assert re.fullmatch(r'body/[A-Za-z0-9_.-]+\.mp4' if index==0 else r'patches/[A-Za-z0-9_.-]+\.png',name)
|
||||
path=(SOURCE/name).resolve(strict=True);assert path.is_relative_to(SOURCE.resolve())
|
||||
assert path.stat().st_size<16_000_000 if index==0 else path.stat().st_size<256_000
|
||||
data=path.read_bytes();assert sha(data)==row['sha256']
|
||||
assert name not in files;files[name]=data
|
||||
if index:
|
||||
assert row['frameIndex']==index-1 and abs(row['ptsUs']-(index-1)*1000000//24)<=2
|
||||
assert 0<=row['x'] and 0<=row['y'] and row['x']+row['width']<=480 and row['y']+row['height']<=848
|
||||
with Image.open(path) as im:
|
||||
assert im.mode=='RGBA' and im.size==(row['width'],row['height'])
|
||||
size+=row['width']*row['height']*4
|
||||
assert size<=8_000_000
|
||||
for name,data in files.items():
|
||||
dest=PACK/name;assert not dest.exists() or dest.read_bytes()==data,f'Unknown destination: {dest}'
|
||||
for name,data in files.items():
|
||||
dest=PACK/name;dest.parent.mkdir(parents=True,exist_ok=True,mode=0o700)
|
||||
if not dest.exists():
|
||||
fd,tmp=tempfile.mkstemp(prefix='.runtime03-',dir=dest.parent)
|
||||
try:
|
||||
with os.fdopen(fd,'wb') as stream:stream.write(data)
|
||||
os.chmod(tmp,0o600);os.replace(tmp,dest)
|
||||
finally:
|
||||
if os.path.exists(tmp):os.unlink(tmp)
|
||||
assert sha((SOURCE/'manifest.json').read_bytes())==PIN
|
||||
return m,files
|
||||
|
||||
def verify_decode(m):
|
||||
body=m['body'];path=PACK/body['path']
|
||||
probe=json.loads(run(['/home/ubuntu/miniconda3/envs/gori-speech/bin/ffprobe','-v','error','-show_streams','-show_frames','-of','json',path],'body-probe.json'))
|
||||
assert len(probe['streams'])==1 and len(probe['frames'])==97
|
||||
stream=probe['streams'][0];assert stream['codec_type']=='video' and stream['codec_name']=='h264' and stream['pix_fmt']=='yuv420p'
|
||||
assert stream['width']==480 and stream['height']==848 and stream['r_frame_rate']=='24/1'
|
||||
assert all(abs(float(f['best_effort_timestamp_time'])-i/24)<1e-5 for i,f in enumerate(probe['frames']))
|
||||
run(['/home/ubuntu/gori-bin/ffmpeg','-v','error','-xerror','-i',path,'-map','0:v:0','-f','null','-'],'body-full-decode.txt')
|
||||
# Stream frames without keeping wholebody frame stacks in memory. Independently
|
||||
# validate exact alpha-zero identity and straight vs premul source-over algebra.
|
||||
process=subprocess.Popen(['/home/ubuntu/gori-bin/ffmpeg','-v','error','-i',str(path),'-map','0:v:0','-f','rawvideo','-pix_fmt','rgb24','-'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||
checks=[]
|
||||
try:
|
||||
for index,p in enumerate(m['patches']):
|
||||
data=process.stdout.read(480*848*3);assert len(data)==480*848*3
|
||||
bodypixels=np.frombuffer(data,np.uint8).reshape(848,480,3)
|
||||
patch=np.asarray(Image.open(PACK/p['path']).convert('RGBA'),np.float32)/255
|
||||
x,y=p['x'],p['y'];assert isinstance(x,int) and isinstance(y,int)
|
||||
base=bodypixels[y:y+p['height'],x:x+p['width']].astype(np.float32)/255
|
||||
a=patch[:,:,3:4];rgb=patch[:,:,:3]
|
||||
for g in (0,.5,1):
|
||||
straight=base*(1-g*a)+rgb*(g*a)
|
||||
premul=base*(1-g*a)+(rgb*a)*g
|
||||
assert np.max(np.abs(straight-premul))<1e-6
|
||||
if g==0:assert np.array_equal(straight,base)
|
||||
if index in (0,17,34,43,52,78,96):
|
||||
checks.append({'frame':index,'globalAlpha':g,'alphaZeroExactBody':True if g==0 else None,
|
||||
'straightVsPremulMaxDiff':float(np.max(np.abs(straight-premul))),
|
||||
'scope':'CPU algebra only; Android GPU/Bitmap colors and perceived naturalness pending'})
|
||||
assert process.stdout.read(1)==b'';assert process.wait(timeout=20)==0
|
||||
finally:
|
||||
if process.poll() is None:process.kill();process.wait()
|
||||
(LOG/'independent-alpha-checks.json').write_text(json.dumps(checks,indent=2)+'\n')
|
||||
|
||||
def tests_current():
|
||||
tests=json.loads((ROOT/'logs/avatar-safe-061/client-tests.json').read_text())
|
||||
assert tests['status']=='passed' and tests['jvm_entry_points']==9
|
||||
for name,h in tests['hashes'].items():assert sha((ROOT/name).read_bytes())==h,f'Untested source: {name}'
|
||||
assert re.search(r'Ran 74 tests .*\n\nOK\s*$',(ROOT/'logs/avatar-safe-061/gateway-tests.txt').read_text())
|
||||
assert PIN in (LOG/'actual-manifest-tests.txt').read_text() and 'PASS: actual exported runtime manifest parsed' in (LOG/'actual-manifest-tests.txt').read_text()
|
||||
assert sha((ROOT/'artifacts/lan-voice-v061-engineering-arm64-debug.apk').read_bytes())==BASELINE
|
||||
assert sha((ROOT/'artifacts/lan-voice-v060-arm64-debug.apk').read_bytes())=='37f789820e86ac1656bda546f47ece3e4533ff8fc54614b171fd8a42accaa52e'
|
||||
assert 'APPROVED_MOTION_HASHES = emptySet<String>()' in (ROOT/'app/src/main/java/com/gorios/lanvoice/avatar/AvatarPack.kt').read_text()
|
||||
|
||||
def verify(apk,files,version_code=13,version_name='0.6.1-natural-dev'):
|
||||
badge=run([TOOLS/'aapt','dump','badging',apk],'badging.txt')
|
||||
for value in ("name='com.gorios.lanvoice'",f"versionCode='{version_code}'",f"versionName='{version_name}'","sdkVersion:'26'","targetSdkVersion:'34'"):
|
||||
assert value in badge,value
|
||||
assert re.search(r'^native-code: (.+)$',badge,re.M)[1].strip()=="'arm64-v8a'"
|
||||
signature=run([TOOLS/'apksigner','verify','--verbose','--print-certs',apk],'signature.txt')
|
||||
pattern=r'Signer #1 certificate SHA-256 digest: (\w+)';cert=re.search(pattern,signature)[1]
|
||||
for suffix in ('051','052','060','061-engineering'):
|
||||
other=run([TOOLS/'apksigner','verify','--print-certs',ROOT/f'artifacts/lan-voice-v{suffix}-arm64-debug.apk'],f'signature-{suffix}.txt')
|
||||
assert re.search(pattern,other)[1]==cert
|
||||
# Keep controlled01 code/data as the existing engineering baseline; verify every
|
||||
# byte without admitting any natural02/03 review demo as a runtime substitute.
|
||||
base=ROOT/'app/src/main/assets/avatar/a01-neutral-graph-v1'
|
||||
oldraw=(base/'manifest.json').read_bytes();assert sha(oldraw)=='e6b6e9a6e555cafb3ca7e0878600c23c4d76f13fb15d98d5f0cd8e5b192a3a09'
|
||||
old=json.loads(oldraw)
|
||||
expected={'assets/avatar/a01-neutral-graph-v1/runtime-03/'+n:d for n,d in files.items()}
|
||||
expected['assets/avatar/a01-neutral-graph-v1/manifest.json']=oldraw
|
||||
for row in old['assets']+[old['anchorImages'][0]]:
|
||||
data=(base/row['path']).read_bytes();assert sha(data)==row['sha256']
|
||||
expected['assets/avatar/a01-neutral-graph-v1/'+row['path']]=data
|
||||
still='assets/avatar/a01-standing-arms-reference/frames/reference.png';data=(ROOT/'app/src/main'/still).read_bytes()
|
||||
assert sha(data)=='36a078ad9e1d2929612e9baa2af524bda90dafceddc4515dd448fc08121d7dd2';expected[still]=data
|
||||
with zipfile.ZipFile(apk) as z:
|
||||
actual={n for n in z.namelist() if n.startswith('assets/avatar/') and not n.endswith('/')}
|
||||
assert actual==set(expected),f'Unexpected/missing avatar files: {actual^set(expected)}'
|
||||
for name,data in expected.items():
|
||||
assert z.read(name)==data,name
|
||||
if name.endswith('.mp4'):assert z.getinfo(name).compress_type==zipfile.ZIP_STORED
|
||||
return cert
|
||||
|
||||
def main():
|
||||
parser=argparse.ArgumentParser(description=__doc__);parser.add_argument('--import-only',action='store_true');parser.add_argument('--verify-existing',action='store_true')
|
||||
args=parser.parse_args();LOG.mkdir(parents=True,exist_ok=True)
|
||||
m,files=import_runtime()
|
||||
if args.import_only:
|
||||
verify_decode(m);print('PASS: runtime03 exact candidate manifest, body/97 RGBA patch bytes, complete CFR decode, independent alpha-zero/straight-premul algebra');return
|
||||
tests_current()
|
||||
if args.verify_existing:assert ARTIFACT.is_file();cert=verify(ARTIFACT,files)
|
||||
else:
|
||||
assert not ARTIFACT.exists(),'Preserve existing natural engineering artifact; no overwrite'
|
||||
run([ROOT/'scripts/build.sh','assembleDebug','-PavatarNatural=true','-PnaturalManifestSha='+PIN],'assemble.txt')
|
||||
built=ROOT/'app/build/outputs/apk/debug/app-debug.apk';cert=verify(built,files)
|
||||
with ARTIFACT.open('xb') as stream:stream.write(built.read_bytes())
|
||||
digest=sha(ARTIFACT.read_bytes());checksum=f'{digest} {ARTIFACT.name}\n'.encode();side=ARTIFACT.with_suffix('.apk.sha256')
|
||||
assert not side.exists() or side.read_bytes()==checksum;side.write_bytes(checksum)
|
||||
url='http://192.168.31.124:8080/'+ARTIFACT.name;opener=urllib.request.build_opener(urllib.request.ProxyHandler({}))
|
||||
with opener.open(url,timeout=15) as response:
|
||||
data=response.read();assert response.status==200 and len(data)==ARTIFACT.stat().st_size and sha(data)==digest
|
||||
with opener.open(url+'.sha256',timeout=15) as response:assert response.status==200 and response.read()==checksum
|
||||
result={'scope':'natural_engineering_candidate_only','version':'0.6.1-natural-dev','versionCode':13,'apk':str(ARTIFACT),'url':url,
|
||||
'bytes':ARTIFACT.stat().st_size,'sha256':digest,'sameCertificateSha256':cert,'manifestSha256':PIN,'httpBytesVerified':True,
|
||||
'productionApproval':False,'naturalQuality':'pending_device_visual_review','bodyLoopSeam':'pending_device_visual_review','actualPerceivedMouthLatencyMs':None,
|
||||
'devicePerf':'not_tested','compliance1s':'not_certified','gitCommitPush':False,'offlineExtra':'avatar_offline_preview'}
|
||||
(LOG/'delivery.json').write_text(json.dumps(result,indent=2)+'\n');print(json.dumps(result,indent=2))
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,133 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build/verify 0.6.1 only after exact graph review, tests, private import and signature checks."""
|
||||
from pathlib import Path
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
import subprocess
|
||||
import urllib.request
|
||||
import zipfile
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
LOGS = ROOT/'logs/avatar-safe-061'
|
||||
TOOLS = Path('/home/ubuntu/android-build/sdk/build-tools/34.0.0')
|
||||
ARTIFACT = ROOT/'artifacts/lan-voice-v061-arm64-debug.apk'
|
||||
PACK = ROOT/'app/src/main/assets/avatar/a01-neutral-graph-v1'
|
||||
RETAINED_060_SHA = '37f789820e86ac1656bda546f47ece3e4533ff8fc54614b171fd8a42accaa52e'
|
||||
|
||||
def sha(data):
|
||||
return hashlib.sha256(data).hexdigest()
|
||||
|
||||
def command(args, log):
|
||||
result = subprocess.run(list(map(str,args)), cwd=ROOT, text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
(LOGS/log).write_text(result.stdout)
|
||||
assert result.returncode == 0, f'{args[0]} failed; see {LOGS/log}'
|
||||
return result.stdout
|
||||
|
||||
def preflight():
|
||||
tests = json.loads((LOGS/'client-tests.json').read_text())
|
||||
assert tests['status'] == 'passed' and tests['jvm_entry_points'] == 9
|
||||
for name, expected in tests['hashes'].items():
|
||||
assert sha((ROOT/name).read_bytes()) == expected, f'Tested source changed: {name}'
|
||||
gateway = (LOGS/'gateway-tests.txt').read_text()
|
||||
assert re.search(r'Ran 74 tests .*\n\nOK\s*$', gateway), 'Full isolated gateway regression required'
|
||||
raw = (ROOT/'docs/avatar/a01-neutral-graph-v1.manifest.json').read_bytes()
|
||||
assert raw == (PACK/'manifest.json').read_bytes(), 'Reviewed text manifest differs from imported bytes'
|
||||
digest = sha(raw)
|
||||
loader = (ROOT/'app/src/main/java/com/gorios/lanvoice/avatar/AvatarPack.kt').read_text()
|
||||
allowlist = re.search(r'APPROVED_MOTION_HASHES\s*=\s*setOf\((.*?)\)', loader, re.S)
|
||||
assert allowlist and digest in re.findall(r'"([0-9a-f]{64})"', allowlist[1]), 'Exact reviewed SHA is not allowlisted'
|
||||
manifest = json.loads(raw)
|
||||
assert manifest['packId'] == 'a01-neutral-graph-v1' and manifest['safeTransitions']['reviewStatus'] == 'approved'
|
||||
assert len(manifest['assets']) == 5
|
||||
# The production Kotlin loader also validates completeness; preserve the review
|
||||
# record identifying the exact hash and every actual junction, never self-approve here.
|
||||
review = json.loads((ROOT/'docs/avatar/a01-neutral-graph-v1.review.json').read_text())
|
||||
assert review['manifestSha256'] == digest and review['graphReviewStatus'] == 'approved'
|
||||
assert review['requiredJunctionsReviewed'] is True and review['talkQualityReviewed'] is True
|
||||
subprocess.run(['python3', str(ROOT/'scripts/import-avatar-graph.py'),str(PACK),
|
||||
'--approved-manifest-sha', digest, '--verify-only'],check=True,cwd=ROOT)
|
||||
old = ROOT/'artifacts/lan-voice-v060-arm64-debug.apk'
|
||||
assert sha(old.read_bytes()) == RETAINED_060_SHA, 'Retained 0.6.0 differs'
|
||||
return manifest, digest
|
||||
|
||||
def verify(apk, manifest):
|
||||
badge = command([TOOLS/'aapt','dump','badging',apk],'badging.txt')
|
||||
for value in ("name='com.gorios.lanvoice'","versionCode='12'","versionName='0.6.1'","sdkVersion:'26'","targetSdkVersion:'34'"):
|
||||
assert value in badge, value
|
||||
assert re.search(r'^native-code: (.+)$',badge,re.M)[1].strip() == "'arm64-v8a'"
|
||||
sig = command([TOOLS/'apksigner','verify','--verbose','--print-certs',apk],'signature.txt')
|
||||
pattern = r'Signer #1 certificate SHA-256 digest: (\w+)'
|
||||
for version in ('051','052','060'):
|
||||
retained = ROOT/f'artifacts/lan-voice-v{version}-arm64-debug.apk'
|
||||
output = command([TOOLS/'apksigner','verify','--print-certs',retained],f'signature-{version}.txt')
|
||||
assert re.search(pattern,output)[1] == re.search(pattern,sig)[1], 'Signing certificate mismatch'
|
||||
expected = {'assets/avatar/a01-neutral-graph-v1/manifest.json': (PACK/'manifest.json').read_bytes()}
|
||||
for row in manifest['assets']:
|
||||
data = (PACK/row['path']).read_bytes()
|
||||
assert sha(data) == row['sha256']
|
||||
expected['assets/avatar/a01-neutral-graph-v1/'+row['path']] = data
|
||||
still = manifest['staticFallbackPath']
|
||||
data = (PACK/still).read_bytes()
|
||||
assert sha(data) == manifest['staticFallbackSha256']
|
||||
expected['assets/avatar/a01-neutral-graph-v1/'+still] = data
|
||||
fallback = 'assets/avatar/a01-standing-arms-reference/frames/reference.png'
|
||||
data = (ROOT/'app/src/main'/fallback).read_bytes()
|
||||
assert sha(data) == '36a078ad9e1d2929612e9baa2af524bda90dafceddc4515dd448fc08121d7dd2'
|
||||
expected[fallback] = data
|
||||
with zipfile.ZipFile(apk) as archive:
|
||||
actual = {name for name in archive.namelist() if name.startswith('assets/avatar/') and not name.endswith('/')}
|
||||
assert actual == set(expected), 'Unexpected or missing private avatar assets in APK'
|
||||
for name,data in expected.items():
|
||||
assert archive.read(name) == data, name
|
||||
if name.endswith('.mp4'): assert archive.getinfo(name).compress_type == zipfile.ZIP_STORED
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--preflight-only',action='store_true')
|
||||
parser.add_argument('--verify-existing',action='store_true',help='Verify preserved APK/HTTP again without rebuilding')
|
||||
args = parser.parse_args()
|
||||
LOGS.mkdir(parents=True,exist_ok=True)
|
||||
manifest, manifest_sha = preflight()
|
||||
if args.preflight_only:
|
||||
print('PASS: tested source, exact reviewed graph and private import preflight')
|
||||
return
|
||||
if args.verify_existing:
|
||||
assert ARTIFACT.is_file()
|
||||
verify(ARTIFACT,manifest)
|
||||
else:
|
||||
assert not ARTIFACT.exists(), 'Refuse overwriting 0.6.1 artifact'
|
||||
command([ROOT/'scripts/build.sh'],'assemble.txt')
|
||||
built = ROOT/'app/build/outputs/apk/debug/app-debug.apk'
|
||||
verify(built,manifest)
|
||||
ARTIFACT.parent.mkdir(parents=True,exist_ok=True)
|
||||
with ARTIFACT.open('xb') as stream: stream.write(built.read_bytes())
|
||||
digest = sha(ARTIFACT.read_bytes())
|
||||
sidecar = ARTIFACT.with_suffix('.apk.sha256')
|
||||
checksum = f'{digest} {ARTIFACT.name}\n'.encode()
|
||||
assert not sidecar.exists() or sidecar.read_bytes() == checksum
|
||||
sidecar.write_bytes(checksum)
|
||||
opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))
|
||||
url = None
|
||||
for prefix in ('','artifacts/'):
|
||||
candidate = 'http://192.168.31.124:8080/'+prefix+ARTIFACT.name
|
||||
try:
|
||||
with opener.open(candidate,timeout=15) as response:
|
||||
data = response.read()
|
||||
assert response.status == 200 and len(data) == ARTIFACT.stat().st_size and sha(data) == digest
|
||||
with opener.open(candidate+'.sha256',timeout=15) as response:
|
||||
assert response.status == 200 and response.read() == checksum
|
||||
url = candidate
|
||||
break
|
||||
except Exception: pass
|
||||
assert url, 'APK preserved; matching HTTP unavailable. Use --verify-existing after delivery repair; never rebuild/overwrite.'
|
||||
result = {'version':'0.6.1','versionCode':12,'apk':str(ARTIFACT.relative_to(ROOT)),'sha256':digest,
|
||||
'bytes':ARTIFACT.stat().st_size,'url':url,'httpBytesVerified':True,'manifestSha256':manifest_sha,
|
||||
'sameCertificateAs':['0.5.1','0.5.2','0.6.0'],'deviceTestStatus':'pending',
|
||||
'actualVisualResponse1s':'requires material trace and device measurement'}
|
||||
(LOGS/'release.json').write_text(json.dumps(result,indent=2)+'\n')
|
||||
print(json.dumps(result,indent=2))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
# Complete reviewed graph only. Never overwrite retained APKs or configure a device.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
source /home/ubuntu/android-build/env.sh
|
||||
python3 scripts/package-avatar-safe-release.py "$@"
|
||||
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build the authorized UI-only internal debug candidate; runtime03 remains unchanged."""
|
||||
from pathlib import Path
|
||||
import argparse, hashlib, importlib.util, json, re, urllib.request, zipfile
|
||||
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
spec=importlib.util.spec_from_file_location('natural_packaging',ROOT/'scripts/package-avatar-natural.py')
|
||||
natural=importlib.util.module_from_spec(spec);spec.loader.exec_module(natural)
|
||||
LOG=ROOT/'logs/avatar-062';natural.LOG=LOG
|
||||
ARTIFACT=ROOT/'artifacts/lan-voice-v062-ui-candidate-arm64-debug.apk'
|
||||
BASELINE=ROOT/'artifacts/lan-voice-v061-natural-engineering-arm64-debug.apk'
|
||||
BASELINE_SHA='8809ff5c2bec26f229b3c4dd505c54f7a3e02756f33bee4db904f1253b49e0fc'
|
||||
CERT='b9608336bc1ed1de3269bb4594f9fe718daaa5439511c5187aa385d2b799dcf1'
|
||||
# Saved code13 source fingerprints: this delivery changes chrome, not mouth rendering.
|
||||
UNCHANGED={
|
||||
'ContinuousBodyRenderer.kt':'4144db91db07585bf066080a251dc40b664775baab33b6267ef1c895d323f0f7',
|
||||
'ContinuousAvatarView.kt':'ff1952f2975902834010c68bc7307e61eb80d2edfe5b4449e99d26577cafb4c4',
|
||||
'ContinuousFramePresenter.kt':'78a2a33ef672d1245bfc5d65d6fd700f22ec190dc0d00b1035140b51514ecc0b',
|
||||
'ContinuousMouth.kt':'19a599297219a312a6600cc46d86b4190ad5a6066754954fcf51d4601bcef3e2',
|
||||
}
|
||||
sha=lambda data:hashlib.sha256(data).hexdigest()
|
||||
|
||||
def main():
|
||||
parser=argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--import-only',action='store_true')
|
||||
parser.add_argument('--verify-existing',action='store_true')
|
||||
args=parser.parse_args();LOG.mkdir(parents=True,exist_ok=True)
|
||||
assert sha(BASELINE.read_bytes())==BASELINE_SHA,'Code13 baseline drift'
|
||||
for name,digest in UNCHANGED.items():
|
||||
assert sha((ROOT/'app/src/main/java/com/gorios/lanvoice/avatar'/name).read_bytes())==digest,'Unexpected mouth renderer change: '+name
|
||||
m,files=natural.import_runtime()
|
||||
if args.import_only:
|
||||
natural.verify_decode(m)
|
||||
print('PASS: unchanged runtime03 exact manifest/body/97patch hashes, CFR/full decode and independent alpha algebra; no renderer or mouth repair claimed')
|
||||
return
|
||||
natural.tests_current()
|
||||
assert 'PASS: clean home' in (ROOT/'logs/avatar-safe-061/ui-contract-tests.txt').read_text()
|
||||
assert 'BUILD SUCCESSFUL' in (LOG/'android-test-compile.txt').read_text(),'Compile optional device UI probe first'
|
||||
if args.verify_existing:
|
||||
assert ARTIFACT.is_file();built=ARTIFACT
|
||||
else:
|
||||
assert not ARTIFACT.exists(),'Never overwrite an existing delivered candidate'
|
||||
natural.run([ROOT/'scripts/build.sh','assembleDebug','-PavatarNatural=true','-PavatarUiCandidate=true','-PnaturalManifestSha='+natural.PIN],'assemble.txt')
|
||||
built=ROOT/'app/build/outputs/apk/debug/app-debug.apk'
|
||||
cert=natural.verify(built,files,14,'0.6.2-ui-dev');assert cert==CERT
|
||||
signature=natural.run([natural.TOOLS/'apksigner','verify','--print-certs',BASELINE],'signature-code13.txt')
|
||||
assert CERT in signature
|
||||
with zipfile.ZipFile(built) as new,zipfile.ZipFile(BASELINE) as old:
|
||||
names={n for n in old.namelist() if n.startswith('assets/avatar/') and not n.endswith('/')}
|
||||
assert names=={n for n in new.namelist() if n.startswith('assets/avatar/') and not n.endswith('/')}
|
||||
assert all(new.read(n)==old.read(n) for n in names),'UI-only APK changed portrait asset bytes'
|
||||
if not args.verify_existing:
|
||||
with ARTIFACT.open('xb') as stream:stream.write(built.read_bytes())
|
||||
digest=sha(ARTIFACT.read_bytes());checksum=f'{digest} {ARTIFACT.name}\n'.encode()
|
||||
side=ARTIFACT.with_suffix('.apk.sha256');assert not side.exists() or side.read_bytes()==checksum
|
||||
side.write_bytes(checksum)
|
||||
url='http://192.168.31.124:8080/'+ARTIFACT.name
|
||||
opener=urllib.request.build_opener(urllib.request.ProxyHandler({}))
|
||||
with opener.open(url,timeout=15) as response:
|
||||
data=response.read();assert response.status==200 and len(data)==ARTIFACT.stat().st_size and sha(data)==digest
|
||||
with opener.open(url+'.sha256',timeout=15) as response:assert response.status==200 and response.read()==checksum
|
||||
result={'scope':'ui_only_internal_debug_candidate','version':'0.6.2-ui-dev','versionCode':14,
|
||||
'apk':str(ARTIFACT),'url':url,'bytes':ARTIFACT.stat().st_size,'sha256':digest,
|
||||
'sameCertificateSha256':cert,'manifestSha256':natural.PIN,'httpBytesVerified':True,
|
||||
'mouthChanged':False,'mouthDeformationResolved':False,'naturalQuality':'not_certified',
|
||||
'uiDeviceInstrumentation':'compiled_not_run','devicePerf':'not_tested',
|
||||
'actualGpuUvColor':'not_measured','compliance1s':'not_certified','productionApproval':False,
|
||||
'offlineExtra':'avatar_offline_preview'}
|
||||
(LOG/'delivery.json').write_text(json.dumps(result,indent=2)+'\n')
|
||||
print(json.dumps(result,indent=2))
|
||||
|
||||
if __name__=='__main__':main()
|
||||
Reference in New Issue
Block a user