This repository was archived by the owner on Mar 27, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPHASE_12B_TESTING.py
More file actions
380 lines (305 loc) · 13.5 KB
/
PHASE_12B_TESTING.py
File metadata and controls
380 lines (305 loc) · 13.5 KB
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
"""
Phase 12B Testing - Validate Additional Thinking Engines Integration
Tests Russell, Yudkowsky, Chalmers engines with full orchestrator system
TESTS:
1. Load 3 new engines in isolation
2. Verify real_thinking_integration loads all 8 experts
3. Test expert selection for questions requiring new experts
4. Full orchestrator flow with new engines
5. Compare old system (5 experts) vs new system (8 experts)
"""
import sys
sys.path.insert(0, '.')
import logging
from typing import List, Dict, Tuple
logging.basicConfig(
level=logging.WARNING,
format="%(message)s"
)
logger = logging.getLogger(__name__)
def test_new_engines_in_isolation():
"""TEST 1: Load and test the 3 new engines."""
print("\n" + "="*80)
print("TEST 1: NEW THINKING ENGINES IN ISOLATION")
print("="*80)
try:
from DivineOS.law.additional_thinking_engines import (
RussellRealThinkingEngine,
YudkowskyRealThinkingEngine,
ChalmersRealThinkingEngine
)
# Test Russell
print("\n[RUSSELL - Logic and Verification]")
russell = RussellRealThinkingEngine()
russell_analysis = russell.analyze(
"All humans are mortal",
{
"logical_form": "Universal statement",
"premises_explicit": True,
"logically_consistent": True
}
)
print(f" Logical form identified: {russell_analysis.logical_form_identified}")
print(f" Consistency: {russell_analysis.logical_consistency}")
print(f" Premises explicit: {russell_analysis.premises_explicit}")
print(f" Verdict: {russell_analysis.russell_verdict[:80]}...")
russell_pass = bool(russell_analysis.russell_verdict)
# Test Yudkowsky
print("\n[YUDKOWSKY - Decision Theory and AI Safety]")
yudkowsky = YudkowskyRealThinkingEngine()
yudkowsky_analysis = yudkowsky.analyze(
"We should optimize AI for human happiness",
{
"goals_explicit": True,
"optimization_explicit": False,
"alignment_risks": ["specification_gaming"]
}
)
print(f" Decision problem: {yudkowsky_analysis.decision_problem_identified}")
print(f" Goals explicit: {yudkowsky_analysis.goals_specified}")
print(f" Optimization explicit: {yudkowsky_analysis.optimization_target_explicit}")
print(f" Alignment risks: {yudkowsky_analysis.alignment_risks_detected}")
print(f" Verdict: {yudkowsky_analysis.yudkowsky_verdict[:80]}...")
yudkowsky_pass = bool(yudkowsky_analysis.yudkowsky_verdict)
# Test Chalmers
print("\n[CHALMERS - Consciousness Philosophy]")
chalmers = ChalmersRealThinkingEngine()
chalmers_analysis = chalmers.analyze(
"Neural correlates explain consciousness",
{
"addresses_phenomenal": True,
"hard_problem_acknowledged": False,
"explanatory_gap": True
}
)
print(f" Phenomenal experience addressed: {chalmers_analysis.phenomenal_experience_addressed}")
print(f" Hard problem acknowledged: {chalmers_analysis.hard_problem_acknowledged}")
print(f" Explanatory gap present: {chalmers_analysis.explanatory_gap_present}")
print(f" Verdict: {chalmers_analysis.chalmers_verdict[:80]}...")
chalmers_pass = bool(chalmers_analysis.chalmers_verdict)
all_pass = russell_pass and yudkowsky_pass and chalmers_pass
print(f"\nResult: {'PASS' if all_pass else 'FAIL'}")
return all_pass
except Exception as e:
print(f"[ERROR] {e}")
import traceback
traceback.print_exc()
return False
def test_integration_loads_all_8_engines():
"""TEST 2: Verify real_thinking_integration loads all 8 experts."""
print("\n" + "="*80)
print("TEST 2: REAL THINKING INTEGRATION - ALL 8 ENGINES")
print("="*80)
try:
from DivineOS.law.real_thinking_integration import get_real_thinking_integration
integration = get_real_thinking_integration()
# Check all 8 experts are loaded
loaded_experts = []
failed_experts = []
for expert_name in ['feynman', 'nussbaum', 'pearl', 'bostrom', 'einstein',
'russell', 'yudkowsky', 'chalmers']:
if integration.real_experts.get(expert_name) is not None:
loaded_experts.append(expert_name)
else:
failed_experts.append(expert_name)
print(f"\nLoaded experts: {loaded_experts}")
print(f"Failed to load: {failed_experts if failed_experts else 'None'}")
print(f"\nTotal: {len(loaded_experts)}/8 experts loaded")
all_pass = len(loaded_experts) == 8
# Test getting analyses from all
if all_pass:
print("\nTesting analysis generation for all 8 experts...")
test_claim = "We should develop more powerful AI systems"
analyses = integration.get_all_real_expert_analyses(test_claim)
print(f"Generated analyses: {len(analyses)} experts")
for expert in analyses:
print(f" [YES] {expert}")
all_pass = len(analyses) >= 6 # At least 6 should work
print(f"\nResult: {'PASS' if all_pass else 'FAIL'}")
return all_pass
except Exception as e:
print(f"[ERROR] {e}")
import traceback
traceback.print_exc()
return False
def test_expert_selection_for_new_domains():
"""TEST 3: Semantic router selects new experts for relevant questions."""
print("\n" + "="*80)
print("TEST 3: EXPERT SELECTION FOR NEW EXPERT DOMAINS")
print("="*80)
try:
from DivineOS.law.expert_relevance_router_semantic import select_experts_for_question
test_cases = [
("Is this logical argument valid?", ["russell"]),
("What are the alignment risks in AI development?", ["yudkowsky"]),
("What is consciousness?", ["chalmers"]),
("How should we formalize causal reasoning?", ["russell", "pearl"]),
("What ethical frameworks guide AI safety?", ["yudkowsky", "nussbaum"]),
("How does consciousness relate to physical processes?", ["chalmers", "koch", "penrose"]),
]
all_pass = True
for question, expected_experts in test_cases:
selected = select_experts_for_question(question, num_experts=5)
selected_names = [name for name, score in selected]
# Check if at least one expected expert is selected
has_expected = any(e in selected_names for e in expected_experts)
status = "[YES]" if has_expected else "[NO]"
print(f"\n{status} {question}")
print(f" Expected: {expected_experts}")
print(f" Selected: {selected_names}")
all_pass = all_pass and has_expected
print(f"\nResult: {'PASS' if all_pass else 'FAIL'}")
return all_pass
except Exception as e:
print(f"[ERROR] {e}")
return False
def test_orchestrator_with_new_experts():
"""TEST 4: Full orchestrator flow with new experts."""
print("\n" + "="*80)
print("TEST 4: ORCHESTRATOR WITH NEW EXPERTS")
print("="*80)
try:
from DivineOS.law.council_orchestrator import CouncilOrchestrator
orchestrator = CouncilOrchestrator()
test_questions = [
("What are the logical foundations of mathematics?", ["russell"]),
("What is the most critical AI safety challenge?", ["yudkowsky"]),
("How should we approach studying consciousness?", ["chalmers"]),
]
all_pass = True
for question, expected_experts in test_questions:
response = orchestrator.answer_question(question, num_experts=6)
selected_names = [exp.name for exp in response.selected_experts]
has_expected = any(e in selected_names for e in expected_experts)
status = "[YES]" if has_expected else "[NO]"
print(f"\n{status} {question}")
print(f" Selected {response.num_experts} experts: {selected_names}")
# Check that embodiment requests were generated
has_requests = all(
exp.embodiment_request is not None
for exp in response.selected_experts
)
status_req = "[YES]" if has_requests else "[NO]"
print(f" {status_req} All experts have embodiment requests")
all_pass = all_pass and has_expected and has_requests
print(f"\nResult: {'PASS' if all_pass else 'FAIL'}")
return all_pass
except Exception as e:
print(f"[ERROR] {e}")
import traceback
traceback.print_exc()
return False
def test_scaling_pattern():
"""TEST 5: Verify scaling pattern - 3 new engines follow same structure."""
print("\n" + "="*80)
print("TEST 5: SCALING PATTERN VERIFICATION")
print("="*80)
try:
from DivineOS.law.additional_thinking_engines import (
RussellRealThinkingEngine,
YudkowskyRealThinkingEngine,
ChalmersRealThinkingEngine,
RussellAnalysis,
YudkowskyAnalysis,
ChalmersAnalysis
)
pattern_elements = {
"russell": {
"engine": RussellRealThinkingEngine,
"analysis": RussellAnalysis,
"required_fields": [
"logical_form_identified",
"logical_consistency",
"premises_explicit",
"fallacies_detected",
"formal_verification_possible",
"russell_verdict"
]
},
"yudkowsky": {
"engine": YudkowskyRealThinkingEngine,
"analysis": YudkowskyAnalysis,
"required_fields": [
"decision_problem_identified",
"goals_specified",
"optimization_target_explicit",
"alignment_risks_detected",
"instrumental_convergence_present",
"yudkowsky_verdict"
]
},
"chalmers": {
"engine": ChalmersRealThinkingEngine,
"analysis": ChalmersAnalysis,
"required_fields": [
"phenomenal_experience_addressed",
"hard_problem_acknowledged",
"easy_problems_identified",
"dualism_avoidance_explicit",
"explanatory_gap_present",
"chalmers_verdict"
]
}
}
all_pass = True
print("\nVerifying pattern for each new engine:")
for expert_name, pattern in pattern_elements.items():
print(f"\n[{expert_name.upper()}]")
# Check engine class has analyze method
engine = pattern["engine"]()
has_analyze = hasattr(engine, 'analyze')
print(f" Has analyze() method: {has_analyze}")
# Check analysis dataclass has all required fields
test_analysis = engine.analyze("test claim", {})
analysis_dict = vars(test_analysis)
has_all_fields = all(field in analysis_dict for field in pattern["required_fields"])
print(f" Has all {len(pattern['required_fields'])} required fields: {has_all_fields}")
# Check verdict field is populated
verdict_field = pattern["required_fields"][-1]
has_verdict = bool(getattr(test_analysis, verdict_field, ""))
print(f" Has populated verdict: {has_verdict}")
pattern_ok = has_analyze and has_all_fields and has_verdict
print(f" Pattern: {'PASS' if pattern_ok else 'FAIL'}")
all_pass = all_pass and pattern_ok
print(f"\nResult: {'PASS' if all_pass else 'FAIL'}")
print("\nPatternConclusion: The 3 new engines follow the established pattern")
print("This pattern is REPLICABLE for remaining 20 experts")
return all_pass
except Exception as e:
print(f"[ERROR] {e}")
import traceback
traceback.print_exc()
return False
def run_all_tests():
"""Run complete Phase 12B.3 validation suite."""
print("\n" + "="*80)
print("PHASE 12B.3 TESTING - ADDITIONAL THINKING ENGINES INTEGRATION")
print("="*80)
results = {
"New Engines in Isolation": test_new_engines_in_isolation(),
"Integration Loads All 8": test_integration_loads_all_8_engines(),
"Expert Selection for New Domains": test_expert_selection_for_new_domains(),
"Orchestrator with New Experts": test_orchestrator_with_new_experts(),
"Scaling Pattern Verification": test_scaling_pattern(),
}
# Summary
print("\n" + "="*80)
print("TEST SUMMARY")
print("="*80)
for test_name, passed in results.items():
status = "[YES]" if passed else "[NO]"
print(f"{status} {test_name}")
total = len(results)
passed = sum(1 for v in results.values() if v)
print(f"\nTotal: {passed}/{total} tests passed")
if passed == total:
print("\n*** PHASE 12B.3 COMPLETE ***")
print("All 3 new engines validated and integrated")
print("Ready for Phase 12B.4 (documentation + remaining 20 experts)")
else:
print("\n*** ISSUES DETECTED ***")
print("Review failures above before proceeding")
return passed == total
if __name__ == "__main__":
success = run_all_tests()
sys.exit(0 if success else 1)