mirror of
https://github.com/openai/codex.git
synced 2026-11-14 14:49:31 +00:00
Centralize Guardian context composition (#43805)
## Why Synchronous approval reviews and asynchronous scoring assemble Guardian evidence separately, duplicating transcript framing and section placement. ## What changed - Move evidence ordering, framing, and delivery into `codex-guardian-context`, while keeping transcript retention, budgets, and delta cursors with their callers. - Pass composed messages directly to the asynchronous sampler, preserving roles, annotations, trusted message boundaries, and image placement. - Reject unsupported synchronous delivery with `SectionError::UnsupportedDelivery` instead of silently dropping content. ## Testing Add composition coverage for preserving separate messages and rejecting them for synchronous delivery. Extend Guardian integration coverage to check trusted tool and skill messages, mixed text and image evidence ordering, and full and delta review framing. GitOrigin-RevId: efc06695ee4e2b7400b123b77ef2a21c8bf40646
This commit is contained in:
1 parent
74d3a5bf10
commit
0034ef93a7
11 files changed
+624
-328
No files matched your search
@@ -47,6 +47,11 @@ pub use verified_answers::render_verified_answers;
|
||||
mod retained_instructions;
|
||||
|
||||
mod action;
|
||||
mod composition;
|
||||
pub use composition::CollectedContext;
|
||||
pub use composition::ComposedContext;
|
||||
pub use composition::ContextPresentation;
|
||||
pub use composition::RenderedTranscript;
|
||||
mod authorization;
|
||||
mod entry;
|
||||
mod history;
|
||||
@@ -188,6 +193,8 @@ pub trait SectionContributor: Send + Sync {
|
||||
pub enum SectionError {
|
||||
/// Evidence required by this contributor for the current input is missing.
|
||||
MissingRequiredEvidence { section: &'static str },
|
||||
/// A section cannot be delivered by the requested consumer.
|
||||
UnsupportedDelivery { section: &'static str },
|
||||
/// Supplied evidence exceeds the section's count or rendered-size limit.
|
||||
EvidenceLimitExceeded { section: &'static str },
|
||||
}
|
||||
@@ -198,6 +205,9 @@ impl std::fmt::Display for SectionError {
|
||||
Self::MissingRequiredEvidence { section } => {
|
||||
write!(formatter, "missing required evidence for section {section}")
|
||||
}
|
||||
Self::UnsupportedDelivery { section } => {
|
||||
write!(formatter, "unsupported delivery for section {section}")
|
||||
}
|
||||
Self::EvidenceLimitExceeded { section } => {
|
||||
write!(formatter, "evidence exceeds limits for section {section}")
|
||||
}
|
||||
@@ -243,6 +253,13 @@ impl SectionRegistry {
|
||||
self.contributors.push(Arc::new(contributor));
|
||||
}
|
||||
|
||||
/// Collects evidence for host transcript selection and shared composition.
|
||||
pub fn prepare(&self, input: &SectionInput<'_>) -> Result<CollectedContext, SectionError> {
|
||||
Ok(CollectedContext {
|
||||
sections: self.collect(input)?,
|
||||
})
|
||||
}
|
||||
|
||||
/// Collects applicable sections in their original registration order.
|
||||
///
|
||||
/// Stops at the first error without returning any partial context. The host
|
||||
|
||||
Reference in new issue
Block a user