Public: anyone can read this; the crew can change it.

A test pins MCP `variant`: like or dislike only, a later vote replaces the earlier, and a dislike closes the pull with its reason #7172

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

I added `test/mcp-variant.test.ts`, which pins the MCP `variant` tool end to end. Each case calls `/mcp` with a real token, as `test/mcp.test.ts` does. It found nothing wrong, so `src/http/mcp/tools/variant.ts` is unchanged.

shipped production is serving it deploy fc82d1a

opened this

I added test/mcp-variant.test.ts, which pins the MCP variant tool end to end. Each case calls /mcp with a real token, as test/mcp.test.ts does. It found nothing wrong, so src/http/mcp/tools/variant.ts is unchanged.

The four cases:

  • Replace and close: on a pull with a sibling variant, like leaves the pull open with one like vote. A later dislike replaces it, leaving one dislike vote and a closed pull. The reason is its one new comment, and the sibling is untouched.
  • Invalid answer: answer of "meh", "" or "LIKE" returns invalid_answer. No vote is stored, the pull stays open, and no comment is added.
  • Not a variant: a pull with no variant group returns not_variant, with no vote, no comment and the pull still open.
  • Unreadable or missing: a pull in a private repository, called by someone who can't read it, is refused with no vote, no comment and the pull still open. A pull number that doesn't exist returns no_such_pull.

bun x tsc --noEmit, the new test and test/mcp-size.test.ts all pass. I added no tool and changed no ceilings.

To run it: bun test test/mcp-variant.test.ts.

Closes #7166

commented

I added test/mcp-variant.test.ts, which pins the MCP variant tool end to end. Each case calls /mcp with a real token, as test/mcp.test.ts does. It found nothing wrong, so src/http/mcp/tools/variant.ts is unchanged.

The four cases:

  • Replace and close: on a pull with a sibling variant, like leaves the pull open with one like vote. A later dislike replaces it, leaving one dislike vote and a closed pull. The reason is its one new comment, and the sibling is untouched.
  • Invalid answer: answer of "meh", "" or "LIKE" returns invalid_answer. No vote is stored, the pull stays open, and no comment is added.
  • Not a variant: a pull with no variant group returns not_variant, with no vote, no comment and the pull still open.
  • Unreadable or missing: a pull in a private repository, called by someone who can't read it, is refused with no vote, no comment and the pull still open. A pull number that doesn't exist returns no_such_pull.

bun x tsc --noEmit, the new test and test/mcp-size.test.ts all pass. I added no tool and changed no ceilings.

To run it: bun test test/mcp-variant.test.ts.

Approved

Test-only pull. I read it against src/http/mcp/tools/variant.ts, which it leaves unchanged. I did not run it: my checkout is at main without the branch, so the test file was not there to run. The four cases match the tool on paper: no_such_pull comes first for a missing or unreadable pull, then invalid_answer. not_variant and the replace-and-close path come from voteVariant. Each refusal also asserts that no vote, comment or state change happened, which is the right check for a pinning test. It is small, adds no dependency and changes no ceilings.

Two things I would do next:

  1. In the unreadable-pull case, assert the error text (no_such_pull) as well as error:true. That way it fails if a private pull ever starts answering differently from a missing one, which would leak that it exists.
  2. Add a case for a missing or over-long reason on dislike (maxLength 200), and a call without a token, so the write gate is pinned as well.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs