pub struct ContentSource {
pub kind: ContentSourceKind,
pub trust_level: ContentTrustLevel,
pub identifier: Option<String>,
pub memory_hint: Option<MemorySourceHint>,
}Expand description
Provenance metadata attached to a piece of untrusted content.
Created at the call-site (tool executor, MCP adapter, A2A handler, etc.) to describe
where content came from. Passed into ContentSanitizer::sanitize] alongside the raw
content so the pipeline can choose the appropriate spotlight wrapper and injection
detection sensitivity.
§Examples
use zeph_sanitizer::{ContentSource, ContentSourceKind, ContentTrustLevel, MemorySourceHint};
// Basic source for a shell tool result.
let source = ContentSource::new(ContentSourceKind::ToolResult)
.with_identifier("shell");
assert_eq!(source.trust_level, ContentTrustLevel::LocalUntrusted);
assert_eq!(source.identifier.as_deref(), Some("shell"));
// Memory retrieval with a hint to skip injection detection for conversation turns.
let mem_source = ContentSource::new(ContentSourceKind::MemoryRetrieval)
.with_memory_hint(MemorySourceHint::ConversationHistory);
assert!(mem_source.memory_hint.is_some());Fields§
§kind: ContentSourceKindThe category of this content source.
trust_level: ContentTrustLevelTrust tier that drives the spotlight wrapper choice.
identifier: Option<String>Optional identifier: tool name, URL, agent ID, etc. Used in spotlight attributes.
memory_hint: Option<MemorySourceHint>Optional hint for memory retrieval sub-sources. When Some, modulates injection
detection sensitivity in ContentSanitizer::sanitize]. Non-memory sources leave
this as None — full detection applies.
Implementations§
Source§impl ContentSource
impl ContentSource
Sourcepub fn new(kind: ContentSourceKind) -> ContentSource
pub fn new(kind: ContentSourceKind) -> ContentSource
Create a new source with the default trust level for the given kind.
§Examples
use zeph_sanitizer::{ContentSource, ContentSourceKind, ContentTrustLevel};
let source = ContentSource::new(ContentSourceKind::WebScrape);
assert_eq!(source.trust_level, ContentTrustLevel::ExternalUntrusted);
assert!(source.identifier.is_none());Sourcepub fn with_identifier(self, id: impl Into<String>) -> ContentSource
pub fn with_identifier(self, id: impl Into<String>) -> ContentSource
Set the identifier for this source (tool name, URL, agent ID, etc.).
The identifier appears in the spotlight wrapper’s XML attributes so the LLM can
see where the content came from (e.g. name="shell", ref="https://example.com").
§Examples
use zeph_sanitizer::{ContentSource, ContentSourceKind};
let source = ContentSource::new(ContentSourceKind::ToolResult)
.with_identifier("shell");
assert_eq!(source.identifier.as_deref(), Some("shell"));Sourcepub fn with_trust_level(self, level: ContentTrustLevel) -> ContentSource
pub fn with_trust_level(self, level: ContentTrustLevel) -> ContentSource
Override the trust level for this source.
Use when the call-site has more context about the actual origin of the content than the default derived from the source kind.
§Examples
use zeph_sanitizer::{ContentSource, ContentSourceKind, ContentTrustLevel};
// Elevate trust for a verified internal source.
let source = ContentSource::new(ContentSourceKind::McpResponse)
.with_trust_level(ContentTrustLevel::LocalUntrusted);
assert_eq!(source.trust_level, ContentTrustLevel::LocalUntrusted);Sourcepub fn with_memory_hint(self, hint: MemorySourceHint) -> ContentSource
pub fn with_memory_hint(self, hint: MemorySourceHint) -> ContentSource
Attach a memory source hint to modulate injection detection sensitivity.
Only meaningful for ContentSourceKind::MemoryRetrieval sources.
Trait Implementations§
Source§impl Clone for ContentSource
impl Clone for ContentSource
Source§fn clone(&self) -> ContentSource
fn clone(&self) -> ContentSource
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ContentSource
impl RefUnwindSafe for ContentSource
impl Send for ContentSource
impl Sync for ContentSource
impl Unpin for ContentSource
impl UnsafeUnpin for ContentSource
impl UnwindSafe for ContentSource
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request