Expand description
In-process native plugin mechanism common crate for evorule-services.
This crate defines the NativeService trait, the NativeServiceDef
declaration entry, and the generic filter router shared by all plugin
families. Each family keeps its own declaration table; the host mounts
the router with a per-family enable set.
§Components
NativeService: the uniform in-process service entry point.NativeServiceDef: declarative registration entry (name, sensitivity flag, one-line description, optional JSON Schema parameter contract, instance constructor).NativeServiceRouter: compositeIoHandlerthat dispatches byservice_nameto a native service and falls back to HTTP otherwise.mount_router: mount helper producing anArc<dyn IoHandler>.
§Enable semantics
NativeServiceRouter::with_enabled and mount_router enforce three
fail-fast rejections: unknown name, duplicate name, empty enable set.
Router lookup always follows declaration order, regardless of the order
of the enable set passed in.
§Async extension point
NativeService::execute_async is an async extension point whose default
implementation wraps the synchronous execute in an immediately-ready
future, so non-overriding services keep byte-for-byte identical behavior.
The router always awaits execute_async, which makes overriding fully
transparent to callers.
Services that need external I/O (HTTP egress, long polling, and similar)
MUST override this method; they must not perform egress from the
synchronous execute (no runtime support on that path). Any degraded
result (e.g. a local stub while the external service is unavailable)
must be truthfully labeled in the returned body; a stub must never
impersonate the real service.
§Usage (plugin side)
- Export a
&'static [NativeServiceDef]declaration table: adding a native capability = append one entry + enable it in the plugin manifest; the host and the mechanism need zero changes. - Services with a fixed parameter surface declare
parametersas a JSON Schema string (OpenAI function parameters subset); it is forwarded to LLM consumers via the capability inventory. - Wrap the table with
mount_router(or useNativeServiceRouterdirectly) to obtain the mountable handler.
Modules§
- executor
- 元指令执行器 - 5 个元指令 +
io_request信号 +enforce强制原语
Structs§
- Native
Service Def - Native service declaration entry (declarative registration: adding a native capability = appending one entry to the plugin declaration table; the router, the capability inventory, and binding checks need zero changes).
- Native
Service Router - Composite IoHandler: a
service_namehit on a native service name dispatches natively; otherwise falls back to HTTP.
Enums§
- Json
Value - JSON 值类型(确定性实现)
Traits§
- IoHandler
- I/O Handler trait —— 所有 I/O handler 实现此接口
- Native
Service - Uniform entry point for native services: receives
args(with__paths already resolved to concrete values by the engine) and returns the business result.
Functions§
- mount_
router - Mount helper: builds an
Arc<dyn IoHandler>with enable semantics (referenced directly by the server-sidePluginDef, avoiding per-family wrapper constructors).