Skip to content

Composition & Wiring

llms.txt lists every page for an agent

A component’s deploy is a composition over capabilities, expressed in the same grammar as Ops: phases run in order, steps in a phase run sequentially unless parallel, gate stops the run gated until the ledger carries its resolution, and onFailure compensates. Steps wire output to input so lint can check the graph before anything runs.

deploy: [
phase("Publish", [publishImage({ from: "archive", to: "$env.registry" })]), // → @Publish.digest
phase("Apply", [cfnDeploy({ template: "archive:t.json", imageRef: "@Publish.digest" })]),
phase("Verify", [waitSteadyState({ service: "api" })]),
]

A step may carry environments, keyed by environment name, with the inputs that differ there. Before the capability sees its input, chant merges the entry for the run’s environment over the step’s own keys, one level deep, and drops the map. The component stays the same in every environment, so chant components promote --to staging applies the staging target and records it under staging, and rollback and redeploy apply the target of the environment they name.

phase("Apply", [
{ kind: "terraform-apply", vars: { region: "us-east-1" }, environments: {
staging: { root: "envs/staging/network" },
prod: { root: "envs/prod/network", vars: { region: "us-east-2" } },
} },
{ kind: "pulumi-up", dir: "infra/shop", environments: {
staging: { stack: "acme/shop/staging" },
prod: { stack: "acme/shop/prod" },
} },
])

An environment the map does not name is refused before anything runs, and the refusal lists the environments it names. A pull request’s environment pr-<n> takes the entry of its template environment (ci.prEnvironment), and a pulumi-up step then derives its review stack from that entry’s stack. A step without environments runs as written in every environment.

A gate step takes environments too, naming the environments it applies in. One component then deploys to dev with no gate and waits for an approval in staging and prod:

phase("Apply", [
{ kind: "gate", gate: "release", environments: ["staging", "prod"] },
{ kind: "terraform-apply", environments: {
dev: { root: "envs/dev/network" },
staging: { root: "envs/staging/network" },
prod: { root: "envs/prod/network" },
} },
])

In place of a list, a map may set the gate’s gate, description or timeout per environment, as in environments: { staging: { description: "QA signs off" }, prod: { timeout: "72h" } }. Where the gate applies, it binds as any gate does: under --release, an approval counts only for that release, that environment and its change set. Elsewhere the run skips it and records the skip: the step record carries gateSkipped, the run event a step-settle with skip: "environment", the deploy record and chant workspace status --json list it under gatesSkipped, and promote --dry-run and --plan-only print it. A pull request’s environment follows its template environment. chant build refuses a gate that names an environment the member does not declare in chant.config.ts, its pipeline’s stages or the component’s own environments. A gate without environments applies in every environment.

Fan-out is composition, not orchestrator knowledge

Section titled “Fan-out is composition, not orchestrator knowledge”

A single component can expand to many units — one CloudFormation stack per instance in a cluster, one host in a fleet. The fan-out is authored in the composition, never known by the driver.

A fan-out unit is itself a small composition. One EC2 instance is provision (cfn-deploy) + code deploy (code-deploy) + health. A component that fans out over N instances composes N such mini-compositions, sequenced seed-first then rolling with a health gate between:

deploy: [
phase("Seed", [cfnDeploy({ stack: "neo4j-az0-0", template: "archive:neo4j.template.json" }), codeDeploy({ instance: 0, revision: "$env.appBundle" }), waitClusterHealthy({ size: 1 })]),
...followers.map((n) => // Array.map over instance configs
phase(`Node ${n}`, [cfnDeploy({ stack: `neo4j-${n}`, template: "archive:neo4j.template.json" }), codeDeploy({ instance: n, revision: "$env.appBundle" }), waitClusterHealthy({ quorum: true })]),
),
]
One component expanding into N per-instance mini-compositions — provision, code deploy, health — sequenced seed-first then rolling, with a health gate between each node. One component expanding into N per-instance mini-compositions — provision, code deploy, health — sequenced seed-first then rolling, with a health gate between each node.
Fan-out: one component composes N per-instance mini-compositions. Single-host is the N=1 case; a fleet is the same shape at N>1.

The driver never learns that a Neo4j cluster seeds first. If a composition ever needs an if component.name === … in the driver, the contract or a capability is missing expressiveness — fix it there, never in the driver.

For wiring one component’s data into another — cross-stack outputs and cross-component artifact references — see Wiring Components.

  • Wiring Components — cross-stack outputs and cross-component artifact outputs, the two ways components reference each other.
  • Build Archive — where a producer’s artifact lives before it is published.
  • Orchestration — how the graph order becomes a run.

chant