``` STEP 2 REPORT — Stdio JSON-RPC and MCP lifecycle Date: 2026-10-19 Step 2 readiness: TRUE — required automated checks pass. Ready for the next step: TRUE, subject to orchestrator review/acceptance. Full product/native compatibility readiness: FALSE; native evidence is unchanged. IMPLEMENTED - Replaced the input-discard entry point with the .NET 10 stdio MCP server. Raw protocol streams use UTF-8; stdout contains protocol messages only. Console diagnostics use UTF-8 stderr, with no startup banner. - Added bounded newline framing, LF/CRLF acceptance, strict UTF-8 rejection, serialized complete output writes, per-message flushes and stream ownership. - Implemented JSON-RPC envelope validation, string/signed-Int64 ID preservation, batch rejection, duplicate-envelope rejection, explicit protocol errors and per-request exception/result-serialization boundaries. Actual transport I/O failures propagate to the entry point and exit nonzero instead of succeeding. - Implemented initialize, notifications/initialized, ping, tools/list, tools/call and notifications/cancelled. Version negotiation supports only 2025-11-25, including returning it as the alternative for an unsupported requested version. - Initialization validates required fields and known optional client metadata, icons, nested capability shapes and request metadata. Client capabilities are not acted on. Ping works at every lifecycle stage; tools require the complete handshake. Repeated initialization and premature tool requests fail explicitly. - Production registry is empty: tools/list returns {"tools":[]}. Only the tools capability is advertised, with listChanged=false. No profile/generation tools, guessed mappings, fake writers or test-only tools are registered in production. - Added thread-safe registration/lookup, deterministic discovery and registry freezing when the session starts. Typed tool contracts use the BCL JSON Schema exporter and the same strict serializer for schemas, inputs and outputs. Handlers support semantic input validation, request cancellation, structured output plus matching JSON text content, and expected isError=true outcomes. - Added bounded active-request tracking. Awaiting handlers do not prevent reading notifications/unrelated requests. String/numeric IDs are distinct. Duplicate active IDs are rejected without replacing/cancelling original work. - EOF and lifetime cancellation (wired to Ctrl+C) cancel outstanding handlers and await cleanup. Valid notifications never receive responses. Cancelled work normally emits no response; unrelated work survives per-request cancellation. - Updated README and added the current protocol contract. The compatibility inventory now links to Step 2 without rewriting its historical native evidence. PROTOCOL LIMITS AND DECISIONS - Incoming limit: 1,048,576 UTF-8 bytes, excluding LF or CRLF. Fixed limit-plus-one frame buffer and 4 KiB read buffer; oversized remainders are drained, not stored. Exactly the limit is accepted, including with CRLF. One bounded error and fixed stderr diagnostic is emitted per oversized frame, then the next frame is read. - Invalid UTF-8: -32700, no replacement decoding. BOM is not stripped. System.Text.Json's default maximum nesting depth is 64. - Empty stream: silent EOF. Blank line: parse error. Nonempty final frame without newline: processed exactly once; malformed final JSON/UTF-8 returns an error. - IDs: strings or signed 64-bit integer tokens. Decimal/fractional/exponent, null, boolean, array/object and out-of-range numeric IDs are unsupported. Unidentifiable/ambiguous IDs use null in errors. - At most 64 active requests; excess requests return -32000. Invalid lifecycle state returns -32002. Standard errors: -32700 parse, -32600 invalid request/ oversized frame/duplicate active ID, -32601 unknown method, -32602 invalid params/tool selection, -32603 unexpected handler or serialization failure. - No pagination cursor is issued; supplied cursors are rejected. Fixed method parameter objects reject unknown fields, including task augmentation; _meta accepts extension fields and validates request progressToken type. - Registry is immutable during a session; no list-change notifications. Typed contracts are not a general arbitrary-JSON-Schema validation engine; domain constraints belong in registered validators/handlers. - Cancellation never targets initialize or the entire server. Invalid/unknown/ completed cancellation IDs are ignored. Already-started output writes complete, so a cancellation race may still deliver a late response. - No shutdown method, resources, prompts, sampling, elicitation, logging RPCs, task APIs, HTTP, server-initiated requests or generation behavior was added. CHANGED FILES (21 deliverables, including this report) README.md docs\mcp-protocol.md docs\format-compatibility.md src\GAJ3T.MusicGen.RiffGrooveBuilder.Server\Program.cs src\GAJ3T.MusicGen.RiffGrooveBuilder.Server\Protocol\StdioTransport.cs src\GAJ3T.MusicGen.RiffGrooveBuilder.Server\Protocol\JsonRpcDispatcher.cs src\GAJ3T.MusicGen.RiffGrooveBuilder.Server\Protocol\McpSession.cs src\GAJ3T.MusicGen.RiffGrooveBuilder.Server\Protocol\McpParameters.cs src\GAJ3T.MusicGen.RiffGrooveBuilder.Server\Protocol\JsonRpcError.cs src\GAJ3T.MusicGen.RiffGrooveBuilder.Server\Tools\McpToolRegistry.cs src\GAJ3T.MusicGen.RiffGrooveBuilder.Server\Tools\McpToolDefinition.cs tests\GAJ3T.MusicGen.RiffGrooveBuilder.UnitTests\GAJ3T.MusicGen.RiffGrooveBuilder.UnitTests.csproj tests\GAJ3T.MusicGen.RiffGrooveBuilder.UnitTests\packages.lock.json tests\GAJ3T.MusicGen.RiffGrooveBuilder.UnitTests\Protocol\StdioTransportTests.cs tests\GAJ3T.MusicGen.RiffGrooveBuilder.UnitTests\Protocol\JsonRpcDispatcherTests.cs tests\GAJ3T.MusicGen.RiffGrooveBuilder.UnitTests\Protocol\McpSessionTests.cs tests\GAJ3T.MusicGen.RiffGrooveBuilder.UnitTests\Protocol\ProtocolTestConnection.cs tests\GAJ3T.MusicGen.RiffGrooveBuilder.IntegrationTests\Stdio\ProcessStartupTests.cs tests\GAJ3T.MusicGen.RiffGrooveBuilder.IntegrationTests\Stdio\McpProtocolTests.cs tests\GAJ3T.MusicGen.RiffGrooveBuilder.IntegrationTests\Stdio\McpProcess.cs prompts\report_2.md DEPENDENCIES AND VALIDATION No package was added or upgraded. UnitTests now also references Server. A normal restore after that project-manifest change regenerated its dependency lock with the Server project entry; central versions and DryWetMIDI 8.0.3 are unchanged. All dotnet commands ran from the repository root with process-local settings: $env:PATH = 'C:\Program Files\dotnet;' + $env:PATH $env:DOTNET_CLI_TELEMETRY_OPTOUT = '1' $env:DOTNET_NOLOGO = '1' No global PATH/tool installation changes were made. 1. dotnet restore .\GAJ3T.MusicGen.RiffGrooveBuilder.slnx PASS, exit 0, five projects restored after the project reference change. 2. dotnet test .\tests\GAJ3T.MusicGen.RiffGrooveBuilder.UnitTests\GAJ3T.MusicGen.RiffGrooveBuilder.UnitTests.csproj -c Release --no-restore --filter FullyQualifiedName~Protocol Development run 1: exit 1, CS9007 in two test raw interpolated strings. Fixed the test interpolation delimiter counts. Development run 2: exit 1, 103 passed / 1 failed / 0 skipped. The Unicode ID assertion compared raw escape spelling instead of decoded JSON ID value. Corrected it to assert ID type and decoded value (not weaken ID preservation). Subsequent combined protocol runs passed. 3. dotnet test .\GAJ3T.MusicGen.RiffGrooveBuilder.slnx -c Release --no-restore --filter 'FullyQualifiedName~Protocol|FullyQualifiedName~ProcessStartup' PASS, exit 0. First successful run: 104 protocol units + 14 process cases. Final targeted run after added regressions: 112 protocol units + 14 process cases = 126 passed, 0 failed, 0 skipped. FINAL REQUIRED ACCEPTANCE COMMANDS 4. dotnet build .\GAJ3T.MusicGen.RiffGrooveBuilder.slnx -c Release --no-restore PASS, exit 0. All five projects built, 0 warnings, 0 errors. 5. dotnet test .\GAJ3T.MusicGen.RiffGrooveBuilder.slnx -c Release --no-build PASS, exit 0. Both xUnit test assemblies discovered and executed: UnitTests: 116 passed, 0 failed, 0 skipped (110 ms). 112 protocol cases + all 4 retained framework/dependency smoke cases. IntegrationTests: 14 passed, 0 failed, 0 skipped (936 ms). 4 updated startup cases + 10 additional real-apphost protocol cases. TOTAL: 130 passed, 0 failed, 0 skipped. 6. dotnet restore .\GAJ3T.MusicGen.RiffGrooveBuilder.slnx --locked-mode PASS, exit 0. All five projects restored against their generated locks. Additional checks: - Editor problems tool over src/tests: no errors found (final check). - git --no-pager diff --check: PASS, exit 0. - PowerShell trailing-whitespace audit: PASS, exit 0; 29 source/test/doc/lock files checked, excluding bin/obj. No scratch artifacts were created. - PowerShell SHA256 preservation audit: PASS, exit 0. The existing orchestrator prompts and Step 1 report match entry hashes, including the pre-existing modified plan: plan.md: 421BE54DC8D428D813BE8A03CA7263C4A981158512191F02789409AF5AEE8677 step_1.md: 03A51C17645BCB7AC58F02648928FC85B4E32CDB1FF5A458878FB574E63AB0CF step_2.md: BC6E4DB1A329F02E2DE12EE9C5ED9370390AE12AA585BA557AB47E0B13688E7B report_1.md: 5B8DFA296AC728CEB6AFFC404D12AACD20FF9C9FE69E3793F6741C728F5AE416 TEST EVIDENCE - Unit transport coverage includes UTF-8/non-ASCII, escaped newlines, invalid UTF-8 including final EOF, empty/blank/final frames, LF/CRLF, byte limits, multi-buffer oversize resynchronization, concurrent serialized writes, flushes, borrowed stream ownership and idle-read cancellation. - Dispatcher/session coverage includes supported/invalid IDs, malformed JSON, envelopes/batches, notification silence, initialization validation/version/ state, ping, empty registry, test-only discovery/schema/result agreement, strict typed/semantic argument validation and expected tool execution errors. - Awaiting synthetic handlers exercise cancellation, unrelated request survival, string/integer ID distinction, duplicate active IDs, overlapping completion, admission bounds, EOF/lifetime cancellation, internal exceptions, response serialization failure recovery and actual read/write I/O failure propagation. - Real Server apphost tests exercise the complete handshake, empty discovery, ping, no notification reply, per-line valid JSON-RPC, malformed input then valid requests on the same connection, unknown methods/tools, invalid params, unsupported-version alternative, repeated initialization, exact 1 MiB/oversize/ invalid-UTF-8 frames and final non-newline frames. - Apphost cases run beside test output and in the existing unrelated Windows system directory. Every process has a 15-second operation timeout, concurrent stdout/stderr draining, exit-zero assertions and bounded process-owned cleanup. No process-name killing or filesystem writes outside the checkout are used. ISSUES, UNRUN CHECKS AND READINESS - Resolved the two development-test issues described above; no production protocol failure remains in final validation. - Editor test discovery was already known unavailable from Step 1. Used the explicitly approved CLI fallback; no required test was skipped or counted from an empty discovery result. - Ctrl+C's lifetime-token path is unit-tested. An actual interactive Windows console control event was not injected; real-process EOF shutdown is tested. - No native/application/deployment checks were performed: composition, real profiles, MIDI/native writers, publication and licensed plugin/Cubase acceptance remain later-step work, not Step 2 claims. - Exact product/version/settings, native schemas/extension semantics, authorized fixtures/template rights and verified articulation mappings remain missing. MCP implementation/testing does not establish AGP/SDP or Cubase compatibility. - No unresolved Step 2 blocker. Automated Step 2 exit criteria are satisfied. Orchestrator review is still required before progression. - Preserved prior scaffold work and existing prompt changes. No commits, delegation, new orchestrator prompts or future-step implementation. Stopping after this report. ```