@@ -555,7 +555,7 @@ class StdioTransportTest < ActiveSupport::TestCase
555555 test "locks the legacy era on a successful initialize and rejects a later modern envelope" do
556556 responses = run_transport_session ( [
557557 initialize_request ( id : 1 ) ,
558- modern_ping_request ( id : 2 ) ,
558+ modern_tools_list_request ( id : 2 ) ,
559559 ] )
560560
561561 refute responses [ 0 ] . key? ( :error )
@@ -568,30 +568,31 @@ class StdioTransportTest < ActiveSupport::TestCase
568568 # the legacy handshake locks `:legacy`, so a later modern envelope is still rejected.
569569 responses = run_transport_session ( [
570570 initialize_request ( id : 1 , protocol_version : "2026-07-28" ) ,
571- modern_ping_request ( id : 2 ) ,
571+ modern_tools_list_request ( id : 2 ) ,
572572 ] )
573573
574574 assert_equal "2026-07-28" , responses [ 0 ] . dig ( :result , :protocolVersion )
575575 assert_equal :legacy , session_era
576576 assert_equal JsonRpcHandler ::ErrorCode ::INVALID_REQUEST , responses [ 1 ] . dig ( :error , :code )
577577 end
578578
579- test "locks the modern era on a successful server/discover and rejects a later initialize with -32022 " do
579+ test "locks the modern era on a successful server/discover and rejects a later initialize with -32601 " do
580580 responses = run_transport_session ( [
581581 { jsonrpc : "2.0" , method : "server/discover" , id : 1 } ,
582582 initialize_request ( id : 2 ) ,
583- modern_ping_request ( id : 3 ) ,
583+ modern_tools_list_request ( id : 3 ) ,
584584 ] )
585585
586586 assert_equal Configuration ::SUPPORTED_MODERN_PROTOCOL_VERSIONS , responses [ 0 ] . dig ( :result , :supportedVersions )
587587 assert_equal :modern , session_era
588- assert_equal ErrorCodes ::UNSUPPORTED_PROTOCOL_VERSION , responses [ 1 ] . dig ( :error , :code )
589- assert_equal Configuration ::SUPPORTED_MODERN_PROTOCOL_VERSIONS , responses [ 1 ] . dig ( :error , :data , :supported )
588+ # SEP-2575 removes `initialize` from the modern lifecycle, so a modern-locked connection
589+ # answers it with Method not found.
590+ assert_equal JsonRpcHandler ::ErrorCode ::METHOD_NOT_FOUND , responses [ 1 ] . dig ( :error , :code )
590591 refute responses [ 2 ] . key? ( :error )
591592 end
592593
593594 test "locks the modern era on a successful request carrying the modern envelope" do
594- responses = run_transport_session ( [ modern_ping_request ( id : 1 ) ] )
595+ responses = run_transport_session ( [ modern_tools_list_request ( id : 1 ) ] )
595596
596597 refute responses [ 0 ] . key? ( :error )
597598 assert_equal :modern , session_era
@@ -601,7 +602,7 @@ class StdioTransportTest < ActiveSupport::TestCase
601602 # An unsupported envelope version fails with -32022, so the connection stays unlocked
602603 # and a legacy initialize can still succeed afterwards.
603604 responses = run_transport_session ( [
604- modern_ping_request ( id : 1 , version : "2027-01-01" ) ,
605+ modern_tools_list_request ( id : 1 , version : "2027-01-01" ) ,
605606 initialize_request ( id : 2 ) ,
606607 ] )
607608
@@ -612,16 +613,29 @@ class StdioTransportTest < ActiveSupport::TestCase
612613
613614 test "requires the modern envelope after a modern era lock" do
614615 responses = run_transport_session ( [
615- modern_ping_request ( id : 1 ) ,
616- { jsonrpc : "2.0" , method : "ping " , id : 2 } ,
616+ modern_tools_list_request ( id : 1 ) ,
617+ { jsonrpc : "2.0" , method : "tools/list " , id : 2 } ,
617618 ] )
618619
619620 refute responses [ 0 ] . key? ( :error )
620621 assert_equal JsonRpcHandler ::ErrorCode ::INVALID_PARAMS , responses [ 1 ] . dig ( :error , :code )
621622 end
622623
624+ test "answers removed lifecycle methods with -32601 after a modern era lock" do
625+ removed_requests = Methods ::MODERN_REMOVED_METHODS . each_with_index . map do |method , index |
626+ { jsonrpc : "2.0" , method : method , id : index + 2 }
627+ end
628+ responses = run_transport_session ( [ modern_tools_list_request ( id : 1 ) ] + removed_requests )
629+
630+ refute responses [ 0 ] . key? ( :error )
631+ responses [ 1 ..] . each_with_index do |response , index |
632+ method = Methods ::MODERN_REMOVED_METHODS [ index ]
633+ assert_equal JsonRpcHandler ::ErrorCode ::METHOD_NOT_FOUND , response . dig ( :error , :code ) , "expected -32601 for #{ method } "
634+ end
635+ end
636+
623637 test "#send_request raises on a modern-locked session" do
624- run_transport_session ( [ modern_ping_request ( id : 1 ) ] )
638+ run_transport_session ( [ modern_tools_list_request ( id : 1 ) ] )
625639
626640 error = assert_raises ( RuntimeError ) do
627641 @transport . send_request ( "roots/list" )
@@ -643,10 +657,12 @@ def initialize_request(id:, protocol_version: "2025-11-25")
643657 }
644658 end
645659
646- def modern_ping_request ( id :, version : "2026-07-28" )
660+ # `tools/list` stands in as the era-distinctive modern request: `ping` cannot,
661+ # because SEP-2575 removes it from the modern lifecycle (-32601 there).
662+ def modern_tools_list_request ( id :, version : "2026-07-28" )
647663 {
648664 jsonrpc : "2.0" ,
649- method : "ping " ,
665+ method : "tools/list " ,
650666 id : id ,
651667 params : {
652668 _meta : {
0 commit comments