Add keyed shell environment policy filters (#34590)

## What changed

- Add `shell_environment_policy.filters`, mapping environment-variable patterns to `include` or `exclude`, while continuing to accept the legacy `exclude` and `include_only` arrays.
- Merge filter keys case-insensitively across config layers so higher-precedence entries can override individual patterns. Switching representations replaces the other representation instead of combining them.
- Reject mixed, duplicate, or malformed filter definitions in enabled layers, config writes, and reloads, while retaining the previous session configuration when a reload is invalid.
- Make config-manager reads and writes representation-aware and preserve existing formatting when updating individual policy values.

## Testing

Add coverage for parsing, schema constraints, layered merging, validation and diagnostics, config writes, override metadata, and invalid session reloads.

GitOrigin-RevId: e15464bca53e6e7ef31fcc97537fda60ed5d670a
This commit is contained in:
Abhinav authored and copyberry committed 2026-07-21 18:23:26 +00:00
1 parent 65f8bf6853
commit 7442f5f932
29 files changed
+1662 -115

No files matched your search

+3 -3
View File
@@ -2512,7 +2512,7 @@ async fn update_feature_flags_disabling_guardian_clears_review_policy_and_restor
app.config.config_layer_stack = app
.config
.config_layer_stack
.with_user_config(&config_toml_path, user_config);
.with_user_config(&config_toml_path, user_config)?;
app.config
.features
.set_enabled(Feature::GuardianApproval, /*enabled*/ true)?;
@@ -2608,7 +2608,7 @@ async fn update_feature_flags_enabling_guardian_overrides_explicit_manual_review
app.config.config_layer_stack = app
.config
.config_layer_stack
.with_user_config(&config_toml_path, user_config);
.with_user_config(&config_toml_path, user_config)?;
app.config.approvals_reviewer = ApprovalsReviewer::User;
app.chat_widget
.set_approvals_reviewer(ApprovalsReviewer::User);
@@ -2677,7 +2677,7 @@ async fn update_feature_flags_disabling_guardian_clears_manual_review_policy_wit
app.config.config_layer_stack = app
.config
.config_layer_stack
.with_user_config(&config_toml_path, user_config);
.with_user_config(&config_toml_path, user_config)?;
app.config
.features
.set_enabled(Feature::GuardianApproval, /*enabled*/ true)?;