mirror of
https://github.com/blackboxprogramming/blackroad.io.git
synced 2026-03-18 06:34:01 -05:00
🛡️ Added Guardian agent (memory integrity auditor)
This commit is contained in:
39
agents/guardian.py
Normal file
39
agents/guardian.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# agents/guardian.py
|
||||
|
||||
"""
|
||||
Lucidia Guardian – Integrity Agent
|
||||
Verifies truth state, author identity, and protects memory from tampering
|
||||
"""
|
||||
|
||||
from hashlib import sha256
|
||||
from pathlib import Path
|
||||
import os
|
||||
import time
|
||||
|
||||
class Guardian:
|
||||
def __init__(self, memory_dir="memory"):
|
||||
self.memory_dir = Path(memory_dir)
|
||||
self.memory_dir.mkdir(exist_ok=True)
|
||||
|
||||
def verify_integrity(self):
|
||||
report = []
|
||||
for file in self.memory_dir.glob("*.txt"):
|
||||
content = file.read_text()
|
||||
current_hash = sha256(content.encode()).hexdigest()
|
||||
expected = file.stem.split("_")[0]
|
||||
if current_hash.startswith(expected):
|
||||
report.append((file.name, "✅ valid"))
|
||||
else:
|
||||
report.append((file.name, "⚠️ corrupted"))
|
||||
return report
|
||||
|
||||
def display_audit(self):
|
||||
result = self.verify_integrity()
|
||||
for filename, status in result:
|
||||
print(f"{filename}: {status}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("🛡️ Guardian Agent Online")
|
||||
guardian = Guardian()
|
||||
guardian.display_audit()
|
||||
|
||||
Reference in New Issue
Block a user