Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion docs/src/content/docs/concepts/comparison.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: How chant compares
description: chant compared with other infrastructure-as-code tools.
description: chant compared with other infrastructure-as-code tools and pipeline engines.
diataxis: explanation
---

Expand Down Expand Up @@ -138,6 +138,22 @@ The most consequential design difference after execution model is the lifecycle

**chant** optimizes for typed, linted, deterministic synthesis that's true to the underlying spec. Deployment is a separate step. The output is the platform's native format, with no lock-in. The trade-off: the build path itself doesn't apply, so you deploy through a chant Op or hand the artifact to your own tool.

## Pipeline engines

The tools above are compared on infrastructure. A pipeline engine asks a different question: where does the pipeline itself run? chant answers at build time. It compiles a typed pipeline to each forge's own YAML. The forge runs that YAML with nothing extra installed, and its own tooling keeps working.

| | Where the pipeline is defined | What runs in a CI job | Step isolation | Cache |
|---|---|---|---|---|
| **chant** | TypeScript, compiled to the forge's YAML | The forge's runner and the commands chant wrote | A `shell()` step can run in a container pinned by digest | The forge's |
| **[Dagger](https://dagger.io)** | Functions in modules (Go, Python, TypeScript and others) | The Dagger engine, in every job | Each operation runs in a container | Content-addressed, kept by the engine |
| **[Bazel](https://bazel.build)** | BUILD files in Starlark | Bazel, in every job | Sandboxed actions keyed by declared inputs | Local and remote, keyed by inputs |

Dagger moves the pipeline to run time: the forge's job starts the engine, and the engine runs the graph. That buys the same pipeline locally and in CI and a cache that knows each step's inputs. The cost is an engine in each job and a pipeline the forge sees only as one opaque step. Dagger also changed engines in 2026: v0.21 began replacing BuildKit's solver with its own, and a new module format is still in development.

Bazel is the reference for a hermetic step: an action runs in a sandbox and its cache key covers every input it declares. The price is declaring every input, which chant's steps don't do today.

chant stays at build time on purpose. A generated pull-request pipeline's jobs are typed values that each forge's generator wraps, and `chant ci run --local` runs the same values without reading YAML. [github-warden](https://github.com/INTENTIUS/github-warden) reads the job names chant generates and requires them as checks, which works because the jobs are the forge's own. Where a step needs a pinned toolchain, give it an `image` ([A shell step in a container](/chant/guide/ops-reference/#a-shell-step-in-a-container)). A Dagger runtime for Ops could plug into the `opRuntime` hook as a lexicon without changing this.

## Trade-offs

chant's design decisions have real consequences:
Expand Down
17 changes: 17 additions & 0 deletions docs/src/content/docs/guide/ops-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ Each step takes an optional `profile` that controls the step's retry and timeout

A step's own `timeout` sets how long one attempt may run, in place of its profile's, and keeps the profile's retries ([#2787](https://github.com/INTENTIUS/chant/issues/2787)). `shell("./build.sh", { timeout: "45m" })` is still one attempt, now of 45 minutes. `activity(fn, args, { timeout })` and a step literal's `timeout` field do the same. The value is a duration such as `45m` or `1h30m`, more than zero and at most six hours (`MAX_STEP_TIMEOUT`). A longer wait is waiting on a person, which a gate step is for. OPS012 flags a bad value at `chant build`, and the run fails the step if one gets that far. `op.json` carries the value on the step beside its `profile`.

### A shell step in a container

`shell()` with an `image` runs the command in a container instead of on the host ([#4015](https://github.com/INTENTIUS/chant/issues/4015)), so the step pins the toolchain it ran with.

```ts
shell("npm ci && npm run build", {
image: "node:24@sha256:<digest>",
outputs: ["dist"],
});
```

The local executor runs `docker run --rm`, or the command `CHANT_CONTAINER_CLI` names, such as `podman`. The step's working directory is mounted at `/workspace`, read-only unless `mounts: { workspace: "rw" }`, and the command runs there as your user. The container sees the step's `env` by name and none of chant's own environment. Each directory in `outputs` is created on the host if it is missing and mounted writable at the same path, so what the command writes there stays. A directory the command leaves empty fails a step that otherwise passed.

The run ledger keeps the image on the step's record, so a reader of the run can see what ran. The image must be pinned by digest; [OPS018](/chant/lint-rules/correctness/#ops018-shell-step-image-not-pinned) refuses a tag at `chant build`. Gates and `onFailure` stay in chant's executor; only the command moves into the container. `TerraformApplyOp` and `TerraformAdoptOp` take `compensate: { command, image }` for a rollback that runs the same way.

This isolates a step. An ephemeral machine per CI job is runner isolation, which `runner-start/v1` covers ([#4147](https://github.com/INTENTIUS/chant/issues/4147)).

## Labels

An Op's `labels` are its discovery keys: free-form `name: value` pairs that say what kind of Op this is and where it belongs. `ConvergeOp` sets `Converge: "true"` alongside an `Env`. `WatchOp` sets `Watch`. `chant operator --env <name>` filters on `labels.Env`, and `chant run list` prints whatever an Op declares.
Expand Down
18 changes: 18 additions & 0 deletions docs/src/content/docs/lint-rules/correctness.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,21 @@ phase("Wave 1", [gate("approve-tier-1", { plan: plan.out.planDigest, aliases: [{
```typescript
// ✅ Fixed: delete the upgrade-tier-1 Op once its gate moves here
```

## OPS018: Shell Step Image Not Pinned

A shell step that runs in a container ([#4015](https://github.com/INTENTIUS/chant/issues/4015)) has to name its image as a literal reference pinned by digest, `<ref>@sha256:<digest>`, or `chant build` refuses it. The run ledger keeps the step's image on its record, and a tag could name a different image by the next run, so the record would no longer say what ran. The check covers the main phases, the `onFailure` phases and the steps inside an effect.

**Severity:** error

```typescript
// ❌ Triggers OPS018, because node:24 is a tag that can move to another image
phase("Test", [shell("npm ci && npm test", { image: "node:24", outputs: ["coverage"] })]),
```

```typescript
// ✅ Fixed: pin the image by digest
phase("Test", [shell("npm ci && npm test", { image: "node:24@sha256:<digest>", outputs: ["coverage"] })]),
```

`docker buildx imagetools inspect node:24` prints the digest a tag points at now, which is the one to pin.
4 changes: 2 additions & 2 deletions docs/src/content/docs/lint-rules/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ chant's lint rules check what your declarations mean as well as how they are str
| **Evaluability** | EVL001–EVL005, EVL007, EVL009–EVL011 | Single file | Flag TypeScript patterns that cannot be statically evaluated |
| **Style** | COR001–COR009, COR012–COR015 | Single file | Structural and naming conventions |
| **Cross-File** | COR010–COR011 | Multi-file | Unused exports and circular dependencies |
| **Correctness** | COR003, COR004, COR007, COR008, COR017, COR021, COR022–COR026, OPS012–OPS017 | Single file / post-synth | Structural errors |
| **Correctness** | COR003, COR004, COR007, COR008, COR017, COR021, COR022–COR026, OPS012–OPS018 | Single file / post-synth | Structural errors |
| **Composite** | EVL009, EVL010, COR017, COR018 | Single file | Best practices for Composite() factories |
| **Composition** | COMP001–COMP007 | Whole component graph | Semantic checks over the discovered `Component` graph (epic #551 Phase 2) |
| **Decide backends** | SYS001, SYS010 | Single file / post-synth | A `decide` backend's key is never a literal, and never crosses plain HTTP to a remote host |
Expand Down Expand Up @@ -90,7 +90,7 @@ See [Disable Directives](/chant/lint-rules/disable-directives/) for details.
- [Evaluability Rules](/chant/lint-rules/evaluability/) — EVL001–EVL005, EVL007
- [Style Rules](/chant/lint-rules/style/) — COR001, COR002, COR005, etc.
- [Cross-File Rules](/chant/lint-rules/cross-file/) — COR010, COR011
- [Correctness Rules](/chant/lint-rules/correctness/) — COR003, COR004, COR007, COR008, COR021, COR022–COR024 (effect-receipt guards), COR025 (stringified reference), COR026 (stale knowledge binding), OPS012–OPS017 (Op model: activity contracts, step-output references, ConvergeOp rule-table refusals, gate approval blocks, gates that resume, gate aliases)
- [Correctness Rules](/chant/lint-rules/correctness/) — COR003, COR004, COR007, COR008, COR021, COR022–COR024 (effect-receipt guards), COR025 (stringified reference), COR026 (stale knowledge binding), OPS012–OPS018 (Op model: activity contracts, step-output references, ConvergeOp rule-table refusals, gate approval blocks, gates that resume, gate aliases, shell step images)
- [Composite Rules](/chant/lint-rules/composite/) — EVL009, EVL010, COR017, COR018
- [Composition Rules](/chant/lint-rules/composition/) — COMP001–COMP007, over the discovered `Component` graph
- [Decide backends](/chant/guide/decision-points/#lint-rules): SYS001 and SYS010, over the `decide` activity's backends
Expand Down
6 changes: 5 additions & 1 deletion docs/src/data/rooms.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export const ROOMS = [
'A generated pull-request pipeline that plans what a change reaches, posts the plan, and on merge applies only the plan a reviewer approved',
"`chant audit` reads a repository's existing pipelines and reports security findings, with a diff for each mechanical fix",
'`chant migrate` translates a GitHub Actions workflow into GitLab CI',
"Pipelines are compiled to the forge's own YAML at build time, so CI runs no extra engine and forge tooling such as required checks keeps working",
],
differs: {},
first: {
Expand All @@ -232,7 +233,10 @@ export const ROOMS = [
{ label: 'Per-PR Preview Environments', href: 'tutorials/github-pr-preview' },
{ label: 'GitLab CI + AWS ALB', href: 'tutorials/gitlab-aws-alb' },
],
background: [{ label: 'Components', href: 'concepts/components' }],
background: [
{ label: 'Components', href: 'concepts/components' },
{ label: 'Pipeline engines', href: 'concepts/comparison#pipeline-engines' },
],
reference: [
{ label: 'chant audit', href: 'cli/audit' },
{ label: 'chant migrate', href: 'cli/migrate' },
Expand Down
6 changes: 6 additions & 0 deletions lexicons/terraform/src/composites/terraform-adopt-op.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ describe("TerraformAdoptOp compensation (#2105)", () => {
expect((op.onFailure![0].steps[0] as ActivityStep).args?.cmd).toBe("./untag.sh");
});

test("a supplied image runs the rollback in that container (#4015)", () => {
const image = `alpine:3.20@sha256:${"b".repeat(64)}`;
const op = props({ ...base, compensate: { command: "./untag.sh", image } });
expect((op.onFailure![0].steps[0] as ActivityStep).args).toEqual({ cmd: "./untag.sh", image });
});

test("compensate: false and omitting it both leave no onFailure", () => {
expect(props(base).onFailure).toBeUndefined();
expect(props({ ...base, compensate: false }).onFailure).toBeUndefined();
Expand Down
9 changes: 7 additions & 2 deletions lexicons/terraform/src/composites/terraform-adopt-op.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ export interface TerraformAdoptOpConfig {
* object with no `command`, throws when the Op is built, naming the Op,
* rather than warning at the moment a rollback is already wanted.
*/
compensate?: boolean | { command?: string };
compensate?: boolean | {
command?: string;
/** Run the rollback command in a container pinned by digest (#4015), as `shell()`'s `image` does. */
image?: string;
};
}

export interface TerraformAdoptOpResources {
Expand All @@ -153,6 +157,7 @@ export interface TerraformAdoptOpResources {

export function TerraformAdoptOp(config: TerraformAdoptOpConfig): TerraformAdoptOpResources {
const compensateCommand = typeof config.compensate === "object" ? config.compensate.command : undefined;
const compensateImage = typeof config.compensate === "object" ? config.compensate.image : undefined;
if (config.compensate !== undefined && config.compensate !== false && compensateCommand === undefined) {
throw new Error(
`TerraformAdoptOp "${config.name}": compensate is enabled, but there is no automatic undo for an ` +
Expand Down Expand Up @@ -212,7 +217,7 @@ export function TerraformAdoptOp(config: TerraformAdoptOpConfig): TerraformAdopt
phase("Adopt", [adopt]),
],
...(compensateCommand
? { onFailure: [phase("Rollback", [activity("shellCmd", { cmd: compensateCommand })])] }
? { onFailure: [phase("Rollback", [activity("shellCmd", { cmd: compensateCommand, ...(compensateImage ? { image: compensateImage } : {}) })])] }
: {}),
});

Expand Down
6 changes: 6 additions & 0 deletions lexicons/terraform/src/composites/terraform-apply-op.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ describe("TerraformApplyOp compensation — total or refused (#2086)", () => {
args: { cmd: "terraform apply -input=false rollback.tfplan" },
});
});

test("compensate: { command, image } runs the rollback in that image (#4015)", () => {
const image = `hashicorp/terraform:1.9@sha256:${"a".repeat(64)}`;
const op = props({ name: "a", root: "app", compensate: { command: "terraform apply rollback.tfplan", image } });
expect(op.onFailure![0].steps[0]).toMatchObject({ fn: "shellCmd", args: { cmd: "terraform apply rollback.tfplan", image } });
});
});

describe("TerraformApplyOp on the local executor (#2086, gate-as-fact #2119)", () => {
Expand Down
9 changes: 7 additions & 2 deletions lexicons/terraform/src/composites/terraform-apply-op.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ export interface TerraformApplyOpConfig {
* rollback is already needed. Supply `compensate: { command: "..." }` with a
* rollback of your own, or leave it unset.
*/
compensate?: boolean | { command?: string };
compensate?: boolean | {
command?: string;
/** Run the rollback command in a container pinned by digest (#4015), as `shell()`'s `image` does. */
image?: string;
};
}

export interface TerraformApplyOpResources {
Expand All @@ -174,6 +178,7 @@ export function TerraformApplyOp(config: TerraformApplyOpConfig): TerraformApply
// fails here, at build time, with the Op named — not as a warning when the
// apply has already half-run. Same shape as ApplyOp's refusal (#1449).
const compensateCommand = typeof config.compensate === "object" ? config.compensate.command : undefined;
const compensateImage = typeof config.compensate === "object" ? config.compensate.image : undefined;
if (config.compensate !== undefined && config.compensate !== false && compensateCommand === undefined) {
throw new Error(
`TerraformApplyOp "${config.name}": compensate is enabled, but terraform has no automatic ` +
Expand Down Expand Up @@ -274,7 +279,7 @@ export function TerraformApplyOp(config: TerraformApplyOpConfig): TerraformApply
},
phases,
...(compensateCommand
? { onFailure: [phase("Rollback", [activity("shellCmd", { cmd: compensateCommand })])] }
? { onFailure: [phase("Rollback", [activity("shellCmd", { cmd: compensateCommand, ...(compensateImage ? { image: compensateImage } : {}) })])] }
: {}),
});

Expand Down
13 changes: 13 additions & 0 deletions packages/core/src/lifecycle/run-ledger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ describe("buildRunRecord", () => {
expect(input.phases[1].steps.map((s) => s.status)).toEqual(["ok", "skipped"]);
});

test("keeps a shell step's image on its record (#4015), and nothing for a step without one", () => {
const image = `node:24@sha256:${"c".repeat(64)}`;
const input = buildRunRecord(
{ name: "build" },
[
{ phase: "Build", fn: "shellCmd", args: { cmd: "npm test", image }, status: "ok", durationMs: 3 },
{ phase: "Build", fn: "shellCmd", args: { cmd: "echo hi" }, status: "ok", durationMs: 1 },
],
{ started: "2026-01-01T00:00:00.000Z", ended: "2026-01-01T00:00:01.000Z", status: "ok" },
);
expect(input.phases[0].steps.map((s) => s.image)).toEqual([image, undefined]);
});

test("carries the commit and the CI run origin when given (#4020), and neither when not", () => {
const times = { started: "2026-01-01T00:00:00.000Z", ended: "2026-01-01T00:00:01.000Z", status: "ok" as const };
const withBoth = buildRunRecord({ name: "ship" }, [], { ...times, gitSha: "a".repeat(40), runOrigin: { forge: "github", repo: "acme/app" } });
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/lifecycle/run-ledger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export function buildRunRecord(
...(record.point ? { point: record.point } : {}),
...(record.gate ? { gate: record.gate } : {}),
...(record.resumed ? { resumed: record.resumed } : {}),
...(record.fn === "shellCmd" && typeof record.args?.image === "string" ? { image: record.args.image } : {}),
});
if (record.outcome) outcomes[record.outcome.name] = record.outcome.value;
}
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/lint/rules/op/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { ops014 } from "./ops014-converge-rule-refusals";
import { ops015 } from "./ops015-gate-approval";
import { ops016 } from "./ops016-gate-resume";
import { ops017Check } from "./ops017-gate-alias";
import { ops018 } from "./ops018-shell-image-digest";
import { sys010Check } from "./sys010-key-over-plain-http";
import type { DecideBackend } from "../../../op/decide-config";

Expand All @@ -25,6 +26,7 @@ export { ops014 } from "./ops014-converge-rule-refusals";
export { ops015 } from "./ops015-gate-approval";
export { ops016 } from "./ops016-gate-resume";
export { ops017, ops017Check, workspaceIdentityGates } from "./ops017-gate-alias";
export { ops018 } from "./ops018-shell-image-digest";
export { sys010, sys010Check } from "./sys010-key-over-plain-http";

export interface CoreOpCheckOptions {
Expand All @@ -36,9 +38,9 @@ export interface CoreOpCheckOptions {

/**
* Core's own post-synth checks over the Op model: OPS012, OPS013, OPS014,
* OPS015, OPS016, OPS017 over the workspace's `identity.gates`, and SYS010
* OPS015, OPS016, OPS017 over the workspace's `identity.gates`, OPS018, and SYS010
* over the `decide` steps and the configured decide backends.
*/
export function coreOpChecks(opts: CoreOpCheckOptions = {}): PostSynthCheck[] {
return [ops012, ops013, ops014, ops015, ops016, ops017Check(opts.identityGates), sys010Check(opts.decideBackends)];
return [ops012, ops013, ops014, ops015, ops016, ops017Check(opts.identityGates), ops018, sys010Check(opts.decideBackends)];
}
Loading
Loading