Skip to content

fix(#63): eliminate the ~2s whole-repo TS-service build in AgentRunner tests (pre-validate false-BLOCK)#171

Open
agjs wants to merge 4 commits into
mainfrom
fix/flaky-test-timeout
Open

fix(#63): eliminate the ~2s whole-repo TS-service build in AgentRunner tests (pre-validate false-BLOCK)#171
agjs wants to merge 4 commits into
mainfrom
fix/flaky-test-timeout

Conversation

@agjs

@agjs agjs commented Jul 22, 2026

Copy link
Copy Markdown
Owner

What

The harness-review pre-review gate runs the full bun run validate and BLOCKs review on any non-zero exit. Under full-suite concurrency its bun test packages phase spuriously timed out, false-BLOCKing every review — even a twice-PASSed diff (observed on PR #170's branch: 9 timeout "fails" blocked a clean change). This is issue #63.

Root cause

AgentRunner.run calls buildTsService(cwd) when no tsService is passed. agent-runner.test.ts runs the agent against the whole tsforge repo (cwd: REPO), so every test built a TypeScript service over the entire project — ~2s per test, even the immediate-abort / no-op cases. In isolation the file ran ~24.6s (~1.8s/test), under bun's 5000ms default; under 273-file CPU contention that startup inflated past 5s → spurious timeouts.

Fix (at the root — no gate change)

  • Pass tsService: null on every run() in agent-runner.test.ts (as many sibling tests already do). These read-only tests exercise tool-gating / events / maxTurns / abort / policy / structured-mode — none use the type-aware tools (type_at/diagnostics) — so a null service is faithful and removes the cost at the source. File drops ~24.6s → ~0.4s; every test is far under the 5s default.
  • Split the pure parseAgentSpec/loadAgentSpecs config tests into agent-specs.test.ts (they don't construct AgentRunner; they belong in their own fast file).

No timeout was raisedsetDefaultTimeout is not used. Nothing is relaxed; bun's 5s fail-fast default and its infinite-loop detection stay intact for every file. The full bun run validate gate is unchanged.

Review

  • harness-review panel: PASS, 4/4 reviewers, zero findings. The panel earned its keep across the iteration: it rejected two earlier gate-relaxing attempts (a global --timeout bump, then a file-scoped one) and caught an incomplete replace_all that left two structured-mode runs unstubbed — all fixed here.
  • 14 tests unchanged (11 AgentRunner + 3 config), all green; typecheck / lint / format clean.

agjs added 4 commits July 22, 2026 21:45
Follow-up to the panel's review of the global timeout bump (major/gate-relaxed,
agreement:1 across reviewers): a suite-wide 30s ceiling weakened fail-fast for
ALL 273 files, not just the load-sensitive integration tests, and could let an
unrelated regression that overshoots 5s pass.

Root cause (measured): every test in agent-runner.test.ts constructs
`new AgentRunner(...).run({ cwd: REPO })`, which pays a fixed ~2s startup cost
against the real repo — even the immediate-abort / no-op cases. In isolation the
file runs ~1.9s/test, under bun's 5000ms default; only under the full suite's
273-file concurrency does CPU contention inflate that startup past 5s, spuriously
timing out and false-BLOCKing the harness-review pre-validate gate.

Fix: setDefaultTimeout(15_000) at the top of agent-runner.test.ts — module-scoped,
so ONLY this file's ceiling rises. The 5s fail-fast default and its infinite-loop
detection stay intact for the other 272 files. 15s is generous margin over the
real ~2s work under contention while still failing a genuine hang here. Gate
stays FULL; not a relaxation.
…ly AgentRunner tests

Follow-up to the panel's finding (major/gate-relaxed, agreement:1): file-scoped
setDefaultTimeout(15s) also raised the ceiling for the parseAgentSpec and
loadAgentSpecs tests, which do NOT construct AgentRunner — over-broadening the
relaxation and contradicting the comment's 'every test here' claim.

Move those pure config-spec tests to a new agent-specs.test.ts (they belong
there anyway — fast, hermetic, no repo). agent-runner.test.ts now contains ONLY
AgentRunner-against-repo tests, so setDefaultTimeout(15_000) is precisely scoped
to exactly the load-sensitive tests; every other file (including the moved
config tests) keeps bun's 5s fail-fast default. Comment corrected to match.

14 tests unchanged (11 AgentRunner + 3 config), all green; typecheck/lint/format clean.
… service) — no timeout change

Panel BLOCK on the scoped timeout (major/gate-relaxed): a reviewer held that ANY
raised ceiling lets a 5-15s regression in these tests pass — a relaxation, even
scoped. They're right that the timeout was treating a symptom.

Root cause (found): AgentRunner.run calls buildTsService(cwd) when no tsService
is passed. With cwd: REPO that builds a TypeScript service over the ENTIRE tsforge
repo — ~2s PER test — even for immediate-abort / no-op cases. That fixed cost, not
the loop work, blew bun's 5s default under full-suite CPU contention.

Fix at the root: pass tsService: null in every run() here (as many sibling tests
already do). These read-only tests exercise tool-gating / events / maxTurns /
abort / policy — none use the type-aware tools — so a null service is faithful.
Result: the file drops from ~24.6s to ~5.3s (11 tests), every test well under the
5s fail-fast default. setDefaultTimeout REMOVED entirely — NO timeout change, so
nothing is relaxed; fail-fast + infinite-loop detection are fully intact.

(Pure config tests remain split into agent-specs.test.ts from the prior step.)
…all missed + fix stale comment

Panel caught (agreement:1, major): the two structured-mode tests use the
single-line .run({ provider, cwd: REPO, ... }) form, which my cwd:REPO-line
replace_all didn't match — so they still called buildTsService(REPO) (~2s) and
the 'every run passes tsService: null' comment was false. Add tsService: null to
both; now EVERY run() is stubbed (file ~24.6s -> ~0.4s). Also fix the stale
agent-specs.test.ts header comment that referenced a 'raised per-file timeout'
(removed in this PR). All 11 AgentRunner + 3 config tests green; typecheck/lint/format clean.
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.

1 participant