Files
reverse-engineering-anything/scripts/verify-real-hopper-linux.mjs
T
2474e6ec6c refactor(verify): run Hopper and Kuna verifier commands through the supervised owner (#12718)
* refactor(verify): run Hopper and Kuna verifier commands through the supervised owner

Replace bare execFile in the Hopper and Kuna real-provider verifiers with
createVerifierCommands, and run pre-workspace toolchain probes through
runOwnedCommand. Close the owner before lineage verification and keep the
diagnostic workspace when cleanup, lineage, or the run fails.

Replace isError-only and FAT64 prose refusals with the projected error code
and structured issue or target details.

* fix(verify): release a clean Kuna workspace after a verification failure

A failed check whose provider, command, and lineage cleanup all completed
still removes the root. The workspace stays only when that cleanup is
unconfirmed, which is the contract the Kuna verifier failure-path tests
already require.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(verify): keep the Kuna report when workspace release fails

release() closes cleanup registration before it removes the root, so
retain() after a failed release throws and skips the JSON report. Register
retention only when release has not started; a failed release already
keeps the workspace.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(verify): keep both Hopper verification and lineage failures

When verification has already failed and lineage observation then fails,
the retained-workspace error carried only the earlier cause. Aggregate
both failures in the Hopper, FAT, and caller verifiers so the cleanup
reason stays with the workspace.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(verify): keep Hopper manifests inside the repository

realpath() accepted REA_HOPPER_CONFORMANCE_MANIFEST_PATH as any filesystem
path. Resolve the manifest against the repository and reject a lexical or
symlink escape before it is read.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(verify): acquire command owners before verifier workspaces

* fix(verify): create the command owner before the verifier workspace

If command-owner setup fails after a workspace is allocated, the temporary
root is never released. Create the owner first and close it when workspace
allocation fails.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(verify): supervise Hopper helper CLI processes

* fix(verify): run Hopper helper CLIs through the command owner

Boundary and Linux owner-exit checks still launched the REA CLI with
execFile, so a timeout could not stop those processes. Both helpers now
require the verifier command owner and run those CLIs through it.

Co-authored-by: morluto <morluto@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <morluto@users.noreply.github.com>
2026-11-20 04:35:35 +00:00

54 lines
1.9 KiB
JavaScript

import { randomUUID } from "node:crypto";
import { access, symlink } from "node:fs/promises";
import { join } from "node:path";
import { runOwnedCommand } from "../dist/process/OwnedCommand.js";
import { createVerifierRun } from "./lib/verifier-run.mjs";
import {
VerifierFixture,
withVerifierFixture,
} from "./lib/verifier-fixture.mjs";
createVerifierRun();
if (process.platform !== "linux")
throw new Error("Linux real-Hopper verification must run on Linux");
const configuredLauncher = process.env.HOPPER_LAUNCHER_PATH;
const launcher = configuredLauncher ?? "/opt/hopper/bin/Hopper";
await access(launcher);
await access("/usr/bin/Xvfb");
await access("/usr/bin/xauth");
await access("/usr/bin/python3");
// ldd runs before a workspace exists, so it uses the same short-lived owner
// as requireLaneToolchain rather than a fixture-retained command owner.
const linked = await runOwnedCommand(
{
command: "ldd",
arguments: [launcher],
cwd: process.cwd(),
env: process.env,
runId: `rea-hopper-linux-ldd-${randomUUID()}`,
expectedCommand: null,
sweepTokenOwnedProcesses: true,
},
{ timeoutMs: null, diagnosticBytes: 1024 * 1024 },
);
if (`${linked.stdout.text}\n${linked.stderr.text}`.includes("not found"))
throw new Error("Hopper has unresolved shared-library dependencies");
const alternateDirectory = await VerifierFixture.open({
prefix: "rea-real-hopper-launcher-",
private: false,
});
const alternateLauncher = join(alternateDirectory.path, "Hopper-alternate");
await withVerifierFixture(alternateDirectory, async () => {
try {
await symlink(launcher, alternateLauncher);
process.env.HOPPER_LAUNCHER_PATH = alternateLauncher;
await import("./verify-real-hopper.mjs");
} finally {
if (configuredLauncher === undefined)
delete process.env.HOPPER_LAUNCHER_PATH;
else process.env.HOPPER_LAUNCHER_PATH = configuredLauncher;
}
});