fix: sweep — every sync spawn in the test trees carries a timeout (436 sites, 157 files)

spawnSync/execSync/Bun.spawnSync BLOCK the main thread, so bun's in-process
per-test timeout can never fire while one waits — a hung child (stdin read,
network probe, dead daemon) wedges the whole shard until the runner's
external wall-clock SIGKILL. This exact class reached main: free-tests run
33262077256, test/gstack-memory-ingest.test.ts (normally 2.3s) held shard 2
at the 360s wall while its five siblings finished in ~65s.

Mechanical sweep in two waves (12 + 4 fan-out agents, every edit verified
against its call site): default timeout: 30_000 (matches the free runner's
per-test budget), 120_000 for genuinely slow ops (installs, builds,
playwright, provider CLIs), helper wrappers fixed ONCE where call sites
route through them. Sites that only LOOK like calls (string fixtures, grep
needles, comments) were skipped with reasons — the enforcement commit that
follows marks them exempt.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-08-31 04:49:57 +00:00
co-authored by Claude Fable 5
parent 79efe395dc
commit 3e674e4c01
139 changed files with 451 additions and 331 deletions
+26 -26
View File
@@ -137,7 +137,7 @@ describe("gstack-gbrain-sync CLI", () => {
const repo = mkdtempSync(join(tmpdir(), "gstack-pinned-source-repo-"));
const commandLog = join(home, "gbrain-commands.log");
mkdirSync(gstackHome, { recursive: true });
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo, timeout: 30_000 });
writeFileSync(join(repo, ".gbrain-source"), "client-acme-app\n");
writeFileSync(join(bindir, "gbrain"), `#!/bin/sh
printf '%s\\n' "$*" >> "$GSTACK_TEST_GBRAIN_LOG"
@@ -179,7 +179,7 @@ exit 99
mkdirSync(gstackHome, { recursive: true });
mkdirSync(join(home, ".gbrain"), { recursive: true });
writeFileSync(join(home, ".gbrain", "config.json"), JSON.stringify({ engine: "pglite", database_url: "pglite:///test" }));
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo, timeout: 30_000 });
writeFileSync(join(repo, ".gbrain-source"), "client-acme-app\n");
symlinkSync(repo, link, "dir");
writeFileSync(join(bindir, "gbrain"), `#!/bin/sh
@@ -223,7 +223,7 @@ esac
const bindir = mkdtempSync(join(tmpdir(), "gstack-pinned-dream-bin-"));
const repo = mkdtempSync(join(tmpdir(), "gstack-pinned-dream-repo-"));
mkdirSync(gstackHome, { recursive: true });
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo, timeout: 30_000 });
writeFileSync(join(repo, ".gbrain-source"), "client-acme-app\n");
writeFileSync(join(bindir, "gbrain"), "#!/bin/sh\nexit 99\n");
chmodSync(join(bindir, "gbrain"), 0o755);
@@ -247,7 +247,7 @@ esac
const gstackHome = join(home, ".gstack");
const repo = mkdtempSync(join(tmpdir(), "gstack-unreadable-pin-repo-"));
mkdirSync(gstackHome, { recursive: true });
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo, timeout: 30_000 });
mkdirSync(join(repo, ".gbrain-source"));
const r = spawnSync("bun", [SCRIPT, "--dry-run", "--code-only", "--quiet"], {
@@ -282,8 +282,8 @@ esac
const gstackHome = join(home, ".gstack");
mkdirSync(gstackHome, { recursive: true });
const repo = mkdtempSync(join(tmpdir(), "gstack-source-id-repo-"));
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
spawnSync("git", ["remote", "add", "origin", remote], { cwd: repo });
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo, timeout: 30_000 });
spawnSync("git", ["remote", "add", "origin", remote], { cwd: repo, timeout: 30_000 });
const r = spawnSync("bun", [SCRIPT, "--dry-run", "--code-only", "--quiet"], {
encoding: "utf-8",
@@ -312,7 +312,7 @@ esac
const gstackHome = join(home, ".gstack");
mkdirSync(gstackHome, { recursive: true });
const repo = mkdtempSync(join(tmpdir(), "gstack-no-origin-"));
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo, timeout: 30_000 });
// No `git remote add origin` — this is the no-remote case.
const r = spawnSync("bun", [SCRIPT, "--dry-run", "--code-only", "--quiet"], {
@@ -347,7 +347,7 @@ esac
const parent = mkdtempSync(join(tmpdir(), "gstack-empty-base-"));
const repo = join(parent, "___");
mkdirSync(repo);
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo, timeout: 30_000 });
// No `origin` remote — forces the basename-fallback path.
const r = spawnSync("bun", [SCRIPT, "--dry-run", "--code-only", "--quiet"], {
@@ -381,8 +381,8 @@ esac
const gstackHome = join(home, ".gstack");
mkdirSync(gstackHome, { recursive: true });
const repo = mkdtempSync(join(tmpdir(), "gstack-host-collide-"));
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
spawnSync("git", ["remote", "add", "origin", "https://github.com/example/multihost.git"], { cwd: repo });
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo, timeout: 30_000 });
spawnSync("git", ["remote", "add", "origin", "https://github.com/example/multihost.git"], { cwd: repo, timeout: 30_000 });
// Dry-run still gates the code stage on `command -v gbrain`. Drop a no-op
// shim on PATH so the stage runs (we only assert the preview line, never
@@ -569,8 +569,8 @@ esac
const repoA = mkdtempSync(join(tmpdir(), "gstack-worktree-a-"));
const repoB = mkdtempSync(join(tmpdir(), "gstack-worktree-b-"));
for (const repo of [repoA, repoB]) {
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
spawnSync("git", ["remote", "add", "origin", remote], { cwd: repo });
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo, timeout: 30_000 });
spawnSync("git", ["remote", "add", "origin", remote], { cwd: repo, timeout: 30_000 });
}
const idOf = (cwd: string): string => {
@@ -606,8 +606,8 @@ esac
const gstackHome = join(home, ".gstack");
mkdirSync(gstackHome, { recursive: true });
const repo = mkdtempSync(join(tmpdir(), "gstack-worktree-stable-"));
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
spawnSync("git", ["remote", "add", "origin", remote], { cwd: repo });
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo, timeout: 30_000 });
spawnSync("git", ["remote", "add", "origin", remote], { cwd: repo, timeout: 30_000 });
const idOf = (): string => {
const r = spawnSync("bun", [SCRIPT, "--dry-run", "--code-only", "--quiet"], {
@@ -635,8 +635,8 @@ esac
const gstackHome = join(home, ".gstack");
mkdirSync(gstackHome, { recursive: true });
const repo = mkdtempSync(join(tmpdir(), "gstack-legacy-cleanup-"));
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
spawnSync("git", ["remote", "add", "origin", "https://github.com/garrytan/gstack.git"], { cwd: repo });
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo, timeout: 30_000 });
spawnSync("git", ["remote", "add", "origin", "https://github.com/garrytan/gstack.git"], { cwd: repo, timeout: 30_000 });
const r = spawnSync("bun", [SCRIPT, "--dry-run", "--code-only", "--quiet"], {
encoding: "utf-8",
@@ -671,8 +671,8 @@ esac
const gstackHome = join(home, ".gstack");
mkdirSync(gstackHome, { recursive: true });
const repo = mkdtempSync(join(tmpdir(), "gstack-attach-preview-"));
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
spawnSync("git", ["remote", "add", "origin", "https://github.com/garrytan/gstack.git"], { cwd: repo });
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo, timeout: 30_000 });
spawnSync("git", ["remote", "add", "origin", "https://github.com/garrytan/gstack.git"], { cwd: repo, timeout: 30_000 });
const r = spawnSync("bun", [SCRIPT, "--dry-run", "--code-only", "--quiet"], {
encoding: "utf-8",
@@ -727,8 +727,8 @@ describe("derivePathOnlyHashLegacyId", () => {
// legacy id regardless of $GSTACK_HOSTNAME, because the pre-#1468 hash
// didn't include hostname.
const repo = mkdtempSync(join(tmpdir(), "gstack-legacy-id-"));
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
spawnSync("git", ["remote", "add", "origin", "https://github.com/example/legacy-test.git"], { cwd: repo });
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo, timeout: 30_000 });
spawnSync("git", ["remote", "add", "origin", "https://github.com/example/legacy-test.git"], { cwd: repo, timeout: 30_000 });
const cwd = process.cwd();
try {
@@ -754,8 +754,8 @@ describe("derivePathOnlyHashLegacyId", () => {
// host-fold id must differ for any non-empty hostname, so the migration
// can detect + clean up the orphan.
const repo = mkdtempSync(join(tmpdir(), "gstack-legacy-id-distinct-"));
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
spawnSync("git", ["remote", "add", "origin", "https://github.com/example/distinct.git"], { cwd: repo });
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo, timeout: 30_000 });
spawnSync("git", ["remote", "add", "origin", "https://github.com/example/distinct.git"], { cwd: repo, timeout: 30_000 });
const cwd = process.cwd();
try {
@@ -890,10 +890,10 @@ describe("constrainSourceId truncation (hyphen-boundary cut)", () => {
const gstackHome = join(home, ".gstack");
mkdirSync(gstackHome, { recursive: true });
const repo = mkdtempSync(join(tmpdir(), "gstack-hyphen-cut-"));
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo, timeout: 30_000 });
// Remote chosen to be long enough that constrainSourceId truncates and
// the boundary lands inside the word `skill`.
spawnSync("git", ["remote", "add", "origin", "https://github.com/drummerms-av-sow-wiz/skill-270c0001.git"], { cwd: repo });
spawnSync("git", ["remote", "add", "origin", "https://github.com/drummerms-av-sow-wiz/skill-270c0001.git"], { cwd: repo, timeout: 30_000 });
const r = spawnSync("bun", [SCRIPT, "--dry-run", "--code-only", "--quiet"], {
encoding: "utf-8",
@@ -924,8 +924,8 @@ describe("constrainSourceId truncation (hyphen-boundary cut)", () => {
const gstackHome = join(home, ".gstack");
mkdirSync(gstackHome, { recursive: true });
const repo = mkdtempSync(join(tmpdir(), "gstack-https-period-"));
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo });
spawnSync("git", ["remote", "add", "origin", "https://github.com/foo/bar.git"], { cwd: repo });
spawnSync("git", ["init", "--quiet", "-b", "main"], { cwd: repo, timeout: 30_000 });
spawnSync("git", ["remote", "add", "origin", "https://github.com/foo/bar.git"], { cwd: repo, timeout: 30_000 });
const r = spawnSync("bun", [SCRIPT, "--dry-run", "--code-only", "--quiet"], {
encoding: "utf-8",