onenoly11 commited on
Commit
1208e0b
Β·
verified Β·
1 Parent(s): 7985780

Create validate_ethics.py

Browse files
Files changed (1) hide show
  1. validate_ethics.py +65 -0
validate_ethics.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ IdeaForge Studio - Ethics Manifest Validator
4
+ Ensures project compliance with PiForge ethical standards
5
+ """
6
+
7
+ import json
8
+ import sys
9
+
10
+ def validate_ethics_manifest():
11
+ """Validate the PiEthics manifest and project consistency."""
12
+ try:
13
+ # Load ethics manifest
14
+ with open("piethics.json", "r") as f:
15
+ ethics = json.load(f)
16
+
17
+ # Load project metadata
18
+ with open("piforge.json", "r") as f:
19
+ forge = json.load(f)
20
+
21
+ # Validation checks
22
+ errors = []
23
+
24
+ # Project name consistency
25
+ if forge["project_name"] != ethics["project_name"]:
26
+ errors.append("❌ Project name mismatch between manifests")
27
+
28
+ # Ethics file reference
29
+ if forge.get("ethical_cert") != "piethics.json":
30
+ errors.append("❌ Missing or incorrect ethics file reference")
31
+
32
+ # Required principles
33
+ required_principles = ["Transparency", "User Autonomy", "Privacy by Design"]
34
+ for principle in required_principles:
35
+ if principle not in ethics.get("core_principles", []):
36
+ errors.append(f"❌ Missing required principle: {principle}")
37
+
38
+ # Version consistency
39
+ if forge["version"] != ethics["version"]:
40
+ errors.append("❌ Version mismatch between manifests")
41
+
42
+ if errors:
43
+ print("Ethics validation failed:")
44
+ for error in errors:
45
+ print(f" {error}")
46
+ return False
47
+ else:
48
+ print("βœ… PiEthics Manifest Validation PASSED")
49
+ print(f" Project: {ethics['project_name']} v{ethics['version']}")
50
+ print(f" Principles: {', '.join(ethics['core_principles'][:3])}...")
51
+ return True
52
+
53
+ except FileNotFoundError as e:
54
+ print(f"❌ Missing required file: {e}")
55
+ return False
56
+ except json.JSONDecodeError as e:
57
+ print(f"❌ Invalid JSON in manifest: {e}")
58
+ return False
59
+ except Exception as e:
60
+ print(f"❌ Unexpected error during validation: {e}")
61
+ return False
62
+
63
+ if __name__ == "__main__":
64
+ success = validate_ethics_manifest()
65
+ sys.exit(0 if success else 1)