"""Test champion forward inference and HOLD.""" import sys import os sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) import champion_gen42 as champ import numpy as np agent = champ.CapsuleAgent(observe=False, observe_visual=False) print('=== FORWARD INFERENCE TEST ===') inputs = { 'obs': np.random.randn(384).astype(np.float32), 'prev_action': 0, 'reset': True, 'frame': 0 } result = agent.forward(inputs) print(f'Result keys: {list(result.keys())}') print(f'Action: {result.get("action")}') print(f'Action probs: {result.get("action_probs")}') print(f'Value: {result.get("value")}') latent = result.get('latent') if latent is not None: print(f'Latent shape: {np.array(latent).shape}') print('\n=== FORWARD_HOLD TEST ===') try: hold_result = agent.forward_hold(inputs) print(f'Hold result keys: {list(hold_result.keys())}') if 'hold_point' in hold_result: hp = hold_result['hold_point'] print(f'Hold point type: {type(hp).__name__}') if hasattr(hp, 'ai_choice'): print(f'AI choice: {hp.ai_choice}') if hasattr(hp, 'ai_confidence'): print(f'AI confidence: {hp.ai_confidence}') if hasattr(hp, 'merkle_root'): print(f'Merkle root: {hp.merkle_root}') except Exception as e: print(f'Hold test error: {e}') print('\n=== CASCADE IDENTITY ===') try: identity = agent.get_cascade_identity() print(f'Identity: {identity}') except Exception as e: print(f'Identity error: {e}') print('\n=== README (first 500 chars) ===') readme = agent.get_readme() print(readme[:500] if readme else 'No readme') print('\n=== REPLICATE QUINE ===') try: new_quine = champ.replicate_quine() print(f'Replicated: {new_quine}') except Exception as e: print(f'Replicate error: {e}') print('\n=== VERIFY INTEGRITY ===') try: valid = champ.verify_quine_integrity() print(f'Integrity valid: {valid}') except Exception as e: print(f'Verify error: {e}')