|
|
|
|
|
""" |
|
|
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: |
|
|
|
|
|
with open("piethics.json", "r") as f: |
|
|
ethics = json.load(f) |
|
|
|
|
|
|
|
|
with open("piforge.json", "r") as f: |
|
|
forge = json.load(f) |
|
|
|
|
|
|
|
|
errors = [] |
|
|
|
|
|
|
|
|
if forge["project_name"] != ethics["project_name"]: |
|
|
errors.append("β Project name mismatch between manifests") |
|
|
|
|
|
|
|
|
if forge.get("ethical_cert") != "piethics.json": |
|
|
errors.append("β Missing or incorrect ethics file reference") |
|
|
|
|
|
|
|
|
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}") |
|
|
|
|
|
|
|
|
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) |