Skip to content

fix(test): reduce and widen the agent-sdk-driver real-git test timeout - #6871

Merged
JSONbored merged 1 commit into
mainfrom
worktree-agent-sdk-driver-flake
Jul 17, 2026
Merged

fix(test): reduce and widen the agent-sdk-driver real-git test timeout#6871
JSONbored merged 1 commit into
mainfrom
worktree-agent-sdk-driver-flake

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • test/unit/agent-sdk-driver.test.ts's real-git-subprocess test (enumerates tracked and untracked worktree changes with git) spawns git init, two git config calls, git add, git commit, and the driver's own diff enumeration (two more, parallelized) against a real temp repo.
  • Under concurrent full-suite load this reliably exceeded its existing explicit 30s timeout (added previously in commit 534dad77 alongside the sibling fix now being applied to test/unit/ai-summaries.test.ts in a separate PR).
  • 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 across 10 runs, with one outlier at ~54s and none exceeding 60s.
  • Discovered as a byproduct of investigating and fixing an unrelated flaky-test report (test/unit/ai-summaries.test.ts, separate PR) -- both tests were widened in the same historical commit for the same reason, and a full-suite verification run for that fix surfaced this one still flaking.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves -- not applicable; this is a maintainer-authored test-reliability fix discovered during unrelated work, not a contributor PR under the linked-issue policy.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally -- test-only change to test/**, which Codecov does not measure, so there is no patch-coverage obligation.
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries -- not applicable; no production code changed.

Additional validation beyond the standard checklist: the fixed test was run 10x under simulated heavy CPU contention (16 CPU-bound processes oversubscribing a 12-core machine) with zero outright failures (see timing data above). A full local npm run test:ci run also passed this file cleanly (agent-sdk-driver.test.ts, 9.3s, no retry needed), though that run also showed test/unit/ai-summaries.test.ts failing (expected -- its fix lives in a separate, not-yet-merged PR; this worktree branched before that fix existed) and surfaced two additional, unrelated flakes (test/unit/github-labels.test.ts, test/unit/github-pr-actions.test.ts) that only appeared while two full 18k-test suites were running concurrently on the same machine -- self-inflicted, unrealistic contention well beyond normal CI conditions. Flagging separately rather than expanding this PR's scope further.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics. (Not applicable -- test-only change.)
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests. (Not applicable -- no such changes.)
  • API/OpenAPI/MCP behavior is updated and tested where needed. (Not applicable -- no such changes.)
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks. (Not applicable -- no UI changes.)
  • Visible UI changes include a UI Evidence section below. (Not applicable -- no visible/UI changes.)
  • Public docs/changelogs are updated where needed. (Not applicable.)

UI Evidence

Not applicable -- test-only change, no UI/frontend/docs surface touched.

Notes

  • Companion PRs from the same investigation: the originally-reported test/unit/ai-summaries.test.ts flake, and a same-pattern timeout fix for the #5132 miner clone/worktree test suite.

…out 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.
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@JSONbored JSONbored self-assigned this Jul 17, 2026
@JSONbored
JSONbored merged commit b12d09d into main Jul 17, 2026
5 checks passed
@JSONbored
JSONbored deleted the worktree-agent-sdk-driver-flake branch July 17, 2026 09:42
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 17, 2026
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.64%. Comparing base (10aad0d) to head (8322713).
⚠️ Report is 41 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6871   +/-   ##
=======================================
  Coverage   93.64%   93.64%           
=======================================
  Files         684      684           
  Lines       68193    68193           
  Branches    18707    18707           
=======================================
  Hits        63857    63857           
  Misses       3350     3350           
  Partials      986      986           
Flag Coverage Δ
shard-1 43.15% <ø> (-0.53%) ⬇️
shard-2 37.08% <ø> (+0.24%) ⬆️
shard-3 32.57% <ø> (-0.06%) ⬇️
shard-4 34.44% <ø> (-0.39%) ⬇️
shard-5 31.31% <ø> (-0.24%) ⬇️
shard-6 46.02% <ø> (+0.28%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

JSONbored added a commit that referenced this pull request Jul 25, 2026
* fix(deps): resolve postcss + tar audit findings via overrides

npm audit flagged postcss <=8.5.17 (path traversal in previous-sourcemap
auto-loading, GHSA-r28c-9q8g-f849, high) and tar <=7.5.20 (uncontrolled
recursion DoS via crafted long-path tar, GHSA-r292-9mhp-454m, moderate),
both transitive. Pin both via overrides, matching this file's existing
pattern for other transitive-dep security fixes: bump the existing tar
override past its first-patched version (7.5.19 -> 7.5.21) and add a new
postcss override (8.5.18, first patched version).

Closes task 1 of #8588's checklist. The remaining findings in that issue
(eslint v10 bump for the brace-expansion/minimatch chain, the
@esbuild-kit->tsx trace, and the recharts v3 migration) are unrelated,
each need their own scoping, and are now tracked as sub-issues #8608,
#8609, #8610.

* build: add the missing ui-kit build step to the local test:ci gate

Discovered incidentally while running the full local gate for #8588:
test/unit/check-ui-kit-package.test.ts's own regression guard needs
packages/loopover-ui-kit/dist/ to exist, but the root test:ci script
never built that workspace before test:coverage -- unlike the real CI
validate-tests job, which already builds it via `npx turbo run build
--filter=@loopover/ui-kit` right before its own coverage step (added in
#8592 to close this exact gap, but only in the CI workflow, not the
local script this repo's own contributing guide points everyone at).
Anyone running `npm run test:ci` from a clean checkout hit a spurious
failure that real CI never showed.

Adds `npm run build --workspace @loopover/ui-kit` alongside the other
per-package builds already in the chain (engine, discovery-index, mcp,
miner), so the local script matches CI again.

* fix(mcp): stop CLI stdout truncation on >64KB piped output

Discovered incidentally while running the full local gate for #8588:
test/unit/mcp-cli-profiles.test.ts's changelog test started failing with
a JSON parse error once packages/loopover-mcp/CHANGELOG.md grew past the
OS pipe buffer size (verified: `loopover-mcp changelog --json | wc -c`
returned exactly 65536 bytes instead of the real 65603+ -- the classic
64KB pipe-buffer boundary).

Root cause: process.stdout/stderr writes to a POSIX pipe are
asynchronous, but the CLI entrypoint called process.exit() immediately
after the command's async work resolved, cutting off any pending write
larger than one pipe buffer's worth before it finished flushing. This
silently truncates any command's output over ~64KB for any real
consumer piping the CLI (not just this test) -- e.g. `loopover-mcp
changelog --json | jq` would get invalid JSON.

Fix: drain both streams (wait for their internal buffer to empty) right
before calling process.exit(), instead of changing when/whether
process.exit() itself is called -- keeps the existing fast-exit behavior
for everything else (no risk of hanging on a lingering fetch keep-alive
socket) while fixing the truncation at its actual source.

* test(miner): raise timeout for build:verify syntax-check regression guard

Discovered incidentally while running the full local gate for #8588:
this test spawns a real subprocess (node --check over every
dist/bin+dist/lib file in packages/loopover-miner) -- 5.5s in isolation,
but it exceeded the default 15s testTimeout once under the full suite's
parallel load. Genuinely necessary real subprocess work with no
redundancy to cut, matching this repo's established real-subprocess
timeout-flake pattern (agent-sdk-driver.test.ts, miner-attempt-worktree
.test.ts, miner-repo-clone.test.ts, #6869/#6871): raise to the same
evidence-based 60000ms ceiling already used for that class of test,
rather than reflexively widening without a reason.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant