perf(web): add idempotent batch verification fast paths
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

This commit is contained in:
mes123456
2026-09-03 20:29:51 +08:00
parent b849eb657b
commit b28b365f3a
19 changed files with 652 additions and 71 deletions

View File

@@ -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)) {