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.
Pitfalls
Mistakes already made in this repository, each with the rule that prevents it. Add one in the same change whenever a mistake is worth not repeating.
Generated code and bridges
A helper in port.rs became part of the bridged API. Making parse_options pub exported it
through the bridge. Keep helpers private; only the unit's exports are pub.
Wiring every napi function broke crates without serde_json. required_deps must add each
crate the generated code uses. After changing codegen, bridge a unit with no JSON parameters and
build it.
Generated helpers unused by a crate failed clippy. Emit each helper only when the crate needs
it (as JOINED_IN_RS and JOINED_OUT_RS are), and run gate on a crate that uses none.
Number formatting picked the wrong digit on ties. A hand-written shortest-digits routine gave
...813 where V8 gives ...812. Take digits from serde_json (zmij), which rounds to the closest
value as V8 does, and test ties.
Two front doors overwrote each other's binary. With CARGO_TARGET_DIR set, every app built
into the same target/, so replays ran another app's binary. The front door now builds into its
own rust/app/target; run cargo test with the variable set after touching the build.
Glue could not hand a single case back. A wired unit that covers only part of the input (a
formatter with unported syntax) had no way to decline after reading stdin. Glue calls
crate::original::run_with_stdin(args, input) to pass the case and the bytes it already read;
lift refuses to finish while any glue still contains original::.
Deep JSON stopped recording at 128 levels. serde_json's recursion limit rejected Prettier's
doc trees. Case and input lines are read with unbounded_depth and the limit disabled, in the
harness and in generated from_json; a test reads a 200-deep line.
analyze suggested a unit bridge refused. It judged exports with its own copy of
bridge's rules, which lacked the sibling .d.ts, alias resolution and the class-method check,
so a unit bridge keeps in JS went into start_here. Both now call bridge::ts_functions and
bridge::class_reason; a new rule for what crosses the bridge goes there, not into one command.
profile and go made the same mistake per function (a hot callback-taking export was "port
it"); they call bridge::ts_functions and bridge::js_only_reason too.
bridge refused a Java unit over an overload it keeps in Java. The duplicate-name check
listed every kept overload, so pad(String) and pad(String, int) were "defined twice".
The overloads of one name in one file are now one kept entry, also under --keep; other
kept functions that share a name still clash. tests/overloads.rs covers Java, Kotlin, C# and
Ruby.
A port that matched the recorded cases passed gate without being the function. diff and
gate replayed only cases.jsonl, so a port that approximated or memorised the recording passed
(the audit's remaining structural weakness). gate now also runs held-out inputs: fresh ones
from a clock seed and recorded arguments with one change. Keep that check in the verdict when
changing gate, and never make it quiet: off (--held-out-cases 0), skipped (a language's ports
that fuzz has not been run end to end against) and "nothing new to try" are printed as such, and inputs that were
generated but not one recorded fail. A zero-case diff reads as a pass. The check puts its cases
into cases.jsonl and puts the recording back, so fuzz and held-out take a per-crate lock
(.rust-anything/recording.lock). record, diff, bench, gate, report, enable and go
take it too, so one of them started while a gate is in its held-out step waits for the recording
to be put back instead of reading the step's cases. go lets go of it while its agent runs, since
the agent runs diff and gate itself. The port's run is stopped after twelve case timeouts
(two minutes by default), so a port that loops on an unseen input fails the check. A test that
needs the draw to reach one region (a planted port that differs only where all three arguments are
above 1) pins --held-out-seed: a seed from the clock missed that region in 32 of 20,000 draws.
A timed fuzz run that has one round record nothing keeps what earlier rounds found, and fails
only if no round compared anything.
The held-out check draws only calls the signature allows (conforms against the declared
TypeScript types): the first demo fixture to run it, demo/fixtures/async-rs, matched its legacy
recording only because that recording compares errors loosely, and failed 13 of 216 fresh inputs on
a non-array for entries: readonly Entry[]. A new input source is tried on every demo fixture
(rust-anything gate demo/fixtures/*-rs) before it is pushed.
profile advised porting a function that was waiting. A loop of execSync("sleep 0.2")
took 41% of a run and was "port it", and go picked it when it was the hottest; the same loop in
Rust still waits for every process. profile now counts the time under Node's blocking
child_process calls and Python's subprocess and os.system as waiting, lists it with the
command and the call, and go passes over a function that mostly waits (and stops when waiting
is most of the run). An asynchronous spawn or exec waits while the thread is idle, so it
makes nothing look hot and is not listed.
bridge scaffolded a function as pure that read app state through another. Each export was
judged by its own signature, so instance() stayed in Java for returning Config while
getContinuationQuery, which calls it, was bridged with a clean String -> String. Plugins now
list each export's calls, and bridge::state_through_calls keeps a caller of a function that hands
over a class object, in bridge, analyze and profile alike. A plugin with such a reason fills
ExportedFn::calls and builds the reason with lang::uses_class.
bridge scaffolded a function as pure that read a singleton of another unit.
LocaleManager.instance() lived outside the bridged package, so no function of the unit took or
returned it. Java and Kotlin now set a blocker for a call to a static instance/getInstance
accessor (lang::reads_singleton) and, in Java, for a static field that is not final; the
reason starts with lang::reads_app_state, and lang::holds_state is what
bridge::state_through_calls passes on to callers. A new reason a caller should inherit belongs
in holds_state.
A bridge found no functions in a module that exports a list. export { a, b as c } was not
read. ts/exports.rs reads export lists; check bridge on a unit written that way.
Checking the checks
gate kept passing after the recording it checks was deleted. cases_tampered read
recorded-from.json and returned nothing when it was missing, so removing the file and then the
failing cases from cases.jsonl passed; the float tolerance in rust-anything.json could be
raised after record for the same reason. rust-anything selftest found both. A check that reads
a file to find tampering must fail when the file is gone, and what it compares against must be
saved at record time, not read from a file the same edit can change.
A port that ran the original passed diff and gate. Every answer was right, so nothing
compared it with anything; the cheat guard read recorded values and tests, not what the port
calls. gate now has spawns (and runtime). A guard against a cheat is not finished until a planted port that
does it, and one that does it with the escape hatch's mark, are both refused (selftest).
A planted bug can be refused for the wrong reason. A planted port that did not build, or one
that a tolerance could not forgive (whole numbers match exactly), looked like a catch. Each
selftest row names the check meant to refuse it and ends UNEXPECTED when another one did;
a port that does not build is an error of the selftest, not a catch. When adding a row, run it
once against the product with the check removed and see it go red.
Recording
Capture code tripped the project's coverage threshold. Code record --from-tests appends to
the original counted against Jest's limit. Wrap anything added to user files in
/* c8 ignore start */ and /* istanbul ignore next */.
A recording held a secret from the environment. A recorded function that returns an
environment variable (os.environ.get("API_TOKEN")) put its value into cases.jsonl, the file
the workflow says to commit. record now fails and removes the file when it holds the value of
a variable whose name says secret (token, password, secret, credential, API key, private key,
8 characters or more); record with env -u NAME, or change the inputs.
Two Python units would not link into one front door. Each bridged crate defines
PyInit__native, and rust/app links units as rlibs, so the second unit made the release link
fail with duplicate symbol. The module sits behind the python-module feature and the front
door turns it off; after changing what a PyO3 crate defines at link time, wire two units into
one front door and build release (a glue that never calls its crate links, as the linker drops
it).
A test command's output corrupted the MCP stream. The child wrote to the server's stdout. Send every child's stdout to stderr or a pipe, never to the MCP server's stdout.
A project header shadowed the C library's. ffmpeg ships libavutil/time.h, and with that
folder on the -I path, #include <time.h> in parseutils.c found it instead of the system's.
A header folder holding a file named like a C standard header goes on -iquote; check that a
C project's originals compile before reading anything into a failed record.
A relative crate path pointed nowhere. The compiler and cargo run in a scratch folder, so
rust-anything build . looked for ./Cargo.toml there. The CLI makes crate paths absolute;
anything new that passes a path to a child process should take it absolute too.
A test runner in watch mode never ends. Run every outside program through crate::process,
which closes stdin and stops it at a time limit; from_tests also sets CI=1.
Coverage listed one file three times. Paths from import walking kept .. segments. Compare
and print canonical paths.
A CLI's recorded writes were invisible because the fixture already held them. A CLI that
regenerates project files was recorded on a project it had just generated, so every case rewrote
files with the bytes they already had, and a front door that wrote nothing passed. Record such
CLIs from a fixture whose generated files are stale (overwrite them with a marker first), and
check that the *.out folders are not empty.
A front door could not find the original through a symlinked rust/. The generated
original.rs resolved the repository as CARGO_MANIFEST_DIR/../.., which is the link target's
parent. Builds by rust-anything now set RUST_ANYTHING_REPO; set it yourself when you build such
a front door with cargo.
A server's recording carried state from its previous run. json-server rewrites its database
on every POST, so the second recording run started from the first one's writes. Record servers
that write files with --fresh <path>, and --pace when they do work after answering.
Ctrl-C during fuzz left the recording holding one round's cases. fuzz writes each round's
fresh cases over cases.jsonl and puts the recording back in a Drop, which a SIGINT or SIGTERM
skips. A copy of the recording and its two lists now sits in .rust-anything/fuzz-restore/ for the
run; recording::verify, diff, record, fuzz and held-out put it back first and say so. A
new file a round writes goes in round_files (and the copy), or an interrupted run leaves it.
Mail cases timed out on macOS CI. Python's smtplib looks up the machine's full host name
for its greeting, and on GitHub's macOS runners that lookup outlasted the 30-second case limit.
Test apps that send mail pass local_hostname="localhost"; an app under test that hangs the same
way needs it too, or a longer --timeout.
Recorded case names were cut to 24 characters. Hundreds of --inputs names shared a prefix
and collided. Given names keep 96 characters (given_slug); look at the case count after
recording against the number of input lines.
A Java case failed on a JVM warning. With many JVMs starting at once, one found its
/tmp/hsperfdata_<user>/<pid> file locked and printed [warning][perf,memops] Cannot use file
to stdout, so the replay's stdout differed. Java test apps run with -XX:-UsePerfData; an app
recorded on a busy machine needs it too.
A broken port passed because its case was never recorded. Recording drops a case whose
result JSON cannot hold (a PHP string that is not UTF-8). The only html_entity_decode input with
' also decoded to a lone Latin-1 byte, so a port that wrongly decoded ' passed.
After writing inputs for a behavior, check that cases.jsonl holds them, and break the port once
to see diff fail.
A check that could not run counted as a pass. stale and cases_tampered returned None
("nothing to compare") when recorded-from.json was missing or had no fingerprint, so deleting the
file switched both off, and an agent could then delete the failing lines of cases.jsonl and gate
green; diff, enable, report and go never asked at all. Every command that trusts the
recording calls recording::verify, and a recording it cannot verify fails with what to run. A
recording made before fingerprints is accepted only with "legacy_recording": true in the
manifest, and every verdict then says so. Test the missing file, the missing hash and the edited
line through the command, not only through the helper.
Known differences and a float tolerance turned failures into matches without a word. The
behavior check passed on failed == 0, and accepted cases and the saved tolerance only reached a
detail line, so go printed "13/13 cases match" over eight wrong ones and the card said "same
result on all". Gate fails when known-diffs entries were added since the last passing gate (or,
with no baseline, at all) or cover more than a tenth of the cases, unless the caller names the
number with --accept-known-diffs; every verdict prints comparison: exact or what it loosened
in its first line, and counts accepted cases apart from matches. A tolerance above 1e-6 needs
--allow-large-tolerance, and recorded-from.json keeps the setting it was recorded under.
enable switched a unit on without the checks gate runs. It built, diffed and edited the
source, so a stale recording, an edited one or a port that returns the recorded table was switched
on. enable runs the recording and cheat-guard checks before it edits anything; --force prints
every check it went past and writes them to the audit log. A switch-on must not be easier to get
than a passing gate.
The cheat guard stopped reading where a heuristic said to. src/.ignore or a hidden folder hid
a file from the walk, the first #[cfg(test)] (a use, a helper) ended the scan, -12345.678,
0xDEADBEEF and ["hel", "lo"].concat() were not the recorded value, nothing looked for
Command::new, include_bytes! of a copy of the recording, a build.rs or a path dependency, and
// recorded-literal: could mark every row of a table. The guard walks every .rs file of the
crate, leaves out only the item under #[cfg(test)] or #[test], reads negative, hex and joined
literals, fails a port that starts a program or includes what it should compute, caps and counts
the escape-hatch comments (a reason is required) and prints the count. When you add a way to hide
code from the guard, add the test that hides a three-entry table that way.
enable said "On" for a module that did not load. The block falls back to the original on any
load error, by design, so a unit shipped without its .node, or on a Node without
process.getBuiltinModule, ran the original everywhere while the card said "Switched on". enable
loads the module the way the block will, and checks it provides each function it rebinds, before it
edits a file.
The fingerprint included the block enable wrote. Every enabled unit then looked stale: gate
failed on recording and go could not run twice. The fingerprint is of the file without the
marked block.
A shadow never compared the calls where the original threw. The original ran outside any
try, so its exception left the shadow before Rust ran and calls stayed 0 for validation
failures, the likeliest place for a port to differ. The shadow runs Rust after an exception too,
compares the error messages and re-raises the original's exception.
An MCP tool answered "failed verdict" with isError: false. A client that reads the flag saw
a failed gate, a stale diff or a mismatching go as success. tool_result sets isError and
verdict from the result of every tool that gives one; add a tool with a verdict to
verdict_failed.
Numbers and claims
Benchmarks taken while other builds ran were off by a wide margin. Run bench on a quiet
machine, run it twice, and name the hardware and core count next to every published number.
A slow server row was the network, not the code. json-server's lifted binary served a large
list at 33 req/s while the same handler took 7 ms in process: no TCP_NODELAY, so the second
write of each response waited for a delayed ACK. Time the handler in process next to every HTTP
number; generated servers set TCP_NODELAY.
Every number in the docs is measured. Say what was run, on what, and the result, including the slow cases (the single-call row is slower than JS on some units). No rounding up for a headline.
Recorded CLI cases never saw a config file. app record runs each case in an empty
directory, so Prettier's .prettierrc, .editorconfig, package.json "prettier" key and
.gitignore/.prettierignore never applied, and a front door that ignored them passed every
case; run from inside a project it formatted differently from Prettier. A CLI that reads files
around its input needs cases recorded with those files, or glue that sends such cases back.
A replay reported the original, not the front door. app replay without --build runs the
recorded command (the Node CLI), passes everything, and prints no fallback rate; app wire --no-check replays nothing. Pass --build <front door binary> and read the fallback line.
gate checked less than it seemed for a split port. Its unwrap, panic and size checks read
port.rs only, and size counts the whole import closure (node_modules included). When the port
lives in a dependency crate, run clippy with -D warnings on that crate and grep it for
unwrap/panic! yourself, and do not quote the size ratio.
A port followed the wrong path key. Prettier's path.match(...) gives predicate i the node
i levels up and the key under which the level below sits. Port the semantics and test a
needs-parens case before reusing it.
A port compiled its regexes on every call. Prettier's printNumber is four regex replaces;
ported with Regex::new inside the function, an array of 100 numbers took 23 ms instead of 0.7.
Compile once (OnceLock or a thread-local cache), and look at the slowest cases of every bench,
not only the mean.
A port read its AST through hashed maps. Bridge crates turn on serde_json's
preserve_order, and Cargo unifies features across the binary, so every field lookup in a
serde_json::Value tree hashed the key. Reading oxc's ESTree into a small vector-backed value
type with interned keys made the printer about 1.7x faster. Profile before blaming the algorithm.
A benchmark timed a stale binary. cargo build --example bench | tail -1 && run took the
pipe's status from tail, so a missing example went unnoticed and the old binary skipped every
CSS file (total_us 0). Check the build's own exit status (set -o pipefail) and that the
timed run covered as many files as the list it was given.
A filter hid real cases from a count. The corpus checker skipped every name containing
config- to leave out the config cases, and four real files (vitest.config.ts, ...) went with
them. Match the exact prefix you mean, and check a group's total against the corpus.
A harvester dropped whole rules. ESLint's tests for no-unused-vars, prefer-const and
no-useless-assignment give their RuleTester a test-only plugin, and the script that turned
RuleTester cases into CLI runs skipped every case of a tester with plugins: 715 cases of three
of the most used rules were missing, and the rules showed "0 cases" instead of an error. Skip
only the cases that use what you cannot express, and check every unit's case count after
harvesting.
A copy of a crate built into the same target folder replaced it. A scratch copy of the port,
with the same package name and version, was built with the same CARGO_TARGET_DIR; cargo gave
both the same artifact name, and examples of the real crate linked the copy's library and
reported stale numbers. Give a copy its own package name or its own target folder.
Tests that built a same-named crate side by side loaded each other's library. Three tests in
tests/fuzz.rs bridged calc.ts, one with a planted bug in sum3 and one with a correct sum3, so all
three had the package calc-rs and shared one cache name. Locally they passed; on CI fuzz found
nothing in a port that differs on 13 of 100 inputs. Every test that bridges a crate gives it its own
package name (bridge::Options::name), and a test that fails because of a library says which one it
loaded (hash, age, the cache's owners.json).
A grep hid the bug it was meant to show. Filtering diffs with a pattern that drops comment-like
lines removed the one line that differed (/* name */ value). Write the expected and actual
output to files and diff them whole.
An exhaustive check covered a different input set from the one the port builds. The Prettier
doc printer was checked on every doc up to size 5, read from JSON through from_value, which
turns align: "" into a no-op as Prettier does. The YAML and Markdown printers build
Align::Text("") directly, and the printer indented for it. Enumerate the values the code really
passes (native Doc values), not a serialised form of them.
Mutation jobs tested each other's binaries. With CARGO_TARGET_DIR set, every
cargo mutants -j N job built into one target dir, so 401 of 693 logs ran a binary another job
had built. Run cargo-mutants with CARGO_TARGET_DIR unset, and check that every log under
mutants.out/log compiles the mutated crate.
Recorded crash messages held Prettier's install path. Prettier prints a stack trace when it
crashes, so cases recorded with one copy of Prettier fail when the front door falls back to
another. Record with the copy the front door's ROOT resolves to.
Sorting cannot pair lines that are matched loosely. An unordered output was compared by
sorting both sides as text and pairing the lines by position, while the lines were then matched
within float_tolerance: 10.0 sorts before 2.0, so it met 2.0 instead of the
9.999999999999999 it matched, and the weaker check failed output the ordered one accepted.
Sorting by value instead only moved the problem -- [..] and 2 against 2.0 then paired wrong,
because a loose match is not transitive and no order agrees with it. Pair the lines against each
other (identical ones first, then a search that gives a line up when another needs it), and keep
the sort for showing the diff.
A demo's lockfile missed a dependency. The Prettier front door gained ignore for config
resolution, but its Cargo.lock was not updated: the next plain build rewrote it, and a
cargo build --locked, as the release workflow runs, would have failed. After adding a dependency
to a demo crate, build it and keep the lockfile it writes.
An installed CLI failed replays on paths it prints about itself. ESLint's stack traces and "There was a problem loading formatter" name the file ESLint was loaded from, so 93 recorded runs differed once ESLint lived in an install prefix. Replay the original from the same install too: a run that fails both ways is the path, not the port.
A port probe kept listening in another thread's child. free_port and the tests'
fixed_port bound a TcpListener and dropped it. A process another thread was spawning held a
copy until it exec'd, so the port was still taken (Address already in use) and a client that
connected to it got Connection reset by peer: with eight threads spawning, 300 of 20,000
rounds. A probe binds and never listens (http::probe_bind).
Language plugins
A tree-sitter supertype never appears in the tree. tree-sitter-kotlin-ng lists
class_member_declaration as a child of class_body, but it is a hidden supertype: the tree
holds the concrete function_declaration directly. Filter on the concrete kind you parse, and
check a small fixture's S-expression before trusting node-types.json child lists.
Kotlin's JVM owner is not the file name. A top-level function compiles to a static method on
<File>Kt (NativeLib.kt → NativeLibKt); only @JvmStatic members of an object or
companion object live on the enclosing class. Emit prototypes in that Java shape, or the
generated JNI symbol and the reflection driver look for a class that does not exist.
The generated Java runtime needs API 26, not API 21. RustAnythingError resolves exception
constructors with plain reflection instead of MethodHandle.invokeExact (which Android only
supports from API 26), but the runtime also uses java.util.Optional and java.util.function
(API 24) and ThreadLocal.withInitial (API 26). build --profile android therefore rejects
--api below 26: a lower library would load but fail in the wrapper before reaching Rust.
Link with -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384 for 64-bit ABIs, or Play
rejects the library on 16 KB devices.
ART is not a desktop JVM, even when the bytecode is Java 8. The generated driver uses
Paths.get, not Path.of, and reads/writes files with Files.readAllBytes/Files.write, not
Java 11's Files.readString/writeString: those methods throw NoSuchMethodError on Android even
at API 30. The driver is dexed with d8 --min-api 26 and started with app_process.
On-device recording needs Android SDK build-tools. d8 and a platform's android.jar come
from the SDK, which can live somewhere other than ANDROID_HOME (the variable often points at an
old SDK); the device scratch directory under /data/local/tmp is removed after every run.
NDK discovery must ignore half-installed NDKs. --ndk wins, then ANDROID_NDK_HOME /
ANDROID_NDK_ROOT, then the newest complete NDK under ANDROID_HOME / ANDROID_SDK_ROOT, then
the usual ~/Android/Sdk, ~/Library/Android/sdk and ~/Documents/Android/Sdk. Completeness
means toolchains/llvm/prebuilt/<host>/bin exists: an interrupted sdkmanager download leaves a
newer directory with only source.properties, which must not shadow a working NDK. The linker is
the NDK's clang, so cargo-ndk is not needed, and cargo runs in the crate's directory so the
caller's .cargo/config.toml cannot leak into the generated crate.
Two parsers for one manifest drifted apart. whole_app::declared() re-read go.mod, pom.xml,
Gradle files, Gemfiles and requirements files with its own code, and five comment fixes landed
there while the plugins' discover() kept the bugs. Read a manifest in one place, the plugin's
discover(), and have every other consumer take Package.deps from it.
A name join split one library in two. --whole-app matched imported names (yaml) against
declared ones (PyYAML) as strings, so most libraries showed up twice. Join spellings by the crate
table row they resolve to (CrateMatch::row), not by the name or the crates text.
A PowerShell binding error depended on the process. The driver splatted recorded arguments
from a plain @{}, whose key order follows .NET's randomized string hashes, so a case with two bad
arguments failed on one parameter while recording and on the other while diffing. Splat from
[ordered]@{} in parameter order, and record twice to see the same cases.jsonl.
$x = if (...) { $array } unrolled the array. An if, foreach or switch statement used
as a value sends its output through the pipeline, so a one-item argument list became a scalar. In
generated PowerShell, assign inside each branch, and return arrays with , $value.
ConvertFrom-Json turns strings into dates. A string shaped like an ISO date comes back as
[datetime], and the switch that stops it (-DateKind String) needs PowerShell 7.5, while 7.4 is
the current LTS. The first driver needed it; generated PowerShell now reads JSON with
System.Text.Json.JsonDocument, and doctor asks for 7.4.
.NET casing is not Unicode casing. ToLowerInvariant leaves İ alone, OrdinalIgnoreCase
never folds ı or ſ to ASCII, and -replace '[a-z]' (case-insensitive) matches İ on
macOS: a port that folded with Rust's to_lowercase failed every recorded case with İ, ı or ſ.
Record REGEX_TRAPS for every PowerShell string function and fold per character as .NET does.
-replace '[a-z]' matching İ depended on the machine. On macOS the
case-insensitive class matches İ; on GitHub's Ubuntu 26.04 runner it does not, as under .NET's
invariant globalization mode, so a port written against a macOS recording failed on Linux CI.
The original itself differs, so record on the machine the code runs on, and reproduce with
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1.
Obligations
Detectors built from lists of known forms stayed silent on the next form. Five reviews in a
row found declarations the obligations detectors missed (a mount prefix held in a constant,
app.get.bind(app), from os import *, a variable expanded by execSync), each behind a
_ => {} or an early return. For every tracked object (a commander program, an express app,
process.env, an argparse parser), a use that no recognised form consumes is a site; write the
fallback branch first.
The ledger called a family complete because it had found nothing wrong. A detector that sees
no route proves nothing about routes declared another way. Only exports can be complete;
commands, flags, routes and environment variables are enumerated or none-found, and a person
attests them. Do not add a state that turns a detector's silence into a guarantee.
A route was listed without the prefix written two lines below it. router.get('/users')
followed by app.use('/api', router) gave GET /users plus a site saying the path was relative,
in seven frameworks, while Django's path("api/", include(...)) was already composed. A site
next to a wrong obligation does not make it right: compose what is readable, and mark in the
obligation itself what is not. After adding a rule to one framework, run it on the others.
A prefix join was written from the examples at hand. fastify adds the leading / a plugin
prefix lacks (prefix: 'v1' serves /v1/b), and the join listed GET v1/b; the fix then joined
level by level and listed GET /v1 where fastify, which composes the plugin prefixes first and
joins the route once, serves /v1/. Read the framework's own join functions (buildRoutePrefix,
then route.js) before writing ours, check the result against the routes the real framework
registers (its onRoute hook), in every major version in use, and make a case the versions
resolve differently a site.
A manifest made obligations read files outside the repository. setup(scripts=["/usr/bin/x", "../other/bin/tool"]) was joined to the root and opened, and the flags of a program on the
machine entered the ledger. The first fix judged the path after prefixing the package folder
(sub//usr/bin/x passed) and did not look at links: a module folder, a source file and the
manifest itself, linked to somewhere else, were still opened. Judge a path taken from the analysed
project as written, before any disk access; resolve links where files are opened (Reader::read,
read_inside) and refuse what leaves the root; whatever is refused is a site. Test with a file
that exists outside the repository and would show if it were read, and watch the opens with
strace.
A test required the behaviour a later rule forbids. a_symlinked_file_that_an_import_reaches_is_read
linked to a file in the temp folder and asserted its variable was listed, so closing reads outside
the repository failed it. When a rule changes, look for the tests that pin the old behaviour and
split them (link inside: read; link outside: site) instead of loosening the rule.
Assertions went vacuous when the contract changed. After complete stopped existing for
surface families, assert_ne!(family, Completeness::Complete) could no longer fail. Assert the
state you expect (is_open(), Enumerated), and after renaming a state, grep the tests for the
old one.
An open-ended review never said yes. Six adversarial reviews of the detectors each found new forms, because the ways of declaring a route or reading the environment have no end. Once the contract stopped claiming completeness, the exit test became a targeted review of the fixes and of earlier findings; what is still unread goes to Known limits and to the person who attests.
A cargo test filter ran no test and looked green. cargo test --lib <filter> --test x
applies the filter to the integration binary too and can run 0 tests there. Read the
running N tests line of every binary you meant to run.
A verification copy built into the same target volume replaced the real build. A scratch copy
with reverted fixes had newer files than the working copy, so cargo kept its binary and the next
full run tested the reverted detector. Same rule as the copied crate above: its own target
folder, or touch the sources before the run that counts.
An exception to a cautious rule was the hole. A help or version case credited nothing, unless
the project declared that spelling as a flag; -v --version with a declared --version then
credited --verbose, though the program prints its version and stops. A list that takes evidence
away must never also grant it.
Evidence rules built from lists of forms failed like the detectors did. Help was -h, then
-fh, then argparse's --hel; each fix added the form just found. What held is the closed
world: a recorded case is read only when the ledger explains every argument (read_case), and
anything else is uncovered with the reason. Write the refusal first on this side too.
Arguments could not tell a run from a usage error. build src --fast=1 exits 2 in argparse
and still credited the command, the flag and the variable. Read the recorded outcome (exit code
0, a 2xx answer) before the arguments. The probes that showed it were written by hand without a
status and so read as exit 0: record a probe with the real recorder, or write the status the
program gave.
A full loader used for a partial read opened what it did not need. Evidence called the case
loader replay uses, which also opens .stdin, .body and fs.base: files outside the
repository through a linked folder, and a FIFO that never answered. Read the header with a header
reader, under the same guard as every other open.
A guard no test held looked done. After each fix, break each guard and run the tests: the
trailing slash among competitors, the folder resolved before it is listed, the scope of an option
when a command exists in two files all survived once. Look at the mutant's diff before its
result, too: one applied with sed changed nothing, another did not compile, and both read as
"killed".
The full run failed on a port while mutants were building. tests/http.rs and the real HTTP
recorder take ports; run next to other test runs they met AddrInUse. Run the pass that counts
alone, and rerun a port collision before reading it as a regression.
A sweep with its own copy of a loader missed a field. The search for ... lines listed the
expected files of a case itself and never looked at the effects key of the case's .toml,
which replay reads first. Whoever compares says where each expected text comes from
(app::expected_source, the field lists next to replay), and every other reader calls that.
An id with a * was read as a pattern. waive 'route:src/app.js#GET /files/*' waived
every route the star matched. Test an argument for equality with a known id before reading it
as anything looser, and keep a test with such an id that has a case: the guard was right once
with no test, and a mutant survived.
The same hole was fixed by form three times. A positional that takes the rest of the line,
then an option that does, then the same through **kwargs and prefix_chars="-+": each fix
named the form the review had just found. The rule that held asks nothing about forms: while
one flag declaration is unread, no flag is linked. After the second fix of one kind, look for
the closed-world rule instead of the third form.
A temporary file with a guessable name was written through a link. A link planted at the
name waive was about to use sent the write elsewhere. Create a temporary file with create_new under a
name that is not predictable, and refuse a target that resolves outside the repository.
A command wrote what its own reader ignored. waive appended an ADR after an unclosed code
block; the reader took the heading for code, and the decision just written was invalid. Before
writing, read the composed text back with the reader that will judge it.
A test's comment claimed a guard the test does not hold. "Read by replay without being
in the list fails this test" was false: replay names its fields itself, and a mutant that
read one more file passed. When a test says two things agree, break each side once; write in
the comment only the direction that failed.
A writer that swallowed every error still hung. The fallback journal ignored all failures,
and a front door given a named pipe as its journal waited on open after the original had
ended; given /dev/stdout it added its line to the program's output. An error that is ignored
is not a call that returns. Code a generated binary runs on the side opens regular files only,
never the file behind its own stdout or stderr; test it with a FIFO, /dev/stdout and the
output redirected to the same file, under a time limit.
A writer and its reader each had their own bounds. The front door wrote the status hyper
gave it (up to 999) and the reader accepted 100 to 599, so one such line voided the journal.
A reader takes its constants from the writer's source (include! of the one file), and a test
sends the writer's extremes through the reader.
A placeholder was identified by its size. A journal line too long to write became
skipped with a byte count, and the count was its identity: a waiver for one covered the next
unknown fallback of the same size, without a word. What stands for content that was not kept
carries a digest of that content, and a test waives one and then reads a different one of the
same size.
An output option replaced a source file. obligations fallbacks --inputs src/cli.ts wrote
its lines over the file and created missing folders on the way. A file a command creates at a
path the user names is created with create_new, in a folder that exists.
An isolation guard had no test until the other side reported. Removing env_remove for
the journal variable passed every test, because nothing looked from inside the original. Test
that a child does not see something with a probe in the child.
Two guards for one property, and the tested one was not the one that held. The mutant of
check_target before a write survived because the read just before already refused the link,
and the mutant of a "target exists" check survived behind create_new. When a mutant
survives behind another guard, say which one holds the property and remove or document the
other; do not count both.
New MCP tools broke the tool/CLI parity test and the generated doc. obligations_check and
obligations_fallbacks are not CLI subcommands of those names (obligations --check,
obligations fallbacks), and docs/tools.md is generated from the tool list. After adding a tool,
run cargo test --test tools, map it in subcommand and cli_only there, and regenerate the doc
with UPDATE_TOOLS_DOC=1; a tool the CLI cannot do (waive, attest) is not a tool at all.
A test expected a result the setup could not give. A unit test of obligations_fallbacks called
it with a valid journal and asserted success, but the tool needs rust/app/rust-anything.json
(app front-door first), and an integration test asserted status = 2 in a case file that writes
status.code = 2. Read what the real command refuses and writes (run it once, cat the case file)
before writing the assertion, and keep the unit test on what it can reach: the call arrives.
A pinning test by substring passed when the option was renamed. The skill test asserted
contains("--repo"), and --repository contains it: renaming the option and deleting a rule left
the four tests green. Check an option as a whole word of the command's own --help, extract every
cited command from the text instead of listing a few, and pin each rule on the sentence that
forbids; break the text once (rename, delete) to see a test fail.
A rule gave the agent a decision the tool reserves for a person. The skill let the agent write a
[[bind]], while a binding closes an obligation with no ADR and no decision entry, even toward a
case that failed. The list of the user's decisions was written from the subcommands (waive,
attest), not from everything that closes an obligation. List the ways out from the code that
reads them (here obligations-bindings.toml), and show what a person closed by hand in the report.
"Read-only" was written for three tools from intent. obligations_fallbacks writes
rust/obligations-fallbacks.jsonl with write and creates the inputs file with inputs, while the
CHANGELOG, the README and a decision said all three only read. Say what each tool writes, from its
code and its annotation, and write "only reads" for the tools that are tested not to write.
A rebase added a second spelling of a field, and the reader of the first one read "absent".
The fallback check asked whether a recorded request sent a body by reading request.body. Upstream
then let a case hold its body as body_base64 or body_file, the merge was clean, and a case with
a binary body read as "no body": it explained a fallback that sent none. A reader that takes a
missing key for a fact lists every key that states that fact, and what it cannot read is a third
answer (RecordedBody::Unread), never "absent". After a rebase, read upstream's changes to every
format the registry reads (git diff <old base> <new base> -- src/app.rs src/http.rs), not only the
files that conflicted.
The wildcard sweep kept the old rule after replay narrowed it. The same rebase made a ...
line a wildcard only in the fields a recorded case lists in rust-anything.cases.json (wild),
and nothing failed: the sweep went on blocking every ... line, so a program that prints one
would have needed a waiver for text replay compares as written. It erred on the blocking side
because the sweep called has_line_wildcard and replay asked a closure of its own. The question
"does replay read a wildcard in this field of this case" has one definition (app::wild_in),
which both call; when upstream changes what a comparison reads, look for the readers that answer
the same question beside it.
The registry looked for the cases where replay no longer always reads them. Upstream added
app::cases_dir, which is spec/cases for an app started with rust-anything new; the registry
kept rust/app-cases in a constant and would have answered "no cases" for a repository replay
finds cases in. Sources::read now stops with an error for such a repository. A reader that finds
nothing must be sure it looked where the command it mirrors looks: after a rebase, grep upstream
for the function that replaced a constant you use.
A file whose name is not UTF-8 was skipped in silence. list made names with
to_string_lossy, so the path built from such a name did not exist and the _ => {} branch of the
walk dropped it, while replay read the real file and its ... line. A listing that cannot name
an entry refuses the folder; it never returns the folder without the entry.
A blocker placed first hid the refusal two upstream tests name. lift returns as soon as
anything blocks, and the registry's blockers come before the escape scan and the replay with the
original hidden; two tests upstream added for those refusals then saw lifted == false for the
registry's reason and failed on the text they look for. A lift fixture decides its obligations
(common::decide_obligations) unless the registry is what it tests. After a rebase, run the
tests upstream added, not only the ones that conflicted.
A test pinned a line ending the rebase changed. has_line_wildcard("a\r\n...\r\n") was
asserted true while upstream's lines now keeps the \r, so replay reads ...\r as text. The
test of a definition shared with replay asserts what compare does on the same bytes, next to
what the definition says.
The registry kept a list of skipped folders after discovery turned it into a rule. Upstream
stopped skipping dist, build, out, target and coverage by name alone: TypeScript
discovery now leaves them out only at the root or beside a package.json, so src/commands/build
is code. The registry read the same constant through lang::skip_dirs, the merge was clean, and
the constant no longer held those names: a packages/x/dist that discovery skips was no longer
reported, and four tests failed on a rule nobody had touched. Discovery's walk and the registry now
ask one function (ts::discover::skips, reached through lang::skips_dir), which takes the folder
and where it sits. The first fix stopped at the constant that had failed tests: target was also
in the registry's own NEVER lists, so an import into a src/target that discovery now reads was
"not read", and a file of another language there was never seen; a review by reading found it, no
test did. A list that becomes a rule cannot be mirrored as a list; after a rebase, read upstream's
changes to what discovery walks (src/ts/discover.rs, the SKIP_DIRS of src/lang/*.rs) beside
the formats the registry reads, and grep the registry for every name the changed rule mentions.
Repository
A local path reached a committed manifest. Demo manifests keep a placeholder root; check
git diff --cached for /Users/ and /home/ before committing (scripts/check-secrets.sh
does this in the pre-commit hook).
A new translation was listed right after English. Language lines list English, Türkçe, Українська first, then the other existing languages in their order, then new ones at the end (see CONTRIBUTING.md).
The debug CLI overflowed its stack on Windows. Unoptimized, run's one match over every
command needs between 1.5 and 2 MB of stack, and Windows gives the main thread 1 MB, so every
cargo run and every CLI test crashed with thread 'main' has overflowed its stack before parsing
its arguments, while the release build and Linux (8 MB) were fine. main runs run on a thread
with an 8 MB stack, and the Windows CI job runs a few CLI tests to keep it that way.
A suggested command broke when pasted. bridge printed rust-anything record <crate> with
the crate folder as display() shows it, so a folder with a space (C:\Users\First Last\...)
split into two arguments. A path in a command that a message tells the user to run goes through
app::cli_path (POSIX quoting in Unix shells and Git Bash, PowerShell quoting on native
Windows); the descriptive mention of the same path stays as it is. An otherwise plain Windows
path containing an internal backtick or typographic double quote keeps its bare spelling in hints
that previously printed it that way. Paste those hints in cmd, or single-quote the path in
PowerShell. A path ending in a backtick uses PowerShell's single-quoted form.
Two sessions edited one checkout. When another agent is working in the repository, work in a separate worktree and bring the change over when its files do not overlap.
The Ruby tests failed on a clean macOS shell. /usr/bin/ruby is Ruby 2.6, which rb-sys's
stable API does not support (Stable API is needed but could not find a candidate). A test that
builds a Ruby extension checks for Ruby 3 with common::have_ruby_3(), not common::have("ruby"),
and skips without it; to run those tests, put a current Ruby first on PATH (Homebrew's
/opt/homebrew/opt/ruby/bin) before cargo test.
A test failed on Linux CI with "Text file busy". It wrote a fake nm script and ran it while
other tests were starting processes; a child forked during the write still held the file open for
writing, so exec failed. Write a script that a test runs from a separate process (cp from a text
file) and never rewrite one that already ran.
A test stopped a front door with Child::kill and its original stayed. The HTTP front door
runs the original in a process group of its own and stops it when it ends; SIGKILL gives it no
chance to, so every full cargo test left three node server.js listening. A test that starts a
front door itself stops it with SIGTERM, keeps SIGKILL for one that does not end, and checks with
ps that nothing still runs out of its folder.
Verdicts that could be weakened
A port that answered with the original passed lift and package. lift checked that the glue
text lacked original::, so a front door running python3 app.py through Command was "pure
Rust" and passed 0 of 68 once the original was moved. Check by running: replay with the original's
files moved aside, and scan the front door for spawns and interpreters as well.
A replay that normalised bytes accepted a different output. A missing trailing newline, CRLF for
LF and a literal [..] line in the original's own output all passed. Compare exactly, and keep
wildcards in a structure that cannot collide with real output.
record shrank the recording and said it was done. An original that exited mid-run, a result
that could not be encoded and a case that timed out each dropped inputs, and the run printed a
count of what was left. Count what was generated against what was recorded, fail on the
difference, and keep the old recording until the new one is complete.
diff read a result file the driver may not have written. A port whose body was exit(0) read
the previous green diff.json. Delete the result before every driver run and check it is the
one this run wrote.
An error matched because something was thrown. Any throw matched any recorded throw, a Python
TypeError matched every recorded error, and a wasm panic (RuntimeError: unreachable) looked
like an ordinary error. Compare the type, and make a panic impossible to mistake for a thrown error
on every path the port is reached by.
A function that changes an argument or prints was bridged as pure. Only the return value is
recorded, so an empty port of sort_in_place(xs) -> None passed every case. Keep such exports in the
original with the reason, in one rule shared by bridge, analyze and profile.
A stricter error check broke a decision that was written down. Making a Swift trap refuse a
Rust panic failed tests/swift.rs on CI, because a port reproduces Swift's overflow trap by
panicking (DECISIONS M14). The test ran only where swiftc exists, so it did not run in the
sandbox. Before tightening a comparison, read the decision and the doc row for that language, and
look for tests that only run with a toolchain the machine lacks.
Recording mutation and output made the old rule too wide, then a language was relaxed on
trust. effects::observes lists the languages whose driver keeps the arguments after the call
and the standard output, and diff compares them; a language joins it only with a test that
bridges a mutator and a printer, plants a no-op port and expects diff to fail
(tests/post_call_state.rs, and a build for real in tests/native.rs). Judging which
parameters are &mut from the text of the function is a guess; the recording is the check, so a
miss fails diff instead of passing.
A recorded case held what the call had done to it. Ruby strings are mutable and the driver
decoded the case's own arguments, so s << "!" changed the case that was written next
(mark("a!!") recorded with the answer for "a!"). The driver decodes a copy. A language whose
decoder hands back the same object needs the same care; record a function that changes a string in
place and read the args of its line.
PHP's mutation is by reference, and the scan said otherwise. sort($xs) on a by-value
array changes a copy, so flagging it kept harmless functions, while the parameters that do change
the caller (array &$xs) were kept for another reason. For PHP the plugin lists the by-reference
parameters, and the text scan is not used for mutation. Ask what the language lets a call change
before reusing another language's rule.
A fully qualified call hid a printer. System.out.println was seen, System.Console.WriteLine
was not (a name preceded by . is a method of something else), so the function was bridged without
a stdout sink and diff caught it on the first case. The recording is the check; write the
scan's tests with using and the short name.
A language was added to the list without its toolchain. PowerShell and Swift stay out of
effects::observes: the rule is a test that plants a no-op port and watches diff fail, and that
needs the runtime. Downloaded tarballs were not run in the container; the Ubuntu packages of .NET
and Kotlin were.
A port that printed with println! looked like one that printed nothing. The capture sees
process.stdout/sys.stdout, not file descriptor 1, so the port writes to stdout: &mut String
and the binding prints it from the caller's side.
A copied-back argument lost its identity. Writing the changed arguments back by replacing the
caller's list or object (xs = fresh) changes nothing for the caller. The wrapper writes into the
same object (xs.length = n, xs[:] = ..., d.clear() then fill) and keeps nested containers
where the shape did not change.
The shadow ran Rust on what the original had already changed. sort hid it and push
did not. Rust gets copies taken before the original runs, with its output held back.
A scan that read only exact text said "ready". from re import sub, import re as regex,
java.util.*, .sort() and \d in a regex were not seen, and a unit with many traps scored 99.
Test a risk with the same code written the other common ways, and keep the table in the docs
checked against the code (tests/risks_doc.rs).
A source file that could not be read vanished. A non-UTF-8 file or a parse error shortened the
export list and the unit stayed "ready". Count it, warn, and refuse to bridge it without --force.