mirror of
https://github.com/morluto/rea.git
synced 2026-11-22 14:35:45 +00:00
* test(mcp): check advertised schemas against a portable dialect in every profile * fix(mcp): re-emit advertised patterns in a portable regex grammar * fix(mcp): present discover_tools input through the selected profile The hot-cold catalog registered discover_tools directly with the SDK, so the default compact input profile still advertised its canonical schema, including page-size defaults clients apply on their own (#5322). Route every listed input schema, transport discovery included, through one server-owned presentation, and pass the selected presentation to the deferred server, which serves recorded tool schemas but not discovery. * fix(mcp): validate advertised dialect by selected profile * fix(mcp): preserve schema widening through references * fix(mcp): refuse zero-padded repeat bounds and record host-specific path patterns * fix(mcp): keep references valid when presentation widens their targets * fix(mcp): relax references into negations and conditionals presentation may remove * fix(mcp): keep astral literals and dynamic references widening in every mode * fix(mcp): omit astral literals and relax untracked references when presentation widens * fix(mcp): read reference pointers by schema position, not segment spelling * fix(mcp): protect references into collapsing boolean unions and keep referencing branches out of the collapse * fix(mcp): omit patterns whose classes name astral characters * fix(mcp): decide union collapse and pointer protection from canonical branches * docs(mcp): document non-u astral matching and pin BMP agreement across V8 modes * test(mcp): expect the advertised base64 schema to omit the unbounded pad-bit probe * fix(mcp): protect references into unevaluated keywords lost evaluation removes * fix(mcp): emit stack-safe classes with non-ASCII members and protect draft-07 reference siblings * fix(mcp): protect references into literal siblings of relaxed draft-07 references * fix(mcp): keep the Evidence union on described borrowed inputs (#10597) * fix(mcp): keep the Evidence union on described borrowed inputs borrowEvidenceInput installed its advertised projection on one schema instance. A call site's .describe() rebuilds the schema from its definition, so match_native_functions advertised left and right as unconstrained values in every input profile. Install the projection in the borrowed parser's constructor so derived schemas keep it, for both borrowed inputs and borrowed arrays. * test(mcp): select the borrowed Evidence contract from its family * docs(mcp): admit baseline growth only for restored contract declarations
82 lines
3.3 KiB
TypeScript
82 lines
3.3 KiB
TypeScript
import { z } from "zod";
|
|
import { prefixedDigestSchema } from "./digests.js";
|
|
import { absoluteLocalPathStringSchema } from "./localPath.js";
|
|
import {
|
|
declareBorrowedEvidenceInput,
|
|
declareEvidenceInput,
|
|
declareEvidenceReferenceAlternative,
|
|
} from "./evidenceInputContract.js";
|
|
|
|
/** Exact reference to Evidence already retained by the current session. */
|
|
export const retainedEvidenceReferenceSchema = z.strictObject({
|
|
kind: z.literal("retained-evidence"),
|
|
evidence_id: prefixedDigestSchema("ev"),
|
|
});
|
|
|
|
/** One completed Evidence record read from a local Evidence file or bundle. */
|
|
export const evidenceFileReferenceSchema = z.strictObject({
|
|
kind: z.literal("evidence-file"),
|
|
path: absoluteLocalPathStringSchema.describe(
|
|
"Absolute local path of one completed Evidence JSON file, or of an Evidence bundle written by --evidence_output or export_evidence_bundle. REA reads and authenticates it, then uses it like retained Evidence, so large records are not charged as inline input.",
|
|
),
|
|
evidence_id: prefixedDigestSchema("ev")
|
|
.exactOptional()
|
|
.describe(
|
|
"The record to select when the file is an Evidence bundle, such as a summary's normalized_result.parent_evidence_id. A bundle holding exactly one record needs no selection.",
|
|
),
|
|
});
|
|
|
|
import { evidenceSchema } from "./evidence.js";
|
|
|
|
/** Portable observation or exact retained identity; semantic authentication follows admission. */
|
|
export const evidenceInputSchema = declareEvidenceInput(
|
|
z.union([evidenceSchema, retainedEvidenceReferenceSchema]),
|
|
);
|
|
export type EvidenceInput = z.output<typeof evidenceInputSchema>;
|
|
|
|
/**
|
|
* Advertise `declaration` for a borrowed parser. Zod rebuilds a derived schema,
|
|
* such as one returned by `.describe()`, from its definition through the
|
|
* instance constructor, so the projection belongs to that constructor rather
|
|
* than to one instance.
|
|
*/
|
|
const advertisedAs = <Schema extends z.ZodType>(
|
|
schema: Schema,
|
|
declaration: z.ZodType,
|
|
): Schema => {
|
|
const base = schema._zod.constr as unknown as {
|
|
init: (instance: Schema, definition: Schema["_zod"]["def"]) => void;
|
|
};
|
|
const Borrowed = z.core.$constructor<Schema>(
|
|
`BorrowedEvidence${schema._zod.def.type}`,
|
|
(instance, definition) => {
|
|
base.init(instance, definition);
|
|
instance._zod.processJSONSchema = (context, json, params) =>
|
|
declaration._zod.processJSONSchema!(context, json, params);
|
|
},
|
|
);
|
|
return new Borrowed(schema._zod.def);
|
|
};
|
|
|
|
/** Borrow a selected inline record until its resource and format owner admits it. */
|
|
export const borrowEvidenceInput = () =>
|
|
declareBorrowedEvidenceInput(
|
|
advertisedAs(z.unknown().nonoptional(), evidenceInputSchema),
|
|
evidenceInputSchema,
|
|
);
|
|
|
|
/** Borrow array width too; its service must admit capacity before resolution. */
|
|
export const borrowEvidenceArray = () => {
|
|
const declaration = z.array(evidenceInputSchema);
|
|
return declareBorrowedEvidenceInput(
|
|
advertisedAs(z.custom<unknown[]>(Array.isArray), declaration),
|
|
declaration,
|
|
);
|
|
};
|
|
|
|
/** Evidence input, or one record read from a local Evidence file or bundle. */
|
|
export const evidenceSourceInputSchema = declareEvidenceReferenceAlternative(
|
|
z.union([...evidenceInputSchema.options, evidenceFileReferenceSchema]),
|
|
);
|
|
export type EvidenceSourceInput = z.output<typeof evidenceSourceInputSchema>;
|