Files
codex/codex-rs/guardian-context/src/section.rs
T
jif e269f2164c Include sender user messages in Guardian delegation reviews (#46179)
## Why

A delegated task can omit restrictions from the sender's user messages. Guardian needs that context when reviewing actions in the receiving thread.

## What changed

- When thread-owned Guardian context is enabled, capture up to three recent local user messages when a `send_message_to_thread` delivery from `codex_app` or `codex_tui` is accepted.
- Provide a bounded snapshot to synchronous and asynchronous reviewers, with explicit notices for unavailable evidence and a reminder that historical context does not transfer permission. Keep the snapshot out of the worker prompt.
- Retain snapshots with their deliveries across replay, compaction, and rollback, and strip them from forked agent history.

## Testing

Add coverage for reviewer-only visibility, missing sender provenance, context-budget preservation, checkpoint replay and rollback, fork isolation, and input serialization that rejects harness metadata.

GitOrigin-RevId: 3870ba762aa81689713b56d4cb3b98566bffed88
2026-09-17 10:02:38 +00:00

33 lines
1.4 KiB
Rust

//! Section identities survive consumer-specific transcript selection and rendering.
use crate::ConversationTranscriptEntry;
use crate::PlannedAction;
use crate::PreviousReviews;
use crate::RenderedNodeReplEvidence;
use crate::TranscriptImages;
use crate::TrustedSkills;
use crate::TrustedTool;
/// Ordered evidence with a stable section identity and source-specific content.
///
/// Variants preserve provenance: transcript entries carry their original roles,
/// root messages remain line-role-labeled, and answers are host-verified fragments.
/// Conversation, authorization and action evidence retain user-role delivery.
/// Host-attested reviews and tool identities use separate developer messages.
/// Review actions/rationales and remote tool descriptions remain untrusted.
#[derive(Clone, Debug, PartialEq)]
pub enum ContextSection<T = ConversationTranscriptEntry> {
ConversationTranscript { items: Vec<T> },
RootConversation { items: Vec<String> },
TrustedUserAnswers { items: Vec<String> },
RetainedUserInstructions { items: Vec<String> },
SenderUserMessages { items: Vec<String> },
PlannedAction(PlannedAction),
PreviousReviews(PreviousReviews),
TrustedTool(TrustedTool),
TrustedSkills(TrustedSkills),
TranscriptImages(TranscriptImages),
NodeReplEvidence(RenderedNodeReplEvidence),
PermissionContext { items: Vec<String> },
}