Home / Reference

Orchestrator: architecture and status

The orchestrator turns obskitpy from "observe your Python robots" into "register, schedule, run, release and observe them". How to use it is in Robots, runs and agents; this page explains how it is built and what is still missing.

Status in 1.0

Capability State
Robot registry: DEV / HMG / PRD, history, roles Done
API tokens, obskitpy robot|runs|agent|login CLI Done
Schedules (cron, UTC), queue, leases, retries, timeout, cancel Done
Pull agents (local, container) with live logs Done
Releases, deployments, PRD approval, post-deploy failure rate Done
GitHub Actions monitor and pipeline builder Done (see CI/CD)
Azure The agent image runs anywhere; not verified on an Azure subscription (guide)
Installing a robot's dependencies, run artifacts, Windows GUI robots Not done
Token management screen, four-eyes approvals, per-robot analytics and alert rules Not done

Architecture

 console / CLI ──HTTPS──> portal (FastAPI) ──> PostgreSQL (robots, runs, queue, releases...)
                             │  ▲
        scheduler loop ──────┘  │ claim · heartbeat · logs · finish (outbound only)
                                │
                    agents (laptop, VM, container, Azure) ──> robot processes ──OTLP──> Collector ──> Elasticsearch

The portal is the control plane; agents are data plane workers that pull. Nothing connects to an agent, so agents need no open ports. Logs and traces of the robots go to the existing OpenTelemetry pipeline, linked by service.name.

Backend layers

api (thin routers) → services (business rules, no FastAPI) → models (SQLAlchemy). Domain errors are raised by services and turned into one JSON error shape ({"detail", "code"}) by api/errors.py. Migrations are Alembic; the portal upgrades its schema at startup.

Run state machine

QUEUED → ASSIGNED → RUNNING → SUCCEEDED | FAILED | TIMED_OUT | CANCELLED
              └──────→ LOST (lease expired)        CANCELLING while a stop is in flight

Queue and concurrency

Runs wait in PostgreSQL. A claim selects queued runs with FOR UPDATE SKIP LOCKED, then locks the robots involved in ascending id order (FOR NO KEY UPDATE) to check each robot's concurrency limit, so concurrent agents never get the same run, never exceed a limit and cannot deadlock each other. Each assignment is a lease (60 s) that heartbeats extend; an expired lease marks the run LOST. Delivery is at least once; a run's run_id is exposed to the robot as OBSKITPY_RUN_ID so robots can be idempotent.

Decisions

Decision Why
Pull-based agents no inbound ports; works across networks, VMs, containers and clouds
PostgreSQL as the queue one dependency fewer; atomic claims with SKIP LOCKED
Credentials as names only the portal never holds a robot's secrets; the agent's environment (Key Vault, secrets) does
Modular monolith one FastAPI app and database; split only with a measured need
GitHub executes CI/CD obskitpy configures, observes and governs instead of rebuilding a CI engine
Releases are immutable; PRD needs an admin nothing reaches production without a second look

Load test

obskitpy/tests/load/load_test.py starts the portal and N agents as separate processes against PostgreSQL, triggers all runs at once and checks that every run finishes exactly once, no robot exceeds its limit, and latencies stay reasonable. 500 runs of 20 robots on 3 agents finished in about 25 s; 4 robots × 50 runs on 2 agents in about 33 s (limited by each robot's concurrency of 4). Running the portal and agents in one Python process starves the server (GIL), so the test does not.

✎ Edit this page on GitHub