| |
| import sys |
| import os |
| import json |
|
|
| |
| sys.path.append(os.getcwd()) |
|
|
| from proof_graph import ProofGraph, ProofStep |
| from pedagogical_builder import build_pedagogical_response |
| import curriculum_engine |
|
|
| def test_deterministic_merge(): |
| print("🧪 Testing Deterministic Merge (V4.1)...") |
| |
| |
| steps = [ |
| ProofStep(1, "x + 2 = 5", "שיוויון בסיסי"), |
| ProofStep(2, "x = 3", "בידוד הנעלם") |
| ] |
| graph = ProofGraph(steps) |
| |
| |
| llm_output = { |
| "steps_explanations": [ |
| {"step_id": 1, "pedagogical_explanation": "נתחיל מהמשוואה"}, |
| {"step_id": 2, "pedagogical_explanation": "נחסר 2 משני האגפים"} |
| ], |
| "teacher_summary": "זה סיכום המורה" |
| } |
| |
| |
| response = build_pedagogical_response("GENERAL", llm_output, {}, proof_graph=graph) |
| |
| |
| ui_steps = response["sections"][0]["steps"] |
| if ui_steps[0]["block_math"] == "x + 2 = 5" and ui_steps[1]["block_math"] == "x = 3": |
| print("✅ Success: Math preserved exactly from ProofGraph.") |
| else: |
| print(f"❌ Failure: Math mismatch. Found {ui_steps[0]['block_math']} and {ui_steps[1]['block_math']}") |
|
|
| def test_curriculum_ontology_enforcement(): |
| print("\n🧪 Testing Curriculum Ontology Enforcement (V4.1)...") |
| |
| |
| rules = curriculum_engine.get_allowed_math_operators("י׳", level="3") |
| grade7_rules = curriculum_engine.get_allowed_math_operators("ז׳", level="4") |
| |
| |
| illegal_steps = [ |
| ProofStep(1, "x + y = 10", "משוואה ראשונה"), |
| ProofStep(2, "x - y = 2", "משוואה שנייה"), |
| ProofStep(3, "2x = 12", "חיבור משוואות", operator_used="SYSTEM_OF_EQUATIONS") |
| ] |
| illegal_graph = ProofGraph(illegal_steps) |
| |
| from proof_graph import validate_pedagogical_legality |
| is_legal, reason = validate_pedagogical_legality(illegal_graph, grade7_rules) |
| |
| if not is_legal and "SYSTEM_OF_EQUATIONS" in reason or "מערכת משוואות" in reason: |
| print("✅ Success: Ontology-based guard REJECTED illegal operator for Grade 7.") |
| else: |
| print(f"❌ Failure: Guard allowed illegal operator or gave wrong reason: {reason}") |
|
|
| if __name__ == "__main__": |
| test_deterministic_merge() |
| test_curriculum_ontology_enforcement() |
| print("\n✨ V4.1 Truth Authority Logic Verification PASSED!") |
|
|