Skip to content

Component Contract

llms.txt lists every page for an agent

A component is declarative data. Its deploy is a composition of capabilities, not a script. The authoring form is TypeScript; it projects to a portable JSON contract that a non-chant or legacy component can hand-write and the same orchestrator can drive.

interface Component {
name: string;
dependsOn: string[]; // ordering only — no logic
build?: BuildSpec; // optional: source → BuildArchive (image/zip/jar, held in the archive)
deploy: Phase[]; // the component's own composition over shared capabilities
// verify + rollback fall out of the capabilities used
liveNames?: string[]; // optional: live entity/resource name(s), when they differ from `name`
composites?: string[]; // optional: composite kind(s) this component deploys, when a consumer can't infer it from `name`
environments?: ComponentEnvironmentDeclaration[]; // optional: where a release goes, by environment
inputs?: { // optional: what a deploy is made from, so an unchanged one is skipped
paths?: string[];
params?: string[];
normalize?: { paths: string[]; command: string }[];
};
}

build is optional: a config-only component has none. deploy is a composition using the same grammar as Ops — phases, parallel, gate, onFailure, dependsOn. See Composition & Wiring.

One component as four phases — build, publish, apply, verify — annotated with the three archetypes: service, infra, and producer/library. One component as four phases — build, publish, apply, verify — annotated with the three archetypes: service, infra, and producer/library.
A component's phases, and the three archetypes that use different subsets of them.

Because deploy is a composition, build-only and apply-only shapes are first-class, not special cases.

ArchetypePhasesExample
Servicebuild → publish → apply → verifyAn ECS service behind an ALB
Infraapply → verify (no build)A DynamoDB table, an EMR cluster, RDS/OpenSearch
Producer / librarybuild → publish (no service apply)A Java/JAR build published to S3 for EMR

A producer emits an artifact other components consume; its deploy is a single Publish phase. See cross-component wiring.

An ALB/ECS target: build an image, promote it at deploy time, apply the stack that registers the service on a shared ALB, wait for steady state. The shared-ALB values arrive as cross-stack outputs, resolved by the graph rather than by a describe-stacks shell script.

import { phase, type Component } from "@intentius/chant/components/component";
import { dockerBuild, publishImage, cfnDeploy, ecsUpdateService, waitSteadyState } from "@intentius/chant/components";
export const searchService: Component = {
name: "search-service",
dependsOn: ["shared-alb"],
build: dockerBuild({ context: ".", into: "archive" }),
deploy: [
phase("Publish", [publishImage({ from: "archive", to: "$env.registry" })]), // → digest
phase("Apply", [
cfnDeploy({ template: "archive:search.template.json",
inputs: { ...sharedAlb.outputs, image: "@Publish.digest" } }),
ecsUpdateService({ cluster: "$env.cluster", service: "search" }),
]),
phase("Verify", [waitSteadyState({ service: "search" })]),
],
};

The authoring form projects to a portable, versioned JSON contract. This is the substrate: the same document can be hand-written for a legacy component and driven by the same orchestrator.

{
"name": "search-service",
"dependsOn": ["shared-alb"],
"build": { "kind": "docker-build", "context": ".", "into": "archive" },
"deploy": [
{ "phase": "Publish", "steps": [{ "kind": "publish-image", "from": "archive", "to": "$env.registry" }] },
{ "phase": "Apply", "steps": [
{ "kind": "cfn-deploy", "template": "archive:search.template.json", "imageRef": "@Publish.digest" },
{ "kind": "ecs-update-service", "cluster": "$env.cluster", "service": "search" } ] },
{ "phase": "Verify", "steps": [ { "kind": "wait-steady-state", "service": "search" } ] }
]
}

A component is discovered the same way chant already discovers resources — by convention, from source, with no registration step. Export a Component (any export name) from a *.component.ts file anywhere under the project (excluding node_modules and a nested project’s own chant.config.ts scope) and chant finds it. archetype does not have to be authored explicitly: when omitted, chant infers it from the composition’s shape (a build present or absent, and whether every step in deploy is publish-family) — the same inference projectToJson applies before validating against the schema.

search-service.component.ts
export const searchService: Component = {
name: "search-service",
// archetype omitted — inferred as "service" (build + a non-publish Apply step)
dependsOn: ["shared-alb"],
build: dockerBuild({ context: ".", into: "archive" }),
deploy: [ /* … */ ],
};
Terminal window
chant list --components # inventory: name, archetype, dependsOn, phases
chant describe search-service --components # one component's full JSON projection
chant graph --components # dependency order + parallel-safe waves

A component may say where a release of it goes in each environment (#3153, ws-095). Each entry names an environment --env takes. Its other fields are optional and describe the site there: the runtime that hosts the release and the url it answers on. A domain names a custom domain attached to the release. A lifecycle names the git remote that its approval and ledger records are pushed to.

export const app: Component = {
name: "app",
dependsOn: [],
environments: [
{ name: "prod", runtime: "local" },
{ name: "fly", runtime: "fly", lifecycle: "origin", url: "https://shop.fly.dev", domain: "shop.example.com" },
],
deploy: [/* ... */],
};

A release Op that imports the component reads its environments directly. chant workspace graph --composites lists each one with its site, so a reader such as a deploy button needs no config key of its own. The member’s chant.config.ts environments still decide which names chant run --env accepts.

A component may say what a deploy of it is made from (#4695), so a release leaves it alone when none of that changed. This matters for a component whose deploy costs something even when nothing changed: a hub that drops every connection it relays when it restarts, say.

export const control: Component = {
name: "control",
dependsOn: ["platform"],
inputs: {
paths: [
"src/control.component.ts",
"src/control.fly.ts",
"../crates/control",
"../web",
":(exclude)../web/e2e",
"../Cargo.lock",
],
params: ["region"],
},
deploy: [/* ... */],
};

paths are git pathspecs read from the member’s directory, so :(exclude) and :(top) work as they do for git diff. params are build parameters by name. A run under a release compares them with the release the environment runs the component from. List the component’s own files among the paths when a change to its steps should deploy it. The files its deploy reads, as the cut records them (a fly-release plan, a template), are compared whether or not they are listed. A component that declares no inputs deploys with every release. Read by chant 0.124.65 and newer.

Some input files change in ways the component doesn’t care about. A release of another part of the repository may bump the repository’s own crate versions in every Cargo.toml and in Cargo.lock, and the hub that lists those files would then deploy with every such release. normalize names a command that each changed copy of a file is piped through before the two are compared (#4718):

inputs: {
paths: ["../crates/control", "../Cargo.toml", "../Cargo.lock", "src/control.component.ts"],
normalize: [
{ paths: ["../Cargo.toml", "../Cargo.lock", "../crates/*/Cargo.toml"], command: "scripts/release blank {path}" },
],
},

A file that changed between the two releases’ commits and that an entry’s paths match (git pathspecs from the member’s directory, as in paths) is read at each commit with git show and piped through the entry’s command. It counts as unchanged when the two outputs are the same bytes. When several entries match a file, the first one is used. An entry only covers files that paths lists. The command:

  • runs with sh -c from the repository’s top level in the checkout, the commit being released, so the same normalizer reads both copies (list the normalizer among paths when a change to it should deploy the component);
  • gets the file on stdin, and {path} in it is replaced by the file’s path from the top level, shell-quoted;
  • must print the same output for the same input.

A command that exits non-zero, is killed or runs past a minute counts the file as changed, and the run says which command failed on which file at which commit. A changed file that is missing at either commit, or that no entry matches, counts as changed the way it did before, and when there is one no command runs at all. A skip that needed a normalization lists each such file with its command in normalizedInputs on the skip record. Read by chant 0.124.68 and newer; an older chant ignores normalize and deploys the component when a listed file changed.

chant