Route approvals through the extension decision API (#43432)

## What changed

- Let approval extensions choose between cached approval, synchronous review, and a user prompt for tool and permission requests, while core enforces mandatory Guardian and fresh-review requirements.
- Carry an optional `review_reason` on Guardian assessment events and use it to trigger strict-review notifications, retaining the fallback for older events.
- Require synchronous review when cached evidence has an unusable encrypted parent compaction.

## Testing

Add regression coverage for manual prompts and cached approvals with non-UTF-8 working directories. Update approval contributors in existing tests to use the decision API.

GitOrigin-RevId: a4e66416070bdaa881daa41429c49021629f44c1
This commit is contained in:
jif authored and copyberry committed 2026-09-07 11:07:28 +00:00
1 parent 0df39752cb
commit e1eb98461c
24 files changed
+605 -250

No files matched your search

@@ -355,10 +355,21 @@ pub(crate) async fn apply_bespoke_event_handling(
);
outgoing.send_server_notification(notification).await;
if assessment.status == codex_protocol::protocol::GuardianAssessmentStatus::InProgress
&& conversation
.thread_extension_data()
.remove::<StrictReviewReason>()
.is_some()
&& match assessment.review_reason {
Some(reason) => matches!(
reason,
codex_protocol::approvals::GuardianReviewReason::ElevatedRisk
| codex_protocol::approvals::GuardianReviewReason::StaleScore
| codex_protocol::approvals::GuardianReviewReason::IncompatibleCompaction
| codex_protocol::approvals::GuardianReviewReason::ScoringFailure
| codex_protocol::approvals::GuardianReviewReason::AuthorizationChanged
),
// MCP elicitations migrate to per-approval reasons next.
None => conversation
.thread_extension_data()
.remove::<StrictReviewReason>()
.is_some(),
}
{
outgoing
.send_server_notification(ServerNotification::StrictReviewRequired(
@@ -2429,6 +2440,7 @@ mod tests {
GuardianAssessmentStatus::Aborted => (None, None, None),
};
GuardianAssessmentEvent {
review_reason: None,
id: format!("review-{id}"),
target_item_id: Some(id.to_string()),
plugin_id: Some("sample@openai-curated".to_string()),
@@ -2498,6 +2510,7 @@ mod tests {
&conversation_id,
"turn-from-event",
&GuardianAssessmentEvent {
review_reason: None,
id: "review-1".to_string(),
target_item_id: Some("item-1".to_string()),
plugin_id: None,
@@ -2546,6 +2559,7 @@ mod tests {
&conversation_id,
"turn-from-event",
&GuardianAssessmentEvent {
review_reason: None,
id: "review-2".to_string(),
target_item_id: Some("item-2".to_string()),
plugin_id: None,
@@ -2602,6 +2616,7 @@ mod tests {
&conversation_id,
"turn-from-event",
&GuardianAssessmentEvent {
review_reason: None,
id: "review-3".to_string(),
target_item_id: None,
plugin_id: None,