fix(mcp): preserve JavaScript workflow identity validation (#1366)

Preserve canonical distinct-source and unique-native-observation refinements after resolving inline or retained JavaScript workflow inputs. The shared application entry points now return structured invalid_request errors before graph parsing and computation, avoiding another complete graph capture.

Six focused tests, actual compiled CLI/SDK stdio workflows, JSON Schema dialect checks, static/document checks, and a real Notion ASAR analysis/recovery/trace/close workflow passed. All 20 final-head checks, including real JavaScript recovery, passed. Native-provider acceptance is not claimed for this provider-neutral validation change.

Fixes #1364
Refs #1065
This commit is contained in:
Ysopwnable
2026-10-10 05:11:38 +08:00
committed by GitHub
parent 6ce3288f3b
commit 53ed942a85
5 changed files with 444 additions and 44 deletions
@@ -46,6 +46,29 @@ const applicationFeatureSeedSchema = z.union([
}),
]);
/** Check unique native identities before projecting an application trace. */
const validateApplicationTraceIdentities = (
input: {
readonly native_observations: readonly { readonly evidence_id: string }[];
},
context: z.RefinementCtx,
): void => {
const ids = input.native_observations.map(({ evidence_id: id }) => id);
if (new Set(ids).size !== ids.length)
context.addIssue({
code: "custom",
path: ["native_observations"],
message: "Native observations must be unique",
});
};
/** Validate native trace identities without capturing their complete Evidence. */
export const applicationTraceIdentitiesSchema = z
.object({
native_observations: z.array(z.object({ evidence_id: evidenceIdSchema })),
})
.superRefine(validateApplicationTraceIdentities);
/** Evidence-backed application graph and feature seed. */
export const traceApplicationFeatureInputSchema = z
.strictObject({
@@ -54,15 +77,7 @@ export const traceApplicationFeatureInputSchema = z
seed: applicationFeatureSeedSchema,
direction: z.enum(["outgoing", "incoming", "both"]).default("both"),
})
.superRefine((input, context) => {
const ids = input.native_observations.map(({ evidence_id: id }) => id);
if (new Set(ids).size !== ids.length)
context.addIssue({
code: "custom",
path: ["native_observations"],
message: "Native observations must be unique",
});
});
.superRefine(validateApplicationTraceIdentities);
const seedMatchSchema = z.strictObject({
node_id: nodeIdSchema,