Skip to content

Codex's shell_environment_policy drops the harness GOCACHE (#396 follow-up) #401

Closed

Description

@DanielNetzer

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

  1. 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" to codex exec, with the values TOML-quoted. set applies after inherit and 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.
  2. 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.
  3. 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.
  4. Protocol 9. This changes the Codex invocation, so bump AdapterProtocolVersion from 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.
  5. Note it in the isolation text. Doctor's Codex isolation line should say that coding runs override shell_environment_policy.set.GOCACHE and GOTMPDIR.

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" runs go test without a cache denial.

Activity

  1. added
    bugSomething isn't working
    Next improvementCapabilities, composition, evidence and usability after the reviewed-PR MVP.
    on Nov 7, 2026
  2. DanielNetzer commented on Nov 7, 2026

    @DanielNetzer
    OwnerAuthor

    Fixed in #404.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Next improvementCapabilities, composition, evidence and usability after the reviewed-PR MVP.bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions