Repository navigation
Replace the Python fake gh and claude with a Rust helper - #218
Merged
Merged
Conversation
The warm suite missed both of #174's targets (249s wall, 650s user + sys against a 701s baseline), and the Python fakes' own CPU was about 352s of that: 4,940 gh calls and 381 claude calls. The fakes are now one std-only Rust executable, built from tests/fakes.rs with rustc the first time a test needs it and cached in CARGO_TARGET_TMPDIR by a hash of its sources. It acts as gh or claude by the name it is called by, under the same contract: the same state and record files, argv handling and output. tests/fakes.rs is also a Cargo test target, so clippy and rustfmt cover the fakes and the JSON layout is checked against Python's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pull the repeated pieces of the fakes into one place each: the --jq refusal, the "not open" check, the branch tip on origin, record appends and the lock file. Move the JSON tests next to the JSON module. Build the fakes without -D warnings, so a lint a newer rustc adds can't fail the suite: clippy covers them through the fakes test target. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Sep 30, 2026
Closed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The warm suite still missed #174's targets (249s wall, 650s user + sys), and the Python fakes' startup used about 352s of that CPU. They're now one std-only Rust executable. It acts as
ghorclaudedepending on the name it's called by, and keeps the same contract: the same state and record JSON files, argv handling and output.The fakes aren't a
[[bin]], so neither the crate nor a dist release ships them. No scenario changed.tests/release.rsonly changed how its fixture installs the fakes, and it now usesmod support.Evidence
All measurements are on a 4-core machine that wasn't idle. The full table with load is in the Result comment on #174.
cargo testtook 249s wall and 444 + 205 = 650s user + sys. Python fake self-CPU was 333s forghand 20s forclaude.After: warm
cargo testtook 107s / 129s / 113s wall and 188s / 202s / 206s user + sys. All 25 test binaries passed. The last two runs had a failingpython3stub first onPATH, and nothing called it.cargo test --no-runtook 108s (target ≤ 300s). Building the fakes adds about 1.2s once, at the first test that needs them.cargo fmt --checkandcargo clippy --all-targets -- -D warningsare clean.Merge Danger
Door: two-way
Test-only. Reverting brings the Python scripts back.
Blast Radius: tests
Running the suite now needs
rustconPATH(or$RUSTC) instead ofpython3. Staletarget/tmp/fakes-*builds pile up as the fakes change, a few MB each.Unaddressed findings
Standards
static LOCK,state_path()from env): skipped. It mirrors how the fake lets go of the lock while a hook script runs, and threading a lock through every command adds noise to a test fake.Jsonstate): skipped. Untyped state passes unknown keys and key order through untouched, which the state-file contract relies on.fakes-<hash>and failed.partialbuilds never cleaned up: skipped. They're small,cargo cleanremoves them, and pruning them could race with parallel test processes.Spec
tests/fakes.rsis an extra test target (not asked for): kept. It's the only way the fakes get clippy and rustfmt.release.rspulls in all ofsupport: kept. Only fixture setup changed, no assertions.rustccan't use serde_json, and the module has its own tests.pr view --jq .<object field>prints JSON, not a Python repr: skipped. Nothing selects a non-string field.gh fake …rejects extra arguments;gh fake pron an unknown head says "no pull requests found" instead of a traceback: skipped. Both still fail (exit 1 or 2), and no caller passes extras.run listtreats a run missingbranch/workflow/eventas not matching (Python crashed);claudeno longer turns\r\ninto\nin stdin and the plugin snapshot: skipped. No test or script records such a run or uses CRLF.tmp-merge-<pid>, nottmpXXXX: skipped. It's removed before any error, and nothing lists that directory.Closes #207
🤖 Generated with Claude Code