fix: preserve camera permission intent and distinguish unknown reply expression
This commit is contained in:
@@ -28,8 +28,11 @@ with tempfile.TemporaryDirectory(prefix='lan-voice-expression-check-') as output
|
||||
'-no-stdlib', '-no-reflect', '-jvm-target', '17', '-classpath', stdlib, '-d', output,
|
||||
'app/src/main/java/com/gorios/lanvoice/expression/ExpressionRules.kt',
|
||||
'app/src/main/java/com/gorios/lanvoice/expression/FaceCueRules.kt',
|
||||
'app/src/main/java/com/gorios/lanvoice/expression/CameraPermissionGate.kt',
|
||||
'tests/expression/ExpressionRulesCheck.kt',
|
||||
'tests/expression/FaceCueRulesCheck.kt'], check=True)
|
||||
'tests/expression/FaceCueRulesCheck.kt',
|
||||
'tests/expression/CameraPermissionCheck.kt'], check=True)
|
||||
subprocess.run([java, '-cp', output + ':' + stdlib, 'ExpressionRulesCheckKt'], check=True)
|
||||
subprocess.run([java, '-cp', output + ':' + stdlib, 'FaceCueRulesCheckKt'], check=True)
|
||||
subprocess.run([java, '-cp', output + ':' + stdlib, 'CameraPermissionCheckKt'], check=True)
|
||||
PY
|
||||
|
||||
@@ -13,7 +13,7 @@ def health():
|
||||
with opener.open('https://192.168.31.61:5011/health',timeout=3) as r:return json.load(r)
|
||||
def atomic(path,content,mode):
|
||||
path.parent.mkdir(parents=True,exist_ok=True)
|
||||
tmp=path.with_name(path.name+'.v050.tmp');tmp.write_bytes(content);tmp.chmod(mode);tmp.replace(path)
|
||||
tmp=path.with_name(path.name+'.v051.tmp');tmp.write_bytes(content);tmp.chmod(mode);tmp.replace(path)
|
||||
def live_hashes():return {name:digest(root/name) for name in deploy_files}
|
||||
original=live_hashes()
|
||||
if original!=expected:
|
||||
@@ -30,7 +30,7 @@ private_hashes={str(p):digest(p) for p in private_files}
|
||||
def relation_unchanged():
|
||||
return subprocess.check_output(['systemctl','--user','cat',unit])==unit_text and all(digest(Path(p))==h for p,h in private_hashes.items())
|
||||
if apply and health().get('busy'): raise RuntimeError('gateway_busy_no_restart')
|
||||
with tempfile.TemporaryDirectory(prefix='voice-v050-stage-') as folder:
|
||||
with tempfile.TemporaryDirectory(prefix='voice-v051-stage-') as folder:
|
||||
stage=Path(folder)
|
||||
for name,content in bundle.items():
|
||||
path=stage/name;path.parent.mkdir(parents=True,exist_ok=True);path.write_bytes(base64.b64decode(content))
|
||||
@@ -42,7 +42,7 @@ with tempfile.TemporaryDirectory(prefix='voice-v050-stage-') as folder:
|
||||
if live_hashes()!=original:raise RuntimeError('source_changed_during_tests')
|
||||
if not relation_unchanged():raise RuntimeError('environment_or_unit_changed_during_tests')
|
||||
if health().get('busy'):raise RuntimeError('gateway_busy_after_tests_no_restart')
|
||||
backup=root/'.runtime/backups'/time.strftime('voice-v050-%Y%m%d-%H%M%S');backup.mkdir(parents=True,mode=0o700)
|
||||
backup=root/'.runtime/backups'/time.strftime('voice-v051-%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')):
|
||||
dst=backup/path.relative_to(root);dst.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(path,dst)
|
||||
@@ -84,7 +84,7 @@ def main():
|
||||
root=Path(__file__).resolve().parents[1]
|
||||
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['provider_baseline']['files']
|
||||
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')})
|
||||
assert all(n.endswith('.py') 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}
|
||||
|
||||
@@ -15,10 +15,11 @@ import hashlib,json,runpy
|
||||
root=Path.cwd();directory=root/'logs/voice-investigation'
|
||||
load=lambda name:json.loads((directory/name).read_text())
|
||||
release=load('release-emotion.json');probe=load('probe-emotion.json');deploy=load('gateway-emotion-deploy.json');client=load('client-emotion-tests.json')
|
||||
assert release['version_name']=='0.5.0' and release['version_code']==8 and release['signature']=='apksigner_verified'
|
||||
assert release['version_name']=='0.5.1' and release['version_code']==9 and release['signature']=='apksigner_verified'
|
||||
assert release['download_http_status']==200 and release['download_bytes']==release['bytes']
|
||||
assert hashlib.sha256((root/release['apk']).read_bytes()).hexdigest()==release['sha256']
|
||||
assert hashlib.sha256((root/'artifacts/lan-voice-v040-arm64-debug.apk').read_bytes()).hexdigest()=='5a6f88cb2f825dbcd5c7b8c1f212b369534bc53c49533e196fb5e9287902e934'
|
||||
assert hashlib.sha256((root/'artifacts/lan-voice-v050-arm64-debug.apk').read_bytes()).hexdigest()=='da47f7a08f63a68fbb6dbe7fb3d803ee58b402de393112a32f92a63ad50c1f33'
|
||||
assert probe['status']=='passed' and probe['downlink_bytes']>0 and probe['llm_chars']>0 and probe['drained_ack']
|
||||
assert probe['emotion_count']==1 and probe['emotion_before_pcm'] and probe['tts_input_matches_body'] and probe['tts_requests']==1
|
||||
assert deploy['status']=='deployed' and deploy['applied'] and deploy['health']=='ok' and client['status']=='passed'
|
||||
@@ -38,18 +39,18 @@ PY
|
||||
git diff --check
|
||||
git add -- app/build.gradle app/src/main/java/com/gorios/lanvoice/MainActivity.kt \
|
||||
app/src/main/java/com/gorios/lanvoice/audio/VoiceSession.kt \
|
||||
app/src/main/java/com/gorios/lanvoice/dialogue/ReplyEmotion.kt \
|
||||
app/src/main/java/com/gorios/lanvoice/expression/ExpressionController.kt \
|
||||
app/src/main/java/com/gorios/lanvoice/dialogue/ReplyEmotion.kt app/src/main/java/com/gorios/lanvoice/diag/DiagnosticReportUpload.kt \
|
||||
app/src/main/java/com/gorios/lanvoice/expression/ExpressionController.kt app/src/main/java/com/gorios/lanvoice/expression/CameraPermissionGate.kt \
|
||||
app/src/main/java/com/gorios/lanvoice/expression/ExpressionState.kt \
|
||||
app/src/main/java/com/gorios/lanvoice/expression/ExpressionUi.kt \
|
||||
app/src/main/java/com/gorios/lanvoice/net/DialogueProtocol.kt \
|
||||
gateway/gateway.py gateway/llm_provider.py gateway/reply_emotion.py gateway/SOURCE_MANIFEST.json gateway/README.md gateway/env.example gateway/scripts/check-archive.py \
|
||||
gateway/tests/test_continuity.py gateway/tests/test_reply_emotion.py gateway/tests/test_gateway_emotion.py gateway/tests/test_llm_provider.py \
|
||||
gateway/tests/test_debug.py gateway/tests/test_continuity.py gateway/tests/test_reply_emotion.py gateway/tests/test_gateway_emotion.py gateway/tests/test_llm_provider.py \
|
||||
tests/session/AudioDoubles.kt tests/session/ProtocolEvents.kt tests/session/ConnectionCheck.kt tests/protocol/ProtocolCheck.kt \
|
||||
scripts/check-reply-regressions.py scripts/check-reply-structure.py scripts/check-emotion-regressions.sh \
|
||||
scripts/check-expression-rules.sh tests/expression/CameraPermissionCheck.kt scripts/check-reply-regressions.py scripts/check-reply-structure.py scripts/check-emotion-regressions.sh \
|
||||
scripts/deploy-gateway-source.py scripts/rollback-gateway-source.py scripts/update-gateway-manifest.py scripts/deploy-gateway.py scripts/archive-gateway.py \
|
||||
scripts/probe-reply-emotion.py scripts/package-emotion-release.sh scripts/finalize-emotion-release.sh \
|
||||
docs/REPLY_EMOTION_050.md docs/PLAN.md
|
||||
docs/CAMERA_EMOTION_051.md docs/REPLY_EMOTION_050.md docs/PLAN.md
|
||||
git diff --cached --check
|
||||
python3 - <<'PY'
|
||||
import subprocess
|
||||
@@ -57,7 +58,7 @@ names=subprocess.check_output(['git','diff','--cached','--name-only'],text=True)
|
||||
assert names and all(n.startswith(('app/','gateway/','tests/','scripts/','docs/')) for n in names)
|
||||
assert not any(any(x in n.split('/') for x in ('logs','artifacts','.runtime','__pycache__','models')) or n.endswith(('.pem','.key','.apk','.wav','.pcm','.pyc')) for n in names)
|
||||
PY
|
||||
git -c user.name=zenord -c user.email=zenord@email.com commit -m 'feat: merge reply emotions while preserving configurable Qwen/Doubao provider'
|
||||
git -c user.name=zenord -c user.email=zenord@email.com commit -m 'fix: preserve camera permission intent and distinguish unknown reply expression'
|
||||
git push origin main
|
||||
python3 - <<'PY'
|
||||
import json,subprocess
|
||||
@@ -65,7 +66,7 @@ from pathlib import Path
|
||||
commit=subprocess.check_output(['git','rev-parse','HEAD'],text=True).strip()
|
||||
remote=subprocess.check_output(['git','ls-remote','origin','refs/heads/main'],text=True).split()[0]
|
||||
assert commit==remote
|
||||
result={'commit':commit,'branch':'main','push':'verified','archive':'gateway/','version':'0.5.0','archive_baseline':'19a7adccd9322986eb0646b165b9ce1cf2650cf2'}
|
||||
result={'commit':commit,'branch':'main','push':'verified','archive':'gateway/','version':'0.5.1','archive_baseline':'19a7adccd9322986eb0646b165b9ce1cf2650cf2'}
|
||||
Path('logs/voice-investigation/git-emotion-release.json').write_text(json.dumps(result,indent=2)+'\n')
|
||||
print(json.dumps(result,indent=2))
|
||||
PY
|
||||
|
||||
@@ -13,7 +13,7 @@ assert probe['status']=='passed' and probe['downlink_bytes']>0 and probe['emotio
|
||||
assert compat['status']=='passed' and client['status']=='passed'
|
||||
for name,digest in deploy['hashes'].items():assert hashlib.sha256((root/'gateway'/name).read_bytes()).hexdigest()==digest,name
|
||||
for name,digest in client['hashes'].items():assert hashlib.sha256((root/name).read_bytes()).hexdigest()==digest,name
|
||||
assert not (root/'artifacts/lan-voice-v050-arm64-debug.apk').exists(), 'release artifact exists: refusing overwrite'
|
||||
assert not (root/'artifacts/lan-voice-v051-arm64-debug.apk').exists(), 'release artifact exists: refusing overwrite'
|
||||
print('Verified tested client/provider source and successful deployed pipeline before APK build')
|
||||
PY
|
||||
./scripts/build.sh
|
||||
@@ -29,7 +29,7 @@ from pathlib import Path
|
||||
root=Path.cwd()
|
||||
badging=(root/'logs/voice-investigation/release-emotion-badging.txt').read_text()
|
||||
assert "name='com.gorios.lanvoice'" in badging
|
||||
assert "versionCode='8'" in badging and "versionName='0.5.0'" in badging
|
||||
assert "versionCode='9'" in badging and "versionName='0.5.1'" in badging
|
||||
native=re.search(r'^native-code: (.+)$',badging,re.M)
|
||||
assert native and native[1].strip()=="'arm64-v8a'", 'unexpected ABI'
|
||||
source=root/'app/build/outputs/apk/debug/app-debug.apk'
|
||||
@@ -39,9 +39,10 @@ if previous.exists():
|
||||
new=(root/'logs/voice-investigation/release-emotion-signature.txt').read_text()
|
||||
pattern=r'Signer #1 certificate SHA-256 digest: (\w+)'
|
||||
assert re.search(pattern,old)[1]==re.search(pattern,new)[1], 'signing certificate changed: update install would fail'
|
||||
artifact=root/'artifacts/lan-voice-v050-arm64-debug.apk'
|
||||
artifact=root/'artifacts/lan-voice-v051-arm64-debug.apk'
|
||||
assert not artifact.exists(), 'release artifact exists: refusing overwrite'
|
||||
assert hashlib.sha256((root/'artifacts/lan-voice-v040-arm64-debug.apk').read_bytes()).hexdigest()=='5a6f88cb2f825dbcd5c7b8c1f212b369534bc53c49533e196fb5e9287902e934'
|
||||
assert hashlib.sha256((root/'artifacts/lan-voice-v050-arm64-debug.apk').read_bytes()).hexdigest()=='da47f7a08f63a68fbb6dbe7fb3d803ee58b402de393112a32f92a63ad50c1f33'
|
||||
shutil.copy2(source,artifact)
|
||||
digest=hashlib.sha256(artifact.read_bytes()).hexdigest()
|
||||
artifact.with_suffix('.apk.sha256').write_text(f'{digest} {artifact.name}\n')
|
||||
@@ -59,7 +60,7 @@ for path in ('artifacts/'+artifact.name, artifact.name):
|
||||
if downloaded==digest: url=base+path;break
|
||||
except Exception: pass
|
||||
assert url is not None, 'APK built, but existing HTTP server did not serve matching bytes'
|
||||
result=dict(version_name='0.5.0',version_code=8,apk=str(artifact.relative_to(root)),bytes=artifact.stat().st_size,sha256=digest,url=url,download_http_status=200,download_bytes=len(content),signature='apksigner_verified',real_phone_playback='not_tested')
|
||||
result=dict(version_name='0.5.1',version_code=9,apk=str(artifact.relative_to(root)),bytes=artifact.stat().st_size,sha256=digest,url=url,download_http_status=200,download_bytes=len(content),signature='apksigner_verified',real_phone_playback='not_tested')
|
||||
(root/'logs/voice-investigation/release-emotion.json').write_text(json.dumps(result,indent=2)+'\n')
|
||||
print(json.dumps(result,indent=2))
|
||||
PY
|
||||
|
||||
@@ -83,10 +83,14 @@ async def probe():
|
||||
if kind=='reply.emotion':
|
||||
assert event['turn_id']==turn and isinstance(event.get('seq'),int) and event['seq']>0
|
||||
assert (event.get('emotion'),event.get('intensity')) in [('neutral',0)]+[(e,i) for e in ('happy','angry','sad') for i in (1,2)]
|
||||
assert event.get('source')=='model', 'real structured output fell back'
|
||||
assert event.get('source') in ('model','fallback')
|
||||
assert event.get('reason') in ('none','missing_fields','unexpected_fields','invalid_emotion','invalid_intensity','invalid_reply','non_json','invalid_json','truncated','input_limit')
|
||||
if event['source']=='fallback':assert (event['emotion'],event['intensity'])==('neutral',0) and event['reason']!='none'
|
||||
if event['reason']=='truncated':assert event.get('finish_reason')=='length'
|
||||
summary['structured_model_output']=event['source']=='model'
|
||||
assert summary['downlink_frames']==0 and emotion is None and reply_body, 'emotion event order/duplicate'
|
||||
emotion=event;summary['emotion_count']+=1
|
||||
summary['reply_emotion']={key:event[key] for key in ('turn_id','seq','emotion','intensity','source')}
|
||||
summary['reply_emotion']={key:event[key] for key in ('turn_id','seq','emotion','intensity','source','reason','parse_branch','finish_reason','usage')}
|
||||
if kind=='tts' and event.get('state')=='sentence_start':
|
||||
assert event.get('text')==reply_body, 'TTS text differs from parsed body'
|
||||
summary['tts_input_matches_body']=True
|
||||
@@ -94,7 +98,7 @@ async def probe():
|
||||
if kind=='voice.metrics': summary['tts_requests']=event.get('tts_request_count')
|
||||
if kind=='metrics':
|
||||
values=event.get('values',{})
|
||||
summary['backend_metrics']={key:values.get(key) for key in ('stt_ms','llm_first_token_ms','llm_first_body_ms','structured_wait_ms','reply_parse_ms','llm_finished_ms','tts_first_pcm_ms','capture_to_first_pcm_ms','total_ms','tts_request_count','face_cue_used')}
|
||||
summary['backend_metrics']={key:values.get(key) for key in ('stt_ms','llm_first_token_ms','llm_first_body_ms','structured_wait_ms','reply_parse_ms','llm_finished_ms','tts_first_pcm_ms','capture_to_first_pcm_ms','total_ms','tts_request_count','face_cue_used','reply_emotion_reason','reply_parse_branch','reply_emotion','reply_intensity','llm_finish_reason','llm_usage','llm_max_tokens')}
|
||||
summary['segments']=[{key:s.get(key) for key in ('audio_seconds','total_ms','rtf','max_chunk_interarrival_ms')} for s in values.get('tts_segments',[])]
|
||||
if kind=='error': raise RuntimeError('gateway_backend_error')
|
||||
if kind=='tts' and event.get('state')=='stop':
|
||||
|
||||
@@ -5,7 +5,7 @@ import hashlib,json
|
||||
root=Path(__file__).resolve().parents[1]/'gateway'
|
||||
manifest=json.loads((root/'SOURCE_MANIFEST.json').read_text())
|
||||
manifest['archive_baseline_commit']='19a7adccd9322986eb0646b165b9ce1cf2650cf2'
|
||||
manifest['workspace_release']='0.5.0'
|
||||
manifest['workspace_release']='0.5.1'
|
||||
manifest['code_version']='0.7.1 (legacy health version; reply.emotion version 1 capability)'
|
||||
for path in sorted(root.rglob('*')):
|
||||
if not path.is_file():continue
|
||||
|
||||
Reference in New Issue
Block a user