Epic: CPEX Rust Core (#12)
Summary
Create cpex-python crate providing PyO3 bindings so Python code can call the Rust PluginManager. This is the "Python → Rust" direction — Python hosts (like ContextForge gateway) use the Rust core for execution.
Motivation
The ContextForge gateway is written in Python. PyO3 bindings let it use the Rust PluginManager as a drop-in replacement, getting compile-time invariant enforcement and the typed hook system while keeping the existing Python integration code.
Scope
#[pymodule] exposing PyPluginManager
PyPluginManager — wraps cpex_core::PluginManager with Python-callable methods
invoke_hook(hook_name, payload, context, extensions) — Python calls, Rust executes
- PyO3-wrapped Rust types for payloads and extensions — Python accesses attributes, Rust controls access
- Maturin build configuration (
pyproject.toml → cpex._native module)
- Type stubs (
_native.pyi) for IDE support
cpex/__init__.py import switch — Rust backend if available, Python fallback otherwise
Acceptance Criteria
from cpex import PluginManager loads the Rust-backed manager when compiled
manager.invoke_hook() dispatches through the Rust 5-phase executor
- Python plugins receive PyO3-wrapped payloads with typed attributes
- Existing
PluginConfig YAML format works without changes
- Falls back to pure Python implementation if Rust module not compiled
Epic: CPEX Rust Core (#12)
Summary
Create
cpex-pythoncrate providing PyO3 bindings so Python code can call the Rust PluginManager. This is the "Python → Rust" direction — Python hosts (like ContextForge gateway) use the Rust core for execution.Motivation
The ContextForge gateway is written in Python. PyO3 bindings let it use the Rust PluginManager as a drop-in replacement, getting compile-time invariant enforcement and the typed hook system while keeping the existing Python integration code.
Scope
#[pymodule]exposingPyPluginManagerPyPluginManager— wrapscpex_core::PluginManagerwith Python-callable methodsinvoke_hook(hook_name, payload, context, extensions)— Python calls, Rust executespyproject.toml→cpex._nativemodule)_native.pyi) for IDE supportcpex/__init__.pyimport switch — Rust backend if available, Python fallback otherwiseAcceptance Criteria
from cpex import PluginManagerloads the Rust-backed manager when compiledmanager.invoke_hook()dispatches through the Rust 5-phase executorPluginConfigYAML format works without changes