import asyncio
import json
import sys
from datetime import datetime
from pathlib import Path

# Add genesis path
GENESIS_ROOT = Path(__file__).parent.parent
sys.path.insert(0, str(GENESIS_ROOT))

from revenue.engine import RevenueEngine

async def verify_engine():
    print("--- STARTING REVENUE ENGINE SCALE-UP ---")
    engine = RevenueEngine()
    
    industries = ["Emergency Plumbing", "Commercial HVAC", "Personal Injury Law"]
    all_gifts = {}

    for industry in industries:
        print(f"\n--- SCOUTING INDUSTRY: {industry} ---")
        targets = await engine.shoe_buyer_scout(industry)
        print(f"Found {len(targets)} targets.")
        
        industry_gifts = []
        for target in targets[:2]: # Top 2 per industry
            print(f"Generating Golden Gift for: {target['name']}...")
            gift = await engine.run_experiment("unified_gift", {
                "business": target,
                "mode": "VAPI_DEMO_LOOM"
            })
            industry_gifts.append({"target": target, "gift": gift})
        
        all_gifts[industry] = industry_gifts

    # Save scale-up results
    results_path = engine.data_dir / f"scaleup_results_{int(datetime.now().timestamp())}.json"
    results_path.write_text(json.dumps(all_gifts, indent=2))
    print(f"\n[SUCCESS] Scale-up results saved to {results_path}")
    print("\n--- SCALE-UP COMPLETE ---")

if __name__ == "__main__":
    asyncio.run(verify_engine())
