export function unwrapOcrCodeFence(raw: string, source: string): string { const lines = raw.split('\n') if (lines.length < 3 || source.includes('```')) return raw if (!/^```[A-Za-z0-9_+.-]*$/u.test(lines[0].trim()) || lines[lines.length - 1].trim() !== '```') return raw const body = lines.slice(1, -1).join('\n') return body.includes('```') ? raw : body } export function isPrecisionOutputWithinBounds(raw: string, source: string): boolean { return Array.from(raw).length <= Math.max(4000, Array.from(source).length * 8) }