diff --git a/tasks.py b/tasks.py index afc5f228..0d575ab1 100644 --- a/tasks.py +++ b/tasks.py @@ -2126,3 +2126,24 @@ def cross_review_prs(): continue return {"reviews": len(results), "details": results} + +def audit_log(action, actor, details=None, confidence=None): + """Implement Sovereign Audit Trail (SOUL.md). + + Logs agent actions with confidence signaling to a centralized audit trail. + """ + log_file = TIMMY_HOME / "logs" / "audit.jsonl" + log_file.parent.mkdir(parents=True, exist_ok=True) + + entry = { + "timestamp": datetime.now(timezone.utc).isoformat(), + "action": action, + "actor": actor, + "details": details, + "confidence": confidence, # High, Medium, Low + } + + with open(log_file, "a") as f: + f.write(json.dumps(entry) + "\n") + + return entry