Appearance
0010. A run works in its repository's devcontainer, on a rootless Podman service ​
Status: Accepted (2026-10-01), an owner decision ("Can't we use devcontainers to build work environments?", then "Go with 7b after slice 7"). It follows the orchestration layer's ADR 0028 (devcontainer.json is the workspace environment contract), which decides what; this record decides how adam-rs does it. The defaults listed under Defaults the owner may revisit were chosen by the plan, not by the owner. Built: the crate adam-devcontainer (DevContainer, an Environment of adam-workspace), the Podman service of the dev stack, their tests and CI job, and the coder's use of them (its configuration, its tools, OpenCode inside, the image, the end to end). The status notes at the end say which change built what.
Amended 2026-10-11 (ADR 0038, not built yet): the coder no longer runs OpenCode in a devcontainer. The tools directory holds adam-exec only, and decision 6's model-key file /run/adam/secrets/model-key goes: no secret enters a devcontainer. The OpenCode CLI of the image stays on PATH, for people and repositories that want it.
Superseded in part 2026-11-19 (ADR 0052, not built yet): the owner's hard cutover removes the Podman path. The crate adam-devcontainer, DEVCONTAINER_* and CONTAINER_HOST, the devcontainer CLI and podman-remote in the image, the Podman service of the dev stack, its CI job and scenarios, and rebuild_environment go; DEVCONTAINER_RUNTIME=podman becomes exit 78. Decision 3's lookup of the file is kept and moves to adam-workspace; adam-exec moves to adam-env-kubernetes. A repository's own environment is now a run pod of its image, through use_repository_environment, offered only with run pods, an allowed image prefix and a configuration in a writable slot. The rest of this record is history.
Context ​
The coder runs every command in its own container: run_command, run_checks, OpenCode, and every command OpenCode starts. One image has to carry the toolchain of every repository it will ever meet, and a repository cannot say what it needs. Slice 7 built the seam for changing that without changing the tools: the Environment and EnvSession traits of adam-workspace (crates/adam-workspace/src/environment.rs), with Local (the coder's own container) as the one implementation, the janitor that releases an environment before it removes the run's workspace, and the order slots joined a run (Slot::seq). This record is the second implementation.
The facts below are what the decision rests on. Each says how it is known.
The devcontainer CLI (@devcontainers/cli 0.89.0, MIT, no runtime dependencies):
- Verified 2026-10-01 by reading its own
--help(npm package 0.89.0) and its source at the tagv0.89.0(src/spec-node/devContainersSpecCLI.ts,src/spec-utils/log.ts):up,read-configuration,run-user-commandsandexectake--docker-path,--workspace-folder,--config,--override-config,--id-label(repeatable; "set on the container and used to query for an existing container"),--mount-workspace-git-rootand--log-format text|json.upalso takes--remove-existing-container,--skip-post-create,--no-lockfile,--gpu-availability all|detect|noneand--container-session-data-folder;read-configurationtakes--include-merged-configurationand has no--container-session-data-folder;exectakes--remote-envand--default-user-env-probeand not--container-session-data-folder. There is nodownorremove.upprints one JSON line on standard output,{"outcome":"success","containerId","remoteUser","remoteWorkspaceFolder"}or{"outcome":"error","message","description",...}with exit code 1;read-configurationprints{"configuration","workspace","featuresConfiguration","mergedConfiguration"};run-user-commandsprints{"outcome":"success"|"error",...}. Logs go to standard error, and with--log-format jsoneach line is{"type":"text"|"raw"|"start"|"stop"|"progress","level","timestamp","text"}. A lifecycle hook announces itself asRunning the <hook> from <origin>....exec <cmd> [args..]reads its arguments with an option parser (an argument such as--versionafter the command is parsed unless something stands before it), and with--log-format jsonit uses a terminal.- For Podman, the CLI adds
--security-opt label=disable, and--userns=keep-idwhen the effective user (theremoteUser, else--user, else the image's user, else root) is not root (the bundle's functionuW).
- Verified 2026-10-01 by running it, in the slice 7b planning (Docker 29.6.2, kernel 6.18, the CLI 0.89.0,
quay.io/podman/stable:v5.8.7-immutable; not re-run for this change, which was written where no Podman runs, and the CI jobdevcontainerrepeats it):--override-configsupplies the content while the config file's directory stays the repository's, so a relativebuild.dockerfileresolves there; without--no-lockfilethe CLI writesdevcontainer-lock.jsoninto the worktree;execwith a text log passes standard input and output through and returns the exit code; killing theexecclient leaves the process inside running;podman rm -fmay print an error ("removing exec sessions ... openByHandleAt failed") and still remove the container.
Rootless Podman in a container (the same planning runs): with Docker's default seccomp profile nested containers fail (cannot clone); with containers' seccomp.json (which allows unshare, clone, clone3 and mount) and systempaths=unconfined (else crun: mount proc) they run, as uid 10001, with --userns=keep-id (files in a bind-mounted directory stay 10001's outside), --network=none and the shared network namespace; there is no /dev/fuse (storage is native overlay on the volume) and pasta needs /dev/net/tun, which is not given. The service (podman system service) makes a socket of mode 0600. No privileged, no cap_add, no devices were needed. The docker-default AppArmor profile has deny mount, (moby/profiles apparmor/template.go), hence apparmor=unconfined.
What this change checked itself (2026-10-01):
- The pinned image:
quay.io/podman/stable:v5.8.7-immutableis the manifest listsha256:f345d8d4fddea244d3a1ced27bcec82d14cc9e32cb5ead7f5882b0baf59dc8b0(quay.io's API). - The seccomp profile: Podman v5.8.7's
go.modrequiresgo.podman.io/common v0.67.2; the profile iscommon/pkg/seccomp/seccomp.jsonof containers/container-libs (the successor of the archived containers/common) at that tag, commit62c711d302a4349b959816d5f3d1b5d8b3a7df73, sha2562598b3b9...(dev/podman/README.md). It allows the same syscalls as the copy the planning used, with more rules that refusesocketfor some address families. - The shapes of
podman inspect(HostConfig.Privileged,CapAdd,SecurityOpt,Devices,NetworkMode,PidMode,IpcMode,UsernsMode,Mounts[].Type|Source|Destination|RW,ImageName,State.Running),podman ps --format json(Id,State,Labels) andpodman images --format json(Names), against Podman v5.8.7's own source (libpod/define/container_inspect.go,libpod/container_inspect_linux.go,pkg/domain/entities/types). Two things the source says that a guess would have got wrong:UsernsModeis"private"or empty and neverkeep-id("TODO: Rootless has an additional 'keep-id' option, presently not reflected here"), sokeep-idis derived from theremoteUserthe CLI reports, and nothing depends on it (the release maps ids through the container's own id map); andIpcModeishostwhen the spec has no IPC namespace, which is the case when the service'scontainers.confsaysipcns="host".
Unverified, to be checked by the CI job devcontainer and by the e2e of the next changes:
- Ubuntu 24.04 runners set
kernel.apparmor_restrict_unprivileged_userns=1, which the service needs off (a secondary source, marcioapm/lux#35). Where it stays on, the coder falls back toLocalwith a step: it degrades, it does not break. Podman's remote client of the distribution against the 5.8.7 server.Settled 2026-10-01 by the CI job: Ubuntu 24.04'spodman-remoteis 4.9.3; it pulled and inspected, but the CLI's image build against the 5.8.7 service hung until the timeout. The client is the staticpodman-remoteof the same release as the service (containers/podman v5.8.7,podman-remote-static-linux_amd64.tar.gz, sha25601b5ac59…5e7efrom the release'sshasums, verified 2026-10-01), in CI and in the coder's image.- Settled 2026-10-02 by the CI job: a container's
/proc/self/uid_mapis relative to the rootless service's own user namespace, not to the host's. Handing the coder's host uid (10001) toadam-exec chowngave the workspace to 110000 (a subuid) and the coder could not delete it.releasenow first numbers the ids as the service does (host.idMappingsofpodman info: the service's own user, which is the coder's, is 0), and leaves the files alone, with a warning, when the service has no number for them. - That Compose resolves the relative path
seccomp=./dev/podman/seccomp.json(PODMAN_SECCOMPoverrides it). - DNS to a compose service name from a devcontainer in the service's network namespace; egress from nested containers.
- That the inspect check does not refuse a container for a
SecurityOptthe service'scontainers.confadds (the check names the option it refused, so the first run says), and that the nested container'sMountshas no bind of the service's/proc(the upstream image's user-levelcontainers.confadds one; theagentuser ofdev/podman/Containerfilehas none, and the inspect check refuses a bind that is not ours either way). git statusinside a slot whose mirror is read-only; OpenCode's native binary inside a glibc image (the coder's change: its end to end,dev/coder-e2e.shSCENARIO=devcontainer, runs OpenCode there).
Decision ​
- A new crate,
adam-devcontainer, implementsEnvironment.DevContaineris a composition of two commands it does not link to: the devcontainer CLI and Podman's remote client, run as child processes. The crate has no dependency on an agent host, a gateway product or a container SDK; the only new dependency isjsonc-parser(MIT), for the file's comments and trailing commas. A binary chooses it at build and configuration time (DEVCONTAINER_RUNTIME=podman); there is no plugin. - The seam is the one slice 7 built (
crates/adam-workspace/src/environment.rs, as built, not as first sketched):ExecSpechas ahidelist (names of the caller's own variables a process must not see),Local::killdoes nothing,ExecIdis a string, and the janitor releases the runsheld_runs()returns that are over.DevContainermakes aPreparedCommandthat isdevcontainer execwith an empty environment plus an allow-list, and the file tools and git stay in the coder. The one addition toadam-workspacewasWorktree::mirror(), which an environment that runsgitin a worktree needs (the.gitfile of a worktree points into the shared bare mirror); the coder's change adds two defaulted methods to the port (see the 2026-10-02 status note). - Which file. The first slot in
Slot::seqorder decides, once, for the whole run; a scratch slot counts. The lookup is.devcontainer/devcontainer.json,.devcontainer.json, then the first of.devcontainer/<folder>/devcontainer.jsonin sorted order (a step names the others). A first slot with none getsSettings::default_image. Later repositories are mounted into the same container and their own devcontainer is ignored (a step says so). A workspace of the older layout staysLocal. - The file is untrusted, and the policy is checked three times (on the file, on
mergedConfiguration, onpodman inspectof the container made, which has the last word and removes the container). Refused:privileged, a capability other thanSYS_PTRACE, asecurityOptother thanseccomp=unconfinedandlabel=disable, abindmount,volume-optandvolume-driver, a mount over/opt/adamor/run/adam,dockerComposeFile,runArgsoutside a short list, a label of the coder's prefix,build.options, and a build context, Dockerfile or local feature that leaves the repository (the last two are additions to the plan: a build context of../../..would put the workspace root, with every other run and the coder's own files, into an image).initializeCommandis removed;appPort,forwardPortsandportsAttributesare removed;workspaceFolder,workspaceMount,mountsandrunArgsare made asoverride_file.rssays. A configuration or Dockerfile path is read as the CLI reads it, relative to the file's directory, which--configkeeps the repository's. - The runtime is a rootless Podman service, never the host's Docker socket. The service container has no
privileged, nocap_addand nodevices(dev/podman/,dev/compose.devcontainer.yaml); it is the trust boundary and is trusted like the coder. One service serves one workspace volume, mounted at the same path in both. A deployment without one runs withDEVCONTAINER_RUNTIME=off, the default. - Credentials never enter. Every process of this crate starts with an empty environment and
PATH, aHOMEof its own,CONTAINER_HOST,LANG,TMPDIR. The GitHub token and App key stay with git in the coder;DATABASE_URL, the bearer tokens and the thread-tools token are not passed. OpenCode's model key is the file/run/adam/secrets/model-key(mode 0600, mounted read-only), named byEnvSession::secret_ref; no secret is on an argument list, and every log and error is scrubbed. - Nothing happens silently. Making an environment is one step (id
environment) that carries the CLI's phase, then "ready in N s" and the list of changes made to the file, or the failure; other steps say that a repository joined, that the environment was lost and is made again, which devcontainer is used, and that the run is in the coder's own environment and why. A broken file is an error that names the file and the key or phase, carries the last 40 lines of the log (scrubbed), and is kept (Broken) until the file changes orrebuildis called: no silent fallback to the default image. - Teardown.
release(run)gives the tree back to the coder's ids (adam-exec chown, mapped through the container's id map), removes the run's containers by label and checks by listing (rm -fexit codes are not trusted), removes thevsc-*images the CLI built for the run (never a pulled base image) and the run's directory.held_runs()finds orphans by label and by directory, for this deployment only. Process cleanup has three backstops, since killing theexecclient does not stop what it started:adam-exec kill(the process, its descendants and, when it leads a group, its group), then the container's removal. - Kubernetes stays
Localuntil the platform has a sandbox provider. Amended 2026-10-05: ADR 0019 gives Kubernetes its own environment, a pod per run (RUN_ENVIRONMENT=kubernetes, the crateadam-env-kubernetes), which is not this one: a repository'sdevcontainer.jsonis not used in a run pod, and the two are never on together (DEVCONTAINER_RUNTIME=podmanwith it is refused). Without that opt-in, Kubernetes staysLocalas decided here.
The sequence ​
The lifecycle ​
state.json (<root>/environments/<run>/) keeps the phase, the digest of the file, the slots the container was made with, the container and its image, and a Broken error. Every ensure on Ready checks with one podman ps that the container is there and running; a container that is not is made again (--remove-existing-container, and the repository's lifecycle commands run again). A probe's answer is reused for 30 seconds; a run that fell back to Local stays there, so that its commands do not change environment half way. An ensure is single-flight per run (an in-process lock, then a flock of <run dir>/lock), and the caller may drop it: a half-made environment is Building in state.json and is made again, with its partial container removed by label.
Amended 2026-11-19: the check is cached for 3 seconds (Settings::alive_ttl): only a positive verdict is remembered, keyed by the run and the container id, and build, rebuild and release forget it. A command in a container that dies inside the window fails rather than running elsewhere; the first ensure after the window sees it gone and makes the environment again (Again::Lost).
Defaults the owner may revisit ​
| Id | Topic | Default | Alternative |
|---|---|---|---|
| OD-B1 | Compose-based devcontainers | Refused, with a clear error | docker compose against the Podman socket: needs the compose CLI in the coder and the policy on every service |
| OD-B2 | Privileges | capAdd only SYS_PTRACE; securityOpt only seccomp=unconfined and label=disable, both under the service's own filter; privileged, other capabilities and binds refused (so no Docker-in-Docker) | Refuse those too, which breaks the official rust, go and cpp features |
| OD-B3 | A repository joins the run | Recreate the container, so the mirror is mounted and the lifecycle commands run again | No restart, and no git inside the slot that joined late |
| OD-B4 | A broken file | An error, and the person decides (rebuild(run, use_default)) | Fall back to the default image on its own, with a warning step |
| OD-B5 | The read-only mirror | Mounted, so git can read inside; it also shows other runs' local branches of the same repository | No mirror, and no git inside |
| OD-B6 | A toolchain devcontainer feature | None; the toolchain stays in the workspace image, and the one tool the agent needs inside, OpenCode, is mounted | A small opencode feature, for musl images |
| OD-B7 | The default image in tests, and pruning | The small MCR base image in the stack and in CI; the workspace image in production; per-run images are removed, pulled base images stay | Test with the real image every time (about 9 GB more per runner) |
| OD-B8 | The container's network | The service's own (--network=host), which the deployment limits | none by default, which needs a per-run model proxy in the coder |
| OD-B9 | No runtime | Run in the coder's own environment, with a visible step | Fail closed when the repository declares a devcontainer |
| OD-B10 | (added here) A file with a path that leaves the repository | Refused (build.context, build.dockerfile, local features), and build.options | Allow a context above the repository, which puts other runs' files into an image |
Consequences ​
- A repository says what it needs, in a file other tools read; the coder's image no longer has to be every repository's environment. The cost is a Podman service beside every coder (images are stored a second time, the first run of an environment pays for a pull or a build), and a host may need a setting (the Ubuntu sysctl).
- Where the service cannot run, the coder degrades to its own environment with a step that says so.
- A new class of untrusted input is accepted, and the policy is the control. The residual risks are the plan's: an escape lands in the Podman service, which sees every run's
/workand its socket but holds no GitHub credential; there are no per-container limits (nested cgroups are off), so one run's build can slow the others and the service's owncpus,mem_limitandpids_limitbound them all; a process that leaves its parent and its group inside the container stays until the container is removed; the mirror shows other runs' local branches of the same repository (OD-B5). It is not isolation between tenants: stronger isolation (a service per run, gVisor, the platform's sandbox) comes after the MVP. - The inspect fixtures of the unit tests are hand-written in Podman's documented shapes, so the gated test and the CI job are the proof that a live Podman answers as they do.
Alternatives rejected ​
- envbuilder (builds a devcontainer from inside a container): its README says it is in maintenance mode (ADR 0028, verified 2026-10-01). The official CLI is the reference implementation.
- The host's Docker socket: it would hand the coder, which holds credentials, control of the host's containers.
- A privileged or Docker-in-Docker service: not needed (see the facts above).
seccomp=unconfinedfor the service: broader than the containers profile, which is enough.- The upstream image's
/procbind into nested containers, instead ofsystempaths=unconfined: a devcontainer would see every run's processes and read the environment of any process with the same uid. - Reading the state of a run from Podman only (no
state.json): aBrokenenvironment has no container to ask, and the digest of the file that broke it has to be somewhere. - Parsing
podman inspectforkeep-id: Podman does not report it (see the facts).
Status notes ​
2026-10-01: built in the crate adam-devcontainer (README.md there): DevContainer, Settings, Runtime, Network; the policy, the override file, the state, adam-exec; dev/podman/ (the service, the pinned seccomp profile), dev/compose.devcontainer.yaml; unit tests, stub-based tests of every call, the gated test against a real Podman, and the CI job devcontainer. Not built: the coder's configuration (DEVCONTAINER_*), its tools and their routing through the environment's session, OpenCode inside the container (AcpCommand cannot clear its environment yet), the rebuild_environment tool, the janitor's use of held_runs, the image with the CLI and Podman's client, the fixtures local/devbox and local/devbox-broken for the end to end, and the orchestration layer's end to end (slices 7b-2, S7b-1 and S7b-2). The facts marked unverified above have not run yet in this repository.
2026-10-02: the coder uses it (slice 7b, A7b-2; bin/adam-coder/README.md, "The work environment"):
- Configuration and start.
DEVCONTAINER_RUNTIME(offby default, orpodman),CONTAINER_HOST,DEVCONTAINER_DEFAULT_IMAGE(default: theworkspaceimage ofanother-agentic-imagesthe coder is built on, by digest only, verified 2026-10-01 by an anonymous manifest request and its config'sdevcontainer.metadatalabel; the devcontainer CLI 0.89.0 cannot parse a reference with both a tag and a digest, which CI's real-Podman job found, so a value for it isname@sha256:...too; a test keeps the tag that digest was published as equal to the Dockerfile'sWORKSPACE_TAG),DEVCONTAINER_NETWORK,DEVCONTAINER_DEPLOYMENT_ID, the two timeouts,DEVCONTAINER_PREPULL,DEVCONTAINER_CLI,DEVCONTAINER_PODMANandOPENCODE_BINARY(a native executable, checked at start): an invalid value is exit 78, nothing connects first. A start withpodmanwrites the tools directory (a failure stops it), probes the service (a service that does not answer is a warning: runs fall back to the coder's own container, with a step, until it does) and pulls the default image in the background.DevContaineris the coder'sEnvironmenteven with the runtimeoff, which is how a repository that has a devcontainer is told, once per run, that this deployment does not use it. - Routing.
run_command,run_checksanddelegate_to_opencodewent through the session already (slice 7); what this change adds is OpenCode from where the environment has it (EnvSession::tool_path), its key as{file:...}(EnvSession::secret_ref),AcpCommand::clear_envfor the CLI's own empty environment,opencode --versiononce per environment (a musl image gets a refusal and the other tools go on), the refusal underDEVCONTAINER_NETWORK=none, theenvironment {kind, source?, image}of thechecksartifact, and a missing tool's answer that says which environment lacks it. A broken environment is a permanent error that tells the model to ask the person (OD-B4: no fallback), andrebuild_environment {use_default?}is the way out. The port gained two defaulted methods for this,Environment::rebuild(run, use_default) -> boolandEnvSession::tool_path(name), besideWorktree::mirror()of decision 2. - Image and stack. The coder image has
@devcontainers/cli0.89.0 and the staticpodman-remoteof containers/podman v5.8.7, the service's own release, pinned by the release's sha256 (the settled finding above; a distribution's package is not used), and its smoke test and the container smoke test check both and that the OpenCode onPATHis an ELF. The fixtureslocal/devboxandlocal/devbox-brokenare on the dev git-server, the mock scripts[mock:devcontainer],[mock:default-env],[mock:broken-env]and[mock:no-runtime](and OpenCode's[mock:oc-devbox]) are indev/wiremock/mock-openai, anddev/coder-e2e.shrunsSCENARIO=devcontainer,default-env,broken-envandno-runtimein CI'scoder.yml. - Not verified here, and why. This change was written where no rootless Podman runs and the coder image does not fit. The unit and stub-based tests, the coder's tests against a fake environment, the binary's start against a service that does not answer, and the mock scripts (against a WireMock, both ways) ran; the facts marked unverified above (the sysctl, DNS and egress from a nested container, OpenCode's binary in a glibc image,
git statusover the read-only mirror) and that the static client in the coder image reaches the service are the end to end's to show, in CI'scoder.yml. - Kubernetes keeps
DEVCONTAINER_RUNTIME=off(decision 9); the chart sets nothing and its README says why. - Not built: the orchestration layer's end to end (S7b-2), and a periodic
podman image prune(the release removes the run's own images; the layers a failed build leaves are the operator'spodman system prune, because another worker may be building on the same service).