Skip to main content

VerbRegistry

Struct VerbRegistry 

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

Immutable registry that dispatches verb calls to registered packs.

Clone is cheap (Arc-wrapped). Constructed via VerbRegistryBuilder.

Implementations§

Source§

impl VerbRegistry

Source

pub fn describe_verb(&self, verb: &str) -> Result<Value, RuntimeError>

Return the help schema envelope for a verb (issue #287).

Walks registered packs for the first matching HandlerDef and returns a structured JSON envelope. Subhandlers carry callable_via_mcp: false. Unknown verbs return RuntimeError::InvalidInput. Full shape documented in docs/protocol.md §Request Schema.

Source

pub async fn dispatch( &self, verb: &str, params: Value, ) -> Result<Value, RuntimeError>

Dispatch a verb to the first pack that handles it.

Routes through the gate, then invokes the matching pack handler. When params["help"] == true, short-circuits to describe_verb with no side effects. Gate errors are fail-open. Full dispatch flow documented in docs/protocol.md.

Source

pub fn find_kind_hook(&self, kind: &str) -> Option<Arc<dyn KindHook>>

Find a kind hook among the registered packs.

Walks packs in registration order; the first pack that both owns the kind (declares it in note_kinds() or entity_kinds()) and returns a hook from kind_hook(kind) wins. Returns None if the kind is unknown to all packs or no owning pack registered a hook.

Source

pub fn all_verbs(&self) -> Vec<&'static HandlerDef>

All MCP-exposed handlers across all registered packs (Visibility::Verb only).

Subhandlers (Visibility::Subhandler) are excluded — they are internal pipeline steps not surfaced on the MCP wire (F118). Returned with 'static lifetime since pack handlers are &'static [HandlerDef] constants.

Source

pub fn all_verbs_with_names(&self) -> Vec<(&str, &'static HandlerDef)>

All MCP-exposed handlers paired with the name of the pack that owns them (Visibility::Verb only).

Subhandlers (Visibility::Subhandler) are excluded from the MCP catalog (F118-F123). Use all_handlers_with_names when internal handlers must also be enumerated (e.g. runtime introspection).

Source

pub fn all_handlers_with_names(&self) -> Vec<(&str, &'static HandlerDef)>

All handler definitions across all registered packs, including subhandlers.

Unlike all_verbs, this includes Visibility::Subhandler entries. Useful for runtime introspection (e.g. list_handlers) and tooling that needs the complete handler surface.

Source

pub fn all_note_kinds(&self) -> Vec<&'static str>

Merged set of note kinds across all registered packs (deduplicated, first-seen order preserved).

Source

pub fn all_entity_kinds(&self) -> Vec<&'static str>

Merged set of entity kinds across all registered packs (deduplicated, first-seen order preserved).

Source

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

Names of packs in topological load order.

Source

pub fn pack_requires(&self, name: &str) -> Option<&'static [&'static str]>

Declared dependencies for a registered pack.

Source

pub fn pack_note_kinds(&self, name: &str) -> Option<&'static [&'static str]>

Note kinds owned by a specific registered pack.

Returns None if no pack with name is registered. The slice is the pack’s NOTE_KINDS constant — 'static lifetime, no allocation.

Source

pub fn pack_entity_kinds(&self, name: &str) -> Option<&'static [&'static str]>

Entity kinds owned by a specific registered pack.

Returns None if no pack with name is registered. The slice is the pack’s ENTITY_KINDS constant — 'static lifetime, no allocation.

Source

pub fn pack_verbs(&self, name: &str) -> Option<&'static [HandlerDef]>

Handlers declared by a specific registered pack.

Returns None if no pack with name is registered. Each HandlerDef carries name + description + visibility — sufficient for introspection clients.

Source

pub fn all_edge_rules(&self) -> Vec<EdgeEndpointRule>

All pack-declared edge endpoint rules across registered packs.

Order follows topological pack registration; duplicates are not deduplicated — validation only checks membership, and an exact-duplicate rule is a harmless restatement.

Source

pub fn all_note_kind_specs(&self) -> Vec<&'static NoteKindSpec>

Collect all NoteKindSpec declarations from every loaded pack.

Used by the runtime for lifecycle introspection and future enforcement.

Source

pub fn all_validation_rules(&self) -> Vec<&'static ValidationRule>

All pack-contributed validation rules across registered packs.

Returns references into the pack-owned 'static slices — no allocation beyond the outer Vec. Rule IDs are namespaced by pack; callers can group by rule.id.split_once('/') to attribute rules to their packs.

Source

pub fn all_schema_plans(&self) -> Vec<SchemaPlan>

Pack-auxiliary schema plans for all registered packs.

Returns one SchemaPlan per pack. Callers (typically the runtime bootstrap) apply each plan to the pack’s assigned backend. Empty plans are included so the caller can iterate uniformly; callers that want to skip empty plans should check plan.is_empty().

Source

pub fn call_register_embedders(&self, runtime: &KhiveRuntime)

Invoke PackRuntime::register_embedders on every registered pack.

Called by the transport during startup, after the registry is built and before the first verb dispatch, so that custom embedding providers contributed by packs are reachable via KhiveRuntime::embedder(name).

Packs whose register_embedders is the default no-op pay no overhead. The method is idempotent when the underlying registry uses last-wins semantics for duplicate provider names.

Source

pub async fn call_warm_all(&self)

Invoke PackRuntime::warm on every registered pack. Called by the daemon at boot (in a background task) so expensive in-memory state (ANN indexes) is pre-loaded without blocking request serving.

Source

pub fn presentation_policy_for(&self, verb: &str) -> VerbPresentationPolicy

Resolve the presentation policy for a verb name.

Walks all registered handlers (including subhandlers) for the first matching name and returns its declared VerbPresentationPolicy. Returns Standard for unknown verbs — unknown verbs will fail at dispatch anyway, so the fallback here is safe.

Source

pub fn is_subhandler_verb(&self, verb: &str) -> bool

Returns true if the named verb exists and is tagged Visibility::Subhandler (internal / operator-only).

Used by the MCP server to gate subhandler invocation at the wire boundary without blocking internal callers that invoke the same verbs through the runtime directly.

Source

pub fn apply_schema_plans(&self, backend: &StorageBackend)

Apply all non-empty pack-auxiliary schema plans to the given backend (c12 startup application).

This is the centralized startup hook that replaced the previous lazy per-pack self-bootstrap pattern. Each pack’s SchemaPlan carries idempotent CREATE TABLE IF NOT EXISTS DDL; calling this more than once is safe. Empty plans are skipped.

Errors from individual plans are logged via tracing::warn! and not propagated so that a single pack’s schema failure does not prevent the rest from loading. Callers that need hard-failure semantics should call all_schema_plans() and apply each plan individually.

Trait Implementations§

Source§

impl Clone for VerbRegistry

Source§

fn clone(&self) -> VerbRegistry

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

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