parseProcessCapture re-threw only the custom (semantic) schema issues as a TypeError whenever any existed, discarding structural issues found in the same parse. Throw the schema's ZodError instead so every issue is retained and describeValidationFailure reports the first issue with the remaining count. Reconstruction obligation candidates now use that same formatter instead of the raw error message. Fixes #5957 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
1013 B
TypeScript
31 lines
1013 B
TypeScript
import {
|
|
processCaptureSchema,
|
|
type UnverifiedProcessCapture,
|
|
} from "./processCapture.js";
|
|
|
|
declare class ProcessCaptureProof {
|
|
private readonly verified: never;
|
|
}
|
|
|
|
/** Semantically verified process capture value. */
|
|
export type ProcessCapture = UnverifiedProcessCapture & ProcessCaptureProof;
|
|
|
|
const verifiedCaptures = new WeakSet<UnverifiedProcessCapture>();
|
|
|
|
const isVerifiedCapture = (
|
|
capture: UnverifiedProcessCapture,
|
|
): capture is ProcessCapture => verifiedCaptures.has(capture);
|
|
|
|
const attachProof = (capture: UnverifiedProcessCapture): ProcessCapture => {
|
|
verifiedCaptures.add(capture);
|
|
if (isVerifiedCapture(capture)) return capture;
|
|
throw new TypeError("Process Capture proof ownership failed");
|
|
};
|
|
|
|
/**
|
|
* Parse unknown input and reject invalid commitments or semantics. Failures
|
|
* throw the schema's ZodError so structural and semantic issues stay together.
|
|
*/
|
|
export const parseProcessCapture = (input: unknown): ProcessCapture =>
|
|
attachProof(processCaptureSchema.parse(input));
|