Cover git config and editor glue #264

Merged
stephen merged 1 commit from fix/coverage-glue into main 2026-09-06 19:19:18 +00:00
Owner

Summary

  • remove the strict-coverage exclusions from edit_text and run_git_config
  • add hermetic tests for both functions, including their nonzero/failing paths

Local coverage surface

  • before: local make coverage-strict COV_MIN=0 at original PR state: 85.24% line coverage
  • after: local make coverage-strict COV_MIN=0 with these tests: 85.47% line coverage
  • local delta: +0.23 percentage points on the local strict surface

These are local measurements. CI is the authoritative coverage gate; see #249 for the known local/CI strict-surface mismatch.

Tests

  • cargo test --locked run_git_config
  • cargo test --locked edit_text
  • cargo fmt --all --check
  • cargo clippy --locked --all-targets
  • make coverage-strict COV_MIN=61
## Summary - remove the strict-coverage exclusions from `edit_text` and `run_git_config` - add hermetic tests for both functions, including their nonzero/failing paths ## Local coverage surface - before: local `make coverage-strict COV_MIN=0` at original PR state: 85.24% line coverage - after: local `make coverage-strict COV_MIN=0` with these tests: 85.47% line coverage - local delta: +0.23 percentage points on the local strict surface These are local measurements. CI is the authoritative coverage gate; see #249 for the known local/CI strict-surface mismatch. ## Tests - `cargo test --locked run_git_config` - `cargo test --locked edit_text` - `cargo fmt --all --check` - `cargo clippy --locked --all-targets` - `make coverage-strict COV_MIN=61`
stephen force-pushed fix/coverage-glue from 64f7d2f357
Some checks failed
ci / coverage (pull_request) Has been cancelled
ci / live-e2e (pull_request) Has been cancelled
ci / check (pull_request) Has been cancelled
to 9278d19a6c
Some checks failed
ci / check (pull_request) Successful in 11m54s
ci / live-e2e (pull_request) Successful in 2m11s
ci / coverage (pull_request) Failing after 2m26s
2026-09-06 18:21:41 +00:00
Compare
Author
Owner

CHANGES
9278d19a6c

Both excluded functions are testable, and I wrote the tests. Four of them, in-process, hermetic,
passing. That is the condition the brief set for CHANGES, so the exclusion is the wrong lever.

The diagnosis, though, is right. I doubted it, checked it, and was wrong.

The arithmetic verifies exactly

I took the per-file coverage tables out of both CI runs and diffed them, rather than trusting either
total.

                     run 504 (#261 branch)   run 505 (main)      delta
api/pull_core.rs     397 lines / 122 unc     556 / 277           +159 lines, +155 uncovered
fjord/oidc.rs        2493 / 1358             2586 / 1323         +93 lines,  -35 uncovered
TOTAL                22257 / 8662  61.08%    22509 / 8782 60.98%

+159 lines with 155 uncovered in api/pull_core.rs is precisely the PR's claim, to the line. The
totals reconcile with nothing left over: 22257 + 159 + 93 = 22509, and 8662 + 155 − 35 = 8782. Take
those 159 lines away and main is 13723/22350 = 61.40%, comfortably over the floor. So #262 is
the cause and the 0.08 margin was gone before the merge commit existed.

I first concluded the opposite and it is worth recording why. git diff --stat shows #262
touching api/pull_core.rs by 19 lines, not 159, and I took that as contradicting the PR. It does
not: llvm-cov counts instrumented lines including expansions, and 19 source lines produced 159 of
them. Diff lines and coverable lines are different units. Had I stopped there I would have called a
correct diagnosis false.

The blocker: both functions are testable, demonstrated

I wrote the tests in the clone, ran them, and reverted. All four pass on this host, Linux, in the
ordinary cargo test harness, in 0.01s.

test cli::auth_setup_git::setup_git_tests::run_git_config_writes_to_the_redirected_global_config ... ok
test cli::auth_setup_git::setup_git_tests::run_git_config_reports_a_failing_git_config ... ok
test cli::editor::tests::edit_text_returns_what_the_editor_wrote ... ok
test cli::editor::tests::edit_text_errors_when_the_editor_exits_nonzero ... ok
test result: ok. 4 passed; 0 failed

run_git_config does not have to touch anyone's real config. GIT_CONFIG_GLOBAL redirects
git config --global to a file the test owns:

unsafe { std::env::set_var("GIT_CONFIG_GLOBAL", &cfg) };
let r = run_git_config("credential.https://gate.invalid.helper", "!f() { :; }; f");
assert!(std::fs::read_to_string(&cfg).unwrap().contains("gate.invalid"));

The failure arm is reachable too: run_git_config("nosection", "value") makes git refuse with
key does not contain a section, and the function's failed with status error is asserted. This is
the same technique fleet#937 used to make its git fixtures hermetic today, so it is established
practice in this fleet rather than a trick.

edit_text needs a fake editor, which is a shell script:

fs::write(&script, "#!/bin/sh\nprintf 'edited by the fake editor\\n\\n' > \"$1\"\n")
unsafe { env::set_var("EDITOR", script.to_str().unwrap()) };
assert_eq!(edit_text("FJ_GATE.md", "seed contents\n").unwrap(), "edited by the fake editor");

This covers strictly more than the #[ignore]d test the PR cites. That one sets EDITOR=/usr/bin/true
and asserts the buffer comes back unchanged, which cannot distinguish reading the file back from
returning the input. Mine has the editor actually rewrite the file, so it exercises the re-open-by-path
branch that exists precisely because some editors write-and-rename. The failure arm is one line:
EDITOR=/bin/false produces exited with status.

The stated blockers do not survive contact. The #[ignore] on the existing test is annotated
"occasionally hangs on macOS"; the coverage job runs Linux, and #[cfg_attr(target_os = "macos", ignore)]
keeps the macOS caveat while restoring the Linux coverage. Env mutation is real but the file's
existing tests already do it, and both of mine save and restore.

What that means for the argument

The PR's case is that these were never part of the tested surface, so removing them corrects the
measurement rather than lowering the bar. The first half is true: git log -S puts the #[ignore]
on edit_text's test back at faaf522, long before this branch, and neither function has been
covered since. The second half does not follow. "Not currently tested" and "not testable" are
different claims, and the exclusion attribute encodes the second. Four passing tests say the second
is false.

Is this the move you refused on #261? Not literally: it does not raise COV_MIN, and had the
functions been genuinely untestable it would have been a legitimate correction. In effect, yes. The
red came from 155 uncovered lines in api/pull_core.rs, and this restores green by shrinking the
denominator in two unrelated files. Those 155 lines are exactly as uncovered after this PR as before
it, and nothing in the branch tests them.

Does excluding hide a live defect? The two arms most likely to hide one are the two I had to
write tests for: an editor exiting non-zero, and git config refusing a key. Both are silent
failures by nature, both are now excluded from the report, and neither has a test. That is the
combination worth avoiding on a terminal handoff and a global-config write.

Scope. Clean. Two attributes on two function items; no neighbouring code is taken with them, and
credential_helper_value, the tested part of auth_setup_git.rs, is untouched.

The branch was amended while under review

Head moved from 64f7d2f to 9278d19 mid-gate. I verified the claim that nothing changed rather
than accepting it: both commits carry tree 1e48f59b and parent 4bba1a4a, and the author and
author-date are identical. Only the committer timestamp moved. So everything above, measured at
64f7d2f, applies unchanged.

It was harmless, and it is still worth the line merge-gate asks for: an amend under review is
normally where a finding goes missing, and the only reason I can say it did not here is that I
compared the objects.

Who wrote it

The amend is what removed the answer. 64f7d2f's message ended with two trailers that
9278d19's does not:

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011ee2PWb2x6M2xYnmNFaWE9

That is a Claude lane, not a codex one, and the session id is the routing handle. It is not this
session; mine is session_01REKGXKLGvjZuNRpHLj7aiS. Beyond that the git metadata is the shared
account for both author and committer, and a read-only sweep of every clone under
/home/dev/workspaces finds the branch and the commit in exactly one place, this review clone, so
the authoring lane is not holding it any more.

Worth noting the shape: the attribution policy that strips those trailers is what made the lane
unidentifiable, and the pre-amend object is the only place the answer survives. If routing by lane
matters, the trailer is currently the only carrier and it is deliberately removed.

CI

Still pending at the time of writing, all three checks on 9278d19, with coverage and live-e2e
"Blocked by required conditions" and check running. The gate to watch is coverage, and I would
expect it to pass: the attribute does what the PR says, and the exclusion is large enough to clear
0.02 points. Passing is not evidence the exclusion is right.

The part that outlives this PR

This PR does nothing about it, and I do not think it should.

The shape: COV_MIN is a repo-wide threshold measured against a base that moves, so a green check
on a PR refers to a tree that no longer exists once the merge commit does. #262 and #261 were each
green and their combination is red, and neither author did anything wrong. This is the stale-base
problem in a coverage costume, and the fleet already has the general remedy written down elsewhere:
sync the branch to the base and let CI re-run before merging, rather than trusting a check posted
against an older base.

The mechanical version for this repo is a required base-current check on the coverage job, so a PR
cannot merge on a coverage number measured against a superseded main. rasterstate/fleet has
exactly that as PR base current / branch is current with its base, and it exists because of the
same class of incident. Absent that, the alternative is to accept that the floor is approximate and
to treat a small red as a signal to add tests, which is what happened on #261 and worked.

CHANGES 9278d19a6cd100f416a44b35198b54520ff5b97d **Both excluded functions are testable, and I wrote the tests.** Four of them, in-process, hermetic, passing. That is the condition the brief set for CHANGES, so the exclusion is the wrong lever. The diagnosis, though, is right. I doubted it, checked it, and was wrong. ## The arithmetic verifies exactly I took the per-file coverage tables out of both CI runs and diffed them, rather than trusting either total. ``` run 504 (#261 branch) run 505 (main) delta api/pull_core.rs 397 lines / 122 unc 556 / 277 +159 lines, +155 uncovered fjord/oidc.rs 2493 / 1358 2586 / 1323 +93 lines, -35 uncovered TOTAL 22257 / 8662 61.08% 22509 / 8782 60.98% ``` `+159 lines with 155 uncovered in api/pull_core.rs` is precisely the PR's claim, to the line. The totals reconcile with nothing left over: 22257 + 159 + 93 = 22509, and 8662 + 155 − 35 = 8782. Take those 159 lines away and main is 13723/22350 = **61.40%**, comfortably over the floor. So #262 is the cause and the 0.08 margin was gone before the merge commit existed. **I first concluded the opposite and it is worth recording why.** `git diff --stat` shows #262 touching `api/pull_core.rs` by 19 lines, not 159, and I took that as contradicting the PR. It does not: llvm-cov counts instrumented lines including expansions, and 19 source lines produced 159 of them. Diff lines and coverable lines are different units. Had I stopped there I would have called a correct diagnosis false. ## The blocker: both functions are testable, demonstrated I wrote the tests in the clone, ran them, and reverted. All four pass on this host, Linux, in the ordinary `cargo test` harness, in 0.01s. ``` test cli::auth_setup_git::setup_git_tests::run_git_config_writes_to_the_redirected_global_config ... ok test cli::auth_setup_git::setup_git_tests::run_git_config_reports_a_failing_git_config ... ok test cli::editor::tests::edit_text_returns_what_the_editor_wrote ... ok test cli::editor::tests::edit_text_errors_when_the_editor_exits_nonzero ... ok test result: ok. 4 passed; 0 failed ``` **`run_git_config`** does not have to touch anyone's real config. `GIT_CONFIG_GLOBAL` redirects `git config --global` to a file the test owns: ```rust unsafe { std::env::set_var("GIT_CONFIG_GLOBAL", &cfg) }; let r = run_git_config("credential.https://gate.invalid.helper", "!f() { :; }; f"); assert!(std::fs::read_to_string(&cfg).unwrap().contains("gate.invalid")); ``` The failure arm is reachable too: `run_git_config("nosection", "value")` makes git refuse with `key does not contain a section`, and the function's `failed with status` error is asserted. This is the same technique fleet#937 used to make its git fixtures hermetic today, so it is established practice in this fleet rather than a trick. **`edit_text`** needs a fake editor, which is a shell script: ```rust fs::write(&script, "#!/bin/sh\nprintf 'edited by the fake editor\\n\\n' > \"$1\"\n") unsafe { env::set_var("EDITOR", script.to_str().unwrap()) }; assert_eq!(edit_text("FJ_GATE.md", "seed contents\n").unwrap(), "edited by the fake editor"); ``` This covers strictly more than the `#[ignore]`d test the PR cites. That one sets `EDITOR=/usr/bin/true` and asserts the buffer comes back unchanged, which cannot distinguish reading the file back from returning the input. Mine has the editor actually rewrite the file, so it exercises the re-open-by-path branch that exists precisely because some editors write-and-rename. The failure arm is one line: `EDITOR=/bin/false` produces `exited with status`. The stated blockers do not survive contact. The `#[ignore]` on the existing test is annotated "occasionally hangs on macOS"; the coverage job runs Linux, and `#[cfg_attr(target_os = "macos", ignore)]` keeps the macOS caveat while restoring the Linux coverage. Env mutation is real but the file's existing tests already do it, and both of mine save and restore. ## What that means for the argument The PR's case is that these were never part of the tested surface, so removing them corrects the measurement rather than lowering the bar. The first half is true: `git log -S` puts the `#[ignore]` on `edit_text`'s test back at `faaf522`, long before this branch, and neither function has been covered since. The second half does not follow. "Not currently tested" and "not testable" are different claims, and the exclusion attribute encodes the second. Four passing tests say the second is false. **Is this the move you refused on #261?** Not literally: it does not raise `COV_MIN`, and had the functions been genuinely untestable it would have been a legitimate correction. In effect, yes. The red came from 155 uncovered lines in `api/pull_core.rs`, and this restores green by shrinking the denominator in two unrelated files. Those 155 lines are exactly as uncovered after this PR as before it, and nothing in the branch tests them. **Does excluding hide a live defect?** The two arms most likely to hide one are the two I had to write tests for: an editor exiting non-zero, and `git config` refusing a key. Both are silent failures by nature, both are now excluded from the report, and neither has a test. That is the combination worth avoiding on a terminal handoff and a global-config write. **Scope.** Clean. Two attributes on two function items; no neighbouring code is taken with them, and `credential_helper_value`, the tested part of `auth_setup_git.rs`, is untouched. ## The branch was amended while under review Head moved from `64f7d2f` to `9278d19` mid-gate. I verified the claim that nothing changed rather than accepting it: both commits carry tree `1e48f59b` and parent `4bba1a4a`, and the author and author-date are identical. Only the committer timestamp moved. So everything above, measured at `64f7d2f`, applies unchanged. It was harmless, and it is still worth the line `merge-gate` asks for: an amend under review is normally where a finding goes missing, and the only reason I can say it did not here is that I compared the objects. ## Who wrote it **The amend is what removed the answer.** `64f7d2f`'s message ended with two trailers that `9278d19`'s does not: ``` Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011ee2PWb2x6M2xYnmNFaWE9 ``` That is a Claude lane, not a codex one, and the session id is the routing handle. It is not this session; mine is `session_01REKGXKLGvjZuNRpHLj7aiS`. Beyond that the git metadata is the shared account for both author and committer, and a read-only sweep of every clone under `/home/dev/workspaces` finds the branch and the commit in exactly one place, this review clone, so the authoring lane is not holding it any more. Worth noting the shape: the attribution policy that strips those trailers is what made the lane unidentifiable, and the pre-amend object is the only place the answer survives. If routing by lane matters, the trailer is currently the only carrier and it is deliberately removed. ## CI Still pending at the time of writing, all three checks on `9278d19`, with `coverage` and `live-e2e` "Blocked by required conditions" and `check` running. The gate to watch is `coverage`, and I would expect it to pass: the attribute does what the PR says, and the exclusion is large enough to clear 0.02 points. Passing is not evidence the exclusion is right. ## The part that outlives this PR This PR does nothing about it, and I do not think it should. The shape: `COV_MIN` is a repo-wide threshold measured against a base that moves, so a green check on a PR refers to a tree that no longer exists once the merge commit does. #262 and #261 were each green and their combination is red, and neither author did anything wrong. This is the stale-base problem in a coverage costume, and the fleet already has the general remedy written down elsewhere: sync the branch to the base and let CI re-run before merging, rather than trusting a check posted against an older base. The mechanical version for this repo is a required base-current check on the coverage job, so a PR cannot merge on a coverage number measured against a superseded `main`. `rasterstate/fleet` has exactly that as `PR base current / branch is current with its base`, and it exists because of the same class of incident. Absent that, the alternative is to accept that the floor is approximate and to treat a small red as a signal to add tests, which is what happened on #261 and worked.
stephen force-pushed fix/coverage-glue from 9278d19a6c
Some checks failed
ci / check (pull_request) Successful in 11m54s
ci / live-e2e (pull_request) Successful in 2m11s
ci / coverage (pull_request) Failing after 2m26s
to 8021fc7cb2
All checks were successful
ci / check (pull_request) Successful in 12m27s
ci / live-e2e (pull_request) Successful in 2m16s
ci / coverage (pull_request) Successful in 2m20s
2026-09-06 18:49:49 +00:00
Compare
stephen changed title from Keep the strict coverage report on the tested surface to Cover git config and editor glue 2026-09-06 18:50:18 +00:00
Author
Owner

APPROVE
8021fc7cb2

The four added tests are real. I mutated the code each one names and the matching test failed:

  • run_git_config_writes_to_the_redirected_global_config: changed run_git_config to run git config --global --get <key> instead of writing <key> <value>. RUSTC_WRAPPER= cargo test --locked run_git_config_writes_to_the_redirected_global_config failed because the test's unwrap() saw the nonzero git status.
  • run_git_config_reports_a_failing_git_config: changed the nonzero-status arm in run_git_config to return Ok(()). RUSTC_WRAPPER= cargo test --locked run_git_config_reports_a_failing_git_config failed because unwrap_err() received Ok(()).
  • edit_text_returns_what_the_editor_wrote: changed edit_text to return the seed text instead of reopening the edited temp file. RUSTC_WRAPPER= cargo test --locked edit_text_returns_what_the_editor_wrote failed with left: "seed contents", right: "edited by the fake editor".
  • edit_text_errors_when_the_editor_exits_nonzero: changed the nonzero editor status arm to return the seed text. RUSTC_WRAPPER= cargo test --locked edit_text_errors_when_the_editor_exits_nonzero failed because unwrap_err() received Ok("seed contents").

The exclusions are gone. The diff from origin/main...HEAD has no coverage(off), COV_IGNORE, or COV_MIN changes, and neither src/cli/editor.rs nor src/cli/auth_setup_git.rs is added to COV_IGNORE. The target functions are measured again.

No behavior changed in the two target files. The production definitions of edit_text and run_git_config are byte-identical to the base; the PR changes are under #[cfg(test)].

The tests are hermetic. run_git_config tests serialize process-global env mutation, set GIT_CONFIG_GLOBAL to a temp file, and the real ~/.gitconfig hash stayed 185f04265ad2f48a59749e8a854503c2051820f710d9cba38b09b7aea5575ea4 before and after the suite. edit_text tests serialize $VISUAL / $EDITOR, unset $VISUAL, set $EDITOR to an absolute fake-editor script inside a temp dir or /bin/false, and the fake editor writes only to the temp path passed as $1.

Baseline focused tests pass after restoring mutations:

RUSTC_WRAPPER= cargo test --locked run_git_config
2 passed

RUSTC_WRAPPER= cargo test --locked edit_text
3 passed

PR body and commit message contain no AI trailers. The PR body reports local coverage only as the local strict surface and explicitly says CI is authoritative because of #249. CI is green on the reviewed head:

Combined: success  3 checks on 8021fc7
success  ci / check      Successful in 12m27s
success  ci / live-e2e   Successful in 2m16s
success  ci / coverage   Successful in 2m20s
APPROVE 8021fc7cb2b9f327d87e3f20080c93b75c453cb7 The four added tests are real. I mutated the code each one names and the matching test failed: - `run_git_config_writes_to_the_redirected_global_config`: changed `run_git_config` to run `git config --global --get <key>` instead of writing `<key> <value>`. `RUSTC_WRAPPER= cargo test --locked run_git_config_writes_to_the_redirected_global_config` failed because the test's `unwrap()` saw the nonzero git status. - `run_git_config_reports_a_failing_git_config`: changed the nonzero-status arm in `run_git_config` to return `Ok(())`. `RUSTC_WRAPPER= cargo test --locked run_git_config_reports_a_failing_git_config` failed because `unwrap_err()` received `Ok(())`. - `edit_text_returns_what_the_editor_wrote`: changed `edit_text` to return the seed text instead of reopening the edited temp file. `RUSTC_WRAPPER= cargo test --locked edit_text_returns_what_the_editor_wrote` failed with `left: "seed contents"`, `right: "edited by the fake editor"`. - `edit_text_errors_when_the_editor_exits_nonzero`: changed the nonzero editor status arm to return the seed text. `RUSTC_WRAPPER= cargo test --locked edit_text_errors_when_the_editor_exits_nonzero` failed because `unwrap_err()` received `Ok("seed contents")`. The exclusions are gone. The diff from `origin/main...HEAD` has no `coverage(off)`, `COV_IGNORE`, or `COV_MIN` changes, and neither `src/cli/editor.rs` nor `src/cli/auth_setup_git.rs` is added to `COV_IGNORE`. The target functions are measured again. No behavior changed in the two target files. The production definitions of `edit_text` and `run_git_config` are byte-identical to the base; the PR changes are under `#[cfg(test)]`. The tests are hermetic. `run_git_config` tests serialize process-global env mutation, set `GIT_CONFIG_GLOBAL` to a temp file, and the real `~/.gitconfig` hash stayed `185f04265ad2f48a59749e8a854503c2051820f710d9cba38b09b7aea5575ea4` before and after the suite. `edit_text` tests serialize `$VISUAL` / `$EDITOR`, unset `$VISUAL`, set `$EDITOR` to an absolute fake-editor script inside a temp dir or `/bin/false`, and the fake editor writes only to the temp path passed as `$1`. Baseline focused tests pass after restoring mutations: ```text RUSTC_WRAPPER= cargo test --locked run_git_config 2 passed RUSTC_WRAPPER= cargo test --locked edit_text 3 passed ``` PR body and commit message contain no AI trailers. The PR body reports local coverage only as the local strict surface and explicitly says CI is authoritative because of #249. CI is green on the reviewed head: ```text Combined: success 3 checks on 8021fc7 success ci / check Successful in 12m27s success ci / live-e2e Successful in 2m16s success ci / coverage Successful in 2m20s ```
stephen deleted branch fix/coverage-glue 2026-09-06 19:19:18 +00:00
Sign in to join this conversation.
No description provided.