fix(javascript): advertise the exact empty seed rule and match empty API keys

Express the empty-seed rule as a JSON-Schema-representable union, so
the advertised trace_application_feature schema rejects what the
server rejects, and match context-bridge seeds on the exact api_key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Iwakurakaoru0822
2026-10-06 22:00:14 -07:00
co-authored by Claude Opus 5.5
parent 6cc45e8dc9
commit 35e5508fd0
3 changed files with 64 additions and 42 deletions
+24 -26
View File
@@ -17,36 +17,34 @@ export const featureSeedMatchMode = (seed: {
}): "exact" | "contains" =>
seed.match ?? (seed.kind === "string" ? "contains" : "exact");
const literalSeedKinds = [
"route",
"string",
"api",
"channel",
"module",
"native-export",
] as const;
/**
* Literal starting point for one application feature trace. An exact literal
* seed may be empty, such as the channel in `ipcMain.handle("")`; an empty
* containment seed would select every node, so it is rejected.
* Literal starting point for one application feature trace. An empty value,
* such as the channel in `ipcMain.handle("")`, must be an explicit exact
* literal seed: empty containment would select every node.
*/
const applicationFeatureSeedSchema = z
.strictObject({
kind: z.enum([
"node-id",
"route",
"string",
"api",
"channel",
"module",
"native-export",
]),
value: z.string(),
const applicationFeatureSeedSchema = z.union([
z.strictObject({
kind: z.enum(["node-id", ...literalSeedKinds]),
value: boundedTextSchema,
match: z.enum(["exact", "contains"]).nullable().default(null),
case_sensitive: z.boolean().default(false),
})
.superRefine((seed, context) => {
if (seed.value !== "") return;
if (seed.kind === "node-id" || featureSeedMatchMode(seed) === "contains")
context.addIssue({
code: "custom",
path: ["value"],
message:
'An empty seed value requires an exact literal match: use match "exact" with a non-node-id kind',
});
});
}),
z.strictObject({
kind: z.enum(literalSeedKinds),
value: z.literal(""),
match: z.literal("exact"),
case_sensitive: z.boolean().default(false),
}),
]);
/** Evidence-backed application graph and feature seed. */
export const traceApplicationFeatureInputSchema = z