Skip to content

Add remote_sandbox_config to our config requirements#18763

Merged
abhinav-oai merged 10 commits intomainfrom
abhinav/remote-sandbox-config
Apr 21, 2026
Merged

Add remote_sandbox_config to our config requirements#18763
abhinav-oai merged 10 commits intomainfrom
abhinav/remote-sandbox-config

Conversation

@abhinav-oai
Copy link
Copy Markdown
Collaborator

@abhinav-oai abhinav-oai commented Apr 20, 2026

Why

Customers need finer-grained control over allowed sandbox modes based on the host Codex is running on. For example, they may want stricter sandbox limits on devboxes while keeping a different default elsewhere.

Our current cloud requirements can target user/account groups, but they cannot vary sandbox requirements by host. That makes remote development environments awkward because the same top-level allowed_sandbox_modes has to apply everywhere.

What

Adds a new remote_sandbox_config section to requirements.toml:

allowed_sandbox_modes = ["read-only"]

[[remote_sandbox_config]]
hostname_patterns = ["*.org"]
allowed_sandbox_modes = ["read-only", "workspace-write"]

[[remote_sandbox_config]]
hostname_patterns = ["*.sh", "runner-*.ci"]
allowed_sandbox_modes = ["read-only", "danger-full-access"]

During requirements resolution, Codex resolves the local host name once, preferring the machine FQDN when available and falling back to the cleaned kernel hostname. This host classification is best effort rather than authenticated device proof.

Each requirements source applies its first matching remote_sandbox_config entry before it is merged with other sources. The shared merge helper keeps that apply_remote_sandbox_config step paired with requirements merging so new requirements sources do not have to remember the extra call.

That preserves source precedence: a lower-precedence requirements file with a matching remote_sandbox_config cannot override a higher-precedence source that already set allowed_sandbox_modes.

This also wires the hostname-aware resolution through app-server, CLI/TUI config loading, config API reads, and config layer metadata so they all evaluate remote sandbox requirements consistently.

Verification

  • cargo test -p codex-config remote_sandbox_config
  • cargo test -p codex-config host_name
  • cargo test -p codex-core load_config_layers_applies_matching_remote_sandbox_config
  • cargo test -p codex-core system_remote_sandbox_config_keeps_cloud_sandbox_modes
  • cargo test -p codex-config
  • cargo test -p codex-core unit tests passed; tests/all.rs integration matrix was intentionally stopped after the relevant focused tests passed
  • just fix -p codex-config
  • just fix -p codex-core
  • cargo check -p codex-app-server

@abhinav-oai abhinav-oai requested a review from a team as a code owner April 20, 2026 23:08
@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

1 similar comment
@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@abhinav-oai abhinav-oai changed the title initial impl Add remote_sandbox_config to our config requirements Apr 20, 2026
@abhinav-oai abhinav-oai force-pushed the abhinav/remote-sandbox-config branch from 4d611ac to 074862b Compare April 20, 2026 23:44
@abhinav-oai abhinav-oai force-pushed the abhinav/remote-sandbox-config branch from 074862b to c90555a Compare April 20, 2026 23:52
@abhinav-oai
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bb2015812f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/app-server/src/codex_message_processor.rs Outdated
Comment thread codex-rs/config/src/host_name.rs
Comment thread codex-rs/core/src/config/mod.rs Outdated
Comment thread codex-rs/app-server/src/codex_message_processor.rs Outdated
Comment on lines +47 to +52
#[cfg(windows)]
fn local_fqdn_for_hostname(_hostname: &str) -> Option<String> {
get_computer_name(ComputerNameKind::PhysicalDnsFullyQualified)
.ok()
.and_then(|hostname| hostname.into_string().ok())
.and_then(|hostname| normalize_fqdn_candidate(&hostname))
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

here's the windows part @dylan-hurd-oai

we're trying to grab the FQDN hostname so we can pattern match again the hostname pattern in the requirements

Comment thread codex-rs/core/src/config_loader/mod.rs Outdated

if let Some(requirements) = cloud_requirements.get().await.map_err(io::Error::other)? {
if let Some(mut requirements) = cloud_requirements.get().await.map_err(io::Error::other)? {
requirements.apply_remote_sandbox_config(requirements_hostname);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is it possible to move this directly inside CloudRequirementsLoader so people won't forget to apply it?

#[cfg(windows)]
use winapi_util::sysinfo::get_computer_name;

pub fn requirements_hostname() -> Option<String> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe make this field more general, just host name?

@abhinav-oai abhinav-oai enabled auto-merge (squash) April 21, 2026 05:03
@abhinav-oai abhinav-oai merged commit ab26554 into main Apr 21, 2026
37 of 39 checks passed
@abhinav-oai abhinav-oai deleted the abhinav/remote-sandbox-config branch April 21, 2026 05:05
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants