-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
P1Priority 1 - HighPriority 1 - HighcodegenCode generationCode generationcoreCore system componentCore system componentpluginsPlugin systemPlugin system
Milestone
Description
Create Code Generation Plugin System
Priority
P1 (High) - Enables language-specific code generation
Labels
corecodegenpluginsP1
Estimated Effort
3-4 weeks
Description
Build the plugin architecture for code generators. This allows language-specific generators to be developed as separate libraries and loaded dynamically.
Requirements:
- Stable Rust ABI interface (challenging!)
- Dynamic library loading
- Plugin discovery
- Version compatibility checking
Current State
Location: core/src/codelib_gen.rs
Only interface defined (24 lines), no implementation. Single todo!() for the loader.
TODO References
codelib_gen.rs:21- "Rust ABI Stable code needs to be done, traits and so on and load here"
Technical Challenge
Rust doesn't have a stable ABI by default. Possible solutions:
- Use C ABI wrapper (traditional approach)
- Use
abi_stablecrate (Rust-to-Rust stable ABI) - Use process-based plugins (spawn external process)
- WebAssembly plugins (WASM runtime)
Need to research and decide on approach.
Acceptance Criteria
- Plugin API defined with stable ABI
- Dynamic library loading works cross-platform
- Plugin discovery from standard paths (
~/.comline/plugins/,./plugins/) - Version compatibility enforcement
- At least 2 reference generators implemented:
- Rust generator (structs, enums, traits)
- TypeScript generator (interfaces, types)
- Plugin development guide written
- Example third-party plugin works
Tasks
- Research stable ABI solutions (compare approaches)
- Design plugin interface (trait definitions)
- Implement dynamic library loading (using
libloadingor similar) - Create plugin registry/discovery system
- Add version checking and compatibility validation
- Build reference Rust generator:
- Generate Rust structs from schema structs
- Generate Rust enums from schema enums
- Generate trait definitions from protocols
- Build reference TypeScript generator:
- Generate TS interfaces
- Generate type definitions
- Generate RPC client stubs
- Write plugin development guide
- Add plugin testing infrastructure
- Document plugin system architecture
Plugin Interface (Draft)
pub trait Generator {
fn name(&self) -> &str;
fn version(&self) -> &str;
fn supports_version(&self, ir_version: &str) -> bool;
fn generate(&self, frozen_units: &[FrozenUnit]) -> Result<String>;
}Dependencies
- Consolidate and Complete IDL Parser #3 IR Compilation (needs complete FrozenUnits)
Blocks
None
Metadata
Metadata
Assignees
Labels
P1Priority 1 - HighPriority 1 - HighcodegenCode generationCode generationcoreCore system componentCore system componentpluginsPlugin systemPlugin system
Type
Projects
Status
Todo