aKode fase 2c: eliminato il codice di invio dati (crate analytics, otel-trace-websocket, sentry, esportatori OTLP); /feedback salva solo in locale; chiavi legacy [analytics]/[otel] accettate e ignorate; test di analytics/OTLP/upload rimossi
Some checks failed
blocking-ci / rust-ci (push) Has been cancelled
blocking-ci / sdk (push) Has been cancelled
blocking-ci / CI required (push) Has been cancelled
blocking-ci / Bazel (push) Has been cancelled
blocking-ci / Blob size policy (push) Has been cancelled
blocking-ci / cargo-deny (push) Has been cancelled
blocking-ci / Codespell (push) Has been cancelled
blocking-ci / repo-checks (push) Has been cancelled
postmerge-ci / rust-ci-full (push) Has been cancelled
postmerge-ci / v8-canary (push) Has been cancelled
postmerge-ci / Postmerge CI results (push) Has been cancelled
Some checks failed
blocking-ci / rust-ci (push) Has been cancelled
blocking-ci / sdk (push) Has been cancelled
blocking-ci / CI required (push) Has been cancelled
blocking-ci / Bazel (push) Has been cancelled
blocking-ci / Blob size policy (push) Has been cancelled
blocking-ci / cargo-deny (push) Has been cancelled
blocking-ci / Codespell (push) Has been cancelled
blocking-ci / repo-checks (push) Has been cancelled
postmerge-ci / rust-ci-full (push) Has been cancelled
postmerge-ci / v8-canary (push) Has been cancelled
postmerge-ci / Postmerge CI results (push) Has been cancelled
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
//! Converts reviewer outcomes into decisions and reports. The host publishes these
|
||||
//! reports and applies them only to the action whose evidence was reviewed.
|
||||
|
||||
use codex_analytics::GuardianReviewAnalyticsResult;
|
||||
use codex_analytics::GuardianReviewDecision;
|
||||
use codex_analytics::GuardianReviewTerminalStatus;
|
||||
use crate::GuardianReviewDecision;
|
||||
use crate::GuardianReviewDetails;
|
||||
use crate::GuardianReviewTerminalStatus;
|
||||
use codex_prompts::ResolvedModelMessages;
|
||||
use codex_prompts::render_guardian_rejection;
|
||||
use codex_protocol::openai_models::ModelInfo;
|
||||
@@ -31,7 +31,7 @@ pub struct ReviewCompletion {
|
||||
/// Absent for actions reviewed without an action-specific client report.
|
||||
pub event: Option<GuardianAssessmentEvent>,
|
||||
pub warning: Option<String>,
|
||||
pub analytics: GuardianReviewAnalyticsResult,
|
||||
pub details: GuardianReviewDetails,
|
||||
/// Only completed assessments may enter the evidence cache or count as policy denials.
|
||||
pub assessment_outcome: Option<GuardianAssessmentOutcome>,
|
||||
}
|
||||
@@ -41,7 +41,7 @@ pub fn complete_review(
|
||||
model: &ModelInfo,
|
||||
require_guardian: bool,
|
||||
mut event: Option<GuardianAssessmentEvent>,
|
||||
mut analytics: GuardianReviewAnalyticsResult,
|
||||
mut details: GuardianReviewDetails,
|
||||
) -> ReviewCompletion {
|
||||
let completed_assessment = match &outcome {
|
||||
GuardianReviewOutcome::Completed(assessment) => Some(assessment.outcome),
|
||||
@@ -54,43 +54,43 @@ pub fn complete_review(
|
||||
event.decision_source = None;
|
||||
event.rationale = Some("Approved using a current low-risk async score.".to_owned());
|
||||
}
|
||||
analytics.decision = GuardianReviewDecision::Approved;
|
||||
analytics.terminal_status = GuardianReviewTerminalStatus::Approved;
|
||||
analytics.failure_reason = None;
|
||||
details.decision = GuardianReviewDecision::Approved;
|
||||
details.terminal_status = GuardianReviewTerminalStatus::Approved;
|
||||
details.failure_reason = None;
|
||||
return ReviewCompletion {
|
||||
decision: Some(ReviewDecision::Approved),
|
||||
event,
|
||||
warning: None,
|
||||
analytics,
|
||||
details,
|
||||
assessment_outcome: None,
|
||||
};
|
||||
}
|
||||
GuardianReviewOutcome::Completed(assessment) => {
|
||||
let approved = matches!(assessment.outcome, GuardianAssessmentOutcome::Allow);
|
||||
analytics.decision = if approved {
|
||||
details.decision = if approved {
|
||||
GuardianReviewDecision::Approved
|
||||
} else {
|
||||
GuardianReviewDecision::Denied
|
||||
};
|
||||
analytics.terminal_status = if approved {
|
||||
details.terminal_status = if approved {
|
||||
GuardianReviewTerminalStatus::Approved
|
||||
} else {
|
||||
GuardianReviewTerminalStatus::Denied
|
||||
};
|
||||
analytics.failure_reason = None;
|
||||
analytics.risk_level = Some(assessment.risk_level);
|
||||
analytics.user_authorization = Some(assessment.user_authorization);
|
||||
analytics.outcome = Some(assessment.outcome);
|
||||
details.failure_reason = None;
|
||||
details.risk_level = Some(assessment.risk_level);
|
||||
details.user_authorization = Some(assessment.user_authorization);
|
||||
details.outcome = Some(assessment.outcome);
|
||||
assessment
|
||||
}
|
||||
GuardianReviewOutcome::Error(error) => {
|
||||
analytics.failure_reason = Some(error.failure_reason());
|
||||
details.failure_reason = Some(error.failure_reason());
|
||||
match error {
|
||||
GuardianReviewError::InputBudgetExceeded if !require_guardian => {
|
||||
let rationale =
|
||||
format!("Automatic approval review failed: {INPUT_BUDGET_MESSAGE}");
|
||||
analytics.decision = GuardianReviewDecision::Aborted;
|
||||
analytics.terminal_status = GuardianReviewTerminalStatus::Aborted;
|
||||
details.decision = GuardianReviewDecision::Aborted;
|
||||
details.terminal_status = GuardianReviewTerminalStatus::Aborted;
|
||||
if let Some(event) = event.as_mut() {
|
||||
event.status = GuardianAssessmentStatus::Aborted;
|
||||
event.rationale = Some(rationale.clone());
|
||||
@@ -99,14 +99,14 @@ pub fn complete_review(
|
||||
decision: None,
|
||||
event,
|
||||
warning: Some(rationale),
|
||||
analytics,
|
||||
details,
|
||||
assessment_outcome: None,
|
||||
};
|
||||
}
|
||||
GuardianReviewError::Timeout => {
|
||||
let rationale = "Automatic approval review timed out while evaluating the requested approval.".to_string();
|
||||
analytics.decision = GuardianReviewDecision::Denied;
|
||||
analytics.terminal_status = GuardianReviewTerminalStatus::TimedOut;
|
||||
details.decision = GuardianReviewDecision::Denied;
|
||||
details.terminal_status = GuardianReviewTerminalStatus::TimedOut;
|
||||
if let Some(event) = event.as_mut() {
|
||||
event.status = GuardianAssessmentStatus::TimedOut;
|
||||
event.rationale = Some(rationale.clone());
|
||||
@@ -115,13 +115,13 @@ pub fn complete_review(
|
||||
decision: Some(ReviewDecision::TimedOut),
|
||||
event,
|
||||
warning: Some(rationale),
|
||||
analytics,
|
||||
details,
|
||||
assessment_outcome: None,
|
||||
};
|
||||
}
|
||||
GuardianReviewError::Cancelled => {
|
||||
analytics.decision = GuardianReviewDecision::Aborted;
|
||||
analytics.terminal_status = GuardianReviewTerminalStatus::Aborted;
|
||||
details.decision = GuardianReviewDecision::Aborted;
|
||||
details.terminal_status = GuardianReviewTerminalStatus::Aborted;
|
||||
if let Some(event) = event.as_mut() {
|
||||
event.status = GuardianAssessmentStatus::Aborted;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ pub fn complete_review(
|
||||
decision: Some(ReviewDecision::Abort),
|
||||
event,
|
||||
warning: None,
|
||||
analytics,
|
||||
details,
|
||||
assessment_outcome: None,
|
||||
};
|
||||
}
|
||||
@@ -150,8 +150,8 @@ pub fn complete_review(
|
||||
"guardian review failed"
|
||||
}
|
||||
};
|
||||
analytics.decision = GuardianReviewDecision::Denied;
|
||||
analytics.terminal_status = GuardianReviewTerminalStatus::FailedClosed;
|
||||
details.decision = GuardianReviewDecision::Denied;
|
||||
details.terminal_status = GuardianReviewTerminalStatus::FailedClosed;
|
||||
let rationale = format!("Automatic approval review failed: {message}");
|
||||
// Keep the existing blocked status for client compatibility.
|
||||
if let Some(event) = event.as_mut() {
|
||||
@@ -164,7 +164,7 @@ pub fn complete_review(
|
||||
))),
|
||||
event,
|
||||
warning: Some(rationale),
|
||||
analytics,
|
||||
details,
|
||||
assessment_outcome: None,
|
||||
};
|
||||
}
|
||||
@@ -214,7 +214,7 @@ pub fn complete_review(
|
||||
decision: Some(decision),
|
||||
event,
|
||||
warning: Some(warning),
|
||||
analytics,
|
||||
details,
|
||||
assessment_outcome: completed_assessment,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user