Skip to content

armgit / rea

Public Imported from GitHub
0

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

test(native): validate demangling through owned contracts

morluto60c08802a7b6
diff --git a/tests/boundary/cli/nativeDemangleCli.test.ts b/tests/boundary/cli/nativeDemangleCli.test.ts
index fe905cbbf..431cf02ef 100644
--- a/tests/boundary/cli/nativeDemangleCli.test.ts
+++ b/tests/boundary/cli/nativeDemangleCli.test.ts
@@ -18,10 +18,10 @@ const evidenceTarget = async () => {
return path;
};
-describe.skipIf(process.platform !== "darwin")(
- "native Swift demangling CLI with line-terminator characters",
- () => {
- cliTest("keeps a carriage return in the symbol", async ({ cli }) => {
+describe("Swift demangling CLI with line-terminator characters", () => {
+ cliTest.skipIf(process.platform !== "darwin")(
+ "keeps a carriage return in the symbol",
+ async ({ cli }) => {
const result = await cli.run({
arguments: [
"demangle-swift",
@@ -41,26 +41,32 @@ describe.skipIf(process.platform !== "darwin")(
],
},
});
- });
+ },
+ );
- cliTest("rejects a symbol spanning lines as input", async ({ cli }) => {
- const missingTarget = join(
- await createTestTempDirectory("rea-demangle-invalid-input-"),
- "absent",
- );
- const result = await cli.run({
- arguments: [
- "demangle-swift",
- missingTarget,
- "$s4main3FooV",
- "$s4main\n3FooV",
- "--json",
- ],
- environment,
- timeoutMs: 20_000,
- });
- expect(result.exitCode).not.toBe(0);
- expect(result.json).toMatchObject({ code: "VALIDATION_ERROR" });
+ cliTest("rejects a symbol spanning lines as input", async ({ cli }) => {
+ const missingTarget = join(
+ await createTestTempDirectory("rea-demangle-invalid-input-"),
+ "absent",
+ );
+ const result = await cli.run({
+ arguments: [
+ "demangle-swift",
+ missingTarget,
+ "$s4main3FooV",
+ "$s4main\n3FooV",
+ "--json",
+ ],
+ environment,
+ timeoutMs: 20_000,
+ });
+ expect(result.signal).toBeNull();
+ expect(result.exitCode).toBe(1);
+ expect(result.json).toMatchObject({
+ code: "VALIDATION_ERROR",
+ fieldErrors: expect.arrayContaining([
+ expect.objectContaining({ path: "symbols.1", missing: false }),
+ ]),
});
- },
-);
+ });
+});
diff --git a/tests/boundary/mcp/nativeDemangleMcp.test.ts b/tests/boundary/mcp/nativeDemangleMcp.test.ts
index 7bff5fa03..3130d09bb 100644
--- a/tests/boundary/mcp/nativeDemangleMcp.test.ts
+++ b/tests/boundary/mcp/nativeDemangleMcp.test.ts
@@ -2,19 +2,15 @@ import { copyFile } from "node:fs/promises";
import { join } from "node:path";
import { describe, expect } from "vitest";
-import { z } from "zod";
+
+import { demangleSwiftSchema } from "../../../src/domain/native/nativeInspection.js";
+import { evidenceResultOf } from "../../../src/contracts/toolOutputSchemaPrimitives.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { mcpTest } from "../../support/mcp/mcpFixture.js";
import { openProductionTarget } from "../../support/mcp/productionSession.js";
-const demangledSchema = z.object({
- normalized_result: z.object({
- symbols: z.array(
- z.object({ input: z.string(), output: z.string(), status: z.string() }),
- ),
- }),
-});
+const demangledSchema = evidenceResultOf(demangleSwiftSchema);
describe.skipIf(process.platform !== "darwin")(
"native Swift demangling through MCP",