OpenAgentID documentation
Source referencesRust module referencearsenal-core

arsenal-core · delegation

Declared module signatures, types, configuration, and source documentation.

Source: arsenal/crates/arsenal-core/src/delegation.rs. SHA-256: 496b1578b6c1df82d7a5daeb80af45a1debdcf1d398fcac40c4963105d8969e7.

This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.

delegation::DelegationConstraints

Delegation constraints - what can be delegated

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DelegationConstraints {
/// Whether delegation is allowed at all

pub allow_delegation: bool,
/// Maximum depth of delegation (0 = no further delegation)

pub max_depth: u8,
/// Scopes that can be delegated (must be subset of parent)

#[serde(skip_serializing_if = "Option::is_none")]
pub delegatable_scopes: Option<ScopeSet>,
/// Agents that can receive delegation, named by OAS DID

///

/// A DID rather than a local key, because this constraint is a token claim:

/// whoever verifies the delegated token must be able to resolve the identity

/// it names.

#[serde(default)]
pub allowed_delegates: Vec<OasDid>,
/// Whether any agent can receive delegation

pub allow_any_delegate: bool,
/// Maximum TTL reduction required (seconds)

pub min_ttl_reduction: i64,
/// Require explicit approval for delegation

pub require_approval: bool
}

Source line: 23.

delegation::DelegationConstraints::allow

Create constraints that allow delegation

#[must_use]
pub fn allow(max_depth: u8) -> Self;

Source line: 63.

delegation::DelegationConstraints::deny

Create constraints that deny delegation

#[must_use]
pub fn deny() -> Self;

Source line: 77.

delegation::DelegationConstraints::can_delegate_to

Check if delegation to a specific agent is allowed

#[must_use]
pub fn can_delegate_to(&self, agent_did: &OasDid) -> bool;

Source line: 83.

delegation::DelegationConstraints::can_delegate_scope

Check if a scope can be delegated

#[must_use]
pub fn can_delegate_scope(&self, scope: &ScopeSet) -> bool;

Source line: 95.

delegation::DelegationConstraints::validate_delegation

Validate a delegation request

Errors

Returns an error if the delegation is not allowed

pub fn validate_delegation(
        &self,
        target_agent: &OasDid,
        requested_scopes: &ScopeSet,
        current_depth: u8,
        parent_ttl: i64,
        requested_ttl: i64,
    ) -> ArsenalResult<()>;

Source line: 109.

A link in the delegation chain

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DelegationLink {
/// Token ID of the delegating token

pub parent_token_id: TokenId,
/// Agent that delegated

pub delegator: AgentId,
/// Agent that received delegation

pub delegate: AgentId,
/// Scopes that were delegated

pub delegated_scopes: ScopeSet,
/// When the delegation occurred

pub delegated_at: chrono::DateTime<chrono::Utc>,
/// Depth in the chain (0 = first delegation)

pub depth: u8
}

Source line: 159.

delegation::DelegationChain

Complete delegation chain for audit and validation

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DelegationChain {

}

Source line: 176.

delegation::DelegationChain::new

Create a new delegation chain starting from a root token

#[must_use]
pub fn new(root_token_id: TokenId, root_agent: AgentId) -> Self;

Source line: 188.

Add a delegation link to the chain

Errors

Returns an error if the chain would be too long

pub fn add_link(&mut self, link: DelegationLink) -> ArsenalResult<()>;

Source line: 200.

delegation::DelegationChain::depth

Get the current depth of the chain

#[must_use]
pub fn depth(&self) -> u8;

Source line: 219.

delegation::DelegationChain::root_token_id

Get the root token ID

#[must_use]
pub fn root_token_id(&self) -> &TokenId;

Source line: 225.

delegation::DelegationChain::root_agent

Get the root agent

#[must_use]
pub fn root_agent(&self) -> &AgentId;

Source line: 231.

delegation::DelegationChain::current_delegate

Get the current (most recent) delegate

#[must_use]
pub fn current_delegate(&self) -> &AgentId;

Source line: 237.

Get all links in the chain

#[must_use]
pub fn links(&self) -> &[DelegationLink];

Source line: 243.

delegation::DelegationChain::validate

Validate the entire chain

Errors

Returns an error if the chain is invalid

pub fn validate(&self) -> ArsenalResult<()>;

Source line: 251.

delegation::DelegationChain::contains_agent

Check if an agent is in the chain (as delegator or delegate)

#[must_use]
pub fn contains_agent(&self, agent_id: &AgentId) -> bool;

Source line: 278.

delegation::DelegationChain::effective_scopes

Get the effective scopes at the end of the chain

This is the intersection of all delegated scopes

#[must_use]
pub fn effective_scopes(&self) -> Option<ScopeSet>;

Source line: 291.

delegation::DelegationChain::to_cbor

Serialize to CBOR

Errors

Returns an error if serialization fails

pub fn to_cbor(&self) -> ArsenalResult<Vec<u8>>;

Source line: 307.

delegation::DelegationChain::from_cbor

Deserialize from CBOR

Errors

Returns an error if deserialization fails

pub fn from_cbor(bytes: &[u8]) -> ArsenalResult<Self>;

Source line: 322.

delegation::DelegationRequest

Delegation request for creating a new delegated token

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DelegationRequest {
/// Agent requesting delegation

pub delegator: AgentId,
/// Target agent to delegate to

pub delegate: AgentId,
/// Scopes to delegate

pub scopes: ScopeSet,
/// Requested TTL in seconds

pub ttl_seconds: i64,
/// Parent token ID

pub parent_token_id: TokenId,
/// Current delegation chain (if any)

#[serde(skip_serializing_if = "Option::is_none")]
pub chain: Option<DelegationChain>
}

Source line: 346.

delegation::DelegationResult

Result of a delegation request

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DelegationResult {
/// Whether delegation was approved

pub approved: bool,
/// New token ID (if approved)

#[serde(skip_serializing_if = "Option::is_none")]
pub token_id: Option<TokenId>,
/// Updated delegation chain

#[serde(skip_serializing_if = "Option::is_none")]
pub chain: Option<DelegationChain>,
/// Reason for denial (if not approved)

#[serde(skip_serializing_if = "Option::is_none")]
pub denial_reason: Option<String>
}

Source line: 364.

On this page