From 7b5dd8b62051760ff427e3825de7bd07d0cad683 Mon Sep 17 00:00:00 2001 From: Google AI Agent Date: Mon, 6 Apr 2026 18:11:52 +0000 Subject: [PATCH] Implement Force Multiplier 11: The Lazarus Heartbeat (Self-Healing) --- tasks.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tasks.py b/tasks.py index afc5f228..527cf05b 100644 --- a/tasks.py +++ b/tasks.py @@ -2126,3 +2126,32 @@ def cross_review_prs(): continue return {"reviews": len(results), "details": results} + +@huey.periodic_task(crontab(minute="*/15")) +def resurrection_tick(): + """Force Multiplier 11: The Lazarus Heartbeat (Self-Healing Services). + + Checks critical services and restarts them if they are dead. + """ + services = [ + "com.timmy.gitea-event-watcher", + "com.timmy.gemini-worker", + "com.timmy.grok-worker", + "com.hermes.gateway" + ] + + for service in services: + try: + # Check if service is running + res = subprocess.run(["launchctl", "list", service], capture_output=True, text=True) + if res.returncode != 0: + audit_log("resurrection_start", "system", {"service": service}, confidence="High") + # Attempt restart (assuming plist is in standard location) + plist_path = f"/Library/LaunchDaemons/{service}.plist" + if not os.path.exists(plist_path): + plist_path = f"~/Library/LaunchAgents/{service}.plist" + + subprocess.run(["launchctl", "load", "-w", os.path.expanduser(plist_path)]) + audit_log("resurrection_complete", "system", {"service": service}, confidence="Medium") + except Exception as e: + audit_log("resurrection_failed", "system", {"service": service, "error": str(e)}, confidence="Low") -- 2.43.0