Skip to content

op: a shell step can run in a container pinned by digest (#4015) - #4176

Merged
lex00 merged 1 commit into
mainfrom
op/4015-container-shell
Oct 21, 2026
Merged

lex00 merged 1 commit into
mainfrom
op/4015-container-shell

Conversation

@lex00

@lex00 lex00 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Builds the two "build" items from the #4015 write-up.

A shell step in a container

shell(cmd, { image, mounts?, outputs? }):

  • image must be <ref>@sha256:<digest>. The local executor runs the command with docker run --rm, or the CLI CHANT_CONTAINER_CLI names (podman), as the host's uid and gid.
  • The step's working directory is mounted at /workspace, read-only unless mounts: { workspace: "rw" }.
  • Each outputs entry is a directory under the working directory. It is created on the host if missing and mounted writable at the same path, so what the command writes stays on the host. A directory the command leaves empty fails a step that otherwise passed. A writable mount inside a read-only bind needs its mountpoint to exist, which is why outputs are directories made beforehand rather than files copied back.
  • The container sees the step's env by name and none of chant's environment. okExit, gatedExit and json behave as before.
  • The run ledger keeps image on the step record (OpRunStepRecord.image).
  • OPS018 refuses an image that is not a literal pinned by digest, across main phases, onFailure and effect steps.
  • TerraformApplyOp and TerraformAdoptOp take compensate: { command, image }. Their other steps are their own activities, not shell commands, so this is the only shell step those builders write.

Gates and onFailure stay in chant's executor; only the command body moves into the container.

Docs

  • Ops reference: "A shell step in a container".
  • Lint rules: OPS018, and the overview range now ends at OPS018.
  • How chant compares: a "Pipeline engines" section with chant, Dagger and Bazel, and the build-time versus run-time argument. The CI room links it and gains a line on compiling to the forge's own YAML.
  • The sentence baseline gains one colon-reveal in lint-rules/correctness.mdx, from the page's own **Severity:** error convention on the new entry (and drops a stale em-dash count in cli/import.mdx).

Tests

  • Unit: containerCommand lines for ro and rw workspaces, digest checks, refusals before anything runs, the contract, the builder, OPS018, the ledger record and both terraform composites. vitest --project unit over packages/core/src/op, packages/core/src/lint, run-ledger and lexicons/terraform: 3567 passed, 23 skipped.
  • e2e: packages/core/src/op/activities/shell-container.e2e.test.ts runs alpine 3.21 by digest. It checks the workspace is read-only, env passes by name only, an output directory lands on the host, an empty output fails, and exit codes and okExit hold. It skips when Docker isn't running. Passed locally, and no containers were left.
  • tsc -p packages/core, check-lexicons (terraform 24/24), docs sentence lint, citations, prompts and diataxis checks pass.

Refs #4015.

shell() takes image (<ref>@sha256:<digest>), mounts and outputs. The
local executor runs the command with docker run --rm (or
CHANT_CONTAINER_CLI), the working directory read-only at /workspace
unless mounts says rw, each output directory mounted writable, and the
step's env passed by name. The run ledger keeps the image on the step
record. OPS018 refuses an image that is not a literal pinned by digest.
TerraformApplyOp and TerraformAdoptOp pass compensate.image through.

Docs: the container step in the Ops reference, OPS018, and a pipeline
engines section (Dagger, Bazel) in How chant compares, linked from the
CI room.
@lex00
lex00 merged commit a24eebc into main Oct 21, 2026
12 checks passed
@lex00
lex00 deleted the op/4015-container-shell branch October 21, 2026 04:08
lex00 added a commit that referenced this pull request Oct 21, 2026
…4198)

#4190's branch was built on 60faf26 but committed with 32dbb0d as its
parent, so its squash replaced the files those four PRs changed with their
older copies. This is the difference between 09a88b7 and the merge #4190
should have made (git merge-tree --merge-base 60faf26 0f57507 673cfb9),
applied onto main.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant