mirror of
https://github.com/openai/codex.git
synced 2026-11-16 06:54:36 +00:00
Add request-scoped Guardian approval decisions (#42807)
## What changed - Extend `ApprovalReviewContributor` with a `decide` hook that can allow an action, return a synchronous review result, or hand the request to the user. - Pass contributors the request's approval state and a callback bound to the existing synchronous reviewer. Review results satisfy the review gate while the host continues to enforce permissions. - Add structured reasons for requesting a fresh Guardian review and select the first contributor decision in registration order. GitOrigin-RevId: ec84474b3fcbcf1027c8502aa1c2947c10149f9d
This commit is contained in:
1 parent
89a4eec6da
commit
0ae02915bd
8 files changed
+145
-1
No files matched your search
@@ -18,6 +18,7 @@ mod metrics;
|
||||
mod prompt;
|
||||
mod review;
|
||||
mod review_session;
|
||||
mod runtime;
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -405,6 +405,35 @@ async fn run_guardian_review(
|
||||
return decision;
|
||||
}
|
||||
|
||||
let runtime = super::runtime::ReviewRuntime {
|
||||
session,
|
||||
context,
|
||||
review_id,
|
||||
request,
|
||||
reasons,
|
||||
options,
|
||||
};
|
||||
codex_extension_api::SynchronousApprovalReviewer::review(
|
||||
&runtime,
|
||||
codex_protocol::approvals::GuardianReviewReason::Policy,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Runs the existing synchronous reviewer without choosing policy or reusing a score.
|
||||
pub(super) async fn run_synchronous_review(
|
||||
runtime: super::runtime::ReviewRuntime,
|
||||
_review_reason: codex_protocol::approvals::GuardianReviewReason,
|
||||
) -> ReviewDecision {
|
||||
let super::runtime::ReviewRuntime {
|
||||
session,
|
||||
context,
|
||||
review_id,
|
||||
request,
|
||||
reasons,
|
||||
options,
|
||||
} = runtime;
|
||||
let turn = Arc::clone(context.turn());
|
||||
let GuardianReviewOptions {
|
||||
plugin_attribution_override,
|
||||
approval_request_source,
|
||||
@@ -777,6 +806,7 @@ async fn run_guardian_review(
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct GuardianReviewOptions {
|
||||
pub(crate) plugin_attribution_override: Option<PluginCommandAttribution>,
|
||||
pub(crate) approval_request_source: GuardianApprovalRequestSource,
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
//! Binds the existing synchronous reviewer to one captured approval action.
|
||||
|
||||
use codex_extension_api::ExtensionFuture;
|
||||
use codex_extension_api::SynchronousApprovalReviewer;
|
||||
use codex_protocol::protocol::ReviewDecision;
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::ApprovalRequestReasons;
|
||||
use super::GuardianApprovalRequest;
|
||||
use super::GuardianReviewContext;
|
||||
use super::GuardianReviewOptions;
|
||||
use super::review::run_synchronous_review;
|
||||
use crate::session::session::Session;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(super) struct ReviewRuntime {
|
||||
pub(super) session: Arc<Session>,
|
||||
pub(super) context: GuardianReviewContext,
|
||||
pub(super) review_id: String,
|
||||
pub(super) request: GuardianApprovalRequest,
|
||||
pub(super) reasons: ApprovalRequestReasons,
|
||||
pub(super) options: GuardianReviewOptions,
|
||||
}
|
||||
|
||||
impl SynchronousApprovalReviewer for ReviewRuntime {
|
||||
fn review(
|
||||
&self,
|
||||
reason: codex_protocol::approvals::GuardianReviewReason,
|
||||
) -> ExtensionFuture<'_, ReviewDecision> {
|
||||
Box::pin(run_synchronous_review(self.clone(), reason))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user