Skip to content

feat: gate unified exec zsh fork composition#24979

Merged
bolinfest merged 1 commit into
mainfrom
pr24979
Jun 1, 2026
Merged

feat: gate unified exec zsh fork composition#24979
bolinfest merged 1 commit into
mainfrom
pr24979

Conversation

@bolinfest

@bolinfest bolinfest commented May 28, 2026

Copy link
Copy Markdown
Collaborator

Why

shell_zsh_fork and unified exec need to remain independently controllable for enterprise rollouts, but we also need a third mode that composes them. That composed mode is intended to preserve unified exec command lifecycle support while letting the zsh fork provide more accurate execv(2) interception.

Enabling unified_exec_zsh_fork by itself is intentionally not sufficient. It is a composition gate, not a dependency-enabling shortcut:

  • unified_exec selects the PTY-backed unified exec tool.
  • shell_zsh_fork opts into the zsh fork backend.
  • unified_exec_zsh_fork only allows those two already-enabled modes to be composed so local zsh unified exec commands can launch through the zsh fork.

This separation is deliberate. Enterprises and staged rollouts must be able to enable or disable unified exec and zsh-fork independently. If unified_exec_zsh_fork implied either dependency, then enabling one under-development composition flag would silently activate a shell backend that the configured feature set left disabled.

This PR introduces only the configuration and planning gate for that composition. Existing shell_zsh_fork behavior continues to use the standalone shell tool unless the new composition feature is explicitly enabled alongside both dependencies.

What Changed

  • Added the under-development feature flag unified_exec_zsh_fork.
  • Added UnifiedExecFeatureMode so the three input feature flags collapse into Disabled, Direct, or ZshFork mode before tool planning.
  • Updated tool selection so zsh-fork composition requires unified_exec, shell_zsh_fork, and unified_exec_zsh_fork.
  • Kept the existing standalone zsh-fork shell tool behavior when only shell_zsh_fork is enabled.
  • Updated config schema output for the new feature flag.

Verification

  • Added feature and tool-config coverage for the new gate.
  • Added planner coverage proving shell_zsh_fork remains standalone until composition is explicitly enabled.
  • Ran focused tests for codex-features, codex-tools, and the affected codex-core planner case.

Stack created with Sapling. Best reviewed with ReviewStack.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 58b5b99d2b

ℹ️ 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/tools/src/tool_config.rs Outdated
features.enabled(Feature::ShellTool)
&& features.enabled(Feature::UnifiedExec)
&& features.enabled(Feature::ShellZshFork)
&& features.enabled(Feature::UnifiedExecZshFork)

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.

P1 Badge Keep zsh-fork composition off remote execs

When all three flags are enabled, this makes TurnContext.unified_exec_shell_mode globally ZshFork for the whole turn, not just local environments. Any exec_command targeting a remote turn environment then goes through the zsh-fork path; UnifiedExecRuntime explicitly rejects that path for remote environments ("unified_exec zsh-fork is not supported for remote environments"), so sessions with a remote environment and these rollout flags will have their unified exec commands fail instead of using the remote exec backend. Gate the zsh-fork mode per selected environment or fall back to Direct for remote execs.

Useful? React with 👍 / 👎.

Comment thread codex-rs/tools/src/tool_config.rs Outdated
ConfigShellToolType::Disabled
} else if features.enabled(Feature::ShellZshFork) {
} else if features.enabled(Feature::ShellZshFork)
&& !unified_exec_uses_zsh_fork_for_features(features)

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.

P2 Badge Preserve explicit shell selection in composition mode

With the composition flag enabled for a zsh user, this path exposes exec_command while UnifiedExecShellMode::ZshFork is selected for the whole session. That mode ignores the tool's documented shell argument and always builds a zsh -c/-lc command, so requests such as { "cmd": "...", "shell": "/bin/bash" } silently run under zsh instead of the requested shell. Either fall back to direct unified exec when shell names a non-zsh shell, reject the request, or stop advertising the shell parameter for this mode.

Useful? React with 👍 / 👎.

@bolinfest bolinfest merged commit d6748f7 into main Jun 1, 2026
46 of 62 checks passed
@bolinfest bolinfest deleted the pr24979 branch June 1, 2026 20:01
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants