Move trusted tool metadata into shared Guardian context (#43597)

## What changed

Represent host-verified tool metadata as `TrustedTool` in `codex-guardian-context` and collect it through an async-only context section. Route Guardian v2 sampling through that section while preserving separate developer-message delivery and the 512-token rendering budget. Omit tool metadata from debug output.

## Testing

Move the rendering-budget test into the shared crate, extend registry coverage for async-only collection and debug redaction, and narrow the scoped approval test to messages tagged `guardian.trusted_tool`.

GitOrigin-RevId: ee7cb4e9b9ceced70438cb58060d1a2973e1dc6a
This commit is contained in:
felixxia-oai authored and copyberry committed 2026-09-07 21:29:31 +00:00
1 parent 0b9b5ecff3
commit 2554239561
16 files changed
+426 -302

No files matched your search

+4 -1
View File
@@ -248,7 +248,9 @@ pub(crate) async fn build_guardian_prompt_items_with_parent_turn(
push_text(text);
}
}
ContextSection::PreviousReviews(_) => unreachable!("prior reviews are async-only"),
ContextSection::PreviousReviews(_) | ContextSection::TrustedTool(_) => {
unreachable!("trusted review and tool sections are async-only")
}
ContextSection::ConversationTranscript { .. } => {}
ContextSection::PermissionContext { items } => permission_items = items,
ContextSection::PlannedAction(action) => {
@@ -482,6 +484,7 @@ pub(super) fn collect_guardian_context(
planned_action,
permissions,
previous_reviews: None,
trusted_tool: None,
})
}