Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test(e2e): large worktree fixtures stop racing a detached git gc --auto
garrytan4d35f532aa64
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c908cf46b5..0068a696c8 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,12 @@ credits are retained; no result has been reassigned to another provider. Originaidentifiers and attribution are available in the pre-removal Git revision`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).+## [0.60.83.0] - 2026-10-06++**The 12k-file clone fixture no longer races a background `git gc`, so the large-manifest clone test stops failing with git exit 128.**++The fixture committed 12,000 files as loose objects, and that commit started a detached `git gc --auto`. The gc packed the objects and deleted the loose copies while the fixture's `git clone --bare` was still copying them, so the clone died with `failed to copy file ... No such file or directory`. On a loaded CI VM the overlap was common enough to fail the full gate. Large fixture repositories now turn off automatic gc and maintenance in their own config before the first commit, so no background job touches them while a test clones, reads or deletes them. The same change covers the 20k-file CLI ceilings fixture and the 12k-file read-only mirror fixture. Fixture git failures now include git's stderr instead of a bare exit status.+## [0.60.82.0] - 2026-10-06**Sync lanes that start at the same moment share the worktree lock instead of all but one reporting it busy, so a clean catch-up no longer falls back to slower paths mid-run (#5984).**diff --git a/test/fix-wave-5-integration.test.ts b/test/fix-wave-5-integration.test.tsindex 95445c1857..9289cb5cb2 100644--- a/test/fix-wave-5-integration.test.ts+++ b/test/fix-wave-5-integration.test.ts@@ -315,7 +315,7 @@ for (const backend of testBackends()) {writeFileSync(join(root, 'TODOS.md'), '# Todos\n\n- keep the mirror pullable\n');mkdirSync(join(root, 'journal'));for (const day of ['2026-09-29', '2026-09-30']) writeFileSync(join(root, 'journal', `${day}.md`), `# ${day}\n\nA journal entry without frontmatter.\n`);- git('init', '-q'); commit('upstream');+ git('init', '-q'); git('config', 'gc.auto', '0'); git('config', 'maintenance.auto', 'false'); commit('upstream');const tracked = () => git('status', '--porcelain', '--untracked-files=no');await registerLocalWriter(engine, 'cli');diff --git a/test/git-fixture-maintenance.test.ts b/test/git-fixture-maintenance.test.tsindex b2ebc19f27..d39c437acc 100644--- a/test/git-fixture-maintenance.test.ts+++ b/test/git-fixture-maintenance.test.ts@@ -4,12 +4,8 @@ import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'nodimport { tmpdir } from 'node:os';import { join, resolve } from 'node:path';-test('Git fixtures suppress automatic maintenance from their first commit onward', () => {- const root = mkdtempSync(join(tmpdir(), 'git-fixture-maintenance-'));- const repo = join(root, 'repo');- const trace = join(root, 'trace.jsonl');+function hermeticGitEnv(root: string, trace: string): Record<string, string> {const globalConfig = join(root, 'global.gitconfig');- mkdirSync(repo);writeFileSync(globalConfig, '');const env: Record<string, string> = {GIT_CONFIG_NOSYSTEM: '1', GIT_CONFIG_GLOBAL: globalConfig,@@ -19,6 +15,15 @@ test('Git fixtures suppress automatic maintenance from their first commit onwardfor (const key of ['PATH', 'SystemRoot', 'SYSTEMROOT', 'WINDIR', 'PATHEXT', 'TEMP', 'TMP']) {if (process.env[key]) env[key] = process.env[key]!;}+ return env;+}++test('Git fixtures suppress automatic maintenance from their first commit onward', () => {+ const root = mkdtempSync(join(tmpdir(), 'git-fixture-maintenance-'));+ const repo = join(root, 'repo');+ const trace = join(root, 'trace.jsonl');+ const env = hermeticGitEnv(root, trace);+ mkdirSync(repo);try {const script = `import { makeGitFixture } from ${JSON.stringify(resolve(import.meta.dir, 'helpers/git-fixture.ts'))};@@ -42,3 +47,29 @@ test('Git fixtures suppress automatic maintenance from their first commit onwardrmSync(root, { recursive: true, force: true });}}, 30000);++test('large worktree fixtures commit without starting background gc before they are cloned', () => {+ const root = mkdtempSync(join(tmpdir(), 'large-worktree-maintenance-'));+ const trace = join(root, 'trace.jsonl');+ const env = hermeticGitEnv(root, trace);+ try {+ const script = `+ import { largeBareRepository } from ${JSON.stringify(resolve(import.meta.dir, 'helpers/large-worktree.ts'))};+ largeBareRepository(${JSON.stringify(root)}, 20);+ `;+ const result = Bun.spawnSync([process.execPath, '--no-env-file', '-e', script], {+ env, stdout: 'pipe', stderr: 'pipe',+ });+ expect({ exitCode: result.exitCode, stderr: result.stderr.toString() }).toEqual({ exitCode: 0, stderr: '' });+ const events = readFileSync(trace, 'utf8').trim().split('\n').map(line => JSON.parse(line));+ const children = events.filter(event => event.event === 'child_start');+ expect(children.filter(event => event.argv?.some((arg: string) => arg === 'maintenance' || arg === 'gc'))).toEqual([]);+ const work = join(root, 'bare-work');+ for (const [key, value] of [['maintenance.auto', 'false'], ['gc.auto', '0']] as const) {+ expect(execFileSync('git', ['-C', work, 'config', '--local', '--get', key], { env, encoding: 'utf8' }).trim()).toBe(value);+ }+ expect(execFileSync('git', ['-C', join(root, 'large.git'), 'rev-list', '--count', 'HEAD'], { env, encoding: 'utf8' }).trim()).toBe('1');+ } finally {+ rmSync(root, { recursive: true, force: true });+ }+}, 30000);diff --git a/test/helpers/large-worktree.ts b/test/helpers/large-worktree.tsindex b63bc70ee8..d7455fd998 100644--- a/test/helpers/large-worktree.ts+++ b/test/helpers/large-worktree.ts@@ -19,15 +19,27 @@ export function writeLargeWorktree(root: string, count: number): number {return bytes;}+/**+ * Commits `root` as a fixture repository. Automatic gc and maintenance are off in the repository's own+ * config: a commit of ~7k+ loose objects otherwise starts a detached `git gc --auto` that packs and prunes+ * them while the test clones, reads or deletes the repository (a local clone then dies with+ * "failed to copy file ... No such file or directory"). Git's stderr is kept for the thrown error.+ */+export function commitFixtureRepository(root: string): void {+ const git = (args: string[]) => execFileSync('git', ['-c', '[email protected]', '-c', 'user.name=t', ...args], { cwd: root, stdio: ['ignore', 'ignore', 'pipe'] });+ git(['init', '--quiet']);+ git(['config', 'gc.auto', '0']);+ git(['config', 'maintenance.auto', 'false']);+ git(['add', '-A']);+ git(['commit', '--quiet', '-m', 'fixture']);+}+/** Commits a large worktree and returns a local bare repository cloned from it. */export function largeBareRepository(directory: string, count: number): string {const work = join(directory, 'bare-work'), bare = join(directory, 'large.git');mkdirSync(work, { recursive: true });writeLargeWorktree(work, count);- const git = (cwd: string, args: string[]) => execFileSync('git', ['-c', '[email protected]', '-c', 'user.name=t', ...args], { cwd, stdio: 'ignore' });- git(work, ['init', '--quiet']);- git(work, ['add', '-A']);- git(work, ['commit', '--quiet', '-m', 'fixture']);- git(directory, ['clone', '--quiet', '--bare', work, bare]);+ commitFixtureRepository(work);+ execFileSync('git', ['clone', '--quiet', '--bare', work, bare], { cwd: directory, stdio: ['ignore', 'ignore', 'pipe'] });return bare;}diff --git a/test/large-brain-ceilings.test.ts b/test/large-brain-ceilings.test.tsindex 62fd88d677..7da2a2a21a 100644--- a/test/large-brain-ceilings.test.ts+++ b/test/large-brain-ceilings.test.ts@@ -18,22 +18,18 @@* waiting an hour.*/import { afterAll, beforeAll, describe, expect, test } from 'bun:test';-import { execFileSync } from 'node:child_process';import { mkdtempSync, rmSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { runCli } from './helpers/cli-spawn.ts';-import { writeLargeWorktree } from './helpers/large-worktree.ts';+import { commitFixtureRepository, writeLargeWorktree } from './helpers/large-worktree.ts';const LARGE_CHECKOUT_FILES = 20_000;const KEYS = { OPENAI_API_KEY: undefined, ANTHROPIC_API_KEY: undefined, VOYAGE_API_KEY: undefined };function commitWorktree(root: string, files: number): void {writeLargeWorktree(root, files);- const git = (args: string[]) => execFileSync('git', ['-c', '[email protected]', '-c', 'user.name=t', ...args], { cwd: root, stdio: 'ignore' });- git(['init', '--quiet']);- git(['add', '-A']);- git(['commit', '--quiet', '-m', 'fixture']);+ commitFixtureRepository(root);}let dir: string;diff --git a/test/persistence-large-manifest.test.ts b/test/persistence-large-manifest.test.tsindex a7935e465e..a127e84941 100644--- a/test/persistence-large-manifest.test.ts+++ b/test/persistence-large-manifest.test.ts@@ -98,7 +98,7 @@ for (const backend of testBackends()) describe(`large worktree manifests (${backtest('a 12k-file repository clones and reclones from a local bare repository', () => fixture(async home => {const bare = largeBareRepository(home, FILES);const target = join(home, 'cloned');- const clone = async (_url: string, stage: string) => { execFileSync('git', ['clone', '--quiet', bare, stage], { stdio: 'ignore' }); };+ const clone = async (_url: string, stage: string) => { execFileSync('git', ['clone', '--quiet', bare, stage], { stdio: ['ignore', 'ignore', 'pipe'] }); };const principal = await topologyPrincipal(engine);const add = { operation: 'add' as const, sourceId: 'large-clone', path: target, remoteUrl: REMOTE, requestId: randomUUID() };expect(await runManagedSourceClone(engine, add, principal, add.requestId, { ...add, requestId: undefined, dryRun: undefined }, { clone }))@@ -114,7 +114,7 @@ for (const backend of testBackends()) describe(`large worktree manifests (${backtest('a legacy manifest with a per-file map past 1 MiB is accepted by reclone recovery and compacted', () => fixture(async home => {const bare = largeBareRepository(home, 20);const target = join(home, 'cloned');- const clone = async (_url: string, stage: string) => { execFileSync('git', ['clone', '--quiet', bare, stage], { stdio: 'ignore' }); };+ const clone = async (_url: string, stage: string) => { execFileSync('git', ['clone', '--quiet', bare, stage], { stdio: ['ignore', 'ignore', 'pipe'] }); };const principal = await topologyPrincipal(engine);const add = { operation: 'add' as const, sourceId: 'legacy-clone', path: target, remoteUrl: REMOTE, requestId: randomUUID() };await runManagedSourceClone(engine, add, principal, add.requestId, { ...add, requestId: undefined, dryRun: undefined }, { clone });