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>,
impl Eq for Principal
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 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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.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 moreimpl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.