#!/usr/bin/env python3 """Validation suite for 600 glyphs with 152 superpowers. Tests: 1. G001 has exactly 152 superpowers 2. G002-G600 have 5-25 superpowers each 3. All superpower IDs are valid (1-152) 4. Specialized types are correctly assigned 5. FedMart telemetry emits on activation """ import sys from pathlib import Path sys.path.insert(0, str(Path.cwd())) from glyphs.superpower_registry import load_all_superpowers, super_stats, get_superpower from glyphs.superpower_assigner import assign_superpowers, calculate_power_count from glyphs.specialized_types import get_specialized_type, SPECIALIZED_GLYPH_TYPES def test_superpowers_loaded(): """Test 1: 152 superpowers loaded.""" stats = super_stats() if stats["total"] != 152: print(f"FAIL: Expected 152 superpowers, got {stats['total']}") return False if not stats["loaded"]: print("FAIL: Superpowers not marked as loaded") return False print(f"PASS: Loaded {stats['total']} superpowers") return True def test_g001_all_powers(): """Test 2: G001 has all 152 superpowers.""" superpowers = assign_superpowers("G001", {"power": 100, "resonance": 100, "stability": 100}) if len(superpowers) != 152: print(f"FAIL: G001 should have 152 superpowers, got {len(superpowers)}") return False if superpowers != list(range(1, 153)): print("FAIL: G001 superpowers not sequential 1-152") return False print(f"PASS: G001 has {len(superpowers)} superpowers") return True def test_g002_g600_power_range(): """Test 3: G002-G600 have 5-25 superpowers.""" test_ids = ["G002", "G100", "G300", "G600"] for glyph_id in test_ids: glyph_num = int(glyph_id[1:]) metrics = { "power": 50 + glyph_num % 50, "resonance": 50 + glyph_num % 40, "stability": 50 + glyph_num % 30, "connectivity": 50 + glyph_num % 20, "affinity": 50 + glyph_num % 10, } superpowers = assign_superpowers(glyph_id, metrics) if len(superpowers) < 5 or len(superpowers) > 25: print(f"FAIL: {glyph_id} has {len(superpowers)} powers (should be 5-25)") return False print(f"PASS: G002-G600 power count in 5-25 range") return True def test_superpower_ids_valid(): """Test 4: All superpower IDs are valid (1-152).""" test_glyphs = ["G001", "G002", "G100", "G300", "G600"] for glyph_id in test_glyphs: metrics = {"power": 70, "resonance": 70, "stability": 70} superpowers = assign_superpowers(glyph_id, metrics) for sp_id in superpowers: if sp_id < 1 or sp_id > 152: print(f"FAIL: {glyph_id} has invalid superpower ID {sp_id}") return False print("PASS: All superpower IDs valid (1-152)") return True def test_specialized_types(): """Test 5: Specialized types correctly assigned.""" # G001 should be aether_node type_001 = get_specialized_type("G001", {"power": 100}) if type_001 != "aether_node": print(f"FAIL: G001 should be aether_node, got {type_001}") return False # G600 should be monument_grade_equilibrium type_600 = get_specialized_type("G600", {"stability": 90, "resonance": 85}) if type_600 != "monument_grade_equilibrium": print(f"FAIL: G600 should be monument_grade_equilibrium, got {type_600}") return False # Test other types type_stability = get_specialized_type("G050", {"stability": 85, "resonance": 70}) if type_stability != "frost_steel_stabilizer": print(f"FAIL: High stability glyph should be frost_steel_stabilizer, got {type_stability}") return False print("PASS: Specialized types correctly assigned") return True def test_power_boost_calculation(): """Test 6: Power boost calculated correctly.""" from glyphs.superpower_registry import calculate_boost # Test with known superpowers boost = calculate_boost([1, 2, 3]) # SP1: 65%, SP2: 40%, SP3: 55% expected = 1.0 + (65 + 40 + 55) / 100.0 # 2.6 if abs(boost - expected) < 0.01: print(f"PASS: Power boost calculated correctly ({boost:.2f})") return True else: print(f"FAIL: Power boost {boost} != expected {expected}") return False def test_supercharged_glyphs_file(): """Test 7: Supercharged glyphs file exists and valid.""" import json path = Path("/home/dave/superdave/glyphs/supercharged_glyphs.json") if not path.exists(): print(f"FAIL: supercharged_glyphs.json not found") return False with open(path) as f: data = json.load(f) if data.get("totalGlyphs") != 600: print(f"FAIL: Expected 600 glyphs, got {data.get('totalGlyphs')}") return False # Check G001 g001 = next(g for g in data["glyphs"] if g["id"] == "G001") if len(g001.get("superpowers", [])) != 152: print(f"FAIL: G001 should have 152 superpowers in file") return False if g001.get("name") != "Ledo": print(f"FAIL: G001 name should be 'Ledo', got '{g001.get('name')}'") return False print("PASS: Supercharged glyphs file valid") return True def test_glyphos_data_file(): """Test 8: GlyphOS data file updated.""" import json path = Path("/home/dave/glyphos/data/glyphs.json") if not path.exists(): print(f"FAIL: glyphos/data/glyphs.json not found") return False with open(path) as f: data = json.load(f) if data.get("total_glyphs") != 600: print(f"FAIL: Expected 600 glyphs, got {data.get('total_glyphs')}") return False # Check G001 g001 = next(g for g in data["glyphs"] if g["glyph_id"] == "G001") if g001.get("name") != "Ledo": print(f"FAIL: G001 name should be 'Ledo' in glyphos data") return False if g001.get("power_count") != 152: print(f"FAIL: G001 should have 152 powers in glyphos data") return False print("PASS: GlyphOS data file updated") return True def test_fedmart_telemetry_module(): """Test 9: FedMart telemetry module exists.""" path = Path("/home/dave/superdave/integrations/fedmart/glyph_telemetry.py") if not path.exists(): print(f"FAIL: glyph_telemetry.py not found") return False # Try to import try: from integrations.fedmart.glyph_telemetry import emit_glyph_activation, GlyphActivationEvent print("PASS: FedMart telemetry module importable") return True except ImportError as e: print(f"FAIL: Cannot import glyph_telemetry: {e}") return False def main(): """Run all validation tests.""" print("=" * 70) print("GLYPH SUPERPOWER VALIDATION SUITE") print("=" * 70) tests = [ ("Superpowers Loaded", test_superpowers_loaded), ("G001 All Powers", test_g001_all_powers), ("G002-G600 Power Range", test_g002_g600_power_range), ("Superpower IDs Valid", test_superpower_ids_valid), ("Specialized Types", test_specialized_types), ("Power Boost Calculation", test_power_boost_calculation), ("Supercharged Glyphs File", test_supercharged_glyphs_file), ("GlyphOS Data File", test_glyphos_data_file), ("FedMart Telemetry Module", test_fedmart_telemetry_module), ] passed = 0 failed = 0 for name, test_func in tests: print(f"\nTest: {name}") if test_func(): passed += 1 else: failed += 1 print("\n" + "=" * 70) print(f"Results: {passed}/{len(tests)} passed") print("=" * 70) if failed > 0: print(f"\n❌ {failed} tests failed") return False else: print("\n✅ All tests passed!") return True if __name__ == "__main__": success = main() sys.exit(0 if success else 1)