Skip to content

test(dry-run): stop git background maintenance from racing the tree snapshot - #845

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
SaulMoro:test/dry-run-load-path-flake
Sep 26, 2026
Merged

jeff-r2026 merged 1 commit into
Tencent:mainfrom
SaulMoro:test/dry-run-load-path-flake

Conversation

@SaulMoro

Copy link
Copy Markdown
Collaborator

Summary

dry-run-load-path.test.ts (#837) hashes the whole fixture tree, runs a --dry-run command, and asserts the tree is unchanged. It failed on macOS / Node 22 in CI run 36241761063 (PR #838). The only diff was this line:

-   "app/.git/objects/maintenance.lock": "e3b0c442…",

Cause: the fixture's git commit starts a detached git maintenance run --auto, which takes .git/objects/maintenance.lock. The lock was there when the baseline was taken and gone when the second snapshot ran. The CLI wrote nothing. On local git 2.55 the lock exists straight after git commit in 20 of 20 fresh repos, and in 0 of 20 once the two configs below are set.

 setupSelfModeClone / setupLegacyNamedPartition
-  git init
+  gitInit(dir)                 # git init + maintenance.auto=false + gc.auto=0
 snapshotTree
   skip home/.teamai/debug.log
+  skip *.lock and gc.pid under a .git dir

The first change fixes the cause: nothing starts in the background. The second guards against any git process that still runs anyway. It skips only git's transient lock files, so a real write to .git/config, hooks or refs still fails the test. No other test snapshots a tree that holds a real git repo. contribute.test.ts mocks git, and the doctor tests list tool directories.

Refs #836.

Evidence

  • Before: the CI failure above: --dry-run on a fresh self-mode clone > roles set writes no file…, at dry-run-load-path.test.ts:161.
    After:
    • for i in $(seq 30); do npx vitest run src/__tests__/dry-run-load-path.test.ts || break; done: 30/30 passed.
    • npx vitest run: 5122 passed, 1 skipped.
    • npx tsc --noEmit is clean, and npm run lint passes with 0 warnings.
  • Guard still works: a throwaway copy of the test that appends to app/.git/config and creates app/.git/probe.lock before the command fails on the app/.git/config hash. It does not report probe.lock.

Tests only, so no real-CLI record (CLAUDE.md).

Merge Danger

Door: two-way

Blast Radius: none

Only one test file changes.

@jeff-r2026 jeff-r2026 self-assigned this Sep 26, 2026
@jeff-r2026
jeff-r2026 self-requested a review September 26, 2026 13:11
@github-actions

Copy link
Copy Markdown

No findings.

The tests-only classification is accurate, so the PR does not require a real-CLI/e2e record under the repository’s review rules. The documented test, type-check, and lint evidence is sufficient. The maintenance.auto=false mitigation also matches Git’s documented mechanism for disabling foreground automatic maintenance. (git-scm.com)

@jeff-r2026
jeff-r2026 merged commit c7e9f90 into Tencent:main Sep 26, 2026
11 checks passed
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.

2 participants