pub struct GovernanceRequest {
pub agent_id: String,
pub action: String,
pub effect: EffectVector,
pub context: HashMap<String, String>,
pub node_id: Option<String>,
pub principal: Option<GatePrincipal>,
}Expand description
Governance evaluation request.
Fields§
§agent_id: StringAgent identifier making the request.
action: StringAction being requested.
effect: EffectVectorComputed effect vector for the action.
context: HashMap<String, String>Additional context for the evaluator.
node_id: Option<String>Node ID of the requesting node (for distributed governance in K6).
principal: Option<GatePrincipal>Optional attributed principal (WEFT-636). When set, propagates onto
GovernanceResult::principal and chain audit payloads. When
absent, the engine synthesises a principal from agent_id alone.
Implementations§
Source§impl GovernanceRequest
impl GovernanceRequest
Sourcepub fn new(agent_id: impl Into<String>, action: impl Into<String>) -> Self
pub fn new(agent_id: impl Into<String>, action: impl Into<String>) -> Self
Create a new governance request.
Sourcepub fn with_node_id(self, node_id: impl Into<String>) -> Self
pub fn with_node_id(self, node_id: impl Into<String>) -> Self
Set the node ID for distributed governance evaluation.
Sourcepub fn with_effect(self, effect: EffectVector) -> Self
pub fn with_effect(self, effect: EffectVector) -> Self
Set the effect vector.
Sourcepub fn with_principal(self, principal: GatePrincipal) -> Self
pub fn with_principal(self, principal: GatePrincipal) -> Self
Set the attributed principal (WEFT-636).
Sourcepub fn with_tool_context(
self,
tool_name: impl Into<String>,
gate_action: impl Into<String>,
effect: EffectVector,
pid: u64,
) -> Self
pub fn with_tool_context( self, tool_name: impl Into<String>, gate_action: impl Into<String>, effect: EffectVector, pid: u64, ) -> Self
Enrich the request with tool execution context (k3:D2).
Sets the context map with tool-specific fields so governance
rules can distinguish between different tool invocations even
when the action string is the generic "tool.exec".
§Fields set
tool— tool name (e.g."fs.read_file")gate_action— the per-tool gate action from the catalogpid— stringified PID of the requesting agent
The effect field is set from the tool’s declared effect vector,
enabling threshold-based governance that varies per tool.
Sourcepub fn with_context_entry(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_context_entry( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add a single key-value pair to the context map.
The reserved keys (crate::governance_project::RESERVED_CONTEXT_KEYS)
are the kernel’s alone and are ignored here.
Sourcepub fn resolved_principal(&self) -> GatePrincipal
pub fn resolved_principal(&self) -> GatePrincipal
Resolve the principal for this request (explicit or synthesised), attributed to the kernel’s attested project when it has one.
Source§impl GovernanceRequest
impl GovernanceRequest
Sourcepub fn attributed(self) -> Self
pub fn attributed(self) -> Self
Attribute this request to the kernel’s attested project (if any).
Sourcepub fn attributed_with(
self,
att: Option<&ProjectAttestation>,
instance: Option<&str>,
) -> Self
pub fn attributed_with( self, att: Option<&ProjectAttestation>, instance: Option<&str>, ) -> Self
attributed with an explicit attestation. With
None the request ends up with no project_id / instance_id in its
context or principal (the user daemon attributes nothing).
Trait Implementations§
Source§impl Clone for GovernanceRequest
impl Clone for GovernanceRequest
Source§impl Debug for GovernanceRequest
impl Debug for GovernanceRequest
Source§impl<'de> Deserialize<'de> for GovernanceRequest
impl<'de> Deserialize<'de> for GovernanceRequest
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for GovernanceRequest
impl RefUnwindSafe for GovernanceRequest
impl Send for GovernanceRequest
impl Sync for GovernanceRequest
impl Unpin for GovernanceRequest
impl UnsafeUnpin for GovernanceRequest
impl UnwindSafe for GovernanceRequest
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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