github erkamyaman/rust-anything v3.0.0

26 minutes ago
  • package makes a whole Node CLI installable: pointed at a front door (rust/app), it lays out
    a main npm package whose command runs the front door binary from <name>-<platform> (macOS
    arm64 and x64, Linux x64 and arm64 with glibc, Windows x64), with the original as a dependency
    pinned to the exact recorded version for every run the port hands back. A Node launcher runs
    the binary (or the original where no binary fits, or with RUST_ANYTHING_MODE=old); outside
    Windows a postinstall script puts the binary in its place, so a covered run starts no Node.
    --bin names the commands, --original <package>@<version> the original when it is not in
    the repository's node_modules. A generated workflow builds and packs every platform.

  • Front doors find the original next to themselves when installed: inside node_modules, the
    generated original.rs resolves node_modules/... from RUST_ANYTHING_ORIGINAL_BASE (set by
    the launcher) or the nearest folder above the binary, before the repository it was built in.
    The Prettier and ESLint front doors carry the change.

  • The ESLint port on npm as eslint-rs (ESLint 10.15.0; macOS and Linux binaries, Windows runs
    ESLint itself), the Prettier port packaged the same way as prettier-rs but not published, and
    .github/workflows/ports-npm.yml, which builds both front doors on every platform, packs them
    with package, and checks the Linux install against the originals.
    Installed from their tarballs on macOS arm64: prettier-rs replays 17,224/17,224 recorded runs
    at 7.9% fallback, through the binary and through the launcher; eslint-rs replays
    10,492/10,585, the 93 others printing ESLint's own install path, as ESLint 10.15.0 run from the
    same install does (docs/packaging.md). The Prettier front door's Cargo.lock now lists
    ignore, which --locked builds needed.

  • Prettier demo: about 75 differences from Prettier 3.6.2 outside the recorded corpus, found by
    differential fuzzing, mutation testing and a Doc-level comparison, are fixed or handed to
    Prettier. 355 new cases and the checks are in demo/real-world/prettier-rs/equiv. The
    recorded corpus now runs 15,861 of 17,224 cases fully in Rust (7.9% fallback, was 15,837 and
    8.1%).

  • package (CLI and MCP tool) lays out a gated port as packages end users install, and writes
    files only: PyO3 ports become a maturin project (an abi3 wheel importable under the original's
    module name), napi ports the napi-rs per-platform npm layout (a main package with
    optionalDependencies on <name>-<platform>, a loader that falls back to the original JS where
    no binary fits), wasm ports one npm package. PyO3 and napi ports also get a GitHub Actions
    workflow building macOS (arm64, x86_64), Linux (x86_64, aarch64) and Windows. Installed from
    their packages, demo/fuzzy-napi and demo/fuzzy-rs pass 2000/2000 recorded cases and
    demo/fixtures/python-textkit-rs 1144/1144 (docs/packaging.md).

  • fuzz: a live differential test. It generates fresh inputs from a new seed (the record
    generator, skipping inputs already recorded), runs them through the original and the built
    port, and reports the mismatches the recorded cases missed. --cases N per function, --seed S
    (random by default and printed, so a run replays), --time SECS for rounds until the budget is
    spent, and --keep (--keep=all) appends the mismatching (all) fresh cases to cases.jsonl so
    the next diff and gate check them. Works wherever record and diff do on this machine:
    TS/JS, Python, C, Go, Ruby, Java and Kotlin. Also an MCP tool.

  • record --pin-clock (TS/JS with the napi bridge, Python): units that read the clock or random
    numbers can be recorded. While pinned (pinned.json, until --no-pin-clock), record, diff,
    fuzz and gate run with RUST_ANYTHING_NOW_MS, RUST_ANYTHING_SEED and TZ=UTC; Date.now(),
    new Date(), Date() and Math.random (time.time, datetime.now, date.today and the
    random module) return that instant and a mulberry32 sequence restarted at every case. The port
    reads the same values from src/port/pinned.rs (now_ms(), random(), getrandbits(),
    randbelow()), written by the first --pin-clock. Recordings without the flag are unchanged.

  • analyze: reads of the clock and random numbers (Date.now(), new Date(), Math.random,
    performance.now(); time.time, datetime.now, random.*, uuid4) are a new low-severity
    risk, "Clock and random numbers", whose advice points to record --pin-clock.

  • C bridge: structs of scalar fields cross by value, as parameters and returns (ffmpeg's
    AVRational av_mul_q(AVRational b, AVRational c)). The struct is read from the project's
    headers (typedef struct ... Name; or struct tag), is a #[repr(C)] struct at the crate root
    (crate::AVRational), and is an object of its fields in cases and recorded results. Structs
    with a pointer, array, bit-field or nested struct field stay in C.

  • C bridge: a char ** / const char ** out-parameter that the function points into a string
    argument (av_strstart(str, pfx, &ptr), strtol's endptr) is recorded as the offset into
    the first char string or buffer parameter, and is Option<&mut Option<usize>> in the port.
    In cases, give its starting offset, true for a NULL start, or null for a NULL pointer.
    A ** the function advances as its own string (av_get_token(const char **buf, ...)) still
    stays in C, as does anything returning memory it allocates.

  • record (C): generated cases give struct parameters objects of their fields (zeros, ones,
    minus ones, each field's minimum and maximum, each field zero with the others one, and small
    random values) instead of values that were recorded as TypeErrors, and char **
    parameters true, null or offset 0.

  • diff (C): a case where the original returned or wrote a pointer outside its arguments (read
    past a string, say) is undefined behavior like a crash, and any answer of the port passes it.

  • Case study: the ffmpeg ports add av_mul_q, av_div_q, av_add_q, av_sub_q, av_d2q,
    av_nearer_q, av_q2intfloat, av_rescale_q, av_rescale_q_rnd, av_strstart and
    av_stristart; 226,447/226,447 recorded calls, gate passes on all 10 crates.

  • diff (C): a case the original recorded as an error (an argument ctypes could not convert)
    passes when the port gives the same error, instead of always failing.

  • Contributors: mise.toml pins the toolchains CI uses, and hk.pkl runs the secrets check,
    cargo fmt and cargo clippy before each commit (suggested by u/touristtam on Reddit).

  • setup --no-backup: changes settings files in place without saving a
    <file>.rust-anything.bak copy first.

  • record/diff (TS/JS): plain data shaped like a marker ({"$date": ...}, Mongo extended JSON)
    is kept as data instead of being read as a Date, undefined or bigint, and a marker key next to
    other keys is ordinary data. Write such an object in --inputs as {"$object": {...}} (#121).

  • record/diff (TS/JS): typed arrays other than Uint8Array (Float64Array, Int32Array,
    Uint8ClampedArray, ...) are recorded with their kind, so a port returning the wrong one
    fails (#122).

  • app replay: lines compared in any order are paired by value within --float-tolerance, not
    by sorted position (#123, #125 by @sameermankotia).

  • analyze (C): a unit depends on what its own header includes, so a.c that reaches b()
    through a.h waits for b.c (#126).

  • README: right under the tagline, it now says the tool doesn't translate code (your agent or you
    write the Rust) and what PHP and C# support today. From a new-user QA review of the README by
    Mashhood Ali, an independent AI evaluation and QA specialist
    who tests products and docs the way a new user would (LinkedIn) (#118).

  • app record --fresh works for CLIs: every case starts from a snapshot of the given files or
    folders (kept in app-cases/files/; a path ending in / gives its contents, so a whole project
    can be the working directory), written files are what differs from it, and files a case
    removes are recorded in <case>.removed and compared on replay. An --inputs case can also
    "remove" files of the snapshot before it runs. --fresh alone no longer implies --http.

  • Front doors built by rust-anything find the original when rust/ is a symlink to a folder
    outside the repository (RUST_ANYTHING_REPO is set at build time).

  • Case study: ESLint 10.15.0 behind a Rust front door, 90 rules (eslint:recommended and 26
    more), 10,585/10,585 recorded CLI runs at 3.6% fallback, gate passes on eslint-stdin-rs
    (demo/real-world/eslint-rs, docs/real-world.md#eslint).

  • bridge and analyze read CommonJS exports: module.exports = { a, b: c },
    module.exports.a = a and exports.a = a, for functions declared in the file. ESLint (and
    most Node code before ESM) exports this way, so its units showed no functions to bridge.

  • The timestamps normalizer also matches JavaScript's Date#toString()
    (Sat Nov 21 2026 01:30:12 GMT+0300 (...)). ESLint's HTML report stamps its time that way:
    the two recording runs differed only in the seconds, so only the seconds became a wildcard and a
    replay ten minutes later failed.

  • Case study: ffmpeg's libavutil (n7.1), 10 units, 135,773/135,773 recorded calls, gate passes
    on each (demo/real-world/ffmpeg-rs, docs/real-world.md#ffmpeg).

  • C bridge: pointer parameters cross it with the original signatures. A const byte pointer
    followed by an integer is a buffer of that length (&[u8] in the port); a byte pointer the
    function writes, paired with the next integer or one named like a size, is &mut [u8] and its
    contents after the call are recorded; a mutable pointer to one scalar is Option<&mut T> and
    its value after the call is recorded; a returned pointer into a parameter is the offset into
    it (Option<usize>). In cases, buffers are hex text (or a size, for that many zero bytes) and
    length parameters are left out. Typedefs of scalars and enums resolve through the project's
    headers. Found porting ffmpeg's libavutil, whose APIs all take pointers.

  • C bridge: a port can take a const char * as Option<crate::CChars<'_>> instead of
    Option<&[u8]>: the bytes are read as the port goes, without the strlen the slice needs
    first. Change the parameter's type in port.rs and run refresh; lib.rs defines CChars
    (an iterator over the bytes, with peek and to_bytes) only when a port uses it. On short
    words the two strlen calls cost more than ffmpeg's whole av_strcasecmp; with CChars the
    port went from 0.23x to 0.68x of C's speed, av_stristr from 0.44x to 1.4x.

  • record and bench for C: a folder holding a header named like a C standard one (ffmpeg's
    libavutil/time.h) is passed with -iquote, so <time.h> stays the system's; flags in
    CFLAGS are added (-DHAVE_AV_CONFIG_H, -I<tree>).

  • build, diff, bench, shadow, gate, refresh and record take the crate path as
    given and make it absolute: rust-anything build . on a C crate failed, since the compiler and
    cargo run in a scratch folder.

  • analyze for C: files under a CPU-architecture folder (x86/, aarch64/, arm/, ...) stay
    in C; goto no longer marks a unit blocked as dynamic code; #include "libavutil/x.h"
    resolves when the folder analyzed is libavutil itself, so its tests/*.c count as tests; a
    unit with no bridgeable export gets a note about the C bridge instead of the JS one.

  • gate for C: the size check counts the project functions the ported functions call, since the
    port does their work too.

  • C char parameters are c_char in generated code (signed or unsigned as the platform's C
    char), not c_schar.

  • doctor on Windows: a missing cargo gets the C++ Build Tools, then
    winget install Rustlang.Rustup, instead of the sh.rustup.rs script, which needs a Unix shell.
    The Build Tools come first because winget runs rustup-init -y, which skips them with a warning.
    The Build Tools fix also adds the C++ workload (and the ARM64 tools on Windows on ARM): without
    --add, winget installs them with no compiler, linker or Windows SDK. Since winget adds nothing
    to Build Tools already installed, the fix also says how to add the workload by hand. A fix of
    several commands prints one per line.

  • analyze --whole-app lists a library once when the code imports it under one name and the
    manifest declares it under another (yaml and PyYAML, androidx.room and
    androidx.room:room-runtime, active_support and activesupport): names the crate table
    resolves to the same row are one dependency. The JSON keeps name (the manifest's spelling
    when declared) and adds names, every spelling; declared is true if any of them is, and
    used_by counts each unit once. The Markdown plan shows the other spellings next to the name.
    Names the table does not know stay separate.

  • analyze --whole-app reads declared dependencies from each language plugin's own manifest
    parser instead of a second copy, so analyze and --whole-app agree, and every manifest in
    the workspace counts, not only the root's (a dependency on another package of the workspace is
    not an external one). The plugin parsers gained what only the copy had: Gradle and Maven
    comments are skipped, a Gradle declaration on the same line as dependencies { is read,
    requirements files follow -r includes and skip VCS, URL and path lines, Poetry dependencies
    count, a gem inside a group block is a development dependency, and add_dependency is read
    on any receiver. TS/JS counts peerDependencies and optionalDependencies as declared too.

Don't miss a new rust-anything release

NewReleases is sending notifications on new releases.