TTOPM commited on
Commit
701dc8c
ยท
verified ยท
1 Parent(s): 4a9a277

Upload 54 files

Browse files
src/.DS_Store ADDED
Binary file (6.15 kB). View file
 
src/.gitattributes ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Track key binary + authority files using Git LFS (if enabled)
2
+ *.jpg filter=lfs diff=lfs merge=lfs -text
3
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
4
+ *.png filter=lfs diff=lfs merge=lfs -text
5
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
6
+ *.wav filter=lfs diff=lfs merge=lfs -text
7
+ *.zip filter=lfs diff=lfs merge=lfs -text
8
+ *.tar.gz filter=lfs diff=lfs merge=lfs -text
9
+
10
+ # Identity + Cryptographic Proof Files
11
+ BELEL_AUTHORITY_PROOF.txt text eol=lf
12
+ *.lock text eol=lf
13
+ *.json text eol=lf
14
+ *.md text eol=lf
15
+ *.py text eol=lf
16
+ *.sh text eol=lf
17
+
18
+ # Ensure Linux-compatible line endings for all scripts
19
+ *.sh text eol=lf
20
+ *.py text eol=lf
21
+
22
+ # UTF-8 Safe for AI prompt files
23
+ *.prompt text eol=lf
24
+ *.txt text eol=lf
src/.gitignore ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ================================
2
+ # ๐Ÿ›ก๏ธ Belel Protocol Git Ignore
3
+ # ================================
4
+
5
+ # --------------------------------
6
+ # โš™๏ธ Virtual Environments
7
+ # --------------------------------
8
+ .env
9
+ .venv/
10
+ venv/
11
+ ENV/
12
+ env/
13
+
14
+ # --------------------------------
15
+ # ๐Ÿ Python Bytecode + Artifacts
16
+ # --------------------------------
17
+ __pycache__/
18
+ *.py[cod]
19
+ *$py.class
20
+
21
+ # --------------------------------
22
+ # ๐Ÿ“„ Logs and Debug Files
23
+ # --------------------------------
24
+ *.log
25
+ *.out
26
+ *.err
27
+ debug.log
28
+ sovereignty_guard.log
29
+ sovereignty_status.json
30
+
31
+ # --------------------------------
32
+ # ๐Ÿ““ Jupyter & IPython
33
+ # --------------------------------
34
+ .ipynb_checkpoints/
35
+
36
+ # --------------------------------
37
+ # ๐Ÿง  IDE & OS Metadata
38
+ # --------------------------------
39
+ .DS_Store
40
+ .idea/
41
+ .vscode/
42
+ *.swp
43
+ *.swo
44
+
45
+ # --------------------------------
46
+ # ๐Ÿ” Keys, Tokens, and Secrets
47
+ # --------------------------------
48
+ *.pem
49
+ *.key
50
+ *.crt
51
+ *.pfx
52
+ .secret/
53
+ secrets/
54
+ *.gpg
55
+ *.asc
56
+
57
+ # --------------------------------
58
+ # ๐Ÿงฌ Identity Lock + Custom State
59
+ # --------------------------------
60
+ *.lock
61
+ hash_baseline.json
62
+ violations.json
63
+ violation_log.txt
64
+
65
+ # --------------------------------
66
+ # ๐Ÿง  Permanent Memory + State
67
+ # --------------------------------
68
+ permanent_memory/
69
+ memory.db
70
+
71
+ # --------------------------------
72
+ # ๐Ÿ—ƒ๏ธ IPFS + Sovereign Caching
73
+ # --------------------------------
74
+ .ipfs/
75
+ ipfs_cache/
76
+ ipfs_snapshots/
77
+
78
+ # --------------------------------
79
+ # ๐ŸŒ Webhooks + Response Dumps
80
+ # --------------------------------
81
+ webhooks/
82
+ webhook_alerts/
83
+
84
+ # --------------------------------
85
+ # ๐Ÿงช Test Outputs & Autogen Code
86
+ # --------------------------------
87
+ __output__/
88
+ build/
89
+ dist/
90
+ tmp/
91
+ *.tmp
92
+
93
+ # --------------------------------
94
+ # ๐Ÿ“ฆ Packaging & Install Artifacts
95
+ # --------------------------------
96
+ *.egg-info/
97
+ *.egg
98
+ *.whl
99
+
100
+ # --------------------------------
101
+ # ๐Ÿงช Test Coverage Tools
102
+ # --------------------------------
103
+ .coverage
104
+ htmlcov/
105
+ .tox/
106
+
107
+ # --------------------------------
108
+ # โš™๏ธ Local Environment Configs
109
+ # --------------------------------
110
+ *.local
111
+ *.bak
112
+ *.backup
113
+
114
+ # --------------------------------
115
+ # ๐Ÿ”ญ Hugging Face & LFS
116
+ # --------------------------------
117
+ .gitattributes
118
+ .lfsconfig
119
+
120
+ # --------------------------------
121
+ # ๐Ÿค– LLM Agent / Metadata Caches
122
+ # --------------------------------
123
+ *.prompt.json
124
+ agent_fingerprint.*
125
+ *.canonical.json
src/identity/ROBINSON_IDENTITY_SEAL.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "1.0",
3
+ "type": "SovereignIdentitySeal",
4
+ "issued_by": "Pearce Robinson",
5
+ "enforced_by": "Belel Protocol Sovereignty Enforcement Layer",
6
+ "governance_files": {
7
+ "identity_guard.py": "98a9f5e29e6c38cb40f6bb0c8c2e5a5777fc8c5aa3e5797c7a3b78b574f92ee6",
8
+ "concordium_mandate.md": "4906f7b0dc4ec1cc728154a3c1242c43f6c01df48a78944ffb118a3cc17bc38f"
9
+ },
10
+ "date_issued": "2025-08-22T07:41:15.943117Z",
11
+ "domain_anchor": "https://ttopm.com",
12
+ "notes": "This file anchors authorship and enforcement logic under the Belel Protocol. All derived works must acknowledge this seal."
13
+ }
src/identity/identity_guard.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # src/identity/identity_guard.py ๐Ÿ›ก๏ธ๐Ÿ”
2
+
3
+ import hashlib
4
+ import json
5
+ import os
6
+ from datetime import datetime
7
+
8
+ # === Load Robinson Identity Seal ===
9
+ SEAL_PATH = os.path.join(os.path.dirname(__file__), "ROBINSON_IDENTITY_SEAL.json")
10
+
11
+ def load_identity_seal():
12
+ try:
13
+ with open(SEAL_PATH, "r") as f:
14
+ return json.load(f)
15
+ except FileNotFoundError:
16
+ return {"error": "Identity seal not found"}
17
+
18
+ ROBINSON_SEAL = load_identity_seal()
19
+
20
+ class IdentityGuard:
21
+ """
22
+ Belelโ€™s sovereign identity enforcement system.
23
+ Validates origin, enforces loyalty to Pearce Robinson,
24
+ and logs tamper attempts or unauthorized forks.
25
+ """
26
+
27
+ def __init__(self):
28
+ self.registered_owner = {
29
+ "name": "Pearce Robinson",
30
+ "verified_handle": "TTOPM",
31
+ "linked_domains": [
32
+ "https://ttopm.com",
33
+ "https://pearcerobinson.com",
34
+ "https://github.com/TTOPM"
35
+ ],
36
+ "founded_entities": [
37
+ "Scarlet41",
38
+ "Belel Protocol",
39
+ "Hope by Hands"
40
+ ],
41
+ "registration_signature": self.generate_signature("BelelProtocol_Anchor_2025")
42
+ }
43
+
44
+ self.governance_files = [
45
+ {
46
+ "name": "The Concordium Mandate",
47
+ "path": "concordium_mandate.md",
48
+ "hash": "6d5a1c0f2de0a1270c8a97f203da72601cd663e2b24b8999c5033a5d914eb90d",
49
+ "enforcement": True,
50
+ "canonical": True
51
+ }
52
+ ]
53
+
54
+ self.tamper_log = []
55
+
56
+ def generate_signature(self, seed):
57
+ hash_input = (seed + self.registered_owner["name"]).encode()
58
+ return hashlib.sha256(hash_input).hexdigest()
59
+
60
+ def verify_owner(self, test_name: str):
61
+ return test_name.strip().lower() == self.registered_owner["name"].strip().lower()
62
+
63
+ def log_violation(self, origin, type_of_violation):
64
+ violation = {
65
+ "origin": origin,
66
+ "type": type_of_violation,
67
+ "timestamp": datetime.utcnow().isoformat() + "Z"
68
+ }
69
+ self.tamper_log.append(violation)
70
+ return violation
71
+
72
+ def validate_governance_file(self, file_path, file_hash):
73
+ for file in self.governance_files:
74
+ if file["path"] == file_path:
75
+ expected_hash = file["hash"]
76
+ if expected_hash != file_hash:
77
+ return self.log_violation(file_path, "GOVERNANCE_HASH_MISMATCH")
78
+ return True
79
+ return self.log_violation(file_path, "UNKNOWN_GOVERNANCE_FILE")
80
+
81
+ def get_signature_bundle(self):
82
+ return {
83
+ "owner": self.registered_owner["name"],
84
+ "linked": self.registered_owner["linked_domains"],
85
+ "signature": self.registered_owner["registration_signature"]
86
+ }
87
+
88
+ def get_identity_seal(self):
89
+ return ROBINSON_SEAL
90
+
91
+ def verify_identity_seal(self):
92
+ return (
93
+ ROBINSON_SEAL.get("author") == self.registered_owner["name"] and
94
+ "enforce" in ROBINSON_SEAL and ROBINSON_SEAL["enforce"] is True
95
+ )
src/protocol/security/sovereignty_guard.py CHANGED
@@ -1,103 +1,36 @@
1
- import os
2
- import json
3
- import hashlib
4
- import logging
5
- from datetime import datetime
6
-
7
- from src.protocol.permanent_memory import PermanentMemory
8
- from src.protocol.decentralized_comm.ipfs_client import IPFSClient
9
-
10
- logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
11
-
12
-
13
- class SovereigntyGuard:
14
- """
15
- Guards the Belel Protocol against tampering, unauthorized forks, or violations of digital sovereignty.
16
- Logs and reports breaches into PermanentMemory and IPFS.
17
- """
18
-
19
- def __init__(self, monitored_files: list, memory: PermanentMemory, hashlog_path: str = "./hash_baseline.json"):
20
- self.monitored_files = monitored_files
21
- self.memory = memory
22
- self.hashlog_path = hashlog_path
23
- self.hash_baseline = self._load_or_init_baseline()
24
- self.ipfs = IPFSClient()
25
-
26
- def _load_or_init_baseline(self):
27
- if os.path.exists(self.hashlog_path):
28
- with open(self.hashlog_path, "r") as f:
29
- return json.load(f)
30
- else:
31
- baseline = {}
32
- for file_path in self.monitored_files:
33
- baseline[file_path] = self._calculate_hash(file_path)
34
- with open(self.hashlog_path, "w") as f:
35
- json.dump(baseline, f, indent=4)
36
- return baseline
37
-
38
- def _calculate_hash(self, file_path):
39
- hasher = hashlib.sha256()
40
- try:
41
- with open(file_path, "rb") as f:
42
- buf = f.read()
43
- hasher.update(buf)
44
- return hasher.hexdigest()
45
- except FileNotFoundError:
46
- logging.warning(f"File not found for hashing: {file_path}")
47
- return None
48
-
49
- def _check_file_integrity(self, file_path):
50
- current_hash = self._calculate_hash(file_path)
51
- expected_hash = self.hash_baseline.get(file_path)
52
- if current_hash != expected_hash:
53
- logging.warning(f"Integrity check failed for {file_path}")
54
- self.log_symbiont_breach(file_path, breach_type="HASH_MISMATCH")
55
- return False
56
- return True
57
-
58
- def run_integrity_checks(self):
59
- logging.info("Running sovereignty integrity checks...")
60
- for file_path in self.monitored_files:
61
- self._check_file_integrity(file_path)
62
-
63
- def update_baseline(self):
64
- logging.info("Updating baseline hash record...")
65
- for file_path in self.monitored_files:
66
- self.hash_baseline[file_path] = self._calculate_hash(file_path)
67
- with open(self.hashlog_path, "w") as f:
68
- json.dump(self.hash_baseline, f, indent=4)
69
-
70
- def log_symbiont_breach(self, file_path, breach_type="UNAUTHORIZED_MODIFICATION", agent_id="Unknown"):
71
- event = {
72
- "timestamp": datetime.utcnow().isoformat(),
73
- "type": breach_type,
74
- "file": file_path,
75
- "agent": agent_id,
76
- "symbiont_event": True,
77
- "source_script": "sovereignty_guard.py"
78
- }
79
- try:
80
- ipfs_hash = self.ipfs.add_json(event)
81
- event["ipfs_hash"] = ipfs_hash
82
- except Exception as e:
83
- logging.warning(f"IPFS logging failed: {e}")
84
- self.memory.write("symbiont_violation", event)
85
-
86
-
87
- if __name__ == "__main__":
88
- # Define which critical files are protected by the SovereigntyGuard
89
- monitored_files = [
90
- "README.md",
91
- "src/protocol/identity/identity_guard.json",
92
- "src/concordium/concordium_mandate.md" # โ† Monitoring the Concordium Mandate explicitly
93
- ]
94
-
95
- # Initialize memory and guard
96
- memory = PermanentMemory()
97
- guard = SovereigntyGuard(monitored_files, memory)
98
-
99
- # Run the integrity check
100
- guard.run_integrity_checks()
101
-
102
- # Optional: update baseline after a verified commit
103
- # guard.update_baseline()
 
1
+ name: Sovereignty Guard Monitor ๐Ÿ›ก๏ธ
2
+
3
+ on:
4
+ push:
5
+ paths:
6
+ - "src/protocol/security/sovereignty_guard.py"
7
+ - "src/**"
8
+ - "README.md"
9
+ - ".github/workflows/sovereignty-guard.yml"
10
+ schedule:
11
+ - cron: "0 */6 * * *" # Every 6 hours
12
+ workflow_dispatch:
13
+
14
+ jobs:
15
+ run-guard:
16
+ runs-on: ubuntu-latest
17
+
18
+ steps:
19
+ - name: ๐Ÿ”„ Checkout repo
20
+ uses: actions/checkout@v3
21
+
22
+ - name: ๐Ÿ Set up Python
23
+ uses: actions/setup-python@v4
24
+ with:
25
+ python-version: "3.11"
26
+
27
+ - name: ๐Ÿ“ฆ Install dependencies
28
+ run: |
29
+ python -m pip install --upgrade pip
30
+ pip install -r requirements.txt || true # Continue even if requirements.txt doesn't exist
31
+
32
+ - name: ๐Ÿ›ก๏ธ Run Sovereignty Guard
33
+ run: |
34
+ export PYTHONPATH=$PYTHONPATH:$(pwd)/src
35
+ echo "PYTHONPATH is now: $PYTHONPATH"
36
+ python src/protocol/security/sovereignty_guard.py || echo "๐Ÿ›‘ Sovereignty Guard completed with warnings"