Repository navigation
Description
Epic: graph-2026-10-freeze Tier: judgment Execution: split: sequant_run writes the fix; the runner session produces the full-suite evidence (AC-1, AC-4), since phases skip the full suite
Seen in the full npm test run for #1292 (branch at 8e5d95a, base origin/main 3cbb5a2). Neither file is touched by that diff.
Failing in the full run:
src/commands/state.test.ts > state command > idempotency (AC-4) > state init should be idempotent - running twice yields same resultsrc/lib/workflow/state-utils.test.ts > state-utils > discoverUntrackedWorktrees > should not discover worktrees that are already tracked
scripts/settle-against-base.sh for each: PASS at HEAD and PASS at base when run alone. Alone they take 14.8 s and 24.4 s. state.test.ts's describe block has a 30 s timeout. Load-induced timeouts are the likely cause, but this is not confirmed: the full-run failure messages were not captured.
Next step: re-run the full suite and capture the failure output to tell a timeout from shared-state interference (compare #1164).
Acceptance Criteria
- AC-1: The full-suite failure output for both tests is captured and the cause is classified as load-induced timeout or shared-state interference (test(mcp): sequant_status tests reconcile and rewrite the checkout's real .sequant/state.json #1164: three MCP tests touch the real
.sequant/state.json). Evidence: the captured failure messages pasted in a comment on this issue, with the one-line classification. - AC-2: If the cause is shared state, both tests run against an isolated state path and no longer read or write the checkout's real
.sequant/state.json; otherwise this AC recordsn/awith the AC-1 classification. Evidence: a test or setup change that points the state path at a temp dir, or then/aline. - AC-3: If the cause is load, the tests' timeouts or setup cost change so they pass under full-suite load; otherwise this AC records
n/awith the AC-1 classification. Evidence: the timeout or setup diff, or then/aline. - AC-4: Both tests pass in 3 consecutive full-suite runs on the PR branch. Evidence: the three run summaries (
Tests … passed) pasted in the PR body.
Prior fixes / producers
- The idempotency test dates from Add state bootstrapping for existing worktrees #117 (2026-01-20). Related: test(mcp): sequant_status tests reconcile and rewrite the checkout's real .sequant/state.json #1164 (MCP tests that touch the real state file).
May touch
src/commands/state.test.ts, src/lib/workflow/state-utils.test.ts, test setup files.
Non-Goals
- Changing state-file behaviour in production code, unless AC-1 shows a production bug (then file it separately).
- Any edit under
plugin/,.claude/skills/ortemplates/skills/(plugin freeze, I-1 of the graph doc).
Activity
docs(#1390): graph-2026-10-freeze founding doc, issue graph and as-fi…
admarble commentedon Oct 10, 2026
AC-1 evidence (runner, 2026-10-10): classified as a load-induced timeout
I ran two full suites on
origin/main@c8762a2cin a detached worktree, withSEQUANT_*env vars unset (npx vitest run --project unit --project integration, JSON reporter):sequant runagents running alongsidestate-utils.test.ts > discoverUntrackedWorktrees > should not discover worktrees that are already trackedstate.test.ts > idempotency (AC-4) > state init should be idempotentClassification: load-induced timeout.
.sequant/state.json. The suites ran in a separate worktree, and the tests still passed.For the fix: AC-2 is
n/aand AC-3 applies. A single test that takes 20–30 s points to setup cost (spawned git/CLI processes per case), not a test that needs more time. Cutting that cost is better than raising the timeout alone.Unrelated local failures in the same runs, not this issue's:
driver-conformance.test.ts > codex commit(git exit 128; the local codex sandbox) andsemgrep.test.tstimeouts (local semgrep under load). CI onmainis green for both.admarble commentedon Oct 10, 2026
Runner context for the phase agents (graph-2026-10-freeze, wave 1). This applies to spec, exec and qa by name.
n/aand the fix is AC-3. Don't re-derive the classification. Recordn/afor AC-2 citing that comment.git init, spawned CLI processes,npmcalls. Cut that setup cost (a sharedbeforeAllfixture, an in-process call instead of a spawn) rather than only raising the 30 s timeout. If you do raise a timeout as well, say why.npm testin exec or qa. Run the two files alone, in the foreground, withtimeout, after a WIP commit, and report each file's per-test durations before and after. The runner produces AC-4's three full-suite runs on the PR branch after the PR opens.plugin/,.claude/skills/ortemplates/skills/.admarble commentedon Oct 10, 2026
Complexity: Standard (4 ACs, 2 directories)
AC Quality Check
lintAcceptanceCriteria: all 4 ACs pass. Every AC is on one line and has anEvidence:clause.Scope Assessment
Non-Goals: present. No production state-file change. No edits under
plugin/,.claude/skills/ortemplates/skills/.src/commands/,src/lib/workflow/)Verdict: ✅ SCOPE_OK
Root cause (measured from the code, not guessed)
discoverUntrackedWorktrees()(src/lib/workflow/worktree-discovery.ts:210) takes nocwdand no injected dependencies. In both tests it does three things against the real developer checkout:git worktree list --porcelain(:122). This checkout has 25 worktrees, and 22 of them arefeature/*branches with issue numbers.fetchIssueTitle, which callsGitHubProvider.fetchIssueTitleSync. That is a synchronousgh issue viewnetwork call with a 10 s timeout each (platforms/github.ts:510).inferPhaseFromLogs(:163) reads and Zod-parses every file in the real.sequant/logs: 97 files, 2 MB, once per discovered worktree.Each failing test calls discovery twice, so it makes about 2 × 22 sequential
ghcalls. That accounts for the 10–30 s run times and for times that grow with load. It also means:discovered.length === 0, theifbranch never runs, and both tests assert nothing (vacuous on CI). They only exercise real logic on a developer machine, and that is where they time out.Acceptance Criteria
AC-1: Capture + classify
Verification: Manual (done)
Status: Done by the runner: classification comment. Load-induced timeout. Don't re-derive it.
AC-2: Isolated state path (if shared state)
Verification: Manual
Status: Record
n/a — AC-1 classified as load-induced timeout (runner comment, 2026-10-10). Both tests already use amkdtempstatePath. The fix below also removes the reads of the realgit worktree listand.sequant/logs, which goes further than AC-2 asked.AC-3: Cut setup cost so the tests pass under load
Verification: Integration Test (the two files run alone, per-test durations before/after)
Scenario: Given a fixture worktree list with N issue branches → When discovery runs twice with one issue tracked in between → Then the assertions hold, with no
ghspawn and no realgit worktree list.Assumptions:
child_processcan be mocked by the args each call receives (state-utils.test.ts already does this forspawnSync).AC-4: 3 consecutive full-suite passes
Verification: Integration Test, runner-owned. It stays unchecked in the PR until the runner pastes the three
Tests … passedsummaries. Exec and qa do not run the full suite.Implementation Plan
Phase 1: Measure (before)
timeout 300 npx vitest run src/commands/state.test.ts src/lib/workflow/state-utils.test.ts --reporter=verboseand record the per-test durations. The PR body needs these as the "before" numbers.Phase 2: Hermetic fixture (recommended option A)
src/lib/workflow/__test-helpers__/worktree-discovery-fixture.ts(follow whatever test-helper location the repo already uses). It installs aspawnSyncmockImplementationkeyed on command + args, not an ordered queue (see the ordered-mock pitfall). It returns:git worktree list --porcelain: a fixture porcelain string with the main worktree, a detached HEAD, a non-issue branch and at least 2feature/<N>-…branches. Return a Buffer stdout, becausegetWorktreeDetailscalls.toString()and passes noencoding.gh issue view <N> --json title: a canned title string,status: 0.spawnSync.state-utils.test.ts: in thediscoverUntrackedWorktreesdescribe (:287), install the fixture inbeforeEach. Remove theif (discovered.length > 0) … elsefallback, so the test asserts that discovery found 2 or more worktrees, that tracking one makesdiscoveredshrink by exactly 1, and thatalreadyTracked === 1. Note thatmockSpawnSyncis alreadyvi.mocked in this file. Reset it inafterEachso the fixture doesn't leak intocheckPRMergeStatusand the other describes.state.test.ts: it has nochild_processmock today. Add the samevi.mock("child_process", …)pass-through and install the fixture for theidempotencyandclear outputdescribes. Apply the same tightening: drop theif, and assertresult2.discovered.length === 0andalreadyTracked === result1.discovered.length, withresult1.discovered.length >= 2.Phase 3: Measure (after)
Rejected options
cwd/deps injection parameter todiscoverUntrackedWorktrees. This is a cleaner seam, but it changes production code (Non-Goal) for a test-only problem. Mockingchild_processmatches the existing pattern instate-utils.test.ts.Design Review
spawnSynckeyed on args forgit worktree listandgh issue view. Rejected: timeout-only (B) and production DI (C), both above.mockGitalready instate-utils.test.ts:886.git log -S "timeout: 30000"on these files: one prior change,0776efe3("stabilize flaky tests with project-based isolation"). That commit raised the timeout and left the real-checkout dependency in place. This is the second patch to this flake. One prior fix is under the stop threshold of 2, but this plan fixes the class (real checkout I/O) instead of the symptom, so there will not be a third timeout bump.git worktree listparsing?" The parsing still runs: the mock returns a realistic porcelain string, andgetWorktreeDetailsparses it. Only the process spawn is faked. "inferPhaseFromLogsstill reads the real.sequant/logs." Yes. With 2–3 fixture worktrees that is about 300 file parses. If the after-measurement shows that cost matters, see Open Question 1.discoverUntrackedWorktreesis defined inworktree-discovery.tsand re-exported fromstate-utils.ts:41. Its consumers aresrc/commands/state.ts(production, unchanged),state.test.ts,state-utils.test.tsandstate-exit-code.test.ts. The last one already mocks the function completely, so it is unaffected. There is one producer, so no parity test is needed.Sibling sites (do these in scope, same files):
state.test.ts:155("clear output" discovery test) andstate-utils.test.ts:292("should return success when called") make the same real calls, once each. They should use the same fixture. It's the same describe and the samebeforeEach, so no scope expansion is needed.Feature Quality Planning
All standard checks pass. Notable items:
state-utils.test.tsshares onemockSpawnSyncacross describes. Reset it inafterEachof the discovery describe.Derived ACs
discoverUntrackedWorktreestest in both files takes < 1 s when its file runs alone. Evidence: the before/after per-test durations in the PR body.SEQUANT_MUTATIONrecord in the PR body. Mutation: inworktree-discovery.ts, comment out thetrackedIssues.has(issueNumber)continue;src/lib/workflow/state-utils.test.ts > state-utils > discoverUntrackedWorktrees > should not discover worktrees that are already trackedfails; restore.Open Questions
inferPhaseFromLogs's real.sequant/logsread too? Recommendation: no, unless the after-measurement is still over 1 s. It is a read with no side effects and costs little at fixture scale. Impact if wrong: a smaller remaining load sensitivity. The fix then isvi.mockofrun-log-schema.js'sLOG_PATHSpointing at the temp dir.child_processorGitHubProvider.prototype.fetchIssueTitleSync? Recommendation:child_process, because one mock covers both thegitand theghcalls and matches the file's existing pattern. Impact if wrong: none functionally.Recommended Workflow
Phases: exec → qa
Quality Loop: disabled
Reasoning: A test-only bug fix in two files. The runner already did AC-1, AC-2 is
n/a, and AC-4 is runner-owned. No testgen, because the work is tests. Exec and qa run only the two files, in the foreground, withtimeout, after a WIP commit. No fullnpm test.Label Review
Current:
bug,graph-2026-10-freezeRecommended: add
plannedQuality Loop: won't auto-enable (SCOPE_OK, no complexity labels)
admarble commentedon Oct 10, 2026
QA Verdict: NEEDS_VERIFICATION
AC coverage: 4/6 met
Gaps:
Suggestions:
inferPhaseFromLogsstill reads the real.sequant/logs. At fixture scale this costs a few milliseconds, and the spec's Open Question 1 accepts it. A future log entry for a fixture issue number (9001–9003) could change the inferred phase, but no test asserts on the phase.Pending ACs:
Needs human review:
admarble commentedon Oct 10, 2026
Correction to AC-1: the cause is shared state, not load. My classification above was wrong.
The exec phase (PR #1395) found the mechanism, and I checked it against the code. On
main, both tests calldiscoverUntrackedWorktreesagainst the real checkout'sgit worktree list --porcelain(worktree-discovery.ts:122), then run onegh issue viewper issue worktree.sequant runcreating new worktrees, which explains the 19.8 s → 29.8 s jump that I read as load.sequant runadds or removes a worktree between the test's two discovery calls. Exec's "before" run failed on assertions atstate.test.ts:58andstate-utils.test.ts:320(PR test(#1322): state.test.ts idempotency and state-utils discoverUntrackedWorktrees cases fail under full-suite load, pass alone #1395 body).if (discovered.length > 0)branches never ran, so the tests asserted nothing there.So the classification is shared-state interference with the machine's worktree list and GitHub. It is not the #1164
.sequant/state.jsonpath: both tests already used a tempstatePath.n/a: PR test(#1322): state.test.ts idempotency and state-utils discoverUntrackedWorktrees cases fail under full-suite load, pass alone #1395's fixture isolates the worktree list and theghtitles.test(#1322): hermetic worktree fixture for discoverUntrackedWorktrees…