Wire production aircraft callbacks and diagnose native prison action selection

This commit is contained in:
2026-09-19 20:03:38 +02:00
parent 53eaf3894d
commit f870443b9b
58 changed files with 40247 additions and 27 deletions
+37
View File
@@ -193,4 +193,41 @@ class AlignmentRunner(unittest.TestCase):
result,proof=r.input_exercise_result('game-started',context,session,observation,{'verified':True})
self.assertFalse(proof['verified']);self.assertIn('unchanged module sources',proof['error'])
class GateChoicesRunner(unittest.TestCase):
def test_readonly_choices_require_gate_and_preserve_default_signature(self):
base=['gamescope','--backend','headless','--','/proton','run','/game']
previous=r.input_observer_command(base,'chat',None,NONCE,True,True)
self.assertNotIn('-errOrdinaryGateChoices',previous)
choices=r.input_observer_command(base,'chat',None,NONCE,True,True,True)
self.assertEqual(choices,previous+['-errOrdinaryGateChoices',NONCE])
valid=dict(observe_prison_choices=True,observe_prison_gate=True,observe_player_input=True,project='chat',settle=50)
r.validate_input_observer(SimpleNamespace(**valid))
r.validate_input_exercise(SimpleNamespace(**valid)) # no input is requested
for missing in ('observe_prison_gate','observe_player_input'):
with self.assertRaises(ValueError):r.validate_input_observer(SimpleNamespace(**{**valid,missing:False}))
with self.assertRaises(ValueError):r.validate_input_exercise(SimpleNamespace(**valid,exercise_player_input=True))
for gate,choice in [(False,True),(True,1),(True,'true')]:
with self.assertRaises(ValueError):r.input_observer_command(base,'chat',None,NONCE,gate=gate,choices=choice)
for extra in (['-errOrdinaryGateChoices',NONCE],['-errOrdinaryGateChoices','foreign'],['-errOrdinaryGateChoicesAlias',NONCE]):
with self.assertRaises(ValueError):r.input_observer_command(base+extra,'chat',None,NONCE,gate=True,choices=True)
def test_input_wrapper_accepts_only_two_exact_gate_flags_without_extra_input_mode(self):
with tempfile.TemporaryDirectory() as folder:
root=Path(folder);(root/'tools').mkdir();profile=root/'profile';profile.mkdir()
for name in ('headless_input_proof.py','headless_display_probe.py','prison_approach_proof.py','ordinary_gate_evidence.py','ordinary_look_evidence.py','prison_approach_evidence.py'):(root/'tools'/name).write_text('# fake')
native=['gamescope','--backend','headless','--','/proton','run','/game','-errOrdinaryInputObserve',NONCE,'-errOrdinaryLookObserve',NONCE,'-errOrdinaryGateObserve',NONCE]
def wrap(value,approach=True):
wrapped,display=r.display_probe_command(value,root,Path('/compat'),profile,Path('/game'),NONCE,':0')
return r.input_exercise_command(wrapped,root,Path('/compat'),profile,Path('/game'),NONCE,':0',display,True,approach)
baseline,context=wrap(native)
command,newcontext=wrap(native+['-errOrdinaryGateChoices',NONCE])
self.assertEqual(command,baseline+['-errOrdinaryGateChoices',NONCE])
self.assertEqual({k:v for k,v in newcontext.items() if k!='command'},{k:v for k,v in context.items() if k!='command'})
self.assertEqual(newcontext['command'],context['command']+['-errOrdinaryGateChoices',NONCE])
for extra in (['-errOrdinaryGateChoices'],['-errOrdinaryGateChoices','foreign'],['-errOrdinaryGateChoices',NONCE]*2,['-errOrdinaryGateObserve',NONCE],['-errOrdinaryGateChoicesAlias',NONCE]):
with self.subTest(extra=extra),self.assertRaises(ValueError):wrap(native+extra)
with self.assertRaises(ValueError):wrap(native[:-2]+['-errOrdinaryGateChoices',NONCE])
with self.assertRaises(ValueError):wrap(native+['-errOrdinaryGateChoices',NONCE],False)
if __name__=='__main__':unittest.main()