Mutation test of the rust-anything gate
=======================================

What this is
------------
rust-anything (github.com/erkamyaman/rust-anything, MIT OR Apache-2.0) records what
an original program does and refuses a Rust port unless every recorded case matches.
Its repository includes a Rust port of vercel/ms (demo/real-world/vercel-ms-rs).
This kit plants one small defect at a time in that port, runs `rust-anything gate`,
and records which check refuses it. A separate script compares each surviving
mutant with the original on 56,986 calls to see whether it really behaves differently.

No language model is called. The port and the original are not copied here; the
steps below fetch them.

Files
-----
  Dockerfile                    Rust, Node 22 and rust-anything from crates.io
  harness/mutate.py             generates the mutants, runs the gate, writes a results file
  harness/differential.mjs      independent comparison of the original and the built port
  harness/demo.sh               the two-edit demonstration quoted in the article
  all-inputs.jsonl              the crate's inputs.jsonl and test-inputs.jsonl joined, one duplicate removed
  known-diffs.jsonl             the 12 cases where the published port already differs (see below)
  results-generated-and-inputs.json   run 1: recording from generated cases and inputs.jsonl (788 cases)
  results-with-tests.json       run 2: recording that also has the original's test inputs (1,127 cases)
  results-held-out-2000.json    run 3: the 17 survivors of run 2 with --held-out-cases 2000
  results-summary.md, results-chart.svg, build_summary.py
  transcripts/                  terminal output: record, diff of the published port, gate baseline, selftest, demo
  environment.txt

Run it
------
  docker build -t ra-test .
  mkdir work && cd work
  git clone https://github.com/vercel/ms && git -C ms checkout 4ff48ce
  git clone https://github.com/erkamyaman/rust-anything ra && git -C ra checkout 1cc3cd4
  mkdir -p ms/rust && cp -R ra/demo/real-world/vercel-ms-rs ms/rust/index-rs
  # in ms/rust/index-rs/rust-anything.json set "root" to "/work/ms"
  cp -R ../harness . && cp ms/rust/index-rs/src/port.rs harness/port.orig.rs
  cp ../all-inputs.jsonl . && cp ../known-diffs.jsonl ms/rust/index-rs/
  run() { docker run --rm -v "$PWD":/work -v ra-cargo:/usr/local/cargo/registry -w /work/ms "$@"; }
  run ra-test rust-anything record rust/index-rs --inputs /work/all-inputs.jsonl
  run ra-test rust-anything gate rust/index-rs --accept-known-diffs 12      # must pass before mutating
  run -e KNOWN=12 -e OUT=/work/results-with-tests.json ra-test python3 /work/harness/mutate.py

The container needs the network for crates.io. It mounts only the work folder.
A full run of 100 mutants took about 15 minutes on an Apple M1.

The 12 accepted differences
---------------------------
With rust-anything 5.1.0 the published port does not pass its own gate: for 12
recorded calls with an argument of the wrong type (a string or null passed to
format, a number or null passed to parse) the original throws Error and the port
throws TypeError from the bridge's type conversion. We listed them in
known-diffs.jsonl, the tool's documented way to accept a difference, so that the
mutation test starts from a passing gate.

Limits
------
One port of one small library, both chosen by the tool's author. Mutants are single
textual edits from thirteen operators. "No behaviour difference found" means none in
the 56,986 calls we tried, not a proof of equivalence. The held-out check draws new
inputs on every run, so its results vary; we report three runs per survivor. The
agent workflow (`rust-anything go`, where a coding agent writes the port) was not run.
