mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Unify Guardian context section collection (#42076)
## What changed - Add typed context sections for root-conversation evidence, trusted user answers, and conversation transcripts to `codex-guardian-context`. - Use the shared section registry when building core Guardian prompts and asynchronous Guardian V2 scoring context. - Preserve source-role labeling while delivering authorization evidence as user-role context, and fail closed when context collection fails. ## Testing - Cover shared section ordering and role preservation for synchronous and asynchronous targets. - Verify trusted user answers appear exactly once as user-role input in Guardian V2 approval flows. GitOrigin-RevId: 1d5d793ffbf166077411a66e85e039596907fb7e
This commit is contained in:
@@ -151,30 +151,7 @@ pub struct CodexThreadSettingsOverrides {
|
||||
pub personality: Option<Personality>,
|
||||
}
|
||||
|
||||
/// One root conversation message exposed only to a worker's Guardian reviewers.
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
pub enum GuardianRootMessage {
|
||||
/// Genuine root-user input that can establish or revoke authorization.
|
||||
User(String),
|
||||
/// Root assistant final output that provides untrusted conversational context.
|
||||
Assistant(String),
|
||||
/// Bounded, already role-labeled genuine user answers and their assistant questions.
|
||||
UserInput(String),
|
||||
}
|
||||
|
||||
impl GuardianRootMessage {
|
||||
/// Renders every line with its original role so message content cannot impersonate another role.
|
||||
pub fn render(self) -> String {
|
||||
let (role, text) = match self {
|
||||
Self::User(text) => ("user", text),
|
||||
Self::Assistant(text) => ("assistant", text),
|
||||
Self::UserInput(fragment) => return fragment,
|
||||
};
|
||||
text.lines()
|
||||
.map(|line| format!("{role}: {line}\n"))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
pub use codex_guardian_context::GuardianRootMessage;
|
||||
|
||||
/// Authorization state that changes on genuine user input or history resets.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
|
||||
Reference in New Issue
Block a user