fix(process)!: require current captures and preserve cleanup failures
Remove v3 capture conversion and require explicit executable identity and event journals. Preserve cancellation, execution diagnostics, snapshots, and cleanup outcomes from preparation through CLI delivery.
This commit is contained in:
@@ -2,7 +2,6 @@ import {
|
||||
processCaptureSchema,
|
||||
type UnverifiedProcessCapture,
|
||||
} from "./processCapture.js";
|
||||
import { z } from "zod";
|
||||
|
||||
declare class ProcessCaptureProof {
|
||||
private readonly verified: never;
|
||||
@@ -23,47 +22,9 @@ const attachProof = (capture: UnverifiedProcessCapture): ProcessCapture => {
|
||||
throw new TypeError("Process Capture proof ownership failed");
|
||||
};
|
||||
|
||||
const recordSchema = z.record(z.string(), z.unknown());
|
||||
const LEGACY_EXECUTABLE_IDENTITY_REASON =
|
||||
"Legacy v3 capture did not distinguish selected and launch executable digests";
|
||||
|
||||
const migrateLegacyV3Capture = (input: unknown): unknown => {
|
||||
const capture = recordSchema.safeParse(input);
|
||||
if (!capture.success) return input;
|
||||
const manifest = recordSchema.safeParse(capture.data.manifest);
|
||||
if (!manifest.success) return input;
|
||||
if (
|
||||
manifest.data.provider_version !== "3" ||
|
||||
"selected_executable_sha256" in manifest.data ||
|
||||
"executable_identity" in manifest.data ||
|
||||
"legacy_executable_sha256" in manifest.data
|
||||
)
|
||||
return input;
|
||||
|
||||
const { executable_sha256 } = manifest.data;
|
||||
if (
|
||||
typeof executable_sha256 !== "string" ||
|
||||
!/^[a-f0-9]{64}$/u.test(executable_sha256)
|
||||
)
|
||||
return input;
|
||||
return {
|
||||
...capture.data,
|
||||
manifest: {
|
||||
...manifest.data,
|
||||
selected_executable_sha256: null,
|
||||
executable_sha256: null,
|
||||
executable_identity: {
|
||||
state: "unknown",
|
||||
reason: LEGACY_EXECUTABLE_IDENTITY_REASON,
|
||||
},
|
||||
legacy_executable_sha256: executable_sha256,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
/** Parse unknown input and reject invalid commitments or semantics. */
|
||||
export const parseProcessCapture = (input: unknown): ProcessCapture => {
|
||||
const parsed = processCaptureSchema.safeParse(migrateLegacyV3Capture(input));
|
||||
const parsed = processCaptureSchema.safeParse(input);
|
||||
if (parsed.success) return attachProof(parsed.data);
|
||||
const issues = parsed.error.issues.flatMap((issue) =>
|
||||
issue.code === "custom"
|
||||
|
||||
Reference in New Issue
Block a user