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
impl VerbRegistry
Sourcepub async fn dispatch(
&self,
verb: &str,
params: Value,
) -> Result<Value, RuntimeError>
pub async fn dispatch( &self, verb: &str, params: Value, ) -> Result<Value, RuntimeError>
Dispatch a verb to the first pack that handles it.
When multiple packs declare the same verb, the first registered pack wins.
The configured Gate is consulted before dispatch
(ADR-029, ADR-035). Deny decisions return
RuntimeError::PermissionDenied immediately — the pack is never
invoked. Allow decisions proceed to pack dispatch as before.
Every gate consultation emits one tracing::info!(... "gate.check") event
with a structured audit_event field (ADR-033). When a EventStore
is configured via VerbRegistryBuilder::with_event_store, an Event
is also persisted to the substrate (ADR-035). Storage errors are logged
via tracing::warn! and never propagated.
When gate.check itself returns an error (gate infrastructure failure),
the error is logged via tracing::warn! and dispatch proceeds (fail-open,
consistent with ADR-029 §Rationale “Why advisory in v0.2”). No audit event
is persisted for an errored gate check — no decision was produced.
The synthesized GateRequest carries ActorRef::anonymous() and the
operation’s namespace — pulled from params["namespace"] when present
(including an explicit empty string, which KhiveRuntime::ns also
preserves), otherwise the registry’s default namespace (configured via
VerbRegistryBuilder::with_default_namespace). Gate-visible
namespace and runtime-visible namespace MUST stay aligned; coercing an
empty string here while the runtime keeps "" would create an
authorization/audit blind spot on the field ADR-029 declares public.
Transports that have richer caller context (auth headers, session
info) will gain a sibling dispatch path in a follow-up.
Sourcepub fn find_kind_hook(&self, kind: &str) -> Option<Arc<dyn KindHook>>
pub fn find_kind_hook(&self, kind: &str) -> Option<Arc<dyn KindHook>>
Find a kind hook (ADR-030) 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.
Sourcepub fn all_verbs(&self) -> Vec<&'static VerbDef>
pub fn all_verbs(&self) -> Vec<&'static VerbDef>
All verb definitions across all registered packs.
Returned with 'static lifetime since pack verbs are &'static [VerbDef]
constants — callers can keep the slice references beyond the registry’s
borrow.
Sourcepub fn all_verbs_with_names(&self) -> Vec<(&str, &'static VerbDef)>
pub fn all_verbs_with_names(&self) -> Vec<(&str, &'static VerbDef)>
All verb definitions paired with the name of the pack that owns them.
Useful for building catalogs that attribute each verb to its source pack.
The pack name has the same lifetime as &self; the VerbDef reference
is 'static.
Sourcepub fn all_note_kinds(&self) -> Vec<&'static str>
pub fn all_note_kinds(&self) -> Vec<&'static str>
Merged set of note kinds across all registered packs (deduplicated, first-seen order preserved).
Sourcepub fn all_entity_kinds(&self) -> Vec<&'static str>
pub fn all_entity_kinds(&self) -> Vec<&'static str>
Merged set of entity kinds across all registered packs (deduplicated, first-seen order preserved).
Sourcepub fn pack_names(&self) -> Vec<&str>
pub fn pack_names(&self) -> Vec<&str>
Names of packs in topological load order.
Sourcepub fn pack_requires(&self, name: &str) -> Option<&'static [&'static str]>
pub fn pack_requires(&self, name: &str) -> Option<&'static [&'static str]>
Declared dependencies for a registered pack (ADR-037).
Sourcepub fn pack_note_kinds(&self, name: &str) -> Option<&'static [&'static str]>
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.
Sourcepub fn pack_entity_kinds(&self, name: &str) -> Option<&'static [&'static str]>
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.
Sourcepub fn pack_verbs(&self, name: &str) -> Option<&'static [VerbDef]>
pub fn pack_verbs(&self, name: &str) -> Option<&'static [VerbDef]>
Verbs declared by a specific registered pack.
Returns None if no pack with name is registered. Each VerbDef
carries name + description — sufficient for introspection clients
like kkernel pack handler (ADR-076).
Sourcepub fn all_edge_rules(&self) -> Vec<EdgeEndpointRule>
pub fn all_edge_rules(&self) -> Vec<EdgeEndpointRule>
All pack-declared edge endpoint rules across registered packs (ADR-031).
Order follows topological pack registration; duplicates are not deduplicated — validation only checks membership, and an exact-duplicate rule is a harmless restatement.
Trait Implementations§
Source§impl Clone for VerbRegistry
impl Clone for VerbRegistry
Source§fn clone(&self) -> VerbRegistry
fn clone(&self) -> VerbRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more