mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
app-server: add review ids for guardian notifications
Keep `targetItemId` as a deprecated compatibility alias while emitting the clearer `reviewId` field on legacy guardian approval review notifications.\n\nCo-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -1372,7 +1372,7 @@
|
||||
"type": "object"
|
||||
},
|
||||
"ItemGuardianApprovalReviewCompletedNotification": {
|
||||
"description": "[UNSTABLE] Temporary notification payload for guardian automatic approval review. This shape is expected to change soon.\n\nTODO(ccunningham): Attach guardian review state to the reviewed tool item's lifecycle instead of sending separate standalone review notifications so the app-server API can persist and replay review state via `thread/read`.",
|
||||
"description": "[UNSTABLE] Temporary notification payload for guardian automatic approval review.\n\nTODO(ccunningham): Attach guardian review state to the reviewed tool item's lifecycle instead of sending separate standalone review notifications so the app-server API can persist and replay review state via `thread/read`.",
|
||||
"properties": {
|
||||
"action": true,
|
||||
"parentToolItemId": {
|
||||
@@ -1385,7 +1385,16 @@
|
||||
"review": {
|
||||
"$ref": "#/definitions/GuardianApprovalReview"
|
||||
},
|
||||
"reviewId": {
|
||||
"default": null,
|
||||
"description": "Stable guardian review identifier for matching started/completed events.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"targetItemId": {
|
||||
"description": "Deprecated alias for `review_id`, retained for backwards compatibility.",
|
||||
"type": "string"
|
||||
},
|
||||
"threadId": {
|
||||
@@ -1404,7 +1413,7 @@
|
||||
"type": "object"
|
||||
},
|
||||
"ItemGuardianApprovalReviewStartedNotification": {
|
||||
"description": "[UNSTABLE] Temporary notification payload for guardian automatic approval review. This shape is expected to change soon.\n\nTODO(ccunningham): Attach guardian review state to the reviewed tool item's lifecycle instead of sending separate standalone review notifications so the app-server API can persist and replay review state via `thread/read`.",
|
||||
"description": "[UNSTABLE] Temporary notification payload for guardian automatic approval review.\n\nTODO(ccunningham): Attach guardian review state to the reviewed tool item's lifecycle instead of sending separate standalone review notifications so the app-server API can persist and replay review state via `thread/read`.",
|
||||
"properties": {
|
||||
"action": true,
|
||||
"parentToolItemId": {
|
||||
@@ -1417,7 +1426,16 @@
|
||||
"review": {
|
||||
"$ref": "#/definitions/GuardianApprovalReview"
|
||||
},
|
||||
"reviewId": {
|
||||
"default": null,
|
||||
"description": "Stable guardian review identifier for matching started/completed events.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"targetItemId": {
|
||||
"description": "Deprecated alias for `review_id`, retained for backwards compatibility.",
|
||||
"type": "string"
|
||||
},
|
||||
"threadId": {
|
||||
|
||||
@@ -8219,7 +8219,7 @@
|
||||
},
|
||||
"ItemGuardianApprovalReviewCompletedNotification": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "[UNSTABLE] Temporary notification payload for guardian automatic approval review. This shape is expected to change soon.\n\nTODO(ccunningham): Attach guardian review state to the reviewed tool item's lifecycle instead of sending separate standalone review notifications so the app-server API can persist and replay review state via `thread/read`.",
|
||||
"description": "[UNSTABLE] Temporary notification payload for guardian automatic approval review.\n\nTODO(ccunningham): Attach guardian review state to the reviewed tool item's lifecycle instead of sending separate standalone review notifications so the app-server API can persist and replay review state via `thread/read`.",
|
||||
"properties": {
|
||||
"action": true,
|
||||
"parentToolItemId": {
|
||||
@@ -8232,7 +8232,16 @@
|
||||
"review": {
|
||||
"$ref": "#/definitions/v2/GuardianApprovalReview"
|
||||
},
|
||||
"reviewId": {
|
||||
"default": null,
|
||||
"description": "Stable guardian review identifier for matching started/completed events.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"targetItemId": {
|
||||
"description": "Deprecated alias for `review_id`, retained for backwards compatibility.",
|
||||
"type": "string"
|
||||
},
|
||||
"threadId": {
|
||||
@@ -8253,7 +8262,7 @@
|
||||
},
|
||||
"ItemGuardianApprovalReviewStartedNotification": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "[UNSTABLE] Temporary notification payload for guardian automatic approval review. This shape is expected to change soon.\n\nTODO(ccunningham): Attach guardian review state to the reviewed tool item's lifecycle instead of sending separate standalone review notifications so the app-server API can persist and replay review state via `thread/read`.",
|
||||
"description": "[UNSTABLE] Temporary notification payload for guardian automatic approval review.\n\nTODO(ccunningham): Attach guardian review state to the reviewed tool item's lifecycle instead of sending separate standalone review notifications so the app-server API can persist and replay review state via `thread/read`.",
|
||||
"properties": {
|
||||
"action": true,
|
||||
"parentToolItemId": {
|
||||
@@ -8266,7 +8275,16 @@
|
||||
"review": {
|
||||
"$ref": "#/definitions/v2/GuardianApprovalReview"
|
||||
},
|
||||
"reviewId": {
|
||||
"default": null,
|
||||
"description": "Stable guardian review identifier for matching started/completed events.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"targetItemId": {
|
||||
"description": "Deprecated alias for `review_id`, retained for backwards compatibility.",
|
||||
"type": "string"
|
||||
},
|
||||
"threadId": {
|
||||
|
||||
@@ -4967,7 +4967,7 @@
|
||||
},
|
||||
"ItemGuardianApprovalReviewCompletedNotification": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "[UNSTABLE] Temporary notification payload for guardian automatic approval review. This shape is expected to change soon.\n\nTODO(ccunningham): Attach guardian review state to the reviewed tool item's lifecycle instead of sending separate standalone review notifications so the app-server API can persist and replay review state via `thread/read`.",
|
||||
"description": "[UNSTABLE] Temporary notification payload for guardian automatic approval review.\n\nTODO(ccunningham): Attach guardian review state to the reviewed tool item's lifecycle instead of sending separate standalone review notifications so the app-server API can persist and replay review state via `thread/read`.",
|
||||
"properties": {
|
||||
"action": true,
|
||||
"parentToolItemId": {
|
||||
@@ -4980,7 +4980,16 @@
|
||||
"review": {
|
||||
"$ref": "#/definitions/GuardianApprovalReview"
|
||||
},
|
||||
"reviewId": {
|
||||
"default": null,
|
||||
"description": "Stable guardian review identifier for matching started/completed events.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"targetItemId": {
|
||||
"description": "Deprecated alias for `review_id`, retained for backwards compatibility.",
|
||||
"type": "string"
|
||||
},
|
||||
"threadId": {
|
||||
@@ -5001,7 +5010,7 @@
|
||||
},
|
||||
"ItemGuardianApprovalReviewStartedNotification": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"description": "[UNSTABLE] Temporary notification payload for guardian automatic approval review. This shape is expected to change soon.\n\nTODO(ccunningham): Attach guardian review state to the reviewed tool item's lifecycle instead of sending separate standalone review notifications so the app-server API can persist and replay review state via `thread/read`.",
|
||||
"description": "[UNSTABLE] Temporary notification payload for guardian automatic approval review.\n\nTODO(ccunningham): Attach guardian review state to the reviewed tool item's lifecycle instead of sending separate standalone review notifications so the app-server API can persist and replay review state via `thread/read`.",
|
||||
"properties": {
|
||||
"action": true,
|
||||
"parentToolItemId": {
|
||||
@@ -5014,7 +5023,16 @@
|
||||
"review": {
|
||||
"$ref": "#/definitions/GuardianApprovalReview"
|
||||
},
|
||||
"reviewId": {
|
||||
"default": null,
|
||||
"description": "Stable guardian review identifier for matching started/completed events.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"targetItemId": {
|
||||
"description": "Deprecated alias for `review_id`, retained for backwards compatibility.",
|
||||
"type": "string"
|
||||
},
|
||||
"threadId": {
|
||||
|
||||
+10
-1
@@ -57,7 +57,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"description": "[UNSTABLE] Temporary notification payload for guardian automatic approval review. This shape is expected to change soon.\n\nTODO(ccunningham): Attach guardian review state to the reviewed tool item's lifecycle instead of sending separate standalone review notifications so the app-server API can persist and replay review state via `thread/read`.",
|
||||
"description": "[UNSTABLE] Temporary notification payload for guardian automatic approval review.\n\nTODO(ccunningham): Attach guardian review state to the reviewed tool item's lifecycle instead of sending separate standalone review notifications so the app-server API can persist and replay review state via `thread/read`.",
|
||||
"properties": {
|
||||
"action": true,
|
||||
"parentToolItemId": {
|
||||
@@ -70,7 +70,16 @@
|
||||
"review": {
|
||||
"$ref": "#/definitions/GuardianApprovalReview"
|
||||
},
|
||||
"reviewId": {
|
||||
"default": null,
|
||||
"description": "Stable guardian review identifier for matching started/completed events.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"targetItemId": {
|
||||
"description": "Deprecated alias for `review_id`, retained for backwards compatibility.",
|
||||
"type": "string"
|
||||
},
|
||||
"threadId": {
|
||||
|
||||
+10
-1
@@ -57,7 +57,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"description": "[UNSTABLE] Temporary notification payload for guardian automatic approval review. This shape is expected to change soon.\n\nTODO(ccunningham): Attach guardian review state to the reviewed tool item's lifecycle instead of sending separate standalone review notifications so the app-server API can persist and replay review state via `thread/read`.",
|
||||
"description": "[UNSTABLE] Temporary notification payload for guardian automatic approval review.\n\nTODO(ccunningham): Attach guardian review state to the reviewed tool item's lifecycle instead of sending separate standalone review notifications so the app-server API can persist and replay review state via `thread/read`.",
|
||||
"properties": {
|
||||
"action": true,
|
||||
"parentToolItemId": {
|
||||
@@ -70,7 +70,16 @@
|
||||
"review": {
|
||||
"$ref": "#/definitions/GuardianApprovalReview"
|
||||
},
|
||||
"reviewId": {
|
||||
"default": null,
|
||||
"description": "Stable guardian review identifier for matching started/completed events.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"targetItemId": {
|
||||
"description": "Deprecated alias for `review_id`, retained for backwards compatibility.",
|
||||
"type": "string"
|
||||
},
|
||||
"threadId": {
|
||||
|
||||
+10
-2
@@ -6,10 +6,18 @@ import type { GuardianApprovalReview } from "./GuardianApprovalReview";
|
||||
|
||||
/**
|
||||
* [UNSTABLE] Temporary notification payload for guardian automatic approval
|
||||
* review. This shape is expected to change soon.
|
||||
* review.
|
||||
*
|
||||
* TODO(ccunningham): Attach guardian review state to the reviewed tool item's
|
||||
* lifecycle instead of sending separate standalone review notifications so the
|
||||
* app-server API can persist and replay review state via `thread/read`.
|
||||
*/
|
||||
export type ItemGuardianApprovalReviewCompletedNotification = { threadId: string, turnId: string, targetItemId: string, parentToolItemId: string | null, review: GuardianApprovalReview, action: JsonValue | null, };
|
||||
export type ItemGuardianApprovalReviewCompletedNotification = { threadId: string, turnId: string,
|
||||
/**
|
||||
* Deprecated alias for `review_id`, retained for backwards compatibility.
|
||||
*/
|
||||
targetItemId: string,
|
||||
/**
|
||||
* Stable guardian review identifier for matching started/completed events.
|
||||
*/
|
||||
reviewId: string | null, parentToolItemId: string | null, review: GuardianApprovalReview, action: JsonValue | null, };
|
||||
|
||||
+10
-2
@@ -6,10 +6,18 @@ import type { GuardianApprovalReview } from "./GuardianApprovalReview";
|
||||
|
||||
/**
|
||||
* [UNSTABLE] Temporary notification payload for guardian automatic approval
|
||||
* review. This shape is expected to change soon.
|
||||
* review.
|
||||
*
|
||||
* TODO(ccunningham): Attach guardian review state to the reviewed tool item's
|
||||
* lifecycle instead of sending separate standalone review notifications so the
|
||||
* app-server API can persist and replay review state via `thread/read`.
|
||||
*/
|
||||
export type ItemGuardianApprovalReviewStartedNotification = { threadId: string, turnId: string, targetItemId: string, parentToolItemId: string | null, review: GuardianApprovalReview, action: JsonValue | null, };
|
||||
export type ItemGuardianApprovalReviewStartedNotification = { threadId: string, turnId: string,
|
||||
/**
|
||||
* Deprecated alias for `review_id`, retained for backwards compatibility.
|
||||
*/
|
||||
targetItemId: string,
|
||||
/**
|
||||
* Stable guardian review identifier for matching started/completed events.
|
||||
*/
|
||||
reviewId: string | null, parentToolItemId: string | null, review: GuardianApprovalReview, action: JsonValue | null, };
|
||||
|
||||
@@ -4866,7 +4866,7 @@ pub struct ItemStartedNotification {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
/// [UNSTABLE] Temporary notification payload for guardian automatic approval
|
||||
/// review. This shape is expected to change soon.
|
||||
/// review.
|
||||
///
|
||||
/// TODO(ccunningham): Attach guardian review state to the reviewed tool item's
|
||||
/// lifecycle instead of sending separate standalone review notifications so the
|
||||
@@ -4874,7 +4874,11 @@ pub struct ItemStartedNotification {
|
||||
pub struct ItemGuardianApprovalReviewStartedNotification {
|
||||
pub thread_id: String,
|
||||
pub turn_id: String,
|
||||
/// Deprecated alias for `review_id`, retained for backwards compatibility.
|
||||
pub target_item_id: String,
|
||||
/// Stable guardian review identifier for matching started/completed events.
|
||||
#[serde(default)]
|
||||
pub review_id: Option<String>,
|
||||
#[serde(default)]
|
||||
pub parent_tool_item_id: Option<String>,
|
||||
pub review: GuardianApprovalReview,
|
||||
@@ -4885,7 +4889,7 @@ pub struct ItemGuardianApprovalReviewStartedNotification {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
/// [UNSTABLE] Temporary notification payload for guardian automatic approval
|
||||
/// review. This shape is expected to change soon.
|
||||
/// review.
|
||||
///
|
||||
/// TODO(ccunningham): Attach guardian review state to the reviewed tool item's
|
||||
/// lifecycle instead of sending separate standalone review notifications so the
|
||||
@@ -4893,7 +4897,11 @@ pub struct ItemGuardianApprovalReviewStartedNotification {
|
||||
pub struct ItemGuardianApprovalReviewCompletedNotification {
|
||||
pub thread_id: String,
|
||||
pub turn_id: String,
|
||||
/// Deprecated alias for `review_id`, retained for backwards compatibility.
|
||||
pub target_item_id: String,
|
||||
/// Stable guardian review identifier for matching started/completed events.
|
||||
#[serde(default)]
|
||||
pub review_id: Option<String>,
|
||||
#[serde(default)]
|
||||
pub parent_tool_item_id: Option<String>,
|
||||
pub review: GuardianApprovalReview,
|
||||
|
||||
@@ -878,10 +878,10 @@ All items emit shared lifecycle events:
|
||||
|
||||
- `item/started` — emits the full `item` when a new unit of work begins so the UI can render it immediately; the `item.id` in this payload matches the `itemId` used by deltas.
|
||||
- `item/completed` — sends the final `item` once that work itself finishes (for example, after a tool call or message completes); treat this as the authoritative execution/result state.
|
||||
- `item/autoApprovalReview/started` — [UNSTABLE] temporary guardian notification carrying `{threadId, turnId, targetItemId, parentToolItemId, review, action?}` when guardian approval review begins. This shape is expected to change soon.
|
||||
- `item/autoApprovalReview/completed` — [UNSTABLE] temporary guardian notification carrying `{threadId, turnId, targetItemId, parentToolItemId, review, action?}` when guardian approval review resolves. This shape is expected to change soon.
|
||||
- `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. `targetItemId` is the stable guardian review id for matching started/completed notifications. `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 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.
|
||||
|
||||
There are additional item-specific events:
|
||||
|
||||
|
||||
@@ -225,7 +225,8 @@ fn guardian_auto_approval_review_notification(
|
||||
rationale: assessment.rationale.clone(),
|
||||
};
|
||||
let parent_tool_item_id = assessment.parent_tool_item_id.clone();
|
||||
let target_item_id = assessment.id.clone();
|
||||
let review_id = assessment.id.clone();
|
||||
let target_item_id = review_id.clone();
|
||||
match assessment.status {
|
||||
codex_protocol::protocol::GuardianAssessmentStatus::InProgress => {
|
||||
ServerNotification::ItemGuardianApprovalReviewStarted(
|
||||
@@ -233,6 +234,7 @@ fn guardian_auto_approval_review_notification(
|
||||
thread_id: conversation_id.to_string(),
|
||||
turn_id,
|
||||
target_item_id,
|
||||
review_id: Some(review_id),
|
||||
parent_tool_item_id,
|
||||
review,
|
||||
action: assessment.action.clone(),
|
||||
@@ -247,6 +249,7 @@ fn guardian_auto_approval_review_notification(
|
||||
thread_id: conversation_id.to_string(),
|
||||
turn_id,
|
||||
target_item_id,
|
||||
review_id: Some(review_id),
|
||||
parent_tool_item_id,
|
||||
review,
|
||||
action: assessment.action.clone(),
|
||||
@@ -2937,6 +2940,7 @@ mod tests {
|
||||
assert_eq!(payload.thread_id, conversation_id.to_string());
|
||||
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.review.status,
|
||||
@@ -2978,6 +2982,7 @@ mod tests {
|
||||
assert_eq!(payload.thread_id, conversation_id.to_string());
|
||||
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.review.status, GuardianApprovalReviewStatus::Denied);
|
||||
assert_eq!(payload.review.risk_score, Some(91));
|
||||
@@ -3019,6 +3024,7 @@ mod tests {
|
||||
assert_eq!(payload.thread_id, conversation_id.to_string());
|
||||
assert_eq!(payload.turn_id, "turn-from-assessment");
|
||||
assert_eq!(payload.target_item_id, "guardian-3");
|
||||
assert_eq!(payload.review_id.as_deref(), Some("guardian-3"));
|
||||
assert_eq!(payload.parent_tool_item_id.as_deref(), Some("command-3"));
|
||||
assert_eq!(payload.review.status, GuardianApprovalReviewStatus::Aborted);
|
||||
assert_eq!(payload.review.risk_score, None);
|
||||
@@ -3057,6 +3063,7 @@ mod tests {
|
||||
assert_eq!(payload.thread_id, conversation_id.to_string());
|
||||
assert_eq!(payload.turn_id, "turn-from-assessment");
|
||||
assert_eq!(payload.target_item_id, "guardian-4");
|
||||
assert_eq!(payload.review_id.as_deref(), Some("guardian-4"));
|
||||
assert_eq!(payload.parent_tool_item_id, None);
|
||||
assert_eq!(payload.review.status, GuardianApprovalReviewStatus::Aborted);
|
||||
assert_eq!(payload.review.risk_score, None);
|
||||
|
||||
@@ -6075,16 +6075,22 @@ impl ChatWidget {
|
||||
),
|
||||
ServerNotification::ItemGuardianApprovalReviewStarted(notification) => {
|
||||
self.on_guardian_review_notification(
|
||||
notification.target_item_id,
|
||||
notification
|
||||
.review_id
|
||||
.unwrap_or(notification.target_item_id),
|
||||
notification.turn_id,
|
||||
notification.parent_tool_item_id,
|
||||
notification.review,
|
||||
notification.action,
|
||||
);
|
||||
}
|
||||
ServerNotification::ItemGuardianApprovalReviewCompleted(notification) => {
|
||||
self.on_guardian_review_notification(
|
||||
notification.target_item_id,
|
||||
notification
|
||||
.review_id
|
||||
.unwrap_or(notification.target_item_id),
|
||||
notification.turn_id,
|
||||
notification.parent_tool_item_id,
|
||||
notification.review,
|
||||
notification.action,
|
||||
);
|
||||
@@ -6351,11 +6357,13 @@ impl ChatWidget {
|
||||
&mut self,
|
||||
id: String,
|
||||
turn_id: String,
|
||||
parent_tool_item_id: Option<String>,
|
||||
review: codex_app_server_protocol::GuardianApprovalReview,
|
||||
action: Option<serde_json::Value>,
|
||||
) {
|
||||
self.on_guardian_assessment(GuardianAssessmentEvent {
|
||||
id,
|
||||
parent_tool_item_id,
|
||||
turn_id,
|
||||
status: match review.status {
|
||||
codex_app_server_protocol::GuardianApprovalReviewStatus::InProgress => {
|
||||
|
||||
@@ -10956,6 +10956,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,
|
||||
turn_id: "turn-1".into(),
|
||||
status: GuardianAssessmentStatus::InProgress,
|
||||
risk_score: None,
|
||||
@@ -10974,6 +10975,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,
|
||||
turn_id: "turn-1".into(),
|
||||
status: GuardianAssessmentStatus::Denied,
|
||||
risk_score: Some(96),
|
||||
@@ -11017,6 +11019,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,
|
||||
turn_id: "turn-1".into(),
|
||||
status: GuardianAssessmentStatus::Approved,
|
||||
risk_score: Some(14),
|
||||
@@ -11068,6 +11071,8 @@ async fn app_server_guardian_review_started_sets_review_status() {
|
||||
thread_id: "thread-1".to_string(),
|
||||
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,
|
||||
review: GuardianApprovalReview {
|
||||
status: GuardianApprovalReviewStatus::InProgress,
|
||||
risk_score: None,
|
||||
@@ -11106,6 +11111,8 @@ async fn app_server_guardian_review_denied_renders_denied_request_snapshot() {
|
||||
thread_id: "thread-1".to_string(),
|
||||
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,
|
||||
review: GuardianApprovalReview {
|
||||
status: GuardianApprovalReviewStatus::InProgress,
|
||||
risk_score: None,
|
||||
@@ -11124,6 +11131,8 @@ async fn app_server_guardian_review_denied_renders_denied_request_snapshot() {
|
||||
thread_id: "thread-1".to_string(),
|
||||
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,
|
||||
review: GuardianApprovalReview {
|
||||
status: GuardianApprovalReviewStatus::Denied,
|
||||
risk_score: Some(96),
|
||||
@@ -11161,6 +11170,57 @@ async fn app_server_guardian_review_denied_renders_denied_request_snapshot() {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn app_server_guardian_review_prefers_review_id_over_target_item_id() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(None).await;
|
||||
let action = serde_json::json!({
|
||||
"tool": "shell",
|
||||
"command": "curl -sS https://example.com",
|
||||
});
|
||||
|
||||
chat.handle_server_notification(
|
||||
ServerNotification::ItemGuardianApprovalReviewStarted(
|
||||
ItemGuardianApprovalReviewStartedNotification {
|
||||
thread_id: "thread-1".to_string(),
|
||||
turn_id: "turn-1".to_string(),
|
||||
target_item_id: "deprecated-guardian-id".to_string(),
|
||||
review_id: Some("guardian-1".to_string()),
|
||||
parent_tool_item_id: Some("command-1".to_string()),
|
||||
review: GuardianApprovalReview {
|
||||
status: GuardianApprovalReviewStatus::InProgress,
|
||||
risk_score: None,
|
||||
risk_level: None,
|
||||
rationale: None,
|
||||
},
|
||||
action: Some(action.clone()),
|
||||
},
|
||||
),
|
||||
None,
|
||||
);
|
||||
|
||||
chat.handle_server_notification(
|
||||
ServerNotification::ItemGuardianApprovalReviewCompleted(
|
||||
ItemGuardianApprovalReviewCompletedNotification {
|
||||
thread_id: "thread-1".to_string(),
|
||||
turn_id: "turn-1".to_string(),
|
||||
target_item_id: "different-deprecated-id".to_string(),
|
||||
review_id: Some("guardian-1".to_string()),
|
||||
parent_tool_item_id: Some("command-1".to_string()),
|
||||
review: GuardianApprovalReview {
|
||||
status: GuardianApprovalReviewStatus::Denied,
|
||||
risk_score: Some(96),
|
||||
risk_level: Some(AppServerGuardianRiskLevel::High),
|
||||
rationale: Some("Would exfiltrate local source code.".to_string()),
|
||||
},
|
||||
action: Some(action),
|
||||
},
|
||||
),
|
||||
None,
|
||||
);
|
||||
|
||||
assert!(chat.pending_guardian_review_status.is_empty());
|
||||
}
|
||||
|
||||
// Snapshot test: status widget active (StatusIndicatorView)
|
||||
// Ensures the VT100 rendering of the status indicator is stable when active.
|
||||
#[tokio::test]
|
||||
@@ -11271,6 +11331,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,
|
||||
turn_id: "turn-1".to_string(),
|
||||
status: GuardianAssessmentStatus::InProgress,
|
||||
risk_score: None,
|
||||
@@ -11300,6 +11361,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,
|
||||
turn_id: "turn-1".to_string(),
|
||||
status: GuardianAssessmentStatus::InProgress,
|
||||
risk_score: None,
|
||||
@@ -11315,6 +11377,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,
|
||||
turn_id: "turn-1".to_string(),
|
||||
status: GuardianAssessmentStatus::InProgress,
|
||||
risk_score: None,
|
||||
@@ -11330,6 +11393,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,
|
||||
turn_id: "turn-1".to_string(),
|
||||
status: GuardianAssessmentStatus::Denied,
|
||||
risk_score: Some(92),
|
||||
|
||||
Reference in New Issue
Block a user