kian_plugin/lib.rs
1//! `kian-plugin` — Ctx registry, Plugin trait, five-mode dispatch, Disposer.
2//!
3//! DESIGN §7 assigns this crate the key interfaces `Ctx`, `Plugin`,
4//! `Disposer`; the design mapping lives in DESIGN §6 ("Plugin system
5//! (Cordis-inspired, Rust-ized)"). Static, compile-time registration only
6//! in built-in (ADR-004) — no dynamic loading.
7//!
8//! The seam *definitions* live in [`kian_core::seams`]; this crate consumes
9//! them and never redefines them.
10//!
11//! Modules:
12//! - [`ctx`] — typed service registry, `Plugin`/`PluginSet` activation,
13//! `Disposer`
14//! - [`dispatch`] — five-mode typed-event dispatch (`emit` / `waterfall` /
15//! `parallel` / `serial` / `bail`)
16//! - [`hooks`] — the hook-plugin vocabulary (closed catalog, payload views,
17//! capability grants), the hook-scoped tier-0 registry and the `HookBus`
18//! dispatch core (PLUGIN-SPEC v2.2, ADR-028)
19
20pub mod ctx;
21pub mod dispatch;
22pub mod hooks;
23
24pub use ctx::{Ctx, Disposer, Plugin, PluginError, PluginSet, Service};
25pub use dispatch::{
26 BailHandler, Flow, Observer, SerialHandler, WaterfallMiddleware, WaterfallNext,
27};
28
29/// Compile-time plugin registration (ADR-004): assembles a [`PluginSet`]
30/// from plugin values. The activation order is *not* the listing order —
31/// [`PluginSet::activate`] derives a deterministic topological order from
32/// the plugins' declared dependencies.
33///
34/// ```ignore
35/// let set = kian_plugins![LoggingPlugin::new(), ToolsPlugin::new()];
36/// let disposer = set.activate(&mut ctx)?;
37/// ```
38#[macro_export]
39macro_rules! kian_plugins {
40 ($($plugin:expr),+ $(,)?) => {{
41 let mut set = $crate::PluginSet::new();
42 $( set.register($plugin); )+
43 set
44 }};
45}