"""Quick smoke test for AIVA autonomy system"""

import sys
from pathlib import Path

GENESIS_ROOT = Path(__file__).parent.parent
sys.path.insert(0, str(GENESIS_ROOT))

try:
    print("Testing imports...")
    from AIVA.autonomy import (
        AutonomyManager,
        AutonomyLevel,
        ConfidenceScorer,
        HITLGateManager,
        GateType
    )
    print("✓ Imports successful")

    print("\nTesting AutonomyManager initialization...")
    manager = AutonomyManager()
    print("✓ AutonomyManager created")

    print("\nTesting confidence scoring...")
    scorer = ConfidenceScorer()
    confidence = scorer.calculate_confidence("test_task", data_completeness=1.0)
    print(f"✓ Confidence calculated: {confidence:.2f}%")

    print("\nTesting HITL gates...")
    hitl = HITLGateManager()
    gate_type = hitl.requires_approval("send_email")
    print(f"✓ HITL gate check: {gate_type}")

    print("\nTesting autonomy decision...")
    can_execute, reason, _ = manager.can_execute_task(
        task_type="test_routine_task",
        task_description="Simple test task"
    )
    print(f"✓ Autonomy decision: can_execute={can_execute}, reason={reason}")

    print("\nTesting budget tracking...")
    budget = manager.get_daily_budget_status()
    print(f"✓ Budget status: ${budget['spent']:.2f} / ${budget['limit']:.2f}")

    print("\n" + "="*60)
    print("ALL SMOKE TESTS PASSED")
    print("="*60)

    # Cleanup
    manager.close()
    scorer.close()
    hitl.close()

except Exception as e:
    print(f"\n✗ ERROR: {e}")
    import traceback
    traceback.print_exc()
    sys.exit(1)
