Integrate corrected char expressions into Liam code36
This commit is contained in:
@@ -10,6 +10,7 @@ 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; this offline replay uses local media callback doubles and does not assert network admission')
|
||||
parser.add_argument('--media-bundle',default='black-correct03',help='Trusted user-debug bundle, when --user-asset-candidate is set')
|
||||
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'
|
||||
@@ -90,20 +91,25 @@ graphics=(ROOT/'tests/avatar/Graphics.kt').read_text();graphics=graphics.replace
|
||||
}
|
||||
''')
|
||||
build='''package com.gorios.lanvoice
|
||||
object BuildConfig { const val AVATAR_STARTUP_FIX=false;const val DEBUG=true;const val AVATAR_NATURAL=true;const val AVATAR_ENGINEERING=true;const val AVATAR_MOUTH_CANDIDATE=true
|
||||
object BuildConfig { const val STARTUP_POSTER_RES_ID=1;const val AVATAR_STARTUP_FIX=false;const val DEBUG=true;const val AVATAR_NATURAL=true;const val AVATAR_ENGINEERING=true;const val AVATAR_MOUTH_CANDIDATE=true
|
||||
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)
|
||||
media=json.loads((ROOT/'manifests/character-build-profiles.json').read_bytes())['mediaBundles'][args.media_bundle]
|
||||
assert media.get('userAuthorizedDebug') is True
|
||||
asset_root=media['assetRoot'];basic_root=media['bootstrapRoot'];pin=media['indexSha256']
|
||||
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
|
||||
raw=archive.read('assets/'+asset_root+'manifest.json');assert hashlib.sha256(raw).hexdigest()==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+'"')
|
||||
patch_count=sum(len(json.loads(archive.read('assets/'+asset_root+r['path']))['patches'])*5 for r in refs)
|
||||
fallback_row=next(p for p in index['conversationPackages'] if p['id']==index['fallbackPackageId'])
|
||||
fallback_frames=json.loads(archive.read('assets/'+asset_root+fallback_row['runtimeManifest']['path']))['body']['frameCount']
|
||||
build=build.replace('const val EMOTION_MANIFEST_SHA="987e125a7d7a2cde99121b5f5246c82f4dbe36c4899d3d49eaffd1a68bafb887"','const val EMOTION_MANIFEST_SHA="'+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()+'";')
|
||||
build=build.replace('object BuildConfig {','object BuildConfig { const val AVATAR_USER_ASSET_CANDIDATE=true;const val EMOTION_ASSET_ROOT="'+asset_root+'";const val STARTUP_ASSET_ROOT="'+basic_root+'";const val STARTUP_MANIFEST_SHA="'+media['bootstrapSha256']+'";')
|
||||
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";')
|
||||
@@ -173,17 +179,17 @@ fun main(args: Array<String>) {
|
||||
println("EMOTION|requested=sad1|current=${binding.currentPackageId}|visual=${binding.visualStatus}")
|
||||
printTrace("happy_sad",trace);check(trace.none { it.second.actual=="media_failed" });check(binding.currentPackageId=="sad-01");view.dispose();TestScheduler.advanceBy(100)
|
||||
}
|
||||
for(initial in listOf(RoleEmotion.NEUTRAL,RoleEmotion.HAPPY)) {
|
||||
for(initial in listOf(RoleEmotion.NEUTRAL,RoleEmotion.HAPPY)) for(assetChoice in 0..1) {
|
||||
val(view,binding,trace)=rig();binding.intent(mediaReply(initial),false);TestScheduler.advanceBy(6000)
|
||||
var stop: ((Boolean)->Unit)?=null;val statuses=mutableListOf<ActionStatus>()
|
||||
val controller=ActionController(index.actionPack,binding,{TestScheduler.now},{stop=it},statuses::add,choose={0})
|
||||
val controller=ActionController(index.actionPack,binding,{TestScheduler.now},{stop=it},statuses::add,choose={assetChoice})
|
||||
check(controller.offer(ActionPlan("public_fixture_action_id_001",7,index.actionPack!!.manifestSha,120000)))
|
||||
println("DANCE|initial=${initial.wire}|offered=true|before_stop_players=${MediaPlayer.created.size}")
|
||||
stop!!(true);MediaPlayer.created.single().let { it.prepared!!(it) };TestScheduler.until(15000) { MediaPlayer.created.any { it.started } || trace.any { it.second.actual=="media_failed" } }
|
||||
val movie=MediaPlayer.created.single();println("DANCE|started=${movie.started}|current=${binding.currentPackageId}|status=${statuses.last().status}")
|
||||
val field=view.javaClass.getDeclaredField("textures").apply { isAccessible=true };val textures=field.get(view) as List<TextureView>
|
||||
val listener=textures[3].surfaceTextureListener!!;val surface=textures[3].surfaceTexture!!
|
||||
index.actionPack.assets.first().media!!.ptsUs.forEachIndexed { i,pts ->
|
||||
index.actionPack.assets[assetChoice].media!!.ptsUs.forEachIndexed { i,pts ->
|
||||
if(i>0) TestScheduler.advanceBy(42);surface.timestamp=pts*1000;listener.onSurfaceTextureUpdated(surface)
|
||||
if(i==0) {
|
||||
println("DANCE_LAYER|initial=${initial.wire}|first_frame_alpha=${textures[3].alpha}|body_alpha=${textures.take(3).map { it.alpha }}")
|
||||
@@ -193,7 +199,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=${index.actionPack.assets.first().media!!.ptsUs.size}|music_visible=${index.actionPack.assets.first().media!!.ptsUs.size}|conversation_visible=0|state=${binding.diagnosticState}")
|
||||
println("DANCE_OWNER|initial=${initial.wire}|asset=${index.actionPack.assets[assetChoice].id}|frames=${index.actionPack.assets[assetChoice].media!!.ptsUs.size}|music_visible=${index.actionPack.assets[assetChoice].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)
|
||||
@@ -223,6 +229,26 @@ fun main(args: Array<String>) {
|
||||
println("STARTUP_REPOSITORY|mode=${args[2]}|main_asset_reads=0|patch_reads=$patchReads|same_process_reloads=0|packages=5|bridge_mouths=8|sensors=0|device=false")
|
||||
}
|
||||
'''
|
||||
if args.user_asset_candidate:
|
||||
fallback=index['fallbackPackageId']
|
||||
variants=[p['id'] for p in index['conversationPackages'] if p['emotion']=='neutral' and p['id']!=fallback]
|
||||
assert variants, 'idle-variant replay requires an actual neutral variant'
|
||||
variant_set='setOf('+','.join(json.dumps(x) for x in variants)+')'
|
||||
main=main.replace('it.second.actual.startsWith("body_idle-")','it.second.actual in '+
|
||||
'setOf('+','.join(json.dumps('body_'+x) for x in variants)+')')
|
||||
main=main.replace('binding.currentPackageId?.startsWith("idle-")==true','binding.currentPackageId in '+variant_set)
|
||||
main=main.replace('listOf("idle-breathe-01","idle-microshift-01")',
|
||||
'listOf('+','.join(json.dumps(x) for x in variants)+')')
|
||||
main=main.replace('neutral-01',fallback)
|
||||
for emotion in ('happy','sad'):
|
||||
actual=next(p['id'] for p in index['conversationPackages'] if p['emotion']==emotion)
|
||||
main=main.replace(emotion+'-01',actual)
|
||||
# A two-bridge reversal can wait a full fallback loop (145 frames in this pack).
|
||||
main=main.replace('TestScheduler.advanceBy(7000)','TestScheduler.advanceBy(15000)')
|
||||
startup_main=startup_main.replace('body.frameCount==97','body.frameCount=='+str(fallback_frames))
|
||||
startup_main=startup_main.replace('packages.size==5','packages.size=='+str(len(index['conversationPackages'])))
|
||||
startup_main=startup_main.replace('packages=5|bridge_mouths=8','packages='+str(len(index['conversationPackages']))+
|
||||
'|bridge_mouths='+str(sum('mouthRuntimeManifest' in e for e in index['edges'])))
|
||||
with tempfile.TemporaryDirectory(prefix='baji-runtime-audit-') as td:
|
||||
tmp=Path(td);files=[]
|
||||
for path in (ROOT/'tests/avatar').glob('*.kt'):
|
||||
|
||||
@@ -19,7 +19,11 @@ ROOT=Path(__file__).resolve().parents[1]
|
||||
parser=argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--gateway-source',type=Path,default=ROOT/'gateway',
|
||||
help='Existing canonical source or read-only snapshot; never changes/deploys the gateway')
|
||||
parser.add_argument('--unreviewed-index-sha',default='',help='Also replay actual no-action Liam HELLO and ready/pending offers of this unregistered pin')
|
||||
args=parser.parse_args()
|
||||
if args.unreviewed_index_sha:
|
||||
import re
|
||||
assert re.fullmatch('[0-9a-f]{64}',args.unreviewed_index_sha)
|
||||
gateway_root=args.gateway_source.resolve(strict=True)
|
||||
snapshot=gateway_root/'SNAPSHOT.json'
|
||||
if snapshot.exists():
|
||||
@@ -52,6 +56,7 @@ with tempfile.TemporaryDirectory(prefix='character-handshake-') as folder:
|
||||
'-d',str(stage/'classes'),*map(str,files)],check=True)
|
||||
hello_file=stage/'hello.jsonl'
|
||||
subprocess.run([ns['JAVA'],'-Dcharacter.helloFile='+str(hello_file),
|
||||
'-Dcharacter.unreviewedPin='+args.unreviewed_index_sha,
|
||||
'-Dcharacter.personas='+','.join(personas),'-cp',
|
||||
str(stage/'classes')+':'+ns['cp'],'HandshakeCheckKt'],check=True,timeout=30)
|
||||
hellos=[json.loads(row) for row in hello_file.read_text().splitlines()]
|
||||
@@ -69,6 +74,7 @@ from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
from fastapi.testclient import TestClient
|
||||
import gateway
|
||||
from action_protocol import configured_packs,negotiate,pending_pin
|
||||
from history import History
|
||||
from guest_sessions import GuestSessions
|
||||
|
||||
@@ -100,8 +106,10 @@ for hello in hellos:
|
||||
expected_voice='synthetic-'+(persona if persona!='default' else 'yangmi_fiction')
|
||||
assert ack['voice_id']==expected_voice
|
||||
assert profile.call_count==(1 if persona=='default' else 0)
|
||||
assert ack['action_available']==('action_pack_sha256' in hello)
|
||||
assert ack['action_pending']==('action_pending_pack_sha256' in hello)
|
||||
assert ack['action_available']==bool(negotiate(hello,configured_packs()))
|
||||
assert ack['action_pending']==bool(pending_pin(hello,configured_packs()))
|
||||
if hello.get('action_pack_sha256')==UNREVIEWED or hello.get('action_pending_pack_sha256')==UNREVIEWED:
|
||||
assert not ack['action_available'] and not ack['action_pending']
|
||||
assert ack['conversation_id'] not in ids;ids.append(ack['conversation_id'])
|
||||
assert ws.receive_json()['type']=='history'
|
||||
assert sessions[-1]==('yangmi_fiction' if persona=='default' else persona,
|
||||
@@ -119,5 +127,5 @@ for persona in sorted({x['persona'] for x in hellos}-{'default'}):
|
||||
ws.receive_json();ids.append(ack['conversation_id'])
|
||||
assert state.busy is False
|
||||
print('PASS: '+str(len(ids))+' canonical ASGI WS handshakes from actual Android HELLO; personas='+','.join(sorted({x["persona"] for x in hellos}))+'; explicit persona ignores active_profile, server-locks voice/language, fresh CID, ready/pending exact pin and disconnect busy cleanup; 0 ASR/LLM/TTS calls, synthetic-only')
|
||||
'''
|
||||
'''.replace('UNREVIEWED',repr(args.unreviewed_index_sha))
|
||||
subprocess.run([sys.executable,'-c',runner],cwd=stage,check=True,timeout=30)
|
||||
|
||||
@@ -39,7 +39,10 @@ parser.add_argument('--user-authorized-debug-sha',help='Explicit exact user-auth
|
||||
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.user_authorized_debug_sha and (not args.index_manifest or not any(
|
||||
row.get('userAuthorizedDebug') is True and row['indexSha256']==args.user_authorized_debug_sha
|
||||
for row in json.loads((ROOT/'manifests/character-build-profiles.json').read_bytes())['mediaBundles'].values())):
|
||||
parser.error('Exact catalogued user-authorized 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')
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python3
|
||||
"""User-authorized metadata-only derivative of the exact expressions-r02 delivery.
|
||||
|
||||
Preserves owner input and all media bytes. Does not import, build, approve or register.
|
||||
"""
|
||||
import argparse
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SOURCE_PIN = '0758672dd2ca8686f32c5e1062bca0d4bbf19063b036a42db71c1050ecb08d08'
|
||||
|
||||
def derive(source, output):
|
||||
spec = importlib.util.spec_from_file_location('expression_media_gate', ROOT/'scripts/package-avatar-emotion.py')
|
||||
gate = importlib.util.module_from_spec(spec);spec.loader.exec_module(gate)
|
||||
source = Path(source).resolve(strict=True);output = Path(output).absolute()
|
||||
gate.require(gate.file_sha(source/'manifest.json') == SOURCE_PIN, 'exact source pin required')
|
||||
gate.require(not output.exists() and not output.is_symlink() and not output.resolve().is_relative_to(source), 'new derivative outside owner input required')
|
||||
gate.require(not any(p.is_symlink() for p in source.rglob('*')), 'source symlink')
|
||||
original = gate.read_json(source/'manifest.json')
|
||||
index = json.loads(json.dumps(original))
|
||||
action = next(a for a in index['actions'] if a['id'] == 'asset_02')
|
||||
clip = gate.locate(source,action['clip']['path'])
|
||||
gate.require(gate.file_sha(clip)==action['clip']['sha256'], 'action clip drift')
|
||||
measured = gate.probe_music_clip(clip)
|
||||
gate.require(action['audioEndUs']==8_000_000 and measured['audioEndUs']==7_940_998, 'unexpected audio endpoint; re-audit required')
|
||||
action['audioEndUs'] = measured['audioEndUs']
|
||||
restored = json.loads(json.dumps(index))
|
||||
next(a for a in restored['actions'] if a['id']=='asset_02')['audioEndUs'] = 8_000_000
|
||||
gate.require(restored==original, 'derivative changes more than audioEndUs')
|
||||
for row in original['files']:
|
||||
p=gate.locate(source,row['path'])
|
||||
gate.require(p.stat().st_size==row['bytes'] and gate.file_sha(p)==row['sha256'], 'source inventory drift')
|
||||
shutil.copytree(source,output)
|
||||
raw=(json.dumps(index,indent=2,ensure_ascii=False)+'\n').encode()
|
||||
(output/'manifest.json').write_bytes(raw)
|
||||
pin=gate.sha(raw)
|
||||
(output/'manifest.sha256').write_text(pin+' manifest.json\n')
|
||||
for row in index['files']:
|
||||
p=gate.locate(output,row['path'])
|
||||
gate.require(p.stat().st_size==row['bytes'] and gate.file_sha(p)==row['sha256'], 'derivative media/inventory drift')
|
||||
gate.require(gate.file_sha(source/'manifest.json')==SOURCE_PIN, 'owner source changed')
|
||||
return {'authorization':'user_requested_deterministic_self_correction', 'sourceIndexSha256':SOURCE_PIN,
|
||||
'derivedIndexSha256':pin,'changedField':'actions[asset_02].audioEndUs','before':8_000_000,'after':7_940_998,
|
||||
'mediaFilesChanged':0,'runtimeManifestsChanged':0,'runtimeReady':'unchanged_false',
|
||||
'independentPiApproval':False,'gatewayChanged':False,'output':str(output)}
|
||||
|
||||
if __name__=='__main__':
|
||||
parser=argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--source',type=Path,required=True);parser.add_argument('--output',type=Path,required=True)
|
||||
args=parser.parse_args();print(json.dumps(derive(args.source,args.output),indent=2)+'\n')
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Strict production gate and optional immutable debug import of a catalogued bundle.
|
||||
|
||||
No asset metadata rewriting, generation, gateway registry admission or APK publication.
|
||||
"""
|
||||
import argparse
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
|
||||
def module(name,path):
|
||||
spec=importlib.util.spec_from_file_location(name,path)
|
||||
value=importlib.util.module_from_spec(spec);spec.loader.exec_module(value);return value
|
||||
|
||||
def main():
|
||||
parser=argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--media-bundle',required=True)
|
||||
parser.add_argument('--manifest',type=Path,required=True)
|
||||
parser.add_argument('--output',type=Path,required=True)
|
||||
parser.add_argument('--import-only',action='store_true')
|
||||
args=parser.parse_args()
|
||||
select=module('selected_media',ROOT/'scripts/select-character-assets.py')
|
||||
pack=module('media_gate',ROOT/'scripts/package-avatar-emotion.py')
|
||||
startup=module('media_startup',ROOT/'scripts/prepare-user-avatar-startup.py')
|
||||
media=select.catalog()['mediaBundles'][args.media_bundle]
|
||||
select.require(media.get('userAuthorizedDebug') is True,'explicit user debug authorization required')
|
||||
source=args.manifest.resolve(strict=True)
|
||||
output=args.output.resolve()
|
||||
select.require(not output.exists() and not output.is_relative_to(source.parent),'new evidence outside owner storage required')
|
||||
output.mkdir(parents=True)
|
||||
report=pack.check_bundle(source,media['indexSha256'],output,user_authorized_debug=True)
|
||||
raw,poster=startup.derive(source.parent,args.media_bundle)
|
||||
select.require(select.digest(raw)==media['bootstrapSha256'],'catalog bootstrap pin mismatch')
|
||||
if args.import_only:
|
||||
pack.import_files(source.parent,report['files'],ROOT/'app/src/main/assets'/media['assetRoot'])
|
||||
basic=startup.prepare(source.parent,media_bundle=args.media_bundle)
|
||||
(output/'import.json').write_text(json.dumps({'authorization':'user_exact_revision_debug_integration',
|
||||
'media_bundle':args.media_bundle,'manifest_sha256':media['indexSha256'],
|
||||
'asset_root':media['assetRoot'],'files':len(report['files']),'bootstrap':basic,
|
||||
'independent_pi_pin':False,'network_dance_available':False,'gateway_changed':False},indent=2)+'\n')
|
||||
print(json.dumps({k:v for k,v in report.items() if k not in ('files','runtime_packages')},indent=2))
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -175,7 +175,8 @@ def check_bundle(manifest,expected,output,user_authorized_debug=False):
|
||||
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')
|
||||
require(not user_authorized_debug or any(row.get('userAuthorizedDebug') is True and row['indexSha256']==expected
|
||||
for row in read_json(ROOT/'manifests/character-build-profiles.json')['mediaBundles'].values()),'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),*(['--user-authorized-debug-sha',expected] if user_authorized_debug else [])],stdout=f,stderr=subprocess.STDOUT,timeout=180)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build/verify one trusted persona debug profile over unchanged code33 media.
|
||||
"""Build/verify one trusted persona debug profile with an explicit immutable media bundle.
|
||||
|
||||
No gateway mutations, voice selection, model calls or device installation.
|
||||
Default profile can be built and verified separately without publishing a main APK.
|
||||
@@ -32,12 +32,15 @@ def file_sha(p):
|
||||
return hashlib.file_digest(f, 'sha256').hexdigest()
|
||||
|
||||
|
||||
def flags(profile, version):
|
||||
pin = select.catalog()['mediaBundles']['black-correct03']['indexSha256']
|
||||
return ['-PcharacterProfile='+profile, '-PactionVersionCode='+str(version),
|
||||
def flags(profile, version, media_bundle='black-correct03'):
|
||||
media = select.catalog()['mediaBundles'][media_bundle]
|
||||
pin = media['indexSha256']
|
||||
return ['-PcharacterProfile='+profile, '-PcharacterMediaBundle='+media_bundle,
|
||||
'-PavatarUserNetworkActions='+str(media.get('networkActionsAllowed',False)).lower(),
|
||||
'-PactionVersionCode='+str(version),
|
||||
'-PnaturalManifestSha=0a3c4918ba746019cf1df885bec66e5858a8950997dac4f64e7d37094be64dad',
|
||||
'-PemotionManifestSha='+pin] + ['-P'+name+'=true' for name in (
|
||||
'avatarUserNetworkActions', 'avatarUserAssetCandidate', 'avatarActionCandidate',
|
||||
'avatarUserAssetCandidate', 'avatarActionCandidate',
|
||||
'avatarNatural', 'avatarMouthCandidate', 'avatarFullActionCandidate', 'avatarPlaybackClockFix',
|
||||
'avatarStartupFix', 'presenceCandidate', 'faceDiagnosticsFix', 'cameraCompatibilityFix',
|
||||
'cameraDirectYuv', 'cameraPreviewStream', 'cameraProbeDiagnostic')]
|
||||
@@ -47,26 +50,32 @@ def build_dir(profile):
|
||||
return ROOT/('app/build' if profile == 'main' else 'app/build/characters/'+profile)
|
||||
|
||||
|
||||
def verify(apk, profile, version):
|
||||
def verify(apk, profile, version, media_bundle='black-correct03'):
|
||||
catalog = select.catalog()
|
||||
role = catalog['profiles'][profile]
|
||||
media = catalog['mediaBundles']['black-correct03']
|
||||
media = catalog['mediaBundles'][media_bundle]
|
||||
selected = select.selection(ROOT/'app/src/main/assets', profile, emotion_sha=media['indexSha256'],
|
||||
user_assets=True, mouth=True, startup=True)
|
||||
user_assets=True, mouth=True, startup=True, media_bundle=media_bundle)
|
||||
require(file_sha(BASELINE) == BASELINE_SHA, 'code33 rollback drift')
|
||||
with zipfile.ZipFile(BASELINE) as old, zipfile.ZipFile(apk) as new:
|
||||
names = lambda z: {n for n in z.namelist() if n.startswith('assets/') and not n.endswith('/')}
|
||||
require(names(new) == names(old) == {'assets/'+n for n in selected['files']}, 'APK selection inventory mismatch')
|
||||
require(names(new) == {'assets/'+n for n in selected['files']}, 'APK selection inventory mismatch')
|
||||
if media_bundle == 'black-correct03':
|
||||
require(names(new) == names(old), 'code33 inventory drift')
|
||||
for name in names(new):
|
||||
raw = new.read(name)
|
||||
row = selected['files'][name[7:]]
|
||||
require(raw == old.read(name) and len(raw) == row['bytes'] and select.digest(raw) == row['sha256'],
|
||||
require(len(raw) == row['bytes'] and select.digest(raw) == row['sha256'],
|
||||
'APK media drift: '+name)
|
||||
if media_bundle == 'black-correct03' or name in names(old):
|
||||
require(raw == old.read(name), 'shared/retained code33 bytes drift: '+name)
|
||||
if name.endswith('.mp4'):
|
||||
require(new.getinfo(name).compress_type == zipfile.ZIP_STORED, 'video compression drift')
|
||||
for name in ('startup_poster', 'startup_black_tulle_poster'):
|
||||
n = 'res/drawable-nodpi-v4/'+name+'.png'
|
||||
require(new.read(n) == old.read(n), 'poster resource drift')
|
||||
poster_path='res/drawable-nodpi-v4/'+media['posterResource']+'.png'
|
||||
require(new.read(poster_path)==new.read('assets/'+media['bootstrapRoot']+'poster.png'), 'selected poster mismatch')
|
||||
# Read real DEX static values rather than trusting a generated Java file.
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
dex_text = ''
|
||||
@@ -87,7 +96,7 @@ def verify(apk, profile, version):
|
||||
'STARTUP_MANIFEST_SHA': media['bootstrapSha256']}
|
||||
for field, value in expected.items():
|
||||
require(dex_values.get(field) == '"'+value+'"', 'APK DEX mismatch: '+field)
|
||||
for field, value in {'AVATAR_NETWORK_ACTIONS_ALLOWED': True, 'AVATAR_USER_ASSET_CANDIDATE': True,
|
||||
for field, value in {'AVATAR_NETWORK_ACTIONS_ALLOWED': media.get('networkActionsAllowed',False), 'AVATAR_USER_ASSET_CANDIDATE': True,
|
||||
'PERMISSION_CONNECTION_RETENTION': role['permissionConnectionRetention']}.items():
|
||||
require(dex_values.get(field) == str(value).lower(), 'APK DEX boolean mismatch: '+field)
|
||||
require(dex_values.get('VERSION_CODE') == str(version) and
|
||||
@@ -111,7 +120,9 @@ def verify(apk, profile, version):
|
||||
re.search(r'android:allowBackup[^\n]*', xml)[0], 'backup mismatch')
|
||||
return {'profile': profile, 'application_id': role['applicationId'], 'persona': role['persona'],
|
||||
'version_name': version_name, 'version_code': version, 'certificate_sha256': CERT,
|
||||
'index_sha256': media['indexSha256'], 'assets_unchanged': len(selected['files']),
|
||||
'index_sha256': media['indexSha256'], 'media_bundle':media_bundle, 'asset_files_verified':len(selected['files']),
|
||||
'assets_unchanged': len(selected['files']) if media_bundle=='black-correct03' else None,
|
||||
'network_actions_allowed':media.get('networkActionsAllowed',False),
|
||||
'poster_resources_unchanged': 2, 'provider_authorities': authorities,
|
||||
'actual_dex_verified': True, 'device': 'not_run', 'gateway_changed': False}
|
||||
|
||||
@@ -143,11 +154,13 @@ def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--profile', choices=sorted(select.catalog()['profiles']), default='lvbu-test')
|
||||
parser.add_argument('--version-code', type=int)
|
||||
parser.add_argument('--media-bundle',choices=sorted(select.catalog()['mediaBundles']),default='black-correct03')
|
||||
parser.add_argument('--build', action='store_true')
|
||||
parser.add_argument('--publish', action='store_true')
|
||||
parser.add_argument('--output', type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
minimum = select.catalog()['profiles'][args.profile].get('minimumVersionCode', 34)
|
||||
minimum = max(select.catalog()['profiles'][args.profile].get('minimumVersionCode', 34),
|
||||
select.catalog()['mediaBundles'][args.media_bundle].get('minimumVersionCode',0))
|
||||
args.version_code = args.version_code if args.version_code is not None else minimum
|
||||
require(args.version_code >= minimum, 'fresh character version required')
|
||||
require(not args.publish or args.profile != 'main', 'main publication outside this task')
|
||||
@@ -156,9 +169,9 @@ def main():
|
||||
'published character version is immutable; choose a new code')
|
||||
if args.build:
|
||||
subprocess.run([str(ROOT/'scripts/build.sh'), ':app:assembleDebug', ':app:compileDebugAndroidTestKotlin',
|
||||
*flags(args.profile, args.version_code)], check=True, cwd=ROOT)
|
||||
*flags(args.profile, args.version_code, args.media_bundle)], check=True, cwd=ROOT)
|
||||
apk = build_dir(args.profile)/'outputs/apk/debug/app-debug.apk'
|
||||
report = verify(apk, args.profile, args.version_code)
|
||||
report = verify(apk, args.profile, args.version_code, args.media_bundle)
|
||||
if args.publish:
|
||||
report = publish(apk, report)
|
||||
args.output.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
@@ -12,8 +12,11 @@ ASSET_ROOT=MEDIA['assetRoot']
|
||||
BASIC_ROOT=MEDIA['bootstrapRoot']
|
||||
sha=lambda data:hashlib.sha256(data).hexdigest()
|
||||
|
||||
def derive(source):
|
||||
index=source/'manifest.json';assert sha(index.read_bytes())==PIN,'exact index drift'
|
||||
def derive(source,media_bundle='black-correct03'):
|
||||
media=json.loads((ROOT/'manifests/character-build-profiles.json').read_bytes())['mediaBundles'][media_bundle]
|
||||
pin=media['indexSha256'];asset_root=media['assetRoot']
|
||||
assert media.get('userAuthorizedDebug') is True,'authorized debug bundle required'
|
||||
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'])
|
||||
@@ -22,23 +25,25 @@ def derive(source):
|
||||
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,
|
||||
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}}
|
||||
'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}
|
||||
def prepare(source,verify_only=False,media_bundle='black-correct03'):
|
||||
media=json.loads((ROOT/'manifests/character-build-profiles.json').read_bytes())['mediaBundles'][media_bundle]
|
||||
raw,poster=derive(source,media_bundle)
|
||||
outputs={ROOT/media.get('bootstrapMetadata','manifests/startup-black-tulle-correct03.json'):raw,
|
||||
ROOT/'app/src/main/assets'/media['bootstrapRoot']/'manifest.json':raw,
|
||||
ROOT/'app/src/main/assets'/media['bootstrapRoot']/'poster.png':poster,
|
||||
ROOT/media.get('resourceDirectory','app/src/main/res')/'drawable-nodpi'/(media['posterResource']+'.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}
|
||||
return {'status':'passed','index_sha256':media['indexSha256'],'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))
|
||||
parser.add_argument('--media-bundle',default='black-correct03')
|
||||
args=parser.parse_args();print(json.dumps(prepare(args.source,args.verify_only,args.media_bundle),indent=2))
|
||||
|
||||
@@ -38,16 +38,25 @@ def catalog():
|
||||
return data
|
||||
|
||||
|
||||
def selection(assets, profile='main', *, emotion_sha='', user_assets=False, mouth=False, startup=False):
|
||||
def authorized_debug_sha(pin):
|
||||
return any(row.get('userAuthorizedDebug') is True and row['indexSha256']==pin
|
||||
for row in catalog()['mediaBundles'].values())
|
||||
|
||||
|
||||
def selection(assets, profile='main', *, emotion_sha='', user_assets=False, mouth=False, startup=False, media_bundle=None):
|
||||
data = catalog()
|
||||
require(profile in data['profiles'], 'unknown character profile')
|
||||
role = data['profiles'][profile]
|
||||
bundle_id = ('black-correct03' if user_assets else 'white-full04') if emotion_sha else None
|
||||
require(role['mediaSelection'] == 'existing-build-flags' or
|
||||
role['mediaSelection'] == bundle_id and mouth and startup, 'profile/media flags mismatch')
|
||||
require(not media_bundle or emotion_sha, 'explicit media needs an exact pin')
|
||||
bundle_id = (media_bundle or ('black-correct03' if user_assets else 'white-full04')) if emotion_sha else None
|
||||
require(bundle_id is None or bundle_id in data['mediaBundles'], 'unknown media bundle')
|
||||
allowed = [role['mediaSelection'], *role.get('additionalMediaSelections', [])]
|
||||
require((role['mediaSelection'] == 'existing-build-flags' and bundle_id in (None,'black-correct03','white-full04')) or
|
||||
bundle_id in allowed and mouth and startup, 'profile/media flags mismatch')
|
||||
bundle = data['mediaBundles'][bundle_id] if bundle_id else None
|
||||
if bundle:
|
||||
require(emotion_sha == bundle['indexSha256'], 'selected exact index mismatch')
|
||||
require(user_assets == bundle.get('userAuthorizedDebug',False), 'media authorization mode mismatch')
|
||||
assets = Path(assets).resolve(strict=True)
|
||||
files = {}
|
||||
|
||||
@@ -111,7 +120,7 @@ def selection(assets, profile='main', *, emotion_sha='', user_assets=False, mout
|
||||
require(boot['sourceIndexSha256'] == emotion_sha and boot['body']['path'] in files and
|
||||
files[boot['body']['path']]['sha256'] == boot['body']['sha256'], 'bootstrap/index/body mismatch')
|
||||
poster = add(boot_root + 'poster.png', boot['posterSha256'])
|
||||
resource = ROOT / 'app/src/main/res/drawable-nodpi' / (bundle['posterResource'] + '.png')
|
||||
resource = ROOT / bundle.get('resourceDirectory','app/src/main/res') / 'drawable-nodpi' / (bundle['posterResource'] + '.png')
|
||||
require(resource.read_bytes() == poster, 'drawable/bootstrap poster mismatch')
|
||||
return {'schemaVersion': 1, 'profile': profile, 'application_id': role['applicationId'],
|
||||
'persona': role['persona'], 'media_bundle': bundle_id, 'media_identity': bundle['identityId'] if bundle else 'a01',
|
||||
@@ -143,13 +152,14 @@ def main():
|
||||
p.add_argument('--profile', choices=sorted(catalog()['profiles']), required=True)
|
||||
p.add_argument('--assets', type=Path, default=ROOT / 'app/src/main/assets')
|
||||
p.add_argument('--emotion-sha', default='')
|
||||
p.add_argument('--media-bundle', default='')
|
||||
for flag in ('user-assets', 'mouth', 'startup'):
|
||||
p.add_argument('--' + flag, choices=['true', 'false'], default='false')
|
||||
p.add_argument('--output', type=Path)
|
||||
p.add_argument('--report', type=Path)
|
||||
a = p.parse_args()
|
||||
result = selection(a.assets, a.profile, emotion_sha=a.emotion_sha, user_assets=a.user_assets == 'true',
|
||||
mouth=a.mouth == 'true', startup=a.startup == 'true')
|
||||
mouth=a.mouth == 'true', startup=a.startup == 'true', media_bundle=a.media_bundle or None)
|
||||
if a.output:
|
||||
stage(a.assets, a.output, result)
|
||||
if a.report:
|
||||
|
||||
Reference in New Issue
Block a user