File size: 3,834 Bytes
a2079ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/env python3
"""
Test Stage 0: Pre-flight validation integration
"""

import logging
from pathlib import Path
from agent.pipeline_engine import OvergrowthPipeline, NetworkIntent

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


def test_preflight_pass():
    """Test pre-flight with valid network"""
    print("\n=== Test 1: Pre-flight Validation - PASS ===")
    
    pipeline = OvergrowthPipeline()
    
    # Create a good network intent
    intent = NetworkIntent(
        description="Corporate office network with guest WiFi",
        business_requirements=["Secure guest access", "High availability", "QoS for VoIP"],
        constraints=["Budget under $15K", "Cisco preferred"],
        budget="$15000",
        timeline="2 weeks"
    )
    
    # Generate source of truth
    model = pipeline.stage2_generate_sot(intent)
    
    # Run pre-flight validation
    results = pipeline.stage0_preflight(model)
    
    print(f"\nValidation Results:")
    print(f"  Schema Valid: {results['schema_valid']}")
    print(f"  Policy Passed: {results['policy_passed']}")
    print(f"  Ready to Deploy: {results['ready_to_deploy']}")
    print(f"  Errors: {len(results['errors'])}")
    print(f"  Warnings: {len(results['warnings'])}")
    print(f"  Info: {len(results['info'])}")
    
    if results['errors']:
        print("\nErrors:")
        for err in results['errors']:
            print(f"  - {err}")
    
    if results['warnings']:
        print("\nWarnings:")
        for warn in results['warnings'][:5]:  # Show first 5
            print(f"  - {warn}")
    
    if results['ready_to_deploy']:
        print("\n✓ Pre-flight validation PASSED - ready to deploy")
    else:
        print("\n✗ Pre-flight validation FAILED")


def test_full_pipeline_with_validation():
    """Test complete pipeline including pre-flight"""
    print("\n=== Test 2: Full Pipeline with Validation ===")
    
    pipeline = OvergrowthPipeline()
    
    consultation = "I need a network for a small retail store with guest WiFi, employee WiFi, POS systems, and security cameras. Budget is $5000."
    
    results = pipeline.run_full_pipeline(consultation)
    
    print(f"\nPipeline Results:")
    print(f"  Intent captured: {'intent' in results}")
    print(f"  Model generated: {'model' in results}")
    print(f"  Pre-flight complete: {'preflight' in results}")
    
    if 'preflight' in results:
        pf = results['preflight']
        print(f"\nPre-flight:")
        print(f"  Ready to deploy: {pf['ready_to_deploy']}")
        print(f"  Errors: {len(pf['errors'])}")
        print(f"  Warnings: {len(pf['warnings'])}")
        
        if 'deployment_status' in results:
            print(f"\nDeployment Status: {results['deployment_status']}")
            if 'deployment_reason' in results:
                print(f"  Reason: {results['deployment_reason']}")
    
    print(f"\nOutputs:")
    print(f"  Diagrams: {'diagrams' in results}")
    print(f"  BOM: {'bom' in results}")
    print(f"  Setup Guide: {'setup_guide' in results}")
    
    if 'bom' in results:
        bom = results['bom']
        print(f"\nBill of Materials:")
        print(f"  Total Cost: ${bom.get('total_estimated_cost', 0):,.2f}")
        print(f"  Devices: {len(bom.get('devices', []))}")
    
    print("\n✓ Full pipeline test complete")


if __name__ == "__main__":
    print("\n" + "="*60)
    print("Stage 0: Pre-flight Validation Test")
    print("="*60)
    
    try:
        test_preflight_pass()
        test_full_pipeline_with_validation()
        
        print("\n" + "="*60)
        print("✓ All pre-flight tests passed!")
        print("="*60 + "\n")
        
    except Exception as e:
        print(f"\n✗ Test failed: {e}")
        import traceback
        traceback.print_exc()
        exit(1)