Skip to content
matrix72cPublic

About

Run Docker Compose task environments on sandbox platforms, one sandbox per service.

Resources

Code of conduct

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Flotilla

CI License Python 3.12

Run a multi-service Compose task as isolated attempts on a sandbox platform.

Flotilla reads a task directory, resolves it into one sandbox per service, uploads the task's files into them, connects them under an explicit network policy, and cleans up its private state afterwards. Resolving a task is a local computation: it reads the task's own files plus each image's config from the registry, and writes nothing it later reads back. There is no build step, no intermediate artifact to publish, and no dataset staging area.

flowchart LR
    subgraph task["<task>/environment/docker-compose.yaml"]
        m[main]
        c[cache]
    end
    task --> F["plan()<br/>parse Compose · read image configs"]
    F --> P
    subgraph P["Sandbox platform"]
        direction LR
        sm["sandbox: main"] <--> sc["sandbox: cache"]
    end
Loading

Example

A task is a directory with a task.toml and an environment/ directory. A multi-service task has a Compose file there; a single-service task can instead name its image in task.toml as [environment].docker_image. Images are published and named by digest, and nothing is built:

task/
  instruction.md
  tests/test.sh            # required Harbor verifier script
  task.toml               # Harbor task configuration
  environment/
    docker-compose.yaml
services:
  main:
    image: alpine@sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc   # alpine:3.20
    depends_on:
      cache:
        condition: service_healthy
  cache:
    image: redis@sha256:7f7d30b7fdd09467bac58198a1f166dd69789d348d4fe859cccb20e0cf287fbe    # redis:7-alpine
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 2s
      retries: 15

The run names that directory, wherever it is: Flotilla reads it on the client and uploads what each service needs. Nothing is generated in between, so what runs is the tree you have.

A deployment is a platform's TOML file. Whoever runs your sandbox platform gives you its values; put the file next to the rest of your configuration, and the schema tells you what is missing:

# platform.toml
backend = "opensandbox"

[opensandbox]
endpoint = "https://sandbox.example.com"
credential_env = "SANDBOX_CREDENTIAL"

[opensandbox.network]
sandbox_cidrs = ["10.42.0.0/16"]

[storage]
host_path = "/shared"

[storage_sandbox]
image = "registry.example.com/team/flotilla-storage@sha256:..."

Measure the deployment's isolation once, before running anything on it. Commands outside your process load the same file:

flotilla probe --config platform.toml --env sandbox.env

See Running tasks for path binding and Deployment for credentials and the storage image.

import asyncio
from pathlib import Path

from flotilla import Deployment, OpenOptions


async def main():
    deployment = Deployment.from_toml("platform.toml")
    plan = deployment.plan(Path("tasks/demo/redis"), OpenOptions(startup_timeout=600, lifetime=300))
    async with deployment.client() as fleet:
        async with fleet.environment(plan) as env:
            pong = await env.service("cache").exec(["redis-cli", "ping"], timeout=30)
            print(pong.stdout.decode().strip())
    assert fleet.cleanup_report is not None and fleet.cleanup_report.clean


asyncio.run(main())

Deployment.plan resolves the task directory into the trial open runs, as a local computation, so a caller can check a whole set of tasks before spending a sandbox on any of it. fleet.environment opens the plan and releases it on exit. The task's own files are uploaded into each sandbox before its services start. This is the runtime. flotilla.flow.run wraps it into a whole run -- the Actors through a harness you supply, then collect, verify and verdict.json; see task flow -- and harbor's own trial machinery drives the same runtime in its loop.

Harbor drives the same lifecycle itself, in place of this loop:

harbor run --env flotilla.integrations.harbor:FlotillaTaskEnvironment \
  --ek config=platform.toml \
  --path /srv/tasks/example/ds/demo

See running harbor trials for what the environment does per trial.

Features

  • Compose semantics, checked up front. depends_on with health conditions, healthchecks, multiple and internal networks, aliases, named volumes, bind mounts, env_file, .env interpolation, resource limits, and user. Every key is classified as equivalent, warned, or rejected, and a rejected key fails the task with its field path before anything is created. The Compose subset is parsed by Flotilla itself, with no docker compose binary; flotilla inspect shows the result locally. See Compose support.
  • Explicit isolation. Network policies are compiled from the Compose networks and the deployment's egress policy: none, an allowlist, or any. A task can turn off internet access entirely. An isolation property flotilla probe cannot demonstrate must be accepted by name in the spec.
  • Confirmed cleanup. Every sandbox and directory is labeled with its owner. A lost create response is reconciled, capacity is released only after deletion is confirmed, and flotilla gc collects what a crashed process left behind.
  • No silent replays. A command is never sent twice. timed_out=True means the remote process was confirmed stopped; if that cannot be confirmed, you get ExecOutcomeUnknown and the environment is retired.
  • Built for many concurrent environments. One client manages admission, create and exec rate limits, sandbox renewal, and per-service resource defaults for every environment it opens.
  • Pluggable backends. OpenSandbox is built in. Another backend lives in the source tree and is added to the BACKENDS table in the flotilla/config package; see Writing a backend.

Get started

Flotilla runs on Linux x86_64 with Python 3.12. A task's task.toml is Harbor's format, so harbor is a required dependency; nothing needs Docker, a Compose binary or a GPU stack. A deployment's isolation must pass flotilla probe before use; see the deployment guide.

git clone https://github.com/matrix72c/flotilla.git
cd flotilla
python -m pip install .

The distribution, import name and CLI are flotilla. Install from this repository or a wheel built from a fixed commit; do not run bare pip install flotilla, which selects an unrelated public PyPI project. Use a fresh environment when migrating from flotilla-compose; the two distributions must not share an environment because they own the same Python module.

Then pick a path:

You have Start with
One Linux machine with Docker, and want to try it Local quick start: run OpenSandbox and Flotilla on one machine
Deployment values from whoever runs your sandbox platform Quick start: write a task and run it from Python
Harbor tasks such as Terminal-Bench Running tasks: run Harbor-format tasks from Python, or drive them with harbor run itself
A sandbox platform to set up for your team Deployment guide

Documentation

Using Flotilla

  • Quick start: write a multi-service task and run it.
  • Running tasks: task layout, task files, and flotilla inspect.
  • Task flow: flotilla.flow.run end to end -- the modules, the nine steps, verdicts and the grading SDK.
  • Runtime API: execution, files, background processes, timeouts, cancellation, and errors.
  • Compose support: which Compose keys are supported, approximated, or rejected.

Operating a deployment

Extending Flotilla

  • SDK surface: what may be imported from flotilla, flotilla.flow, flotilla.verifier, flotilla.integrations.harbor, and flotilla.testing, and the stability commitments.
  • Integration guide: use Flotilla from an evaluation runner or RL framework, or run harbor trials directly.
  • Writing a backend: support another sandbox platform.
  • Architecture: internals and terminology.

Status

Flotilla is alpha software. The supported targets are Linux x86_64, Python 3.12, the OpenSandbox backend with execd release 1.1.1 or later, and released Harbor (harbor>=0.26.0,<0.27) for harbor-driven trials. APIs and configuration may change between minor versions before 1.0; the commit history records each change.

Contributing

Contributions are welcome; see CONTRIBUTING.md. Report vulnerabilities privately as described in SECURITY.md. This project follows a code of conduct.

License

Flotilla is licensed under the Apache License 2.0. The storage image includes BusyBox, which is licensed under GPLv2; see third-party components.

About

Run Docker Compose task environments on sandbox platforms, one sandbox per service.

Resources

Code of conduct

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages