From 83227137fd0256cf0b18aa773303f2d08edb40b1 Mon Sep 17 00:00:00 2001 From: JSONbored <49853598+JSONbored@users.noreply.github.com> Date: Fri, 17 Jul 2026 02:40:14 -0700 Subject: [PATCH] fix(test): reduce and widen the agent-sdk-driver real-git test's timeout budget The real-git-subprocess test in test/unit/agent-sdk-driver.test.ts (init/config/config/ add/commit against a temp repo, then the driver's own diff enumeration) exceeds its explicit 30s timeout under concurrent full-suite load. Commit identity now goes through GIT_AUTHOR_*/GIT_COMMITTER_* env vars on the commit call instead of two separate `git config` subprocess spawns, cutting setup from 5 sequential git invocations to 3. The remaining spawns still wait on real OS process scheduling under load, so the timeout is also widened to 60s based on repeated measurement under simulated CPU contention (16 processes oversubscribing a 12-core machine): clean single-attempt runs ranged ~0.3-20s, with one outlier at ~54s and none exceeding 60s across 10 runs. --- test/unit/agent-sdk-driver.test.ts | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/test/unit/agent-sdk-driver.test.ts b/test/unit/agent-sdk-driver.test.ts index 763d4ce26c..2f09301a3f 100644 --- a/test/unit/agent-sdk-driver.test.ts +++ b/test/unit/agent-sdk-driver.test.ts @@ -88,19 +88,28 @@ describe("createAgentSdkCodingAgentDriver", () => { }); it("enumerates tracked and untracked worktree changes with git", async () => { - // Real subprocess spawns (init, 2x config, add, commit, plus the driver's own diff enumeration) -- - // legitimately more wall-clock latency than the default 15s test timeout reliably covers under - // concurrent CI shard/system load (observed timing out under heavy parallel contention with no logic - // failure; passes in well under 1s in isolation). An explicit timeout says so instead of relying on - // ambient headroom. + // Real subprocess spawns (init, add, commit, plus the driver's own diff enumeration) -- legitimately + // more wall-clock latency than the default 15s test timeout reliably covers under concurrent CI + // shard/system load (passes in well under 1s in isolation). Commit identity goes through + // GIT_AUTHOR_*/GIT_COMMITTER_* env vars on the commit call instead of two separate `git config` + // subprocess spawns, cutting setup from 5 sequential git invocations to 3 -- but each remaining spawn + // still waits on real OS process-scheduling under load, which a smaller loop-body trim can reduce but + // not eliminate. Reproduced under simulated contention (16 CPU-bound processes oversubscribing a + // 12-core machine): clean single-attempt runs ranged ~0.3-20s, with one run exceeding 30s outright. + // 60s covers the observed range with headroom instead of relying on ambient timing. const dir = await mkdtemp(join(tmpdir(), "gittensory-agent-sdk-")); + const commitEnv = { + ...process.env, + GIT_AUTHOR_NAME: "Test User", + GIT_AUTHOR_EMAIL: "test@example.invalid", + GIT_COMMITTER_NAME: "Test User", + GIT_COMMITTER_EMAIL: "test@example.invalid", + }; try { await execFileAsync("git", ["init"], { cwd: dir }); - await execFileAsync("git", ["config", "user.email", "test@example.invalid"], { cwd: dir }); - await execFileAsync("git", ["config", "user.name", "Test User"], { cwd: dir }); await writeFile(join(dir, "tracked.ts"), "export const value = 1;\n"); await execFileAsync("git", ["add", "tracked.ts"], { cwd: dir }); - await execFileAsync("git", ["commit", "-m", "init"], { cwd: dir }); + await execFileAsync("git", ["commit", "-m", "init"], { cwd: dir, env: commitEnv }); const driver = createAgentSdkCodingAgentDriver({ query: queryYielding([ @@ -119,7 +128,7 @@ describe("createAgentSdkCodingAgentDriver", () => { } finally { await rm(dir, { recursive: true, force: true }); } - }, 30000); + }, 60000); it("derives changed files from the worktree after untracked mutating tools", async () => { const driver = driverWith({