mirror of
https://github.com/morluto/rea.git
synced 2026-11-21 22:15:50 +00:00
* 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>
142 lines
4.5 KiB
JavaScript
142 lines
4.5 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { createHash } from "node:crypto";
|
|
import { execFile } from "node:child_process";
|
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { promisify } from "node:util";
|
|
import {
|
|
artifactCli,
|
|
artifactMcpResult,
|
|
artifactMcpCall,
|
|
withArtifactMcp,
|
|
withBundleResourcesMcp,
|
|
} from "../../lib/artifact-e2e.mjs";
|
|
import { requireMcpToolError } from "../../lib/mcp-verifier-results.mjs";
|
|
import {
|
|
VerifierFixture,
|
|
withVerifierFixture,
|
|
} from "../../lib/verifier-fixture.mjs";
|
|
|
|
if (process.platform !== "darwin")
|
|
throw new Error(
|
|
"Asset catalog E2E requires macOS, Xcode actool and assetutil",
|
|
);
|
|
const exec = promisify(execFile);
|
|
await exec("/usr/bin/xcrun", ["--find", "actool"]);
|
|
await exec("/usr/bin/xcrun", ["--find", "clang"]);
|
|
await exec("/usr/bin/assetutil", ["--version"]);
|
|
const fixture = await VerifierFixture.open({ prefix: "rea-asset-e2e-" });
|
|
const root = fixture.path;
|
|
let report;
|
|
await withVerifierFixture(fixture, async () => {
|
|
const app = join(root, "Fixture.app");
|
|
const resources = join(app, "Contents", "Resources");
|
|
await mkdir(resources, { recursive: true });
|
|
await mkdir(join(app, "Contents", "MacOS"), { recursive: true });
|
|
await exec("/usr/bin/xcrun", [
|
|
"clang",
|
|
fileURLToPath(
|
|
new URL(
|
|
"../../../tests/conformance/interface-builder/fixture.c",
|
|
import.meta.url,
|
|
),
|
|
),
|
|
"-o",
|
|
join(app, "Contents", "MacOS", "Fixture"),
|
|
]);
|
|
await writeFile(
|
|
join(app, "Contents", "Info.plist"),
|
|
'<?xml version="1.0"?><plist version="1.0"><dict><key>CFBundleExecutable</key><string>Fixture</string><key>CFBundleIdentifier</key><string>dev.rea.asset-fixture</string></dict></plist>',
|
|
);
|
|
await exec("/usr/bin/xcrun", [
|
|
"actool",
|
|
fileURLToPath(
|
|
new URL(
|
|
"../../../tests/conformance/native/Assets.xcassets",
|
|
import.meta.url,
|
|
),
|
|
),
|
|
"--compile",
|
|
resources,
|
|
"--platform",
|
|
"macosx",
|
|
"--minimum-deployment-target",
|
|
"12.0",
|
|
]);
|
|
const raw = JSON.parse(
|
|
(
|
|
await exec("/usr/bin/assetutil", [
|
|
"--info",
|
|
join(resources, "Assets.car"),
|
|
])
|
|
).stdout,
|
|
);
|
|
const sha256 = createHash("sha256")
|
|
.update(await readFile(join(resources, "Assets.car")))
|
|
.digest("hex");
|
|
const executableSha256 = createHash("sha256")
|
|
.update(await readFile(join(app, "Contents", "MacOS", "Fixture")))
|
|
.digest("hex");
|
|
const cli = await artifactCli("inspect-asset-catalog", app);
|
|
assert.deepEqual(
|
|
cli.records.map(({ metadata }) => metadata),
|
|
raw,
|
|
);
|
|
assert.equal(cli.catalogs[0].sha256, sha256);
|
|
assert.ok(
|
|
cli.records.some(
|
|
({ asset_name, metadata }) =>
|
|
asset_name === "FixtureColor" && metadata.AssetType === "Color",
|
|
),
|
|
);
|
|
await withBundleResourcesMcp(app, async (client) => {
|
|
assert.deepEqual(
|
|
await artifactMcpResult(client, "inspect_asset_catalog"),
|
|
cli,
|
|
);
|
|
const first = await artifactMcpResult(client, "inspect_asset_catalog", {
|
|
limit: 1,
|
|
});
|
|
assert.equal(first.next_offset, 1);
|
|
const next = await artifactMcpResult(client, "inspect_asset_catalog", {
|
|
offset: first.next_offset,
|
|
});
|
|
assert.deepEqual([...first.records, ...next.records], cli.records);
|
|
const invalid = await artifactMcpCall(client, {
|
|
name: "inspect_asset_catalog",
|
|
arguments: { offset: -1 },
|
|
});
|
|
// appleAssetCatalogInputSchema requires an inclusive offset minimum of 0.
|
|
// projectInputIssues reports that bound as out_of_range.
|
|
assert.partialDeepStrictEqual(requireMcpToolError(invalid), {
|
|
code: "invalid_request",
|
|
details: {
|
|
operation: "inspect_asset_catalog",
|
|
issues: [{ path: ["offset"], reason: "out_of_range", minimum: 0 }],
|
|
},
|
|
});
|
|
});
|
|
const { resource_root, target_sha256, ...resourcePayload } = cli;
|
|
assert.equal(resource_root.executable_sha256, null);
|
|
assert.equal(target_sha256, null);
|
|
await withArtifactMcp(app, async (client) => {
|
|
const binary = await artifactMcpResult(client, "inspect_asset_catalog");
|
|
assert.equal(binary.target_sha256, executableSha256);
|
|
assert.deepEqual(binary, {
|
|
...resourcePayload,
|
|
target_sha256: executableSha256,
|
|
});
|
|
});
|
|
report = {
|
|
ok: true,
|
|
mocked: false,
|
|
cli: true,
|
|
stdio_mcp: true,
|
|
records: raw.length,
|
|
pagination: true,
|
|
malformed_input_rejected: true,
|
|
};
|
|
});
|
|
process.stdout.write(`${JSON.stringify(report)}\n`);
|