diff --git a/tasks.py b/tasks.py index afc5f228..73d36814 100644 --- a/tasks.py +++ b/tasks.py @@ -2126,3 +2126,39 @@ def cross_review_prs(): continue return {"reviews": len(results), "details": results} + +@huey.periodic_task(crontab(minute="*/10")) +def nexus_bridge_tick(): + """Force Multiplier 16: The Nexus Bridge (Sovereign Health Feed). + + Generates a JSON feed for the Nexus Watchdog to visualize fleet health. + """ + gitea = get_gitea_client() + repos = ["Timmy_Foundation/timmy-config", "Timmy_Foundation/timmy-home", "Timmy_Foundation/the-nexus"] + + health_data = { + "timestamp": datetime.now(timezone.utc).isoformat(), + "fleet_status": "nominal", + "active_agents": ["gemini", "claude", "codex"], + "backlog_summary": {}, + "recent_audits": [] + } + + # 1. Backlog Summary + for repo in repos: + issues = gitea.get_open_issues(repo) + health_data["backlog_summary"][repo] = len(issues) + + # 2. Recent Audits (last 5) + audit_file = TIMMY_HOME / "logs" / "audit.jsonl" + if audit_file.exists(): + with open(audit_file, "r") as f: + lines = f.readlines() + health_data["recent_audits"] = [json.loads(l) for l in lines[-5:]] + + # 3. Write to Nexus Feed + feed_path = TIMMY_HOME / "nexus" / "fleet_health.json" + feed_path.parent.mkdir(parents=True, exist_ok=True) + feed_path.write_text(json.dumps(health_data, indent=2)) + + audit_log("nexus_feed_updated", "system", {"repo_count": len(repos)}, confidence="High")