Files
codex/codex-rs/guardian-context/src/section.rs
T
felixxia-oai 29aa1df62e Retain assistant context for Guardian authorization reviews (#47582)
## Why

Ordinary user replies can depend on preceding assistant messages. Losing those messages during compaction can leave Guardian without the context needed to interpret a reply's scope.

## What changed

- Retain original assistant messages, including commentary, with their recorded order across checkpoints and resume. Exclude compaction output from this evidence.
- Include assistant context in local and delegated reviews as untrusted context, with separate storage limits and lower budget priority than user instructions.
- Prefer assistant context preceding ordinary replies when selecting bounded root evidence, and report unavailable context without inferring what a reply refers to.
- Preserve inherited context scope and remove assistant evidence beyond rollback boundaries, including during rollout migration.

## Testing

Extend coverage for compaction and resume, checkpoint migration, queued-input ordering and rollback, role labeling, and evidence budgets that preserve user restrictions while dropping assistant context.

GitOrigin-RevId: 886189b0be29ffc3d324b56f5d0b673d6b8d84da
2026-09-23 16:15:55 +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<crate::Budgeted<String>> },
SenderUserMessages { items: Vec<String> },
PlannedAction(PlannedAction),
PreviousReviews(PreviousReviews),
TrustedTool(TrustedTool),
TrustedSkills(TrustedSkills),
TranscriptImages(TranscriptImages),
NodeReplEvidence(RenderedNodeReplEvidence),
PermissionContext { items: Vec<String> },
}