fix(mcp): require absolute evidence bundle paths
This commit is contained in:
1 parent
4714c7eaa3
commit
3cf6206614
6 files changed
+258
-16
No files matched your search
@@ -3,7 +3,6 @@ import { z } from "zod";
|
||||
import { isAbsolute } from "node:path";
|
||||
import { localPathStringSchema } from "../domain/localPath.js";
|
||||
import { artifactComparisonInputSchema } from "../domain/artifactComparison.js";
|
||||
import { bundleComparisonInputSchema } from "../domain/bundleComparison.js";
|
||||
import { callPathInputSchema } from "../domain/callPathSchemas.js";
|
||||
import { changedBehaviorInputSchema } from "../domain/changedBehavior.js";
|
||||
import { functionComparisonInputSchema } from "../domain/functionComparisonSchemas.js";
|
||||
@@ -23,6 +22,7 @@ import {
|
||||
import { binarySessionInputSchema } from "./sessionStatusContract.js";
|
||||
import {
|
||||
addressContextInputSchema,
|
||||
bundleComparisonMcpInputSchema,
|
||||
importEvidenceBundleInputSchema,
|
||||
listUnknownsInputSchema,
|
||||
navigationContextInputSchema,
|
||||
@@ -114,8 +114,8 @@ export const SESSION_TOOL_CONTRACTS = [
|
||||
),
|
||||
session(
|
||||
"compare_bundles",
|
||||
"Compare two canonical Evidence bundles by exact record membership, explicit one-to-one observation pairs, and complete residual-unknown revision histories. Missing bundle members describe omission only, never behavioral equivalence; output is digest-anchored and returns every change inline.",
|
||||
bundleComparisonInputSchema,
|
||||
"Compare two canonical Evidence bundles by exact record membership, explicit one-to-one observation pairs, and complete residual-unknown revision histories. Supply absolute local filesystem paths; relative paths are rejected. Missing bundle members describe omission only, never behavioral equivalence; output is digest-anchored and returns every change inline.",
|
||||
bundleComparisonMcpInputSchema,
|
||||
),
|
||||
session(
|
||||
"find_changed_behavior",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { z } from "zod";
|
||||
import { isAbsolute } from "node:path";
|
||||
|
||||
import { localPathStringSchema } from "../domain/localPath.js";
|
||||
import { absoluteLocalPathStringSchema } from "../domain/localPath.js";
|
||||
import { bundleComparisonInputSchema } from "../domain/bundleComparison.js";
|
||||
|
||||
import { processTraceSpecificationSchema } from "../domain/process/processTraceSpecification.js";
|
||||
import { evidenceSchema } from "../domain/evidence.js";
|
||||
@@ -27,16 +27,22 @@ export const addressContextInputSchema = z.strictObject({
|
||||
|
||||
/** Session-owned Evidence bundle import options. */
|
||||
export const importEvidenceBundleInputSchema = z.strictObject({
|
||||
path: localPathStringSchema
|
||||
.refine(isAbsolute, {
|
||||
message:
|
||||
"path must be an absolute local filesystem path (for example /tmp/evidence.json or C:\\rea\\evidence.json)",
|
||||
})
|
||||
.describe(
|
||||
"Absolute local filesystem path for the evidence bundle to import; relative paths are rejected.",
|
||||
),
|
||||
path: absoluteLocalPathStringSchema.describe(
|
||||
"Absolute local filesystem path for the evidence bundle to import; relative paths are rejected.",
|
||||
),
|
||||
});
|
||||
|
||||
/** MCP compares files selected on the server host, so require explicit paths. */
|
||||
export const bundleComparisonMcpInputSchema =
|
||||
bundleComparisonInputSchema.extend({
|
||||
left_bundle_path: absoluteLocalPathStringSchema.describe(
|
||||
"Absolute local filesystem path to the left Evidence bundle.",
|
||||
),
|
||||
right_bundle_path: absoluteLocalPathStringSchema.describe(
|
||||
"Absolute local filesystem path to the right Evidence bundle.",
|
||||
),
|
||||
});
|
||||
|
||||
/** Evidence references for deterministic process comparison. */
|
||||
export const processComparisonInputSchema = z.strictObject({
|
||||
left: evidenceSchema,
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { isAbsolute } from "node:path";
|
||||
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
import { absoluteLocalPathStringSchema } from "./localPath.js";
|
||||
|
||||
it("matches the host path module for absolute local paths", () => {
|
||||
for (const path of [
|
||||
"/absolute/path",
|
||||
"/",
|
||||
"relative/path",
|
||||
"C:\\absolute\\path",
|
||||
"c:/absolute/path",
|
||||
"C:relative/path",
|
||||
"\\\\server\\share\\path",
|
||||
"\\rooted\\path",
|
||||
"//server/share/path",
|
||||
"file:///absolute/path",
|
||||
]) {
|
||||
expect(absoluteLocalPathStringSchema.safeParse(path).success).toBe(
|
||||
isAbsolute(path),
|
||||
);
|
||||
}
|
||||
expect(absoluteLocalPathStringSchema.safeParse("").success).toBe(false);
|
||||
expect(
|
||||
absoluteLocalPathStringSchema.safeParse("/absolute/with\0nul").success,
|
||||
).toBe(false);
|
||||
});
|
||||
@@ -19,6 +19,12 @@ export const nulFreeStringSchema = z
|
||||
/** A selected local filesystem path: nonempty and free of NUL bytes. */
|
||||
export const localPathStringSchema = nulFreeStringSchema.min(1);
|
||||
|
||||
/** A caller-selected path that is absolute on the host running REA. */
|
||||
export const absoluteLocalPathStringSchema = localPathStringSchema.regex(
|
||||
process.platform === "win32" ? /^(?:[\\/]|[A-Za-z]:[\\/])/u : /^\//u,
|
||||
"must be an absolute local filesystem path",
|
||||
);
|
||||
|
||||
/** Test lexical containment on the host platform; callers must resolve symlinks first. */
|
||||
export const isPathWithinRoot = (root: string, path: string): boolean => {
|
||||
const value = relative(root, path);
|
||||
|
||||
Reference in new issue
Block a user