[PR #1461] [MERGED] fix(mcp): validate doctor probe against its discovered output contract #2902

Closed
opened 2026-10-17 21:11:36 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1461
Author: @N0zoM1z0
Created: 10/10/2026
Status: ✅ Merged
Merged: 10/10/2026
Merged by: @N0zoM1z0

Base: main ← Head: fix/mcp-doctor-discovered-output-validation


📝 Commits (1)

  • 946bde7 fix(mcp): validate doctor probe against its discovered output contract

📊 Changes

3 files changed (+144 additions, -7 deletions)

View changed files

📝 src/mcpDoctor.ts (+20 -6)
📝 tests/boundary/mcp/mcpDoctor.test.ts (+76 -1)
➕ tests/fixtures/mcpDoctorReply.mjs (+48 -0)

📄 Description

The MCP doctor could report healthy: true for a binary_session reply that violated the output schema advertised by the same production server. Discover the complete tool/prompt inventory first, select the probe definition by name, and pass that definition to the SDK call. Keep the absolute deadline and owned-child cleanup.

A rejected probe now reports the request/schema failure while retaining the already observed server and inventory, rather than replacing them with an undifferentiated transport failure. The successful report and default Evidence contract remain unchanged.

Validation:

  • A committed stdio replay regression captures fresh metadata and a valid reply from the actual production server, then checks both valid and schema-invalid replies. The invalid case fails on the original main implementation and passes with this fix.
  • All nine doctor/CLI-help tests, full serial typecheck, lint, duplication gate and changed-file formatting pass under the documented two-CPU and process-family budget.
  • The actual public CLI doctor report is byte-identical (1,593 bytes). A 74-byte JavaScript target produces identical default Evidence to main through CLI and SDK stdio MCP; text/structured parity, source digest and subsequent ping pass.
  • Independent fault injection at the actual production stdio producer confirms main accepts an extra output property and the fix rejects it. This exercises the production client/server boundary; it does not certify a deep-analysis provider.

This is a diagnostic correctness fix. Interleaved cold CLI timings did not establish a speedup, and no model-token saving is claimed. The SDK internal cause of the original default-path behavior remains unverified.

Closes #1454. Refs #1065, #723, #1433.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1461 **Author:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Created:** 10/10/2026 **Status:** ✅ Merged **Merged:** 10/10/2026 **Merged by:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Base:** `main` ← **Head:** `fix/mcp-doctor-discovered-output-validation` --- ### 📝 Commits (1) - [`946bde7`](https://github.com/morluto/rea/commit/946bde7dd8091da53cd645d7e80dd83d42d0e87f) fix(mcp): validate doctor probe against its discovered output contract ### 📊 Changes **3 files changed** (+144 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `src/mcpDoctor.ts` (+20 -6) 📝 `tests/boundary/mcp/mcpDoctor.test.ts` (+76 -1) ➕ `tests/fixtures/mcpDoctorReply.mjs` (+48 -0) </details> ### 📄 Description The MCP doctor could report `healthy: true` for a `binary_session` reply that violated the output schema advertised by the same production server. Discover the complete tool/prompt inventory first, select the probe definition by name, and pass that definition to the SDK call. Keep the absolute deadline and owned-child cleanup. A rejected probe now reports the request/schema failure while retaining the already observed server and inventory, rather than replacing them with an undifferentiated transport failure. The successful report and default Evidence contract remain unchanged. Validation: - A committed stdio replay regression captures fresh metadata and a valid reply from the actual production server, then checks both valid and schema-invalid replies. The invalid case fails on the original main implementation and passes with this fix. - All nine doctor/CLI-help tests, full serial typecheck, lint, duplication gate and changed-file formatting pass under the documented two-CPU and process-family budget. - The actual public CLI doctor report is byte-identical (1,593 bytes). A 74-byte JavaScript target produces identical default Evidence to main through CLI and SDK stdio MCP; text/structured parity, source digest and subsequent ping pass. - Independent fault injection at the actual production stdio producer confirms main accepts an extra output property and the fix rejects it. This exercises the production client/server boundary; it does not certify a deep-analysis provider. This is a diagnostic correctness fix. Interleaved cold CLI timings did not establish a speedup, and no model-token saving is claimed. The SDK internal cause of the original default-path behavior remains unverified. Closes #1454. Refs #1065, #723, #1433. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:11:36 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2902
No description provided.