pub enum Principal {
User(PrincipalId),
Component(ComponentId),
System,
}Expand description
The actor performing an action.
A Principal represents identity only, not permission level. Permission is determined by the runtime layer’s Session.
§Variants
| Variant | Description | Typical Use |
|---|---|---|
User | Human user | Interactive CLI usage |
Component | Autonomous component | Background processing |
System | Internal operations | Lifecycle, cleanup |
§Why Not Just Use ComponentId?
ComponentId identifies what is executing (LLM, Tool, etc.).
Principal identifies who initiated the action.
A Tool component may execute a file write, but the Principal is the human user who requested it. This distinction enables:
- Audit trails attributing actions to users
- Permission checks based on who initiated
- Rate limiting per user, not per component
§Example
use orcs_types::{Principal, ComponentId, PrincipalId};
// Human user
let user = Principal::User(PrincipalId::new());
// Component acting autonomously (e.g., scheduled task)
let component = Principal::Component(ComponentId::builtin("scheduler"));
// System internal operation
let system = Principal::System;Variants§
User(PrincipalId)
Human user identified by PrincipalId.
Represents interactive CLI usage or API calls from authenticated users.
Component(ComponentId)
Component acting autonomously.
Used when a component initiates actions without direct human involvement, such as:
- Scheduled background tasks
- Event-driven reactions
- Plugin self-maintenance
System
System internal operations.
Used for operations that are not attributable to any specific user or component:
- Lifecycle management (startup, shutdown)
- Garbage collection
- Internal housekeeping
Implementations§
Source§impl Principal
impl Principal
Sourcepub fn is_user(&self) -> bool
pub fn is_user(&self) -> bool
Returns true if this is a Principal::User.
Sourcepub fn is_component(&self) -> bool
pub fn is_component(&self) -> bool
Returns true if this is a Principal::Component.
Sourcepub fn is_system(&self) -> bool
pub fn is_system(&self) -> bool
Returns true if this is Principal::System.
Sourcepub fn user_id(&self) -> Option<&PrincipalId>
pub fn user_id(&self) -> Option<&PrincipalId>
Returns the PrincipalId if this is a User, otherwise None.
Sourcepub fn component_id(&self) -> Option<&ComponentId>
pub fn component_id(&self) -> Option<&ComponentId>
Returns the ComponentId if this is a Component, otherwise None.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Principal
impl<'de> Deserialize<'de> for Principal
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Principal, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Principal, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Principal
impl Serialize for Principal
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for Principal
impl StructuralPartialEq for Principal
Auto Trait Implementations§
impl Freeze for Principal
impl RefUnwindSafe for Principal
impl Send for Principal
impl Sync for Principal
impl Unpin for Principal
impl UnsafeUnpin for Principal
impl UnwindSafe for Principal
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.