Skip to main content

NamespaceToken

Struct NamespaceToken 

Source
pub struct NamespaceToken { /* private fields */ }
Expand description

Authorization proof that a caller is permitted to access a specific namespace.

Created by crate::VerbRegistry::dispatch after the gate approves the request. The sealed inner field prevents external code from constructing a token without going through the authorization path.

The namespace field is the write namespace: all records created via this token land in that namespace. visible is the read visibility set: list/search/get operations will return records from any namespace in this set. The write namespace is always a member of the visible set.

Single-namespace behaviour (backward-compatible default): visible contains exactly [namespace] — identical to the old strict-equality checks.

Implementations§

Source§

impl NamespaceToken

Source

pub fn namespace(&self) -> &Namespace

Return the write namespace this token authorises.

All records created via this token land in this namespace.

Source

pub fn visible_namespaces(&self) -> &[Namespace]

Return the read-visibility set.

List, search, and get operations must accept records whose namespace is a member of this set. The write namespace is always included.

Source

pub fn visible_namespace_strs(&self) -> Vec<&str>

Return a deduplicated list of visible namespace strings (borrowed).

Convenience for passing directly to storage layer filters.

Source

pub fn actor(&self) -> &ActorRef

Return the actor reference embedded in this token.

Source

pub fn with_namespace(&self, ns: Namespace) -> Self

Return a new token with the same actor but a different namespace.

The visible set is replaced with [ns] — the minted token has namespace = ns and visible = [ns]. This is a full read+write token for ns: public runtime APIs (list_notes, update_note, delete_note, etc.) accept it and will operate on ns. It is NOT a type-enforced write-only or append-only capability. This is a capability-transfer primitive, not a policy gate: the caller is responsible for enforcing any ACL check before calling this method and for using the minted token only in the intended narrow scope (e.g. a single create_note call).

Callers today:

  • khive-pack-memory FTS fanout: iterates token’s own visible set; no escalation.
  • khive-pack-comm inbound delivery: mints a token for the recipient ns, gated by actor.allowed_outbound_namespaces allowlist check immediately before, and uses it for exactly one create_note call (append-only by convention, not by type enforcement).

Under a security model (cloud, mutual auth), replace this call pattern with a type-enforced append-only capability or a comm.ingest Subhandler dispatch (see ADR-056/ADR-053) that goes through the Gate.

Trait Implementations§

Source§

impl Clone for NamespaceToken

Source§

fn clone(&self) -> NamespaceToken

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 NamespaceToken

Source§

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

Formats the value using the given formatter. Read more

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