Skip to content

Turn off git auto maintenance in every scenario - #268

Merged
JacobStephens2 merged 6 commits into
mainfrom
issue-263
Oct 1, 2026
Merged

JacobStephens2 merged 6 commits into
mainfrom
issue-263

Conversation

@JacobStephens2

@JacobStephens2 JacobStephens2 commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

Every scenario's gitconfig now turns git's auto maintenance off, so no git command in a scenario (by thirdshift, a fake, or a script) leaves a background writer behind.

 home/.gitconfig   (written by write_gitconfig for every Scenario)
   [user]         name, email
   [init]         defaultBranch = main
+  [maintenance]  auto = false
+  [gc]           auto = 0        # for a git too old to know maintenance.auto
   [url "<origin.git>"]  insteadOf = https://github.com/acme/widgets.git

A comment on write_gitconfig explains the race. The base_moves_on scripts and src/ are untouched.

Seam tested: Scenario (the harness's public interface), through launch_git, in tests/harness.rs.

Was the cause confirmed on git 2.47 or later?

Partly. Background maintenance is confirmed as a writer that outlives its command and breaks the clone-and-delete script on git 2.55, and the setting stops it. The exact rm: ... Directory not empty from the CI run was not reproduced, so that symptom is still inferred.

These measurements are from the first Run on this branch, which built git 2.51.0 and 2.55.0 from source (the machine has 2.43.0) and looped the base_moves_on script (clone, commit, push, rm -rf) under bash -e against a bare origin with the scenario's gitconfig. The builds were deleted afterwards, and the loops were not repeated in the Run that wrote this body.

git setting failed loops
2.55.0 without 5 of 1,800
2.55.0 with 0 of 1,800
2.51.0 without 0 of 300
2.51.0 with 0 of 300
2.43.0 without 0 of 300
  • All 5 failures were the next loop's git clone losing a race with the origin's maintenance after the push, not the rm -rf: fatal: failed to copy file to '<clone>/.git/objects/42/c8bb…': No such file or directory (4 on loose objects, 1 on objects/bitmap-ref-tips_…).
  • GIT_TRACE=1 on 2.51 shows git maintenance run --auto --quiet --detach started after a commit and on the receiving side of a push; with maintenance.auto=false it is not started.
  • A second loop with no push (clone, commit, rm -rf only) did not fail in 1,500 loops on 2.55 either way, so the clone's own maintenance racing rm -rf was not seen.

Evidence

  • Before: a_scenarios_gitconfig_turns_auto_maintenance_off fails: git ["config", "--get", "maintenance.auto"] failed
    After: it passes, asserting maintenance.auto is false and gc.auto is 0 with the scenario's HOME.
  • cargo test at the branch head, merged with main at 9b65352: 29 test binaries, 625 passed, 0 failed, on git 2.43.0. No test was weakened, skipped or retried. cargo fmt --check and cargo clippy --all-targets are clean.
  • The first Run also reported one full pass with git 2.55.0 first on PATH; that was not repeated here.
  • The earlier red test and test-macos checks on this PR were the_binary_never_links_openssl in tests/packaging.rs, which failed on main at 362b9ca too. main is green again and is merged into the branch.

Unaddressed findings

Addressed from this review: the write_gitconfig comment stated the rm -rf failure as fact; it now leads with the re-clone failure that was seen and says the rm -rf one "can" happen. The tests/harness.rs header now names the harness as its one subject, with the waits and the gitconfig under it.

Standards

  • Possible Duplicated Code: the two setting/value pairs appear in both the test and write_gitconfig. Skipped: the test's literals are its independent statement of what to expect; a shared constant would make it pass by construction. The reviewer advised against acting on it too.
  • (earlier review) The test reads the settings back rather than observing that no maintenance starts. Skipped: the race is not observable on the git 2.43 the suite runs on locally, and was a 1-in-360 event even on 2.55. The test is named for what it checks.
  • (earlier review) "a script" in the write_gitconfig comment is looser than "the fake agent's script". Skipped: the scripts at issue are also run by the fake gh's hooks (on_ci_read), so the narrower term would be wrong.

Spec

  • git_output sets HOME but does not clear the environment, so a GIT_CONFIG_GLOBAL or GIT_CONFIG_COUNT exported in a developer's shell would replace the scenario's gitconfig for the harness's own git calls. Skipped: predates this change, does not affect CI, and would bypass the identity and the insteadOf rule too. thirdshift, the fakes and their scripts run with a cleared environment and are covered.
  • tests/update.rs runs thirdshift update with HOME set to an empty directory. Skipped: predates this change; that test expects a refusal before any git command and has no clone-and-delete script.
  • tests/release.rs, tests/site_deploy.rs and the unit tests in src/git.rs and src/worktree.rs build repositories with GIT_CONFIG_GLOBAL=/dev/null and no Scenario, so auto maintenance stays on there. Skipped: the reviewer raised it as outside the spec, which scopes the change to the gitconfig the harness writes for every scenario. It is the same hazard class and may deserve its own issue if those tests ever flake this way.

Merge Danger

Door: two-way

Test harness only; reverting is one commit.

Blast Radius: tests

Repositories in scenarios never auto-pack. They live for one test, so nothing depends on it.

Closes #263

🤖 Generated with Claude Code

JacobStephens2 and others added 4 commits October 1, 2026 13:12
A newer git detaches auto maintenance into the background after a
commit, where it can still write into .git/objects once the command has
returned. A test script that then deletes its temporary clone, or clones
the origin again, races it.

Closes #263

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on main at 362b9ca; fix main first)

2026-10-01T13:25:01Z, host thirdshift. Uncommitted work at the time of failure is included in this commit.
JacobStephens2 and others added 2 commits October 1, 2026 17:21
…seen, the harness tests' header for both subjects

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JacobStephens2
JacobStephens2 marked this pull request as ready for review October 1, 2026 17:44
@JacobStephens2
JacobStephens2 merged commit 0582aa0 into main Oct 1, 2026
14 checks passed
@JacobStephens2
JacobStephens2 deleted the issue-263 branch October 1, 2026 17:50
@JacobStephens2 JacobStephens2 mentioned this pull request Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

End-to-end tests that delete a temporary clone fail intermittently on newer git

1 participant