1024 (2026-10-05): error batches with stacks legitimately exceed 64KB, causing endless 413s define('CLUSTER_SIMILARITY_THRESHOLD', 0.35); define('ERRORS_FILE', DEBUG_DATA_DIR . '/errors.json'); define('SESSIONS_FILE', DEBUG_DATA_DIR . '/sessions.json'); define('CLUSTERS_FILE', DEBUG_DATA_DIR . '/clusters.json'); if (!is_dir(DEBUG_DATA_DIR)) { mkdir(DEBUG_DATA_DIR, 0755, true); } function load_json($path) { if (!file_exists($path)) return []; $data = json_decode(file_get_contents($path), true); return is_array($data) ? $data : []; } function save_json($path, $data) { $encoded = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); $fp = fopen($path, 'c'); if ($fp && flock($fp, LOCK_EX)) { ftruncate($fp, 0); fwrite($fp, $encoded); fflush($fp); flock($fp, LOCK_UN); fclose($fp); } else { // Fallback: write without lock file_put_contents($path, $encoded); } @chmod($path, 0664); } function json_response($data, $code = 200) { http_response_code($code); echo json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); exit; } function error_response($msg, $code = 400) { json_response(['success' => false, 'error' => $msg], $code); }