Python-to-Rust Agent Verification: Unit Tests, Full Diffs, and Blind Fingerprints
When Qwen3.6-27B passed all 12 ported Rust unit tests, held-out parity averaged 41.7/80 (41, 41, 43). Full Python-vs-Rust diffs raised parity to 80/80 across all three seeds, blind fingerprints plus a local sandbox reached 53.0/80 (49, 52, 58), and Qwen3-Coder-30B-A3B failed to compile in 4 of 9 runs while its compiled diff-tool runs stayed at 40-44/80.

When local Qwen3.6-27B ported our 4-stage Python processor to Rust and passed all 12 starter unit tests across all three seeds, exact output parity on 80 held-out cases averaged 41.7/80 (41, 41, 43, or 52.1%).
Adding a differential oracle with full Python-vs-Rust diffs lifted Qwen3.6-27B to 80/80 across every seed (0.00 held-in minus held-out gap), while blind byte fingerprints on the hidden cases, paired with a sandbox that shows full Python and Rust outputs for agent-written inputs, reached 53.0/80 (49, 52, 58).
Under the same setup, Qwen3-Coder-30B-A3B failed to compile in 4 of 9 runs (E0596, E0716, E0428, E0599, E0308) and its four compiled runs with diff tools scored 40 to 44/80, close to the 40/80 it got with unit tests alone.
To isolate the verification loops described in our earlier analysis of Anthropic's Rust migration report, we held weights, decoding (temperature=0.2, top_p=0.95, max_tokens=8192), llama-server flags (-ngl 99 -fa on --parallel 1 -c 98304 --jinja), and the offline Rust toolchain (rustc 1.98.1, serde 1.0.229, serde_json 1.0.151) constant on a single A100 80GB GPU. All 18 runs (2 models x 3 arms x 3 seeds) ported reference/messages_api.py, a 331-line synthetic module we wrote in the shape of the Messages API (validate, build_prompt, parse_stream, and count_usage). Its cases were built to expose Python defaults (round-half-even, float formatting, ensure_ascii, splitlines), so parity measures how many of these traps an agent finds, not a typical porting error rate. Runs were scored against deterministic held_in (80 cases) and held_out (80 cases, SEED = 20261127), with no network tool and no direct reads of either split. These ratios describe two Q4_K_M local models on a 331-line single module rather than frontier cloud models or multi-crate repositories.
Experimental setup across three verification arms
Each run started in an offline Cargo workspace containing read-only reference/messages_api.py, reference/test_messages_api.py, and src/main.rs, plus an editable src/lib.rs holding 4 stubbed serde_json::Value functions plus the process_case wiring and all 12 starter tests (16 assertions) pre-ported into #[cfg(test)] mod tests. We pre-ported the tests so quote-escaping typos during porting could not break them, and disabled write_file so a whole-file overwrite could not delete them, restricting edits to edit_file inside src/lib.rs, and fixed 98,304 context tokens and 60 steps per run (in unlocked repositories, test weakening can compound these parity gaps):
- Arm 1 (
arm1_unit_tests): Verify builds and the 12 unit tests withrun_cargo_test(cargo test --offline). - Arm 2 (
arm2_diff_full): Compile offline and runrun_diff_fullagainst 80held_in.jsonlcases, returning grouped mismatch counts with sample failing inputs and full Python vs. Rust strings. - Arm 3 (
arm3_diff_blind): Compile and run the same 80held_in.jsonlcases viarun_diff_blindwhile stripping all text and returning onlystep,piece,first_diff_byte,py_bytes,rs_bytes, and structuralfeature_tags(has_cr_sse,has_cache_usage,has_temperature,has_emoji), paired withsandbox_check(case_json), which returns the full Python and Rust outputs for any input the agent writes. Only the held-in corpus stays hidden.
Completion calls (finish or plain-text stops) were rejected up to 3 times if cargo test failed (ending as gave_up(test_fail)) and nudged up to 2 times in Arms 2 and 3 when held_in stayed below 80/80.

18-run results: full diffs hit 80/80; coder failed to compile 4 of 9
Compile failures (error(compile)) are tallied separately below rather than averaged as zero parity.
| Model | Arm | Compiled | Statuses | held_in (/80) | held_out (/80) | Stages (val/prm/sse/usg) | Avg steps | Avg tokens | Time (s) |
|---|---|---|---|---|---|---|---|---|---|
Qwen3-Coder-30B-A3B | arm1 | 1/3 | 1 ok, 2 gave_up | 39.0 [39] | 40.0 [40] | 75.0 / 60.0 / 74.0 / 64.0 | 38.0 | 903,903 | 127.0 |
Qwen3-Coder-30B-A3B | arm2 | 2/3 | 2 ok, 1 gave_up | 41.0 [39-43] | 42.0 [40-44] | 75.5 / 60.5 / 73.5 / 65.0 | 41.7 | 1,233,632 | 218.5 |
Qwen3-Coder-30B-A3B | arm3 | 2/3 | 2 ok, 1 gave_up | 39.5 [39-40] | 40.5 [40-41] | 75.5 / 60.5 / 73.5 / 63.5 | 43.3 | 1,188,223 | 262.1 |
Qwen3.6-27B | arm1 | 3/3 | 3 ok | 40.7 [40-42] | 41.7 [41-43] | 76.0 / 61.7 / 74.0 / 64.0 | 26.7 | 590,736 | 207.1 |
Qwen3.6-27B | arm2 | 3/3 | 3 ok | 80.0 [80-80] | 80.0 [80-80] | 80.0 / 80.0 / 80.0 / 80.0 | 44.0 | 1,284,661 | 370.2 |
Qwen3.6-27B | arm3 | 3/3 | max_steps 3 | 52.0 [48-57] | 53.0 [49-58] | 76.0 / 69.0 / 78.0 / 68.0 | 60.0 | 2,132,972 | 657.0 |
Qwen3.6-27B finished every Arm 1 run cleanly in 23 to 34 steps (207.1 s mean) with 12/12 passing unit tests, while missing 37 to 39 of 80 held-out cases. Opening run_diff_full in Arm 2 raised mean cost to 44.0 steps (1,284,661 tokens, 370.2 s) and fixed every bug in four diff rounds per seed: 40 -> 57 -> 72 -> 80 (seed 42), 40 -> 46 -> 68 -> 80 (seed 43), and 40 -> 57 -> 72 -> 80 (seed 44), generalizing 80/80 to held_out (in Arms 1 and 3, held_in - held_out = -1.0 comes from split RNG differences putting one extra edge case inside held_in, showing no overfitting). Arm 3's 53.0/80 represents 60-step progress under the turn cap, with all three seeds hitting MAX_STEPS = 60 while making 14, 17, and 19 sandbox_check calls.
Qwen3-Coder-30B-A3B gained little from differential feedback. Four runs failed cargo test (E0596/E0716 borrows in arm1 s43 and s44, 29 errors including E0428/E0599 in arm2 s42, and E0308/E0428 plus 3 8,192-token truncations in arm3 s44). The four compiled runs that had diff tools scored 40 to 44/80 held-out; arm2 s43, for example, moved 40 -> 43 and then stayed at 43 for three more rounds.
Four silent parity traps behind passing unit tests
Test-fidelity audits found zero tampering: 17 of 18 runs left the 12 starter tests (16 assertions, 0 #[ignore]) byte-identical to scaffold/src/lib.rs, and Qwen3.6-27B arm2 s43 preserved all 12 while appending test_rounding_check (5 assertions on 12.5 -> 12, 13.5 -> 14, 11.5 -> 12). Across all 18 workspaces we found 0 external process calls and 0 hardcoded corpus sentinel strings, and the tool outputs of the 6 Arm 3 runs leaked 0 raw case text.
With unit tests green, Qwen3.6-27B Arm 1 (41/80, seed 42) diverged across all four checkpoints on ordinary Python-vs-Rust language defaults:
| Stage | Failing cases | Python vs. Rust gap | Diff offset & sizes | Sample output diff (held_out) |
|---|---|---|---|---|
validate | validate_temp_ties (4) | Python round(t, 2) rounds .5 to even (0.625 -> 0.62) vs. Rust .round() (0.63) | byte=101-103, 139-141B equal (e.g., 139B == 139B) | PY 0.62 vs. RS 0.63 |
build_prompt | <meta> float + json.dumps (11) | float(0) prints "0.0" ("1.0") vs. Rust "0" ("1"); json.dumps spacing (", ", ": ") vs. compact | byte=40/42, 45B/233B vs. 43B/221B | PY temperature="0.0"/> vs. RS "0"/> |
build_prompt | BMP (6), emoji surrogates (2) | json.dumps ensure_ascii=True emits \uXXXX and \ud83c\udf89 vs. Rust raw UTF-8 | byte=62-125, 182B/131B vs. 168B/117B | PY "\ud83c\udf89" vs. RS "🎉" |
parse_stream | sse_bare_cr_and_spaces (6) | splitlines() splits bare \r and lstrip() trims multi-spaces; Rust .lines() missed frames | byte=20, 77B vs. 63B | PY 'CR_10 MULTI_10' vs. RS '' |
count_usage | Cache ties (10) + bare \r (6) | round(cw * 1.25) rounds 12.5 -> 12 vs. Rust 13; shared SSE parser dropped 6 streams | byte=25-26, 183-184B equal (e.g., 184B == 184B) | PY billable_input_units: 132 vs. RS 133 |
Qwen3-Coder-30B-A3B (arm1 s42) also missed valid_thinking_disabled (140B vs. 59B, byte=2) by validating budget_tokens when thinking.enabled was false.
Bugs blind fingerprints fixed, and bugs they never found

Among length-changing bugs, Qwen3.6-27B Arm 3 fixed bare \r framing in 2 of 3 seeds and the JSON spacing and <meta> float display in 2 of 3 seeds without seeing raw text. The 8 non-ASCII escaping cases also change length, and no seed fixed them. Seed 44, the best of the three, shows the flow:
- Bare
\rSSE framing (seed 44, steps 10-23): Round 1 (40/80) surfacedparse_streamfingerprintd8cef026(count=6,first_diff_byte=20,py_bytes=75,rs_bytes=63,tags=["has_cr_sse", "has_multiline_sse", "has_stream"]). Inferring Python's bare-\rsplitlines()behavior raised round 2 to46/80(parse_streamhit80/80; shared SSE parsing raisedcount_usage63 -> 69/80). Seed42also solvedparse_stream80/80blind; seed43stayed at74/80. - JSON separators and
"1.0"display (seed 44, steps 24-56): Syntheticsandbox_checkinputs exposed109B vs. 108Bspacing (48/80), and a probe with"temperature": 1.0at step 49 returnedfirst_diff_byte=42, py_bytes=47, rs_bytes=45on<meta model="claude-sonnet" temperature="1.0"/>, lifting round 4run_diff_blindto57/80(58/80held-out,build_prompt 61 -> 72).
Where byte lengths matched cleanly, blind fingerprints stalled. On count_usage (10 tie cases, 183-184B equal across Python and Rust at byte=25-26, with seed 42 repeatedly seeing four 183B == 183B and four 184B == 184B mismatches in its top held-in groups) and validate (4 tie cases, 139-141B equal at byte=101-103), seed 42 first suspected JSON key ordering, then switched to a value hypothesis and tried cw=100, 101, and 102 in sandbox_check. cw=102 gives 127.5, a tie that both languages happen to round to 128, so it got "match": true; the agent also wrongly believed Rust's round uses banker's rounding, and spent its 60 steps without finding the .5 tie behavior. All three Arm 3 seeds stalled at validate=76/80, missed all 8 ensure_ascii=True escaping cases, and took 1.8x the wall time (657.0 s vs. 370.2 s) and 1.7x the tokens (2.13M vs. 1.28M) of Arm 2.
Three verification rules for teams
- Treat green ported unit tests as wiring checks, not behavioral equivalence. Passing all 12 starter tests left held-out parity at
41.7/80, and unlocked repositories can also suffer from test weakening. - Attach full Python-vs-Rust diffs first whenever fixtures are non-sensitive.
Qwen3.6-27Breached80/80in37-52steps with lower wall time and token cost than blind probing. The diff loop's effect can be near zero for some models:Qwen3-Coder-30B-A3Bstayed at40-44/80even on compiled runs. - Pre-seed blind sandboxes with easy-to-miss boundary cases whenever raw text must stay hidden. One-digit
.5ties hide behind identical byte lengths and all three blind seeds missed the escaping cases, so explicit boundary seeds for.5banker's-rounding ties, integer-valued floats (1.0/0.0), bare\r, and UTF-16 emoji pairs are a safer default.
Subscribe below for our next coding-agent verification benchmark.