"""Read-only diagnostic boundaries; no native control/application proof.""" from pathlib import Path import subprocess import sys import tempfile import unittest from policy_harness import body ROOT=Path(__file__).resolve().parents[1] SOURCE=ROOT/'addons/core/Scripts/Game/ERR/00_Core/ERR_NativeFlightInputDiagnostics.c' class FlightInputDiagnostics(unittest.TestCase): def test_observers_have_no_control_or_setting_mutators(self): source=SOURCE.read_text() self.assertTrue(source.startswith('#ifdef WORKBENCH')) for forbidden in ['.Set', '.AddOrFindSignal(', '.AddOrFindMPSignal(', '.StartEngine(', '.StopEngine(', '.Spawn', '.Teleport(', '.Delete', 'Check(', 'Transition(']: self.assertNotIn(forbidden,source) self.assertNotIn('modded class SCR_CharacterControllerComponent',source) self.assertIn('super.ApplyPilot(controller, owner, dt);',source) self.assertIn('super.PreparePilotActions(controller, owner, am, dt);',source) self.assertIn('super.Diagnostic(now);',source) def test_exact_actor_and_authority_before_observation(self): for signature in ['override void ApplyPilot(', 'void ERR_ObserveAppliedFlightInput(']: method=body(SOURCE,signature) self.assertIn('controller != m_Character || owner != m_Pilot',method) self.assertIn('!ERR_InputDiagActive()',method) self.assertLess(method.index('owner != m_Pilot'),method.index('m_Input.GetVehicleCollective()')) active=body(SOURCE,'protected bool ERR_InputDiagActive(') self.assertIn('System.GetCLIParam("errFlightInputDiag", enabled)',active) self.assertIn('!m_Bound || m_Stopped || !m_Input',active) self.assertIn('return PoweredAuthority();',active) def test_existing_signal_indexes_and_bounded_correlated_samples(self): lookup=body(SOURCE,'protected string ERR_ExistingRotorSignal(') self.assertIn('signals.FindSignal(name)',lookup) self.assertLess(lookup.index('if (index < 0) return "missing";'),lookup.index('signals.GetSignalValue(index)')) source=SOURCE.read_text() for name in ['MainRotorCollective','MainRotorCyclicForward','MainRotorCyclicAside','TailRotorCollective']: self.assertIn('ERR_ExistingRotorSignal(signals, "'+name+'")',source) self.assertIn('m_Controller.GetAutohoverEnabled()',source) self.assertIn('now >= m_NextLog',source) self.assertIn('m_ERRInputDiagSamples >= 120',source) self.assertEqual(source.count('PrintFormat('),3) self.assertIn('m_ERRAppliedSequence = m_ERRWrittenSequence;',source) self.assertIn('m_ControlUpdates == before',source) def test_optional_runner_flag_parses_then_refuses_missing_prefix(self): with tempfile.TemporaryDirectory() as directory: profile=Path(directory) result=subprocess.run([sys.executable,str(ROOT/'tools/headless_workbench.py'), '--smoke','powered-flight','--project','core','--rounds','1','--timeout','420', '--compat',str(profile/'missing-prefix'),'--profile',str(profile), '--flight-input-diagnostics'],text=True,capture_output=True) self.assertNotEqual(result.returncode,0) self.assertIn('must be a disposable cloned prefix',result.stderr) self.assertEqual(list(profile.iterdir()),[]) runner=(ROOT/'tools/headless_workbench.py').read_text() self.assertIn("if a.flight_input_diagnostics: command += ['-errFlightInputDiag', '1']",runner) if __name__=='__main__': unittest.main()