Commit 47e156d
committed
Rework channel liveness, stream ids, and init ordering after review
The second review round found several defects that traced back to a few
structural gaps rather than isolated bugs; this addresses the gaps.
- Channel delivery is now a value: write() returns whether the message
reached the event store or an attached response, an EventStore failure is
contained inside the write (resumability degrades, the stream survives,
no store text on the wire), and attach() returns None on a dead channel
so nothing can stream from one. A server-to-client request that cannot
reach any client fails the caller with CONNECTION_CLOSED instead of
parking it, and the JSON-response body derives from the channel's
recorded outcome (result, terminated-404, or 500) rather than a
"cannot happen" branch.
- Stream ids handed to the EventStore are minted by the transport in a
session-scoped namespace, so a client-chosen request id can no longer
name the standalone GET stream and two sessions on one store can no
longer replay each other's frames.
- One SSE-response runner owns the pump, error containment, and cleanup
for the POST, GET, and replay responses (the POST path had lost the
guard its siblings kept).
- A session-level gate holds requests that arrive while an initialize is
still being served until the handshake commits, restoring the ordering
the stream-pair driver's parked read loop used to guarantee.
- The POSTed client message is delivered even when the 202 could not be
written back, and the correlator marks the single site where the
cancelled-request answer policy lives for every transport.
Adds regression tests for each of the above.1 parent 1e3be94 commit 47e156d
7 files changed
Lines changed: 659 additions & 143 deletions
File tree
- docs
- src/mcp
- server
- tests
- interaction
- server
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
744 | 744 | | |
745 | 745 | | |
746 | 746 | | |
747 | | - | |
748 | | - | |
| 747 | + | |
| 748 | + | |
749 | 749 | | |
750 | 750 | | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
751 | 755 | | |
752 | 756 | | |
753 | 757 | | |
| |||
757 | 761 | | |
758 | 762 | | |
759 | 763 | | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
760 | 776 | | |
761 | 777 | | |
762 | 778 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
234 | 239 | | |
235 | 240 | | |
236 | 241 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
448 | 448 | | |
449 | 449 | | |
450 | 450 | | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
451 | 456 | | |
452 | 457 | | |
453 | 458 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
| 283 | + | |
| 284 | + | |
284 | 285 | | |
285 | 286 | | |
286 | 287 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
426 | | - | |
| 426 | + | |
427 | 427 | | |
428 | 428 | | |
429 | 429 | | |
| |||
0 commit comments