fix(native): name the ownership helper prerequisite in command failures (#2506)

* fix(native): name the ownership helper prerequisite in command failures

Every supervised native command launch needs the Darwin process-ownership
helper. When that helper cannot be compiled (relative REA_DARWIN_SWIFTC_PATH,
missing SDKROOT, a missing compiler, or an SDK/compiler mismatch), the
runner reduced the typed DarwinProcessOwnershipInspectionError to a bare
`io` failure. inspect_macho then reported `execution_failure` with no hint,
and inspect_artifact on any universal Mach-O said only "lipo could not
enumerate universal Mach-O slices".

The runner now keeps the inspection message as the failure's `detail` at
the launch boundary and carries it through xcrun resolution. The native
provider adds it to its diagnostics and the slice reader appends it to its
message, matching what the SQLite and capture providers already report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(native): cover the provider's ownership helper diagnostics

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kaoru0822
2026-10-13 00:10:58 -07:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 4276aaf18b
commit 20f51d7286
6 changed files with 90 additions and 2 deletions
+3 -1
View File
@@ -81,7 +81,9 @@ export class MachOSliceArtifactReader implements ArtifactReader {
if (!captured.ok)
throw new ArtifactReaderFailure(
captured.error.reason === "cancelled" ? "cancelled" : "unavailable",
"lipo could not enumerate universal Mach-O slices",
captured.error.detail === null
? "lipo could not enumerate universal Mach-O slices"
: `lipo could not enumerate universal Mach-O slices: ${captured.error.detail}`,
{
cause: captured.error,
...(captured.error.cleanupFailure === null &&
+18 -1
View File
@@ -4,6 +4,7 @@ import { createReadStream } from "node:fs";
import { realpath } from "node:fs/promises";
import { err, ok, type Result } from "../domain/result.js";
import { DarwinProcessOwnershipInspectionError } from "../process/DarwinProcessRunTokenReader.js";
import {
OwnedCommandFailure,
runOwnedCommand,
@@ -39,6 +40,7 @@ export interface NativeCommandCapture {
export class NativeCommandFailure extends Error {
readonly cleanupOwner: ProviderProcessSupervisor | undefined;
readonly cleanupFailures: readonly NativeCommandCleanupFailure[];
readonly detail: string | null;
constructor(
readonly tool: string,
@@ -58,6 +60,7 @@ export class NativeCommandFailure extends Error {
super(`Native command ${tool} failed: ${reason}`, options);
this.cleanupOwner = options?.cleanupOwner;
this.cleanupFailures = options?.cleanupFailures ?? [];
this.detail = options?.detail ?? null;
}
}
@@ -67,6 +70,8 @@ export interface NativeCommandFailureOptions extends ErrorOptions {
readonly cleanupOwner?: ProviderProcessSupervisor;
/** All owners still incomplete after a preflight retry blocked this command. */
readonly cleanupFailures?: readonly NativeCommandCleanupFailure[];
/** Host-side reason the command could not be supervised, such as a missing ownership helper compiler. */
readonly detail?: string;
}
/** One failed cleanup attempt; the runner retains `owner` until it is verified stopped. */
@@ -310,6 +315,9 @@ export const resolveXcrunTool = async (
...(found.error.cleanupFailures.length === 0
? {}
: { cleanupFailures: found.error.cleanupFailures }),
...(found.error.detail === null
? {}
: { detail: found.error.detail }),
},
found.error.capture,
found.error.cleanupFailure,
@@ -449,7 +457,16 @@ const captureProcess = async (
),
);
}
return err(new NativeCommandFailure(tool, "io", null, { cause }));
return err(
new NativeCommandFailure(tool, "io", null, {
cause,
// Process supervision needs the Darwin ownership helper; its typed
// message names the compiler or SDK prerequisite to fix.
...(cause instanceof DarwinProcessOwnershipInspectionError
? { detail: cause.message }
: {}),
}),
);
}
};
+1
View File
@@ -966,6 +966,7 @@ const translateCommandFailure = (
signal: failure.capture?.signal ?? null,
stdout_bytes: failure.capture?.stdoutBytes ?? 0,
stderr_bytes: failure.capture?.stderrBytes ?? 0,
...(failure.detail === null ? {} : { detail: failure.detail }),
},
});
};