Create Code Generation Plugin System
Updated 2026-08-30 for accuracy. core now has a minimal built-in
generator, not a todo!() stub: core/src/codelib_gen/{mod.rs,rust.rs} —
find_generator("rust", _) returns a synchronous fn(&Vec<FrozenUnit>) -> String that emits structs / enums / traits. There is still no dynamic
loading, ABI, plugin discovery or version negotiation — that substance is what
remains here.
The earlier, more complete design lives in ComlineProject/generation
(code_gen = source-text emission; lib_gen = a buildable crate skeleton;
rust_c_ffi + rust_abi_stable flavors). It is unmigrated — it imports the
removed comline_core::…::basic_storage. Reviving it is part of this issue.
Consumer-facing hook: the code-generation output-config doc specs a
comline.toml [generate] mode = "code" | "lib" | "dylib" that sits on top
of this issue — code = the built-in generator, lib / dylib = lib_gen.
Priority
P1 (High) - Enables language-specific code generation
Labels
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
core/src/codelib_gen/mod.rs — find_generator(name, version), hardcoded
match name { "rust" => … }, returns (fn(&Vec<FrozenUnit>) -> String, ext).
core/src/codelib_gen/rust.rs — generate_rust: structs, enums, trait for
protocols. Synchronous, in-process, no versioning.
ComlineProject/generation — code_gen / lib_gen / rust_c_ffi /
rust_abi_stable scaffolding, pre-CAS, does not build against current core.
- No dynamic loading, no ABI boundary, no discovery, no
supports_version.
Technical Challenge
Rust doesn't have a stable ABI by default. Possible solutions:
- Use C ABI wrapper (traditional approach)
- Use
abi_stable crate (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
Tasks
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
Blocks
None
Create Code Generation Plugin System
Priority
P1 (High) - Enables language-specific code generation
Labels
corecodegenpluginsP1Description
Build the plugin architecture for code generators. This allows language-specific generators to be developed as separate libraries and loaded dynamically.
Requirements:
Current State
core/src/codelib_gen/mod.rs—find_generator(name, version), hardcodedmatch name { "rust" => … }, returns(fn(&Vec<FrozenUnit>) -> String, ext).core/src/codelib_gen/rust.rs—generate_rust: structs, enums,traitforprotocols. Synchronous, in-process, no versioning.
ComlineProject/generation—code_gen/lib_gen/rust_c_ffi/rust_abi_stablescaffolding, pre-CAS, does not build against currentcore.supports_version.Technical Challenge
Rust doesn't have a stable ABI by default. Possible solutions:
abi_stablecrate (Rust-to-Rust stable ABI)Need to research and decide on approach.
Acceptance Criteria
~/.comline/plugins/,./plugins/)Tasks
libloadingor similar)ComlineProject/generationgenerators againstcurrent
core(code_gentext +lib_gencrate/dylib).codelib_gen::rust):imports asuse(currently dropped)Plugin Interface (Draft)
Dependencies
Blocks
None