Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8b8cc24
v2.0.0-beta: 10 autonomous cron workflows + CTO self-merge
germanf Jul 3, 2026
aef15a8
v2.1.0-beta: Phase B — Memory & Self-Improvement (#121)
germanf Jul 3, 2026
8d5bb68
5.3.c — Health check expansion: memory, CPU, backup, MCP, backends
Jul 7, 2026
2843b80
Merge pull request #123 from germanf/feature/health-check-expansion
germanf Jul 7, 2026
21e4d48
5.3.a — Alerting system: webhook channel, REST API, health integratio…
Jul 7, 2026
23f8981
Merge pull request #126 from germanf/feature/alerting-system
germanf Jul 7, 2026
6696218
5.4.a — Real-time SSE Jobs Page: job list + live log viewer with Even…
Jul 7, 2026
6932311
Merge pull request #127 from germanf/feature/realtime-jobs
germanf Jul 7, 2026
8224879
5.1.a — Map-Reduce in Orchestrator: backend factory + endpoint, front…
Jul 7, 2026
7cc90f1
fix: parallelism validation, empty input guard, chunk denominator
Jul 7, 2026
f423b15
Merge pull request #128 from germanf/feature/map-reduce
germanf Jul 9, 2026
06efd24
5.4.b — Alert UI in Dashboard: Active Alerts widget with polling + ac…
Jul 9, 2026
d71689b
fix: ack error handling, consistent polling, remove unused CSS
Jul 9, 2026
7a7abd6
Merge pull request #129 from germanf/feature/alert-ui
germanf Jul 10, 2026
f0124a1
5.3.b — Prometheus metrics endpoint at /metrics with health_check gauge
Jul 10, 2026
7568ebb
Merge pull request #130 from germanf/feature/prometheus-metrics
germanf Jul 10, 2026
cc46e89
5.4.c — Health Timeline: degraded/unavailable lines, summary bar
Jul 10, 2026
35201ea
Merge pull request #131 from germanf/feature/health-timeline
germanf Jul 11, 2026
4333d4e
5.3.d — Backup Integrity Verification: PRAGMA integrity_check on all …
Jul 11, 2026
590c0f1
Merge pull request #132 from germanf/feature/backup-integrity
germanf Oct 28, 2026
c2555db
Merge branch 'main' into dev
germanf Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
v2.0.0-beta: 10 autonomous cron workflows + CTO self-merge
- 10 operational workflow DAGs with 30-min cron tick
- Recursive 5-min retry re-entrancy when workflow still running
- SQLite workflow_runs table for run tracking
- Scheduler API: GET /api/scheduler/workflows, runs, retries
- POST /api/scheduler/tick, /api/scheduler/run
- CTO self-approval for all merges (no human gate)
- 10 YAML workflow definitions for MCP server inspection
- ruff + py_compile + pnpm build + pnpm test: all passing

Co-authored-by: KyoX <kyox@iscire.com>
  • Loading branch information
germanf and KyoX authored Jul 3, 2026
commit 8b8cc24ac4c27c8f6c9fb0a0a5cdd7e5bca03d4b
10 changes: 10 additions & 0 deletions dashboard/chat_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@

CREATE INDEX IF NOT EXISTS idx_chats_project ON chats(project_id);
CREATE INDEX IF NOT EXISTS idx_messages_chat ON messages(chat_id);

CREATE TABLE IF NOT EXISTS workflow_runs (
id TEXT PRIMARY KEY,
workflow_name TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'pending',
started_at REAL,
completed_at REAL,
detail_json TEXT
);
CREATE INDEX IF NOT EXISTS idx_wr_workflow ON workflow_runs(workflow_name);
"""


Expand Down
4 changes: 4 additions & 0 deletions dashboard/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@
from dashboard.routes.notes import router as notes_router
from dashboard.routes.orchestrator import router as orchestrator_router
from dashboard.routes.projects import router as projects_router
from dashboard.routes.scheduler import router as scheduler_router
from dashboard.routes.token_accounting import router as token_accounting_router
from dashboard.routes.workflows import router as workflows_router
from dashboard.token_accounting import init_token_accounting
from dashboard.tracing import TracingMiddleware
from dashboard.workflow_scheduler import start as start_workflow_scheduler

app = FastAPI(title="Agentic Software Boutique")
app.state.limiter = limiter
Expand All @@ -71,6 +73,7 @@
app.include_router(hermes_webhook_router)
app.include_router(cron_router)
app.include_router(workflows_router)
app.include_router(scheduler_router)
app.include_router(token_accounting_router)


Expand Down Expand Up @@ -115,6 +118,7 @@ async def startup():
(start_headroom_learn, "headroom_learn"),
(start_curator_loop, "curator_loop"),
(start_backup_loop, "backup_loop"),
(start_workflow_scheduler, "workflow_scheduler"),
]:
try:
fn()
Expand Down
174 changes: 174 additions & 0 deletions dashboard/ops_workflows.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
"""10 autonomous operational workflows for cron-driven maintenance."""
from __future__ import annotations

import shutil
import time
from collections.abc import Callable, Coroutine
from typing import Any

from loguru import logger

from dashboard.chat_store import DB_PATH, _connect

_WORKFLOW_REGISTRY: dict[str, dict[str, Any]] = {}


def register(
name: str, interval_min: int = 30, enabled: bool = True
) -> Callable[[Callable[..., Coroutine]], Callable[..., Coroutine]]:
def wrapper(func: Callable[..., Coroutine]) -> Callable[..., Coroutine]:
_WORKFLOW_REGISTRY[name] = {
"func": func,
"interval_min": interval_min,
"enabled": enabled,
"last_tick": 0.0,
"running": False,
}
return func
return wrapper


def list_workflows() -> dict[str, dict[str, Any]]:
return {k: {kk: vv for kk, vv in v.items() if kk != "func"} for k, v in _WORKFLOW_REGISTRY.items()}


@register("system_health")
async def system_health() -> dict[str, Any]:
from dashboard.health import registry
results = await registry.run_all()
for hc in results:
logger.info("Health [{}] status={}", hc.name, hc.status)
return {"checks": len(results), "failures": sum(1 for h in results if h.status != "healthy")}


@register("db_backup")
async def db_backup() -> dict[str, Any]:
backup_dir = DB_PATH.parent / "backups"
backup_dir.mkdir(parents=True, exist_ok=True)
ts = int(time.time())
backup_path = backup_dir / f"chat.{ts}.db"
if DB_PATH.exists():
shutil.copy2(DB_PATH, backup_path)
extant = sorted(backup_dir.glob("chat.*.db"), reverse=True)
for old in extant[5:]:
old.unlink()
logger.info("DB backed up: {} ({} kept)", backup_path, min(len(extant), 5))
return {"backup": str(backup_path), "kept": min(len(extant), 5)}
return {"error": "chat.db not found"}


@register("job_evict")
async def job_evict() -> dict[str, Any]:
from dashboard.runner import _FINISHED_STATUSES, _jobs
now = time.time()
before = len(_jobs)
to_delete = []
for jid, job in list(_jobs.items()):
if job.status in _FINISHED_STATUSES:
age = now - (job.ended_at or job.started_at)
if age > 3600:
to_delete.append(jid)
for jid in to_delete:
_jobs.pop(jid, None)
logger.info("Evicted {} finished jobs ({} remaining)", len(to_delete), len(_jobs))
return {"evicted": len(to_delete), "remaining": len(_jobs), "before": before}


@register("chat_prune")
async def chat_prune() -> dict[str, Any]:
cutoff = time.time() - 7 * 86400
pruned = 0
async with _connect() as conn:
cur = await conn.execute(
"DELETE FROM messages WHERE created_at < ?", (cutoff,)
)
pruned = cur.rowcount
logger.info("Pruned {} old messages", pruned)
return {"pruned_messages": pruned}


@register("headroom_learn")
async def headroom_learn() -> dict[str, Any]:
try:
from dashboard.headroom_learn import compute_baseline
baseline = await compute_baseline()
logger.info("Headroom baseline: {}", baseline)
return {"baseline": baseline}
except Exception as e:
logger.warning("Headroom learning skipped: {}", e)
return {"skipped": str(e)}


@register("token_log")
async def token_log() -> dict[str, Any]:
try:
from dashboard.token_accounting import get_daily_usage
usage = await get_daily_usage()
logger.info("Token usage: {}", usage)
return {"usage": usage}
except Exception as e:
logger.warning("Token log skipped: {}", e)
return {"skipped": str(e)}


@register("diagnostics")
async def diagnostics() -> dict[str, Any]:
info: dict[str, Any] = {
"timestamp": time.time(),
"db_exists": DB_PATH.exists(),
"db_size": DB_PATH.stat().st_size if DB_PATH.exists() else 0,
}
async with _connect() as conn:
for table in ("projects", "chats", "messages", "workflow_runs"):
try:
cur = await conn.execute(f"SELECT COUNT(*) as cnt FROM {table}")
row = await cur.fetchone()
info[f"{table}_count"] = row["cnt"] if row else 0
except Exception:
info[f"{table}_count"] = -1
try:
from dashboard.runner import _jobs
info["active_jobs"] = sum(1 for j in _jobs.values() if j.status.value == "running")
info["total_jobs"] = len(_jobs)
except Exception:
pass
logger.info("Diagnostics: {}", info)
return info


@register("alerts_prune")
async def alerts_prune() -> dict[str, Any]:
from dashboard.alerts import alerts
before = len(alerts._alerts)
alerts._alerts = [a for a in alerts._alerts if a.get("severity") in ("critical", "warning")]
pruned = before - len(alerts._alerts)
logger.info("Pruned {} non-critical alerts ({} remain)", pruned, len(alerts._alerts))
return {"pruned": pruned, "remaining": len(alerts._alerts)}


@register("workflow_log_cleanup")
async def workflow_log_cleanup() -> dict[str, Any]:
cutoff = time.time() - 30 * 86400
async with _connect() as conn:
cur = await conn.execute(
"DELETE FROM workflow_runs WHERE started_at < ?", (cutoff,)
)
pruned = cur.rowcount
logger.info("Pruned {} old workflow run records", pruned)
return {"pruned": pruned}


@register("scheduler_self_check")
async def scheduler_self_check() -> dict[str, Any]:
"""Log scheduler status: which workflows are running, stuck, or due."""
now = time.time()
statuses = {}
for name, cfg in _WORKFLOW_REGISTRY.items():
statuses[name] = {
"enabled": cfg["enabled"],
"running": cfg["running"],
"interval_min": cfg["interval_min"],
"seconds_since_tick": now - cfg["last_tick"],
}
logger.info("Scheduler self-check: {}", statuses)
return statuses
53 changes: 53 additions & 0 deletions dashboard/routes/scheduler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from fastapi import APIRouter, Request
from pydantic import BaseModel

from dashboard.chat_store import _connect
from dashboard.ops_workflows import list_workflows
from dashboard.rate_limit import limiter
from dashboard.workflow_scheduler import _pending_retries, tick_one

router = APIRouter(prefix="/api/scheduler", tags=["scheduler"])


@router.get("/workflows")
@limiter.limit("30/minute")
async def get_workflows(request: Request):
return list_workflows()


@router.post("/tick")
@limiter.limit("10/minute")
async def trigger_tick(request: Request):
from dashboard.workflow_scheduler import tick
await tick()
return {"ok": True}


class RunRequest(BaseModel):
name: str


@router.post("/run")
@limiter.limit("10/minute")
async def run_workflow(request: Request, body: RunRequest):
return await tick_one(body.name)


@router.get("/runs")
@limiter.limit("30/minute")
async def get_runs(request: Request, limit: int = 20):
async with _connect() as conn:
cur = await conn.execute(
"SELECT * FROM workflow_runs ORDER BY started_at DESC LIMIT ?", (limit,)
)
rows = await cur.fetchall()
return [dict(r) for r in rows]


@router.get("/retries")
@limiter.limit("30/minute")
async def get_retries(request: Request):
return {
name: not t.done()
for name, t in list(_pending_retries.items())
}
Loading