Skip to content

fix(stateless): separate mutation and subscription observation deadlines - #600

Draft
ThorFuchs wants to merge 2 commits into
modelcontextprotocol:mainfrom
ThorFuchs:fix/stateless-subscription-observation
Draft

ThorFuchs wants to merge 2 commits into
modelcontextprotocol:mainfrom
ThorFuchs:fix/stateless-subscription-observation

Conversation

@ThorFuchs

Copy link
Copy Markdown

Problem

Related to #530 and our subscription-specific reproduction. This PR addresses the subscription probes, not the separate logging timeout in #530.

In server-stateless, the same stream timer covers opening the subscription, executing the diagnostic mutation on another connection, and observing the resulting notification. A correct server can therefore lose its subscriber before the mutation commits. The check then warns that a notification was missing, although there was no active subscription at publication.

Observed with the published 0.2.0-alpha.12 referee and a native Swift Streamable HTTP server (milliseconds relative to ACK write completion):

Event Debug run 1 Debug run 2 Release
Mutation starts 12.014 10.976 3.918
Subscription removed 1475.665 1478.121 513.870
Catalog published 4532.320 4454.250 485.240
Publication targets 0 0 1

Detailed trace and exact pinned-bundle evidence.

Change

  • Separate bounded subscription opening, diagnostic mutation, and post-mutation observation. The opening and observation windows retain their existing values; the mutation has a separate finite 10 s budget, aligned with the existing default of sendStatelessRequest.
  • Pass the abort signal into the mutation RPC, require a successful mutation response for mutation checks, and do not treat an incomplete negative observation as a successful filter test.
  • Invoke the trigger only after acknowledgment; frames already parsed before the trigger are not counted as its mutation receipt.
  • Explicitly abort/cancel the owned stream in cleanup.
  • Preserve existing check IDs, requirement severities, no-callback probe timeout values, dependency versions, lockfile and outer scenario timeout. No expected-failure waiver.

Validation

  • Native macOS ARM64, Node 24.22.3 / npm 11.19.1: locked npm ci, Prettier, git diff --check, targeted Vitest 29/29 (20 existing + 9 new), npm run build, full npm test 650/650 across 49 files, npm run check (tsgo, ESLint, Prettier) all completed successfully. The final formatting-only commit reproduces the two formatted files byte-for-byte from that tested checkout; all other tracked source files unchanged.
  • Independent Node 22.16.0 loopback HTTP/SSE proof: 10/10. Extracted published helper misses the real notification after a 2 s mutation with a 1.5 s stream window; candidate receives it with the same 1.5 s post-mutation observation window. Negative controls cover missing notification, hanging/rejected trigger, no ACK, wrong filter, early closure and a pre-trigger frame; cleanup control verifies the owned stream closes.
  • Both the original published referee bundle and the candidate bundle ran server-stateless against fresh processes of the unchanged bundled TypeScript everything-server example with pinned @modelcontextprotocol/sdk 1.29.0: 30/30, 0 failures, 0 warnings each. This example uses SDK-backed dispatch with a custom draft/stateless HTTP path; it is not a claim of native draft support by SDK 1.29.0. Runs used Node 22.16.0 in the local verification environment.
  • The native candidate bundle SHA-256 is 0d65ec7ba15f0f9a7f977cc7bec612f1592166287fcb57f1ae3cd83c46e23236; original published bundle b56fb575e61edaac83c2008af40a6a78b47815c4038a02a9b04cd336d38832a0.

The install reported existing lock-graph audit findings and install-script warnings, and the full tests emitted a Node DEP0190 warning from the existing client runner. No dependency updates are included in this scoped patch; audit attribution/remediation is not part of this PR.

Draft: requesting direction on the proposed phase boundaries; the direct patched-bundle A/B on the native Swift server remains to be run. No claim that the candidate has already passed that native scenario. The original #530 logging probe is deliberately left out of scope.

Copy link
Copy Markdown
Author

Native Swift cross-referee follow-up (N3.1)

Native macOS 27.3 ARM64, Apple Swift 6.4.2, Node 24.22.3/npm 11.19.1. Exact same HTTP B3 fixture source c99b65a9ee7879187e6d67e9771b8daa30115502 and Core 044e2ab332d9f55632c900c13f23502acd8e8972 (#61 candidate), one Debug and one Release binary reused across fresh processes. Published alpha.12 bundle SHA-256 b56fb575e61edaac83c2008af40a6a78b47815c4038a02a9b04cd336d38832a0, PR candidate b0fa91d7cef7d844e35a5526e2c9a7549e25dd83, bundle SHA-256 0d65ec7ba15f0f9a7f977cc7bec612f1592166287fcb57f1ae3cd83c46e23236.

Configuration Original Candidate Prompt mutation (original / candidate)
Debug pair 1 29 SUCCESS, 1 WARNING 30 SUCCESS 4.956 / 4.973 s
Debug pair 2 (candidate first) 29 SUCCESS, 1 WARNING 30 SUCCESS 4.624 / 4.799 s
Release 30 SUCCESS 30 SUCCESS 0.473 / 0.471 s

178 SUCCESS, 2 WARNING, 0 FAILURE/SKIPPED across 180 checks. Both warnings are the original sep-2575-server-sends-prompts-list-changed-on-subscription observation warning. All 10 successful prompt/tool notification checks contain real change frames with subscription IDs; six fixtures exit 0 and report joined=2, active=0. 29 matching workspace pins; recorded input and executable hashes unchanged. Both archived SwiftPM lockfiles independently rehashed. Candidate Debug succeeds even though mutation latency is slightly longer.

Our local diagnostic runner initially rejected all six receipts because it incorrectly assumed 30 distinct IDs (the meta-invalid-400 ID deliberately has three distinct fieldIssue variants); it also expected the warning under error rather than errorMessage. Original archive and exit 1 remain intact. Corrected validator and 15/15 regression controls plus read-only archive replay yield PASS_DIAGNOSTIC_OFFLINE_REPLAY. Archive SHA-256 fcdccd666088a412a98bde53d78170e4741e513164776d7068f8ac22ee47397a. Reproduction, exact hashes, limitations and replay. No fresh native execution after the checker correction; original native process exit receipts for fixtures are present; referee exit is inferred from reaching the original checked validation and corroborated by logs.

This directly compares the two referee artifacts, not solely the patch against a matched upstream-base build. Together with the earlier isolated loopback proof and N2 trace chronology, the native result supports separating mutation and observation budgets. The published referee result is unchanged; no server deadline, test mask, or severity change. Upstream review/acceptance remains pending.

Copy link
Copy Markdown
Author

Hi @pcarleton and @felixweinberger — we've now completed the planned validation for this change, including the full 650-test suite and the native Swift cross-referee A/B described above. The candidate passed all 90 checks; both original Debug runs reproduced the observation warning.

When you have a chance, I'd really appreciate your feedback and review of the proposed separation of the mutation and observation phases. I'm happy to provide additional traces, answer any questions, or adapt the approach based on your suggestions.

Thank you for all your work on the conformance suite!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant