Repository navigation
[P34] ci: build for iOS and run the tests on its simulator - #337
Merged
Merged
Conversation
Cancelling the caller of a tools/call resolves the request's slot at once and leaves the rest (marking the call abandoned, telling the server) to cancelRequest, which runs later on the actor. A response handled in between found the call neither pending for the caller nor abandoned: the slot dropped it, and with it the only copy of the id of the task the server had created, so the task ran on. A heavily loaded visionOS simulator hit it in "Cancelling the caller cancels the task on the server". - ResponseSlot.resolve and AnyPendingRequest.resume report whether their outcome is the one the sender gets. - handleResponse treats a tools/call answer the slot refused as abandoned and sends tasks/cancel for the task in it, as it does for an answer that arrives after cancelRequest. Tests: LateTaskAnswerTests.cancelRacesAnswer, a hand-driven peer that answers each of 500 calls with a task and cancels the caller as it answers; every task must get tasks/cancel. Without the fix about one run in five leaves an orphan on macOS. callerCancellation waits up to 10 s instead of 2 s for the server task to stop.
Building the package scheme for iOS failed: the interop client, the HelloClient example and a docs snippet start a server with Process, which does not exist on iOS, tvOS, watchOS or visionOS (Mac Catalyst is os(iOS)). - The interop client's --stdio, HelloClient and the transport-stdio-client snippet sit behind `#if !(os(iOS) || os(tvOS) || os(watchOS) || os(visionOS))` (the snippet behind `os(macOS)`, like its sibling in Client.swift). There --stdio throws and HelloClient prints why and exits 1; the woven docs are unchanged. - scripts/ci/apple-platform.sh <iOS|tvOS|watchOS|visionOS|macCatalyst> [<destination id>]: xcodebuild build-for-testing of the mcp-swift-sdk-Package scheme (every target, test bundles included) for the device SDK, unsigned, then xcodebuild test on the first simulator -showdestinations offers (this Mac for Mac Catalyst), with the result bundle in .build/apple/<platform>/. A missing SDK or runtime fails with the command that installs it; on Linux the job passes and says so, as fuzz does on macOS. - scripts/ci/jobs gains apple-ios; ci.yml an apple-platforms matrix (iOS) on macos-latest that uploads the result bundle on failure. Another platform is a line in each. Conformance and interop do not run there: their harnesses start the fixtures as host processes. - Two tests that waited a fixed time failed once each under the simulator's load: testServerInitializeMetadata waits for the sent message (MockTransport.waitForSentMessages), and the discovery timeout test waits up to 10 s for its POST to stop. - CONTRIBUTING, CLAUDE.md and CHANGELOG describe the job. Verified with Xcode 27.1: iOS, tvOS, visionOS and Mac Catalyst build for the device and pass on the simulator (1350 tests); watchOS is not installed here. macOS swift test, and build-test on Linux (RHEL UBI 9 through scripts/ci-linux.sh), pass.
AGENTS.md arrived with main (#318) and describes main's tree. Update the facts that the conformance stack changed: - The spec revisions: the SDK serves 2025-11-25 through the handshake and 2026-07-28 per request; code that serves both reads ProtocolProfile flags, and Version.supported lists both eras. - The repository map: conformance/ (fixtures and baselines), interop/, fuzz/, Examples/ with the doc snippets, docs/src/, design/, and scripts/ci/. There is one manifest, Package.swift. - Dependencies (swift-crypto and Yams; no eventsource), toolchains, the iOS simulator job, and the platform gates (SSE streams through the same code everywhere; Crypto with CryptoKit only for Secure Enclave keys; the Process gate). - Commands: the conformance legs, doc coverage, weave, and the CI job runner. - Stability: VERSIONING.md from 1.0.0, the api-breakage job, enum categories, and a deprecated shim that exists (Version.latest). - Concurrency: handlers that Client or Server store on themselves capture self weakly, because a strong capture keeps the server alive; the previous text said the opposite. - Tests and docs: expectWire golden tests, the handshake test configuration, the conformance baselines, the woven guides, the migration guide and CHANGELOG, and ROADMAP's SEP coverage table. - Generated files (docs, README, baselines, interop results) are not edited by hand.
The late-answer tests drove only the 2026-07-28 shape, where the task is the tools/call result; at 2025-11-25 it is nested in `task`, which handleResponse also reads. A hand-driven peer, LatePeer, now answers in either revision (initialize, a tool that runs only as a task, flat tasks/get and tasks/cancel results at 2025-11-25), and both tests run at both. Dropping the nested lookup fails both 2025-11-25 cases. - cancelRacesAnswer expects every call to have reached the peer and created a task (race.isSettled): a callTool that failed before sending created no task and passed. A one-minute time limit turns a missed cancellation into a failure instead of a hang. At 2025-11-25 it also checks that every call asked for a task. - clientCancelsOrphan waits up to 10 s for each step instead of sharing one 2 s deadline, and checks that tasks/cancel names the late task. - callerCancellation waits for the task to run on the server instead of sleeping 100 ms before it cancels the caller. scripts/ci/apple-platform.sh: a Mac whose Xcode lacks the platform's SDK or a simulator runtime skips the job and says so unless CI is set (GitHub Actions sets it), where it still fails. Before, running every job locally failed on such a Mac. Docs: - CHANGELOG: the tasks/cancel of a call cancelled as its answer arrives joins the tasks feature, which is new in 1.0.0, and says that over HTTPClientTransport at 2026-07-28 an answer not yet read when the cancellation closes the response stream is lost and its task keeps running. The platform line says that CI checks iOS only. - AGENTS.md: withTasks(_:) and withSkills(_:listInResources:) register their defaults, not Server.start; the process snippets gate on canImport(System) && os(macOS) because they also use System's FileDescriptor; swift-nio also backs the HTTP server example. - CLAUDE.md: the job scripts include api-breakage, fuzz and conformance-scripts; the apple-* skip rule.
This was referenced Nov 25, 2026
varun06
previously approved these changes
Nov 25, 2026
varun06
left a comment
Contributor
There was a problem hiding this comment.
Already reviewed and still looking good.
Base automatically changed from
conformance/p33-transport-release
to
rel/1.0.0
November 25, 2026 12:55
varun06
approved these changes
Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
rel/1.0.0in order (previous: P33 (#338) · next: P35 (#336))conformance/p34-apple-platformsconformance/p33-transport-release(stacked: GitHub retargets this PR torel/1.0.0when the previous part merges)4e87ad8client: cancel the task of a tools/call cancelled as its answer arrivesd181ebcci: build for iOS and run the tests on its simulatorad57600docs: bring AGENTS.md up to date with the stack91be03fclient: review fixes for the iOS PRSummary
The package builds for iOS, and CI checks it: a new
apple-iosjob builds every target, test bundles included, for the iOS device SDK and runsMCPTestsandSnippetTestson an iOS simulator. The job script takes any platform ofPackage.swift(iOS, tvOS, watchOS, visionOS, Mac Catalyst), so gating another one later is one line inscripts/ci/jobsand one matrix entry inci.yml. Running the suite on simulators also found a client race that could leave a server task running after its caller was cancelled; the first commit fixes it. A last commit bringsAGENTS.md, which arrived withmain(#318), up to date with the whole stack.Motivation
Building the
mcp-swift-sdk-Packagescheme for iOS failed:Processdoes not exist on iOS, tvOS, watchOS or visionOS (Mac Catalyst isos(iOS)). The interop client, theHelloClientexample and a docs snippet use it to start a server. Nothing in CI built for those platforms, so nothing caught it.Changes
client: cancel the task of a tools/call cancelled as its answer arrivestools/callresolves the request's slot at once and leaves the rest (marking the call abandoned, telling the server) tocancelRequest, which runs later on the actor. A response handled in between found the call neither pending for the caller nor abandoned: the slot dropped it, and with it the only copy of the id of the task the server had created, so the task ran on. A heavily loaded visionOS simulator hit it in "Cancelling the caller cancels the task on the server".ResponseSlot.resolveandAnyPendingRequest.resumereport whether their outcome is the one the sender gets (Sources/MCP/Base/PendingRequest.swift).handleResponsetreats atools/callanswer the slot refused as abandoned and sendstasks/cancelfor the task in it, as it already did for an answer that arrives aftercancelRequest(Sources/MCP/Client/Client.swift).ci: build for iOS and run the tests on its simulator--stdio,HelloClientand thetransport-stdio-clientsnippet sit behind#if !(os(iOS) || os(tvOS) || os(watchOS) || os(visionOS))(the snippet behindos(macOS), like its sibling inClient.swift). There--stdiothrows andHelloClientprints why and exits 1. The woven docs are unchanged.scripts/ci/apple-platform.sh <iOS|tvOS|watchOS|visionOS|macCatalyst> [<destination id>]:xcodebuild build-for-testingof themcp-swift-sdk-Packagescheme (every target, test bundles included) for the device SDK, unsigned;xcodebuild teston the first simulator-showdestinationsoffers (this Mac for Mac Catalyst), with the result bundle in.build/apple/<platform>/Tests.xcresult;fuzzdoes on macOS.scripts/ci/jobsgainsapple-ios;.github/workflows/ci.ymlanapple-platformsmatrix (iOS) onmacos-latestthat uploads the result bundle on failure.CONTRIBUTING.md,CLAUDE.mdand CHANGELOG (Fixes) describe the job and the fix.docs: bring AGENTS.md up to date with the stackAGENTS.mddescribedmain's tree. It now gives the two revisions the SDK serves (2025-11-25 through the handshake, 2026-07-28 per request) andProtocolProfile, the repository map (conformance/,interop/,fuzz/,Examples/,docs/src/,design/,scripts/ci/; one manifest), the dependencies, toolchains and platform gates, the commands,VERSIONING.mdfrom 1.0.0 with theapi-breakagejob, the generated files not to edit by hand, and the test and documentation rules.ClientorServerstore on themselves captureselfweakly, because a strong capture is a retain cycle that keeps every started server alive (fixed in P21 ([P21] ci: stability tooling for 1.x #350)).Behavior changes
tools/callcancelled while the server's answer creating a task is already on its way now getstasks/cancelfor that task; before, the task could keep running until its TTL.mcp-interop-client --stdiofails with a message andHelloClientexits 1. Both only compile there.Tests
LateTaskAnswerTests.cancelRacesAnswer: a hand-driven peer answers each of 500tools/calls with a new task and cancels the caller as it answers; every task must gettasks/cancel. Without the fix about one run in five leaves an orphan on macOS (the window is narrow, hence the 500 calls).callerCancellation(up to 10 s instead of 2 s),testServerInitializeMetadata(MockTransport.waitForSentMessagesinstead of a 200 ms sleep) and the discovery timeout test (up to 10 s instead of 1 s).Review notes
drive(ClientTasks.swift) still has a smaller window: at 2026-07-28 its firsttasks/get, which runs only when the create result is notworking, is outside the block that sendstasks/cancelon cancellation.Verification
xcodebuild test, 1237 + 113 tests each;scripts/ci/run-jobs.sh apple-iospasses (77 s).swift test1237 tests in 135 suites + 113 snippet tests (twice);swift scripts/weave.swift --check;mcp-interop-client --stdioagainstHelloServer.swift:6.1-rhel-ubi9,scripts/ci-linux.sh build-test): 1334 tests and the hello example;apple-iosskips there.AI usage disclosure: the changes, the tests, the commit messages and this description were written with Claude Opus 5.5 and reviewed by the authors.