Preserve saved sandbox permissions when resuming codex exec (#62194)

## Why

`codex exec resume` sends the current process's sandbox defaults as
overrides. A session started with `:read-only` can therefore resume with
workspace write access when the configured default is `:workspace`.

## What changed

- Restore the saved permission selection, working directory, and workspace
  roots by default. Honor explicit overrides and append directories requested
  with `--add-dir` to the resumed workspace roots.
- Recover built-in read-only permissions from older history without widening
  current read access. Require an explicit permission selection when a saved
  named profile cannot be loaded or saved read-only access cannot be restored.
- Report sandbox permissions and writable roots from the running thread.

## Testing

Add regression coverage for a denied write on the first resumed shell call,
legacy read-only history, explicit permission overrides, and workspace root
preservation with and without `--add-dir`.

GitOrigin-RevId: ed2cf3132f9ce34570661f801c9534a55696e3a5
This commit is contained in:
viyatb-oai
2026-11-18 05:13:56 +00:00
committed by copyberry
parent b78fa4af86
commit 89feadf3cc
16 changed files with 756 additions and 150 deletions
@@ -18,6 +18,7 @@ use codex_core::config::Config;
use codex_exec_server::BoundOutput;
use codex_protocol::models::WebSearchAction;
use codex_protocol::protocol::SessionConfiguredEvent;
use codex_utils_path_uri::PathUri;
use serde_json::json;
pub use crate::event_processor::CodexStatus;
@@ -611,6 +612,7 @@ impl EventProcessor for EventProcessorWithJsonOutput {
_: &Config,
_: &str,
session_configured: &SessionConfiguredEvent,
_: &[PathUri],
) {
self.emit(Self::thread_started_event(session_configured));
}