Notify extensions when Guardian policy changes the approvals reviewer (#63995)

## Why

A Guardian policy refresh can switch a running thread from Auto Review
to user approvals. Without a config change notification, Guardian's
shadow reviewers can stay active after that switch.

## What changed

Notify config contributors with the previous and updated effective
configs when a policy refresh changes the approvals reviewer. Send the
notification after releasing the session locks, even if the refreshed
policy blocks the current model.

## Testing

Extend the Guardian shadow test to refresh policy on a root thread and
its child. Verify that both receive the reviewer change, that switching
to user approvals cancels their shadow reviewers, and that allowing
Auto Review again restores the requested reviewer.

GitOrigin-RevId: fd61acf7fb161be341a63a2e867582e6c308d0dc
This commit is contained in:
felixxia-oai
2026-11-25 22:42:49 +00:00
committed by copyberry
parent 71cf244137
commit 9938ffba35
3 changed files with 107 additions and 34 deletions
+13 -2
View File
@@ -77,6 +77,10 @@ impl Session {
.unwrap_or_else(|_| requirements.approvals_reviewer.value());
config.requested_approvals_reviewer = Some(requested);
config.approvals_reviewer = reviewer;
let notify_contributors = configuration.step_settings.approvals_reviewer != reviewer
&& !self.services.extensions.config_contributors().is_empty();
let previous_config =
notify_contributors.then(|| Self::build_effective_session_config(configuration));
let previous = Arc::downgrade(current);
let config = Arc::new(config);
let snapshots = &mut state.guardian_config_snapshots;
@@ -100,7 +104,10 @@ impl Session {
.step_settings
.validate(&configuration.step_settings_constraints(&configuration.environments))
});
match validation {
// The reviewer change is published even if the new policy blocks the current model.
let new_config =
notify_contributors.then(|| Self::build_effective_session_config(configuration));
let outcome = match validation {
Ok(()) => {
if was_blocked && !state.shutting_down {
self.input_queue.pending_work_wake.notify_one();
@@ -111,7 +118,11 @@ impl Session {
warn!(%error, "Guardian policy blocks the current model");
ConfigRefreshOutcome::Rejected
}
}
};
drop(binding);
drop(state);
self.emit_config_changed_contributors(previous_config.as_ref(), new_config.as_ref());
outcome
}
pub(crate) async fn refresh_runtime_config(