mirror of
https://github.com/openai/codex.git
synced 2026-11-24 23:20:47 +00:00
core: populate guardian parent ids for direct reviews
Populate parent tool item ids for direct guardian-reviewed tool actions while preserving distinct network approval review ids. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
co-authored by
Codex
parent
8e2dc92d6a
commit
7beebc0c57
@@ -1354,6 +1354,7 @@
|
||||
"action": true,
|
||||
"parentToolItemId": {
|
||||
"default": null,
|
||||
"description": "Reviewed parent tool item identifier. For direct tool reviews this matches `review_id`; attributed `network_access` reviews may differ, and unattributed `network_access` reviews may omit it.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
@@ -1395,6 +1396,7 @@
|
||||
"action": true,
|
||||
"parentToolItemId": {
|
||||
"default": null,
|
||||
"description": "Reviewed parent tool item identifier. For direct tool reviews this matches `review_id`; attributed `network_access` reviews may differ, and unattributed `network_access` reviews may omit it.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
|
||||
@@ -8201,6 +8201,7 @@
|
||||
"action": true,
|
||||
"parentToolItemId": {
|
||||
"default": null,
|
||||
"description": "Reviewed parent tool item identifier. For direct tool reviews this matches `review_id`; attributed `network_access` reviews may differ, and unattributed `network_access` reviews may omit it.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
@@ -8244,6 +8245,7 @@
|
||||
"action": true,
|
||||
"parentToolItemId": {
|
||||
"default": null,
|
||||
"description": "Reviewed parent tool item identifier. For direct tool reviews this matches `review_id`; attributed `network_access` reviews may differ, and unattributed `network_access` reviews may omit it.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
|
||||
@@ -4949,6 +4949,7 @@
|
||||
"action": true,
|
||||
"parentToolItemId": {
|
||||
"default": null,
|
||||
"description": "Reviewed parent tool item identifier. For direct tool reviews this matches `review_id`; attributed `network_access` reviews may differ, and unattributed `network_access` reviews may omit it.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
@@ -4992,6 +4993,7 @@
|
||||
"action": true,
|
||||
"parentToolItemId": {
|
||||
"default": null,
|
||||
"description": "Reviewed parent tool item identifier. For direct tool reviews this matches `review_id`; attributed `network_access` reviews may differ, and unattributed `network_access` reviews may omit it.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
|
||||
+1
@@ -62,6 +62,7 @@
|
||||
"action": true,
|
||||
"parentToolItemId": {
|
||||
"default": null,
|
||||
"description": "Reviewed parent tool item identifier. For direct tool reviews this matches `review_id`; attributed `network_access` reviews may differ, and unattributed `network_access` reviews may omit it.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
|
||||
+1
@@ -62,6 +62,7 @@
|
||||
"action": true,
|
||||
"parentToolItemId": {
|
||||
"default": null,
|
||||
"description": "Reviewed parent tool item identifier. For direct tool reviews this matches `review_id`; attributed `network_access` reviews may differ, and unattributed `network_access` reviews may omit it.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
|
||||
+7
-1
@@ -20,4 +20,10 @@ targetItemId: string,
|
||||
/**
|
||||
* Stable guardian review identifier for matching started/completed events.
|
||||
*/
|
||||
reviewId: string | null, parentToolItemId: string | null, review: GuardianApprovalReview, action: JsonValue | null, };
|
||||
reviewId: string | null,
|
||||
/**
|
||||
* Reviewed parent tool item identifier. For direct tool reviews this
|
||||
* matches `review_id`; attributed `network_access` reviews may differ,
|
||||
* and unattributed `network_access` reviews may omit it.
|
||||
*/
|
||||
parentToolItemId: string | null, review: GuardianApprovalReview, action: JsonValue | null, };
|
||||
|
||||
+7
-1
@@ -20,4 +20,10 @@ targetItemId: string,
|
||||
/**
|
||||
* Stable guardian review identifier for matching started/completed events.
|
||||
*/
|
||||
reviewId: string | null, parentToolItemId: string | null, review: GuardianApprovalReview, action: JsonValue | null, };
|
||||
reviewId: string | null,
|
||||
/**
|
||||
* Reviewed parent tool item identifier. For direct tool reviews this
|
||||
* matches `review_id`; attributed `network_access` reviews may differ,
|
||||
* and unattributed `network_access` reviews may omit it.
|
||||
*/
|
||||
parentToolItemId: string | null, review: GuardianApprovalReview, action: JsonValue | null, };
|
||||
|
||||
@@ -4843,6 +4843,9 @@ pub struct ItemGuardianApprovalReviewStartedNotification {
|
||||
/// Stable guardian review identifier for matching started/completed events.
|
||||
#[serde(default)]
|
||||
pub review_id: Option<String>,
|
||||
/// Reviewed parent tool item identifier. For direct tool reviews this
|
||||
/// matches `review_id`; attributed `network_access` reviews may differ,
|
||||
/// and unattributed `network_access` reviews may omit it.
|
||||
#[serde(default)]
|
||||
pub parent_tool_item_id: Option<String>,
|
||||
pub review: GuardianApprovalReview,
|
||||
@@ -4866,6 +4869,9 @@ pub struct ItemGuardianApprovalReviewCompletedNotification {
|
||||
/// Stable guardian review identifier for matching started/completed events.
|
||||
#[serde(default)]
|
||||
pub review_id: Option<String>,
|
||||
/// Reviewed parent tool item identifier. For direct tool reviews this
|
||||
/// matches `review_id`; attributed `network_access` reviews may differ,
|
||||
/// and unattributed `network_access` reviews may omit it.
|
||||
#[serde(default)]
|
||||
pub parent_tool_item_id: Option<String>,
|
||||
pub review: GuardianApprovalReview,
|
||||
|
||||
@@ -879,7 +879,7 @@ All items emit shared lifecycle events:
|
||||
- `item/autoApprovalReview/started` — [UNSTABLE] temporary guardian notification carrying `{threadId, turnId, targetItemId, reviewId, parentToolItemId, review, action?}` when guardian approval review begins.
|
||||
- `item/autoApprovalReview/completed` — [UNSTABLE] temporary guardian notification carrying `{threadId, turnId, targetItemId, reviewId, parentToolItemId, review, action?}` when guardian approval review resolves.
|
||||
|
||||
`review` is [UNSTABLE] and currently has `{status, riskScore?, riskLevel?, rationale?}`, where `status` is one of `inProgress`, `approved`, `denied`, or `aborted`. `action` is the guardian action summary payload from core when available and is intended to support temporary standalone pending-review UI. `reviewId` is the stable guardian review id for matching started/completed notifications. `targetItemId` is a deprecated alias for `reviewId` retained for backwards compatibility. `parentToolItemId` points at the reviewed parent tool item when app-server can attribute the review to one, including attributed `network_access` reviews. These notifications are separate from the target item's own `item/completed` lifecycle and are intentionally temporary while the guardian app protocol is still being designed.
|
||||
`review` is [UNSTABLE] and currently has `{status, riskScore?, riskLevel?, rationale?}`, where `status` is one of `inProgress`, `approved`, `denied`, or `aborted`. `action` is the guardian action summary payload from core when available and is intended to support temporary standalone pending-review UI. `reviewId` is the stable guardian review id for matching started/completed notifications. `targetItemId` is a deprecated alias for `reviewId` retained for backwards compatibility. `parentToolItemId` points at the reviewed parent tool item; for direct tool reviews it matches `reviewId`, while attributed `network_access` reviews may point at a different parent item and can remain absent when attribution is unavailable. These notifications are separate from the target item's own `item/completed` lifecycle and are intentionally temporary while the guardian app protocol is still being designed.
|
||||
|
||||
There are additional item-specific events:
|
||||
|
||||
|
||||
@@ -2925,7 +2925,7 @@ mod tests {
|
||||
"turn-from-event",
|
||||
&GuardianAssessmentEvent {
|
||||
id: "item-1".to_string(),
|
||||
parent_tool_item_id: None,
|
||||
parent_tool_item_id: Some("item-1".to_string()),
|
||||
turn_id: String::new(),
|
||||
status: codex_protocol::protocol::GuardianAssessmentStatus::InProgress,
|
||||
risk_score: None,
|
||||
@@ -2941,7 +2941,7 @@ mod tests {
|
||||
assert_eq!(payload.turn_id, "turn-from-event");
|
||||
assert_eq!(payload.target_item_id, "item-1");
|
||||
assert_eq!(payload.review_id.as_deref(), Some("item-1"));
|
||||
assert_eq!(payload.parent_tool_item_id, None);
|
||||
assert_eq!(payload.parent_tool_item_id.as_deref(), Some("item-1"));
|
||||
assert_eq!(
|
||||
payload.review.status,
|
||||
GuardianApprovalReviewStatus::InProgress
|
||||
@@ -2967,7 +2967,7 @@ mod tests {
|
||||
"turn-from-event",
|
||||
&GuardianAssessmentEvent {
|
||||
id: "item-2".to_string(),
|
||||
parent_tool_item_id: None,
|
||||
parent_tool_item_id: Some("item-2".to_string()),
|
||||
turn_id: "turn-from-assessment".to_string(),
|
||||
status: codex_protocol::protocol::GuardianAssessmentStatus::Denied,
|
||||
risk_score: Some(91),
|
||||
@@ -2983,7 +2983,7 @@ mod tests {
|
||||
assert_eq!(payload.turn_id, "turn-from-assessment");
|
||||
assert_eq!(payload.target_item_id, "item-2");
|
||||
assert_eq!(payload.review_id.as_deref(), Some("item-2"));
|
||||
assert_eq!(payload.parent_tool_item_id, None);
|
||||
assert_eq!(payload.parent_tool_item_id.as_deref(), Some("item-2"));
|
||||
assert_eq!(payload.review.status, GuardianApprovalReviewStatus::Denied);
|
||||
assert_eq!(payload.review.risk_score, Some(91));
|
||||
assert_eq!(
|
||||
|
||||
@@ -313,7 +313,7 @@ async fn handle_exec_approval_uses_call_id_for_guardian_review_and_approval_id_f
|
||||
assessment_event,
|
||||
GuardianAssessmentEvent {
|
||||
id: "command-item-1".to_string(),
|
||||
parent_tool_item_id: None,
|
||||
parent_tool_item_id: Some("command-item-1".to_string()),
|
||||
turn_id: parent_ctx.sub_id.clone(),
|
||||
status: GuardianAssessmentStatus::InProgress,
|
||||
risk_score: None,
|
||||
|
||||
@@ -406,12 +406,12 @@ pub(crate) fn guardian_request_parent_tool_item_id(
|
||||
parent_tool_item_id,
|
||||
..
|
||||
} => parent_tool_item_id.as_deref(),
|
||||
GuardianApprovalRequest::Shell { .. }
|
||||
| GuardianApprovalRequest::ExecCommand { .. }
|
||||
| GuardianApprovalRequest::ApplyPatch { .. }
|
||||
| GuardianApprovalRequest::McpToolCall { .. } => None,
|
||||
GuardianApprovalRequest::Shell { id, .. }
|
||||
| GuardianApprovalRequest::ExecCommand { id, .. }
|
||||
| GuardianApprovalRequest::ApplyPatch { id, .. }
|
||||
| GuardianApprovalRequest::McpToolCall { id, .. } => Some(id),
|
||||
#[cfg(unix)]
|
||||
GuardianApprovalRequest::Execve { .. } => None,
|
||||
GuardianApprovalRequest::Execve { id, .. } => Some(id),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use super::approval_request::guardian_request_parent_tool_item_id;
|
||||
use super::*;
|
||||
use crate::codex::Session;
|
||||
use crate::codex::TurnContext;
|
||||
@@ -370,6 +371,14 @@ fn guardian_request_turn_id_prefers_network_access_owner_turn() {
|
||||
guardian_request_turn_id(&apply_patch, "fallback-turn"),
|
||||
"fallback-turn"
|
||||
);
|
||||
assert_eq!(
|
||||
guardian_request_parent_tool_item_id(&network_access),
|
||||
Some("command-1")
|
||||
);
|
||||
assert_eq!(
|
||||
guardian_request_parent_tool_item_id(&apply_patch),
|
||||
Some("patch-1")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -9557,6 +9557,7 @@ async fn guardian_denied_exec_renders_warning_and_denied_request() {
|
||||
id: "guardian-in-progress".into(),
|
||||
msg: EventMsg::GuardianAssessment(GuardianAssessmentEvent {
|
||||
id: "guardian-1".into(),
|
||||
parent_tool_item_id: Some("guardian-1".into()),
|
||||
turn_id: "turn-1".into(),
|
||||
status: GuardianAssessmentStatus::InProgress,
|
||||
risk_score: None,
|
||||
@@ -9575,6 +9576,7 @@ async fn guardian_denied_exec_renders_warning_and_denied_request() {
|
||||
id: "guardian-assessment".into(),
|
||||
msg: EventMsg::GuardianAssessment(GuardianAssessmentEvent {
|
||||
id: "guardian-1".into(),
|
||||
parent_tool_item_id: Some("guardian-1".into()),
|
||||
turn_id: "turn-1".into(),
|
||||
status: GuardianAssessmentStatus::Denied,
|
||||
risk_score: Some(96),
|
||||
@@ -9618,6 +9620,7 @@ async fn guardian_approved_exec_renders_approved_request() {
|
||||
id: "guardian-assessment".into(),
|
||||
msg: EventMsg::GuardianAssessment(GuardianAssessmentEvent {
|
||||
id: "thread:child-thread:guardian-1".into(),
|
||||
parent_tool_item_id: Some("thread:child-thread:guardian-1".into()),
|
||||
turn_id: "turn-1".into(),
|
||||
status: GuardianAssessmentStatus::Approved,
|
||||
risk_score: Some(14),
|
||||
@@ -9765,6 +9768,7 @@ async fn guardian_parallel_reviews_render_aggregate_status_snapshot() {
|
||||
id: format!("event-{id}"),
|
||||
msg: EventMsg::GuardianAssessment(GuardianAssessmentEvent {
|
||||
id: id.to_string(),
|
||||
parent_tool_item_id: Some(id.to_string()),
|
||||
turn_id: "turn-1".to_string(),
|
||||
status: GuardianAssessmentStatus::InProgress,
|
||||
risk_score: None,
|
||||
@@ -9794,6 +9798,7 @@ async fn guardian_parallel_reviews_keep_remaining_review_visible_after_denial()
|
||||
id: "event-guardian-1".into(),
|
||||
msg: EventMsg::GuardianAssessment(GuardianAssessmentEvent {
|
||||
id: "guardian-1".to_string(),
|
||||
parent_tool_item_id: Some("guardian-1".to_string()),
|
||||
turn_id: "turn-1".to_string(),
|
||||
status: GuardianAssessmentStatus::InProgress,
|
||||
risk_score: None,
|
||||
@@ -9809,6 +9814,7 @@ async fn guardian_parallel_reviews_keep_remaining_review_visible_after_denial()
|
||||
id: "event-guardian-2".into(),
|
||||
msg: EventMsg::GuardianAssessment(GuardianAssessmentEvent {
|
||||
id: "guardian-2".to_string(),
|
||||
parent_tool_item_id: Some("guardian-2".to_string()),
|
||||
turn_id: "turn-1".to_string(),
|
||||
status: GuardianAssessmentStatus::InProgress,
|
||||
risk_score: None,
|
||||
@@ -9824,6 +9830,7 @@ async fn guardian_parallel_reviews_keep_remaining_review_visible_after_denial()
|
||||
id: "event-guardian-1-denied".into(),
|
||||
msg: EventMsg::GuardianAssessment(GuardianAssessmentEvent {
|
||||
id: "guardian-1".to_string(),
|
||||
parent_tool_item_id: Some("guardian-1".to_string()),
|
||||
turn_id: "turn-1".to_string(),
|
||||
status: GuardianAssessmentStatus::Denied,
|
||||
risk_score: Some(92),
|
||||
|
||||
@@ -10105,7 +10105,7 @@ async fn guardian_denied_exec_renders_warning_and_denied_request() {
|
||||
id: "guardian-in-progress".into(),
|
||||
msg: EventMsg::GuardianAssessment(GuardianAssessmentEvent {
|
||||
id: "guardian-1".into(),
|
||||
parent_tool_item_id: None,
|
||||
parent_tool_item_id: Some("guardian-1".into()),
|
||||
turn_id: "turn-1".into(),
|
||||
status: GuardianAssessmentStatus::InProgress,
|
||||
risk_score: None,
|
||||
@@ -10124,7 +10124,7 @@ async fn guardian_denied_exec_renders_warning_and_denied_request() {
|
||||
id: "guardian-assessment".into(),
|
||||
msg: EventMsg::GuardianAssessment(GuardianAssessmentEvent {
|
||||
id: "guardian-1".into(),
|
||||
parent_tool_item_id: None,
|
||||
parent_tool_item_id: Some("guardian-1".into()),
|
||||
turn_id: "turn-1".into(),
|
||||
status: GuardianAssessmentStatus::Denied,
|
||||
risk_score: Some(96),
|
||||
@@ -10168,7 +10168,7 @@ async fn guardian_approved_exec_renders_approved_request() {
|
||||
id: "guardian-assessment".into(),
|
||||
msg: EventMsg::GuardianAssessment(GuardianAssessmentEvent {
|
||||
id: "thread:child-thread:guardian-1".into(),
|
||||
parent_tool_item_id: None,
|
||||
parent_tool_item_id: Some("thread:child-thread:guardian-1".into()),
|
||||
turn_id: "turn-1".into(),
|
||||
status: GuardianAssessmentStatus::Approved,
|
||||
risk_score: Some(14),
|
||||
@@ -10221,7 +10221,7 @@ async fn app_server_guardian_review_started_sets_review_status() {
|
||||
turn_id: "turn-1".to_string(),
|
||||
target_item_id: "guardian-1".to_string(),
|
||||
review_id: Some("guardian-1".to_string()),
|
||||
parent_tool_item_id: None,
|
||||
parent_tool_item_id: Some("guardian-1".to_string()),
|
||||
review: GuardianApprovalReview {
|
||||
status: GuardianApprovalReviewStatus::InProgress,
|
||||
risk_score: None,
|
||||
@@ -10261,7 +10261,7 @@ async fn app_server_guardian_review_denied_renders_denied_request_snapshot() {
|
||||
turn_id: "turn-1".to_string(),
|
||||
target_item_id: "guardian-1".to_string(),
|
||||
review_id: Some("guardian-1".to_string()),
|
||||
parent_tool_item_id: None,
|
||||
parent_tool_item_id: Some("guardian-1".to_string()),
|
||||
review: GuardianApprovalReview {
|
||||
status: GuardianApprovalReviewStatus::InProgress,
|
||||
risk_score: None,
|
||||
@@ -10281,7 +10281,7 @@ async fn app_server_guardian_review_denied_renders_denied_request_snapshot() {
|
||||
turn_id: "turn-1".to_string(),
|
||||
target_item_id: "guardian-1".to_string(),
|
||||
review_id: Some("guardian-1".to_string()),
|
||||
parent_tool_item_id: None,
|
||||
parent_tool_item_id: Some("guardian-1".to_string()),
|
||||
review: GuardianApprovalReview {
|
||||
status: GuardianApprovalReviewStatus::Denied,
|
||||
risk_score: Some(96),
|
||||
@@ -10480,7 +10480,7 @@ async fn guardian_parallel_reviews_render_aggregate_status_snapshot() {
|
||||
id: format!("event-{id}"),
|
||||
msg: EventMsg::GuardianAssessment(GuardianAssessmentEvent {
|
||||
id: id.to_string(),
|
||||
parent_tool_item_id: None,
|
||||
parent_tool_item_id: Some(id.to_string()),
|
||||
turn_id: "turn-1".to_string(),
|
||||
status: GuardianAssessmentStatus::InProgress,
|
||||
risk_score: None,
|
||||
@@ -10510,7 +10510,7 @@ async fn guardian_parallel_reviews_keep_remaining_review_visible_after_denial()
|
||||
id: "event-guardian-1".into(),
|
||||
msg: EventMsg::GuardianAssessment(GuardianAssessmentEvent {
|
||||
id: "guardian-1".to_string(),
|
||||
parent_tool_item_id: None,
|
||||
parent_tool_item_id: Some("guardian-1".to_string()),
|
||||
turn_id: "turn-1".to_string(),
|
||||
status: GuardianAssessmentStatus::InProgress,
|
||||
risk_score: None,
|
||||
@@ -10526,7 +10526,7 @@ async fn guardian_parallel_reviews_keep_remaining_review_visible_after_denial()
|
||||
id: "event-guardian-2".into(),
|
||||
msg: EventMsg::GuardianAssessment(GuardianAssessmentEvent {
|
||||
id: "guardian-2".to_string(),
|
||||
parent_tool_item_id: None,
|
||||
parent_tool_item_id: Some("guardian-2".to_string()),
|
||||
turn_id: "turn-1".to_string(),
|
||||
status: GuardianAssessmentStatus::InProgress,
|
||||
risk_score: None,
|
||||
@@ -10542,7 +10542,7 @@ async fn guardian_parallel_reviews_keep_remaining_review_visible_after_denial()
|
||||
id: "event-guardian-1-denied".into(),
|
||||
msg: EventMsg::GuardianAssessment(GuardianAssessmentEvent {
|
||||
id: "guardian-1".to_string(),
|
||||
parent_tool_item_id: None,
|
||||
parent_tool_item_id: Some("guardian-1".to_string()),
|
||||
turn_id: "turn-1".to_string(),
|
||||
status: GuardianAssessmentStatus::Denied,
|
||||
risk_score: Some(92),
|
||||
|
||||
Reference in New Issue
Block a user