Verify manual approval provenance in Guardian transcripts (#64160)

## Why

Guardian identified manual approvals by the opening text of a developer
message. Hook output could use the same opening text, and unrelated
content in the same message could be included with an approval.

## What changed

Check each developer text part before joining it into the transcript.
Require the manual approval prefix, the `guardian.approved_action` content
kind, and provenance from the harness outside of hooks.

## Testing

Transcript tests cover missing provenance and same-prefix text with hook
provenance or a different content kind. The context budget test checks
that the full manual approval stays ahead of a later user restriction
and that adjacent hook text is excluded.

GitOrigin-RevId: 64fafc3a429ce1e21eb5233c8223228947d1c20b
This commit is contained in:
ioanbudea-OAI
2026-11-26 14:29:37 +00:00
committed by copyberry
parent 7ca4eada90
commit 61369c4e95
7 changed files with 117 additions and 68 deletions
@@ -1,5 +1,6 @@
use super::ContextualUserFragment;
use crate::guardian::AUTO_REVIEW_DENIED_ACTION_APPROVAL_DEVELOPER_PREFIX;
use codex_guardian_context::MANUAL_APPROVAL_CONTENT_KIND;
use codex_protocol::models::ContentItem;
use codex_protocol::models::ContentItemKind;
use codex_protocol::models::input_text;
@@ -10,7 +11,7 @@ pub(crate) struct GuardianApprovedAction {
}
impl GuardianApprovedAction {
pub(crate) const KIND: &str = "guardian.approved_action";
pub(crate) const KIND: &str = MANUAL_APPROVAL_CONTENT_KIND;
pub(crate) fn new(approved_action_json: String) -> Self {
Self {