Skip to content

Refuse a re-verification request the tool would refuse on its arguments - #127

Open
gavmor wants to merge 1 commit into
prooflinedev:mainfrom
gavmor:fix/validate-reverification-request
Open

gavmor wants to merge 1 commit into
prooflinedev:mainfrom
gavmor:fix/validate-reverification-request

Conversation

@gavmor

@gavmor gavmor commented Dec 4, 2026

Copy link
Copy Markdown

Closes #126.

FixesClient.requestReverification forwarded the caller's arguments to the request_reverification MCP tool unchecked, so a request the tool documents as invalid was still sent over the wire. This builds the tool arguments through a checked helper instead.

Why this is worth refusing locally

The SDK already refuses locally what the server would refuse. readCoverageFiles says so in its own docstring, and Transport.request refuses an MCP body over 8,192 bytes before sending it. request_reverification was the gap.

Sending a request that the tool will reject on its arguments alone costs more than a wasted round trip:

  • It spends the full three-request MCP handshake before the server answers.
  • request_reverification is a write with an allowance the server keeps per finding and per pull request, documented as 3 requests per finding per head and 10 per pull request per hour.
  • The MCP tools reference documents unconfirmed writes: a write can be recorded and then fail to report, so a refusal "is not proof that nothing happened".

What is checked

Taken from the MCP tools reference and this repository's README, not inferred:

Argument Refused when
commit_sha not a full 40-character hexadecimal SHA
finding_ids not a list of 1 to 20 distinct nonempty IDs
review_id empty
note present and outside 1 to 2,000 characters

Two details the checks get right rather than approximately:

  • Case. The tool documents ^[0-9a-fA-F]{40}$, so an uppercase commit is accepted. This deliberately does not reuse the lowercase rule readCoverageFiles applies to tested_sha, which is a different field with a different documented contract.
  • Characters, not UTF-16 units. The note's limit counts characters, so the check counts code points. A note of 1,500 astral characters has length 3,000 and is within the documented limit; measuring with length would refuse a request the server accepts. There is a test for exactly this.

An omitted note or organization_id stays absent rather than arriving as null, and the forwarded finding list is a copy of the caller's array.

requestReverification becomes async so an invalid request rejects with a TypeError rather than throwing synchronously, which is how uploadCoverageFiles reports the same class of refusal. It already returned a promise, so this is not a signature change for callers.

Scope

No generated code, OpenAPI contract, or workflow is touched, per the README's contribution note. Behaviour is unchanged for any request that is already valid: the existing fix helpers preserve unavailable context and never retry a verification request test passes without modification.

The forwarded finding_ids copy is a by-product of building the arguments, not a fix for the general nested-argument snapshot in McpTools.call. That is a separate concern already covered by #68 and #66, and this change does not touch src/mcp.ts.

Verification

The new test asserts that each invalid case rejects with TypeError and that the server observed no request at all, so no handshake and no request allowance is spent. It also asserts the accepted cases are sent unchanged.

Removing src/fixes.ts from the working tree and rebuilding makes the new test fail with Missing expected rejection (TypeError): no findings, so it covers the change rather than restating it.

Local run on Node 22, mirroring .github/workflows/ci.yml:

pnpm install --frozen-lockfile    ok
pnpm generate && git diff --exit-code    no drift
pnpm lint && pnpm typecheck && node check-claims.mjs    ok
pnpm build && pnpm test    107 tests, 107 pass, 0 fail (106 before)
npm pack --ignore-scripts    proofline-sdk-10.9.0.tgz

`requestReverification` forwarded the caller's arguments to
`request_reverification` without checking them. Every other local
refusal in the SDK happens before a request: `readCoverageFiles`
refuses a malformed commit SHA, a report count outside 1 to 50,
duplicate names and an oversized body, and the transport refuses an
MCP body over 8,192 bytes.

The documented arguments of `request_reverification` are checkable
without a round trip: `commit_sha` matches `^[0-9a-fA-F]{40}$`,
`finding_ids` holds 1 to 20 distinct findings of one review, and an
optional `note` holds 1 to 2,000 characters. Sending a request that
fails one of them costs the three-request MCP handshake, and
`request_reverification` is a write whose allowance the server keeps
per finding and per pull request. A write that is refused after the
server records it is also not proof that nothing happened, so a
request the server would refuse on its arguments alone is never worth
sending.

Build the tool arguments through a checked helper. The note's limit
counts characters, so count code points rather than the two UTF-16
units a surrogate pair spends; a note of 1,500 astral characters is
within the limit even though its `length` is 3,000. The commit accepts
either case, unlike the lowercase `tested_sha` a coverage upload takes.
An omitted note or organization stays absent rather than arriving as
null, and the forwarded finding list is a copy of the caller's.

`requestReverification` becomes `async` so an invalid request rejects
with a `TypeError` rather than throwing synchronously, matching
`uploadCoverageFiles`.

This branch has not been deployed

No deployments
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.

requestReverification sends a re-verification request the tool would refuse on its arguments

1 participant