pub struct Guard { /* private fields */ }Expand description
The output-guard orchestrator. Cheap to share behind Arc.
Implementations§
Source§impl Guard
impl Guard
pub fn new(cfg: GuardConfig, scorer: Option<Box<dyn Scorer>>) -> Self
Sourcepub fn from_config(c: &PromptInjectionConfig) -> Result<Self, GuardError>
pub fn from_config(c: &PromptInjectionConfig) -> Result<Self, GuardError>
Build from config. In default builds the scorer is always None; if a
model is configured, a warning is logged (the injection-model feature
is required). Under the injection-model feature the configured ONNX
model is loaded instead.
pub fn config(&self) -> &GuardConfig
Sourcepub fn tool_security_note(&self) -> String
pub fn tool_security_note(&self) -> String
A sentence describing, per override field, whether the agent’s
security arg is currently honored (granted) or ignored (not granted).
Appended to covered tools’ descriptions.
Sourcepub fn harden(&self, content: &str) -> Hardened
pub fn harden(&self, content: &str) -> Hardened
HIGH-strength cleaning for rover’s own inference. Always runs patterns plus the model (when loaded); ignores output-side allowlists/overrides (internal hardening is not bypassable).
Sourcepub fn assess(
&self,
url: &str,
security: Option<&SecurityArg>,
body: &str,
) -> Assessment
pub fn assess( &self, url: &str, security: Option<&SecurityArg>, body: &str, ) -> Assessment
Scan + act on body. The caller renders the frontmatter (embedding
Assessment.telemetry), then calls finish.
Sourcepub fn finish(
&self,
a: &Assessment,
frontmatter: &str,
body: &str,
honor_drop: bool,
) -> String
pub fn finish( &self, a: &Assessment, frontmatter: &str, body: &str, honor_drop: bool, ) -> String
Produce the final agent-facing content string. frontmatter is the
already-rendered frontmatter (may be empty, e.g. for summarize).
body is the final body to wrap: the acted-upon body for the direct
path, or a summary on the summarize path. honor_drop is false on the
summarize path — the returned body is a cleaned summary, so the
strict-drop action on the raw body does not apply.
Sourcepub fn guard_metadata(
&self,
url: &str,
security: Option<&SecurityArg>,
fields: &mut [&mut String],
) -> MetadataGuard
pub fn guard_metadata( &self, url: &str, security: Option<&SecurityArg>, fields: &mut [&mut String], ) -> MetadataGuard
Guard get_metadata field values in place. No wrapper (no document):
scans each field, applies the level action to it, and returns aggregate
telemetry plus a warning notice when anything was detected.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Guard
impl !UnwindSafe for Guard
impl Freeze for Guard
impl Send for Guard
impl Sync for Guard
impl Unpin for Guard
impl UnsafeUnpin for Guard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more