Integrate reviewed full action pack admission and bounded idle scheduling
This commit is contained in:
@@ -57,7 +57,14 @@ async def main(stage):
|
||||
'http://127.0.0.1:8888/v1','qwen3.8-27b','json_schema','Asia/Shanghai')
|
||||
report.update(provider=provider.model,zone=provider.clock.zone.key,mode=provider.structured_output)
|
||||
fixture_sha=hashlib.sha256(b'isolated-public-action-calling-path-fixture-not-an-asset').hexdigest()
|
||||
os.environ['LAN_ACTION_PACKS']=json.dumps({fixture_sha:{'asset_01':1000,'asset_02':1000}})
|
||||
if approved:
|
||||
from action_protocol import configured_packs
|
||||
assert configured_packs().get(approved['sha256'])==approved['durations']
|
||||
fixture_sha=approved['sha256'];playback_ms=max(approved['durations'].values())
|
||||
report['approved_pack_metadata']=approved
|
||||
else:
|
||||
playback_ms=1000
|
||||
os.environ['LAN_ACTION_PACKS']=json.dumps({fixture_sha:{'asset_01':1000,'asset_02':1000}})
|
||||
token=secrets.token_urlsafe(32) # Ephemeral fixture token, never output.
|
||||
history=History(stage/'fixture-history.sqlite3');await history.initialize()
|
||||
clocks=[]
|
||||
@@ -115,7 +122,7 @@ async def main(stage):
|
||||
event=json.loads(await ws.recv());assert event['type']=='hello'
|
||||
return event
|
||||
availability=[]
|
||||
for cap in ({},{'action_protocol':1,'action_kinds':['dance'],'action_pack_sha256':'b'*64}):
|
||||
for cap in ({},{'action_protocol':1,'action_kinds':['dance'],'action_pack_sha256':'b'*64},{'action_protocol':1,'action_kinds':['dance'],'action_pack_sha256':'e73f336123bf5e2dec2d82b97eb22cc632a4ee75bcf7f4bd0052b1ff42d95cd7'}):
|
||||
async with websockets.connect(f'ws://127.0.0.1:{port}/ws/dialogue',**kwargs) as ws:
|
||||
event=await hello(ws,cap);availability.append(event['action_available']);assert not event['action_available']
|
||||
async with asyncio.timeout(5):
|
||||
@@ -189,7 +196,7 @@ async def main(stage):
|
||||
await ws.send(json.dumps({'type':'ping'}))
|
||||
if kind=='pong' and plan is not None and after_turn is None:
|
||||
assert report['tts_requests']==2 and len(emotions)==1
|
||||
await asyncio.sleep(max(0,1.05-(time.monotonic()-started_at)))
|
||||
await asyncio.sleep(max(0,(playback_ms/1000+.05)-(time.monotonic()-started_at)))
|
||||
await ws.send(json.dumps(complete));await ws.send(json.dumps(complete))
|
||||
trace({'type':'fixture.audio_video_end_returnA_completed_twice','turn_id':pre_turn})
|
||||
if kind=='speech.start':
|
||||
@@ -218,7 +225,7 @@ async def main(stage):
|
||||
'premature_completion_no_after':True,'action_pcm_no_second_asr':True,
|
||||
'prepare_ms':metrics[pre_turn].get('expression_prepare_ms'),
|
||||
'full_reply_ms':metrics[pre_turn]['llm_first_body_ms'],'finish_reason':metrics[pre_turn]['llm_finish_reason'],
|
||||
'simulated_media_duration_ms':1000,'mic_audio_record':'not_run','music_video_playback':'not_run'}
|
||||
'simulated_media_duration_ms':playback_ms,'mic_audio_record':'not_run','music_video_playback':'not_run'}
|
||||
finally:
|
||||
server.should_exit=True
|
||||
with suppress(Exception): await asyncio.wait_for(task,5)
|
||||
|
||||
@@ -35,7 +35,7 @@ with tempfile.TemporaryDirectory(prefix='voice-gateway-stage-') as folder:
|
||||
for name,content in bundle.items():
|
||||
path=stage/name;path.parent.mkdir(parents=True,exist_ok=True);path.write_bytes(base64.b64decode(content))
|
||||
test_start=time.perf_counter()
|
||||
result=subprocess.run([sys.executable,str(stage/'scripts/check-archive.py'),'--vad-model',str(root/'models/silero_vad.onnx')],cwd=stage,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,timeout=120,env={**os.environ,'PYTHONDONTWRITEBYTECODE':'1'})
|
||||
result=subprocess.run([sys.executable,str(stage/'scripts/check-archive.py')],cwd=stage,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,timeout=120,env={**os.environ,'PYTHONDONTWRITEBYTECODE':'1'})
|
||||
summary={'status':'tests_passed' if result.returncode==0 else 'tests_failed','test_output':result.stdout.decode(errors='replace'),'test_elapsed_ms':round((time.perf_counter()-test_start)*1000,2),'applied':False,'expected_hashes':original,
|
||||
'candidate_source_hashes':{name:hashlib.sha256((stage/name).read_bytes()).hexdigest() for name in deploy_files}}
|
||||
if result.returncode: print(json.dumps(summary));raise SystemExit(1)
|
||||
@@ -45,7 +45,7 @@ with tempfile.TemporaryDirectory(prefix='voice-gateway-stage-') as folder:
|
||||
if health().get('busy'):raise RuntimeError('gateway_busy_after_tests_no_restart')
|
||||
backup=root/'.runtime/backups'/time.strftime('voice-gateway-%Y%m%d-%H%M%S');backup.mkdir(parents=True,mode=0o700)
|
||||
# Save all actual runtime Python sources/tests, modes, plus unit/env privately. No logs/history/audio copied.
|
||||
for path in list(root.glob('*.py'))+list((root/'tests').glob('*.py'))+list((root/'personas').glob('*.json')):
|
||||
for path in list(root.glob('*.py'))+list((root/'tests').glob('*.py'))+list((root/'personas').glob('*.json'))+list(root.glob('reviewed_action_packs.json')):
|
||||
dst=backup/path.relative_to(root);dst.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(path,dst)
|
||||
for i,path in enumerate(private_files):
|
||||
dst=backup/'private'/str(i);dst.parent.mkdir(parents=True,exist_ok=True,mode=0o700);shutil.copy2(path,dst)
|
||||
@@ -86,9 +86,9 @@ def main():
|
||||
parser=argparse.ArgumentParser(description=__doc__);parser.add_argument('--apply',action='store_true');args=parser.parse_args()
|
||||
source=root/'gateway';manifest=json.loads((source/'SOURCE_MANIFEST.json').read_text())
|
||||
baseline=manifest.get('deployment_baseline',manifest['provider_baseline'])['files']
|
||||
files=sorted(set(baseline)|{p.relative_to(source).as_posix() for p in source.glob('*.py')}|{p.relative_to(source).as_posix() for p in (source/'tests').glob('*.py')})
|
||||
files=sorted(set(baseline)|{p.relative_to(source).as_posix() for p in source.glob('*.py')}|{p.relative_to(source).as_posix() for p in (source/'tests').glob('*.py')}|{'reviewed_action_packs.json'})
|
||||
public_personas={'personas/lvbu.lorebook.json','personas/yangmi.lorebook.json'}
|
||||
assert all((n.endswith('.py') or n in public_personas) and not Path(n).is_absolute() and '..' not in Path(n).parts for n in files)
|
||||
assert all((n.endswith('.py') or n in public_personas or n=='reviewed_action_packs.json') and not Path(n).is_absolute() and '..' not in Path(n).parts for n in files)
|
||||
expected={name:baseline.get(name) for name in files}
|
||||
record=root/'logs/voice-investigation/gateway-emotion-deploy.json'
|
||||
# SOURCE_MANIFEST is the reviewed expected live baseline. Old ignored records
|
||||
|
||||
@@ -252,10 +252,25 @@ def next_version(paths):
|
||||
return max([16,*codes])+1
|
||||
|
||||
|
||||
def tested_source():
|
||||
def reviewed_actions(index,pin,registry):
|
||||
"""External pin is necessary but never replaces production media validation."""
|
||||
require(registry is not None,'dance import/publication requires separately reviewed gateway capability admission; read-only gate supported')
|
||||
table=read_json(registry)
|
||||
expected={row['id']:(row['clip']['durationUs']+999)//1000 for row in index['actions']}
|
||||
require(set(expected)=={'asset_01','asset_02'} and all(row['kind']=='dance' and row['mouthAllowed'] is False for row in index['actions']),'reviewed dance shape')
|
||||
require(table.get(pin)==expected,'reviewed action pin/duration mismatch')
|
||||
return expected
|
||||
|
||||
|
||||
def tested_source(full=False):
|
||||
client=json.loads((ROOT/'logs/avatar-safe-061/client-tests.json').read_text())
|
||||
require(client['status']=='passed' and client['jvm_entry_points']==9,'client regression evidence')
|
||||
for name,digest in client['hashes'].items(): require(file_sha(ROOT/name)==digest,'untested source: '+name)
|
||||
if full:
|
||||
evidence=read_json(ROOT/'logs/action-emotion/full-release/checks.json')
|
||||
require(evidence['gateway_passed']==97 and evidence['gateway_skipped']==1 and evidence['offline_gles_goldens']==200 and evidence['packaging_passed']>=27,'full release regression evidence')
|
||||
for name,digest in evidence['hashes'].items(): require(file_sha(ROOT/name)==digest,'full release evidence drift: '+name)
|
||||
return
|
||||
evidence=json.loads((ROOT/'logs/action-emotion/bridge-talk/delivery.json').read_text())
|
||||
require(evidence['gateway_passed']==97 and evidence['gateway_skipped']==1 and evidence['offline_gles_goldens']==40,'gateway/GLES evidence')
|
||||
for name,digest in evidence['source_hashes'].items():
|
||||
@@ -268,18 +283,20 @@ def packaging_tests_current():
|
||||
for name,digest in evidence['hashes'].items(): require(file_sha(ROOT/name)==digest,'untested packaging source: '+name)
|
||||
|
||||
|
||||
def publish(report,output,requested):
|
||||
def publish(report,output,requested,full=False):
|
||||
require(all(edge.get('nativeLoop') is True or 'mouthRuntimeManifest' in edge for edge in read_json(ROOT/'app/src/main/assets'/ASSET_ROOT/'manifest.json')['edges']),
|
||||
'live emotion release needs bridge-own TALK runtimes')
|
||||
tested_source();packaging_tests_current();require(file_sha(ROLLBACK)==ROLLBACK_SHA,'rollback drift')
|
||||
tested_source(full);packaging_tests_current();require(file_sha(ROLLBACK)==ROLLBACK_SHA,'rollback drift')
|
||||
version=next_version((ROOT/'artifacts').glob('*.apk'))
|
||||
if requested is not None:
|
||||
require(requested>=version,'version code occupied');version=requested
|
||||
require(not full or version>=18,'full candidate needs code >=18')
|
||||
subprocess.run([str(ROOT/'scripts/build.sh'),'assembleDebug','compileDebugAndroidTestKotlin','-PavatarActionCandidate=true',
|
||||
'-PavatarNatural=true','-PavatarMouthCandidate=true','-PnaturalManifestSha='+LEGACY_PIN,
|
||||
'-PemotionManifestSha='+report['manifest_sha256'],'-PactionVersionCode='+str(version)],check=True,cwd=ROOT)
|
||||
'-PemotionManifestSha='+report['manifest_sha256'],'-PactionVersionCode='+str(version),'-PavatarFullActionCandidate='+str(full).lower()],check=True,cwd=ROOT)
|
||||
built=ROOT/'app/build/outputs/apk/debug/app-debug.apk';badge=badging(built)
|
||||
for text in ("name='com.gorios.lanvoice'",f"versionCode='{version}'","versionName='0.7.0-emotion-dev'","sdkVersion:'26'","targetSdkVersion:'34'"):
|
||||
version_name='0.7.0' if full else '0.7.0-emotion-dev'
|
||||
for text in ("name='com.gorios.lanvoice'",f"versionCode='{version}'",f"versionName='{version_name}'","sdkVersion:'26'","targetSdkVersion:'34'"):
|
||||
require(text in badge,'APK metadata: '+text)
|
||||
require(re.search(r'^native-code: (.+)$',badge,re.M)[1].strip()=="'arm64-v8a'",'APK ABI')
|
||||
cert=subprocess.check_output([str(TOOLS/'apksigner'),'verify','--verbose','--print-certs',str(built)],text=True)
|
||||
@@ -295,7 +312,8 @@ def publish(report,output,requested):
|
||||
config=ROOT/'app/build/generated/source/buildConfig/debug/com/gorios/lanvoice/BuildConfig.java'
|
||||
require('EMOTION_MANIFEST_SHA = "'+report['manifest_sha256']+'"' in config.read_text(),'compiled index pin mismatch')
|
||||
require(version>=next_version((ROOT/'artifacts').glob('*.apk')),'version became occupied during build')
|
||||
artifact=ROOT/f'artifacts/lan-voice-v070-emotion-candidate-code{version}-arm64-debug.apk'
|
||||
stem='action-emotion' if full else 'emotion-candidate'
|
||||
artifact=ROOT/f'artifacts/lan-voice-v070-{stem}-code{version}-arm64-debug.apk'
|
||||
with artifact.open('xb') as f,built.open('rb') as source: shutil.copyfileobj(source,f)
|
||||
digest=file_sha(artifact);checksum=f'{digest} {artifact.name}\n'.encode()
|
||||
with artifact.with_suffix('.apk.sha256').open('xb') as f: f.write(checksum)
|
||||
@@ -304,8 +322,8 @@ def publish(report,output,requested):
|
||||
with opener.open(url,timeout=30) as response: require(response.status==200 and sha(response.read())==digest,'HTTP APK bytes mismatch')
|
||||
with opener.open(url+'.sha256',timeout=15) as response: require(response.status==200 and response.read()==checksum,'HTTP checksum mismatch')
|
||||
require(file_sha(ROLLBACK)==ROLLBACK_SHA,'rollback modified')
|
||||
delivery={'status':'partial_emotion_candidate','version_name':'0.7.0-emotion-dev','version_code':version,'url':url,'sha256':digest,
|
||||
'certificate_sha256':CERT,'manifest_sha256':report['manifest_sha256'],'dance_available':False,'action_count':0,
|
||||
delivery={'status':'full_action_emotion_candidate' if full else 'partial_emotion_candidate','version_name':version_name,'version_code':version,'url':url,'sha256':digest,
|
||||
'certificate_sha256':CERT,'manifest_sha256':report['manifest_sha256'],'dance_available':full,'action_count':report['action_count'],
|
||||
'http_bytes_verified':True,'device':'not_run','naturalness':'not_certified','paid_calls':0,'gateway_deployed':False}
|
||||
(output/'delivery.json').write_text(json.dumps(delivery,indent=2)+'\n')
|
||||
return delivery
|
||||
@@ -320,12 +338,13 @@ def main():
|
||||
parser.add_argument('--previous-import-report',type=Path,help='Verified previous bundle-gate.json; requires --previous-pin and fresh backup')
|
||||
parser.add_argument('--previous-pin')
|
||||
parser.add_argument('--backup',type=Path)
|
||||
parser.add_argument('--action-registry',type=Path,help='Reviewed public gateway registry required for full dance release')
|
||||
parser.add_argument('--version-code',type=int,help='Default max existing APK code+1, minimum17')
|
||||
args=parser.parse_args();manifest=args.manifest.resolve(strict=True);output=args.output.resolve()
|
||||
require(not output.exists() and not output.is_relative_to(manifest.parent),'new evidence outside owner root required')
|
||||
if args.import_only or args.publish: require(args.pi_pin==args.sha256 and re.fullmatch('[0-9a-f]{64}',args.pi_pin or ''),'external Pi pin required')
|
||||
if args.import_only or args.publish:
|
||||
require(read_json(manifest)['actions']==[],'dance import/publication requires separately reviewed gateway capability admission; read-only gate supported')
|
||||
if read_json(manifest)['actions']: reviewed_actions(read_json(manifest),args.pi_pin,args.action_registry)
|
||||
output.mkdir(parents=True)
|
||||
report=check_bundle(manifest,args.sha256,output)
|
||||
if args.import_only or args.publish:
|
||||
@@ -337,7 +356,7 @@ def main():
|
||||
require(not args.previous_pin and not args.backup,'previous import report required')
|
||||
import_files(manifest.parent,report['files'],target)
|
||||
(output/'import.json').write_text(json.dumps({'externally_pinned_sha256':args.pi_pin,'files':len(report['files']),'naturalness':'not_certified'})+'\n')
|
||||
result=publish(report,output,args.version_code) if args.publish else {k:v for k,v in report.items() if k!='files'}
|
||||
result=publish(report,output,args.version_code,bool(report['action_count'])) if args.publish else {k:v for k,v in report.items() if k!='files'}
|
||||
print(json.dumps(result,indent=2))
|
||||
|
||||
|
||||
|
||||
@@ -13,13 +13,25 @@ ROOT=Path(__file__).resolve().parents[1]
|
||||
def main():
|
||||
parser=argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--output',type=Path,required=True,help='New ignored numeric evidence file')
|
||||
parser.add_argument('--approved-pack-sha',help='Exact public registry pin; no fixture admission')
|
||||
parser.add_argument('--pack-gate',type=Path,help='Matching production gate for actual action metadata')
|
||||
args=parser.parse_args()
|
||||
output=args.output.resolve()
|
||||
if output.exists() or not output.is_relative_to(ROOT/'logs'): raise ValueError('new logs evidence required')
|
||||
source={p.name:base64.b64encode(p.read_bytes()).decode() for p in (ROOT/'gateway').glob('*.py')}
|
||||
approved=None
|
||||
if args.approved_pack_sha:
|
||||
registry=ROOT/'gateway/reviewed_action_packs.json'
|
||||
table=json.loads(registry.read_text())
|
||||
gate=json.loads(args.pack_gate.read_text())
|
||||
assert gate['status']=='passed' and gate['manifest_sha256']==args.approved_pack_sha and gate['action_count']==2
|
||||
durations={row['id']:(row['durationUs']+999)//1000 for row in gate['action_measurements']}
|
||||
assert table[args.approved_pack_sha]==durations
|
||||
approved={'sha256':args.approved_pack_sha,'durations':durations,'body_packages':5,'edges':13,'own_bridges':8}
|
||||
source[registry.name]=base64.b64encode(registry.read_bytes()).decode()
|
||||
baseline=json.loads((ROOT/'gateway/SOURCE_MANIFEST.json').read_text())['deployment_baseline']['files']
|
||||
expected={name:digest for name,digest in baseline.items() if name in source and name!='tests_fake.py'}
|
||||
payload='sources='+repr(source)+'\nexpected='+repr(expected)+'\n'+(ROOT/'scripts/action-calling-path-remote.py').read_text()
|
||||
payload='sources='+repr(source)+'\nexpected='+repr(expected)+'\napproved='+repr(approved)+'\n'+(ROOT/'scripts/action-calling-path-remote.py').read_text()
|
||||
run=subprocess.run(['ssh','-o','BatchMode=yes','-o','ConnectTimeout=5',
|
||||
'gorios-spark-2@192.168.31.61','cd /home/gorios-spark-2/lan-voice && exec .venv/bin/python -'],
|
||||
input=payload.encode(),capture_output=True,timeout=210)
|
||||
|
||||
Reference in New Issue
Block a user