Reject resident audio reuse without session lease opt-in

This commit is contained in:
firestar5683
2026-09-19 16:51:29 -07:00
parent a23492f627
commit ca2c16b7bc
2 changed files with 8 additions and 0 deletions
+1
View File
@@ -5,6 +5,7 @@ from pathlib import Path
def verify(metadata,environ):
if metadata.get('resident_capable') and environ.get('ROADSCORE_RESIDENT')!='1':raise ValueError('Resident service requires an opted-in fresh handoff and playback lease')
if int(metadata.get('generation_seed',-1))!=int(environ['ROADSCORE_GENERATION_SEED']):raise ValueError('Resident composer belongs to another seed; its owner must finish/release that session')
if metadata.get('prepared_profile')!=environ.get('ROADSCORE_ACE_PROFILE','prism'):raise ValueError('Resident composer profile differs from this launch')
if metadata.get('composition_policy','prepared-v1')!=environ.get('ROADSCORE_COMPOSITION_POLICY','prepared-v1'):raise ValueError('Resident composer policy differs from this launch')
@@ -77,3 +77,10 @@ def test_wrong_bank_does_not_change_existing_session(worker):
state,saved,audio,model=worker
with pytest.raises(ValueError,match='identity changed'):state['prepare_session'](selection(124,'b'*64))
assert state['base_seed']==123 and audio==[]
def test_nonresident_launch_cannot_reuse_resident_audio_with_same_seed():
from prepared_session import verify
metadata={'generation_seed':123,'prepared_profile':'prism','composition_policy':'hook-cache-v1','resident_capable':True}
env={'ROADSCORE_GENERATION_SEED':'123','ROADSCORE_ACE_PROFILE':'prism','ROADSCORE_COMPOSITION_POLICY':'hook-cache-v1'}
with pytest.raises(ValueError,match='opted-in'):verify(metadata,env)