Some checks failed
- Integrate GPU scoring inline into reasoning/multi_path.py (auto-uses GPU when available) - Integrate GPU deduplication into multi_agent/consensus_engine.py - Add semantic_search() method to memory/semantic_graph.py with GPU acceleration - Integrate GPU training into self_improvement/training.py AutoTrainer - Fix all 758 ruff lint issues (whitespace, import sorting, unused imports, ambiguous vars, undefined names) - Fix all 40 mypy type errors across the codebase (no-any-return, union-attr, arg-type, etc.) - Fix deprecated ruff config keys (select/ignore -> [tool.ruff.lint]) - Add .dockerignore to exclude .venv/, tests/, docs/ from Docker builds - Add type hints and docstrings to verification/outcome.py - Fix E402 import ordering in witness_agent.py - Fix F821 undefined names in vector_pgvector.py and native.py - Fix E741 ambiguous variable names in reflective.py and recommender.py All 276 tests pass. 0 ruff errors. 0 mypy errors. Co-Authored-By: Nakamoto, S <defi@defi-oracle.io>
30 lines
1.3 KiB
Python
30 lines
1.3 KiB
Python
"""Structured audit log for AGI."""
|
|
import uuid
|
|
|
|
from fusionagi.schemas.audit import AuditEntry
|
|
|
|
|
|
class AuditLog:
|
|
def __init__(self, max_entries=100000):
|
|
self._entries = []
|
|
self._max_entries = max_entries
|
|
self._by_task = {}
|
|
self._by_type = {}
|
|
def append(self, event_type, actor, action="", task_id=None, payload=None, outcome=""):
|
|
entry_id = str(uuid.uuid4())
|
|
entry = AuditEntry(entry_id=entry_id, event_type=event_type, actor=actor, task_id=task_id, action=action, payload=payload or {}, outcome=outcome)
|
|
if len(self._entries) >= self._max_entries:
|
|
self._entries.pop(0)
|
|
idx = len(self._entries)
|
|
self._entries.append(entry)
|
|
if entry.task_id:
|
|
self._by_task.setdefault(entry.task_id, []).append(idx)
|
|
self._by_type.setdefault(entry.event_type.value, []).append(idx)
|
|
return entry_id
|
|
def get_by_task(self, task_id, limit=100):
|
|
indices = self._by_task.get(task_id, [])[-limit:]
|
|
return [self._entries[i] for i in indices if i < len(self._entries)]
|
|
def get_by_type(self, event_type, limit=100):
|
|
indices = self._by_type.get(event_type.value, [])[-limit:]
|
|
return [self._entries[i] for i in indices if i < len(self._entries)]
|