Skip to content

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

Closed

Description

@admarble

Context

Found during #1150 QA (PR #1163). PR #1163 fixed the destructive case: state-utils.test.ts rebuilt an empty state onto the checkout's real .sequant/state.json, so every npm test wiped it.

Three test files still write the checkout's real state:

  • src/mcp/server.test.ts
  • __tests__/integration/mcp-e2e.integration.test.ts
  • __tests__/integration/mcp-serve-async-refactor.integration.test.ts

Mechanism: the sequant_status tool (src/mcp/tools/status.ts:54) builds new StateManager() on the default path, which is process.cwd()/.sequant/state.json. It then calls reconcileState({ stateManager }), which contacts GitHub for every tracked issue. The tests call the tool from the repo root. As a result each run:

  • rewrites the developer's real state file: issue titles are refreshed from GitHub and lastSynced/lastUpdated are bumped;
  • makes live GitHub calls from a unit test;
  • asserts against whatever the checkout's state happens to contain. For example, not_tracked for issue 99999 holds only because no one tracks 99999.

How it was measured: copy a sentinel state.json into the checkout, run each file alone with npx vitest run <file>, then diff the file. Each of the three changed it. On 2026-09-25 the diff showed #1150's stored title replaced by its live GitHub title, plus new timestamps. Nothing was deleted.

Acceptance criteria

  • AC-1: running any of the three test files leaves the working checkout's .sequant/state.json byte-identical — Evidence: npx vitest run src/lib/test-state-hermetic.test.ts (a new gate test) seeds a sentinel state file, runs the three files in a child vitest process with cwd = the checkout, and asserts its checksum is unchanged
  • AC-2: sequant_status in these tests reads a state file the test created, never the checkout's — Evidence: npx vitest run src/mcp/server.test.ts with a case that seeds issue 42 in a temp state and gets status back for it
  • AC-3: these tests make no GitHub call: reconcile is either pointed at a stub or the tracked set is empty — Evidence: npx vitest run src/mcp/server.test.ts __tests__/integration/mcp-e2e.integration.test.ts __tests__/integration/mcp-serve-async-refactor.integration.test.ts with gh removed from PATH for the run, green
  • AC-4: the sequant_status production behavior is unchanged (default path, reconcile on), and a test-only override (a statePath option or a cwd set per server instance) is the only way the tests redirect it — Evidence: npx vitest run src/mcp/tools/status.test.ts (or equivalent) asserting the default StateManager path when no override is given
  • AC-5: npm run build && npm test green — Evidence: CI test job

Non-Goals

  • Changing what sequant_status or reconcileState do for real users.
  • A suite-wide hermeticity sweep of every test that touches .sequant/. That is only worth doing if the AC-1 gate finds more offenders; if so, file them separately.

Related

#1150 / PR #1163 (the destructive case, fixed) · #1086 (env leaks into the suite, the same hermeticity class)

Activity

  1. added
    bug
    on Sep 25, 2026
  2. added a commit that references this issue on Sep 28, 2026
  3. added a commit that references this issue on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions