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:
Charles Cunningham
2026-03-22 15:36:06 -07:00
parent 33077d50e1
commit 8e2dc92d6a
12 changed files with 195 additions and 20 deletions
+3 -3
View File
@@ -876,10 +876,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);