mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
Move Guardian review evidence into the reviewer extension (#57702)
## What changed Move review evidence storage, authorization snapshots, sender exchange selection, and bounded Node REPL evidence into `codex-guardian-reviewer`. Update core to call or re-export these APIs while retaining host-specific context rendering and capture-mode selection. Move the existing Node REPL evidence and text truncation tests alongside their implementations in the reviewer crate. GitOrigin-RevId: d851cd353cf9f31eb47ce13f43f6f935dc2f5d93
This commit is contained in:
@@ -3,12 +3,8 @@
|
||||
//! quoted delegation text cannot establish sender provenance. Unloaded senders are read
|
||||
//! through the host's authenticated thread store, without resuming their runtime.
|
||||
|
||||
use crate::context::GuardianSenderExchange;
|
||||
use crate::context::GuardianSenderMessages;
|
||||
use crate::context_manager::ContextManager;
|
||||
use codex_guardian_context::GuardianRootMessage;
|
||||
use codex_history::RetainedContextEntry;
|
||||
use codex_history::RetainedContextOrder;
|
||||
use codex_history::RolloutItem;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
@@ -111,38 +107,7 @@ impl LocalAgentRuntime {
|
||||
}
|
||||
};
|
||||
if let Some(context) = context {
|
||||
let mut exchanges = Vec::new();
|
||||
let mut assistant = None;
|
||||
for (order, entry) in context.ordered_entries() {
|
||||
match (order, entry) {
|
||||
(
|
||||
RetainedContextOrder::Local(_),
|
||||
RetainedContextEntry::UserMessage(message),
|
||||
) => exchanges.push((message, assistant.take())),
|
||||
(
|
||||
RetainedContextOrder::Local(_),
|
||||
RetainedContextEntry::AssistantMessage(message),
|
||||
) => assistant = Some(message),
|
||||
(RetainedContextOrder::Inherited(_), _)
|
||||
| (_, RetainedContextEntry::VerifiedAnswer(_)) => {}
|
||||
}
|
||||
}
|
||||
fragment.messages = exchanges
|
||||
.into_iter()
|
||||
.rev()
|
||||
.take(/*n*/ 3)
|
||||
.map(|(user, assistant)| GuardianSenderExchange {
|
||||
user: user.complete.then(|| user.text.clone()),
|
||||
assistant: assistant.map(|message| {
|
||||
if message.complete {
|
||||
GuardianRootMessage::Assistant(message.text.clone())
|
||||
} else {
|
||||
GuardianRootMessage::IncompleteAssistantContext
|
||||
}
|
||||
}),
|
||||
})
|
||||
.collect();
|
||||
fragment.messages.reverse();
|
||||
fragment.messages = codex_guardian_reviewer::guardian_sender_exchanges(&context);
|
||||
}
|
||||
}
|
||||
Some(fragment)
|
||||
|
||||
@@ -10,9 +10,6 @@
|
||||
//! Handoff projection preserves saved heartbeat instructions and the active turn's skills.
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::hash::Hash;
|
||||
use std::hash::Hasher;
|
||||
|
||||
use super::LocalAgentControl;
|
||||
use crate::codex_thread::GuardianRootMessage;
|
||||
@@ -307,30 +304,12 @@ impl LocalAgentControl {
|
||||
.services
|
||||
.thread_extension_data
|
||||
.get_or_init(GuardianReviewEvidence::default);
|
||||
let mut authorization_version = root_evidence.authorization_version(history.as_ref());
|
||||
if prepared.missing_root_instructions {
|
||||
authorization_version.retained_context_complete = false;
|
||||
}
|
||||
let mut review_context_revision = history.guardian_review_context_revision();
|
||||
if let Some(selected) = &prepared.handoff_selection {
|
||||
let mut revision = DefaultHasher::new();
|
||||
review_context_revision.hash(&mut revision);
|
||||
selected.hash(&mut revision);
|
||||
review_context_revision = revision.finish();
|
||||
}
|
||||
let trusted_skill_paths = prepared
|
||||
.latest_user_turn_id
|
||||
.as_deref()
|
||||
.map(|turn_id| root_evidence.trusted_skill_paths(turn_id))
|
||||
.unwrap_or_default();
|
||||
Some(GuardianRootSnapshot {
|
||||
Some(root_evidence.root_snapshot(
|
||||
root_thread_id,
|
||||
history_reset_version,
|
||||
authorization_version,
|
||||
review_context_revision,
|
||||
messages: prepared.messages,
|
||||
trusted_skill_paths,
|
||||
request_candidates: Some(request_candidates),
|
||||
})
|
||||
history.as_ref(),
|
||||
prepared,
|
||||
request_candidates,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user