Skip to main content

ADR-0037 — The session workspace has two boundaries: the team authorises, the run executes

  • Status: Accepted — records founder ruling 2 (own account, upsqdvb, user.type=User, #4578 comment 6980541294, 2026-11-18) and the architect's design under it. The ruling is not reopened here; what this ADR adds is the mechanism (acquisition, mount, stamping, cleanup, the enablement chain) and the two refusals. Implementation lands in Stage 2 slices S1 #4632 (launcher-side acquisition, mount, lease/reaper on the compose profile), S3 #4634 (coder mount, stamping, cleanup on coder_result) and S6 #4637 (Kubernetes materialisation). No further founder sign-off is required: the ruling chose the direction, named the credential posture and rejected the alternative; nothing below widens it.
  • Date: 2026-11-20
  • Deciders: Founder (ruling 2 — direction, credential posture, both modes). Principal Architect (the design under it). backend-security reviews the S0 contract (#4631) and S1 as the independent lane on the two new privilege boundaries.
  • Refs: #3735 (the workspace tracker; this discharges its "ADR accepted naming the interface, the owner and the isolation model" line) · #4630 (Stage 2 tracker; plan in its first comment) · #4598 (launcher privilege model, ruling 4) · #2597 (code_exec sandbox HLD; D1–D3 ruled 2026-11-18) · #4152 (GitHub-first governed source foundation — the team source grant this ADR authorises against) · #3680 (repository map Tier C — the READ_ONLY consumer) · ADR-0038 (the governed git write; the only way bytes leave a READ_WRITE workspace) · HLD #2113 / LLD #2184 (WR2-3 substrate obligations #1–#4) · ADR-0028 (preview ingress precedent for "ingress only from one component")
  • Numbering note: ADR-0032 through ADR-0035 are claimed by issues (#2599, #2601, #2643, #3063) with no file in docs/adrs/; ADR-0036 is the last file. 0037 and 0038 were the next unclaimed numbers on 2026-11-20 (no open PR touches docs/adrs/ except #1209's ADR-0014; no issue claims either number other than the Stage 2 issues that announce them).

Context​

The primitive nobody owned​

Two consumers need the same thing and today neither has it: a governed agent session that can read — and for the coder, edit and run — a checkout of repo@commit that the platform provisioned, inside a sandbox, with nothing of ours lying around in it.

  • Repository map Tier C (#3680, tracked by #3735): one governed agent walks a deterministic index over a checkout. Read-only. The tracker's historical brief already named the interface shape (AcquireWorkspace(org, team, repo_id, commit) → workspace_id, shallow, pinned, per-tenant, TTL, hard cleanup "including SDK transcripts/caches").
  • The Stage 2 coder (#4630): the SDLC coder roster entry runs as a pinned Claude Code CLI over that checkout, edits, runs tests, and hands the change to the governed write (ADR-0038). Read-write.

What exists on origin/main (0ce504c4b), and what this ADR builds on rather than re-inventing:

FactWhere
Superseded by S6 (#4637, D4 as amended). The WR2-3 sandbox admitted exactly ONE credential: the per-run, prefix-scoped, short-TTL object-store signer. "Never logged."internal/workflow/sandbox/runner.go:85-89 (Credential), as of 2026-11-20. S6 deleted the type and the signer fields, and the launcher refuses workspace_signer (ErrWorkspaceSignerRefused)
The dev launcher already provisions a host workdir and bind-mounts it read-write at /work for a batch run; the serve path swaps that bind for a 32 MiB tmpfsdockerlauncher.go:82-111 (Launch), :471-500 (buildServeDockerArgs, tmpfs swap at :480-484)
Serve mode exists: a detached, health-checked, long-running sandbox with StartServed / Probe / StopServedinternal/workflow/sandbox/serve.go:168-199 (ServiceRunner, ServiceLauncher), ServeSpec at :80-118
Batch defaults are a 60 s wall and 256 MiB of memory-backed /work; a real checkout plus a Go build cache fits neitherpolicy.go:36-43 (DefaultResourceLimits), podspec.go:61-63 (ErrNoDiskBound, kernel sizeLimit)
The team's SCM credential is decrypted only for the exact active, unexpired epoch under org + team + provider + host predicates — never for "a token"internal/vault/repo_map_credentials.go:221 (Resolve)
The run workspace blob plane is content-addressed and quota'd per runinternal/workflow/workspace/store.go:127 (WriteArtifact)
Superseded by S6 (#4637). The Kubernetes transport is a fail-closed stubk8slauncher.go:28 (ErrK8sSubstratePending), :48 (PodExecutor), :166 (PreviewPodExecutor), as of 2026-11-20. That file was deleted by S6 (#4637, principal-architect Q5); the sandbox-launcher's k8s backend (launcher_k8s.go) replaces it
The launcher is constructed only under WF_CODE_EXEC_ENABLED; docker (dev) or k8scmd/agent-orchestrator/main.go:1430-1452; env in config.go:146-156
The worker already refuses to leak its own environment into the CLI (allowlist wrapper), and keeps one CLAUDE_CONFIG_DIR per orgservices/agent-worker/src/agent_worker/orchestrator/driver.py:86-137, segment.py:221-224
A roster dispatch is governed as agent_action with the dispatched agent_ref as target; its identity key is run_id:step@ordinalinternal/workflow/orchrt/bridge.go:293-307 (govHop), hook.go:71-99

The ruling, verbatim​

write the workspace ADR now for both modes, read-only (repository map) and read-write (coder): the platform launcher shallow-clones repo@commit outside the sandbox with the team's SCM credential from the vault, mounts it into the per-run sandbox, stamps the pinned commit on every result, and deletes it with the run including SDK transcripts and caches; the credential never enters the sandbox, and the ADR records "team = authorization boundary, run = execution boundary". Alternative: clone inside the sandbox with git and a short-lived token — rejected, it hands the sandbox an SCM credential and an egress grant.

Why "two boundaries" is the load-bearing sentence​

Every earlier design of this primitive blurred who may see this repository with which process is touching it right now. Those are different questions with different lifetimes. A team's right to a repository outlives any run; a run's checkout must not outlive the run. Conflating them produces either a shared cache that leaks state between runs (and between the humans whose approvals those runs carried), or a per-run credential that ends up inside the sandbox. This ADR separates them and names which component owns each.

Decision​

D1 — Team = authorization boundary; run = execution boundary​

Authorization is decided against (org, team, repository) and nothing narrower. A workspace may be acquired iff the team the run executes in (RunScope.TeamID, orchrt/hook.go:239-247, sourced from the run row — never from the worker) holds a source grant for that repository under the #4152 foundation, and the credential resolved for it is that team's (RepoMapCredentialScope{OrgID, TeamID, Provider, Host} — the SQL predicates at repo_map_credentials.go:208-214 and :221-233 are the authority; an in-code check is additional, never a substitute). No per-agent, per-run or per-human credential exists on this path. The human the run acts for (RunScope.MemberID) is provenance, not authority.

Execution is bound to exactly one (run, step, ordinal) — the agents+gates idempotency key (coder@1, coder@2, …). A workspace is created for one dispatch, mounted into one sandbox session, and destroyed when that dispatch's result is recorded or its lease lapses. Consequences that follow by construction, not by policy:

  • Two dispatches in one run (coder@1 and a re-dispatch coder@2 after a crash, exactly the #4616 recovery shape) get two independent checkouts of the same pinned commit. Nothing carries over — not an edit, not a build cache, not a transcript.
  • Two runs never share a workspace, however equal their (team, repo, commit) are.
  • A resumed orchestrator segment on another host finds no workspace; it finds the sandbox_sessions row (S1) that tells it what to release.

D2 — Both modes, declared on the definition, enforced twice​

RosterEntry.sandbox.mode (S0 contract, proto/upsquad/workflow/v1/agents_gates.proto) is one of:

ModeMountBuilt-ins the worker allows inside the sandboxConsumer
SANDBOX_MODE_READ_ONLY/work read-onlyRead, Grep, Globrepository map Tier C (#3680); any governed reader
SANDBOX_MODE_READ_WRITE/work read-writeRead, Grep, Glob, Edit, Write, Bashthe coder (#4634)

In both modes WebFetch, WebSearch, Agent/Task and NotebookEdit are denied, and MCP is strict_mcp_config to that agent's team-gateway server only (the existing roster rule, runtime.proto:1091-1116 mcp_servers). The mode is enforced by two independent layers that cannot be collapsed into one: the launcher's mount flag (:ro / :rw on the bind; the k8s volume's readOnly) and the worker's per-tool deny list. Every built-in call still passes PreToolUse and is audited as a tool_action hop with its path or command (internal/workflow/orchrt/README.md rules), so "the coder ran go test" is a row, not an inference. Path deny-rules apply in both modes to .env*, *.pem, id_*, .git/config, **/secrets/**.

The mode is not a runtime choice: it is validated at definition create (agentsgates/validate.go roster rules, extended in S0) and carried unchanged to the worker (OrchestratorSandbox.mode) and to the launcher (AcquireWorkspaceRequest.mode).

D3 — Acquisition is launcher-side, outside the sandbox, shallow and pinned​

The launcher (ruling 4: on the compose profile a separate sandbox-launcher service, the only holder of /var/run/docker.sock; on Autopilot the PodExecutor under its own service account — #4598; as amended by S6 #4637: on Kubernetes too it is the sandbox-launcher, in-cluster under its own service account, with a k8s backend — see D4) performs the clone into a directory it owns and chose; the caller never names a host path.

git -c credential.helper= -c core.askPass=<helper> \
clone --depth 1 --no-tags --single-branch --branch <ref> https://<host>/<owner>/<repo>.git <dir>
git -C <dir> -c advice.detachedHead=false checkout --detach <commit> # when a commit, not a ref, is pinned
git -C <dir> rev-parse HEAD # ⇒ the pinned commit stamped on every result (D5)
git -C <dir> remote remove origin # no remote survives acquisition

with GIT_TERMINAL_PROMPT=0, the credential supplied through a GIT_ASKPASS helper that reads it from a file descriptor the launcher opens for that one process — never on argv, never in the sandbox's environment, never written to .git/config (http.extraheader is not used because it persists in the config when set with git config; passed as -c it is argv-visible — both are refused). After the clone the launcher asserts git config --local --list contains no extraheader, askpass or credential key and that the token bytes do not occur anywhere under <dir>/.git (S1 acceptance). Fetched bytes ≈ working-tree bytes: #3735's representative target carries ~826 MiB of history that a shallow, single-branch, no-tags clone never fetches (S1 acceptance measures it on upsquad-ai/upsquad-core).

Who resolves the credential. The orchestrator (which already holds the vault passphrase and constructs the launcher under WF_CODE_EXEC_ENABLED, main.go:1420-1452) performs the #4152 grant check, calls Resolve (repo_map_credentials.go:221), and passes the resulting short-lived SCM token to the launcher inside AcquireWorkspaceRequest.clone_credential over the authenticated orchestrator→launcher hop (S1 design on #4598). The launcher uses it for the clone and drops it; it keeps no database connection and no vault passphrase. This is the narrower reading of "the platform launcher shallow-clones … with the team's SCM credential from the vault": the platform resolves from the vault, the launcher clones with it, the sandbox never sees it. The alternative — giving the root-equivalent launcher process its own vault + DB access so it can resolve credentials itself — is rejected in "Rejected" below.

D4 — Mount: the workspace is /work, and /work is the SDK cwd​

  • docker (dev, S1/S3): the launcher-owned directory is bind-mounted at /work (:rw for READ_WRITE, :ro for READ_ONLY) into the served container. The serve path's current tmpfs swap (buildServeDockerArgs, dockerlauncher.go:480-484) is replaced by the workspace bind when ServeSpec.workspace_id is set; the batch path (buildDockerArgs, :319) is untouched. Because the sandbox runs as uid 65534 (:329) and the launcher writes the checkout, the launcher chowns the tree to 65534 (READ_WRITE) or leaves it owner-read-only with world read (READ_ONLY); no 0777 on a checkout. The directory lives under a launcher-owned root that is the same path on the host and inside the launcher container (a bind source is resolved by the daemon on the host — S1 design on #4598), mode 0700, owned by the launcher's uid.
  • Kubernetes (S6), as amended by S6 #4637 (principal-architect Q2 7082568103, reconciled with backend-security 7082592178 in 7082619703), superseding the blob-artifact design this bullet first recorded: the sandbox-launcher runs in-cluster under its own service account and is the only pod-creating component. It streams the work tree (never the git directory, which stays launcher-only exactly as on docker) into the pod's ws-receive init container over a single, mutually authenticated connection: the pod proves knowledge of a per-pod key first, frames are AEAD-sealed, the launcher dials once and never after materialisation. There is no blob-store artifact and no workspace signer: no credential enters the pod for materialisation, and the launcher refuses a request carrying workspace_signer (checkNoWorkspaceSigner). The init container has the pod's egress (NetworkPolicy is per pod), not "no egress". The coder tier's /work is a generic ephemeral PVC on an xfs StorageClass (bytes and inodes bounded by the filesystem, principal-architect Q4), not a disk-backed emptyDir, whose sizeLimit is a kubelet-polled eviction. changed_paths comes from a read-only native sidecar's content-addressed manifest diffed by the launcher (Q3, stamped changed_paths_source=in_pod_observer); no git process ever reads a sandbox-written tree on Kubernetes.
  • /work is the SDK cwd for the sandboxed session (the SDK project key the worker records, driver.py:168-174), so the CLI's project-relative state lands under the sandbox's own CLAUDE_CONFIG_DIR (/tmp/claude, tmpfs — dockerlauncher.go:332 already mounts /tmp as a 32 MiB tmpfs; the coder tier's /tmp is sized by its policy row), not under the worker's per-org config dir. The coder's transcripts therefore live and die inside the sandbox; Stage 2 keeps no worker-side transcript mirror for the coder (no coder-session resume — the recovery shape is re-dispatch, §D6).

The coder tier needs more than the batch defaults: the plan's code_exec_resource_policy coder row (CPU 2, mem 4 GiB, wall 3600 s, disk 2 GiB, pids 512, output 1 MiB; S2) is the ceiling the launcher clamps to (policy.go ClampLimits). On Kubernetes that is a generic ephemeral PVC (as amended above), not the memory-backed tmpfs the batch template uses — S6 records that delta against obligation #1 in the substrate runbook.

D5 — Stamping: every result names repo@commit, from the platform's record, never from the model​

AcquireWorkspaceResponse.commit is the launcher's git rev-parse HEAD after checkout. The orchestrator stores it on the sandbox_sessions row (S1) and stamps it on:

  • the coder_session reply to the worker (so the coder's system prompt can cite it);
  • the dispatch result the orchestrator receives (coder_result is merged with the Go side's own {repo, base_commit, changed_paths} before it is projected to workflow_actions.output and the tool_result audit hop — the worker's report never supplies these; changed_paths comes from ReleaseWorkspaceResponse, i.e. from the launcher's git status --porcelain over the tree it is about to delete). The git directory never enters the sandbox mount (amended by S1 #4632, principal-architect review 6009358522 / backend-security review 6009354871): the launcher keeps it at a launcher-only path beside the work tree, mounts only the work tree at /work, and runs every git call with an explicit --git-dir and --work-tree plus core.fsmonitor=false and core.untrackedCache=false, each bounded by a launcher-side timeout. The release status also passes --ignore-submodules=all (git never enters a gitlink path, where a sandbox-built repository or a gitfile naming another host path would supply config: S1 round 2, backend-security review 6009781747 N1) and --ignored=matching (a sandbox-written .gitignore cannot hide a file: principal-architect review 6009798798 N2). So nothing a sandbox writes (a .git directory or pointer file, a config with fsmonitor or filter definitions, a repository or gitfile at a gitlink path, an index, a commit, a .gitignore) can make the socket-holding launcher execute a command or hide a change from changed_paths. Three reporting rules follow: a gitlink path is reported changed unless it is still the real, empty directory the checkout left (git does not look inside it, so the launcher decides, without following a symlink); changed_paths is capped at 10000 entries and a list of exactly that length is truncated, never exhaustive (dirty is true); and a status that fails, times out (a FIFO named .gitignore blocks git) or writes anything to stderr (git warns and exits 0 for what it could not examine, e.g. a chmod 000 directory; stdout alone is parsed) makes ReleaseWorkspace fail with a fixed error — never an empty list with dirty=false. The workspace is deleted either way. Repeat calls never read clean (S1 round 3, principal-architect review 6010280599 R3-1): only the call that examined the tree returns a list; an unknown id (never acquired, already released, failed or reaped) is NotFound, and a workspace still being acquired or released is Aborted (retryable) — so a retry of a failed release cannot turn the fail-closed answer into "nothing changed";
  • the governed write: the hook-overlaid updated_input on github.commit_files carries base_commit beside the idempotency key (ADR-0038 D5), so the commit object itself records the checkout it was authored against (Upsquad-Base-Commit: trailer).

Tier C's read tools (#3478) carry the same commit on every result (path@commit), as #3735's brief required. In neither mode does a result leave the workspace without the pin: a model claim that cannot be cited to repo@commit is not a result.

D6 — Cleanup: with the run, including transcripts and caches, and on every exit path​

ReleaseWorkspace(workspace_id) = stop the container if still up → rm -rf the workspace directory → rm -rf the session's config/scratch dirs → close the sandbox_sessions row. A repeat call never reads clean (amended by S1 round 3, principal-architect review 6010280599 R3-1, superseding the earlier "a second release of an unknown id is a no-op"): an unknown, already-released or reaped id is NotFound, a release already in progress is Aborted, and only the call that examined the tree returns changed_paths (see D5). It fires on:

  1. coder_result (normal end) — the orchestrator calls it inside the result handler, before the dispatch is projected complete;
  2. the run reaching a terminal state while a session is open (cancel, exhaustion, error) — the W2 sweeper (#4592) already owns terminal-state reconciliation; S1 adds "open sandbox sessions of a non-running run are released";
  3. lease expiry — the launcher keeps a lease per session (RenewLease, TTL 120 s, renewed by the orchestrator at TTL/3); a worker or orchestrator crash stops renewals and the launcher's reaper kills the container and deletes the workspace within 2 × TTL (S1 acceptance). W2 recovery then re-fires the dispatch as coder@N+1 in a fresh workspace (D1);
  4. launcher restart — a startup sweep removes every container it labelled and every directory under its workspace root older than the TTL.

Nothing is retained: a READ_WRITE workspace is never captured into the blob plane (the change leaves only through ADR-0038's governed write); a READ_ONLY workspace produced no bytes to keep. On Kubernetes there is no packed artifact (amended by S6 #4637): the work tree exists only on the pod's ephemeral volume, deleted with the pod. Repository-bearing sessions are excluded from automatic memory extraction, including on resume (founder, 2026-10-16, recorded on #3735) — the coder's turn is such a session.

D7 — The credential never enters: what is, and is not, in the sandbox​

Inside the sandbox process environment there is, exhaustively: PORT; UPSQUAD_RELAY_SECRET (consumed by the relay process and scrubbed before it execs the CLI — S3's relay contract); the forced-proxy variables; and, over the relay's keep-list (the driver.py:103-114 mechanism, now applied across the relay rather than a local wrapper), the Model Gateway route and the coder agent's own short-TTL team-gateway bearer — the same class of credential every roster agent already receives (OrchestratorAgentToken, runtime.proto:1144-1150), minted per segment (cmd/agent-orchestrator/agentsgates_runtime.go:207-269). The following are absent by construction and asserted by test (Stage 2 acceptance 4(d): grep of /proc/1/environ and of the tree from inside): the SCM token, the vault passphrase, DATABASE_URL, the platform signing key, the launcher's caller token, any long-lived token of ours. On Kubernetes no workspace signer exists (D4 as amended by S6 #4637); the relay secret reaches the pod over the authenticated init stream into a memory-medium file, never the pod spec.

api.github.com is not reachable from the sandbox — not because the grant omits it, but because the per-run squid grant (policy.go:102-118 DeriveEgressGrant, dev/sandbox/squid.conf:32-36) is requested ∩ tenant ∩ ¬deny and the coder requests nothing; the only additions are a platform tier (Model Gateway host, team gateway host — from the launcher's configuration, never from the definition) that S1 adds as one conf.d line reviewed by backend-security. Git write is an MCP tool behind the gateway (ADR-0038), so the sandbox needs no route to GitHub and gets none.

Amended 2026-11-22 (S3 review, PR #4683): "the credential never enters" covers every credential of ours, not only the SCM token. A sandboxed coder has Bash; any credential in its environment is the model's. In Stage 2 the sandbox environment therefore carries no team-gateway bearer, and the coder has no MCP until S5 tunnels it as a worker-side SDK MCP server whose every call passes PreToolUse. The model route is the one residual: until it is tunnelled to a worker-side proxy, it is a per-dispatch route with TTL ≤ wall + 5 min and a gateway-side spend cap equal to the dispatch budget, revoked on close (prod-enablement #4647). The team-gateway host is removed from the coder's platform tier when the tunnel lands.

Change note: the paragraph above is principal-architect review 6012369293 (PR #4683, finding F1, ruling (c)), applied verbatim. In S3 the team-gateway host has already left the platform tier (dev/sandbox/conf.d/20-platform-tier.conf), because no bearer path remains to need it; the per-dispatch route, its TTL and its spend cap are NOT built in S3 (the run's route token is in the sandbox, dev only) and are recorded as unmet prod-enablement gates on #4647.

Amended 2026-11-22 (S5, core#4636; principal-architect review 6014569135 on PR #4689, ruling AMEND): the sandbox holds no credential that authenticates to any platform service (its relay secret opens only its own relay session). (1) Gateway tools. A sandboxed coder's team-gateway tools are an in-process SDK MCP server hosted by the WORKER (upsquad_coder_gw, type: sdk). The sandboxed CLI reaches it over the CLI control protocol, which the relay carries as ordinary stdio; every call passes the coder's PreToolUse hook to the bridge first; the worker then executes only a call the bridge allowed, with exactly the input the bridge allowed (the ADR-0038 D5 overlay included), using the coder's own gateway bearer, which never leaves the worker. A call that skipped the hook, changed its arguments or replays is refused before the gateway; the worker records each execution itself (PostToolUse from the worker, the Go side marks the key executed), so a call the CLI re-fires or never reports runs once and is recorded once. Through that path a GitHub write is bound to the workspace repository and refused from a read_only session, and commit_files carries the session's base_commit. The bridge denies any other MCP name from a sandboxed caller, the worker builds the coder's options with no http server, and the relay refuses the bearer's name. (2) Model route. The CLI's ANTHROPIC_BASE_URL is the relay's own loopback listener and its token a fixed placeholder; each model call is a stream over the one relay connection to the worker's shim, which forwards only the Messages API to the Model Gateway with the route bearer it alone holds, meters every response the gateway returns, and enforces a HARD spend bound: each request's worst case (every body byte, plus 2000 tokens for the provider's hidden prompt and 2000 per image block, an input token priced as a cache write at 1.25×; every max_tokens an output token) is reserved before it is forwarded; the only cache write admitted is the default (5-minute, 1.25×) one — a 1-hour cache_control is refused — and document blocks are refused (they bill per page, not per byte); the worker's shim serves at most 16 concurrent streams. The residual, stated: a hidden prompt beyond 2000 tokens and an image beyond its 2000-token floor; the bound is one admission window of at most 16 streams at those terms (cents at the ceiling rates), settled when each response's real usage is charged (#4690), concurrent requests are admitted only while budget − spent − open reservations covers theirs, and a stream that ends before its final usage (an early close, a relay that dies) is charged its reservation. The channel is also an egress policy: a body that repeats a key is refused and the CHECKED object, re-serialised, is what is forwarded; only the CLI's own top-level request keys and betas pass; MCP servers, server tools (web fetch/search, computer), containers and URL-sourced content are refused, as is any method but POST, and every credential, cookie and x-upsquad-* header the sandbox sends is dropped. The relay refuses every ANTHROPIC_* name in the handshake. The coder's reported usage is the worker's measurement (cost_source = worker_metered), never the sandbox's; the dollars of record are the gateway's llm_usage_events rows by run (#4617). What remains in the sandbox environment is PORT, UPSQUAD_RELAY_SECRET (relay only) and the forced-proxy variables.

Change note (S5): the three #4647 route-token controls are superseded rather than built: no route token is in the sandbox, so there is no token to scope per dispatch, to expire or to revoke, and the spend bound is the shim's reservation-based cap at the dispatch's clamped budget. Still open on #4647 and on the named prod-enablement gate #4690 (backend-security ruling on #4689): the route the SHIM holds is the run's orchestrator route (attribution per agent stays with the SDK buckets and workflow_actions), and the Model Gateway host is still in the sandbox platform tier although nothing in the sandbox can authenticate to it (removal is a separate, devops-reviewed change to the egress smoke).

D8 — The enablement chain is one chain, and READ_ONLY shares its floor in Stage 2​

A sandboxed dispatch runs only when all hold, checked in this order, denied fail-closed at the first miss and before any container or clone exists:

  1. WF_CODE_EXEC_ENABLED (process; the launcher is not even constructed otherwise, main.go:1430);
  2. a code_exec_org_enablement row for the org (ruling D1 on #2597, S2; absent row = denied);
  3. RunScope.Clearance >= 4 (ruling 5; checked in the bridge beside the Governor call, bridge.go:150-157, with its own reason constant);
  4. the team source grant for (org, team, repo) (#4152; D1 above);
  5. the Governor's agent_action verdict for the dispatch target (bridge.go:293-307), and the before_agent gate if the definition declares one (orchestrator/gates.go:82-84).

READ_ONLY shares steps 1–5 unchanged in Stage 2, floor included. Tier C may argue a lower floor for a mount that is read-only with no Bash — but a lower floor is a widening, and it is routed as one with its own evidence in the Tier C LLD (#3680), not taken here by default. There is no new flag: the two kill levers of HLD #2597 §5 (the process flag and the org row) are the levers.

Rejected​

  • Clone inside the sandbox with a short-lived token — the ruling's named alternative. It hands the sandbox an SCM credential and an egress grant to the SCM host; a coder with Bash would then have both. Rejected by the founder; recorded so it is not re-asked.
  • The launcher resolves the credential itself (own vault passphrase + DB connection). The launcher is already root-equivalent on the host (docker socket); adding the tenant credential store to the same process makes one compromise total. The credential already has to cross one hop (vault → clone); crossing it inside an authenticated request to a process that holds nothing else is the smaller surface.
  • A per-team persistent workspace cache ("the checkout is the same, keep it warm"). It makes the team the execution boundary: edits, build artefacts and transcripts of run A become visible to run B, carrying run A's approvals with them. The cost it would save (one shallow clone) is seconds, not the 826 MiB the full history would be.
  • Materialising via the artifact store on docker too (one code path for both substrates). A second copy of every checkout through the blob plane for no isolation gain on a host that can bind-mount; the k8s path pays it only because the pod has no shared disk.
  • Full clone / history depth knob. Stage 2 offers no --depth N; the coder sees one commit of history. A repository whose change needs git log/blame is a Tier C index question, not a workspace question.
  • docker exec / pod-exec into a running sandbox. Needs a Docker SDK or client-go (neither in go.mod) and makes the orchestrator a second container-controlling component, which ruling 4 forbids. The relay (S3) exists so that no exec is ever needed.

Consequences​

  • Positive. One primitive serves the repo map and the coder; the credential posture is narrower than WR2-3's (amended by S6 #4637): no credential enters a sandbox for materialisation on any substrate (no workspace signer; the work tree is streamed in), and the only secret a pod receives is the single-use relay secret, over the authenticated init stream into a memory-medium file; every result carries repo@commit; a crash leaves nothing behind that a reaper cannot find by lease; the enablement chain reuses the two levers the founder already ratified; nothing widens: no new flag, no new credential class, no new egress to a tenant host.
  • Secrets committed in the tenant's own repository are readable by the coder (Read, Bash). Path deny-rules cover the conventional shapes; the gateway's redaction covers model egress; the rest is the tenant's repository hygiene, and this ADR says so rather than pretending otherwise (plan risk 4).
  • Disk. The coder tier needs ~2 GiB of disk-backed /work and a larger /tmp than the 32 MiB serve default; S2's policy row and S6's volume class carry it. Memory-backed tmpfs is not used for a checkout.
  • A crash re-dispatch re-clones and rebuilds — a cold Go/node cache per dispatch. Bounded by the per-dispatch max_cost_usd and the envelope; accepted over any cross-run cache (D1).
  • A new host path to guard — the launcher's workspace root. 0700, launcher uid, same path host-side and in the launcher container, swept on start.
  • No coder-session resume in Stage 2. The worker holds no transcript mirror for the sandboxed CLI; a crash mid-coder costs the dispatch, not the run.
  • Two layers for the mode means two tests per mode (mount flag, deny list), and a mutation of either must be caught by its own witness — not by the other layer masking it (WR2 retro class 5).

References​

Founder ruling 2 — #4578 comment 6980541294 · workspace tracker #3735 · Stage 2 tracker #4630 (plan in comment 1) · S0 contract #4631 · S1 #4632 · S3 #4634 · S6 #4637 · launcher privilege model #4598 (ruling 4) · HLD #2597 (D1–D3) · source foundation #4152 · Tier C #3680 · ADR-0038 · WR2-3: HLD #2113, LLD #2184, docs/runbooks/sandbox-substrate.md