Files
reverse-engineering-anything/src/contracts/errorSchemas.ts
T
morluto 8688eb0195 perf(cli/mcp): eliminate eager JSON schema work, double projection, and O(N^2) error compaction (#13466)
* perf(cli/mcp): eliminate eager JSON schema work, double projection, and O(N^2) error compaction (#13464)

* test(mcp): cover reuse of the registration input schema projection
2026-11-22 16:42:37 +00:00

31 lines
896 B
TypeScript

import { z } from "zod";
import { analysisErrorProjectionSchema } from "../domain/analysisErrorProjectionSchema.js";
/** CLI label and input diagnostics surrounding the strict canonical error projection. */
export const analysisCliErrorEnvelopeSchema = z
.object({
error: z.string().min(1),
input_path: z.string().optional(),
input_reason: z
.enum(["invalid-json", "read-failed", "too-large"])
.optional(),
})
.passthrough()
.superRefine((value, context) => {
const {
error: _label,
input_path: _inputPath,
input_reason: _inputReason,
...projection
} = value;
const parsed = analysisErrorProjectionSchema.safeParse(projection);
if (!parsed.success) {
context.addIssue({
code: "custom",
message:
"CLI error envelope must contain a canonical analysis error projection",
});
}
});