test(javascript): distinguish selected paths from artifact identity

Check CLI parity against the admitted absolute selection and verify that MCP retains relative selections separately. Equal canonical artifact results do not imply equal Evidence IDs when caller-selected paths differ.
This commit is contained in:
morluto committed 2026-10-20 01:17:45 +08:00
1 parent 2dd5effe2a
commit b44cb5bd30
2 files changed
+20 -13

No files matched your search

@@ -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,
},
@@ -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 },