Appearance
0041. A run pod sees only its own run ​
Status: Proposed (2026-10-18). Built in the same change (adam-env-kubernetes, the chart's pod template and admission policy, the tests below); the decisions the owner must confirm are at the end, and what is unverified is marked. Amends ADR 0019: decision 2 (what the code fills in), decision 3 (the files), decision 7 (the admission policy), OD-K1 and the consequence "It is not isolation between runs". Builds on ADR 0008 (slots) and ADR 0010 (a path means the same in every environment), and qualifies ADR 0040 (the cache's trust domain).
Context ​
ADR 0019 gave each active run a pod for its commands and said plainly that this was not isolation between runs: the pod mounts the coder's whole workspace volume at /work, so that one owner's runs could share it. The coder is now to be offered to every user, so a command of one person's run must not see another person's run. What a run pod could reach on the volume, verified 2026-10-18 by reading crates/adam-workspace/src/workspace.rs (the layout) and deploy/coder/templates/_runpods.tpl at b819770:
| On the volume | A command could |
|---|---|
workspaces/<run>/<slot>/, every run's worktrees and scratch projects | read every other run's files (source of repositories the person never named) |
meta/<run>/, the slots' metadata | read their repository URLs and branches |
git/<host>/<owner>/<repo>.git, a bare mirror shared by every run of that repository | read every repository the coder ever mirrored, and write the mirror: its config, hooks/, info/attributes, refs and objects |
The write is worse than the read. The coder's own git runs in every run's worktree of that mirror. It starts from an empty environment, never runs hooks or an fsmonitor, and removed some configuration keys (url.*, remote.*, http.*, credential.*, core.sshCommand, ...) before a credentialed command (the first version's Inner::sanitize_mirror_config, which is gone: the mirror's configuration is now put back to what the workspace writes, crates/adam-workspace/src/mirror_config.rs); it did not stop a filter.* or diff.* command in the mirror's configuration, a rewritten ref (another person's unpushed agent/* branch) or a poisoned object. A run that writes the mirror reaches the coder and every other run of that repository.
KubeSession::prepare refuses a working directory outside workspaces/<run>, which is a check on the caller's request, not on what a command reads. The admission policy let any pod the coder made reference any key of the coder's Secret, or mount it, although the template uses MODEL_API_KEY only; the Secret also holds GITHUB_TOKEN, A2A_BEARER_TOKENS and the MCP tokens (externalsecret.yaml).
Decision ​
A run pod mounts the workspace volume only through
subPathmounts, at the same paths as in the coder.Mount (path in the pod and in the coder) Mode For <root>/workspaces/<run>read-write the run's slots <root>/git/<host>/<owner>/<repo>.git, for each worktree slotread-only the objects, refs and configuration a worktree's .gitfile points into<root>/git/<host>/<owner>/<repo>.git/worktrees/<name>, for each worktree slotread-write, mounted on top the worktree's HEADandindex, whichgit statusrefreshes.../worktrees/<name>/HEAD,commondir,gitdirandlogsread-only, mounted on top of that the branch the coder's resetmoves (decision 11), what itsgitfollows out of the directory (decision 7), what ties it to its slot, and the reflog it appends to<root>/workspaces/<run>/<slot>, for each slot, worktree or scratch project (added 2026-10-27, #125)read-write, mounted on top of the run's directory so that the slot's directory is a name the pod cannot rename, move, remove or exchange ( EBUSY): the coder'sgitfinds its work tree by nameNothing of
meta/, of another run, or of another repository's mirror is in the pod.<name>is<run>+<slot>(decision 9) and comes from the coder's metadata, never from the slot's.gitfile (decision 6). A bind mount of a file or of a directory cannot be written, renamed over, replaced by a link or removed from the pod (verified, decision 10), though the directory around it is writable and its files belong to the very uid that tries. A scratch slot is a repository inside the run's directory and needs nothing more. (Amended 2026-10-27: it needs a mount of its own like every slot, last row of the table; it still needs no git directories.) The legacy worktree of a run (<root>/worktrees/<run>) is outside the run's directory, wherepreparealready refuses a working directory, and gets no mount. A worktree whose directory in the mirror is not known (decision 6), or whoseHEAD,commondir,gitdirorlogsis not what git wrote (a link, a pipe, a missing file; a missinglogsis made by the coder), gets no git mounts and a warning in the log: less access is safe, and the nextensuretries again.The template marks the workspace by mounting its volume once, whole, at the workspace root; the code replaces that mount. This amends decision 2 of ADR 0019: the code fills in the pod's name, namespace, labels and annotations, and the mounts of that one volume; every other part of the template stays as the deployment wrote it (
PodTemplate::render). The mount is the run container's mount whose path is the workspace root (WORKSPACE_ROOT, or the worker's folder under it) or the closest directory above it. The coder refuses to start (exit 78, as for every template mistake) when there is none; when it has asubPath, is read-only, names a volume the pod does not have, or when the volume is mounted by any other container or a second time. Where the template mounts the volume is where thesubPaths start.The mounts of a pod are fixed when it is made, so a repository added later needs a pod made again. The pod's annotation
adam.vymalo.com/workspace-mountsrecords its mounts (rw <path>/ro <path>, one per line; the lines of a worktree's directory in the mirror end in@<generation>, below). Eachensurecomputes the mounts the run's workspace needs now and compares: a mount the pod lacks (a worktree slot added since; a pod of the earlier version, which has no annotation and mounts everything) is a reason to make the pod again, and a mount the pod has and the run no longer needs is not. A bind mount follows a directory and not its name: a slot whose directory was lost and added again has the same name for its directory in the mirror (decision 9) and a new directory under it, and the pod's mounts, whose lines would be the same, keep the deleted one, so git in the pod would see aHEADand an index that are not the coder's. So the coder records a generation in the slot's metadata (admin_gen, new each time it makes the directory: the time in nanoseconds and a count, in hex),Worktree::git_dir_generationsays it, and the lines of the directory and of its four read-only entries carry it: a changed generation is a mount the pod lacks. A slot made before the generation was recorded has none, and its lines are what they were.ensureasks the pod withadam-exec active: with no command running it deletes the pod and makes another (the files are on the volume, ADR 0019 decision 5); with one running, or when the pod cannot be asked, it answersEnvError::Unavailable, which the caller waits out as it waits for a slot (ADR 0019 decision 6, up toRUN_POD_WAIT_SECS). A command prepared a moment before is killed with the pod and fails; the model can run it again. Only a worktree needs a mount of its own: a scratch project, or a directory added inside the run's directory, is already visible. Amended (2026-11-16, ADR 0044 slice 16): a command that was started to outlive its call does not hold the pod. A development server a run starts withstart_commandhas an exec id that begins withbg-(ExecSpec::background).ensureandsealaskadam-exec active-fg, which leaves those records out, so a new slot makes the pod again while a server runs in it; the server ends with the pod, and the coder says so inlist_commands. The idle sweep still asksadam-exec active, which counts them, so a pod with a server in it is never idle (it is stopped by the run's end, a park on the person,BACKGROUND_COMMAND_MAX_SECSor the janitor). A pod of an image whoseadam-exechas noactive-fg(made by an older coder) answers its usage line, and is askedactiveinstead: every command holds it, as before. Amended (2026-10-27, #125, second change): every slot, a scratch project too, is a mount of its own (decision 1), so a slot added later, a scratch project started or taken over by a later task, needs a pod made again, and a scratch slot has a generation like a worktree's:dir_genin its metadata (Slot::generation; new when the coder makes the directory, when a lost one is made again, and when another run's project is taken over; absent from metadata written before it, and then the line of the slot is the one it always had). The file and git tools do not callensure, so the coder calls the new provided methodEnvironment::sealright after it adds a slot (prepare_workspace,start_scratch,publish_scratch, the take-over of a conversation's projects): the Kubernetes environment deletes a pod that lacks the mount when no command runs in it (the next command makes the new one) and never makes a pod; while a command runs it answersUnavailable, the slot stays, the tool's result says so, and the nextensuremakes the pod when the command ends.The run's directory is made by the coder before its pod is. A
subPaththat does not exist is made by the kubelet, as root.The admission policy allows exactly one Secret reference: one
secretKeyRefof the coder's Secret, by name (coder.secretName) and by the keyMODEL_API_KEY(onedefine, used by the template and the policy). It refuses a Secret volume,envFromof a Secret, and any othersecretKeyRef, so that no run pod holds a credential but the model key. Against a compromised coder this buys little (it holds those secrets itself); it is the check that a mistake in the template, or a change later, cannot putGITHUB_TOKENin a pod a command runs in. ADR 0038 removes even this key later and is not built here.The worktree's directory in the mirror is the coder's record, not a file the run can write. The
.gitfile of a slot is written by git, and then by whatever runs in the slot: a command that writesgitdir: <mirror>/worktrees/<B's name>into it would have the coder, at the next pod made again, mount run B's directory (itsHEAD,index,commondir) read-write into this run's pod, and tamper with B's run. So the coder records the name in the slot's own metadata (meta/<run>/<dir>.json, fieldadmin, which no pod mounts) when it makes the worktree: it lists the mirror'sworktrees/before and aftergit worktree add(under the mirror's lock; a pod cannot write that directory) and takes the one new entry whosegitdirnames the new worktree. The metadata version stays 2: the field is optional, old metadata reads as before and an older coder ignores the field. A record is believed only while it is still the run's: each time a slot is opened the recorded name must carry the run (decision 9), be a directory of its own (not a link, not a file), and itsgitdirmust name the slot. A record that fails this (the directory was pruned and the name given to another run's worktree, which is what a moved slot made possible before decision 9) leaves the worktree with no git directory. For a slot made before the record, the directory is the oneworktrees/*/gitdirthat names the slot's.gitamong the directories that carry no run (git's own names, from before decision 9) or this run, and is then recorded if it carries the run; none or several is no answer (a run can add a candidate by writing its owngitdir, so the worst it can do is make the answer none), and then the slot gets no git mounts and the coder's own git refuses it (WorkspaceError::Corrupt, "cannot tell which directory").Worktree::git_dirandWorktree::git_pinsay it.Every
gitthe coder runs on a slot is pinned to that record.GIT_DIR=<mirror>/worktrees/<name>,GIT_COMMON_DIR=<mirror>andGIT_WORK_TREE=<slot>are set on each (GitPin; the workspace's worktree commands,commit_all,push,publish,diff_stat, the coder'srun_commandsnapshot and restore,run_checks, the tree ids,git applyofapply_patch), so the slot's.git, and thecommondirandgitdirof its directory, which a run's commands write, steer nothing. A scratch project's pin is its own.gitfor both directories and requires that it be a real directory (a file or link a command put there to send git into another run's worktree or a mirror is refused). What pinning does not cover, and what is done about each:What git reads in a slot Result (git 2.43.0) Done .gitfile of the slotignored once GIT_DIRis set (verified: a clean filter planted in the repository it names did not run, and ran for an unpinnedgit add -A)pinned commondirof the worktree's directoryGIT_COMMON_DIRwins for the configuration, hooks, attributes and objects (verified: the planted filter did not run), but git's reference store still reads the file (refs/remotes/origin/mainwas "not a valid object name" withcommondirpointing at another directory)a read-only mount in a run pod, so a run cannot write it; the coder only checks it ( GitPin::check: a regular file, opened without following a link, that says../..) and refuses git on the worktree otherwise. It does not put the file back: the first version did, by opening the file a run can replace by a link, and wrote through the link to any file the coder can write (verified by a test that failed before)HEADof the worktree's directorydata, but git commitfollows it: a run that points it at another run's branch has the coder commit its files there (verified with a test that failed before); andresetfollows it too (decision 11)the commit is made with plumbing onto refs/heads/<the run's branch>, whateverHEADsays, with the old tip as the compare-and-swap (commit_all_in); the coder's snapshot and restore take the branch from the metadata (decision 11); and a read-only mount in a run pod, so a run cannot write itconfig.worktreeof the worktree's directoryread only with core.repositoryformatversion1 andextensions.worktreeConfigtrue in the common configuration (verified: with both, a filter in it ran; with format 0 it did not)the coder makes format-0 mirrors and never turns the extension on (a test pins both); extensions.worktreeConfigis among the keys the workspace removes from the mirror's configuration before a credentialed commandlogs/HEADof the worktree's directorygit appends to the file a link there names (verified with git 2.43.0: a line <old> <new> <identity> <time> <message>was added to a file that is not a log), which would corrupt any file the coder can write, the mirror'sconfigamong themlogsis a read-only mount in a run pod, andGitPin::checkrefuses a worktree whoselogsorlogs/HEADis a link or a pipe (a check, not a seal, where nothing is mounted)indexdata: no command named in it runs ( core.fsmonitoris forced off); the coder copies it (diff_stat, the tree ids)read as a regular file and copied into a private directory of the coder (decision 10) HEAD,ORIG_HEAD,info/sparse-checkoutand the likedata: no command named in them runs ( core.fsmonitoris forced off; hooks are off); git writesHEADandORIG_HEADby lock file and rename, which replaces a linkHEADandindexmust be regular files at the checkinfo/attributes,info/exclude,hooks/,packed-refs,objects/the common directory's ( git rev-parse --git-path), read-only in a podnone the working tree's own .gitattributesselects a driver, whose command comes from the configuration, which is the mirror's none Local mode and Podman are unchanged and work with the pin: it names the same directories git would have found. They are not protected by it: the commands share the coder's container, or bind the mirror read-write.
Git in a run pod reads, and refreshes its index. Verified 2026-10-18 with git 2.43.0 and real bind mounts (
deploy/coder/tests/git-in-run-pod.sh, which builds the pod's view in a private mount namespace and runs git as uid 10001 in it):status(also after the working tree changed),log,diff,describe,rev-parse,grep,show,worktree listandcheckout -- <file>work. Whatever writes an object, a ref or the configuration of the shared mirror fails:add,commit,stash,reset --hard,tag,branch,config --local, afetchthat brings objects, and a script that installs hooks (husky install). So does movingHEAD(switch --detach,checkout <commit>): it appends tologs/HEAD, which is read-only (decision 1), and git says "unable to append to ... Read-only file system". Before decision 1 hadlogsit worked; the coder'srun_commandundoes and refuses such a change anyway.HEADitself is a read-only file there (decision 11):blame,show,for-each-refandbranch --show-currentwork, and nothing git does for what a check needs writesHEAD. That is the point, and the coder does the committing (ADR 0010: git stays in the coder). The mirror'sworktrees/still lists every run's directory of that repository, with theirHEAD, index and log (below).A worktree's directory in the mirror is called
<run>+<slot>, and nothing is pruned. Git names it after the last component of the path, so every run's directory for the same repository starts from the same name, andgit worktree prune, which the coder ran before each new worktree, removes any directory whosegitdirnames a path that is gone. A command that renames its slot away makes its own directory stale (verified: a test failed before); the next run's worktree was then given the name again, and the first run, putting its slot back, found another run's directory under the name the coder had recorded, which the coder would have pinned its git to and mounted read-write into the first run's pod. Now a worktree is made in<root>/staging/<run>+<slot>(no pod mounts it) and moved to its slot withgit worktree move, which keeps the name (verified, git 2.43.0);+is in no run id and no slot name, so no other run's directory begins with<run>+. The coder runs nogit worktree prune: it removes what an earlier try at the same slot left by name (and a directory that carries no run and names the same slot), removes a run's directories by name when the run goes (and, when its metadata cannot be read, every<run>+...directory of every mirror), and does not judge another run's directory stale, whatever itsgitdirsays. The base checkout (add_base_checkout) is called<run>+<slot>+baseand made the same way. The directories above the destination (the run's directory,.adam-base) are the run's to write, andgit worktree movefollows a link there and, when something is at the destination, moves the tree into it. So the way to the destination is looked at before the move and again after it (every component a plain directory, from the run's directory down), and the new directory in the mirror must name the destination. When it does not, the coder removes the directory in the mirror, the staging copy and the tree where git put it (<destination>/<name>) if the way to it is plain, and returns an error that says where it went; a tree behind a link is left (a removal would follow the link to wherever the run points it by now: it is inert, its directory in the mirror being gone), and so is a directory that appeared at the destination, which is not the coder's. A swap in the milliseconds between the first look and the move is detected and undone this way, not prevented.What the coder opens in a directory a run can write, it opens without following a link. The run's pod writes its run's directory and the worktree's directory in the mirror, and the coder later meets whatever it left there, with the rights of the coder, which holds the whole volume and the GitHub App's key (
crates/adam-workspace/src/safe_fs.rs):- a file it reads (
commondir,gitdir, the slot's.git, the index) is openedO_NOFOLLOW | O_NONBLOCKand must be a regular file of an accepted size, so a link leads nowhere and a pipe does not make the coder wait (a test hung before); - a copy it makes (
diff_stat, the coder's tree ids copy the index) is made in a0700directory of its own in the process's temporary directory, off the volume, with a name nobody chose andO_EXCL;gitworks on it throughGIT_INDEX_FILE. The first version copied toindex.adam-diff-<pid>-<n>beside the index: a link planted at a name it could predict was written through, and anindexthat was a link copied any readable file (the App's key) into the directory the run reads; - a file it writes there (the slot's
.git, put back byrun_command's restore) is written beside it and renamed over it; - a slot is a plain directory (
lstat) that is a direct child of the run's directory, and so is the directorygitis pinned to (GitPin::check): a link in place of a slot, to another run's slot, is not a slot, is not listed, and is refused by everygit; the coder's file tools (confine) look at the root without following a link before they canonicalise it. The first version took such a link for a slot (verified: another run's.envwas committed on this run's branch); - a scratch project's directory and its
.gitare looked at without following a link beforecreate_dir_allandgit init(Scratch::init, on everyadd_scratch), and are refused when they are a link or a file: the first version askedtry_exists, which follows a link, and made the repository where the link led. The repository'sinfo/exclude, which a snapshot reads and a restore writes, is read as a regular file, and written by replacing it;infomust be a directory itself, or the state is not known and nothing is run (run_command'sRepoState); git worktree removeresolves a link and deletes the worktree it leads to (verified, git 2.43.0) when the path is not the one a worktree is registered at (a run that writes its owngitdir, as local mode, Podman and a pod made before the mounts can, arranges that; when it is, git checks that the.gitfile points back and refuses), so it is asked only about a path that is plain all the way down from the run's directory; a link is removed, not followed. The same holds for the base checkout and its directory.adam-base.
- a file it reads (
HEADof the worktree's directory is read-only in a run pod, and the coder's restore takes the run's branch from its metadata.HEADis a file the run's pod could write (the directory is read-write forindex), andresetandcommitact on the branch it names. The coder'srun_commandandrunsnapshot the worktree before a command and put it back when the command changed what it must not; the first version took the branch to putHEADon, and to reset, fromHEADitself: when a command (or an earlier one) had written another run'sagent/*branch there, the restore reset that branch to the commit the snapshot had seen (verified: a test failed before; the other run's branch was moved back to the older commit). Now:- in a run pod
HEADis a read-only file mount likecommondir(decision 1). Git in the pod does not write it: it cannot move a ref (the mirror is read-only), and the commands that moveHEADfail anyway on the reflog (decision 8). Verified 2026-10-18 withgit-in-run-pod.sh(status, log, diff, describe, blame, show, for-each-ref,branch --show-current,checkout -- <file>and a refreshed index work; a write, append, rename over, removal or link atHEAD,symbolic-ref HEADandupdate-ref --no-deref HEADfail; the script fails whenHEADis left out of the mounts). The coder does not rewrite it either: it putsHEADback only when it differs (point_head), because a file replaced by a new one is a file the pod's mount no longer follows (the problem of decision 3); - the snapshot of a repository's worktree (
Snapshot::of_slot) takes the branch fromWorktree::local_branch, never fromHEAD; it records whetherHEADwas onrefs/heads/<that>; when it was not,run_commandandrunrun nothing and say so ("HEAD of this worktree is on ..., not on the run's own branch ...: nothing was run ... tell the person"), and a restore from such a snapshot writes nothing and returnsfalse. A restore of a worktree whoseHEADwas on its branch before the command putsHEADback on that branch and resets that branch only; resetfollowsHEAD, so aHEADthat is flipped between the restore'ssymbolic-refand itsresetwould still be followed. In a podHEADcannot be flipped; in local mode and Podman, which nothing here protects (Known limits), it can.
- in a run pod
Known limits, not built ​
- A mirror is shared by everyone who works on a repository. Two people on one repository can read each other's unpushed
agent/*branches (refs and objects) through the read-only mirror. They can also read every sibling run's directory inworktrees/, which is in the mirror: itsgitdir(the other run's id, now in the directory's name too, and the path of its slot in the volume), itsHEAD(the branch it is on), itsindex(the paths and blob ids of what it has staged, not the contents of files that were never committed) and itslogs. The names of the files and the ids of the runs are what leaks; the contents of an uncommitted file are not in the mirror. Left open: it is the shared-mirror trade-off above, closed by a mirror for each person (open decision 3), which needs the person's identity, which a later step brings. - The package cache is writable by every run (ADR 0040), and other users' builds read it. One run can write into what another person's
npm ciorcargo buildtakes: a cross-tenant integrity risk. ADR 0040 called the volume "one trust domain: every run on it is the owner's"; that holds only while the runs are. Left as it is (open decision 2). - An embedded repository in the working tree runs its own configuration in the coder's git. Pinning decides which repository the coder's git works on, not what is inside its working tree. A directory with a
.gitof its own (a nested repository, a submodule checkout;modules/of the worktree's directory holds the gitdirs of submodules) that the index lists as a gitlink is entered bygit status,git add -A,git diffandgit commit, with that repository's configuration: afilter.*.cleanthere ran (verified by hand with git 2.43.0 and the spy of the tests; a gitlink is made by a run'sgit add subin its pod, which writes only the index, or by the coder's owngit add -Athe first time it sees the nested repository).-c diff.ignoreSubmodules=allstopsstatusanddiffbut notadd -Aand hides a changed gitlink fromdiff --cached --quiet, so it is not applied. The coder's git starts from an empty environment and without hooks or a monitor; what it cannot be kept from is a command that runs as the coder's user in the coder's container, which holds the GitHub App key. Closing it needs the coder's git to run apart from the coder's secrets (another user, or a sandbox), or to refuse a worktree with an embedded repository (racy, since the run writes the index and the directory at any time). Open decision 6. Amended (2026-10-27, #118): with run pods the program a repository's configuration names no longer runs where a secret is readable. The coder's git commands that carry no credential run in thegit-sandboxcontainer of the coder pod (open decision 6 below, closed by the last amendment), so thefilter.*.cleanof the embedded repository still runs, in a container that has no token, no Secret and no view of the coder's processes. What it can still do there is read and write the work volume (the item on the sandbox's reach, below). Local mode, Podman and run pods off stay as described. - A run's commands can still write the index of their own directory in the mirror. The index is the content of the next commit, which is the run's own work. (
HEAD,commondir,gitdirandlogscannot be written from a pod, decisions 1 and 11; in local mode and PodmanHEADcan, and the coder's commit and restore do not follow it.) - A swap between a check and the use that follows it is not closed for a slot's directory.
GitPin::checkand the reads of decision 10 look at a path and then git (or the coder) uses it; in a run pod the files that matter (commondir,gitdir,logs) are mounts and cannot be swapped, but a slot's directory can be renamed by the run's commands at any time, and a link put there in the milliseconds between the check and git's read would be followed once. Closing it makes each slot a mount point (a new slot would then need a pod made again, which decision 3 already does for worktrees but not for scratch projects), or has the coder hold a descriptor of the directory for the length of a command. Not built. Amended (2026-10-27, #125, the first of two changes): the coder's own opens are now relative to the slot.Slot,WorktreeandScratchhold the slot's directory, opened where the slot is checked without following a link (SlotDir,crates/adam-workspace/src/safe_fs/slot_dir.rs), and the file tools (read_file,write_file,edit_file,share_file, and the pathsapply_patchchecks),copy_into,Scratch::files, the restore of the worktree's.gitfile and of a scratch project'sinfo/excluderesolve, open, make and rename relative to that descriptor (openat2withRESOLVE_BENEATH | RESOLVE_NO_SYMLINKSwhere the kernel has it, a walk withO_NOFOLLOWwhere not). A swap of a slot, or of a directory below it, between the check and the use is not followed; the tests make the swap happen at that point (safe_fs::race) and fail on the code before. An absolute link inside the worktree is no longer followed by a read (it was). What stays open:gitfinds its work tree by name inside its own process, whatever the coder holds (verified with git 2.43.0), so a swap in the instant between the last look at the slot andgit's read of its name is still not closed:GitPin::check,GitCmdandGitAt::commandnow look at the directory against the descriptor first and last (a slot moved away and replaced by a directory of the same name is refused), which narrows the window and does not close it, andapply_patchstill hasgit applywrite by name. Closing it is the second change: every slot a mount point of the run's pod (subPath), which the run cannot rename. Not built. Amended (2026-10-27, #125, the second of two changes): in a run pod every slot, worktree and scratch project, is asubPathmount of its own on top of the run's directory (decisions 1 and 3), so the pod's commands, and the processes they left running, cannot rename, move, remove or exchange a slot's directory and the namegitfinds its work tree by is safe (verified withdeploy/coder/tests/git-in-run-pod.sh, real bind mounts:mv,rmdirand an exchange of the slot fail withEBUSY, a sibling that is not a slot still renames, and git works; the same checks in a real run pod are in therun-podsjob, verified 2026-10-27 in therun-podsjob of run 40456829784 (job 122032008830), where the cluster test's slot checks passed). Not covered:- The window before the mount. A pod made before a slot was added lacks its mount until
Environment::seal(right after the slot is added) or the nextensuremakes the pod again, which needs that no command runs in it. While a command runs, the directory can still be renamed; the tool that added the slot says so in its result. A pod of the run a scratch project was taken over from, if the janitor has not released it yet, keeps its mount of the project's directory, which now lives in another run's workspace, until it is released (at most one sweep,WORKSPACE_SWEEP_SECS, after that run ended; a conversation is one person's). - Slot creation. The run's directory is the run's to write until the slot is there; the move of a new worktree into place is detected afterwards and undone, as before (decision 9).
.adam-base/(the base checkouts), which is not a slot and not mounted.- The index and the other entries of a worktree's directory in the mirror that are not sealed (the item above).
- What
gitdoes below the slot (the files it reads there by name, as the embedded-repository and scratch-project items say); the coder's own file tools open those relative to the slot's descriptor (first change). - Local mode and Podman, which have no mounts: the slot's directory is a name there, and the first change's tripwires are all they have. No admission rule requires a
subPathon every mount of the work volume, and the chart is unchanged.
- The window before the mount. A pod made before a slot was added lacks its mount until
- A scratch project is a repository the run controls entirely. Its
.gitis a directory in the run's directory, with its ownconfig(afilter.*.cleanor acore.fsmonitorthere runs in the coder'sgit add -A, decision 7's open decision 6), its ownlogs(the link-append of decision 7 reaches any file through.git/logs/HEAD), and its own hooks (off). The pin requires.gitto be a plain directory without acommondir; it cannot make what is inside it the coder's. The coder's own reads and writes of its files are made without following a link (decision 10:info/exclude), butgititself readsinfo/exclude,info/attributesandpacked-refsthere with a plainopen: a link or a pipe at one of them would be followed or waited on by the coder'sgit add -A(unverified: not tried). The remedy is the one for the embedded repository below: the coder's git apart from the coder's secrets. Amended (2026-10-27, #118): with run pods that remedy is built. The scratch project'sconfig(afilter.*.clean, acore.fsmonitor) runs in the git sandbox, where the key, the token and the coder's environment are not readable: therun-podsjob makes such a project and shows its program running as the child of the sandbox'stini, reading nothing of the canaries that the same program, run by plain git in the coder container, reads. A link or a pipe atinfo/exclude,info/attributesorpacked-refsis now followed or waited on by the sandbox'sgit, not the coder's; the coder gives each local command a time limit (five minutes) and a command never outlives its connection (the sandbox kills the process group), so a pipe holds a command and not the coder. That last point is still unverified: it is not tried. - Slots made before decision 9 keep git's own names (
worktrees/<repo>, no run in them). They are found by the onegitdirthat names the slot among the directories that carry no run, as before; a run that owns another such directory can make that answer ambiguous (none), and, if the slot's own directory is gone, name its own as the only candidate. They age out with their runs. - Local mode and Podman share the coder's container or bind the mirror read-write: none of this protects them. This covers the git sandbox too (open decision 6 below): without run pods the chart renders none,
GIT_SANDBOX_SOCKETis unset, and the coder's git runs in its own container. - Git in a base checkout does not work in a run pod.
add_base_checkoutmakes a second worktree for the check on the base (.adam-base/<slot>in the run's directory); its directory in the mirror is made after the pod and is not mounted, sogitthere says it is not a repository. The commands that do not use git run as before. - A repository's devcontainer on Podman (ADR 0010) binds the mirror read-write. Not touched here.
- The model key is in every run pod's environment until ADR 0038 is built. Amended 2026-11-24: ADR 0038 is built (#145,
cb7bb8f): no model key is in a run pod. This limit is closed.
Alternatives rejected ​
- A read-write mirror with a policy in the coder (refuse a command that writes it): a command is a shell; the mount is the only thing that holds.
- Mounting the slot's
.gitread-only to pin the chain from the worktree to the mirror: a command can rename the slot's directory and make another with a.gitof its own, which the coder's git then reads; the slot directory itself would have to be a mount, and then a rename by the coder (adopt_scratch) breaks it. The coder's own git is pinned instead (decision 7). What the pin does not cover and a mount can,commondir,gitdirandlogsof the worktree's directory, is mounted read-only (decision 1). - A private copy of the whole git directory for the coder's git (a
HEADthe coder writes, the index copied in and written back,commondirmade by the coder): it removes every file of the run's directory from what git reads but the index, and would needrun_command's snapshot and restore, which act on the realHEAD, rewritten. Not built; the mounts and the checks above are what there is. git worktree prunescoped by a name: prune has no scope; deleting by name does the same job.- An
emptyDiroverworktrees/to hide other runs' directories: three more mounts for each repository, for a trust domain (the shared refs) that stays open until a mirror per person. - Mounting single files of the mirror (
config,packed-refs): git replaces them by rename, so the pod would keep the old inode. - A clone for each run in the pod: the files are on the volume so that a pod can be thrown away (ADR 0019 decision 5).
- Hot-adding the mount to the running pod: needs mount propagation and a privileged container.
Facts, and how they are known ​
- The git behaviour in decision 6 and that git names a second worktree of a mirror
r1: verified 2026-10-18, git 2.43.0,git-in-run-pod.sh(CI runs it in therun-podsjob). - The behaviours in decisions 6 and 7 (a rewritten
.git,commondirandHEAD, a forgedgitdir, an ambiguous or missing back-pointer,config.worktreewith and without the extension, a scratch.gitreplaced by a file, an embedded repository): verified 2026-10-18 with git 2.43.0 by the tests ofcrates/adam-workspace/tests/workspace.rs, each of which fails without the change it tests (the pin, the explicit commit), and by hand for the embedded repository. - The behaviours of decisions 1, 9 and 10, verified 2026-10-18 with git 2.43.0: a file bind-mounted read-only is not writable, appendable, renamable over, removable or replaceable by a link by the uid that owns it, nor a read-only
logsdirectory (git-in-run-pod.sh); git appends a reflog line through a link atlogs/HEAD;git worktree remove --force <link>deletes the worktree the link leads to (by hand, in the scratchpad);git worktree movekeeps the directory's name;git worktree pruneremoves the directory of a worktree whose path is gone; a worktree is named after the last component of its path; a copy of the index into the directory the run writes, at a predictable name, was written through a planted link, and a linkedindexwas copied; a linked slot was committed on another run's branch; and a pipe where the coder reads a file hung it. Each of those incrates/adam-workspace/tests/workspace.rsfailed when run against the sources of the first version (dc7e4d5); the tests ofbin/adam-coder(gitcli.rs,files.rs) were written with the change and are the same cases on the coder's side. - The behaviours of decisions 3, 9 to 11 added by the third version, verified 2026-10-18 with git 2.43.0 and each failing against the sources of
5aa41e5: a snapshot taken withHEADon another run's branch restored by resetting that branch (bin/adam-coderhead_tests, andrun_commandandrunrefusing,tests/tools.rs); a slot made again under the same name gives the pod's annotation another line, and the pod is made again (fake.rs, with the generation oftests/workspace.rs);git worktree moveinto a directory that appeared at the destination puts the tree at<destination>/<name>and leaves the directory in the mirror naming it (placement_tests); a scratch directory or.gitthat is a link was made into a repository where it led (tests/workspace.rs);info/excludeas a link was read and written through (exclude_tests); a read-only bind mount ofHEADcannot be written, renamed over, removed or linked, and git's read-only commands work with it (git-in-run-pod.sh). - The policy's expressions: verified 2026-10-18 with an independent CEL implementation (cel-python) on thirteen sample pods (the intended pod admitted; another key, another Secret's key, a Secret volume, an init container's reference,
envFromand a projected Secret refused; a ConfigMap reference admitted); unverified against the API server's own type checker and runtime until therun-podsjob has run (it also refuses three more changes there). - That a container runtime mounts a read-only
subPathdirectory with a read-writesubPathdirectory inside it, that the kubelet makes a missingsubPathwith the volume root's mode, and the whole isolation scenario (a_run_pod_sees_only_its_own_runintests/cluster.rs, seeded bykind-run-pods.sh): unverified until CI runs therun-podsjob; no container daemon exists where this was written. containerd and CRI-O sort mounts so that a parent comes first (unverified, from memory).
Decisions for the owner to confirm ​
- Git in a run pod cannot write. The mirror is read-only, so a command that runs
git commit,git addof a new file,git stash,git tag,git config --localor a hook installer fails in a run pod. The coder commits and pushes (commit_and_push), and OpenCode, while it stays (ADR 0038), will see the refusal. The alternative, a writable object store, lets a run plant objects every run reads. - The shared package cache (ADR 0040) stays as decided and stays a cross-tenant integrity risk. Open: a cache for each person, or read-only in run pods (a writer outside them, or the pull-through proxy of ADR 0040). Until then, share it only among runs that trust each other.
- A mirror for each person, instead of for each repository, closes the shared refs and worktree directories. It needs the person's identity in the coder.
- A new repository waits for a running command (or makes the pod again when none runs) instead of ending the command.
- Exactly one Secret key in a run pod,
MODEL_API_KEY, until ADR 0038 removes it. Amended 2026-11-24: ADR 0038 was built incb7bb8f(#145): a run pod holds no Secret reference at all. The admission policy refuses asecretKeyRef, anenvFromsecretRefand a Secret volume;render-check.shasserts the template has none and the policy says so, andkind-run-pods.shsubmits each form to a real API server and requires the refusal. - Moving
HEADin a run pod fails (git switch --detach,git checkout <commit>), becauselogsis read-only; the coder'srun_commandandrunundo such a change anyway. The alternative is a writablelogs, which leaves a link atlogs/HEADable to make the coder's git append to any file it can write; the coder could instead never write the worktree's reflog (its ownupdate-refthrough the mirror, its restores withoutreset), which is a rewrite ofrun_command's restore and does not hold for a future command. HEADis read-only in a run pod, and a worktree whoseHEADis not on its branch runs no command. SealingHEADcloses the reset of another run's branch for pods; the metadata rule closes it for the coder's own state and covers local mode and Podman up to the race in decision 11. The cost: a run that wanted to moveHEADby hand in its pod could not (it already could not, decision 7 of this list), and a worktree that is found withHEADelsewhere (only a command that wrote the file can have done it) is not usable byrun_commandandrununtil the person looks at it, instead of being put right by the coder. The alternative is to putHEADback on the run's branch and go on, which leaves the question of what else that command changed. A pod made before this change has noHEADmount in its annotation and is made again once, when no command runs in it.- The embedded-repository vector above. Run the coder's git apart from its secrets (a user of its own or a sandbox), or accept it while every run is a person who may be trusted with the coder's container. (The pin and the explicit commit are decided and built; whether the Podman devcontainer should get a read-only mirror too is still open.) Closed 2026-10-27 for run pods (#118, the amendment below): a sandbox. What stays open is whether the Podman devcontainer should get a read-only mirror, and git per run.
Consequences ​
- A command of a run sees its own directory, the mirror of each repository the run works on, and nothing of any other run, of
meta/or of any other repository's mirror. It can no longer write what the coder's git reads in other runs. - A run that adds a repository while a command runs waits for it to end; one that adds a repository while nothing runs pays the making of a pod (scheduling, and a pull on a node that lacks the image) once more.
- A pod made by the earlier version is made again at the next
ensure(it has no annotation, or lacks theHEADmount), after its command ends; and so is the pod of a run whose slot was made again under the same name (the generation). - The coder's
giton a slot is pinned andWorktree::commit_allcommits with plumbing onto the run's own branch; this holds in local mode and with Podman too (the pin names the directories git would have found). A slot made before the directory in the mirror was recorded is resolved from the mirror at its next listing, or refused if that is ambiguous.Worktreegainsgit_dir,git_dir_generationandgit_pin,SlotandScratchgaingit_pin, and the new public type isGitPin.WorktreeDirsgains the fieldgenerationandMountthe methodgeneration(a struct literal ofWorktreeDirsneeds the field). PodTemplate::parseandfrom_filetake the workspace root;rendertakes the mounts;MOUNTS_ANNOTATION,WorkspaceMounts,MountandWorktreeDirsare new. The chart's template, its policy and the goldens change; no value and no environment variable does, andRUN_ENVIRONMENT=localandrunPods.enabled: falseare as they were.
Amended ​
2026-11-19, ADR 0052 (not built yet). A run pod may run the repository's own image (
use_repository_environment): only theruncontainer's image changes, to one that starts with a prefix the deployment allows. What a run pod mounts and sees, and every other refusal of the admission policy, are unchanged; ADR 0010, which this record builds on for "a path means the same in every environment", is superseded in part, and that rule now holds between the coder and its run pods only.2026-10-18, after a security review of the first version (#117). The coder's file operations on paths a run can write (decision 10); a slot that is a link is not a slot (decision 10); the directories of the mirror are
<run>+<slot>, made in staging and moved, never pruned, and a record is believed only while it is still the run's (decisions 6 and 9);commondir,gitdirandlogsare read-only mounts andGitPin::checkonly checks (decisions 1 and 7), where the first version rewrotecommondirthrough the link the run had put there; the siblingworktrees/*exposure is stated (Known limits); movingHEADin a pod no longer works (decision 8, owner decision 7). The residual races and the scratch project are in Known limits.2026-10-18, after the second review.
HEADof the worktree's directory is a read-only mount, and the coder's snapshot and restore take the run's branch from the metadata and run nothing whenHEADis elsewhere (decision 11); a scratch project's directory and.gitare looked at without following a link before they are made, and itsinfo/excludeis read and written likecommondir(decision 10);git worktree moveis verified afterwards and undone when it went somewhere else (decision 9); the mounts of a pod carry the generation of the worktree's directory, so a slot made again has the pod made again (decision 3).2026-10-27, #125 (first of two changes). The coder holds each slot's directory open and does its own file work relative to it (Known limits: a swap between a check and the use); decision 10's "the coder's file tools (
confine) look at the root without following a link" is now "open it without following a link, and use the descriptor". The second change, the slot as a mount point of the pod, is not built.2026-10-27, #125 (second of two changes). Every slot is a
subPathmount of its own in the run pod, with the slot's generation in the annotation line (decisions 1 and 3), and the coder callsEnvironment::sealright after it adds a slot so that a stale idle pod is deleted at once and the next command makes the new one (Known limits: a swap between a check and the use lists what stays open).2026-10-27, #124 (ADR 0042). The run pods' network policy, which this ADR does not describe and ADR 0019 does, no longer opens the internet: a run pod reaches DNS, the egress proxy and
runPods.networkPolicy.extraEgress, and nothing else, and the pod template (decision 2's template) setsHTTPS_PROXY,HTTP_PROXYandNO_PROXY(lower case too) to the proxy. The mounts, the admission policy and the rest of the template are as above; the policy allows plain values for these variables and still allows no Secret reference but the model key.2026-10-27, #118 (open decision 6 closed for run pods). The coder's local git runs in a
git-sandboxcontainer of the coder pod, and the git commands that carry a token stay in the coder after the mirror's configuration has been put back to an allow-list. Two changes (the sandbox server, its relay and the coder's routing:adam-git-sandboxandadam-workspace; the chart and its proof, here).- Why a sandbox. Git always reads the configuration of the repository it works on and has no switch that turns off the
filter.*,diff.*.textconvorcore.fsmonitorprograms defined there; driver names are arbitrary, so they cannot be overridden one by one; and a scratch project's.gitand an embedded repository are written by the run. So the program has to run where nothing secret is readable. The alternatives: the key held only in memory (a Secret volume's file stays readable by the container's user, and the other secrets are in the environment of processes of that user); git in the run pod (the commit writes objects and the branch into the mirror, which the run pod mounts read-only: decision 1). - The container. With
runPods.enabledthe coder pod has a second container,git-sandbox, from the coder's own image, runningadam-git-sandbox(a native sidecar: it starts before the coder, after a startup probe that runsadam-git --versionthrough the relay, and stops after it). It has no Secret volume, noenvFrom, no variable from a Secret, none of the coder's other volumes, and no service-account token: the pod setsautomountServiceAccountToken: falseand the token is a projected volume mounted in the coder container alone, at the path the in-cluster client reads; nor does the GitHub MCP sidecar have it any more (it had, before). The pod does not share a process namespace, so the sandbox cannot read the/procof the coder's processes (/proc/<pid>/environof a process of the same user is readable otherwise). It has a read-only root file system, anemptyDir/tmpof its own (in memory and sized: a program that fills it getsENOSPC, where a disk-backed volume would get the pod evicted), the default seccomp profile, no capability and no escalation, and a memory limit of its own. It mounts the work volume at the same path as the coder (the commands carry paths) and runs as the same user (one writes the files the other reads); the two share the socket's directory and nothing else. There is no switch to turn it off: it is on with run pods. - The routing (decided and built in the first change; recorded here for the whole). The
gitcommands that carry no credential (status,add,diff,commitand its plumbing,worktree,config,apply, ...) go over the socket (GIT_SANDBOX_SOCKET, set by the chart) to the sandbox; a sandbox that cannot be reached is an error, never a fallback.fetch,pushandls-remote, which need the token, stay in the coder, on the bare mirror, after its configuration has been put back to what the workspace writes (the Context's list of keys that were removed is now a list of keys that stay:mirror_config.rs), so aurl.*.insteadOfor anhttp.*key that a filter in the sandbox planted cannot redirect the request that carries the token. - What the
run-podsjob proves (deploy/coder/tests/kind-run-pods.sh; unverified until CI has run it: no cluster exists where this was written). On a pod made from the chart's own StatefulSet (the coder container sleeps, because the real coder needs a database and a model; its environment, mounts, projected token and security contexts are the chart's, with the App's key a Secret volume and canaries for the key, the model key, a bearer token and the database URL): the sandbox has no token file, no key, no mount of a secret or a projected volume, none of the coder's variables or of the canaries in its environment, and its process 1 is its owntini -- adam-git-sandboxwith none of the coder's processes in sight, while the coder container has all of them and its token is accepted by the API server; a commit made through the socket works and is the same commit in both containers; and the vector: a scratch project whose own.git/confignames afilter.x.cleanand acore.fsmonitor, applied by a.gitattributes, that write what they can read (the token, the key,/proc/*/environ, their own environment) to a marker.adam-git add -A(andstatus,diff) through the socket runs them in the sandbox (the marker's first process is the sandbox'stini) and the marker holds none of the secrets: the token and the key areNo such file or directory. The control: the same project added by plain git in the coder container writes a marker that holds all five, so the check can fail.tests/render-check.shholds the render's half (no Secret,envFromor secret variable in the sandbox, the token mounted in the coder alone, noshareProcessNamespace, the same work path and user, the socket variable), each broken on purpose once. - Not covered.
- A filter in the sandbox can still read and write the whole work volume: every run's files, every mirror, as the coder's git could. Closing that needs git per run, in the run pod, which needs a different commit path (the mirror is read-only there). A follow-up. Integrity of other people's branches in the shared mirror stays as exposed as before until a mirror for each person (#122, open decision 3).
- The race between the repair of the mirror's configuration and a network command's read of it: a writer already running in the sandbox can change
configbetween the two statements of one task, under the mirror lock. Shortening it further needs the network commands to read a configuration of the coder's own. - Local mode, Podman and run pods off, where the coder's git runs in its own container, unprotected, as before. Without run pods the commands of a run run in that container anyway.
- The sandbox is a container of the coder's pod, not a user or a machine: a flaw in the container runtime's isolation or a capability the deployment adds back would reach the coder's. It is the same boundary the run pods rely on.
- The sandbox's output is untrusted by design and the coder treats it as data; nothing here makes
git's answers true.
- Why a sandbox. Git always reads the configuration of the repository it works on and has no switch that turns off the
2026-11-24, open decision 2 closed (the owner, ANR-Q52). "(c) Read-only in run pods, filled by a pull-through proxy to the public registries (a proxy to build and run)." The shared package cache (ADR 0040) is mounted read-only in run pods and only the pull-through proxy writes it; the admission policy will refuse a run pod that mounts the cache claim read-write. A cache for each person is not chosen. The risk named under decision 2 above (one run writing what another person's build reads) stays open until the admission slice and the proxy slice are built; this note records the choice and builds nothing.
2026-11-24, a mirror for each person: the design (owner decision 3; issue #122). Nothing is built. Design only, to be confirmed by the owner before the build card is written. It closes the first Known limit (a mirror is shared by everyone who works on a repository) and is the "later use of the identity" that sys ADR 0064 decision 15 names without deciding. Unverified until built: every behaviour below is a plan, none is run.
- Naming. The person is the pseudonym of the
identity/v1assertion (sys ADR 0064 decision 2): 43 characters of base64url, the same for one person, one agent and one deployment, and never the e-mail. The layout isgit/<host>/<owner>/<repo>.gitbecominggit/p-<pseudonym>/<host>/<owner>/<repo>.git. Thep-prefix means a pseudonym that starts with-is never read as an option; the coder checks the alphabet (A-Za-z0-9_-, 43 long) before it builds any path, and refuses a run whose pseudonym does not match, instead of falling back. - First fetch. The first run of a person on a repository makes their mirror by a fresh bare clone from the host (as today's first fetch), under the mirror lock of decision 6. It is not seeded from another person's mirror: copying one would copy their unpushed
agent/*refs and objects, which is the exposure this closes. The cost is one full clone per person and repository, paid once; a deployment that finds it too slow sets a pull-through cache at the host (ADR 0040), which is shared and holds only what the host already serves. - Mounts. Decision 1's table is unchanged except for the path: a run pod mounts
subPathof its own person's mirror only, so the siblingworktrees/*of other people's runs are not there to read. Nothing ofgit/p-<other>/is in the pod. Because a person now owns their mirror, the run pod of that person's own run may see the person's other runs' worktree directories; that is the same person, and is stated here as accepted. - Storage. One mirror per person and repository on the same work volume, so the volume grows with people times repositories. The deployment sizes it; the chart gets a documented starting point and no default quota.
- Clean-up. The sweeper that removes idle run directories also removes a person's mirror when no run of that person has used it for a time the deployment sets (
mirror_idle_ttl, off by default so nothing is removed unless asked), after the last worktree directory in it is gone, under the mirror lock. Removing a mirror loses only objects that are on the host; a branch not yet pushed is lost, so the sweeper refuses a mirror that still holds a ref the host does not have, and says so in the run's record. - No pseudonym. When the identity extension is off or the assertion carries no
sub, the coder uses the layout of today, one mirror per repository shared by everyone, and the Known limit stays open for that deployment. The sentence a test can check: a run with no pseudonym mountsgit/<host>/<owner>/<repo>.git; a run with one mounts onlygit/p-<pseudonym>/.... The coder never mixes the two for one person within a deployment, because a pseudonym appearing later would orphan the shared mirror's refs. - Workspaces that last (ANR-52). A kept slot is a worktree of the person's mirror, so it follows the person: the slot's
gitdirpoints intogit/p-<pseudonym>/..., and the sweeper must not remove the mirror while a kept slot exists. - The kind test the build card adds. Two people, one repository: each run pod lists only its own mirror and no
worktrees/entry of the other; a run with no pseudonym sees the shared path; the sweeper removes an idle mirror with no unpushed ref and refuses one that has one. It runs in kind beside the existing mounts checks, andrender-check.shholds the render's half. What this does not close: a filter in the git sandbox still reads the whole work volume (Known limits above), so the volume's other people's mirrors stay readable from the sandbox until git runs per run. The mount change reaches run pods only.
- Naming. The person is the pseudonym of the