Respect explicit untrusted project config (#18626)

## Why

Fixes #18475. A `-c` override such as `projects.<cwd>.trust_level =
"untrusted"` is meant to be a runtime config override, but app-server
thread startup treated any non-trusted project as eligible for automatic
trust persistence when a permissive sandbox/cwd was requested. That
meant an explicit `untrusted` session override could still cause
`config.toml` to be updated with `trusted`.

## What changed

The app-server auto-trust path now runs only when the active project
trust level is unknown. Explicit `trusted` and explicit `untrusted`
values are both respected, regardless of whether they came from
persisted config or session flags.

A focused `thread/start` test now covers the explicit `untrusted` case
with a permissive sandbox request.

## Verification

- `cargo test -p codex-app-server`
- `just fix -p codex-app-server`
This commit is contained in:
Eric Traut
2026-04-23 10:51:17 -07:00
committed by GitHub
Unverified
parent f1061d9d07
commit c2423f42d1
2 changed files with 39 additions and 1 deletions
@@ -2597,7 +2597,7 @@ impl CodexMessageProcessor {
requested_permissions_trust_project(&typesafe_overrides, config.cwd.as_path());
if requested_cwd.is_some()
&& !config.active_project.is_trusted()
&& config.active_project.trust_level.is_none()
&& (requested_permissions_trust_project
|| matches!(
config.permissions.sandbox_policy.get(),