WeaveFFI Roadmap (Rust core)
This roadmap tracks high-level goals for the first five releases, with a detailed step-by-step plan to reach 0.1.0. The project uses a Rust core that exposes an FFI-friendly, stable C ABI used by language-specific bindings.
Release goals
- 0.1.0 — MVP foundation: Rust workspace, IDL/IR v0, stable C ABI, basic type coverage, error and memory model, code generators for C header, Swift (SwiftPM System Library), Android (JNI skeleton), Node.js (TypeScript + ffi-napi), minimal Web/WASM target, CLI, samples, and docs.
- 0.2.0 — Type system + packaging: Structs/enums/options, arrays/slices, richer string/byte handling, first-class async surface (callbacks → futures), packaging improvements (SwiftPM/Gradle/npm templates), better cross-compilation UX.
- 0.3.0 — Annotated Rust input: Support reading an annotated Rust crate as input (derive/proc-macro), advanced async/concurrency (streams), improved diagnostics, and template customization hooks.
- 0.4.0 — Safety + performance: Zero-copy where safe, arena/pool patterns, lifetime-safe handles, incremental codegen, template plugins, caching, and DX polish across all targets. (High-level goals; detailed plan TBD.)
- 0.5.0 — Ecosystem expansion: Additional languages (e.g., Python, .NET), distribution story (prebuilt artifacts), stability hardening, and release automation. (High-level goals; detailed plan TBD.)
0.1.0 detailed plan (MVP)
Focus: Deliver a usable MVP that accepts a simple IDL/IR, generates a stable C ABI plus minimal bindings/templates for Swift, Android, Node.js, and Web/WASM, and ships a CLI with a working sample.
1) Workspace scaffolding
- Create a Rust workspace with crates:
weaveffi-ir: in-memory IR + (de)serialization viaserde(YAML/TOML/JSON)weaveffi-core: core logic (validation, codegen orchestration, templates)weaveffi-gen-c: C header generator (and helper C stubs if needed)weaveffi-gen-swift: SwiftPM System Library template + thin Swift wrapperweaveffi-gen-android: JNI glue + Gradle module template (Kotlin)weaveffi-gen-node: TypeScript template usingffi-napito load the .dylib/.soweaveffi-cli: end-user CLI (weaveffi) invoking core/generatorssamples/calculator: tiny Rust lib compiled to C ABI for end-to-end testing
2) IR/IDL v0 (input model)
- Define a minimal but practical schema to describe:
- Functions (name, doc, params, return, async=false for 0.1.0)
- Types: primitives (i32, u32, i64, f64, bool),
string(UTF-8),bytes, andhandle(opaque resource IDs); no nested structs for 0.1.0 - Errors: named error domain with numeric codes + messages
- Implement parsers via
serdefor YAML and/or TOML; emit helpful diagnostics. - Validate IR (name collisions, reserved keywords, unsupported shapes, etc.).
3) ABI, memory, and error model
- Establish a stable C ABI surface convention (prefix, naming, versioning):
weaveffi_<module>_<function>(... , weaveffi_error* out_err)style- All strings returned are UTF-8, owned by the Rust core; provide
weaveffi_free_string(const char*)andweaveffi_free_bytes(uint8_t*, size_t) - Opaque
handlerepresented asuint64_t(oruintptr_t) from user perspective
- Error model:
- A compact
weaveffi_errorstruct with{ code: int32_t, const char* message } - Map Rust
Result<T, E>to C: fillout_err->code != 0on error - Provide
weaveffi_error_clear(weaveffi_error*)to release message buffers
- A compact
4) Code generators (templates)
- C generator (
weaveffi-gen-c):- Emit a single
.hwith function prototypes, error types, free functions - Optionally emit a tiny
.cconvenience layer if helpful for some targets
- Emit a single
- Swift generator (
weaveffi-gen-swift):- SwiftPM System Library template with
module.modulemapreferencing the header - Thin Swift wrapper translating to ergonomic Swift types and throwing errors
- SwiftPM System Library template with
- Android generator (
weaveffi-gen-android):- Kotlin (or Java) JNI wrapper class + Gradle
android-librarytemplate - C JNI shims that forward to the C ABI; sample
CMakeLists.txt
- Kotlin (or Java) JNI wrapper class + Gradle
- Node generator (
weaveffi-gen-node):- TypeScript wrapper using
ffi-napito load the C ABI shared library at runtime - Generate
.d.tstypes from the IR; include basic build scripts
- TypeScript wrapper using
- Web/WASM minimal (
weaveffi-core):- Documented
wasm32-unknown-unknownbuild with a thin JS glue stub; full ergonomics can wait for 0.2.x/0.3.x
- Documented
5) CLI
weaveffi new <name>: create a starter layout (IDL + example module)weaveffi generate: read IDL → validate IR → emit C header + platform templatesweaveffi doctor: check for toolchain prerequisites (Rust, Xcode, Android NDK, Node toolchain), reporting actionable guidance
6) Sample: calculator
- Rust
samples/calculatorcrate exporting a few functions via the C ABI:add(i32, i32) -> i32,mul(i32, i32) -> i32,echo(string) -> string- One fallible function returning an error code/message
- Include ready-to-run generated outputs for each target in a
examples/folder.
7) Tooling and CI
- GitHub Actions workflow: build
weaveffi-clifor macOS and Linux; run unit tests - Basic integration test: generate bindings from the calculator IDL and compile the produced templates (at least header + Node wrapper) in CI
8) Documentation
READMEquickstart and link to this roadmap- Docs pages for: IDL schema, memory & error model, per-platform setup/run steps
- End-to-end tutorial using the calculator sample
9) Release and versioning
- Tag
v0.1.0; attach CLI binaries for macOS (arm64/x86_64) and Linux (x86_64) - Publish npm template (if applicable) as a starter, and provide SwiftPM/Gradle template repos or archives
10) Acceptance checklist
- CLI can read a calculator IDL, generate artifacts, and the artifacts compile
- C header compiles; Node wrapper can call into the shared library successfully
- SwiftPM System Library builds and links on macOS/iOS simulator locally
- Android template builds an
.aarwith JNI stubs (smoke test) - Docs explain memory management and error handling clearly