refactor(process): separate capture implementation from analyst workflows (#988)

* refactor(process): separate capture implementation from analyst workflows

* fix(ci): generate source catalog before shard tests
This commit is contained in:
Ysopwnable
2026-10-08 00:46:21 +08:00
committed by GitHub
parent 5b172b1042
commit 6aa9afb549
98 changed files with 214 additions and 141 deletions
@@ -0,0 +1,39 @@
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. */
export const parseProcessCapture = (input: unknown): ProcessCapture => {
const parsed = processCaptureSchema.safeParse(input);
if (parsed.success) return attachProof(parsed.data);
const issues = parsed.error.issues.flatMap((issue) =>
issue.code === "custom"
? [{ path: issue.path.join("."), message: issue.message }]
: [],
);
if (issues.length > 0)
throw new TypeError(
`Invalid process capture: ${issues.map(({ path, message }) => `${path}: ${message}`).join("; ")}`,
);
throw parsed.error;
};