Circuit Orchestration

Pre-wired topologies with smart adapters, mock collapse, A/B routing, multi-protocol support, federation, and self-healing. Define the board. Slot services in.

pip install baton-orchestrator
[ ]

Circuit-First Design

Topology is a first-class artifact. Define nodes, edges, and contracts in baton.yaml. Services slot in and out of a fixed board.

<->

Smart Adapters

Every node gets an async reverse proxy. Health checks, metrics, hot-swap with drain, and per-request routing -- all built in.

TCP

Multi-Protocol

HTTP, TCP, gRPC, protobuf, and SOAP out of the box. Extensible ProtocolHandler registry for custom protocols.

{ }

Mock Collapse

Auto-generate mock servers from OpenAPI specs. Start fully mocked, slot in services one at a time, collapse back when done.

A|B

A/B Routing

Weighted splits, canary rollouts, header-based routing. Config locking prevents accidental overrides during tests.

%>>

Canary Auto-Promotion

Automated canary evaluation with error rate and latency thresholds. Promotes through weight steps or rolls back.

+/-

Hot-Swap

Replace running services with zero downtime. Drain connections from old instance, start new, switch. Atomic and safe.

!!!

Self-Healing

Custodian monitors health every 5 seconds. Auto-restarts failed services, replaces with mocks, escalates when repairs fail.

~>

Observability

Live dashboard, per-node metrics, request signals, per-path statistics. Prometheus export. JSONL persistence for offline analysis.

<=>

Federation

Multi-cluster heartbeat, cross-cluster state sync, automatic failover and restore. Pull-based peer discovery with configurable thresholds.

TLS

Certificate Management

Monitor TLS certificate expiry with warning and critical thresholds. Auto-rotate certs with zero downtime -- new connections get the new cert.

MCP

AI Integration

Model Context Protocol server exposes circuit state to Claude Code and other AI assistants. Inspect topology, metrics, and signals.

[#]

Image Building

Auto-detect Python or Node runtimes, generate Dockerfiles, build and push container images. Integrated into deploy pipeline.

GCP

Cloud Deploy

Deploy to GCP Cloud Run with --build. Each node becomes a service. Edges auto-wired via environment variables.

***

Security Hardened

Command injection prevention, header injection guards, path traversal protection, fail-closed auth, bounded header parsing.

///

804 Tests

701 hand-written tests plus 103 pact-generated smoke tests covering all 36 source modules. Every public function verified callable.

Five minutes to a running circuit

Define your topology, boot with mocks, slot in real services, run A/B tests, federate across clusters.

# Define the circuit baton init myproject baton node add api --port 8001 baton node add service --port 8002 baton node add rpc --port 8003 --mode grpc baton edge add api service baton edge add api rpc # Boot with mocks -- entire circuit in one process baton up --mock # Slot in a real service (mock replaced, zero downtime) baton slot api "python app.py" # A/B test a new version (80/20 split) baton route ab api "python app_v2.py" --split 80/20 # Canary with auto-promotion baton route canary api "python app_v2.py" --pct 10 --promote # Check federation status baton federation status baton federation peers --json # Monitor certificates baton certs status # Build images and deploy to GCP Cloud Run baton deploy --provider gcp --build --project my-project

How it works

Baton architecture: baton.yaml defines nodes and edges, runtime creates reverse proxy adapters with slot() for swapping services or mocks, collapse levels from full_mock through partial to full_live

Protocol Support

Mode Description Health Check
http HTTP/1.1 reverse proxy with tracing, circuit breaker, retries HTTP GET to health path
tcp Bidirectional byte pipe TCP connectivity
grpc Transparent HTTP/2 forwarding TCP connectivity
protobuf Length-prefixed binary proxy (4-byte big-endian + payload) TCP connectivity
soap HTTP with SOAPAction header awareness and fault detection HTTP + SOAP fault check

Core Concepts

Circuit

The board. Nodes + edges + contracts. Defined in baton.yaml.

Adapter

Async reverse proxy at each node. Handles routing, health, metrics.

Slot / Swap

Insert or replace a service. Hot-swap drains before switching.

Collapse

Compress circuit. Full mock through partial to full live.

Custodian

Health monitor. Restart, replace, escalate. Self-heals the board.

Routing

Weighted, header, canary. Per-request. Lockable.

Protocol

Pluggable handlers. HTTP, TCP, gRPC, protobuf, SOAP. Extensible.

Federation

Multi-cluster heartbeat, state sync, automatic failover.

Provider

Deployment backend. Local processes or GCP Cloud Run.

Manifest

Service self-description. API spec, mocks, dependencies.

Ingress

Entry point from outside the circuit. First node traffic hits.

Egress

External dependency. Always mocked. Third-party APIs, databases.

Dashboard

Live UI. Node cards, bar charts, signal log, topology. Polls every 2s.

Canary

Auto-promote or rollback. Compares error rate + latency against thresholds.

Certificates

TLS cert monitoring, expiry alerts, zero-downtime rotation.

MCP

AI integration. Exposes circuit state to Claude Code and other assistants.