Skip to content

armgit / rea

Public Imported from GitHub
0

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

test(javascript): distinguish selected paths from artifact identity

morlutob44cb5bd306d
diff --git a/tests/acceptance/applications/applicationWorkflowCli.test.ts b/tests/acceptance/applications/applicationWorkflowCli.test.ts
index d0eb19157..77795085c 100644
--- a/tests/acceptance/applications/applicationWorkflowCli.test.ts
+++ b/tests/acceptance/applications/applicationWorkflowCli.test.ts
@@ -20,6 +20,7 @@ import {
} from "../../../src/contracts/javascript/javascriptApplicationWorkflowExamples.js";
import { analyzeJavaScriptApplication } from "../../support/javascriptApplicationScope.js";
import { parseEvidence } from "../../../src/domain/evidence.js";
+import { absoluteCallerPath } from "../../../src/filesystem/callerPath.js";
import {
javascriptApplicationAnalysisResultSchema,
type JavaScriptApplicationAnalysisResult,
@@ -640,16 +641,18 @@ it("resolves source-map URL paths once without changing their declarations", asy
}, 20_000);
describe("JavaScript application path CLI", () => {
- it("accepts a relative local application path and preserves canonical Evidence identity", async () => {
+ it("retains the admitted relative CLI selection and canonical artifact identity", async () => {
const root = await createTestTempDirectory("rea-relative-application-cli-");
await writeFile(join(root, "app.js"), "export const value = 1;\n");
- const absolute = await analyzeJavaScriptApplication({ input_path: root });
+ const relativePath = relative(process.cwd(), root);
+ const admittedPath = absoluteCallerPath(relativePath);
+ const absolute = await analyzeJavaScriptApplication({
+ input_path: admittedPath,
+ });
if (!absolute.ok) throw absolute.error;
const absoluteAnalysis = javascriptApplicationAnalysisResultSchema.parse(
absolute.value.normalized_result,
);
-
- const relativePath = relative(process.cwd(), root);
const fromCli = await runCli([
"analyze-javascript-application",
relativePath,
@@ -658,6 +661,7 @@ describe("JavaScript application path CLI", () => {
expect(fromCli).toMatchObject({
evidence_id: absolute.value.evidence_id,
+ parameters: { input_path: admittedPath },
normalized_result: {
input_path: absoluteAnalysis.input_path,
},
diff --git a/tests/boundary/mcp/applicationExportShapeMcp.test.ts b/tests/boundary/mcp/applicationExportShapeMcp.test.ts
index 179451390..8ace1e8af 100644
--- a/tests/boundary/mcp/applicationExportShapeMcp.test.ts
+++ b/tests/boundary/mcp/applicationExportShapeMcp.test.ts
@@ -154,9 +154,6 @@ describe("application workflow MCP parity", () => {
]);
if (!left.ok) throw left.error;
if (!right.ok) throw right.error;
- const leftAnalysis = javascriptApplicationAnalysisResultSchema.parse(
- left.value.normalized_result,
- );
const harness = await createApplicationMcpHarness();
const { client, session } = harness;
const selectors = {
@@ -166,16 +163,22 @@ describe("application workflow MCP parity", () => {
right_export_name: "default",
};
try {
+ const relativePath = relative(process.cwd(), leftRoot);
const relativeApplication = await client.callTool({
name: "analyze_javascript_application",
- arguments: { input_path: relative(process.cwd(), leftRoot) },
+ arguments: { input_path: relativePath },
});
expect(relativeApplication.isError).not.toBe(true);
- expect(relativeApplication.structuredContent).toMatchObject({
- evidence_id: left.value.evidence_id,
- normalized_result: { input_path: leftAnalysis.input_path },
- subject: { local_path: left.value.subject?.local_path },
- });
+ const relativeEvidence = parseEvidence(
+ relativeApplication.structuredContent,
+ );
+ expect(relativeEvidence.parameters.input_path).toBe(relativePath);
+ expect(left.value.parameters.input_path).toBe(leftRoot);
+ expect(relativeEvidence.normalized_result).toEqual(
+ left.value.normalized_result,
+ );
+ expect(relativeEvidence.subject).toEqual(left.value.subject);
+ expect(relativeEvidence.evidence_id).not.toBe(left.value.evidence_id);
const full = await client.callTool({
name: "compare_javascript_export_shapes",
arguments: { left: left.value, right: right.value, ...selectors },