Skip to content

Add OpenAI Codex Cloud sandbox environment support - #2244

Merged
Asherlc merged 2 commits into
mainfrom
claude/dofek-codex-setup-fixes-tq1src
Jul 28, 2026
Merged

Asherlc merged 2 commits into
mainfrom
claude/dofek-codex-setup-fixes-tq1src

Conversation

@Asherlc

@Asherlc Asherlc commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Summary

Add support for running development tasks in OpenAI's Codex Cloud sandbox environment, which lacks Docker and requires special handling for service startup and testing workflows.

Changes

  • AGENTS.md: Added comprehensive "OpenAI Codex Cloud specific instructions" section documenting:

    • Docker unavailability and why workarounds won't help
    • SANDBOX=1 environment variable to skip Docker-dependent service startup
    • mise run test:sandbox verification gate for Docker-free checks (typecheck, biome, unit/mobile tests)
    • Integration test expectations (write tests but flag as locally unverified; CI still gates them)
    • Secrets lifecycle and runtime credential handling in Codex environments
  • scripts/dev-environment.ts: Modified start() function to detect SANDBOX=1 and skip Docker-backed service startup (Postgres, ClickHouse, Kafka, Redis) with an informative message directing users to test:sandbox

  • scripts/dev-environment.test.ts: Added test coverage for sandbox mode:

    • New sandbox option in test fixtures
    • Test verifying that SANDBOX=1 skips all service startup commands and returns success
  • mise.toml: Added test:sandbox task that runs Docker-free verification:

    • Recursive typecheck across all packages
    • Biome linting
    • Unit and mobile tests (no integration tests)

Implementation Details

The SANDBOX=1 check is a simple early return in the start() function, preventing any Docker commands from being invoked. This allows mise run cloud:init to complete successfully by running cloud:prebuild (dependencies, CodeGraph, RTK) while skipping the Docker-dependent cloud:start path. The test:sandbox task provides the closest equivalent to local pre-push checks within the sandbox constraints.

https://claude.ai/code/session_01FosqbddopEXkiCfhRfTMav

Summary by Sourcery

Add support for running the dev environment and verification checks in Docker-less OpenAI Codex Cloud sandboxes using a SANDBOX=1 mode and a new sandbox test task.

New Features:

  • Document Codex Cloud-specific development workflows, constraints, and verification steps in AGENTS.md.
  • Introduce a SANDBOX=1 mode in the dev environment script to skip Docker-backed service startup in sandboxed agents.
  • Add a test:sandbox task to run Docker-free typechecks, linting, and unit/mobile tests via mise.

Enhancements:

  • Extend dev-environment tests to cover SANDBOX-based behavior that skips service startup.

Summary by cubic

Adds sandbox support for OpenAI Codex Cloud by skipping Docker-backed services when SANDBOX=1 and adding a Docker-free test:sandbox task with full Node-only lint policies. This lets mise run cloud:init succeed in the sandbox while keeping integration tests CI-only.

  • New Features

    • scripts/dev-environment.ts: start() exits early when SANDBOX=1 and skips Docker services.
    • mise.toml: Added test:sandbox (recursive typecheck, pnpm lint:sandbox, unit/mobile tests).
    • package.json: Added lint:sandbox (Node-only lint checks) and redefined lint as lint:sandbox + lint:analytics-sql.
    • scripts/dev-environment.test.ts: Test verifies SANDBOX=1 skips all service startup and succeeds.
    • AGENTS.md: Updated Codex Cloud guidance; cites the Docker limit as observed in setup logs, explains SANDBOX=1, test:sandbox, and CI gating for integration tests.
  • Migration

    • In Codex Cloud, set SANDBOX=1 and run mise run cloud:init.
    • Use mise run test:sandbox to verify; integration tests run in CI.

Written for commit 44e60b6. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Added sandbox-aware development workflows that skip Docker-dependent service startup when Docker is unavailable.
    • Added a dedicated sandbox verification task covering type checks, formatting, linting, and tests.
  • Documentation

    • Documented sandbox environment limitations, verification steps, integration-test expectations, and secret-handling guidance.
  • Tests

    • Added coverage confirming sandbox mode avoids starting local services and completes successfully.

Codex cloud containers cannot run Docker: the kernel blocks user
namespace creation, so installing the binary does not help. `mise run
cloud:init` therefore died at the `cloud:start` step with "Unable to run
docker: spawnSync docker ENOENT", leaving the environment unbootable.

Gate the Docker-backed startup path behind SANDBOX=1 rather than
removing it, so local development keeps starting Postgres, ClickHouse,
and Redis and keeps hard-failing when the daemon is genuinely down.

Add a `test:sandbox` task so work is still verifiable without those
services: every package's typecheck, biome, and the Docker-free unit and
mobile test tiers. Integration coverage remains a CI gate.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FosqbddopEXkiCfhRfTMav
Copilot AI review requested due to automatic review settings July 28, 2026 17:54
@cursor

cursor Bot commented Jul 28, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @Asherlc, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@codereviewbot-ai

codereviewbot-ai Bot commented Jul 28, 2026

Copy link
Copy Markdown

LGTM! The changes cleanly check SANDBOX=1 to skip Docker and local service startup in sandboxed environments, with full unit test coverage added in scripts/dev-environment.test.ts.


🤖 Reviewed by codereviewbot.ai - Catch bugs before your team does.

@sourcery-ai

sourcery-ai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds first-class support for running dev workflows in OpenAI Codex Cloud’s Docker-less sandbox by gating Docker-dependent startup behind SANDBOX=1, introducing a Docker-free test:sandbox task, and documenting Codex-specific constraints and expectations for testing and secrets.

Sequence diagram for cloud:init and sandbox-aware startup

sequenceDiagram
  participant Developer
  participant Mise
  participant Task_cloud_init
  participant Dev_environment_start
  participant Docker
  participant Compose_up
  participant Setup_db

  Developer->>Mise: mise run cloud:init
  Mise->>Task_cloud_init: run cloud:prebuild
  Task_cloud_init-->>Mise: prebuild complete
  Mise->>Task_cloud_init: run cloud:start
  Task_cloud_init->>Dev_environment_start: start()

  alt SANDBOX == 1
    Dev_environment_start-->>Task_cloud_init: write SANDBOX=1 skip message
  else SANDBOX != 1
    Dev_environment_start->>Docker: runCommand docker info
    Dev_environment_start->>Compose_up: runCommand pnpm compose:up
    Dev_environment_start->>Setup_db: runCommand pnpm setup-db
  end
Loading

Flow diagram for SANDBOX handling in dev-environment start

flowchart TD
  Start[call start]
  Check{SANDBOX == 1}
  Start --> Check
  Check -- Yes --> Msg[write SANDBOX=1 skip message]
  Msg --> End[return]
  Check -- No --> Docker[runCommand docker info]
  Docker --> Compose[runCommand pnpm compose:up]
  Compose --> SetupDB[runCommand pnpm setup-db]
Loading

File-Level Changes

Change Details Files
Document Codex Cloud sandbox constraints and prescribed workflows.
  • Added a Codex Cloud–specific section describing the codex-universal image and linking to OpenAI cloud environment docs.
  • Explained that Docker and Docker-dependent services/tests cannot run in the sandbox and listed commands that will fail there.
  • Documented using SANDBOX=1 with mise run cloud:init to bypass Docker-backed startup while still running prebuild steps.
  • Described mise run test:sandbox as the Docker-free verification gate and how it maps to existing pre-push expectations.
  • Clarified expectations for still writing integration tests, marking them as locally unverified, and relying on CI to run them.
  • Explained Codex secrets lifecycle, emphasizing that runtime credentials must be written during setup and that Infisical-backed secrets are unavailable at agent runtime.
AGENTS.md
Gate dev-environment start() logic on SANDBOX=1 to skip Docker-backed services in sandboxed environments.
  • Added an early return in start() when process.env.SANDBOX === "1" that prints guidance about Docker unavailability and suggests mise run test:sandbox.
  • Kept the existing Docker-dependent startup sequence (docker info, compose up, setup-db) for non-sandbox environments unchanged.
scripts/dev-environment.ts
Extend dev-environment tests to cover SANDBOX behavior.
  • Extended the dev-environment test fixture to accept a sandbox boolean flag and plumbed it into the environment as SANDBOX.
  • Added a test case that runs the start command with sandbox enabled, asserting exit status 0, no commands executed, and the SANDBOX messaging in stdout.
scripts/dev-environment.test.ts
Introduce a Docker-free test:sandbox task for Codex Cloud verification.
  • Added a test:sandbox task that runs recursive per-package typechecks, Biome linting with a diagnostics cap, and regular unit/mobile tests without integration tests.
  • Left existing cloud:init and doctor tasks intact so that SANDBOX behavior is driven via the environment variable and not by separate task wiring.
mise.toml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Support Docker-free OpenAI Codex Cloud sandboxes

✨ Enhancement 🧪 Tests 📝 Documentation ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Allow Codex Cloud initialization to bypass unavailable Docker services via SANDBOX=1.
• Add Docker-free typechecking, linting, and tests through test:sandbox.
• Document sandbox constraints, integration-test expectations, and runtime secret handling.
Diagram

graph TD
  A["Codex Cloud"] --> B["cloud:init"] --> C["cloud:prebuild"] --> D{"SANDBOX=1?"}
  D -- Yes --> E["Skip services"] --> F["test:sandbox"]
  D -- No --> G["Docker services"] --> H["Environment doctor"]
Loading
High-Level Assessment

The explicit SANDBOX=1 opt-in is the appropriate approach because it isolates Codex-specific behavior while preserving hard failures for broken local Docker environments. Automatic Codex detection or silently tolerating every missing Docker daemon would be less predictable and could conceal genuine setup failures.

Files changed (4) +49 / -0

Enhancement (1) +9 / -0
dev-environment.tsBypass service startup in sandbox mode +9/-0

Bypass service startup in sandbox mode

• Adds an early return when 'SANDBOX=1', preventing Docker checks, service startup, database setup, and full environment diagnostics. It prints guidance directing sandbox users to the new verification task.

scripts/dev-environment.ts

Tests (1) +11 / -0
dev-environment.test.tsVerify sandbox startup bypasses Docker services +11/-0

Verify sandbox startup bypasses Docker services

• Extends test fixtures to set 'SANDBOX' explicitly and adds coverage confirming sandbox startup succeeds without executing service commands. The test also verifies that users receive sandbox-specific guidance.

scripts/dev-environment.test.ts

Documentation (1) +21 / -0
AGENTS.mdDocument Codex Cloud sandbox workflows and constraints +21/-0

Document Codex Cloud sandbox workflows and constraints

• Documents Docker unavailability, sandbox initialization, Docker-free verification, integration-test expectations, and the Codex secrets lifecycle. It clarifies which commands cannot run and what contributors must report as locally unverified.

AGENTS.md

Other (1) +8 / -0
mise.tomlAdd a Docker-free sandbox verification task +8/-0

Add a Docker-free sandbox verification task

• Defines 'test:sandbox' to run recursive workspace typechecks, Biome checks, and Docker-free unit and mobile tests without starting infrastructure services.

mise.toml

@Asherlc
Asherlc enabled auto-merge July 28, 2026 17:56
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds Codex Cloud guidance, a test:sandbox verification task, and SANDBOX=1 handling that skips Docker-backed service startup with test coverage.

Changes

Codex sandbox workflow

Layer / File(s) Summary
Sandbox startup guard
scripts/dev-environment.ts, scripts/dev-environment.test.ts
The test harness propagates SANDBOX, and start() exits before Docker and service commands when sandbox mode is enabled.
Sandbox instructions and verification
AGENTS.md, mise.toml
Codex Cloud constraints, credential handling, and the Docker-free test:sandbox workflow are documented.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • Asherlc/dofek#2224: Introduces related cloud development environment behavior centered on scripts/dev-environment.ts.

Suggested labels: type/feature

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 1 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title is imperative and concise, but it lacks the required area prefix for this cross-cutting change. Prefix it with the relevant area, e.g. [server] Add OpenAI Codex Cloud sandbox environment support.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

qodo-code-review Bot commented Jul 28, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 147 rules

Grey Divider


Remediation recommended

1. Codex kernel claim uncited ✓ Resolved 📘 Rule violation § Compliance
Description
The claim that Codex blocks user namespaces and cannot run Docker lacks an adjacent OpenAI
primary-source citation. The nearby Testcontainers link does not substantiate Codex Cloud kernel
behavior.
Code

AGENTS.md[272]

+The Codex container's kernel blocks user namespace creation, so the Docker daemon cannot run. Installing the `docker` binary does not help and must not be attempted; there is no workaround, and time spent on one is wasted. Consequently Postgres/TimescaleDB, ClickHouse, Kafka/Redpanda, Redis, and [testcontainers](https://testcontainers.com/) are all unavailable.
Relevance

⭐⭐⭐ High

Strong precedent consistently accepts adjacent primary-source citation fixes for third-party
behavior claims.

PR-#2052
PR-#2237
PR-#2047

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 1505719 requires third-party platform behavior claims in AGENTS.md to have an
adjacent official or primary-source citation. AGENTS.md line 272 makes specific claims about the
Codex container kernel and Docker availability without an adjacent OpenAI citation.

Rule 1505719: Cite third-party behavior claims in docs with primary sources
AGENTS.md[272-272]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The documentation asserts that the Codex container blocks user namespace creation and cannot run Docker, but it does not cite an adjacent OpenAI primary source supporting that behavior.

## Issue Context
The Testcontainers hyperlink in the paragraph does not substantiate claims about Codex Cloud's kernel restrictions. Add an official OpenAI citation next to the claim, or rephrase it as a repository-specific observed limitation if no official source exists.

## Fix Focus Areas
- AGENTS.md[272-272]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Sandbox gate omits policies ✓ Resolved 🐞 Bug ⚙ Maintainability
Description
test:sandbox substitutes a raw Biome invocation for the lint suite and therefore omits Docker-free
checks such as suppression detection and workflow-download validation. Repository-policy violations
can pass the documented sandbox verification gate and cause avoidable CI failures.
Code

mise.toml[45]

+  "pnpm exec biome check . --max-diagnostics=500",
Relevance

⭐⭐⭐ High

The documented gate omits runnable policy checks; similar incomplete quality-gate fixes were
accepted.

PR-#896
PR-#1807
PR-#2224

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The root lint command includes multiple policy scripts beyond Biome. At least suppression detection
and workflow-download validation only inspect tracked files or workflow contents using Node and Git,
so the lack of Docker does not justify excluding them from the sandbox gate; nevertheless, the new
task runs only Biome, typechecking, and tests.

mise.toml[41-47]
package.json[130-141]
scripts/no-suppressions.ts[23-51]
scripts/workflow-download-policy.ts[1-78]
AGENTS.md[279-280]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The sandbox verification task runs Biome directly, omitting repository policy checks that do not require Docker or ClickHouse.

## Issue Context
Keep `lint:analytics-sql` excluded where its service dependency is unavailable, but invoke the independently runnable policy scripts from `test:sandbox` so the documented gate catches their violations locally.

## Fix Focus Areas
- mise.toml[41-47]
- package.json[130-141]
- AGENTS.md[279-280]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

Comment thread AGENTS.md Outdated
Comment thread mise.toml Outdated
Review flagged two real gaps. `test:sandbox` ran biome directly, skipping
`lint:suppressions`, `lint:workflow-downloads`, `lint:exact-versions`,
`lint:analytics-policy`, `lint:mobile-telemetry`, and `lint:web-stories`
— all pure Node/git checks that run fine without Docker, so policy
violations could pass the sandbox gate and fail CI instead.

Extract `lint:sandbox` as `pnpm lint` minus `lint:analytics-sql`, the one
policy that needs uv and a running ClickHouse, and define `lint` in terms
of it so the two cannot drift.

The Docker claim in AGENTS.md had no primary source, because OpenAI does
not document it. Attribute it to our own setup logs as an observed
limitation instead of implying documented behavior, and tighten the
section.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FosqbddopEXkiCfhRfTMav
@codereviewbot-ai

codereviewbot-ai Bot commented Jul 28, 2026

Copy link
Copy Markdown

LGTM


🤖 Reviewed by codereviewbot.ai - Catch bugs before your team does.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@AGENTS.md`:
- Around line 271-285: Add one blank line after each new Markdown heading in
AGENTS.md: “There is no Docker — do not try to install it,” “Boot the
environment with SANDBOX=1,” “Verify work with mise run test:sandbox,” “Still
write integration tests — flag them as locally unverified,” and “Secrets are
gone by the time you run,” before their following paragraphs, preserving all
content unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 67bc53a1-357f-4fcd-8d12-6f5c913baafd

📥 Commits

Reviewing files that changed from the base of the PR and between d9a65db and 00f1275.

📒 Files selected for processing (4)
  • AGENTS.md
  • mise.toml
  • scripts/dev-environment.test.ts
  • scripts/dev-environment.ts

Comment thread AGENTS.md Outdated
@github-actions

Copy link
Copy Markdown
Contributor

Storybook previews for 3865f999 are ready:

This comment updates automatically on each PR push.

@Asherlc
Asherlc merged commit f32d853 into main Jul 28, 2026
187 of 191 checks passed
@Asherlc
Asherlc deleted the claude/dofek-codex-setup-fixes-tq1src branch July 28, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants