Skip to content

Rewrite your app in Rust, piece by piece, checked against the original at every step. Works with TypeScript, JavaScript, Python, Go, Ruby, Java, C, PHP, C#, Kotlin, PowerShell and Swift.

docs: Diff row names all eight languages for post-call comparison (#1474)

Attilac1ad41ede446
diff --git a/docs/how-it-works.md b/docs/how-it-works.md
index b5b5de89..bbe4bb31 100644
--- a/docs/how-it-works.md
+++ b/docs/how-it-works.md
@@ -35,7 +35,7 @@ analyze --whole-app ──> app record ──> app front-door ──> per unit:
| 2. Bridge | `rust-anything bridge <repo> <unit>` | Crate with the bindings (`lib.rs`, plus the wrapper the source language loads) and stubs to port (`port.rs`); `--batch fn:param` adds a class that keeps many `param` values in Rust; `--as-json T` bridges a type parameter the app only fills with data as JSON values |
| 3. Record | `rust-anything record <crate>` | Runs the original on generated edge cases (non-ASCII, emoji, `-0`, `NaN`, ints where floats are expected, ...) and on every semantic trap in every parameter (string length and case, signed division, overflow edges, float printing, map and sort order), and saves `cases.jsonl`; a string argument of an `--inputs` case that holds JSON, or base64 or base64url JSON, also gets cases with each inner value changed and encoded back the same way (dates in the shapes JS, Python and others parse, numbers, strings); `--from-tests -- npx jest` (or `-- pytest`) also records every call the original's own test suite makes; `--float-tolerance 1e-9` lets floats match within that share for numeric code; `--pin-clock` (TS/JS with napi, Python) sets `TZ=UTC` for the original and the port and fixes the clock and random numbers during record and diff (`Date.now()`, `new Date()`, `Math.random` in JS; `time.time()`, `time.time_ns()`, `datetime.now()`/`today()`, `datetime.utcnow()`, `date.today()` and `random` in Python), and `src/port/pinned.rs` gives the port the same ones (`pinned::now_ms()`, `pinned::now_secs()`, `pinned::random()` for `random.random()`, and `pinned::randbelow()`/`getrandbits()` for `randint`, `randrange`, `choice` and `shuffle`). For TS/JS, Python, Ruby, Go, Java, Kotlin, PHP and C# functions it also keeps what each call did besides returning: the arguments after it (`args_after`, only when they changed) and what it wrote to standard output (`stdout`), marked `"post": true` ([What a call is compared on](#what-a-call-is-compared-on)) |
| 3. Build | `rust-anything build <crate>` | Builds the Rust side: `.node`, wasm package, Python extension or shared library |
-| 3. Diff | `rust-anything diff <crate>` | Replays the recorded cases against Rust, called the way the original's callers call it; lists mismatches, each with where it first differs (`return`, `throw` or `call N`, the JSON path such as `$.items[2].name`, the kind of difference, and for text the character with a little context), and the distinct differences with how many cases each covers under a short stable id, so 40 failing cases from one bug read as one line; a thrown error matches on its class, and on its message too for a unit recorded with `record --messages`; for a TS/JS or Python function it also compares the arguments after the call and what it printed (the difference is located at `arguments after the call` or `stdout`); `--redact` prints all of it as shapes only (types, lengths and unsalted FNV-64 hashes, no values or arguments). That is not anonymisation: a hash of a short or guessable value (a small list, an id, a password) can be found by trying candidates, so read it before pasting it anywhere public |
+| 3. Diff | `rust-anything diff <crate>` | Replays the recorded cases against Rust, called the way the original's callers call it; lists mismatches, each with where it first differs (`return`, `throw` or `call N`, the JSON path such as `$.items[2].name`, the kind of difference, and for text the character with a little context), and the distinct differences with how many cases each covers under a short stable id, so 40 failing cases from one bug read as one line; a thrown error matches on its class, and on its message too for a unit recorded with `record --messages`; for TS/JS, Python, Ruby, Go, Java, Kotlin, PHP and C# functions it also compares the arguments after the call and what it printed (the difference is located at `arguments after the call` or `stdout`); `--redact` prints all of it as shapes only (types, lengths and unsalted FNV-64 hashes, no values or arguments). That is not anonymisation: a hash of a short or guessable value (a small list, an id, a password) can be found by trying candidates, so read it before pasting it anywhere public |
| 3. Fuzz | `rust-anything fuzz <crate>` | Fresh inputs from a new seed (`--seed`, `--cases`, `--time`) through the original and Rust, including recorded JSON and base64 JSON string arguments with random inner values; reports what the recording missed, and `--keep` adds those cases to it; `--generator <command>` takes each round's inputs from your own program instead ([Fuzz with your own inputs](#fuzz-with-your-own-inputs)) |
| 3. Bench | `rust-anything bench <crate>` | Times the recorded cases on the original and on Rust, bridge included |
| 4. Shadow | `rust-anything shadow <crate>` | Drop-in that runs both, returns the original's result, reports mismatches; `RUST_ANYTHING_MODE=old\|shadow\|new`. Not for PHP, C#, PowerShell and Swift: `shadow` refuses them and says what to do instead |