step 3.4 complete: agent run orchestrator — local/cloud runner + trigger_pending_runs + 23 tests

This commit is contained in:
2026-03-05 16:13:21 +01:00
parent 608d6c784f
commit 914f70bd85
6 changed files with 1228 additions and 14 deletions

View File

@@ -39,6 +39,7 @@ from jose import JWTError, jwt
from sqlalchemy import select, update
from app.config.settings import settings
from app.core.agent_runner import trigger_pending_runs
from app.core.device_manager import device_manager
from app.db import async_session
from app.models import AgentRunLog
@@ -100,8 +101,8 @@ async def device_ws(websocket: WebSocket) -> None:
agent_ids,
)
# Step 3.4 will replace this stub with a real call to agent_runner.
asyncio.create_task(_trigger_pending_runs_stub(user_id, device_id))
# Trigger any overdue agent runs now that the device is connected.
asyncio.create_task(trigger_pending_runs(user_id, device_id, device_manager))
# ── 4. Concurrent message loop + heartbeat ────────────────────────
try:
@@ -217,10 +218,4 @@ async def _mark_runs_disconnected(user_id: str) -> None:
)
# ── Pending-run trigger stub (Step 3.4 will replace) ─────────────────
async def _trigger_pending_runs_stub(user_id: str, device_id: str) -> None:
"""No-op stub. Step 3.4 wires this to agent_runner.trigger_pending_runs."""
logger.debug(
"device_ws: _trigger_pending_runs stub user=%s device=%s", user_id, device_id
)