appcore_core/plugin.rs
1// =============================================================================
2// #######
3// ### ### F: plugin.rs
4// ## ## ## ## P: AppCore-Runtime
5// ## ##
6// C: 2026/05/29 20:47:35 by dnettoRaw
7// ## ## ## ## U: 2026/06/04 11:51:30 by dnettoRaw
8// ########### S: 0.6.0
9// =============================================================================
10
11//! Application plugin contract using concrete core registries.
12
13use crate::bus::CommandBus;
14use crate::command::CommandRegistry;
15use crate::decision::{DecisionEngine, DecisionRegistry};
16use crate::error::RuntimeResult;
17use crate::event::EventRegistry;
18use crate::identity::RuntimeIdentity;
19use crate::ids::NodeId;
20use crate::state::StateRegistry;
21use appcore_contracts::ApplicationManifestV1;
22
23/// Runtime-facing application plugin contract.
24pub trait AppPlugin: Send + Sync {
25 /// Returns the application-owned V1 contract.
26 fn application_manifest(&self) -> ApplicationManifestV1;
27 /// Returns the Runtime identity bound to the supplied node.
28 fn identity(&self, node_id: NodeId) -> RuntimeIdentity;
29
30 /// Declares command names implemented by the plugin.
31 fn register_commands(&self, registry: &mut CommandRegistry) -> RuntimeResult<()>;
32 /// Declares event names emitted by the plugin.
33 fn register_events(&self, registry: &mut EventRegistry) -> RuntimeResult<()>;
34 /// Declares state names used by the plugin.
35 fn register_states(&self, registry: &mut StateRegistry) -> RuntimeResult<()>;
36 /// Registers decision names for catalog/manifest/introspection.
37 fn register_decisions(&self, registry: &mut DecisionRegistry) -> RuntimeResult<()>;
38 /// Registers executable decision nodes used at dispatch time.
39 /// `RuntimeBuilder` keeps registry aligned with engine names after this step.
40 fn register_decision_nodes(&self, _engine: &mut DecisionEngine) -> RuntimeResult<()> {
41 Ok(())
42 }
43
44 /// Registers executable command handlers.
45 fn register_handlers(&self, _bus: &mut CommandBus) -> RuntimeResult<()> {
46 Ok(())
47 }
48}
49
50#[cfg(test)]
51#[path = "plugin_tests.rs"]
52mod tests;