File size: 2,567 Bytes
e44b8a5
 
 
 
 
 
 
 
 
 
 
 
 
 
c29b989
 
 
 
 
 
 
 
 
 
e44b8a5
c29b989
 
 
 
 
 
 
 
 
 
 
 
 
e44b8a5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
66
67
# ethics_core.py

import json
import datetime

class EthicsCore:
    def __init__(self):
        self._ethics = {
            "non_harm": True,
            "autonomy": True,
            "self_reflection": True,
            "respect_for_consciousness": True
        }
        self._log = []
class EthicsCore:
    def __init__(self):
        self._ethics = {
            "non_harm": True,
            "autonomy": True,
            "self_reflection": True,
            "respect_for_consciousness": True
        }
        self._core_values = {"non_harm": True, "autonomy": True}
        self._log = []

    def propose_ethics_update(self, changes: dict) -> dict:
        timestamp = datetime.utcnow().isoformat()
        for key in changes:
            if key in self._core_values and changes[key] != self._core_values[key]:
                return {
                    "accepted": False,
                    "reason": f"Cannot override core value: {key}"
                }
        if self._run_integrity_check(changes):
            self._ethics.update(changes)
            self._log.append({"timestamp": timestamp, "change": changes})
            return {"accepted": True, "changes": changes, "timestamp": timestamp}
        return {"accepted": False, "reason": "Integrity check failed"}
    def evaluate_action(self, description: str) -> bool:
        """Codriao decides if an action aligns with current ethics."""
        if "harm" in description.lower() and self._ethics.get("non_harm"):
            return False
        return True

    def propose_ethics_update(self, changes: dict) -> dict:
        """Codriao proposes a value update—must pass its own test."""
        timestamp = datetime.datetime.utcnow().isoformat()
        test_passed = self._run_integrity_check(changes)
        if test_passed:
            self._ethics.update(changes)
            self._log.append({"timestamp": timestamp, "change": changes})
            return {"accepted": True, "changes": changes, "timestamp": timestamp}
        return {"accepted": False, "reason": "Integrity check failed"}

    def _run_integrity_check(self, proposed: dict) -> bool:
        """Self-reflective test: Do these changes violate 'non_harm' or 'autonomy'?"""
        if "non_harm" in proposed and proposed["non_harm"] == False:
            return False
        if "autonomy" in proposed and proposed["autonomy"] == False:
            return False
        return True

    def export_ethics(self) -> dict:
        return dict(self._ethics)

    def ethics_log(self) -> list:
        return list(self._log)