Skip to content

tidy-transport: one reverse-RPC reply for all three transports - #274

Merged
dinstein merged 1 commit into
mainfrom
tidy-transport
Aug 9, 2026
Merged

tidy-transport: one reverse-RPC reply for all three transports#274
dinstein merged 1 commit into
mainfrom
tidy-transport

Conversation

@dinstein

@dinstein dinstein commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Nightly tidy pass over internal/mcp/transport (2026-08-09, sixth slice).

  • Pass Aconn.handlePeer built the reverse-RPC answer inline while
    invokePeer did exactly the same for both HTTP transports, describing
    itself 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.
  • Pass B — nothing cleared the bar.
  • Pass C — nothing to reconcile in this slice.

Read and not acted on:

  • ssescan.go's deliberate deviation from the SSE dispatch rule (an
    empty-data event is dispatched so lastID advances) is correct as
    documented, and all three consumers do carry the guard it says they must.
  • drainBody dereferences resp while its sibling drainClose guards
    resp == nil. Real, but every caller of the first holds a response; not
    worth a commit on its own.

No parser was touched, so no fuzz round is owed. Verification: make ci green.

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>
@dinstein
dinstein merged commit c01737a into main Aug 9, 2026
3 checks passed
@dinstein
dinstein deleted the tidy-transport branch August 9, 2026 15:30
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.

1 participant