File size: 4,638 Bytes
f4bee9e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/usr/bin/env python3
"""
🔍 PHASE 5.1 VERIFICATION - Final check of all components
"""

import sys
from pathlib import Path

# Add project root to path
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))

def verify_database_models():
    """Verify all 7 database models exist"""
    print("\n📦 VERIFYING DATABASE MODELS (7 TABLES)...")
    
    models = [
        "deployment_identity.py",
        "model_registry.py", 
        "security_memory.py",
        "autonomous_decisions.py",
        "policy_versions.py",
        "operator_interactions.py",
        "system_health_history.py"
    ]
    
    all_exist = True
    for model in models:
        path = Path("database/models") / model
        if path.exists():
            print(f"   ✅ {model}")
        else:
            print(f"   ❌ {model}")
            all_exist = False
    
    return all_exist

def verify_engine_components():
    """Verify Phase 5 engine components"""
    print("\n🧠 VERIFYING PHASE 5 ENGINE COMPONENTS...")
    
    components = [
        "autonomous/core/database_engine.py",
        "autonomous/core/compatibility.py",
        "database/config.py",
        "database/init_database.py"
    ]
    
    all_exist = True
    for component in components:
        path = Path(component)
        if path.exists():
            print(f"   ✅ {component}")
        else:
            print(f"   ❌ {component}")
            all_exist = False
    
    return all_exist

def verify_execution_scripts():
    """Verify execution scripts"""
    print("\n🚀 VERIFYING EXECUTION SCRIPTS...")
    
    scripts = [
        "execute_phase5.py",
        "test_phase5_engine.py", 
        "setup_postgresql.py",
        "test_database.py"
    ]
    
    all_exist = True
    for script in scripts:
        path = Path(script)
        if path.exists():
            print(f"   ✅ {script}")
        else:
            print(f"   ❌ {script}")
            all_exist = False
    
    return all_exist

def test_minimal_integration():
    """Test minimal integration"""
    print("\n🧪 TESTING MINIMAL INTEGRATION...")
    
    try:
        # Test database engine creation
        from autonomous.core.database_engine import create_phase5_engine
        
        engine = create_phase5_engine()
        print("   ✅ Phase 5 engine created")
        
        # Test basic functionality
        health = engine.get_ecosystem_health()
        print(f"   ✅ Ecosystem health check: {health.get('health_score', 0.0):.3f}")
        
        models = engine.get_models_by_domain("vision")
        print(f"   ✅ Model retrieval: {len(models)} vision models")
        
        return True
        
    except Exception as e:
        print(f"   ❌ Integration test failed: {e}")
        return False

def main():
    """Main verification routine"""
    print("\n" + "="*80)
    print("🔍 PHASE 5.1 COMPONENT VERIFICATION")
    print("="*80)
    
    # Verify components
    models_ok = verify_database_models()
    engine_ok = verify_engine_components()
    scripts_ok = verify_execution_scripts()
    
    # Test integration
    integration_ok = test_minimal_integration()
    
    print("\n" + "="*80)
    print("📊 VERIFICATION RESULTS")
    print("="*80)
    
    all_ok = models_ok and engine_ok and scripts_ok and integration_ok
    
    if all_ok:
        print("✅ PHASE 5.1: FULLY VERIFIED")
        print("\n🎯 COMPONENTS STATUS:")
        print("   Database Models: 7/7 tables ✓")
        print("   Engine Components: 4/4 files ✓")
        print("   Execution Scripts: 4/4 scripts ✓")
        print("   Integration Test: PASSED ✓")
        
        print("\n🚀 READY FOR:")
        print("   • Phase 5.2: Ecosystem Authority")
        print("   • Production deployment with PostgreSQL")
        print("   • Multi-domain security operations")
        
    else:
        print("⚠️  PHASE 5.1: PARTIALLY VERIFIED")
        print("\n🔧 ISSUES FOUND:")
        if not models_ok:
            print("   • Missing database models")
        if not engine_ok:
            print("   • Missing engine components")
        if not scripts_ok:
            print("   • Missing execution scripts")
        if not integration_ok:
            print("   • Integration test failed")
        
        print("\n💡 RECOMMENDATIONS:")
        print("   1. Run the creation scripts again")
        print("   2. Check file permissions")
        print("   3. Verify Python dependencies")
    
    print("\n" + "="*80)
    return all_ok

if __name__ == "__main__":
    success = main()
    sys.exit(0 if success else 1)