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.