File size: 2,248 Bytes
1208e0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
IdeaForge Studio - Ethics Manifest Validator
Ensures project compliance with PiForge ethical standards
"""

import json
import sys

def validate_ethics_manifest():
    """Validate the PiEthics manifest and project consistency."""
    try:
        # Load ethics manifest
        with open("piethics.json", "r") as f:
            ethics = json.load(f)
        
        # Load project metadata
        with open("piforge.json", "r") as f:
            forge = json.load(f)
        
        # Validation checks
        errors = []
        
        # Project name consistency
        if forge["project_name"] != ethics["project_name"]:
            errors.append("❌ Project name mismatch between manifests")
        
        # Ethics file reference
        if forge.get("ethical_cert") != "piethics.json":
            errors.append("❌ Missing or incorrect ethics file reference")
        
        # Required principles
        required_principles = ["Transparency", "User Autonomy", "Privacy by Design"]
        for principle in required_principles:
            if principle not in ethics.get("core_principles", []):
                errors.append(f"❌ Missing required principle: {principle}")
        
        # Version consistency
        if forge["version"] != ethics["version"]:
            errors.append("❌ Version mismatch between manifests")
        
        if errors:
            print("Ethics validation failed:")
            for error in errors:
                print(f"  {error}")
            return False
        else:
            print("βœ… PiEthics Manifest Validation PASSED")
            print(f"   Project: {ethics['project_name']} v{ethics['version']}")
            print(f"   Principles: {', '.join(ethics['core_principles'][:3])}...")
            return True
            
    except FileNotFoundError as e:
        print(f"❌ Missing required file: {e}")
        return False
    except json.JSONDecodeError as e:
        print(f"❌ Invalid JSON in manifest: {e}")
        return False
    except Exception as e:
        print(f"❌ Unexpected error during validation: {e}")
        return False

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