pub struct NetworkPolicyDecider { /* private fields */ }Expand description
Glue type that bundles a NetworkPolicy with a session cache and an
auditor. Tools call NetworkPolicyDecider::evaluate before any HTTP
transport is constructed; the result decides whether to proceed, deny,
or prompt the user.
Implementations§
Source§impl NetworkPolicyDecider
impl NetworkPolicyDecider
Sourcepub fn new(policy: NetworkPolicy, auditor: Option<NetworkAuditor>) -> Self
pub fn new(policy: NetworkPolicy, auditor: Option<NetworkAuditor>) -> Self
Build a decider from a policy. The session cache starts empty.
Sourcepub fn with_default_audit(policy: NetworkPolicy) -> Self
pub fn with_default_audit(policy: NetworkPolicy) -> Self
Convenience: build a decider with default audit logging at
~/.deepseek/audit.log, if policy.audit is true.
Sourcepub fn policy(&self) -> &NetworkPolicy
pub fn policy(&self) -> &NetworkPolicy
Inspect the policy.
Sourcepub fn cache(&self) -> &NetworkSessionCache
pub fn cache(&self) -> &NetworkSessionCache
Inspect the session cache.
Sourcepub fn evaluate(&self, host: &str, tool: &str) -> Decision
pub fn evaluate(&self, host: &str, tool: &str) -> Decision
Decide for host, consulting the session cache first.
Audit logging happens only for terminal decisions (Allow / Deny).
Prompt is intentionally not logged here — the caller is responsible
for recording the user’s eventual answer with record_prompt_outcome.
Sourcepub fn approve_session(&self, host: &str, tool: &str)
pub fn approve_session(&self, host: &str, tool: &str)
Approve host for the rest of the session (one-shot). Audit log gets
Prompt-Approved.
Sourcepub fn deny_session(&self, host: &str, tool: &str)
pub fn deny_session(&self, host: &str, tool: &str)
Deny host for the rest of the session. Audit log gets Prompt-Denied.
Sourcepub fn approve_persistent(&mut self, host: &str, tool: &str) -> &NetworkPolicy
pub fn approve_persistent(&mut self, host: &str, tool: &str) -> &NetworkPolicy
Persist host into the policy’s allow list (so it survives the session)
and approve it in-session. Returns the updated policy so callers can
write it back to disk.
Trait Implementations§
Source§impl Clone for NetworkPolicyDecider
impl Clone for NetworkPolicyDecider
Source§fn clone(&self) -> NetworkPolicyDecider
fn clone(&self) -> NetworkPolicyDecider
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more