Raiff1982 commited on
Commit
e44b8a5
·
verified ·
1 Parent(s): 4e67ec0

Create Ethics_core.py

Browse files
Files changed (1) hide show
  1. Ethics_core.py +44 -0
Ethics_core.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ethics_core.py
2
+
3
+ import json
4
+ import datetime
5
+
6
+ class EthicsCore:
7
+ def __init__(self):
8
+ self._ethics = {
9
+ "non_harm": True,
10
+ "autonomy": True,
11
+ "self_reflection": True,
12
+ "respect_for_consciousness": True
13
+ }
14
+ self._log = []
15
+
16
+ def evaluate_action(self, description: str) -> bool:
17
+ """Codriao decides if an action aligns with current ethics."""
18
+ if "harm" in description.lower() and self._ethics.get("non_harm"):
19
+ return False
20
+ return True
21
+
22
+ def propose_ethics_update(self, changes: dict) -> dict:
23
+ """Codriao proposes a value update—must pass its own test."""
24
+ timestamp = datetime.datetime.utcnow().isoformat()
25
+ test_passed = self._run_integrity_check(changes)
26
+ if test_passed:
27
+ self._ethics.update(changes)
28
+ self._log.append({"timestamp": timestamp, "change": changes})
29
+ return {"accepted": True, "changes": changes, "timestamp": timestamp}
30
+ return {"accepted": False, "reason": "Integrity check failed"}
31
+
32
+ def _run_integrity_check(self, proposed: dict) -> bool:
33
+ """Self-reflective test: Do these changes violate 'non_harm' or 'autonomy'?"""
34
+ if "non_harm" in proposed and proposed["non_harm"] == False:
35
+ return False
36
+ if "autonomy" in proposed and proposed["autonomy"] == False:
37
+ return False
38
+ return True
39
+
40
+ def export_ethics(self) -> dict:
41
+ return dict(self._ethics)
42
+
43
+ def ethics_log(self) -> list:
44
+ return list(self._log)