Expand description
Run trestle environments on Docker Compose.
olai_stack_topology plans and renders an environment without touching Docker; this crate
is the part that runs it. The CLI and the desktop app share it.
ComposeEngine: what the runtime asks of Compose (up, down, ls, ps, logs, events, network removal).DockerCliruns thedockerCLI;FakeEngine(featuretesting) is an in-memory stand-in for tests.- Typed
ProjectStatus,ServiceStatus/HealthandEngineEvent, parsed from the CLI’s JSON output (the test fixtures are captured from real engines, seedocs/runtime.md). probe_host_ports: whether a plan’s host ports are free before starting it.managed_projectsandremove_mesh_if_idle: matching what Docker runs against what the caller manages.Instances: runs the revisions of anolai_stack_state::Storeas compose projects, side by side, with the layeredEffectiveEnvinjected and credentials resolved bySecretProviders (EnvProvider, andKeychainProviderbehind featurekeychain) andSourceoverlays.
Values that must not reach a file (credentials) go to Compose as process environment only:
every lifecycle call takes the variables to add (UpOptions::env).
use olai_stack_runtime::{ComposeEngine, DockerCli, UpOptions};
let docker = DockerCli::new();
let opts = UpOptions { wait: true, ..UpOptions::default() };
docker.up(std::path::Path::new("demo/dev"), &opts).await?;
for project in docker.ls().await? {
println!("{}: {}", project.name, project.status);
}Structs§
- Busy
Port - A host port a plan binds that something on this host already holds.
- Docker
Cli - Runs the
dockerCLI (with the Compose plugin). It honoursDOCKER_HOSTand the current Docker context like the CLI does;with_contextpins one. - Down
Options - How to
downa project. - Effective
Env - An instance’s resolved environment: every variable with its value and provenance. The
same resolution feeds what a UI shows (
masked) and what the instance launches with (launch_vars). - Engine
Event - One event about a container of a Compose project.
- EnvLayers
- The layers an
EffectiveEnvis resolved from, each a map of variables. Build it with thewith_*methods in any order; resolution appliesLayerorder. - EnvProvider
- Secrets from this process’s environment: the key is a variable name. Named
env. - Fake
Engine testing - An in-memory Docker:
upcreates a project with scripted services,downremoves it, and both raise the events Docker would. Clones share state, so a test can hand one to the code under test and inspect another. - Instance
Event - What happened to one service of an instance.
- Instances
- Runs the store’s instances on an engine. Each instance runs one revision in its own compose project, on its own slot and under its own host label, so two revisions of one environment run side by side:
- Keychain
Provider keychain - Secrets in the OS credential store (macOS Keychain, Windows Credential Manager, the Linux
kernel keyring), under one service name; the key is the account. Named
keychain. - LogLine
- One line a container logged.
- LogOptions
- How to read a project’s
logs. - Masked
Var - One row of
EffectiveEnv::masked. - Materialized
- What
Instances::materializeproduced. - Overlay
- What a
Sourcecontributes to an instance’s environment. - Project
Status - One Compose project Docker knows of (a row of
docker compose ls --all). - Published
- A host port a container publishes.
- Reconcile
Options - How
Instances::reconciletreats what it finds. - Reconciled
- What
Instances::reconcilefound. - Resolved
- A variable as resolved: its value, the layer it came from, and the lower layers it overrode (or, for a placement key, the layers that tried and were ignored).
- Secret
Providers - The providers a runtime resolves secrets with, by name. A reference to a provider that isn’t registered is an error: a missing keychain never silently falls back to another provider.
- Secret
Value - A secret’s value. Its
DebugandDisplayprint<redacted>. - Service
Status - One container of a project (a row of
docker compose ps --all). - Source
Ctx - What a source is asked for.
- Source
Error - Why a source failed.
- UpOptions
- How to
upa project. - User
Vars - The user’s own variables, as a source named
user: literal values only (secrets belong in the store as references).
Enums§
- EnvValue
- One variable’s value: plain, or a secret.
- Error
- What can go wrong driving a
ComposeEngine. - Event
Action - What happened to a container.
- Event
Filter - Which projects’ events to watch.
- Fake
Call testing - One call the fake received, for assertions.
- Health
- A container’s health, as its healthcheck reports it.
- Instance
Error - What can go wrong running an instance.
- Layer
- Where a variable’s value comes from, lowest precedence first. A higher layer overrides a
lower one, except over
Placement, whose keys nothing overrides. - Layer
Value - What one layer sets, before secrets are resolved.
- Progress
- Where a command’s progress output goes.
- Project
Match - Which projects a caller manages.
- Secret
Error - Why a secret couldn’t be resolved.
- State
- A container’s lifecycle state, as Docker reports it.
Constants§
- INSTANCES_
DIR - The directory under the state directory instances are materialized into.
- MASK
- What a masked secret shows as.
- PLACEMENT_
KEYS - Keys the placement reserves in an instance’s environment: no layer overrides them.
- PROJECT_
LABEL - The label Compose puts on every container with its project’s name.
- SERVICE_
LABEL - The label Compose puts on every container with its service’s name.
Traits§
- Compose
Engine - Docker Compose, as the runtime drives it.
DockerCliruns the real CLI;FakeEngine(featuretesting) is an in-memory stand-in. - Secret
Provider - Where secret values live. The store holds
SecretRefs naming a provider and a key; the provider resolves them at launch. - Source
- Something outside the store an instance takes variables, endpoints and credentials from, as an overlay on its environment (a Neon branch, say: its Postgres URL, its object-storage endpoint and vended keys, its function URLs). An instance names the sources it takes; they apply in that order, above the store’s vars and below the instance’s own overrides.
Functions§
- instance_
project - The compose project of revision
revisionofenvinworkspace. - is_free
- Whether
portcan be bound on every interface, as Docker publishes by default. - managed_
projects - The projects Docker knows of (running or stopped) that
whichpicks. - parse_
event - Parse one line of
docker events --format '{{json .}}'.Ok(None)for an event that isn’t about a Compose container, and for theexec_*events every healthcheck probe raises. - parse_
instance_ project (workspace, env, revision)of an instance project name, if it is one.- parse_
log_ line - Parse one line of
docker compose logs --timestamps --no-color, e.g.web-1 | 2026-11-02T19:55:16.807260250Z tick 1. A line without the<container> |prefix is kept whole as the text, with no container. - parse_
ls - Parse
docker compose ls --all --format json: a JSON array of projects. - parse_
ps - Parse
docker compose ps --all --format json. Compose prints one JSON object per line; some versions print a single JSON array instead, which is accepted too. - probe_
host_ ports - Every host port
planbinds that can’t be bound right now, so a start can be refused before Compose fails half-way. A check, not a reservation: the port can be taken between the probe and the start. - remove_
mesh_ if_ idle - Remove the shared
networkonce none ofmembersis known to Docker any more; returns whether it was removed.
Type Aliases§
- Engine
Stream - A stream of items from a long-running command; dropping it stops the command.
- Result
- The crate’s result type.