Preserve managed exec policy after rules parse errors - #31188
Merged
Conversation
This was referenced Jul 6, 2026
This was referenced Jul 6, 2026
viyatb-oai
reviewed
Jul 6, 2026
| } | ||
| Err(err) => return Err(err.into()), | ||
| }; | ||
| let (exec_policy, warning) = load_exec_policy_with_warning(&config_layer_stack).await?; |
Contributor
There was a problem hiding this comment.
Can we add a proxy-state regression for this path? The helper test covers command policy, but not that malformed custom rules still preserve a managed denied domain here.
viyatb-oai
reviewed
Jul 6, 2026
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn malformed_custom_rules_preserve_requirements_exec_policy() -> anyhow::Result<()> { |
Contributor
There was a problem hiding this comment.
Can we add a test_codex regression here that starts a real session with malformed custom rules and a managed forbidden prefix, then verifies the command is rejected? This test only exercises the helper.
Contributor
Author
There was a problem hiding this comment.
Good call. Done.
viyatb-oai
approved these changes
Jul 6, 2026
etraut-openai
added a commit
that referenced
this pull request
Jul 6, 2026
## Why App-server initialization captures exec-policy parse warnings only once. Each `thread/start` then reloads config for that thread's cwd and rereads its `.rules` files, so rules that become malformed after initialization—or belong to a different project—are dropped without a fresh warning to the requesting client. ## What changed - Validate exec-policy rules against the freshly loaded per-thread config during `thread/start`. - Send the existing structured `configWarning` only to the connection that requested the thread. - Preserve nonfatal startup and avoid repeating an identical warning already delivered during initialization. This is intentionally separate from the TUI `legacy_core` cleanup in #31179 and the managed-requirements fallback fix in #31188.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Cleanup for #31179 exposed a core fallback bug that the TUI had been handling locally. When a custom
.rulesfile fails to parse, nonfatal clients warn and continue, butload_exec_policy_with_warningreplaced the entire policy withPolicy::empty()before managed requirements were merged. App-server and desktop clients could therefore silently lose required prompt and forbidden rules.This fix is intentionally separate from #31179 so the TUI cleanup does not depend on it.
What changed
codex exec.