tidy-transport: one reverse-RPC reply for all three transports - #274
Merged
Conversation
conn.handlePeer built the answer to a server-initiated request inline — method-not-found without a handler, internal-error for a handler that failed or returned nothing, and the id forced onto whatever it did return. invokePeer does exactly that for the two HTTP transports, and its own comment described itself as "mirroring the stdio contract" while the stdio copy sat here. One contract, two implementations, three call sites: the arrangement in which a reverse-RPC answer comes to differ by transport for no reason anybody chose. handlePeer now calls invokePeer and keeps only the half that genuinely is stdio's — writing the frame, and what an oversized one costs. The reply was equivalent branch for branch, including the messages, so this changes no behaviour. Three of the four outcomes were already pinned by TestPeerRequestInlineReply; the fourth — a handler returning neither response nor error, which still owes the server a reply because the id is outstanding on the wire — joins the table. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nightly tidy pass over
internal/mcp/transport(2026-08-09, sixth slice).conn.handlePeerbuilt the reverse-RPC answer inline whileinvokePeerdid exactly the same for both HTTP transports, describingitself as "mirroring the stdio contract". One contract, two
implementations, three call sites. Equivalent branch for branch,
including the messages, so no behaviour change; the one outcome the
table did not reach — a handler returning neither response nor error —
joins
TestPeerRequestInlineReply.Read and not acted on:
ssescan.go's deliberate deviation from the SSE dispatch rule (anempty-data event is dispatched so
lastIDadvances) is correct asdocumented, and all three consumers do carry the guard it says they must.
drainBodydereferencesrespwhile its siblingdrainCloseguardsresp == nil. Real, but every caller of the first holds a response; notworth a commit on its own.
No parser was touched, so no fuzz round is owed. Verification:
make cigreen.