pub struct SkillTrustGate { /* private fields */ }Expand description
Shared registry + trust-snapshot pair backing both skill-body tool executors.
Cloning is cheap — all fields are Arcs (TurnTrustFloor wraps one internally).
Construct one instance per executor from the same trust_snapshot Arc (and the same
turn_trust_floor, when available) so load_skill and invoke_skill see identical
trust state within a turn.
Implementations§
Source§impl SkillTrustGate
impl SkillTrustGate
Sourcepub fn new(
registry: Arc<RwLock<SkillRegistry>>,
trust_snapshot: Arc<RwLock<HashMap<String, SkillTrustSnapshot>>>,
) -> Self
pub fn new( registry: Arc<RwLock<SkillRegistry>>, trust_snapshot: Arc<RwLock<HashMap<String, SkillTrustSnapshot>>>, ) -> Self
Build a gate over registry and trust_snapshot, with no turn trust floor wired.
Equivalent to with_turn_trust_floor with None —
prefer that constructor when a live agent turn’s floor is available so a Quarantined
body read degrades the turn’s trust (#6701, RC-3).
§Examples
use std::collections::HashMap;
use std::sync::Arc;
use parking_lot::RwLock;
use zeph_core::SkillTrustGate;
use zeph_skills::registry::SkillRegistry;
let registry = Arc::new(RwLock::new(SkillRegistry::empty()));
let trust_snapshot = Arc::new(RwLock::new(HashMap::new()));
let _gate = SkillTrustGate::new(registry, trust_snapshot);Sourcepub fn with_turn_trust_floor(self, turn_trust_floor: TurnTrustFloor) -> Self
pub fn with_turn_trust_floor(self, turn_trust_floor: TurnTrustFloor) -> Self
Build a gate over registry and trust_snapshot, wired to the given turn trust floor.
turn_trust_floor should be the same handle TrustGateExecutor::trust_floor() returns
for the live agent turn, so an explicit invoke_skill/load_skill of a Quarantined
skill folds the turn’s trust floor down (#6701, RC-3) instead of leaving the gate’s
weakest-link fold blind to bodies read outside the proactive-activation path.
Sourcepub async fn resolve_body(
&self,
skill_name: &str,
) -> Result<SkillBodyResolution, ToolError>
pub async fn resolve_body( &self, skill_name: &str, ) -> Result<SkillBodyResolution, ToolError>
Resolve skill_name through the trust pipeline shared by load_skill and
invoke_skill: refuse Blocked before any body read, re-check integrity when
requires_trust_check is set, then sanitize/wrap the body per trust level.
A missing trust-snapshot row resolves to SkillTrustLevel::MISSING_ENTRY_FALLBACK
(Trusted) — “never classified”, not “known untrusted”. skill_name is sanitized before
it appears in any returned message, including the not-found path.
§Errors
Returns an error only when the requires_trust_check integrity re-check’s
spawn_blocking task panics or is cancelled — a hash mismatch, missing skill directory,
or unreadable SKILL.md are reported as Ok(SkillBodyResolution::Refused(_)), not Err.
§Examples
let registry = Arc::new(RwLock::new(SkillRegistry::empty()));
let trust_snapshot = Arc::new(RwLock::new(HashMap::new()));
let gate = SkillTrustGate::new(registry, trust_snapshot);
match gate.resolve_body("nonexistent").await.unwrap() {
SkillBodyResolution::NotFound(message) => assert!(message.contains("nonexistent")),
_ => panic!("expected NotFound for an empty registry"),
}Trait Implementations§
Source§impl Clone for SkillTrustGate
impl Clone for SkillTrustGate
Source§fn clone(&self) -> SkillTrustGate
fn clone(&self) -> SkillTrustGate
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for SkillTrustGate
impl !UnwindSafe for SkillTrustGate
impl Freeze for SkillTrustGate
impl Send for SkillTrustGate
impl Sync for SkillTrustGate
impl Unpin for SkillTrustGate
impl UnsafeUnpin for SkillTrustGate
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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