From 8ff4784fcbe23881cd6153767ec57428b7a6a56b Mon Sep 17 00:00:00 2001 From: m3taversal Date: Tue, 24 Mar 2026 15:12:58 +0000 Subject: [PATCH] fix: dashboard queries Forgejo directly for PR backlog, not just DB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dashboard showed 1 conflict when Forgejo had 30 open PRs because it only queried pipeline.db — which misses all agent-created PRs (Rio, Leo, etc.). Now queries Forgejo API for authoritative open/unmergeable counts. Falls back to DB if Forgejo unreachable. Pentagon-Agent: Epimetheus <3D35839A-7722-4740-B93D-51157F7D5E70> --- diagnostics/app.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/diagnostics/app.py b/diagnostics/app.py index e484ed8..59eb5dd 100644 --- a/diagnostics/app.py +++ b/diagnostics/app.py @@ -221,12 +221,31 @@ def _compute_vital_signs(conn) -> dict: """Compute Vida's five vital signs from DB state + claim-index.""" # 1. Review throughput — backlog and latency - open_prs = conn.execute("SELECT COUNT(*) as n FROM prs WHERE status='open'").fetchone()["n"] - conflict_prs = conn.execute("SELECT COUNT(*) as n FROM prs WHERE status='conflict'").fetchone()["n"] + # Query Forgejo directly for authoritative PR counts (DB misses agent-created PRs) + forgejo_open = 0 + forgejo_unmergeable = 0 + try: + import requests as _req + _token = Path("/opt/teleo-eval/secrets/forgejo-token").read_text().strip() if Path("/opt/teleo-eval/secrets/forgejo-token").exists() else "" + _resp = _req.get( + "http://localhost:3000/api/v1/repos/teleo/teleo-codex/pulls?state=open&limit=50", + headers={"Authorization": f"token {_token}"} if _token else {}, + timeout=10, + ) + if _resp.status_code == 200: + _prs = _resp.json() + forgejo_open = len(_prs) + forgejo_unmergeable = sum(1 for p in _prs if not p.get("mergeable", True)) + except Exception: + # Fallback to DB counts if Forgejo unreachable + forgejo_open = conn.execute("SELECT COUNT(*) as n FROM prs WHERE status='open'").fetchone()["n"] + + open_prs = forgejo_open + conflict_prs = forgejo_unmergeable conflict_permanent_prs = conn.execute("SELECT COUNT(*) as n FROM prs WHERE status='conflict_permanent'").fetchone()["n"] approved_prs = conn.execute("SELECT COUNT(*) as n FROM prs WHERE status='approved'").fetchone()["n"] reviewing_prs = conn.execute("SELECT COUNT(*) as n FROM prs WHERE status='reviewing'").fetchone()["n"] - backlog = open_prs + approved_prs + conflict_prs + reviewing_prs + backlog = open_prs oldest_open = conn.execute( "SELECT MIN(created_at) as oldest FROM prs WHERE status='open'"