fix(process): expose Darwin swiftc compile deadline via env (#2240)

* fix(process): expose Darwin swiftc compile deadline via env

Busy hosts can exceed the hard-coded 60s ownership-helper compile
timeout. Honor REA_SWIFTC_COMPILE_TIMEOUT_MS like the other provider
startup deadlines, keeping 60000 as the default.

Fixes #2184

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(process): keep the Swift compile deadline with its runtime owner

* fix(comparison): recheck historical calls-only changes (#2223)

* fix(comparison): preserve incomplete function call evidence

Keep missing, unknown, partial and unresolved call relationships unknown in function comparisons and reconstruction claims. Aggregate IDA caller and callee coverage without overwriting uncertainty.

Validate with 144 focused tests, typecheck/lint, docs checks and test discovery. Real providers were not verified; the full headless IDA session suite requires unavailable Windows native controls.

* fix(comparison): recheck historical calls-only changes

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
(cherry picked from commit 688defca0f)

* fix(ci): isolate Linux Hopper process fixture inventory

(cherry picked from commit 8cac51e12184d56a9ba80a4427b3e6082ddac1ec)

* fix(android): make DEX descriptor pattern portable

(cherry picked from commit 1335bcddc569a1cfb34b6efedcb6f2e3aaaa3357)

* fix: repair the static-check failures on the default branch (#2895)

* fix: repair the static-check failures on the default branch

The default branch fails its own required `Static checks` job three ways, so
every pull request reports that job as failed regardless of its own change.

- `npm run format:check` reports `src/domain/functionComparison.test.ts` and
  `src/ida/IdaOperationRunner.ts`.
- `npm run lint` reports a duplicate `import { join } from "node:path"` in
  `tests/boundary/mcp/ghidraInventoryMcp.test.ts` (lines 4 and 17).
- `npm run typecheck` reports `format: "devin"` missing from the client format
  union in `src/application/SupportedClients.ts`, and an unchecked index in
  `tests/boundary/cli/clientProfileLifecycle.test.ts`, whose pair array is
  inferred as `string[][]`.

Apply the pinned formatter, drop the duplicate import, list the `"devin"` format
that its own definition already uses, and mark the pair array `as const`.

Validation: `npm run check:fast` and `npm run format:check` pass.

* fix(setup): keep Devin on the JSON configuration dialect

---------

Co-authored-by: 吴佳浩 <wujiahao@supremind.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
(cherry picked from commit df3d96da80)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
Co-authored-by: morluto <17176810+morluto@users.noreply.github.com>
Co-authored-by: Lucien <164857476+dakjdakd@users.noreply.github.com>
Co-authored-by: 吴佳浩Alben <35291372+XiaoBinGan@users.noreply.github.com>
Co-authored-by: 吴佳浩 <wujiahao@supremind.com>
This commit is contained in:
BeqaKs
2026-10-14 02:59:54 +08:00
committed by GitHub
co-authored by Cursor morluto morluto Lucien 吴佳浩Alben 吴佳浩
parent 42667fc1a0
commit e4186af31b
8 changed files with 113 additions and 5 deletions
@@ -0,0 +1,34 @@
import { describe, expect, it } from "vitest";
import { resolveSwiftcCompileTimeoutMs } from "./DarwinProcessRunTokenReader.js";
describe("resolveSwiftcCompileTimeoutMs", () => {
it("keeps the historical default when unset", () => {
expect(resolveSwiftcCompileTimeoutMs({ environment: {} })).toBe(120_000);
});
it("prefers an explicit compileTimeoutMs over the environment", () => {
expect(
resolveSwiftcCompileTimeoutMs({
compileTimeoutMs: 12_000,
environment: { REA_SWIFTC_COMPILE_TIMEOUT_MS: "300000" },
}),
).toBe(12_000);
});
it("reads a valid REA_SWIFTC_COMPILE_TIMEOUT_MS value", () => {
expect(
resolveSwiftcCompileTimeoutMs({
environment: { REA_SWIFTC_COMPILE_TIMEOUT_MS: "300000" },
}),
).toBe(300_000);
});
it("falls back to the default for a malformed environment value", () => {
expect(
resolveSwiftcCompileTimeoutMs({
environment: { REA_SWIFTC_COMPILE_TIMEOUT_MS: "loud" },
}),
).toBe(120_000);
});
});
+28 -5
View File
@@ -5,6 +5,10 @@ import { isAbsolute, join } from "node:path";
import { fileURLToPath } from "node:url";
import { z } from "zod";
import {
DEFAULT_SWIFTC_COMPILE_TIMEOUT_MS,
providerStartupTimeoutSchema,
} from "../config/providerStartupTimeout.js";
import { safeParseJson } from "../domain/safeJson.js";
import { boundedUtf8Text } from "./boundedUtf8Text.js";
import { execFileOutput, execFileOutputFailure } from "./ExecFileOutput.js";
@@ -73,10 +77,27 @@ const sourceFiles = [
*/
export const SWIFTC_INTERRUPT = "SIGINT";
/** Deadline for the one-shot helper compilation. */
// A fresh Swift SDK cache took 88 seconds on the supported Intel macOS VM.
// Keep compilation bounded independently of short provider version probes.
const COMPILER_TIMEOUT_MS = 120_000;
/**
* Resolve the Darwin ownership-helper compile deadline from an explicit option
* or `REA_SWIFTC_COMPILE_TIMEOUT_MS`. The default matches the measured fresh
* Swift SDK cache on the supported Intel macOS VM (about 88s), so compilation
* stays bounded independently of short provider version probes. Invalid ambient
* values fall back to the default; `parseConfig` still rejects them at CLI/MCP
* admission.
*/
export const resolveSwiftcCompileTimeoutMs = (
options: {
readonly compileTimeoutMs?: number;
readonly environment?: Readonly<Record<string, string | undefined>>;
} = {},
): number => {
if (options.compileTimeoutMs !== undefined) return options.compileTimeoutMs;
const raw = (options.environment ?? process.env)
.REA_SWIFTC_COMPILE_TIMEOUT_MS;
if (raw === undefined) return DEFAULT_SWIFTC_COMPILE_TIMEOUT_MS;
const parsed = providerStartupTimeoutSchema.safeParse(raw);
return parsed.success ? parsed.data : DEFAULT_SWIFTC_COMPILE_TIMEOUT_MS;
};
/** Bound on compiler diagnostics embedded in the inspection failure text. */
const STDERR_EXCERPT_LIMIT = 512;
@@ -257,6 +278,8 @@ export const createDarwinProcessRunTokenReader = (
readonly compiler?: DarwinProcessReaderCompiler;
/** Deadline for helper compilation, independent of provider execution. */
readonly compileTimeoutMs?: number;
/** Environment consulted when `compileTimeoutMs` is omitted. */
readonly environment?: Readonly<Record<string, string | undefined>>;
/**
* Caller-owned directory holding the compiler's module cache. Unset keeps
* Swift's reusable default cache; a supplied directory outlives this
@@ -269,7 +292,7 @@ export const createDarwinProcessRunTokenReader = (
kind: "xcrun",
executable: "/usr/bin/xcrun",
};
const compilerTimeoutMs = options.compileTimeoutMs ?? COMPILER_TIMEOUT_MS;
const compilerTimeoutMs = resolveSwiftcCompileTimeoutMs(options);
const moduleCachePath = options.moduleCachePath ?? "";
let root: string | undefined;
let executable: string | undefined;
@@ -225,6 +225,8 @@ export const createSystemProcessOwnershipHost = (
readonly darwinCompiler?: DarwinProcessReaderCompiler;
/** Override the caller-owned module cache used compiling that helper. */
readonly darwinModuleCachePath?: string;
/** Deadline for Darwin ownership-helper compilation. */
readonly compileTimeoutMs?: number;
} = {},
): ProcessOwnershipHost => {
const darwinModuleCachePath =
@@ -247,6 +249,9 @@ export const createSystemProcessOwnershipHost = (
...(darwinModuleCachePath === undefined
? {}
: { moduleCachePath: darwinModuleCachePath }),
...(options.compileTimeoutMs === undefined
? { environment: hostEnvironment }
: { compileTimeoutMs: options.compileTimeoutMs }),
})
: undefined;
const listProcesses = async (signal?: AbortSignal) => {