Integrate exact user-authorized correct03 720 debug assets with isolated admission
This commit is contained in:
@@ -11,6 +11,7 @@ fun main() {
|
||||
reportedActionClockCheck()
|
||||
playbackDiagnosticCheck()
|
||||
boundedRuntimeDiagnosticCheck()
|
||||
userCandidateAdmissionCheck()
|
||||
dynamicBodyCheck()
|
||||
actionCheck()
|
||||
emotionActionCheck()
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
package com.gorios.lanvoice
|
||||
object BuildConfig { const val AVATAR_USER_ASSET_CANDIDATE=false }
|
||||
@@ -1,2 +1,2 @@
|
||||
package com.gorios.lanvoice
|
||||
object R { object drawable { const val startup_poster=1 } }
|
||||
object R { object drawable { const val startup_poster=1;const val startup_black_tulle_poster=2 } }
|
||||
|
||||
@@ -26,6 +26,13 @@ fun startupCacheCheck() {
|
||||
receipt.complete(key(install=2));check(!receipt.contains(key()) && receipt.contains(key(install=2)))
|
||||
} finally { folder.deleteRecursively() }
|
||||
} finally { worker.shutdownNow() }
|
||||
val userPin="208f703ed92bf795bfeb78a1cef89b67bed2e45da80038a56157fd1ecd4cfa93"
|
||||
val userKey=StartupAssetKey(31,1,userPin,"avatar/a01-black-tulle-roomy720-correct03/",3)
|
||||
check(userKey.fingerprint!=key(pin=userPin,validator=3).fingerprint)
|
||||
for((root,pin,version) in listOf(Triple("avatar/unknown/",userPin,3),
|
||||
Triple(userKey.root,"b".repeat(64),3),Triple(userKey.root,userPin,2))) {
|
||||
check(runCatching { StartupAssetKey(31,1,pin,root,version) }.isFailure)
|
||||
}
|
||||
println("PASS: production startup shared-future concurrency/cancel/cache/failure-retry and atomic immutable APK receipt corruption/install/pin/version/validator invalidation")
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import com.gorios.lanvoice.avatar.*
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun userCandidateAdmissionCheck() {
|
||||
val hash="c".repeat(64);val root=dynamicRuntimeFixture(97,24,1,hash,720,1280)
|
||||
val rows=root["patches"] as List<Map<String,Any?>>
|
||||
val compact=root+("patches" to rows.map { it-"path"-"sha256" })
|
||||
fun read(m: Map<String,Any?>,user: Boolean=false,debug: Boolean=true,expected: String=hash)=
|
||||
ContinuousAvatarManifest.read(m,hash,expected,debug,"fixture/",userAuthorizedDebug=user)
|
||||
val admitted=checkNotNull(read(compact));check(admitted.textureImages.size==485 && admitted.patches.first().path.endsWith("l4.png"))
|
||||
val candidate=compact+("runtimeReady" to false)
|
||||
check(read(candidate)==null);checkNotNull(read(candidate,true))
|
||||
check(read(candidate,true,false)==null);check(read(candidate,true,true,"b".repeat(64))==null)
|
||||
check(read(candidate+("publishApproval" to true),true)==null)
|
||||
check(read(candidate-"runtimeReady",true)==null)
|
||||
check(read(continuousFixture()+("runtimeReady" to false),true)==null)
|
||||
check(read(compact+("patches" to listOf(rows[0]+("path" to "patches/wrong.png"))+rows.drop(1)))==null)
|
||||
check(read(compact+("patches" to listOf(rows[0]-"sha256")+rows.drop(1)))==null)
|
||||
check(read(compact+("patches" to listOf(rows[0]-"path")+rows.drop(1)))==null)
|
||||
val levels=rows[0]["levels"] as List<Map<String,Any?>>
|
||||
check(read(compact+("patches" to listOf((rows[0]-"path"-"sha256")+("levels" to levels.dropLast(1)))+rows.drop(1)))==null)
|
||||
check(read(candidate+("body" to (root["body"] as Map<String,Any?>)+("width" to 480)),true)==null)
|
||||
println("PASS: user-authorized debug-only candidate admission; default/release/hash/self-approval/legacy fences retained; schema2 level-only tracks and explicit-alias consistency, malformed levels rejected")
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
"""User debug authorization is separate from Pi/network action approval; preserve exact source bytes."""
|
||||
import importlib.util, json, tempfile, unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
ROOT=Path(__file__).resolve().parents[2]
|
||||
spec=importlib.util.spec_from_file_location('user_pack',ROOT/'scripts/package-avatar-user-candidate.py')
|
||||
pack=importlib.util.module_from_spec(spec);spec.loader.exec_module(pack)
|
||||
class UserAssetPackageTests(unittest.TestCase):
|
||||
def test_authorization_is_exact_not_pi_or_live(self):
|
||||
a=pack.authorization(pack.PIN);self.assertFalse(a['independent_pi_pin']);self.assertFalse(a['network_dance_available'])
|
||||
for pin,pi,registry in [('0'*64,None,None),(pack.PIN,pack.PIN,None),(pack.PIN,None,Path('registry'))]:
|
||||
with self.subTest(pin=pin),self.assertRaises(ValueError):pack.authorization(pin,pi,registry)
|
||||
def test_buildconfig_exact_pin_isolated_roots_and_network_guards(self):
|
||||
s=(ROOT/'app/build.gradle').read_text()
|
||||
self.assertIn("emotionManifestSha != '"+pack.PIN+"'",s)
|
||||
self.assertIn("if (!avatarUserAssetCandidate && avatarPlaybackClockFix",s)
|
||||
for root in ('avatar/a01-expression-action-v1/**','avatar/startup-white-01/**','avatar/a01-black-tulle-roomy720-correct03/**'):self.assertIn(root,s)
|
||||
activity=(ROOT/'app/src/main/java/com/gorios/lanvoice/MainActivity.kt').read_text()
|
||||
self.assertIn('reviewedActionPack = avatarPack?.emotionAction?.actionPack?.takeIf { !BuildConfig.AVATAR_USER_ASSET_CANDIDATE',activity)
|
||||
self.assertIn('if(BuildConfig.AVATAR_STARTUP_FIX && !BuildConfig.AVATAR_USER_ASSET_CANDIDATE) BuildConfig.EMOTION_MANIFEST_SHA else null',activity)
|
||||
self.assertIn('if(mediaReady && !BuildConfig.AVATAR_USER_ASSET_CANDIDATE)',activity)
|
||||
self.assertIn('if(!offlineAvatarPreview && ::session.isInitialized && !BuildConfig.AVATAR_USER_ASSET_CANDIDATE)\n',activity)
|
||||
self.assertIn('if(!offlineAvatarPreview && ::session.isInitialized) session.foreground',activity)
|
||||
offline=(ROOT/'app/src/main/java/com/gorios/lanvoice/avatar/CallScreen.kt').read_text()
|
||||
self.assertIn('OfflineDancePreview(pack?.emotionAction?.actionPack?',offline)
|
||||
def test_level_only_alias_support_does_not_mutate_metadata(self):
|
||||
parser=(ROOT/'app/src/main/java/com/gorios/lanvoice/avatar/ContinuousAvatarManifest.kt').read_text()
|
||||
self.assertIn('!p.containsKey("path") && !p.containsKey("sha256")',parser)
|
||||
self.assertIn('patch.path==levels[4].path && patch.sha256==levels[4].sha256',parser)
|
||||
def test_bootstrap_exact_source_and_bound(self):
|
||||
meta=json.loads((ROOT/'manifests/startup-black-tulle-correct03.json').read_bytes())
|
||||
self.assertEqual(meta['sourceIndexSha256'],pack.PIN);self.assertEqual((meta['posterWidth'],meta['posterHeight']),(180,320))
|
||||
self.assertTrue(meta['body']['path'].startswith(pack.startup.ASSET_ROOT));self.assertEqual(meta['body']['ptsUs'][0],0)
|
||||
self.assertEqual((meta['body']['width'],meta['body']['height']),(720,1280))
|
||||
# Bootstrap recreator rejects changed bytes rather than overwriting a previous image.
|
||||
self.assertIn('Unknown bootstrap bytes preserved',(ROOT/'scripts/prepare-user-avatar-startup.py').read_text())
|
||||
def test_packaged_inventory_rejects_review_and_correct02(self):
|
||||
import zipfile
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
old=Path(directory)/'old.apk';new=Path(directory)/'new.apk'
|
||||
prefix='assets/'+pack.startup.ASSET_ROOT;meta=(ROOT/'manifests/startup-black-tulle-correct03.json').read_bytes()
|
||||
poster=(ROOT/'app/src/main/assets'/pack.startup.BASIC_ROOT/'poster.png').read_bytes()
|
||||
rows={prefix+'manifest.json':b'exact candidate',prefix+'own.png':b'own patches'}
|
||||
report={'files':{n[len(prefix):]:{'sha256':pack.pack.sha(b),'bytes':len(b)} for n,b in rows.items()}}
|
||||
basic={'assets/'+pack.startup.BASIC_ROOT+'manifest.json':meta,'assets/'+pack.startup.BASIC_ROOT+'poster.png':poster}
|
||||
def write(path,files):
|
||||
with zipfile.ZipFile(path,'w') as z:
|
||||
for n,b in files.items():z.writestr(n,b)
|
||||
write(old,{'assets/avatar/legacy/kept.png':b'rollback','assets/'+pack.pack.ASSET_ROOT+'manifest.json':b'old','assets/avatar/startup-white-01/poster.png':b'old'})
|
||||
with patch.object(pack,'OLD',old),patch.object(pack,'OLD_SHA',pack.pack.file_sha(old)):
|
||||
expected={'assets/avatar/legacy/kept.png':b'rollback',**rows,**basic};write(new,expected)
|
||||
self.assertEqual(pack.verify_apk(new,report)['runtime_referenced_files'],2)
|
||||
for n,b in [(prefix+'review.png',b'extra'),(prefix+'own.png',b'correct02'),('assets/avatar/legacy/kept.png',b'changed'),('assets/'+pack.startup.BASIC_ROOT+'poster.png',b'wrong')]:
|
||||
write(new,{**expected,n:b})
|
||||
with self.subTest(file=n),self.assertRaises(ValueError):pack.verify_apk(new,report)
|
||||
Reference in New Issue
Block a user