Repository navigation
test(#1322): state.test.ts idempotency and state-utils discoverUntrackedWorktrees cases fail under full-suite load, pass alone - #1395
Merged
admarble merged 3 commits intoOct 10, 2026
Conversation
… tests The state.test.ts idempotency and state-utils discovery tests ran against the real checkout: one gh issue view per issue worktree (10-20 s per test, load-sensitive) and a git worktree list that other sessions change mid-test. On CI they asserted nothing. A spawnSync fixture keyed on command + args answers git worktree list and gh issue view; the conditional assertions are now unconditional and the 30 s describe timeouts are gone. Entire-Checkpoint: 5e3a2c5cf92a
4 tasks
…te-test-ts-idempotency-and-state-utils-dis
…te-test-ts-idempotency-and-state-utils-dis
admarble
deleted the
feature/1322-test-state-test-ts-idempotency-and-state-utils-dis
branch
October 10, 2026 14:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
What was wrong.
discoverUntrackedWorktreesread the realgit worktree listand ran onegh issue viewper issue worktree, each with a 10 s timeout. Each failing test called discovery twice. On CI there are no issue worktrees, so theif (discovered.length > 0)branches never ran and the tests asserted nothing.Fix (test-only, no production change):
src/lib/workflow/__fixtures__/worktree-discovery.fixture.ts: stands in forspawnSyncand answers by command and arguments, not call order:git worktree list --porcelainreturns a fixed list as a Buffer: main, a detached HEAD,chore/tidy-docs, and three issue worktrees (9001, 9002, 9003).gh issue view <N> --json titlereturns a canned title.spawnSync.src/lib/workflow/state-utils.test.ts: sets up the fixture inbeforeEachof the discovery describe and resets it inafterEach. Theif/elsefallback is gone. The test now checks that exactly the tracked worktree drops out and thatalreadyTracked === 1. The 30 s timeout is removed.src/commands/state.test.ts: fakeschild_processthe same way and sets up the fixture. The idempotency test now asserts every time. The "clear output" test now requires at least one discovered and one skipped worktree, so its loops actually check something. Both 30 s timeouts are removed; every test now runs in under 20 ms.Pre-PR AC Verification
git worktree list, with onegh issue viewper issue worktree. Run time grew with the worktree count, and assertions failed when a concurrent run changed the list (exec's before-run:state.test.ts:58,state-utils.test.ts:320). The runner's first classification, load-induced timeout, was wrong.ghtitles, and they already used amkdtempstatePath. Neither reads the real worktree list or the checkout's.sequant/state.json.ghcalls and no realgit worktree list. The 30 s timeouts are dropped rather than raised.f5fe3054, run by the runner. Both tests passed in all three (see below).Per-test durations, both files run alone:
Mutation-verified: AC-6 — commented out the
continueafteralreadyTracked++inworktree-discovery.ts.src/lib/workflow/state-utils.test.ts > state-utils > discoverUntrackedWorktrees > should not discover worktrees that are already trackedfailed, along withsrc/commands/state.test.ts > state command > idempotency (AC-4) > state init should be idempotent - running twice yields same result. Only those two failed (2 failed, 39 passed). Restored.parseMutationMarkersreads the marker back correctly.Checks
npm run buildpassed.npm run lintpassed with 0 warnings.AC-4: three consecutive full-suite runs (runner,
f5fe3054,npx vitest run --project unit --project integration)state init should be idempotentshould not discover worktrees that are already trackedTests 1 failed | 9091 passed | 1 expected fail | 3 skipped (9096)Tests 1 failed | 9091 passed | 1 expected fail | 3 skipped (9096)Tests 1 failed | 9091 passed | 1 expected fail | 3 skipped (9096)The single failure in each run is
driver-conformance.test.ts > codex commit: git add and git commit succeed inside the driver's default sandbox(git exit 128). It fails the same way onmain(c8762a2c) on this machine and passes in CI. It comes from the local codex sandbox and is unrelated to this diff.Plugin freeze (I-1):
git diff --name-only origin/main...HEAD | grep -E '^(plugin|\.claude/skills|templates/skills)/'is empty.Fixes #1322
🤖 Generated by
sequant run; runner sections added with Claude Code