Skip to content

test(#1164): MCP sequant_status tests use a test-owned state file and make no GitHub calls - #1205

Merged
admarble merged 8 commits into
mainfrom
test/1164-hermetic-mcp-status
Sep 28, 2026
Merged

admarble merged 8 commits into
mainfrom
test/1164-hermetic-mcp-status

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

Closes #1164. The three MCP test files that call sequant_status no longer read or rewrite the checkout's real .sequant/state.json, and they no longer make GitHub calls.

  • Production change (test-only override): registerStatusTool(server, { statePath }) and createServer(version, context, { status: { statePath } }). serve passes nothing, so the tool still builds new StateManager() on the default path and still reconciles.
  • src/mcp/server.test.ts and mcp-serve-async-refactor.integration.test.ts: each server reads a state file in a fresh temp dir.
  • mcp-e2e.integration.test.ts: the stdio and SSE server subprocesses get SEQUANT_PROJECT_DIR=TEST_DIR. serve already changes into that dir, so no new production knob was needed.
  • New gate src/lib/test-state-hermetic.test.ts:
    • It seeds a sentinel state, runs the three files in a child vitest with cwd set to the checkout (global setup skipped, so dist/ is not rebuilt under the parent suite), and asserts the checksum is unchanged and the child suite is green with 3 of 3 files.
    • It keeps an on-disk backup of any real state file (state.json.hermetic-gate-backup). A run killed before its finally block is recovered at the start of the next run. I tested that by planting a leftover backup: the gate restored it.

Acceptance criteria

  • AC-1: npx vitest run src/lib/test-state-hermetic.test.ts: 1 passed.
  • AC-2: npx vitest run src/mcp/server.test.ts: the new case seeds issue 42 in a temp state and gets back status: "not_started", title: "Seeded title"; the stubbed GitHub lookup is asserted to be called once, with ([42], []).
  • AC-3: the three files plus status.test.ts, run with gh's directory removed from PATH (command -v gh exit 1): 4 files, 38 tests passed. The run passing is weak evidence on its own, because GitHubProvider swallows errors. What rules out GitHub calls: reconcile returns early on an empty tracked set, the e2e server runs in an empty TEST_DIR, and the issue-42 stub is asserted.
  • AC-4: npx vitest run src/mcp/tools/status.test.ts: 2 passed. With no override, the StateManager gets statePath undefined, which resolves to the default STATE_FILE_PATH, and reconcile runs on that same instance.
  • AC-5: CI test job.

Mutation records

Mutation-verified: AC-1 — removed the statePath override from mcp-serve-async-refactor's createServer call ({ status: {} }); src/lib/test-state-hermetic.test.ts failed ("state.json changed … lastSynced rewritten"); restored.

Mutation-verified: AC-2 — removed the statePath override from server.test.ts's createServer call ({ status: {} }); the issue-42 case failed; restored.

Mutation-verified: AC-4 — status.ts defaulted statePath to ".sequant/other-state.json" when no override is given; src/mcp/tools/status.test.ts failed; restored.

Notes for review

  • Cost: the gate adds a nested vitest run of 25–130 s to the unit project, depending on machine load. If the e2e file flakes inside the child run, the gate reports "child suite failed (not a hermeticity finding)" instead of a hermeticity failure.
  • One unexplained red: during development, a first run of the three files without gh, at load average 16–18, had 3 failures in 1 file and its output was not captured. Every run since has been green, including mine above after merging main. If CI shows the same thing, that failure is real.
  • No CHANGELOG entry: the change is tests plus a test-only option, the same treatment fix(test): strip tilde fences from mutation-marker property noise #1188 got.

Test plan

  • AC-1 to AC-4 commands above, run after merging main
  • CI test + canary

🤖 Generated with Claude Code

@admarble
admarble merged commit 6cb6b9b into main Sep 28, 2026
7 checks passed
@admarble
admarble deleted the test/1164-hermetic-mcp-status branch September 28, 2026 14:07
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.

test(mcp): sequant_status tests reconcile and rewrite the checkout's real .sequant/state.json

1 participant