Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(hopper): keep automated Linux setup off non-x86_64 hosts (#3422)

David Fontanet Bujaldón86655eac6655
diff --git a/docs/installation.md b/docs/installation.md
index d6e1bdb4b..80a10fe20 100644
--- a/docs/installation.md
+++ b/docs/installation.md
@@ -542,8 +542,10 @@ Hopper is separate commercial software with its own license. Its free demo has
vendor-defined limits, and a paid license is optional. REA reuses any detected
installation and preserves Hopper during uninstall.
-The automated Hopper installer supports macOS 12+, Ubuntu 24.04+, Fedora 41+,
-Nobara 44+, 64-bit Arch Linux, CachyOS, or Omarchy. REA itself runs on any
+The automated Hopper installer supports macOS 12+ and x86_64 hosts running
+Ubuntu 24.04+, Fedora 41+, Nobara 44+, Arch Linux, CachyOS, or Omarchy. The
+official Linux packages are x86_64-only, so setup does not offer Hopper on other
+Linux architectures; configure [Ghidra](#ghidra) there instead. REA itself runs on any
Linux distribution with a recognized apt, dnf, or pacman package family, where
an existing Hopper launcher is selected through `HOPPER_LAUNCHER_PATH`. Ghidra
and IDA have their own provider-specific host requirements; Windows Ghidra uses
diff --git a/scripts/verify-package-discovery.d.mts b/scripts/verify-package-discovery.d.mts
index 1531e9dba..85f433a50 100644
--- a/scripts/verify-package-discovery.d.mts
+++ b/scripts/verify-package-discovery.d.mts
@@ -15,7 +15,8 @@ export interface SetupHostFacts {
/**
* Derive agent setup support from the doctor node check and automated Hopper
* installer applicability from the facts their owners parse. Applicability is
- * undefined when its owning fact is unavailable.
+ * undefined when its owning fact is unavailable. On Linux, Hopper readiness is
+ * required only where the automated installer applies.
*/
export function packageSetupSupport(
checks:
diff --git a/scripts/verify-package-discovery.mjs b/scripts/verify-package-discovery.mjs
index 9f2a5d7a8..f0d5016d6 100644
--- a/scripts/verify-package-discovery.mjs
+++ b/scripts/verify-package-discovery.mjs
@@ -33,24 +33,23 @@ const REQUIRED_LLM_TOPICS = [
*
* Host readiness and installer applicability are different facts: a
* distribution REA supports can still be absent from the Hopper package's
- * tested list, so the doctor host check cannot answer the second question.
- * Applicability stays undefined when its owning fact is unavailable, which is
- * distinct from a host known to lack an automated installer.
+ * tested list, or run on an architecture the package lacks, so the doctor host
+ * check cannot answer the second question. On Linux, Hopper readiness is
+ * required only where the automated installer applies; elsewhere setup never
+ * provides Hopper. Applicability stays undefined when its owning fact is
+ * unavailable, which is distinct from a host known to lack an automated
+ * installer.
*/
export function packageSetupSupport(checks, host) {
const supportedSetupHost =
checks?.find(({ name }) => name === "node")?.ok === true;
+ const hostCheckOk = checks?.find(({ name }) => name === "host")?.ok;
+ const hopperSetupSupported = hopperInstallerSupported(host, hostCheckOk);
const hopperReadinessRequired =
host.platform !== "win32" &&
- checks?.find(({ name }) => name === "host")?.ok === true;
- return {
- supportedSetupHost,
- hopperReadinessRequired,
- hopperSetupSupported: hopperInstallerSupported(
- host,
- checks?.find(({ name }) => name === "host")?.ok,
- ),
- };
+ hostCheckOk === true &&
+ (host.platform !== "linux" || hopperSetupSupported === true);
+ return { supportedSetupHost, hopperReadinessRequired, hopperSetupSupported };
}
/**
@@ -76,7 +75,7 @@ async function readHostLinuxDistribution() {
if (process.platform !== "linux") return undefined;
const { readLinuxDistribution } =
await import("../dist/application/LinuxHopper.js");
- return readLinuxDistribution();
+ return readLinuxDistribution(process.arch);
}
/** Validate --help, --llms, and doctor output and determine host setup support. */
diff --git a/src/application/Doctor.test.ts b/src/application/Doctor.test.ts
index a134fa2a6..8f01ccc7e 100644
--- a/src/application/Doctor.test.ts
+++ b/src/application/Doctor.test.ts
@@ -445,7 +445,7 @@ describe("doctor", () => {
),
).toEqual({
node: `Install ${SUPPORTED_NODE_VERSION_PROSE}.`,
- host: "REA supports macOS 12+, Linux distributions with a recognized apt, dnf, or pacman package family, and the experimental Windows x64 Ghidra P0 boundary; automated Hopper setup additionally requires Ubuntu 24.04+, Fedora 41+, Nobara 44+, 64-bit Arch Linux, CachyOS, or Omarchy.",
+ host: "REA supports macOS 12+, Linux distributions with a recognized apt, dnf, or pacman package family, and the experimental Windows x64 Ghidra P0 boundary; automated Hopper setup on Linux additionally requires an x86_64 host running Ubuntu 24.04+, Fedora 41+, Nobara 44+, Arch Linux, CachyOS, or Omarchy.",
hopper: "Run rea setup to install Hopper, or set HOPPER_LAUNCHER_PATH.",
target: "Supply a readable local app or program path.",
});
diff --git a/src/application/Doctor.ts b/src/application/Doctor.ts
index cbb335322..735258b0d 100644
--- a/src/application/Doctor.ts
+++ b/src/application/Doctor.ts
@@ -566,7 +566,7 @@ export const systemDoctorHost = (
: { configuredIlspyCmdPath: environment.REA_ILSPY_CMD_PATH }),
macosVersion: () =>
readMacosVersion(hostExecFileOutput, commandEnvironment),
- linuxDistribution: readLinuxDistribution,
+ linuxDistribution: () => readLinuxDistribution(architecture),
async validTarget(path) {
return (
await parseBinaryTarget(path, {
diff --git a/src/application/DoctorDiagnostics.ts b/src/application/DoctorDiagnostics.ts
index f09c17889..46236bd77 100644
--- a/src/application/DoctorDiagnostics.ts
+++ b/src/application/DoctorDiagnostics.ts
@@ -4,6 +4,7 @@ import {
} from "../domain/runtimeVersion.js";
import { providerStartupTimeoutSchema } from "../config/providerStartupTimeout.js";
import {
+ LINUX_HOPPER_SETUP_HOSTS,
linuxHopperLauncherCandidates,
systemLinuxHopperLauncherCandidates,
supportsReaHost,
@@ -147,8 +148,7 @@ const hostCheck = async (host: DoctorHost): Promise<DoctorCheck> => {
? `${host.platform} ${host.architecture}`
: `${linuxDistribution.id} ${linuxDistribution.versionId ?? "unknown"}`);
return check("host", supported, detail, {
- remediation:
- "REA supports macOS 12+, Linux distributions with a recognized apt, dnf, or pacman package family, and the experimental Windows x64 Ghidra P0 boundary; automated Hopper setup additionally requires Ubuntu 24.04+, Fedora 41+, Nobara 44+, 64-bit Arch Linux, CachyOS, or Omarchy.",
+ remediation: `REA supports macOS 12+, Linux distributions with a recognized apt, dnf, or pacman package family, and the experimental Windows x64 Ghidra P0 boundary; automated Hopper setup on Linux additionally requires ${LINUX_HOPPER_SETUP_HOSTS}.`,
classification: "unsupported_host",
});
};
diff --git a/src/application/LinuxHopper.test.ts b/src/application/LinuxHopper.test.ts
index b1c802879..7a2838e86 100644
--- a/src/application/LinuxHopper.test.ts
+++ b/src/application/LinuxHopper.test.ts
@@ -144,24 +144,38 @@ class RecordingLinuxHost implements LinuxHopperInstallHost {
};
}
+const TESTED_DISTRIBUTIONS = [
+ ['ID=ubuntu\nVERSION_ID="24.04"\n', "deb"],
+ ["ID=fedora\nVERSION_ID=41\n", "rpm"],
+ ['ID=nobara\nVERSION_ID="44"\nID_LIKE="rhel centos fedora"\n', "rpm"],
+ ["ID=arch\n", "arch"],
+ ["ID=cachyos\nID_LIKE=arch\n", "arch"],
+ ['ID=omarchy\nID_LIKE=arch\nVERSION_ID="4.0.4"\n', "arch"],
+] as const;
+
describe("Linux Hopper host classification", () => {
- it.each([
- ['ID=ubuntu\nVERSION_ID="24.04"\n', "deb"],
- ["ID=fedora\nVERSION_ID=41\n", "rpm"],
- ['ID=nobara\nVERSION_ID="44"\nID_LIKE="rhel centos fedora"\n', "rpm"],
- ["ID=arch\n", "arch"],
- ["ID=cachyos\nID_LIKE=arch\n", "arch"],
- ['ID=omarchy\nID_LIKE=arch\nVERSION_ID="4.0.4"\n', "arch"],
- ] as const)(
+ it.each(TESTED_DISTRIBUTIONS)(
"accepts an explicitly supported distribution",
(document, family) => {
- expect(parseLinuxDistribution(document)).toMatchObject({
+ expect(parseLinuxDistribution(document, "x64")).toMatchObject({
packageFamily: family,
hopperSetupSupported: true,
});
},
);
+ it.each(TESTED_DISTRIBUTIONS)(
+ "keeps the x86_64-only Hopper package off an arm64 host running %s",
+ (document, family) => {
+ const distribution = parseLinuxDistribution(document, "arm64");
+ expect(distribution).toMatchObject({
+ packageFamily: family,
+ hopperSetupSupported: false,
+ });
+ expect(supportsReaHost(distribution)).toBe(true);
+ },
+ );
+
it("detects unresolved or loader-reported shared libraries", () => {
expect(
linuxSharedLibrariesAvailable(
@@ -193,7 +207,9 @@ describe("Linux Hopper host classification", () => {
])(
"rejects vendor/version combinations without a tested Hopper installer",
(document) => {
- expect(parseLinuxDistribution(document).hopperSetupSupported).toBe(false);
+ expect(parseLinuxDistribution(document, "x64").hopperSetupSupported).toBe(
+ false,
+ );
},
);
@@ -207,14 +223,16 @@ describe("Linux Hopper host classification", () => {
])(
"hosts REA on a distribution Hopper has no tested package for: %s",
(document) => {
- const distribution = parseLinuxDistribution(document);
+ const distribution = parseLinuxDistribution(document, "x64");
expect(distribution.hopperSetupSupported).toBe(false);
expect(supportsReaHost(distribution)).toBe(true);
},
);
it("withholds host support from a distribution with no package family", () => {
- expect(supportsReaHost(parseLinuxDistribution("ID=nixos\n"))).toBe(false);
+ expect(supportsReaHost(parseLinuxDistribution("ID=nixos\n", "x64"))).toBe(
+ false,
+ );
expect(supportsReaHost(undefined)).toBe(false);
});
});
diff --git a/src/application/LinuxHopper.ts b/src/application/LinuxHopper.ts
index 203debce3..3eef31531 100644
--- a/src/application/LinuxHopper.ts
+++ b/src/application/LinuxHopper.ts
@@ -31,6 +31,16 @@ import {
/** Package-manager output retained per stream without stopping the command. */
const PACKAGE_MANAGER_OUTPUT_BYTES = 64 * 1024;
+/**
+ * The only host architecture the published Linux packages declare: `dpkg-deb`
+ * reports `Architecture: amd64`, the RPM lead is `x86_64`, and `.PKGINFO` has
+ * `arch = x86_64`.
+ */
+const SUPPORTED_RELEASE_ARCHITECTURE: NodeJS.Architecture = "x64";
+
+/** Hosts the automated Linux Hopper installer supports, for remediation text. */
+export const LINUX_HOPPER_SETUP_HOSTS =
+ "an x86_64 host running Ubuntu 24.04+, Fedora 41+, Nobara 44+, Arch Linux, CachyOS, or Omarchy";
/** Package mutations disclosed before a Linux Hopper installation. */
export interface LinuxHopperInstallDisclosure {
@@ -77,7 +87,8 @@ interface LinuxDistributionIdentity {
/**
* Parsed Linux distribution information used for package selection.
*
- * `hopperSetupSupported` is the automated Hopper installer's tested list. It is
+ * `hopperSetupSupported` is the automated Hopper installer's tested list,
+ * restricted to hosts whose architecture matches the pinned package. It is
* narrower than the hosts where REA itself runs, which {@link supportsReaHost}
* answers from the package family.
*/
@@ -250,8 +261,14 @@ export type LinuxHopperLauncherStatus =
| "unsupported_hopper_build"
| "cleanup_failed";
-/** Parse an os-release document without executing its shell syntax. */
-export const parseLinuxDistribution = (text: string): LinuxDistribution => {
+/**
+ * Parse an os-release document without executing its shell syntax, and
+ * classify automated Hopper setup for the host architecture.
+ */
+export const parseLinuxDistribution = (
+ text: string,
+ architecture: NodeJS.Architecture,
+): LinuxDistribution => {
const fields = new Map<string, string>();
for (const line of text.split("\n")) {
const match = /^([A-Z_]+)=(.*)$/u.exec(line.trim());
@@ -273,6 +290,7 @@ export const parseLinuxDistribution = (text: string): LinuxDistribution => {
const packageFamily = packageFamilyFor(id, fields.get("ID_LIKE"));
const hopperSetupSupported =
packageFamily !== undefined &&
+ architecture === SUPPORTED_RELEASE_ARCHITECTURE &&
(id === "arch" ||
id === "cachyos" ||
(id === "omarchy" && packageFamily === "arch") ||
@@ -288,12 +306,15 @@ export const parseLinuxDistribution = (text: string): LinuxDistribution => {
: { ...identity, packageFamily, hopperSetupSupported: false };
};
-/** Read and classify the current Linux distribution. */
-export const readLinuxDistribution = async (): Promise<
- LinuxDistribution | undefined
-> => {
+/** Read and classify the current Linux distribution on a host architecture. */
+export const readLinuxDistribution = async (
+ architecture: NodeJS.Architecture,
+): Promise<LinuxDistribution | undefined> => {
try {
- return parseLinuxDistribution(await readFile("/etc/os-release", "utf8"));
+ return parseLinuxDistribution(
+ await readFile("/etc/os-release", "utf8"),
+ architecture,
+ );
} catch (cause: unknown) {
// best-effort cleanup: optional host probing; unknown distribution means unsupported.
void cause;
@@ -303,7 +324,7 @@ export const readLinuxDistribution = async (): Promise<
/** Download, verify, install, and read back the official Hopper Linux package. */
export const installLinuxHopper = async (
- host: LinuxHopperInstallHost = systemLinuxHopperInstallHost(process.env),
+ host: LinuxHopperInstallHost,
options: {
readonly signal?: AbortSignal;
} = {},
@@ -451,13 +472,18 @@ export const linuxHopperLauncherCandidates = (
...systemLinuxHopperLauncherCandidates,
];
-/** Compose package-manager and linker checks from the selected caller environment. */
+/**
+ * Compose package-manager and linker checks from the selected caller
+ * environment. The distribution comes from the caller's host-fact owner, so
+ * installation follows the same architecture classification as the plan.
+ */
export const systemLinuxHopperInstallHost = (
environment: Readonly<NodeJS.ProcessEnv>,
+ distribution: LinuxHopperInstallHost["distribution"],
): LinuxHopperInstallHost => {
const publisher = systemLinuxHopperPublisher(environment);
return {
- distribution: readLinuxDistribution,
+ distribution,
release: (family, signal) => publisher.currentRelease(family, signal),
download: downloadHopperPackage,
createTemporaryDirectory: () => mkdtemp(join(tmpdir(), "rea-hopper-")),
@@ -508,7 +534,9 @@ export const systemLinuxHopperPublisher = (
): LinuxHopperPublisher =>
new LinuxHopperPublisher(
environment,
- async () => (await readLinuxDistribution())?.packageFamily,
+ // Only the package family is read here; it does not depend on the
+ // architecture that gates automated setup.
+ async () => (await readLinuxDistribution(process.arch))?.packageFamily,
);
/** Read-only authentication; persistent package retention belongs to approved setup. */
diff --git a/src/application/Setup.recovery.test.ts b/src/application/Setup.recovery.test.ts
index 244aee26b..f6522eafe 100644
--- a/src/application/Setup.recovery.test.ts
+++ b/src/application/Setup.recovery.test.ts
@@ -316,7 +316,7 @@ describe("setup scoped readiness", () => {
expect(result.status).toBe("needs_human");
expect(host.hopperInstalls).toBe(0);
expect(result.remediation).toBe(
- "Automated Hopper setup supports Ubuntu 24.04+, Fedora 41+, Nobara 44+, 64-bit Arch Linux, CachyOS, and Omarchy; configure an existing supported provider instead.",
+ "Automated Hopper setup requires an x86_64 host running Ubuntu 24.04+, Fedora 41+, Nobara 44+, Arch Linux, CachyOS, or Omarchy; configure an existing supported provider instead.",
);
});
diff --git a/src/application/SetupHost.ts b/src/application/SetupHost.ts
index aa17c643f..9f6e2ceb7 100644
--- a/src/application/SetupHost.ts
+++ b/src/application/SetupHost.ts
@@ -21,8 +21,8 @@ import {
import { runDoctor, systemDoctorHost, type DoctorHost } from "./Doctor.js";
import {
installLinuxHopper,
+ LINUX_HOPPER_SETUP_HOSTS,
LinuxHopperTemporaryCleanupOwner,
- readLinuxDistribution,
systemLinuxHopperInstallHost,
type LinuxHopperInstallHost,
} from "./LinuxHopper.js";
@@ -129,7 +129,7 @@ export const hostRemediation = async (
return `Install ${SUPPORTED_NODE_VERSION_PROSE} and rerun setup.`;
if (!installHopper) return undefined;
if (host.platform !== "darwin" && host.platform !== "linux")
- return "REA supports Hopper on macOS and selected 64-bit Linux distributions.";
+ return "REA supports Hopper on macOS and selected x86_64 Linux distributions.";
if (host.platform === "darwin") {
const version = await host.macosVersion();
return version === undefined || major(version) < 12
@@ -138,7 +138,7 @@ export const hostRemediation = async (
}
if ((await host.linuxDistribution())?.hopperSetupSupported === true)
return undefined;
- return "Automated Hopper setup supports Ubuntu 24.04+, Fedora 41+, Nobara 44+, 64-bit Arch Linux, CachyOS, and Omarchy; configure an existing supported provider instead.";
+ return `Automated Hopper setup requires ${LINUX_HOPPER_SETUP_HOSTS}; configure an existing supported provider instead.`;
};
/** Production setup effects for Hopper, agent configuration, and the canonical skill directory. */
@@ -154,7 +154,11 @@ export const systemSetupHost = (
? systemMacHopperInstallHost(homeDirectory, environment)
: undefined;
const resources = new ArtifactResourceScope();
- const linuxHopperHost = systemLinuxHopperInstallHost(environment);
+ const linuxDistribution = () => doctorHost.linuxDistribution();
+ const linuxHopperHost = systemLinuxHopperInstallHost(
+ environment,
+ linuxDistribution,
+ );
const pendingLinuxHopperCleanup = new LinuxHopperTemporaryCleanupOwner();
return {
platform,
@@ -170,7 +174,7 @@ export const systemSetupHost = (
...setupRegistration(platform, homeDirectory, environment),
nodeVersion: process.versions.node,
macosVersion: () => doctorHost.macosVersion(),
- linuxDistribution: readLinuxDistribution,
+ linuxDistribution,
close: () =>
closeSetupResources(resources, macHopperHost, doctorHost, () =>
closeLinuxHopperInstallHost(linuxHopperHost, pendingLinuxHopperCleanup),
diff --git a/src/setupEnvironment.test.ts b/src/setupEnvironment.test.ts
index a065c51da..02efabcfb 100644
--- a/src/setupEnvironment.test.ts
+++ b/src/setupEnvironment.test.ts
@@ -294,6 +294,55 @@ it.each([
},
);
+it.each([
+ {
+ architecture: "x64",
+ hopperSetupSupported: true,
+ code: "download_failed",
+ downloads: 1,
+ },
+ {
+ architecture: "arm64",
+ hopperSetupSupported: false,
+ code: "unsupported_host",
+ downloads: 0,
+ },
+] as const)(
+ "installs Linux Hopper from the selected doctor host's $architecture classification",
+ async ({ architecture, hopperSetupSupported, code, downloads }) => {
+ // Installation must follow the doctor host's facts, never the ambient
+ // os-release and process.arch. A refused download keeps the supported case
+ // from writing or invoking a package manager.
+ const fetch = vi
+ .spyOn(globalThis, "fetch")
+ .mockResolvedValue(new Response(null, { status: 403 }));
+ const host = systemSetupHost(
+ createDoctorHostFixture({
+ platform: "linux",
+ architecture,
+ linuxDistribution: () =>
+ Promise.resolve({
+ id: "ubuntu",
+ versionId: "24.04",
+ packageFamily: "deb",
+ hopperSetupSupported,
+ }),
+ }),
+ { HOME: "/fixture/home" },
+ );
+ try {
+ expect(await host.installHopper(false)).toMatchObject({
+ status: "failed",
+ code,
+ });
+ expect(fetch).toHaveBeenCalledTimes(downloads);
+ } finally {
+ fetch.mockRestore();
+ await host.close?.();
+ }
+ },
+);
+
it("registers the selected Windows package runner after canonicalizing environment aliases", async () => {
const environment = snapshotEnvironment(
{
diff --git a/tests/evaluation/package/packageSetupSupport.test.ts b/tests/evaluation/package/packageSetupSupport.test.ts
index 2103e5f95..c8c92be3d 100644
--- a/tests/evaluation/package/packageSetupSupport.test.ts
+++ b/tests/evaluation/package/packageSetupSupport.test.ts
@@ -3,16 +3,25 @@ import { describe, expect, it } from "vitest";
import { packageSetupSupport } from "../../../scripts/verify-package-discovery.mjs";
import { parseLinuxDistribution } from "../../../src/application/LinuxHopper.js";
-const osRelease = (fields: Record<string, string>) =>
+const osRelease = (
+ fields: Record<string, string>,
+ architecture: NodeJS.Architecture = "x64",
+) =>
parseLinuxDistribution(
Object.entries(fields)
.map(([key, value]) => `${key}="${value}"`)
.join("\n"),
+ architecture,
);
/** A Debian-family host REA supports that the Hopper package never tests. */
const KALI = osRelease({ ID: "kali", VERSION_ID: "2026.3", ID_LIKE: "debian" });
const UBUNTU_24 = osRelease({ ID: "ubuntu", VERSION_ID: "24.04" });
+/** A tested distribution on an architecture the pinned Hopper packages lack. */
+const UBUNTU_24_ARM64 = osRelease(
+ { ID: "ubuntu", VERSION_ID: "24.04" },
+ "arm64",
+);
const checks = ({ node = true, host = true } = {}) => [
{ name: "node", ok: node },
@@ -22,7 +31,8 @@ const checks = ({ node = true, host = true } = {}) => [
describe("packaged setup support derivation", () => {
it("keeps an installer-untested REA-supported distribution out of the automated Hopper path", () => {
// The doctor host check passes on Kali, so reading installer applicability
- // from it promised an automated install the packaged setup never offers.
+ // from it promised an automated install the packaged setup never offers,
+ // and Hopper readiness that setup never provides there.
expect(
packageSetupSupport(checks(), {
platform: "linux",
@@ -30,7 +40,23 @@ describe("packaged setup support derivation", () => {
}),
).toEqual({
supportedSetupHost: true,
- hopperReadinessRequired: true,
+ hopperReadinessRequired: false,
+ hopperSetupSupported: false,
+ });
+ });
+
+ it("keeps an arm64 host off the x86_64-only automated Hopper path", () => {
+ // ubuntu-24.04-arm runs REA, but every pinned Linux Hopper package is
+ // x86_64, so packaged setup must not expect an automated install or
+ // Hopper readiness there.
+ expect(
+ packageSetupSupport(checks(), {
+ platform: "linux",
+ linuxDistribution: UBUNTU_24_ARM64,
+ }),
+ ).toEqual({
+ supportedSetupHost: true,
+ hopperReadinessRequired: false,
hopperSetupSupported: false,
});
});