Skip to main content

Principal

Enum Principal 

Source
pub enum Principal {
    Operator {
        id: OperatorId,
    },
    Platform {
        id: PlatformId,
    },
    Delegate {
        authorizing: Box<Principal>,
        delegate: DelegateId,
        scope: AuthorityScope,
    },
    Federated {
        trust_root: TrustRoot,
        identity: ExternalId,
    },
}
Expand description

A first-class principal — the entity acting in CellOS authority chains.

Per ADR-0019 §Decision, every signed event attributes one of these four variants. Composition (Delegate.scope ⊆ authorizing.scope) is enforced by Principal::compose.

§Wire form

The structured representation uses an internally-tagged enum with kind as the discriminant — see the module-level docs for the URI form. Round-trip is guaranteed: Principal::from_source_uri(p.to_source_uri()) == Ok(p) for every valid principal.

Variants§

§

Operator

The historical case: a human operator’s bearer-token identity. Preserved as the v0.5 wire form so existing consumers round-trip byte-for-byte.

Fields

§

Platform

The hosted control plane itself acting on behalf of a tenant. Used for periodic compaction, tenant migration, billing snapshots.

Fields

§

Delegate

An LLM session / programmatic agent acting on behalf of an authorizing principal, with bounded scope. Use Principal::compose to construct — the constructor enforces the narrowing invariant.

Fields

§authorizing: Box<Principal>
§delegate: DelegateId
§

Federated

An external IAM (OIDC issuer, ADO org, GitHub org) acting as a principal via federation.

Fields

§trust_root: TrustRoot
§identity: ExternalId

Implementations§

Source§

impl Principal

Source

pub fn root_operator(&self) -> Option<&OperatorId>

Returns Some(operator_id) iff the principal chain bottoms out at a human Principal::Operator at any depth; None otherwise. Used by compliance queries to answer ADR-0019’s “did a human author this action at any depth?” question.

Source

pub fn effective_scope(&self) -> AuthorityScope

The effective scope a principal exposes to a downstream delegate.

  • A Delegate exposes its own (already-narrowed) scope.
  • Any other variant is treated as holding the root scope (AuthorityScope::root) for the purpose of composition. ADR-0019 §Out-of-scope leaves “what specific capabilities a non-delegate principal holds” to the tenancy and federated- authority ADRs; pre-ratification we treat the root as unbounded so composition does not block legitimate first delegations.
Source

pub fn compose( authorizing: Principal, delegate: DelegateId, requested_scope: AuthorityScope, ) -> Result<Principal, AuthorityScopeViolation>

Compose a delegate principal. Returns Ok(Principal::Delegate { … }) iff requested_scope is a subset of authorizing.effective_scope(). Otherwise returns AuthorityScopeViolation naming the first non-narrowing capability — the admission discriminant delegate_scope_not_narrowing.

Source

pub fn to_source_uri(&self) -> String

Render the CloudEvent source URI representation per ADR-0019:

  • Operator: principal://operator/<id>
  • Platform: principal://platform/<id>
  • Delegate: principal://<chain>/delegate/<id>?scope=<csv> where <chain> is the authorizing principal’s URI body (everything after principal://, query stripped).
  • Federated: principal://federated/<root_kind>/<root_id>/identity/<external_id>

The ?scope= query carries capabilities in sorted-token form (the AuthorityScope backing BTreeSet orders them), comma- separated, so the URI is canonical and to_source_uri ∘ from_source_uri is a deterministic identity on valid principals.

Source

pub fn from_source_uri(uri: &str) -> Result<Principal, PrincipalParseError>

Parse a CloudEvent source URI back into a Principal. Returns PrincipalParseError for any input that does not match the grammar in Principal::to_source_uri.

Trait Implementations§

Source§

impl Clone for Principal

Source§

fn clone(&self) -> Principal

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Principal

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Principal

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Principal

Source§

fn eq(&self, other: &Principal) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Principal

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Principal

Source§

impl StructuralPartialEq for Principal

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,