baobab/docs/PROJECT_OVERVIEW.md
Maxime Van Hees 0ebda7c1aa Updates
2025-08-14 14:14:34 +02:00

11 KiB
Raw Blame History

Baobab Project Overview

This document explains the system architecture and execution model: what a supervisor is, what an actor is (including each actor type and how they are used), how jobs flow through Redis, and how the various interfaces expose functionality over WebSocket and Unix IPC.

References point directly into the codebase for quick lookup.

1. Core Concepts

2. Actors and Script Execution

The system defines four actor types. Each actor has its own queue and executes scripts differently, with standardized context variables injected into script execution (e.g., CALLER_ID, CONTEXT_ID).

Actor types and behavior:

  • OSIS (Rhai, non-blocking, sequential)

    • Executes Rhai scripts one after another on a single thread using the Rhai engine.
    • Intended for non-blocking tasks.
  • SAL (Rhai, blocking async, concurrent)

    • Executes blocking asynchronous Rhai scripts concurrently by spawning a new thread per evaluation.
    • Intended for IO-bound or blocking tasks requiring concurrency.
  • V (HeroScript via V engine) and Python (HeroScript via Python engine)

    • Execute HeroScript scripts in their respective engines.

Execution context:

Actor implementation surface:

  • Actors implement Actor and plug into the provided Actor::spawn() loop.
  • The common loop:
    • Connects to Redis (per-actor id),
    • Blocks on the actors queue with BLPOP,
    • Handles a special “ping” script inline (health check),
    • Delegates other jobs to Actor::process_job().

3. Supervisor Responsibilities and Guarantees

4. Interfaces (APIs and Transports)

The project exposes two complementary ways to interact with the supervisor and job system.

A. OpenRPC Server (JSON-RPC 2.0 over WebSocket or Unix IPC)

B. WebSocket Server (Actix)

  • A dedicated Actix-based WebSocket server that runs a multi-circle endpoint: each connected circle uses its path “/{circle_pk}”. Each connection is handled by a dedicated Actix actor.
  • Server runtime and session actor:
  • Auth and flow:
  • Integration with supervisor:
    • The WS server issues job requests via the supervisor (e.g., a “play” call builds and runs a job through Supervisor).

5. End-to-End Job Flow

6. How the Interfaces Fit Together

  • The OpenRPC server provides a JSON-RPC 2.0 façade for programmatic control (automation, services).

    • Choose between WebSocket and Unix IPC transports via Transport.
    • It wraps the Supervisor, delegating all job and lifecycle supervision calls.
  • The WebSocket (Actix) server provides a multi-circle, session-based, interactive API well-suited for browser or persistent WS clients.

Both interfaces ultimately converge on the same core abstraction: the Supervisor orchestrating jobs and actors over Redis with zinit-backed lifecycle guarantees.

7. Additional References