Repository navigation
Description
Problem
#396 (v0.4.5) gives Codex coding runs a Lab-owned Go cache by setting GOCACHE and GOTMPDIR in the harness process environment and adding --add-dir <lab>/caches/harness. On a real run, Codex's own go test ./... and go vet ./... still failed with a sandbox denial on ~/Library/Caches/go-build, and Codex reported the run as blocked.
Seen on forgecell-trial Issue #3 with v0.4.5, Molecule mol-3-9fd6dbd16593acd6266fa447. The attempt record shows the cache was attached (harnessCache.gocache = <lab>/caches/harness/go-build).
The cause is Codex's shell_environment_policy. The user's ~/.codex/config.toml sets shell_environment_policy.inherit = "core", so Codex passes only core variables (HOME, PATH, USER, …) to the commands it runs, and drops GOCACHE and GOTMPDIR. Go then falls back to its default cache under HOME, which the sandbox denies. With Codex's default (inherit = "all") the variables would get through, so whether #396 works depends on the user's config.
Decisions
- Pass the cache through Codex's own config override, which a policy can't filter. Alongside
--add-dir, add-c shell_environment_policy.set.GOCACHE="<root>/go-build"and-c shell_environment_policy.set.GOTMPDIR="<root>/gotmp"tocodex exec, with the values TOML-quoted.setapplies afterinheritand the include/exclude filters, so the variables reach every command whatever the user's policy is. Keep setting them in the process environment as well. - Only where Give Codex coding runs a writable Lab-owned Go build cache (#43, slice 1) #396 applies: Codex coding requests that carry the harness cache. Nothing else changes.
- The quoting is safe. The cache root is already a validated clean absolute path with no control characters. Quote it as a TOML basic string, escaping
\and", and refuse a path containing a newline. - Protocol 9. This changes the Codex invocation, so bump
AdapterProtocolVersionfrom 8 to 9 and pin the new contract digest, as Give Codex coding runs a writable Lab-owned Go build cache (#43, slice 1) #396 did. - Note it in the isolation text. Doctor's Codex isolation line should say that coding runs override
shell_environment_policy.set.GOCACHEandGOTMPDIR.
Acceptance
- A Codex coding invocation with the harness cache carries
--add-dir <root>and both-c shell_environment_policy.set.…overrides with the right quoted values. - Analysis, review and meta invocations, and Claude Code and Cursor, are unchanged.
- A cache root containing
"or\is quoted correctly; one with a newline is refused. - The pinned contract digest moves to protocol 9; versions 2–8 keep their pins.
- Verified for real afterwards: a Codex coding run on forgecell-trial with
inherit = "core"runsgo testwithout a cache denial.
Activity
Pass the harness Go cache through Codex's shell_environment_policy (#401
DanielNetzer commentedon Nov 7, 2026
Fixed in #404.