Skip to content

Commit ab8130a

Browse files
committed
fix(apple): duplicate the cold-toolchain-probe budget instead of a shared module
toolchain-probe-budget.ts sat outside every platform-apple facade's eager closure, but runner-cache-metadata.ts (imported from it) sits inside all seven -- so the new import added one module to each, tripping the eager-closure-budgets no-growth gate (#2422). Delete the shared module. cache-identity.ts keeps the canonical constant inline (it was already outside the gated closures); runner-cache-metadata.ts declares its own copy, guarded by a new unit test that asserts the two stay equal.
1 parent 44496c2 commit ab8130a

4 files changed

Lines changed: 47 additions & 18 deletions

File tree

‎packages/platform-apple/src/runner/__tests__/runner-cache-metadata.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import assert from 'node:assert/strict';
33
import { AppError } from '@agent-device/kernel/errors';
44
import { IOS_DEVICE, IOS_SIMULATOR, MACOS_DEVICE } from './device-fixtures.ts';
55
import {
6+
COLD_TOOLCHAIN_PROBE_TIMEOUT_MS,
67
diffComparableRunnerCacheMetadata,
78
resolveRunnerBundleBuildSettings,
89
resolveRunnerMaxConcurrentDestinationsFlag,
@@ -11,10 +12,20 @@ import {
1112
resolveRunnerSandboxBuildArgs,
1213
resolveExpectedRunnerCacheMetadata,
1314
} from '../runner-cache-metadata.ts';
15+
import { COLD_TOOLCHAIN_PROBE_TIMEOUT_MS as SNAPSHOT_SOURCE_COLD_TOOLCHAIN_PROBE_TIMEOUT_MS } from '../../snapshot-source/cache-identity.ts';
1416
import { appleToolchainProbeResult, stubAppleToolchainProbes } from './apple-toolchain-fixtures.ts';
1517

1618
const runCmdSync = stubAppleToolchainProbes();
1719

20+
// This file's COLD_TOOLCHAIN_PROBE_TIMEOUT_MS is a deliberate local copy of
21+
// snapshot-source/cache-identity.ts's constant of the same name, not an
22+
// import of it -- see the doc comment on the export in
23+
// runner-cache-metadata.ts for why. This test is what keeps the two values
24+
// from drifting apart (#2422).
25+
test('COLD_TOOLCHAIN_PROBE_TIMEOUT_MS matches the copy in snapshot-source/cache-identity.ts', () => {
26+
assert.equal(COLD_TOOLCHAIN_PROBE_TIMEOUT_MS, SNAPSHOT_SOURCE_COLD_TOOLCHAIN_PROBE_TIMEOUT_MS);
27+
});
28+
1829
test('resolveRunnerMaxConcurrentDestinationsFlag uses simulator flag for simulators', () => {
1930
assert.equal(
2031
resolveRunnerMaxConcurrentDestinationsFlag(IOS_SIMULATOR),

‎packages/platform-apple/src/runner/runner-cache-metadata.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,27 @@ import {
1818
resolveRunnerSdkName,
1919
} from './apple-runner-platform.ts';
2020
import { computeRunnerSourceFingerprint } from './runner-source.ts';
21-
import { COLD_TOOLCHAIN_PROBE_TIMEOUT_MS } from '../toolchain-probe-budget.ts';
2221

2322
const DEFAULT_IOS_RUNNER_APP_BUNDLE_ID = 'com.callstack.agentdevice.runner';
2423
const RUNNER_DERIVED_ROOT = path.join(os.homedir(), '.agent-device', 'apple-runner');
2524
export const RUNNER_CACHE_METADATA_FILE = '.agent-device-runner-cache.json';
2625
const RUNNER_CACHE_SCHEMA_VERSION = 2;
2726
const RUNNER_CACHE_METADATA_VALUE_MAX_LENGTH = 300;
27+
28+
/**
29+
* Per-call timeout for a toolchain identity probe (`xcodebuild -version`,
30+
* `xcrun --show-sdk-version`, …). Must equal `COLD_TOOLCHAIN_PROBE_TIMEOUT_MS`
31+
* in `../snapshot-source/cache-identity.ts` -- both absorb the same ~18 to
32+
* 19 second syspolicyd signature-scan stall on the first `xcodebuild`/
33+
* `xcrun` exec after a fresh macOS host boots (#2422). It is declared here
34+
* rather than imported from that module because this file sits in every
35+
* platform-apple façade's eager closure and `snapshot-source/*` does not
36+
* (`scripts/__tests__/eager-closure-budgets.ts`); a unit test
37+
* (`__tests__/runner-cache-metadata.test.ts`) asserts the two constants stay
38+
* equal so they cannot drift apart.
39+
*/
40+
export const COLD_TOOLCHAIN_PROBE_TIMEOUT_MS = 30_000;
41+
2842
const TOOLCHAIN_PROBE_MAX_BUFFER = 128 * 1024;
2943
const TOOLCHAIN_PROBE_DETAIL_MAX_LENGTH = 200;
3044
const TOOLCHAIN_PROBE_HINT =

‎packages/platform-apple/src/snapshot-source/cache-identity.ts‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,27 @@ import type { ExecResult } from '@agent-device/host-kit/command';
44
import { snapshotSourceError } from './errors.ts';
55
import { remainingSnapshotSourceMs, type SnapshotSourceDeadline } from './deadline.ts';
66
import type { SnapshotSourceHost } from './types.ts';
7-
import { COLD_TOOLCHAIN_PROBE_TIMEOUT_MS } from '../toolchain-probe-budget.ts';
7+
8+
/**
9+
* Per-call timeout for a toolchain identity probe (`xcodebuild -version`,
10+
* `xcrun --show-sdk-version`, `sw_vers`, `uname`, …). On a fresh macOS host,
11+
* Apple's syspolicyd signature scan blocks the very first `xcodebuild`/
12+
* `xcrun`/large-binary exec after boot for roughly 18 to 19 seconds at 0%
13+
* CPU; the second exec of the same tool is instant. A budget sized for a
14+
* warm toolchain (the old 10 s / 5 s split) trips on that cold-start stall
15+
* and reports a bogus toolchain-probe timeout unrelated to the change under
16+
* test (#2422).
17+
*
18+
* `runner/runner-cache-metadata.ts` needs this same budget but cannot import
19+
* it from here: this module is outside every platform-apple façade's eager
20+
* closure today, and importing it from `runner-cache-metadata.ts` would pull
21+
* `snapshot-source/*` into all of them (`scripts/__tests__/eager-closure-
22+
* budgets.ts`). It instead declares its own copy of this constant, checked
23+
* against this one for equality by a unit test
24+
* (`runner/__tests__/runner-cache-metadata.test.ts`) so the two cannot drift
25+
* apart.
26+
*/
27+
export const COLD_TOOLCHAIN_PROBE_TIMEOUT_MS = 30_000;
828

929
export type SnapshotSourceToolchainIdentity = Readonly<{
1030
xcode: string;

‎packages/platform-apple/src/toolchain-probe-budget.ts‎

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)