Files
blackroad-io-site/agents/guardian.py

40 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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()