Skip to content

core: move workspace roots onto environments#31655

Open
pakrym-oai wants to merge 11 commits into
mainfrom
pakrym/full-ci-environment-workspace-roots
Open

core: move workspace roots onto environments#31655
pakrym-oai wants to merge 11 commits into
mainfrom
pakrym/full-ci-environment-workspace-roots

Conversation

@pakrym-oai

@pakrym-oai pakrym-oai commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Depends on #31892.

Why

Workspace roots describe the filesystem available in a selected execution environment, but core stored them as separate thread-global session state. That split allowed the selected cwd and workspace roots to diverge and made remote executor sandbox context depend on app-server-host paths.

What changed

  • add optional runtimeWorkspaceRoots to app-server environment selections
  • default omitted per-environment roots to that environment's cwd
  • use top-level runtimeWorkspaceRoots only when app-server synthesizes default environments
  • carry environment-native roots as PathUri values through core and into filesystem/process sandbox contexts
  • keep session permission profiles symbolic and materialize :workspace_roots for the selected environment
  • remove the separate core session workspace-roots setting and derive compatibility responses from the primary environment
  • regenerate app-server schemas and document the environment-local behavior

Explicit empty environment roots remain empty. When explicit environments and top-level roots are both supplied, the explicit environments determine the roots.

Validation

  • just test -p codex-app-server-protocol
  • focused core session settings and permission-profile tests
  • app-server integration coverage for per-environment override and environment-cwd defaulting
  • checks for codex-core, codex-app-server, and codex-app-server-protocol

@pakrym-oai pakrym-oai marked this pull request as ready for review July 9, 2026 16:00
@pakrym-oai pakrym-oai requested a review from a team as a code owner July 9, 2026 16:00

@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: 76ec0b291f

ℹ️ 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/core/src/session/session.rs Outdated
Comment thread codex-rs/app-server/src/request_processors/turn_processor.rs Outdated
Comment on lines +706 to +710
.map(PathUri::to_abs_path)
.collect::<std::io::Result<Vec<_>>>()
})
.transpose()
.ok()

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 Keep foreign environment roots out of host path conversion

For cross-OS remote environments, such as a Linux app-server selecting a Windows exec environment with runtimeWorkspaceRoots: ["C:\\repo"], PathUri::to_abs_path rejects the Windows URI because it is not host-native, and the error is discarded before falling back to the legacy host roots. The turn context and model-visible filesystem permissions are then built for the host fallback instead of the selected environment-native roots, despite the API accepting those roots.

AGENTS.md reference: AGENTS.md:L317-L322

Useful? React with 👍 / 👎.

Comment thread codex-rs/app-server/src/request_processors/thread_processor.rs Outdated
Comment on lines +598 to +603
let legacy_fallback_workspace_roots = workspace_roots.unwrap_or(snapshot.workspace_roots);
let environment_selections = environment_selections.unwrap_or_else(|| {
self.thread_manager.default_environment_selections(
&legacy_fallback_cwd,
&legacy_fallback_workspace_roots,
)

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 Retarget implicit workspace roots on cwd-only turns

When turn/start changes only cwd, this reuses the previous snapshot roots unchanged, so a normal thread whose roots were implicitly [old_cwd] creates the next default environment with cwd = new_cwd but workspace_roots = [old_cwd]. Profiles that grant :workspace_roots therefore keep permitting the old directory and not the new working directory, regressing the prior cwd-retargeting behavior for app-server turns that move between workspaces.

AGENTS.md reference: AGENTS.md:L102-L110

Useful? React with 👍 / 👎.

Comment thread codex-rs/app-server/src/request_processors/turn_processor.rs Outdated
.unwrap_or_else(|| PathUri::from_abs_path(&turn_ctx.cwd));
let workspace_roots = turn_ctx.config.effective_workspace_roots();
let workspace_roots = tool.workspace_roots(req);
let permissions = workspace_roots

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.

verbose!

windows_sandbox_private_desktop: self.windows_sandbox_private_desktop,
})
.map_err(CodexErr::from)?;
let workspace_roots = self

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.

needs a todo

Comment thread codex-rs/core/src/session/turn_context.rs
.and_then(|turn_environment| turn_environment.cwd().to_abs_path().ok())
.unwrap_or_else(|| session_configuration.cwd().clone());
let per_turn_config = Self::build_per_turn_config(&session_configuration, cwd.clone());
let workspace_roots = primary_turn_environment

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.

needs todo

@pakrym-oai pakrym-oai force-pushed the pakrym/full-ci-environment-workspace-roots branch from aa1b8e8 to 78b99eb Compare July 9, 2026 20:41
@pakrym-oai pakrym-oai force-pushed the pakrym/full-ci-environment-workspace-roots branch from 78b99eb to 2917cdb Compare July 9, 2026 21:01
@pakrym-oai pakrym-oai changed the base branch from main to pakrym/full-ci-fs-workspace-roots July 9, 2026 21:02
@pakrym-oai

Copy link
Copy Markdown
Collaborator Author

@codex review this

@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: e215b3e109

ℹ️ 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/core/src/session/session.rs
Comment thread codex-rs/app-server/src/request_processors.rs
Comment thread codex-rs/app-server/src/request_processors/thread_processor.rs Outdated
Comment on lines +591 to +594
let environment_selections = environment_selections.unwrap_or_else(|| {
let workspace_roots = workspace_roots.unwrap_or(snapshot.workspace_roots);
self.thread_manager
.default_environment_selections(&legacy_fallback_cwd, &workspace_roots)

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 Rebind implicit roots on cwd-only updates

When a thread started with the default workspace root later receives only a cwd update, this path reuses snapshot.workspace_roots from the previous cwd instead of rebinding the implicit root to legacy_fallback_cwd. The next turn then runs in the new cwd while :workspace_roots still points at the old directory, so workspace-write commands or patches in the new cwd are denied unless the client also sends runtimeWorkspaceRoots (which thread/settings/update cannot do).

AGENTS.md reference: AGENTS.md:L102-L110

Useful? React with 👍 / 👎.

Comment thread codex-rs/core/src/session/session.rs
Base automatically changed from pakrym/full-ci-fs-workspace-roots to main July 9, 2026 23:20
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.

2 participants