Skip to content

Lite fleets run on local Docker; a restarted fleet can be stopped and collected again; release 0.9.0 - #41

Merged
flujo-app merged 7 commits into
mainfrom
docker-fleet
Nov 23, 2026
Merged

flujo-app merged 7 commits into
mainfrom
docker-fleet

Conversation

@flujo-app

Copy link
Copy Markdown
Owner

Fixes #40.

What changes

A lite fleet can now run on local Docker instead of Fly, with the same plan and the same shared board:

import { FactoryDockerLiteFleet, CodexSubscriptionBroker } from 'flujo-factory';

const fleet = new FactoryDockerLiteFleet({
  directory: '/absolute/private/fleet-run',
  auth: new CodexSubscriptionBroker({ authFile: '/absolute/private/.codex/auth.json' }),
});
await fleet.deploy({ runId: 'my-local-run', app: 'my-local-swarm', goal, machines: 3, agentsPerMachine: 4 });
  • One container per machine, one Docker volume each for /data, one private network per fleet. The first container holds the board, as on Fly.
  • Nothing in the fleet logic is copied. FactoryCloudLiteFleet already takes its provider as an infrastructure object (the tests use that to stand in for Fly). The new src/cloud-lite/docker.mjs is such a provider: it answers the eleven provider commands a fleet sends (apps create, volumes create, machine list, machine exec, ...) with Docker. Deploy, observe, operator messages, stop, start, runtime update, quiesce, collect and retire are the existing code.
  • The worker runtime is unchanged for Docker. Each container answers on the private network as <machine id>.vm.<app>.internal, the name workers already use on Fly.
  • The host reaches the board on a loopback-only port that Docker picks. No worker port is published.
  • Secrets stay off command lines. Logins and board credentials are copied into each container as root-only files (a tar stream to docker cp) and become environment variables of the worker runtime only. They are not in docker inspect.
  • Easy defaults. Without image, workers start from node:24-bookworm-slim. Without bundlePath, the installed SDK is packed once into the fleet directory and reused on resume.
  • Refused early: Docker not running, Windows containers, fewer CPUs than one machine asks for, the plan's Fly network, Fly image sources. Nothing is recorded in that case.
  • Only labelled resources are touched. An existing volume or network is never adopted. retire() removes only what carries the fleet's label.
  • No new dependency. The Docker command line is called directly.

Limits, stated in PUBLIC_SDK.md: region, cpuKind and diskGb have no effect on Docker; cpus and memoryMb become container limits; a modelProvider still needs https URLs; every container start installs the worker program again (two to four minutes).

Two faults found while testing on real Docker, fixed for Fly as well

  1. A fleet that was started again could not be stopped again. stop() kept one journal entry per machine. After stop, start and a second stop, that entry was already done, so the second stop sent nothing while the journal said "stopped" and the machines kept running. A stop now has one entry per machine and start, and start() sets the status back to provisioned (not for a sealed fleet).
  2. After a restart, an agent that had finished a turn could not be stopped, so quiesce() and collect() timed out. The board still showed that turn, the restarted runtime had forgotten it, and a stop names the turn the board shows. The runtime now restores it when it resumes a session; a turn the board still shows running while the session is idle is closed as interrupted.

Both have a test that fails without the fix.

Other changes

  • README.md: a short Docker example under "Go big"; the install line now points at 0.9.0.
  • PUBLIC_SDK.md: new section "Lite fleets on local Docker".
  • scripts/docker-fleet-smoke.mjs (also npm run smoke:docker-fleet): the real check, shipped in the package so anyone can run it on their own Docker.
  • The workflow's focused list gains test/cloud-lite-docker.test.mjs and test/cloud-lite-connection.test.mjs.
  • Release 0.9.0 (package.json, package-lock.json).

Tests

  • New test/cloud-lite-docker.test.mjs, 11 tests against a Docker kept in memory: what a plan turns into; secrets never on a command line or in container settings; the packed bundle and its reuse; the host connection to a real board server; stop and start; runtime update with rollback; collection; retire and its refusal of an unknown container; early refusals; no adoption of existing volumes or networks; and a check that every provider command in fleet.mjs has a Docker equivalent, so a new one cannot be forgotten.
  • test/cloud-lite-connection.test.mjs and test/cloud-lite.test.mjs: one new test each for the two fixes.

Real Docker runs

Run with scripts/docker-fleet-smoke.mjs from a clean snapshot of beaaf5e (the code of this PR before the record itself was added) on Docker Desktop 29.6.1 for Windows 10, image node:24.22.1-bookworm-slim. Record: evidence/docker-fleet-acceptance-20261123.json.

Run What it did Result
Codex, 2 containers x 2 agents, subscription login deploy; only the board port published, on loopback; no secret in container settings; all 4 agents enrolled on the shared board; real model turn: an agent in the second container recorded a claim on the board in the first; stop; start (same containers, sessions found again); second real turn on the resumed session; runtime update (new containers, same volumes); collect (one verified archive per machine); retire (nothing left) 11 of 11 checks, 9 min 16 s
Claude Code, 2 x 2 deploy, same network and secret checks, all 4 agents enrolled, retire 5 of 5 checks
FLUJO, 2 x 2 deploy, same network and secret checks, all 4 agents enrolled, retire 5 of 5 checks

Time from start to all agents enrolled: Codex 3 min 24 s on first start and 1 min 27 s after a restart, Claude Code 4 min 18 s, FLUJO 7 min 31 s (its first start installs FLUJO onto the volume).

Not shown by these runs:

  • Model turns of Claude Code or FLUJO workers on Docker. Those two runs used placeholder logins and called no model; they show that the programs install, start and enrol in containers.
  • Docker on a Linux host. The unit tests run on Linux; the real containers ran on Docker Desktop for Windows.
  • The workspace-write and read-only sandboxes inside containers. The runs used the default.
  • More than two machines.

Earlier attempts, for the record: the first real run failed in the check script itself (it compared session IDs too early after a restart). The second failed at the collect step and exposed fault 2 above. Fault 1 was found while writing the check, whose second stop() did nothing.

Local CI before GitHub

The steps of .github/workflows/public-sdk.yml, run on commit b062c12 from a clean source snapshot (git archive) with a clean npm ci:

Platform Node npm Python Result
Windows 10 (Git Bash, Windows tar.exe ahead of Git's) 22.17.0 10.9.2 3.13.1 pass
Windows 10 (same) 24.22.1 11.19.1 3.13.1 pass
Linux, node:22.17.0-bookworm-slim container, non-root user 22.17.0 10.9.2 3.11.2 pass
Linux, node:24.22.1-bookworm-slim container, non-root user 24.22.1 11.19.1 3.11.2 pass

Each run:

  • npm ci
  • npm audit --omit=dev --audit-level=high: passes; it reports 2 moderate findings, the same as on main (no dependency changed).
  • node scripts/test-temp-guard.mjs <focused list from the workflow>: 304 tests, 304 pass, nothing left in the temp location. (287 on main; 11 new Docker tests, the 4 existing connection tests now in the list, and 2 new tests for the fixes.)
  • python -B -m unittest discover -s selfhost/modal -p "test_*.py": 11 tests pass.
  • npm pack, a fresh install of flujo-factory-0.9.0.tgz into an empty folder, scripts/verify-public-sdk.mjs (now also checks the two Docker exports), --help of factory-public, factory-lite and factory-evidence, factory-selfhost profiles, and the installed MCP stdio test: pass.
  • node scripts/test-temp-guard.mjs test/generic-swarm-evidence.test.mjs: 7 tests pass.

The slim Linux images got python3 and git from Debian inside the container first, as the GitHub runner has both. The Linux container is Debian 12, not the runner's Ubuntu image. The Linux snapshot was made with core.autocrlf=false, so its files have the line endings a Linux checkout has.

stop() kept one journal entry per machine. After stop, start and a second stop, that entry was already marked done, so the second stop sent nothing while the journal said "stopped" and the machines kept running. A stop now has one entry per machine and start. start() also sets the status back to provisioned, unless the fleet is sealed.
FactoryDockerLiteFleet runs the lite fleet in local containers instead of Fly machines: one container and one volume per machine, one private network, the same shared board on the first machine. It answers the provider commands the fleet already sends, so plans, worker programs, logins and all fleet actions are unchanged. Secrets travel as root-only files, never on a command line or in docker inspect. Refs #40.
After a machine restart the board still shows the last turn of a resumed session, but the new runtime had forgotten it. A stop command names the turn the board shows, so it was refused, and quiesce and collect timed out. The runtime now restores that turn when it resumes a session; a turn the board still shows running while the session is idle is closed as interrupted.
Three runs from a clean snapshot of beaaf5e on Docker Desktop for Windows: a full Codex fleet with two real model turns, and Claude Code and FLUJO workers enrolling on the board.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lite fleets run only on Fly; there is no way to run the same swarm on local Docker

1 participant