Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(ios-simulator): harden cancellation boundaries
JiangJiahao6096be38651a
diff --git a/apps/desktop/src/main/maker-host/__tests__/iosSimulatorShellHook.test.ts b/apps/desktop/src/main/maker-host/__tests__/iosSimulatorShellHook.test.tsindex 47a2b45c14..a8da034749 100644--- a/apps/desktop/src/main/maker-host/__tests__/iosSimulatorShellHook.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/iosSimulatorShellHook.test.ts@@ -4,6 +4,8 @@ import type { Logger } from '@cindy/maker-core';import { createIOSSimulatorShellGuardHook } from '../claude-hooks/ios-simulator-shell-hook.js';+const describeMac = process.platform === 'darwin' ? describe : describe.skip;+function createLoggerSpy(): { logger: Logger; warn: ReturnType<typeof vi.fn> } {const warn = vi.fn();const logger = {@@ -18,7 +20,7 @@ function createLoggerSpy(): { logger: Logger; warn: ReturnType<typeof vi.fn> } {return { logger, warn };}-describe('iOS Simulator shell guard hook', () => {+describeMac('iOS Simulator shell guard hook', () => {it('denies bypass commands without persisting command text in logs', async () => {const { logger, warn } = createLoggerSpy();const hook = createIOSSimulatorShellGuardHook(logger);diff --git a/apps/desktop/src/main/maker-host/__tests__/shellCommandPolicy.test.ts b/apps/desktop/src/main/maker-host/__tests__/shellCommandPolicy.test.tsindex 15f62f0f89..a52351d0f2 100644--- a/apps/desktop/src/main/maker-host/__tests__/shellCommandPolicy.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/shellCommandPolicy.test.ts@@ -80,6 +80,12 @@ describeMac('embedded iOS Simulator shell policy', () => {'TOOL=$(printf simctl); xcrun "$TOOL" shutdown DEVICE','launchctl submit -l cindy-test -- /usr/bin/xcrun simctl shutdown DEVICE',`sandbox-exec -p '(version 1) (allow default)' /usr/bin/xcrun simctl shutdown DEVICE`,+ "shopt -s expand_aliases\nalias sim='xcrun simctl'\nsim shutdown DEVICE",+ "alias sim=xcrun\\ simctl; eval 'sim erase DEVICE'",+ "builtin alias sim='/usr/bin/xcrun simctl'; eval 'sim shutdown DEVICE'",+ "command -- alias sim='open -a Simulator'; eval sim",+ "alias safe='ls -la' sim='xcrun simctl'; eval 'sim boot DEVICE'",+ "alias sc='simctl'; eval 'sc shutdown DEVICE'",])('denies Simulator mutation hidden behind shell execution: %s', (command) => {expect(getDesktopShellCommandPolicy(command)).toMatchObject({ decision: 'deny' });});@@ -148,6 +154,10 @@ PY`,`git grep simctl | awk '{print $1}'`,`python3 -c 'print("ordinary")'; git grep simctl`,'git grep simctl || python3',+ 'alias',+ 'alias sim',+ "alias ll='ls -la'; ll",+ 'echo "alias sim=\'xcrun simctl\'"',])('allows a non-bypass command: %s', (command) => {expect(getDesktopShellCommandPolicy(command)).toBeUndefined();});diff --git a/apps/desktop/src/main/maker-host/shell-command-policy.ts b/apps/desktop/src/main/maker-host/shell-command-policy.tsindex 3d6893afac..f6337bb89d 100644--- a/apps/desktop/src/main/maker-host/shell-command-policy.ts+++ b/apps/desktop/src/main/maker-host/shell-command-policy.ts@@ -896,6 +896,23 @@ function containsSimulatorFunctionBody(command: string, depth: number): booleanreturn false;}+/** Alias bodies are executable later, so reject unsafe definitions up front. */+function containsSimulatorAliasDefinition(tokens: string[], depth: number): boolean {+ if (executableName(tokens[0]) !== 'alias') return false;+ let index = tokens[1] === '--' ? 2 : 1;+ for (; index < tokens.length; index += 1) {+ const definition = tokens[index]!;+ const separator = definition.indexOf('=');+ // `alias` and `alias name` only inspect the current shell state.+ if (separator <= 0) continue;+ const body = definition.slice(separator + 1);+ if (containsLiteralSimulatorExecutor(body) || containsSimulatorBypass(body, depth + 1)) {+ return true;+ }+ }+ return false;+}+function containsSimulatorBypass(command: string, depth = 0): boolean {if (depth > 8) return /\b(?:simctl|Simulator(?:\.app)?)\b/i.test(command);if (@@ -918,6 +935,7 @@ function containsSimulatorBypass(command: string, depth = 0): boolean {if (hasUnresolvedExecutableExpansion(segment, tokens)) return true;const unwrapped = unwrapCommand(tokens);if (unwrapped.inspectionOnly) continue;+ if (containsSimulatorAliasDefinition(unwrapped.tokens, depth)) return true;if (unwrapped.nestedShell !== null) {if (unwrapped.unresolvedWrapper)return containsSimulatorExecutor(tokenizeShellSegment(segment));diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/ios-simulator.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/ios-simulator.test.tsindex 505839ce2e..1345a5b7f5 100644--- a/apps/desktop/src/main/mcp-integrations/__tests__/ios-simulator.test.ts+++ b/apps/desktop/src/main/mcp-integrations/__tests__/ios-simulator.test.ts@@ -578,7 +578,10 @@ describe('iOS Simulator host', () => {});await scheduled[0]!.task();- expect(lifecycle.shutdownExact).toHaveBeenCalledWith(detached.simulatorUdid);+ expect(lifecycle.shutdownExact).toHaveBeenCalledWith(+ detached.simulatorUdid,+ expect.any(AbortSignal),+ );expect(actor.listAll()).toEqual([]);expect(resourceScheduler.runningCount()).toBe(0);} finally {@@ -759,8 +762,14 @@ describe('iOS Simulator host', () => {await host.reconcileOwnership();- expect(lifecycle.shutdownExact).toHaveBeenCalledWith(instance.simulatorUdid);- expect(lifecycle.deleteExact).toHaveBeenCalledWith(instance.simulatorUdid);+ expect(lifecycle.shutdownExact).toHaveBeenCalledWith(+ instance.simulatorUdid,+ expect.any(AbortSignal),+ );+ expect(lifecycle.deleteExact).toHaveBeenCalledWith(+ instance.simulatorUdid,+ expect.any(AbortSignal),+ );expect(actor.listAll()).toEqual([]);});@@ -791,8 +800,14 @@ describe('iOS Simulator host', () => {await host.reconcileOwnership();- expect(lifecycle.shutdownExact).toHaveBeenCalledWith(instance.simulatorUdid);- expect(lifecycle.deleteExact).toHaveBeenCalledWith(instance.simulatorUdid);+ expect(lifecycle.shutdownExact).toHaveBeenCalledWith(+ instance.simulatorUdid,+ expect.any(AbortSignal),+ );+ expect(lifecycle.deleteExact).toHaveBeenCalledWith(+ instance.simulatorUdid,+ expect.any(AbortSignal),+ );expect(actor.listAll()).toEqual([]);});@@ -969,8 +984,14 @@ describe('iOS Simulator host', () => {await host.reconcileOwnership();- expect(lifecycle.shutdownExact).toHaveBeenCalledWith(instance.simulatorUdid);- expect(lifecycle.deleteExact).toHaveBeenCalledWith(instance.simulatorUdid);+ expect(lifecycle.shutdownExact).toHaveBeenCalledWith(+ instance.simulatorUdid,+ expect.any(AbortSignal),+ );+ expect(lifecycle.deleteExact).toHaveBeenCalledWith(+ instance.simulatorUdid,+ expect.any(AbortSignal),+ );expect(actor.listAll()).toEqual([]);});@@ -1255,11 +1276,64 @@ describe('iOS Simulator host', () => {await host.reconcileOwnership();- expect(lifecycle.shutdownExact).toHaveBeenCalledWith(instance.simulatorUdid);+ expect(lifecycle.shutdownExact).toHaveBeenCalledWith(+ instance.simulatorUdid,+ expect.any(AbortSignal),+ );expect(lifecycle.deleteExact).not.toHaveBeenCalled();expect(actor.listAll()).toEqual([]);});+ it('aborts archived CoreSimulator cleanup before updater force-quit', async () => {+ let shutdownSignal: AbortSignal | undefined;+ const lifecycle: IOSSimulatorSimctlLifecycle = {+ findExact: vi.fn(),+ bootExact: vi.fn(),+ shutdownExact: vi.fn(+ (_udid: string, signal?: AbortSignal) =>+ new Promise<void>((_resolve, reject) => {+ shutdownSignal = signal;+ signal?.addEventListener('abort', () => reject(signal.reason), { once: true });+ }),+ ),+ createExact: vi.fn(),+ deleteExact: vi.fn(),+ };+ const actor = new IOSSimulatorInstanceActor({+ store: new IOSSimulatorOwnershipStore({ createId: () => crypto.randomUUID() }),+ lifecycle,+ });+ const instance = actor.attach({+ sessionId: 'archived-force-quit',+ worktreeRoot: '/tmp/archived-force-quit',+ sourceFingerprint: 'fingerprint-a',+ creationProvenance: 'external',+ bootProvenance: 'agent-booted',+ device: { ...READY_REPORT.devices[0]!, state: 'Booted' },+ });+ const host = createIOSSimulatorHost({+ actor,+ lifecycle,+ runtime: { inspect: vi.fn(async () => READY_REPORT) },+ getSession: vi.fn(async () => ({+ ...localSession(instance.sessionId),+ status: 'archived' as const,+ })),+ });++ const reconciling = host.reconcileOwnership();+ await vi.waitFor(() => expect(shutdownSignal).toBeDefined());+ host.abortOperationsForExit();++ expect(shutdownSignal?.aborted).toBe(true);+ await expect(reconciling).resolves.toBeUndefined();+ expect(actor.getOwned(instance.sessionId, instance.instanceId)).toMatchObject({+ healthState: 'degraded',+ errorCode: 'ARCHIVED_CLEANUP_FAILED',+ });+ await host.dispose();+ });+it.each(['Booted', 'Booting'] as const)('keeps archived ownership and scheduler capacity when %s shutdown fails',async (deviceState) => {@@ -4537,7 +4611,10 @@ describe('iOS Simulator host', () => {await expect(cleanup).resolves.toBeUndefined();expect(driverManager.start).not.toHaveBeenCalled();expect(driverManager.stop).toHaveBeenCalledWith(attached.instanceId);- expect(lifecycle.shutdownExact).toHaveBeenCalledWith(attached.simulatorUdid);+ expect(lifecycle.shutdownExact).toHaveBeenCalledWith(+ attached.simulatorUdid,+ expect.any(AbortSignal),+ );expect(actor.list('session-a')).toEqual([]);expect(resourceScheduler.runningCount()).toBe(0);});@@ -4767,9 +4844,9 @@ describe('iOS Simulator host', () => {});await expect(cleanup).resolves.toBeUndefined();expect(actor.list('session-a')).toEqual([]);- expect(lifecycle.findExact).toHaveBeenCalledWith(createdDevice.udid);+ expect(lifecycle.findExact).toHaveBeenCalledWith(createdDevice.udid, expect.any(AbortSignal));expect(lifecycle.shutdownExact).not.toHaveBeenCalled();- expect(lifecycle.deleteExact).toHaveBeenCalledWith(createdDevice.udid);+ expect(lifecycle.deleteExact).toHaveBeenCalledWith(createdDevice.udid, expect.any(AbortSignal));});it('does not register a build after its task is archived at the reconcile boundary', async () => {@@ -5299,7 +5376,10 @@ describe('iOS Simulator host', () => {expect(discardInstance).toHaveBeenCalledWith(instance.instanceId);expect(stopDriver).toHaveBeenCalledWith(instance.instanceId);if (toolName === 'stop_instance') {- expect(lifecycle.shutdownExact).toHaveBeenCalledWith(instance.simulatorUdid);+ expect(lifecycle.shutdownExact).toHaveBeenCalledWith(+ instance.simulatorUdid,+ expect.any(AbortSignal),+ );expect(actor.list('session-a')[0]).toMatchObject({ lifecycleState: 'stopped' });} else {expect(lifecycle.shutdownExact).not.toHaveBeenCalled();diff --git a/apps/desktop/src/main/mcp-integrations/ios-simulator.ts b/apps/desktop/src/main/mcp-integrations/ios-simulator.tsindex b93290e040..b35536489f 100644--- a/apps/desktop/src/main/mcp-integrations/ios-simulator.ts+++ b/apps/desktop/src/main/mcp-integrations/ios-simulator.ts@@ -1797,6 +1797,7 @@ export function createIOSSimulatorHost(options: IOSSimulatorHostOptions = {}): Iinstance: IOSSimulatorInstance,device: IOSSimulatorEnvironmentReport['devices'][number] | null | undefined,deviceStateKnown = true,+ signal?: AbortSignal,): Promise<boolean> {const hostOwnsBoot =instance.bootProvenance === 'agent-booted' || instance.creationProvenance === 'cindy';@@ -1813,7 +1814,7 @@ export function createIOSSimulatorHost(options: IOSSimulatorHostOptions = {}): I});} else {try {- await lifecycle.shutdownExact(instance.simulatorUdid);+ await lifecycle.shutdownExact(instance.simulatorUdid, signal);deviceStopped = true;schedulerReleaseAllowed = true;} catch (error) {@@ -1829,7 +1830,7 @@ export function createIOSSimulatorHost(options: IOSSimulatorHostOptions = {}): I// `simctl delete` would turn successful external cleanup into a permanent// retry loop, so only delete when the exact device still exists.if (instance.creationProvenance === 'cindy' && cleanupSucceeded && device) {- await lifecycle.deleteExact(instance.simulatorUdid).catch((error) => {+ await lifecycle.deleteExact(instance.simulatorUdid, signal).catch((error) => {cleanupSucceeded = false;logger.warn('iOS Simulator stale binding cleanup could not delete device', {instanceId: instance.instanceId,@@ -1874,14 +1875,14 @@ export function createIOSSimulatorHost(options: IOSSimulatorHostOptions = {}): Iconst released = await actor.runOwnershipCleanup(snapshot.instanceId,sessionId,- async (instance) => {+ async (instance, signal) => {const hostOwnsBoot =instance.bootProvenance === 'agent-booted' || instance.creationProvenance === 'cindy';let device: IOSSimulatorEnvironmentReport['devices'][number] | null | undefined;let deviceStateKnown = !hostOwnsBoot;if (hostOwnsBoot) {try {- device = await lifecycle.findExact(instance.simulatorUdid);+ device = await lifecycle.findExact(instance.simulatorUdid, signal);deviceStateKnown = device !== undefined;} catch (error) {logger.warn('iOS Simulator removed task cleanup could not inspect exact device', {@@ -1891,7 +1892,7 @@ export function createIOSSimulatorHost(options: IOSSimulatorHostOptions = {}): I});}}- return releaseStaleBinding(instance, device, deviceStateKnown);+ return releaseStaleBinding(instance, device, deviceStateKnown, signal);},);if (!released) failures.add(snapshot.instanceId);@@ -2197,7 +2198,13 @@ export function createIOSSimulatorHost(options: IOSSimulatorHostOptions = {}): Ireturn false;}if (!session || session.status === 'deleted' || session.status === 'archived') {- return (await releaseStaleBinding(instance, device)) && complete;+ const released = await actor.runOwnershipCleanup(+ instance.instanceId,+ instance.sessionId,+ (owned, signal) =>+ releaseStaleBinding(owned, device, true, signal),+ );+ return released && complete;}if (session.remoteHostId || !device) {const runtimeReleased = await releaseInstanceRuntime(instance);@@ -5787,6 +5794,7 @@ export function createIOSSimulatorHost(options: IOSSimulatorHostOptions = {}): Idispose() {if (disposePromise) return disposePromise;disposePromise = (async () => {+ actor.abortOperationsForExit();const lifecycleStarts = actor.cancelAllLifecycleStarts();const mutations = actor.cancelAllMutations();const builds = [...activeBuilds.values()];diff --git a/packages/ios-simulator-runtime/src/instance-actor.test.ts b/packages/ios-simulator-runtime/src/instance-actor.test.tsindex 0f2dd31af8..1fb480879e 100644--- a/packages/ios-simulator-runtime/src/instance-actor.test.ts+++ b/packages/ios-simulator-runtime/src/instance-actor.test.ts@@ -106,7 +106,10 @@ describe("IOSSimulatorInstanceActor", () => {const stopped = await harness.actor.stop(harness.route(started));expect(stopped).toMatchObject({ lifecycleState: "stopped", generation: 3 });- expect(harness.lifecycle.shutdownExact).toHaveBeenCalledWith(UDID);+ expect(harness.lifecycle.shutdownExact).toHaveBeenCalledWith(+ UDID,+ expect.any(AbortSignal),+ );await expect(harness.actor.stop(harness.route(started)),).rejects.toMatchObject({@@ -149,7 +152,34 @@ describe("IOSSimulatorInstanceActor", () => {lifecycleState: "stopped",generation: 2,});- expect(harness.lifecycle.shutdownExact).toHaveBeenCalledWith(UDID);+ expect(harness.lifecycle.shutdownExact).toHaveBeenCalledWith(+ UDID,+ expect.any(AbortSignal),+ );+ });++ it("aborts an in-flight stop through the force-exit seam", async () => {+ const harness = createHarness();+ const started = await harness.actor.start(harness.route());+ let shutdownSignal: AbortSignal | undefined;+ vi.mocked(harness.lifecycle.shutdownExact).mockImplementationOnce(+ (_udid, signal) =>+ new Promise((_resolve, reject) => {+ shutdownSignal = signal;+ signal?.addEventListener("abort", () => reject(signal.reason), {+ once: true,+ });+ }),+ );++ const stopping = harness.actor.stop(harness.route(started));+ await vi.waitFor(() => expect(shutdownSignal).toBeDefined());+ harness.actor.abortOperationsForExit();++ expect(shutdownSignal?.aborted).toBe(true);+ await expect(stopping).rejects.toMatchObject({+ code: "MUTATION_CANCELLED",+ });});it("cancels an in-flight start while preserving Host-owned detach grace", async () => {@@ -491,7 +521,10 @@ describe("IOSSimulatorInstanceActor", () => {expect(harness.scheduled).toHaveLength(1);expect(onResourceReleased).not.toHaveBeenCalled();await harness.scheduled[0]?.();- expect(harness.lifecycle.shutdownExact).toHaveBeenCalledWith(UDID);+ expect(harness.lifecycle.shutdownExact).toHaveBeenCalledWith(+ UDID,+ expect.any(AbortSignal),+ );expect(harness.store.get(detached.instanceId)).toBeNull();expect(onResourceReleased).toHaveBeenCalledWith(expect.objectContaining({ instanceId: detached.instanceId }),@@ -556,7 +589,10 @@ describe("IOSSimulatorInstanceActor", () => {Date.parse(detached.graceExpiresAt!) - now,);await scheduled[0]?.task();- expect(lifecycle.shutdownExact).toHaveBeenCalledWith(UDID);+ expect(lifecycle.shutdownExact).toHaveBeenCalledWith(+ UDID,+ expect.any(AbortSignal),+ );expect(store.get(detached.instanceId)).toBeNull();expect(onResourceStopped).toHaveBeenCalledTimes(1);});@@ -599,7 +635,10 @@ describe("IOSSimulatorInstanceActor", () => {),).resolves.toBe(true);- expect(lifecycle.shutdownExact).toHaveBeenCalledWith(UDID);+ expect(lifecycle.shutdownExact).toHaveBeenCalledWith(+ UDID,+ expect.any(AbortSignal),+ );expect(store.get(detached.instanceId)).toBeNull();expect(onResourceStopped).toHaveBeenCalledTimes(1);});@@ -710,6 +749,36 @@ describe("IOSSimulatorInstanceActor", () => {expect(onResourceReleased).not.toHaveBeenCalled();});+ it("aborts in-flight detach cleanup on exit without scheduling a retry", async () => {+ const harness = createHarness();+ const started = await harness.actor.start(harness.route());+ const onResourceStopped = vi.fn();+ let shutdownSignal: AbortSignal | undefined;+ vi.mocked(harness.lifecycle.shutdownExact).mockImplementationOnce(+ (_udid, signal) =>+ new Promise((_resolve, reject) => {+ shutdownSignal = signal;+ signal?.addEventListener("abort", () => reject(signal.reason), {+ once: true,+ });+ }),+ );+ const detached = await harness.actor.detach(+ harness.route(started),+ onResourceStopped,+ );++ const cleanup = Promise.resolve(harness.scheduled[0]?.());+ await vi.waitFor(() => expect(shutdownSignal).toBeDefined());+ harness.actor.abortOperationsForExit();++ expect(shutdownSignal?.aborted).toBe(true);+ await expect(cleanup).resolves.toBeUndefined();+ expect(harness.store.get(detached.instanceId)).not.toBeNull();+ expect(harness.scheduled).toHaveLength(0);+ expect(onResourceStopped).not.toHaveBeenCalled();+ });+it("serializes reattachment behind an in-flight grace shutdown", async () => {const harness = createHarness();const started = await harness.actor.start(harness.route());@@ -725,7 +794,10 @@ describe("IOSSimulatorInstanceActor", () => {const cleanup = Promise.resolve(harness.scheduled[0]?.());await vi.waitFor(() =>- expect(harness.lifecycle.shutdownExact).toHaveBeenCalledWith(UDID),+ expect(harness.lifecycle.shutdownExact).toHaveBeenCalledWith(+ UDID,+ expect.any(AbortSignal),+ ),);let reattached = false;const reattach = harness.actor@@ -765,15 +837,24 @@ describe("IOSSimulatorInstanceActor", () => {it("deletes only an exact Cindy-provenance simulator", async () => {const harness = createHarness({ cindy: true });await harness.actor.delete(harness.route());- expect(harness.lifecycle.deleteExact).toHaveBeenCalledWith(UDID);+ expect(harness.lifecycle.deleteExact).toHaveBeenCalledWith(+ UDID,+ expect.any(AbortSignal),+ );expect(harness.store.get(harness.instance.instanceId)).toBeNull();});it("shuts down a ready Cindy simulator before deleting it", async () => {const harness = createHarness({ booted: true, cindy: true });await harness.actor.delete(harness.route());- expect(harness.lifecycle.shutdownExact).toHaveBeenCalledWith(UDID);- expect(harness.lifecycle.deleteExact).toHaveBeenCalledWith(UDID);+ expect(harness.lifecycle.shutdownExact).toHaveBeenCalledWith(+ UDID,+ expect.any(AbortSignal),+ );+ expect(harness.lifecycle.deleteExact).toHaveBeenCalledWith(+ UDID,+ expect.any(AbortSignal),+ );});it("creates a Cindy-owned simulator from an exact installed template", async () => {diff --git a/packages/ios-simulator-runtime/src/instance-actor.ts b/packages/ios-simulator-runtime/src/instance-actor.tsindex 1d4c95e753..eef901b288 100644--- a/packages/ios-simulator-runtime/src/instance-actor.ts+++ b/packages/ios-simulator-runtime/src/instance-actor.ts@@ -119,6 +119,7 @@ export class IOSSimulatorInstanceActor {string,Set<ActiveLifecycleStart>>();+ readonly #lifecycleExitController = new AbortController();constructor(options: IOSSimulatorInstanceActorOptions) {this.#store = options.store;@@ -437,7 +438,9 @@ export class IOSSimulatorInstanceActor {/** Abort and drain mutations owned by one Cindy task before its worktree is recycled. */async cancelMutationsForSession(sessionId: string): Promise<void> {await this.#abortAndDrainMutations(- this.#store.listForSession(sessionId).map((instance) => instance.instanceId),+ this.#store+ .listForSession(sessionId)+ .map((instance) => instance.instanceId),);}@@ -485,7 +488,10 @@ export class IOSSimulatorInstanceActor {0,state.queuedAgentMutations - 1,);- if (state.agentPaused || state.takeoverEpoch !== expectedTakeoverEpoch) {+ if (+ state.agentPaused ||+ state.takeoverEpoch !== expectedTakeoverEpoch+ ) {throw new IOSSimulatorInstanceError("MUTATION_CANCELLED","The queued simulator action was cancelled because simulator control changed.",@@ -550,7 +556,7 @@ export class IOSSimulatorInstanceActor {runOwnershipCleanup<T>(instanceId: string,sessionId: string,- task: (instance: IOSSimulatorInstance) => Promise<T>,+ task: (instance: IOSSimulatorInstance, signal: AbortSignal) => Promise<T>,): Promise<T> {// Validate the old owner before changing mutation/grace state. The// serialized check below is still required because ownership can be@@ -560,8 +566,9 @@ export class IOSSimulatorInstanceActor {this.#abortLifecycleStartsForInstance(instanceId);this.#cancelDetachGrace(instanceId);return this.#serialize(instanceId, async () => {+ this.#throwIfLifecycleExitCancelled();const instance = this.#store.requireOwned(instanceId, sessionId);- return task(instance);+ return task(instance, this.#lifecycleExitController.signal);});}@@ -589,6 +596,22 @@ export class IOSSimulatorInstanceActor {);}+ #lifecycleExitCancelledError(): IOSSimulatorInstanceError {+ return new IOSSimulatorInstanceError(+ "MUTATION_CANCELLED",+ "Simulator lifecycle cleanup was cancelled because Cindy is exiting.",+ true,+ );+ }++ #throwIfLifecycleExitCancelled(): void {+ const signal = this.#lifecycleExitController.signal;+ if (!signal.aborted) return;+ throw signal.reason instanceof Error+ ? signal.reason+ : this.#lifecycleExitCancelledError();+ }+#throwIfLifecycleStartCancelled(signal: AbortSignal): void {if (!signal.aborted) return;throw signal.reason instanceof Error@@ -688,6 +711,12 @@ export class IOSSimulatorInstanceActor {/** Synchronous force-quit seam; async disposal separately awaits settlement. */abortOperationsForExit(): void {+ for (const instanceId of [...this.#cancelGrace.keys()]) {+ this.#cancelDetachGrace(instanceId);+ }+ if (!this.#lifecycleExitController.signal.aborted) {+ this.#lifecycleExitController.abort(this.#lifecycleExitCancelledError());+ }for (const instanceId of this.#mutationStates.keys()) {this.abortMutationsForInstance(instanceId);}@@ -864,13 +893,18 @@ export class IOSSimulatorInstanceActor {this.abortMutationsForInstance(admission.instanceId);this.#abortLifecycleStartsForInstance(admission.instanceId);return this.#serialize(admission.instanceId, async () => {+ this.#throwIfLifecycleExitCancelled();const instance = this.#requireAdmittedLifecycleRoute(admission);if (instance.lifecycleState === "stopped") return instance;this.#store.update(instance.instanceId, instance.sessionId, {lifecycleState: "stopping",});try {- await this.#lifecycle.shutdownExact(instance.simulatorUdid);+ await this.#lifecycle.shutdownExact(+ instance.simulatorUdid,+ this.#lifecycleExitController.signal,+ );+ this.#throwIfLifecycleExitCancelled();const now = new Date(this.#clock.now()).toISOString();return this.#store.update(instance.instanceId, instance.sessionId, {lifecycleState: "stopped",@@ -1028,6 +1062,7 @@ export class IOSSimulatorInstanceActor {delayMs: number,): void {this.#cancelDetachGrace(context.instanceId);+ if (this.#lifecycleExitController.signal.aborted) return;const token = Symbol("detach-grace-cleanup");const cancel = this.#scheduler.schedule(Math.max(0, delayMs), () =>this.#runDetachGraceCleanup(context).then(@@ -1055,6 +1090,7 @@ export class IOSSimulatorInstanceActor {context: DetachGraceCleanupContext,error: unknown,): void {+ if (this.#lifecycleExitController.signal.aborted) return;const current = this.#matchingDetachGrace(context);if (!current) return;try {@@ -1067,10 +1103,15 @@ export class IOSSimulatorInstanceActor {#runDetachGraceCleanup(context: DetachGraceCleanupContext): Promise<void> {return this.#serialize(context.instanceId, async () => {+ this.#throwIfLifecycleExitCancelled();const current = this.#matchingDetachGrace(context);if (!current) return;this.#assertMutationAllowed?.();- await this.#lifecycle.shutdownExact(current.simulatorUdid);+ await this.#lifecycle.shutdownExact(+ current.simulatorUdid,+ this.#lifecycleExitController.signal,+ );+ this.#throwIfLifecycleExitCancelled();const afterShutdown = this.#matchingDetachGrace(context);if (!afterShutdown) return;// Resource release is intentionally before ownership release. The Host@@ -1109,6 +1150,7 @@ export class IOSSimulatorInstanceActor {route: IOSSimulatorMutationRoute,): Promise<IOSSimulatorInstance> {return this.#serialize(route.instanceId, async () => {+ this.#throwIfLifecycleExitCancelled();const instance = this.#store.assertMutationRoute(route);if (instance.creationProvenance !== "cindy") {throw new IOSSimulatorInstanceError(@@ -1118,9 +1160,17 @@ export class IOSSimulatorInstanceActor {}this.#assertMutationAllowed?.();if (instance.lifecycleState === "ready") {- await this.#lifecycle.shutdownExact(instance.simulatorUdid);+ await this.#lifecycle.shutdownExact(+ instance.simulatorUdid,+ this.#lifecycleExitController.signal,+ );+ this.#throwIfLifecycleExitCancelled();}- await this.#lifecycle.deleteExact(instance.simulatorUdid);+ await this.#lifecycle.deleteExact(+ instance.simulatorUdid,+ this.#lifecycleExitController.signal,+ );+ this.#throwIfLifecycleExitCancelled();this.#cancelDetachGrace(instance.instanceId);return this.#store.release(instance.instanceId, instance.sessionId);});diff --git a/packages/ios-simulator-runtime/src/native-sidecar/channel.test.ts b/packages/ios-simulator-runtime/src/native-sidecar/channel.test.tsindex c5b1e1ffba..0256c1f670 100644--- a/packages/ios-simulator-runtime/src/native-sidecar/channel.test.ts+++ b/packages/ios-simulator-runtime/src/native-sidecar/channel.test.ts@@ -181,13 +181,44 @@ describe("IOSSimulatorNativeSidecarChannel", () => {});it("times out pending requests without leaving them in the multiplexer", async () => {- const { channel } = harness({ requestTimeoutMs: 5 });+ const { channel, processes } = harness({ requestTimeoutMs: 5 });await channel.start();await expect(channel.request(command("availability")),).rejects.toMatchObject({code: "TIMEOUT",});+ processes[0]!.stdout.write(reply("sidecar-1", { ready: true }));+ await Promise.resolve();+ expect(channel.state).toBe("running");+ const next = channel.request(command("availability"));+ processes[0]!.stdout.write(reply("sidecar-2", { ready: true }));+ await expect(next).resolves.toEqual({ ready: true });+ await channel.stop();+ });++ it("ignores one late reply for an aborted request without terminating the sidecar", async () => {+ const { channel, processes } = harness();+ await channel.start();+ const controller = new AbortController();+ const aborted = channel.request(command("tap"), controller.signal);++ controller.abort();+ await expect(aborted).rejects.toMatchObject({ code: "ABORTED" });+ processes[0]!.stdout.write(reply("sidecar-1", {}));+ await Promise.resolve();++ expect(channel.state).toBe("running");+ expect(channel.crashCount).toBe(0);+ const next = channel.request(command("availability"));+ processes[0]!.stdout.write(reply("sidecar-2", { ready: true }));+ await expect(next).resolves.toEqual({ ready: true });++ // A tombstone consumes exactly one expected late reply. A duplicate keeps+ // the existing fail-closed behavior for unsolicited protocol traffic.+ processes[0]!.stdout.write(reply("sidecar-1", {}));+ await vi.waitFor(() => expect(channel.state).toBe("failed"));+ expect(channel.crashCount).toBe(1);await channel.stop();});diff --git a/packages/ios-simulator-runtime/src/native-sidecar/channel.ts b/packages/ios-simulator-runtime/src/native-sidecar/channel.tsindex e2c11be56c..f2299a4e93 100644--- a/packages/ios-simulator-runtime/src/native-sidecar/channel.ts+++ b/packages/ios-simulator-runtime/src/native-sidecar/channel.ts@@ -31,6 +31,7 @@ const MAX_EARLY_STREAM_EVENTS_PER_STREAM = 4;const MAX_EARLY_STREAMS = 8;const MAX_EARLY_STREAM_BYTES = 32 * 1024 * 1024;const MAX_CLOSED_STREAMS = 64;+const MAX_LOCALLY_SETTLED_REQUESTS = 256;export type IOSSimulatorNativeSidecarChannelState ="idle" | "running" | "failed" | "parked" | "stopped";@@ -307,6 +308,7 @@ export class IOSSimulatorNativeSidecarChannel implements IOSSimulatorNativeSidecreadonly #launcher: IOSSimulatorNativeSidecarProcessLauncher;#decoder = new IOSSimulatorNativeSidecarFrameDecoder();readonly #pending = new Map<string, PendingRequest>();+ readonly #locallySettledRequestIds = new Set<string>();readonly #streams = new Map<string, StreamState>();readonly #earlyStreamEvents = new Map<string, EarlyStreamEvent[]>();readonly #closedStreams = new Map<@@ -401,6 +403,7 @@ export class IOSSimulatorNativeSidecarChannel implements IOSSimulatorNativeSidec}this.#process = process;this.#state = "running";+ this.#locallySettledRequestIds.clear();this.#decoderReset();process.stdout.on("data", (chunk: Buffer | Uint8Array | string) => {try {@@ -752,6 +755,7 @@ export class IOSSimulatorNativeSidecarChannel implements IOSSimulatorNativeSidecif (!pending) return;this.#pending.delete(id);pending.removeAbortListener();+ this.#rememberLocallySettledRequest(id);const error = new IOSSimulatorNativeSidecarChannelError("TIMEOUT",`Native sidecar request ${command.op} timed out.`,@@ -763,9 +767,13 @@ export class IOSSimulatorNativeSidecarChannel implements IOSSimulatorNativeSidec}}, this.#options.requestTimeoutMs);const onAbort = () => {+ const pending = this.#pending.get(id);+ if (!pending) return;clearTimeout(timeout);this.#pending.delete(id);- reject(abortError());+ pending.removeAbortListener();+ this.#rememberLocallySettledRequest(id);+ pending.reject(abortError());};signal?.addEventListener("abort", onAbort, { once: true });this.#pending.set(id, {@@ -808,6 +816,7 @@ export class IOSSimulatorNativeSidecarChannel implements IOSSimulatorNativeSidecconst reply = decodeIOSSimulatorNativeSidecarJson(frame);const id = readString(reply.id, "id");const pending = this.#pending.get(id);+ if (!pending && this.#locallySettledRequestIds.delete(id)) return;if (!pending)throw new IOSSimulatorNativeSidecarProtocolError(`Unknown reply id ${id}`,@@ -1205,6 +1214,20 @@ export class IOSSimulatorNativeSidecarChannel implements IOSSimulatorNativeSidecthis.#earlyStreamBytes = 0;}+ /**+ * The Helper cannot cancel a command that already crossed stdio. Keep a+ * bounded one-reply tombstone so an expected late reply cannot be mistaken+ * for protocol desynchronization after local abort or timeout.+ */+ #rememberLocallySettledRequest(id: string): void {+ this.#locallySettledRequestIds.add(id);+ while (this.#locallySettledRequestIds.size > MAX_LOCALLY_SETTLED_REQUESTS) {+ const oldest = this.#locallySettledRequestIds.values().next().value;+ if (oldest === undefined) break;+ this.#locallySettledRequestIds.delete(oldest);+ }+ }+#timestamp(): string {return (this.#options.now ?? (() => new Date()))().toISOString();}diff --git a/packages/ios-simulator-runtime/src/simctl-lifecycle.test.ts b/packages/ios-simulator-runtime/src/simctl-lifecycle.test.tsindex 07006bc86a..64428114e7 100644--- a/packages/ios-simulator-runtime/src/simctl-lifecycle.test.ts+++ b/packages/ios-simulator-runtime/src/simctl-lifecycle.test.ts@@ -174,6 +174,61 @@ describe("createIOSSimulatorSimctlLifecycle", () => {}});+ it("propagates cleanup cancellation into shutdown and delete subprocesses", async () => {+ const shutdownController = new AbortController();+ const deleteController = new AbortController();+ let shutdownSignal: AbortSignal | undefined;+ let deleteSignal: AbortSignal | undefined;+ const run = vi.fn<IOSSimulatorCommandRunner["run"]>(+ async (_command, args, options) => {+ if (args[1] === "list") {+ return { stdout: listJson("Booted"), stderr: "", exitCode: 0 };+ }+ if (args[1] === "shutdown") {+ shutdownSignal = options?.signal;+ return await new Promise((resolve) => {+ options?.signal?.addEventListener(+ "abort",+ () => resolve({ stdout: "", stderr: "", exitCode: null }),+ { once: true },+ );+ });+ }+ if (args[1] === "delete") {+ deleteSignal = options?.signal;+ return await new Promise((resolve) => {+ options?.signal?.addEventListener(+ "abort",+ () => resolve({ stdout: "", stderr: "", exitCode: null }),+ { once: true },+ );+ });+ }+ throw new Error(`unexpected ${args.join(" ")}`);+ },+ );+ const lifecycle = createIOSSimulatorSimctlLifecycle({+ commandRunner: { run },+ });++ const shuttingDown = lifecycle.shutdownExact(+ UDID,+ shutdownController.signal,+ );+ await vi.waitFor(() =>+ expect(shutdownSignal).toBe(shutdownController.signal),+ );+ shutdownController.abort(new Error("shutdown cancelled for exit"));+ await expect(shuttingDown).rejects.toThrow("shutdown cancelled for exit");++ const deleting = lifecycle.deleteExact(UDID, deleteController.signal);+ await vi.waitFor(() => expect(deleteSignal).toBe(deleteController.signal));+ deleteController.abort(new Error("delete cancelled for exit"));+ await expect(deleting).rejects.toThrow("delete cancelled for exit");++ expect(run.mock.calls[0]?.[2]?.signal).toBe(shutdownController.signal);+ });+it("uses exact argv for create, shutdown, and delete", async () => {const run = vi.fn<IOSSimulatorCommandRunner["run"]>(async (_command, args) => {diff --git a/packages/ios-simulator-runtime/src/simctl-lifecycle.ts b/packages/ios-simulator-runtime/src/simctl-lifecycle.tsindex 4ce6532ce9..af574c1e33 100644--- a/packages/ios-simulator-runtime/src/simctl-lifecycle.ts+++ b/packages/ios-simulator-runtime/src/simctl-lifecycle.ts@@ -73,15 +73,18 @@ export type IOSSimulatorContentSize =| "accessibility-extra-extra-extra-large";export interface IOSSimulatorSimctlLifecycle {- findExact(udid: string): Promise<IOSSimulatorDevice | null>;+ findExact(+ udid: string,+ signal?: AbortSignal,+ ): Promise<IOSSimulatorDevice | null>;bootExact(udid: string, signal?: AbortSignal): Promise<IOSSimulatorDevice>;- shutdownExact(udid: string): Promise<void>;+ shutdownExact(udid: string, signal?: AbortSignal): Promise<void>;createExact(input: {name: string;deviceTypeIdentifier: string;runtimeIdentifier: string;}): Promise<IOSSimulatorCreatedDevice>;- deleteExact(udid: string): Promise<void>;+ deleteExact(udid: string, signal?: AbortSignal): Promise<void>;/** Set the simulated system appearance without bringing Simulator.app forward. */setAppearance?(udid: string, appearance: "light" | "dark"): Promise<void>;/** Enable or disable the simulated Increase Contrast accessibility setting. */@@ -535,9 +538,11 @@ export function createIOSSimulatorSimctlLifecycle();},- async shutdownExact(udid): Promise<void> {+ async shutdownExact(udid, signal): Promise<void> {const normalized = requireUdid(udid);- const device = await findExact(normalized);+ throwIfAborted(signal);+ const device = await findExact(normalized, signal);+ throwIfAborted(signal);if (!device) {throw new IOSSimulatorInstanceError("SIMULATOR_NOT_FOUND",@@ -545,11 +550,12 @@ export function createIOSSimulatorSimctlLifecycle();}if (device.state.toLowerCase() === "shutdown") return;- const result = await runner.run(XCRUN, [- "simctl",- "shutdown",- normalized,- ]);+ const result = signal+ ? await runner.run(XCRUN, ["simctl", "shutdown", normalized], {+ signal,+ })+ : await runner.run(XCRUN, ["simctl", "shutdown", normalized]);+ throwIfAborted(signal);if (result.exitCode !== 0) {throw new IOSSimulatorInstanceError("SIMULATOR_SHUTDOWN_FAILED",@@ -584,9 +590,15 @@ export function createIOSSimulatorSimctlLifecycle(return { udid, name, runtimeIdentifier, deviceTypeIdentifier };},- async deleteExact(udid): Promise<void> {+ async deleteExact(udid, signal): Promise<void> {const normalized = requireUdid(udid);- const result = await runner.run(XCRUN, ["simctl", "delete", normalized]);+ throwIfAborted(signal);+ const result = signal+ ? await runner.run(XCRUN, ["simctl", "delete", normalized], {+ signal,+ })+ : await runner.run(XCRUN, ["simctl", "delete", normalized]);+ throwIfAborted(signal);if (result.exitCode !== 0) {throw new IOSSimulatorInstanceError("SIMULATOR_DELETE_FAILED",diff --git a/packages/ios-simulator-runtime/src/wda/process-manager.test.ts b/packages/ios-simulator-runtime/src/wda/process-manager.test.tsindex 7a101d16e8..204e849a1c 100644--- a/packages/ios-simulator-runtime/src/wda/process-manager.test.ts+++ b/packages/ios-simulator-runtime/src/wda/process-manager.test.ts@@ -364,7 +364,7 @@ describe("WDA orphan ownership matching", () => {});it("reads only exact simctl candidates and revalidates diagnostic ownership", () => {- const simctl = path.join(path.dirname(xcodebuild), "simctl");+ const simctl = path.posix.join(path.posix.dirname(xcodebuild), "simctl");const diagnosticInput = {cacheRoot,simulatorUdid: UDID,diff --git a/packages/ios-simulator-runtime/src/wda/process-manager.ts b/packages/ios-simulator-runtime/src/wda/process-manager.tsindex 3315861b89..7f19855826 100644--- a/packages/ios-simulator-runtime/src/wda/process-manager.ts+++ b/packages/ios-simulator-runtime/src/wda/process-manager.ts@@ -28,6 +28,8 @@ import {type WdaSourceManifest,} from "./source-provider.js";+const darwinPath = path.posix;+const MAX_LOG_BYTES = 256 * 1024;const WDA_INTERRUPT_GRACE_MS = 5_000;const WDA_TERMINATE_GRACE_MS = 1_000;@@ -260,7 +262,7 @@ function classifyCindyWdaControllers(const executablePaths = [...(input.xcodebuildExecutablePaths ?? ["/usr/bin/xcodebuild"]),]- .map((value) => path.resolve(value))+ .map((value) => darwinPath.resolve(value)).filter((value, index, values) => values.indexOf(value) === index);if (executablePaths.length === 0) {return { ownedGroups: [], conflictingGroups: [] };@@ -268,14 +270,14 @@ function classifyCindyWdaControllers(const conflictExecutablePaths = [...(input.inspectedXcodebuildExecutablePaths ?? executablePaths),]- .map((value) => path.resolve(value))+ .map((value) => darwinPath.resolve(value)).filter((value, index, values) => values.indexOf(value) === index);- const root = path.resolve(input.cacheRoot);+ const root = darwinPath.resolve(input.cacheRoot);const executablePattern = executablePaths.map(escapeRegularExpression).join("|");- const projectPattern = `${escapeRegularExpression(path.join(root, "source"))}\\/[0-9a-f]{40}\\/WebDriverAgent\\.xcodeproj`;- const derivedPattern = `${escapeRegularExpression(path.join(root, "derived"))}\\/[0-9a-f]{64}`;+ const projectPattern = `${escapeRegularExpression(darwinPath.join(root, "source"))}\\/[0-9a-f]{40}\\/WebDriverAgent\\.xcodeproj`;+ const derivedPattern = `${escapeRegularExpression(darwinPath.join(root, "derived"))}\\/[0-9a-f]{64}`;const basePattern =`(?:${executablePattern}) -quiet -project ${projectPattern}` +` -scheme WebDriverAgentRunner` +@@ -360,13 +362,13 @@ export function findCindyWdaRunnerCandidates(): WdaRunnerProcessCandidate[] {const normalizedUdid = normalizeSimulatorUdid(input.simulatorUdid);if (!normalizedUdid) return [];- const coreSimulatorRoot = path.resolve(+ const coreSimulatorRoot = darwinPath.resolve(input.coreSimulatorRoot ??- path.join(os.homedir(), "Library", "Developer", "CoreSimulator"),+ darwinPath.join(os.homedir(), "Library", "Developer", "CoreSimulator"),);const runnerPattern = new RegExp(`^${escapeRegularExpression(- path.join(+ darwinPath.join(coreSimulatorRoot,"Devices",normalizedUdid,@@ -392,9 +394,9 @@ function diagnosticExecutablePaths(): Set<string> {const paths = new Set<string>(["/usr/bin/xcrun"]);for (const executable of xcodebuildExecutablePaths) {- const resolved = path.resolve(executable);- if (path.basename(resolved) !== "xcodebuild") continue;- const simctl = path.join(path.dirname(resolved), "simctl");+ const resolved = darwinPath.resolve(executable);+ if (darwinPath.basename(resolved) !== "xcodebuild") continue;+ const simctl = darwinPath.join(darwinPath.dirname(resolved), "simctl");if (simctl !== "/usr/bin/simctl") paths.add(simctl);}return paths;@@ -456,7 +458,10 @@ export function matchesCindyWdaDiagnosticCommand();if ([...argv.matchAll(udidPattern)].length !== 1) return false;- const derivedRoot = path.join(path.resolve(input.cacheRoot), "derived");+ const derivedRoot = darwinPath.join(+ darwinPath.resolve(input.cacheRoot),+ "derived",+ );const outputPattern = new RegExp(`(?:^|\\s)--output(?:=|\\s+)${escapeRegularExpression(derivedRoot)}` +`\\/[0-9a-f]{64}(?=\\/|\\s|$)`,@@ -520,7 +525,7 @@ export function matchesLegacyCindyWdaRunnerEnvironment(return false;}const derivedRoot = escapeRegularExpression(- path.join(path.resolve(input.cacheRoot), "derived"),+ darwinPath.join(darwinPath.resolve(input.cacheRoot), "derived"),);const legacyDerivedPath = new RegExp(`(?:^|\\s)DYLD_LIBRARY_PATH=${derivedRoot}\\/[0-9a-f]{64}` +@@ -668,7 +673,7 @@ function isAllowlistedXcodebuildCandidate(executablePath: string,selectedPaths: ReadonlySet<string>,): boolean {- const resolved = path.resolve(executablePath);+ const resolved = darwinPath.resolve(executablePath);if (selectedPaths.has(resolved) || resolved === "/usr/bin/xcodebuild") {return true;}@@ -687,7 +692,9 @@ async function readWdaProcessInventory(// unrelated process credentials never enter the Cindy process.const processSnapshot = await readDarwinProcessSnapshot(input.signal);const executablePaths = new Set(- (input.xcodebuildExecutablePaths ?? []).map((value) => path.resolve(value)),+ (input.xcodebuildExecutablePaths ?? []).map((value) =>+ darwinPath.resolve(value),+ ),);const rows = parseDarwinProcessSnapshot(processSnapshot);const controllerRows: string[] = [];@@ -718,7 +725,9 @@ async function readWdaProcessInventory(processSnapshot,controllerSnapshot: controllerRows.join("\n"),inspectedXcodebuildExecutablePaths: [- ...new Set(candidates.map((row) => path.resolve(row.command.trim()))),+ ...new Set(+ candidates.map((row) => darwinPath.resolve(row.command.trim())),+ ),],};}@@ -727,10 +736,10 @@ async function readSelectedXcodebuildPaths(signal?: AbortSignal,): Promise<string[]> {const configured = process.env.DEVELOPER_DIR?.trim();- if (configured && path.isAbsolute(configured)) {+ if (configured && darwinPath.isAbsolute(configured)) {return ["/usr/bin/xcodebuild",- path.join(configured, "usr", "bin", "xcodebuild"),+ darwinPath.join(configured, "usr", "bin", "xcodebuild"),];}const result = await new Promise<{ output: string; exitCode: number | null }>(@@ -805,7 +814,7 @@ async function readSelectedXcodebuildPaths(},);const developerDirectory = result.output.trim();- if (result.exitCode !== 0 || !path.isAbsolute(developerDirectory)) {+ if (result.exitCode !== 0 || !darwinPath.isAbsolute(developerDirectory)) {throw new WdaError("TERMINATION_FAILED","The selected Xcode path could not be verified during WDA recovery",@@ -813,7 +822,7 @@ async function readSelectedXcodebuildPaths(}return ["/usr/bin/xcodebuild",- path.join(developerDirectory, "usr", "bin", "xcodebuild"),+ darwinPath.join(developerDirectory, "usr", "bin", "xcodebuild"),];}