Expand description
rust-anything: plan, bridge, verify and ship incremental migrations to Rust.
The steps (analyze, bridge, harness, shadow, gate) are language-neutral in shape;
each source language is a plugin module. TypeScript/JavaScript (ts) is the first.
Modules§
- analyze
- Builds the migration plan: units, their dependency graph, port order and readiness.
- app
- App-level record and replay for CLIs, in any language: the program is a black box.
- bridge
- Step 2: scaffold a Rust crate for one unit, with JS bindings and a manifest the later steps read.
- codegen
- Code generation for a bridge crate: port stubs from TS signatures, and the binding layer
(
lib.rs,index.cjs) from the port’s Rust signatures. - codegen_
batch - Batch classes: a function run over many items that stay on the Rust side.
- codegen_
batch_ native - Batch classes for Ruby (magnus), Go (cgo) and Java (JNI): the same
runandrankas the TS and Python batches incodegen_batch, over items kept in Rust and run on all cores. - codegen_
c - C ABI bridge: drop-in
extern "C"replacements with the original names and signatures. - codegen_
ffi - The JSON bridge for Go, Ruby and Java: the port is plain Rust over serde types, and one
dispatcher takes a function name and its arguments as JSON and answers
{"ok": value},{"error": message}or{"panic": message}. - codegen_
go - Go: the cgo wrapper package (the original API over the Rust library), and the driver that calls a package’s functions by name for record, diff and bench.
- codegen_
java - Java: the JNI wrapper (the original classes’ static methods over the Rust library), a small JSON codec with no dependencies, and the reflection driver for record, diff and bench.
- codegen_
py - PyO3 bindings and the Python wrapper package for a bridge crate.
- codegen_
ruby - Ruby: the Fiddle wrapper (the original module functions over the Rust library), and the driver that calls them by name for record, diff and bench.
- codegen_
tswire - The binary wire for TypeScript/JavaScript: generated JS encoders write arguments into a buffer registered once with the Rust module, the Rust side reads them in place, and the result comes back the same way. No JSON text, no per-property napi calls.
- error_
paths - Error paths: where the original fails (
throw,raise, anerrorresult), whether a recorded case reaches each of them, and whether the port panics where the original failed politely. - front_
door - The front door:
rust/app, a Rust binary that owns a CLI’s entry point from day one and runs the original for every command not ported yet, andwire, which hands commands to a unit’sport.rsbehind a kill switch. - front_
door_ http - The HTTP front door: an axum server that proxies every route no unit answers to the original server, which it starts on a port of its own.
- gate
- Step 5: the definition of done for one port.
- harness
- Steps 3 and 5’s runtime half: record what the original code does, build the Rust module, and replay the recorded cases against it.
- harness_
c - The C side of record, build, diff and bench: the original is compiled into a shared library, and Python’s ctypes calls it and the Rust library with the same signatures.
- harness_
go - The Go side of record, build, diff and bench. A generated driver calls the package’s
functions by name: built against the original package to record, and against the cgo
wrapper over the Rust library to diff. Both builds are separate modules under
.rust-anything/withreplacedirectives, so nothing is written into the original repository. - harness_
java - The Java side of record, build, diff and bench. A generated driver calls the unit’s static methods by reflection: compiled with the original sources to record, and with the JNI wrapper classes over the Rust library to diff.
- harness_
py - The Python side of record, build, diff and bench: same cases, same markers, run by a Python driver instead of Node.
- harness_
ruby - The Ruby side of record, build, diff and bench. A generated driver calls the module functions by name: with the original files loaded to record, and with the Fiddle wrapper over the Rust library loaded to diff.
- http
- HTTP servers as a black box: start the original (or any build) on a port, send the recorded requests in order, and store or compare what it answers.
- lang
- Source languages. TypeScript/JavaScript lives in
crate::ts; the others are plugins that produce the same workspace, facts and exports, with types mapped into the TS-like type dialect the planner, generators and port stubs use (string,number,int,T[], …). - library
- Libraries (no
main, no server): the front door is the library’s public API as a Rust crate,rust/app, re-exporting each unit’sport.rsonce it is wired. Until the lift, the original package keeps its callers and reaches Rust through each unit’s bindings and shadow drop-in, which honors the unit’s kill switch. - lift
app lift: once the front door answers every recorded case in Rust, remove the fallback, the kill switches and the units’ bindings, and prove the pure binary on the recorded cases.- mcp
- MCP server over stdio: every step as a tool, for any agent.
- profile
profile: run a real workload under the language’s own profiler and say what to port.- report
- Renders a
Reportas a Markdown migration plan for people. - risks
- The catalog of TypeScript/JavaScript behaviors that do not carry over to Rust as-is.
- setup
setup: register rust-anything with the coding agents on this machine, in one command.- shadow
- Step 4: a drop-in module that runs the TS original and the Rust port side by side.
- tolerance
- Float tolerance: numeric code (physics, statistics, graphics) rarely gives bit-identical
floats once ported, because the order of operations, fused multiply-add and the math library
differ. With a tolerance, two results still match when every number differs by at most
tolerancetimes the larger magnitude (absolute below 1). Integers, strings and structure must still match exactly, and the same value written differently (3and3.0) is a formatting difference, not rounding, so it never passes. - ts
- The TypeScript/JavaScript language plugin: discovery, parsing and the npm crate table.
- walk
- Directory walks that read
.gitignorethe way git does: from the repository root down to the scanned folder and below it, never from folders above the repository (a*in a home-folder.gitignorewould otherwise hide every file). - whole_
app analyze --whole-app: what a whole-app port needs on top of the unit plan. The app’s entry points and shape, every external dependency (imported or declared) with its Rust crate, the port order as pieces (units that import each other move together), and the decisions to put to the user in the grilling round.- wire
- The binary wire for Go and Java: values cross as compact bytes whose encoders and decoders are generated per type on both sides, without JSON text or reflection.