@phren/cli
Version:
Knowledge layer for AI agents - CLI, MCP server, and data layer
27 lines (26 loc) • 1.41 kB
JavaScript
import { z } from "zod";
export const RECALL_NEGATIVE_CLASSES = ["conversational", "off-domain", "cross-project-lure", "typo", "envelope", "other-tool", "trust-expiry"];
export const RECALL_TIERS = ["active", "topic", "older"];
export const recallEvalCaseSchema = z.object({
id: z.string().trim().min(1),
prompt: z.string().trim().min(1),
project: z.string().trim().min(1).nullable(),
kind: z.enum(["negative", "positive"]),
class: z.string().trim().min(1),
reason: z.string().trim().min(1).optional(),
/** Which eval store the case runs against; the public fixture unless named. */
fixture: z.literal("ranking").optional(),
relevant: z.array(z.object({
project: z.string().trim().min(1),
fid: z.string().regex(/^[a-f0-9]{8}$/),
match: z.string().trim().min(1),
}).strict()),
tier: z.enum(RECALL_TIERS).nullable(),
}).strict().superRefine((value, ctx) => {
if (value.kind === "positive" && (!value.relevant.length || value.tier === null)) {
ctx.addIssue({ code: "custom", message: "Positive cases need relevant findings and a tier" });
}
if (value.kind === "negative" && (value.relevant.length || value.tier !== null || !RECALL_NEGATIVE_CLASSES.some(c => c === value.class))) {
ctx.addIssue({ code: "custom", message: "Negative cases need a known negative class, no relevant findings and a null tier" });
}
});