INNER CODE UNIT · TypeScript
ensurePatchSourceWithinBudget
totec448-spec/chat-on-steroids · src/main/codex/apply-patch/index.ts:48
async function ensurePatchSourceWithinBudget(path: string, allowMissing = false): Promise<void> {
try {
const metadata = await getMetadata(path);
if (metadata.isFile && metadata.size > MAX_PATCH_SOURCE_BYTES) {
throw invalidInput(`file is too large to patch safely: limit is ${MAX_PATCH_SOURCE_BYTES} bytes`);
}
} catch (error) {
if (allowMissing && errorCode(error) === 'ENOENT') return;
throw error;
}
}
/**
* Verification-time file target check.
*
* The runtime is intentionally sequential and can therefore leave earlier hunks committed when a
* later filesystem operation fails. The model-facing adapter avoids that ordinary class of partial
* patch by running `verifyApplyPatchArgs` first, so destinations have to be validated here too,