pub struct TemplatePack { /* private fields */ }Expand description
Example pack joining vocabulary, handlers, dependencies, and a runtime handle.
See crates/khive-pack-template/docs/api/pack-scaffold.md.
Implementations§
Source§impl TemplatePack
impl TemplatePack
Sourcepub fn new(runtime: KhiveRuntime) -> Self
pub fn new(runtime: KhiveRuntime) -> Self
Bind the template pack to the runtime used by its handlers.
Trait Implementations§
Source§impl Pack for TemplatePack
impl Pack for TemplatePack
Source§const NOTE_KINDS: &'static [&'static str] = vocab::NOTE_KINDS
const NOTE_KINDS: &'static [&'static str] = vocab::NOTE_KINDS
Declare note kinds this pack contributes. Must not overlap with other packs.
Source§const ENTITY_KINDS: &'static [&'static str] = vocab::ENTITY_KINDS
const ENTITY_KINDS: &'static [&'static str] = vocab::ENTITY_KINDS
Declare entity kinds this pack contributes. Must not overlap with other packs.
Source§const HANDLERS: &'static [HandlerDef]
const HANDLERS: &'static [HandlerDef]
Handler table. Each entry is one verb or subhandler the pack can dispatch.
Source§const REQUIRES: &'static [&'static str]
const REQUIRES: &'static [&'static str]
Pack dependencies. The named packs must be in the configured KHIVE_PACKS list.
Source§const EDGE_RULES: &'static [EdgeEndpointRule] = _
const EDGE_RULES: &'static [EdgeEndpointRule] = _
Additional edge endpoint rules this pack contributes. Read more
Source§const ENTITY_TYPES: &'static [EntityTypeDef] = _
const ENTITY_TYPES: &'static [EntityTypeDef] = _
Entity-type subtypes this pack contributes to the
(EntityKind, entity_type) registry (the entity_type axis is distinct from and
finer-grained than the closed EntityKind
taxonomy — see khive-types::entity_type::EntityTypeRegistry). Read moreSource§const NOTE_KIND_SPECS: &'static [NoteKindSpec] = _
const NOTE_KIND_SPECS: &'static [NoteKindSpec] = _
Lifecycle and schema specs for note kinds this pack owns. Read more
Source§const SCHEMA_PLAN: Option<PackSchemaPlan> = None
const SCHEMA_PLAN: Option<PackSchemaPlan> = None
Pack-auxiliary schema plan. Read more
Source§const VALIDATION_RULES: &'static [&'static str] = _
const VALIDATION_RULES: &'static [&'static str] = _
Validation rule IDs contributed by this pack. Read more
Source§impl PackRuntime for TemplatePack
impl PackRuntime for TemplatePack
Source§fn dispatch<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
verb: &'life1 str,
params: Value,
_registry: &'life2 VerbRegistry,
token: &'life3 NamespaceToken,
) -> Pin<Box<dyn Future<Output = Result<Value, RuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn dispatch<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
verb: &'life1 str,
params: Value,
_registry: &'life2 VerbRegistry,
token: &'life3 NamespaceToken,
) -> Pin<Box<dyn Future<Output = Result<Value, RuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Dispatch a declared verb or return invalid-input for an unknown name.
Source§fn note_kinds(&self) -> &'static [&'static str]
fn note_kinds(&self) -> &'static [&'static str]
Note kinds this pack owns — must equal
<Self as Pack>::NOTE_KINDS.Source§fn entity_kinds(&self) -> &'static [&'static str]
fn entity_kinds(&self) -> &'static [&'static str]
Entity kinds this pack owns — must equal
<Self as Pack>::ENTITY_KINDS.Source§fn handlers(&self) -> &'static [HandlerDef]
fn handlers(&self) -> &'static [HandlerDef]
Handlers this pack registers — must equal
<Self as Pack>::HANDLERS.Source§fn requires(&self) -> &'static [&'static str]
fn requires(&self) -> &'static [&'static str]
Pack names whose vocabulary this pack references.
Defaults to empty so existing packs compile without changes.
Source§fn edge_rules(&self) -> &'static [EdgeEndpointRule]
fn edge_rules(&self) -> &'static [EdgeEndpointRule]
Pack-extensible edge endpoint rules — must equal
<Self as Pack>::EDGE_RULES.
Defaults to empty so existing packs that don’t extend the edge contract
can ignore it.Source§fn entity_types(&self) -> &'static [EntityTypeDef]
fn entity_types(&self) -> &'static [EntityTypeDef]
Pack-extensible entity-type subtypes — must equal
<Self as Pack>::ENTITY_TYPES.
Defaults to empty so existing packs that don’t extend the entity_type
registry can ignore it.Source§fn note_kind_specs(&self) -> &'static [NoteKindSpec]
fn note_kind_specs(&self) -> &'static [NoteKindSpec]
NoteKindSpec declarations for note kinds this pack owns. Read more
Source§fn kind_hook(&self, _kind: &str) -> Option<Arc<dyn KindHook>>
fn kind_hook(&self, _kind: &str) -> Option<Arc<dyn KindHook>>
Optional per-kind hook for shared CRUD specialization. Read more
Source§fn schema_plan(&self) -> SchemaPlan
fn schema_plan(&self) -> SchemaPlan
Pack-auxiliary schema. Read more
Source§fn validation_rules(&self) -> &'static [ValidationRule]
fn validation_rules(&self) -> &'static [ValidationRule]
Domain-specific validation rules contributed by this pack. Read more
Source§fn register_embedders(&self, _runtime: &KhiveRuntime)
fn register_embedders(&self, _runtime: &KhiveRuntime)
Register custom embedding providers with the runtime. Called during pack
initialisation, before the first verb dispatch, so
KhiveRuntime::embedder(name)
resolves provider names declared here. Default no-op — packs that only use
built-in lattice models do not need to override this.
See docs/api/pack.md#register_embedders for a usage example.Source§fn register_entity_type_validator(&self, _runtime: &KhiveRuntime)
fn register_entity_type_validator(&self, _runtime: &KhiveRuntime)
Install a pack-owned entity-type validator on the runtime, called during pack
initialisation (after the registry is built, before the first dispatch) so
create_many/create_entity reject unregistered entity_type values at the
runtime layer. Default no-op leaves the validator absent (skip-when-None).
See docs/api/pack.md#register_entity_type_validator for the two-hook compatibility contract.Source§fn register_entity_type_validator_with_types(
&self,
runtime: &KhiveRuntime,
_pack_entity_types: &[EntityTypeDef],
)
fn register_entity_type_validator_with_types( &self, runtime: &KhiveRuntime, _pack_entity_types: &[EntityTypeDef], )
Install a pack-owned entity-type validator that also receives the boot-time
composed set of every loaded pack’s
ENTITY_TYPES (VerbRegistry::all_entity_types).
Defaults to calling register_entity_type_validator
with just the runtime. call_register_entity_type_validators calls this hook, not
the simpler one — override this to receive the composed vocabulary.
See docs/api/pack.md#register_entity_type_validator for the two-hook compatibility contract.Source§fn register_note_mutation_hook(&self, _runtime: &KhiveRuntime)
fn register_note_mutation_hook(&self, _runtime: &KhiveRuntime)
Install a pack-owned note-mutation hook on the runtime, called during pack
initialisation with the same timing as
register_entity_type_validator. Packs
that cache derived state keyed by note content (e.g. khive-pack-memory’s warm
ANN index) override this to install a hook via
KhiveRuntime::install_note_mutation_hook. Default no-op leaves the hook absent.
See docs/api/pack.md#register_note_mutation_hook for cross-pack notification rationale.Source§fn warm<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn warm<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Warm up any in-memory state from persisted snapshots (optional). Called after
all packs are registered but before serving the first request. Must be
idempotent and infallible — errors are logged internally, never propagated.
Source§fn registered_embedding_model_names(&self) -> Vec<String>
fn registered_embedding_model_names(&self) -> Vec<String>
Names of all embedding models registered on this pack’s underlying runtime
handle. Defaults to empty — only packs that own embedding-bearing verbs
(kg, memory) need to override this.
See
docs/api/pack.md#registered_embedding_model_names for the ADR-103 consumer.Auto Trait Implementations§
impl !RefUnwindSafe for TemplatePack
impl !UnwindSafe for TemplatePack
impl Freeze for TemplatePack
impl Send for TemplatePack
impl Sync for TemplatePack
impl Unpin for TemplatePack
impl UnsafeUnpin for TemplatePack
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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