perf(web): add idempotent batch verification fast paths
This commit is contained in:
@@ -64,6 +64,25 @@ export function validateContextBundle(bundle, { current = true } = {}) {
|
||||
if (context.commands.length > GOVERNANCE_LIMITS.maxTaskCommands) {
|
||||
add(violations, "TASK_COMMANDS_TOO_WIDE", `count=${context.commands.length}`);
|
||||
}
|
||||
if (!context.inputMetadata || typeof context.inputMetadata !== "object") {
|
||||
add(violations, "INPUT_METADATA_MISSING", context.task);
|
||||
} else {
|
||||
const requiredMetadata = [
|
||||
relative(files.queuePath),
|
||||
relative(files.taskPath),
|
||||
relative(files.parentManifestPath),
|
||||
...(fs.existsSync(files.parentStatusPath) ? [relative(files.parentStatusPath)] : []),
|
||||
...context.inputPaths,
|
||||
];
|
||||
for (const file of [...new Set(requiredMetadata)]) {
|
||||
const metadata = context.inputMetadata[file];
|
||||
if (!metadata || typeof metadata !== "object" || metadata.exists !== true
|
||||
|| !Number.isSafeInteger(metadata.bytes) || typeof metadata.mtime_ns !== "string"
|
||||
|| !/^[a-f0-9]{64}$/u.test(metadata.sha256 ?? "")) {
|
||||
add(violations, "INPUT_METADATA_INVALID", `${context.task}:${file}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const selection = context.inputSelection;
|
||||
if (!selection || selection.schemaVersion !== 1 || !Array.isArray(selection.selected) || !Array.isArray(selection.excluded)) {
|
||||
|
||||
Reference in New Issue
Block a user