Repository navigation
[Server] Serve both protocol eras over stdio - #546
Open
chr-hertel wants to merge 11 commits into
Open
chr-hertel wants to merge 11 commits into
chr-hertel wants to merge 11 commits into
Conversation
chr-hertel
requested review from
CodeWithKyrian,
Nyholm and
soyuka
as code owners
October 7, 2026 21:29
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Stream frames are advanced before being written, which can delay progress notifications until subsequent work completes.
1 open finding
What changed in this PR
Adds dual-era stdio support, selecting the handshake or modern dispatcher from the first request.
Changes:
- Routes stdio traffic by protocol era and supports modern streams and cancellation.
- Adds headerless stateless dispatch and correlated protocol errors.
- Expands tests and documentation for dual-era behavior.
| File | Description |
|---|---|
src/Server/Transport/StdioTransport.php |
Implements dual-era routing and stream handling. |
src/Server/Stateless/StatelessProtocol.php |
Adds headerless inline dispatch. |
src/Server/Protocol.php |
Correlates missing-session errors by request ID. |
tests/Unit/Server/Transport/StdioDualEraTest.php |
Tests stdio era selection and streams. |
tests/Unit/Server/Stateless/StatelessProtocolTest.php |
Tests inline modern dispatch. |
tests/Unit/Server/ProtocolTest.php |
Verifies correlated handshake errors. |
examples/server/bootstrap.php |
Documents dual-era example behavior. |
docs/run/protocol-eras.md |
Documents stdio era selection. |
docs/protocol-versions.md |
Updates protocol compatibility guidance. |
CHANGELOG.md |
Records the new behavior. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
chr-hertel
added this pull request to stack #549
October 7, 2026 21:49
chr-hertel
force-pushed
the
server-stdio-dual-era
branch
from
October 7, 2026 22:35
62c01f5 to
6a22720
Compare
chr-hertel
force-pushed
the
server-stdio-dual-era
branch
from
October 7, 2026 22:52
6a22720 to
87e15e5
Compare
| if ($classification->modern && null === $this->stateless) { | ||
| // Served nothing but the handshake: say which revisions that | ||
| // is, the way the HTTP entry does, and leave the era open. | ||
| $this->writeError(Error::forUnsupportedProtocolVersion((string) $classification->claimedVersion, ProtocolVersion::handshakeVersions(), $request['id'])); |
Comment on lines
+241
to
+247
| if (\is_array($decoded) && self::CANCELLED_NOTIFICATION === ($decoded['method'] ?? null) && !isset($decoded['id'])) { | ||
| $requestId = $decoded['params']['requestId'] ?? null; | ||
|
|
||
| if ((\is_string($requestId) || \is_int($requestId)) && isset($this->streams[$key = self::streamKey($requestId)])) { | ||
| unset($this->streams[$key]); | ||
| $this->logger->debug('StdioTransport dropped a cancelled request.', ['request_id' => $requestId]); | ||
| } |
chr-hertel
force-pushed
the
server-stdio-dual-era
branch
from
October 8, 2026 00:55
87e15e5 to
087aaac
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A leading JSON-RPC response incorrectly produces an id-less error before era selection.
3 open findings
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
| return; | ||
| } | ||
|
|
||
| $this->handleMessage($message, $this->sessionId); |
This branch has not been deployed
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.

Split out of #537.
StdioTransportsettles the era on the client's first request: a2026-07-28_metaenvelope gets the modern dispatcher, anything else the handshake. A request from the other era is refused afterwards (-32022/-32600)subscriptions/listennext to other requests,notifications/cancelledto stop oneinitializeon a modern-only endpoint gets-32022naming the served revisions, and the handshake leg echoes the id when refusing a request without a session - so a probing client fails fast instead of timing out