Skip to main content

SubstrateCoordinator

Struct SubstrateCoordinator 

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

Cross-backend dispatch layer.

Owns node-to-backend location (D2), cross-backend link stamping (D3), fan-out entity/note search with RRF (D4), traversal (D5, future), and partition tolerance (D6, future).

Implementations§

Source§

impl SubstrateCoordinator

Source

pub fn new(registry: BackendRegistry) -> Self

Construct from a BackendRegistry.

Source

pub fn with_locator_ttl(registry: BackendRegistry, ttl: Duration) -> Self

Construct from a BackendRegistry with a custom locator TTL.

Source

pub fn single(runtime: Arc<KhiveRuntime>) -> Self

Construct with a single backend (single-backend deployment default).

Source

pub fn registry(&self) -> &BackendRegistry

The underlying BackendRegistry.

Source

pub fn locator_cache(&self) -> &Arc<LocatorCache> ⓘ

A shared reference to the locator cache (D2).

Source

pub fn primary_runtime(&self) -> Option<Arc<KhiveRuntime>>

The primary backend’s runtime, or None if the registry is empty.

Source

pub fn backend_ids(&self) -> Vec<BackendId>

List all registered backend ids.

Source

pub fn backend_count(&self) -> usize

Number of registered backends.

Source

pub fn is_single_backend(&self) -> bool

True when this is a single-backend deployment.

Source

pub async fn locate(&self, id: Uuid, namespace: &Namespace) -> Option<BackendId>

Resolve which backend owns the substrate node identified by id.

Namespace-agnostic per ADR-007 Rev 3: presence of the record on a backend is sufficient — the stored namespace is NOT compared to the caller namespace. The namespace parameter is used only for runtime.authorize() capability checks.

Delegates to the private locate_endpoint, which resolves in the same substrate order as get (entity/note/event, then edge — #674), so a full-UUID link endpoint locates exactly what get resolves for the same UUID.

Source

pub fn record_created(&self, id: Uuid, backend_id: BackendId)

Prewarm the locator cache after a successful create.

Called by the SubstrateCoordinatorService so that the first locate() for a newly-created record is a cache hit rather than a backend scan.

Source

pub fn invalidate(&self, id: Uuid)

Invalidate the locator cache entry for id.

Create an edge whose endpoints may be on different backends (ADR-029 D3).

Locates both source_id and target_id. When they are on different backends, the edge is written on the source backend with target_backend stamped to the target backend id. When both endpoints are on the same backend, delegates to the normal link path (no target_backend stamp).

The coordinator validates endpoints via validate_link_endpoints on the source backend’s runtime before writing the edge.

Observable, policy-aware form of Self::link_cross_backend.

Broadcast a validated KG search request to all registered backends in parallel. One selected backend passes its ranking evidence through; multiple selected backends use outer RRF (k=60). Every filter in the request reaches the matching runtime search method on every backend.

Per-backend errors are captured in BackendSearchResult::error — a single failing backend does NOT abort the fan-out.

Authorizes each backend token against namespace alone (visible set [namespace]) — see Self::fan_out_search_with_visibility for the caller-widened-visibility variant the MCP coordinator boundary uses.

Source

pub async fn fan_out_search_with_visibility( &self, request: &ValidatedSearchRequest, namespace: &Namespace, extra_visible: &[Namespace], ) -> (Vec<SearchHit>, Vec<NoteSearchHit>, Vec<BackendSearchResult>)

Same as Self::fan_out_search, but authorizes each backend token with an explicit extra read-visibility set (MAJ-3 fix).

extra_visible mirrors the normal registry dispatch path’s ['local'] ∪ visible_namespaces widening (khive_runtime::pack::VerbRegistry::dispatch_with_identity) — pass &[] (equivalent to Self::fan_out_search) to authorize against namespace alone, or the caller’s resolved extra-visible set to widen read visibility the same way the single-backend registry path does. An explicit namespace= request parameter intentionally narrows visibility and must be passed as &[] by the caller — this method does not itself distinguish explicit from default namespace resolution.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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