Fleet deployment

How fleets work and how to get the most out of the fleet API for deployment.


Start here (first time)

Work from a project directory you care about. Fleet data is written to .dal/fleets.json under the current working directory (see File layout). That path is typically gitignored (many apps add .dal/ to .gitignore).

Example: first fleet from a Worker mold

From a directory that contains your Worker mold file (paths are examples; use your own):

dal agent fleet create assistant-workers --from-mold mold/worker.mold.dal --count 2
dal agent fleet list -v
dal agent fleet deploy assistant-workers "Smoke test task"
dal agent fleet run assistant-workers
dal agent fleet health assistant-workers

1. Create a fleet (any project)

Option A — empty fleet (name only; add members later with add-from-mold or add-member):

dal agent fleet create my-fleet

Option B — fleet from a mold (spawns N agents and records their IDs):

dal agent fleet create my-fleet --from-mold mold/worker.mold.dal --count 3

Molds are .mold.dal files; see MOLD_FORMAT.md.

2. Inspect

dal agent fleet list
dal agent fleet list -v
dal agent fleet show my-fleet

3. Record a task, then run it

deploy stores the task string on the fleet (what you intend to run). It does not by itself execute long-lived workers across machines.

dal agent fleet deploy my-fleet "Process daily logs"
dal agent fleet run my-fleet

run uses the built-in dispatcher: it loads the fleet, ensures members (may add from mold if the roster is empty), and sends last_deployed_task to each member via agent coordination. Use dal agent fleet health my-fleet for a quick status.

4. Scale (optional)

dal agent fleet scale my-fleet 5

5. Export for Docker / Kubernetes (optional)

dal agent fleet export my-fleet --format docker-compose
dal agent fleet export my-fleet --format k8s

Reality check

When you are comfortable with this flow, read Fleet vs agent and the rest of this page for scaling, blue/green, and automation.


Fleet vs agent


Current model

API (Rust): fleet::create, fleet::create_from_mold, fleet::list, fleet::show, fleet::scale, fleet::delete, fleet::deploy, fleet::add_from_mold, fleet::add_member, fleet::run, fleet::health, fleet::export (with ExportFormat::K8s or DockerCompose). Fleet has optional last_create_params (used when scaling up).

CLI: dal agent fleet create|list|show|scale|delete|deploy|add-from-mold|add-member|run|health|export ...


Deployment flow (use of the API)

1. Define once (mold), scale as needed

2. Deploy a task to the fleet

3. Where execution happens

So: deploy = “record this task for this fleet”; execution = dal agent fleet run or your own long-lived process that reads the fleet and runs the task.

4. Getting the most out of the API

Goal Use
Homogeneous worker pool create_from_mold with one mold and desired count; scale to adjust.
Record what to run deploy <name> <task>; then use show or read .dal/fleets.json for last_deployed_task / last_deployed_at.
Blue/green or canary Use two fleets (e.g. workers-blue, workers-green); deploy to one, then switch traffic or scale the other to 0.
Rollback Redeploy a previous task string, or scale down and scale up from a previous mold version.
Export for orchestrators Use `dal agent fleet export [name] --format k8s

File layout


Implemented (production-grade)

Area Implementation
Task execution dal agent fleet run [name] loads fleets, ensures members (adds from mold if empty), and dispatches last_deployed_task to each member via agent::coordinate(..., "task_distribution").
Scale-up params Fleet has optional last_create_params; set by create_from_mold and used by scale() when spawning new members.
Add members add_from_mold(name, mold_source, count, base, params?) adds N agents from a mold (sets mold_source if fleet was empty). add_member(name, agent_id) registers an existing agent.
Health dal agent fleet health <name> reports member count, has_mold, last_deployed_task/at, status (ok/empty).
DAL/stdlib API fleet namespace in runtime: fleet::create, fleet::create_from_mold, fleet::list, fleet::show, fleet::scale, fleet::delete, fleet::deploy, fleet::add_from_mold, fleet::add_member, fleet::health.
Export dal agent fleet export [name] [--format k8s|docker-compose] emits YAML (JobList or docker-compose services).
list output dal agent fleet list [--verbose|-v] shows last_deployed_task and last_deployed_at.

Optional / future

Area Notes
Scale-down teardown Scale-down still only truncates member_ids; no agent terminate/teardown. Can be added when agent lifecycle API supports it.
Concurrency Single-writer recommended for .dal/fleets.json. Multiple processes writing may overwrite; use one runner/CLI at a time or add advisory file locking (e.g. fs2) if needed.

Summary