{"record":{"id":"389dc6cb36a7a2a1","repo":"JuliusBrussee/caveman","slug":"eval-evidence-file-exceeds-4-mib-batch-limit","errorCode":null,"errorMessage":"eval evidence file exceeds 4 MiB batch limit","messagePattern":"eval evidence file exceeds 4 MiB batch limit","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":17601,"sourceCode":"  };\n  const fieldMap = flagFrom(argv, \"--field-map\", \"\");\n  if (fieldMap) headers[\"x-cave-field-map\"] = fieldMap;\n  const response = await fetch(`${cfg.baseURL}/api/v1/imports?format=${encodeURIComponent(format)}`, {\n    method: \"POST\",\n    headers,\n    body: data\n  });\n  print(await response.json());\n}\n\n// auditEvalImport turns newline-delimited, source-neutral eval records into one\n// bounded batch. Server stamps tenant scope, observed basis, and external-only\n// authority; CI cannot promote its own results into rollout authority.\nasync function auditEvalImport(argv: string[]) {\n  const file = positionalAfterOptions(argv.slice(1), new Set([\"--project\"]));\n  if (!file) throw new Error(`usage: ${invokedCommand(\"audit\")} eval-import <evidence.jsonl> [--project <uuid>] [--dry-run]`);\n  const data = await readFile(file);\n  if (data.byteLength > 4 * 1024 * 1024) throw new Error(\"eval evidence file exceeds 4 MiB batch limit\");\n\n  const items: Record<string, unknown>[] = [];\n  for (const [index, rawLine] of data.toString(\"utf8\").split(/\\r?\\n/).entries()) {\n    const line = rawLine.trim();\n    if (!line) continue;\n    let parsed: unknown;\n    try {\n      parsed = JSON.parse(line);\n    } catch {\n      throw new Error(`eval evidence line ${index + 1} is not valid JSON`);\n    }\n    if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n      throw new Error(`eval evidence line ${index + 1} must be a JSON object`);\n    }\n    items.push(parsed as Record<string, unknown>);\n    if (items.length > 1000) throw new Error(\"eval evidence batch exceeds 1000 records\");\n  }\n  if (items.length === 0) throw new Error(\"eval evidence file contains no records\");","sourceCodeStart":17583,"sourceCodeEnd":17619,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/index.ts#L17583-L17619","documentation":"Eval evidence is imported as one bounded batch, and the CLI enforces a hard 4 MiB ceiling on the evidence file (read fully into memory before upload). Files larger than 4,194,304 bytes are rejected before any parsing or network call.","triggerScenarios":"Running `caveman audit eval-import <file>` where the file's byte length exceeds 4 MiB, throwing immediately after `readFile`.","commonSituations":"Accumulating months of eval records in one .jsonl file; exporting raw full-payload eval traces instead of summarized records; a CI job concatenating many evidence files into one.","solutions":["Split the evidence file into chunks under 4 MiB and import each chunk as a separate batch.","Trim or summarize records before import (e.g. drop verbose payloads) to reduce size.","Compress/rotate older evidence into separate imports rather than one giant file."],"exampleFix":"// before (shell)\ncaveman audit eval-import ./all-evidence.jsonl  # 12 MiB -> exceeds 4 MiB batch limit\n// after (shell)\nsplit -b 3m all-evidence.jsonl chunk_\nfor f in chunk_*; do caveman audit eval-import \"$f\" --project 1234-abcd; done","handlingStrategy":"validation","validationCode":"// shell\nif [ \"$(stat -c%s evidence.jsonl)\" -gt 4194304 ]; then\n  echo \"file exceeds 4 MiB; split before import\"; exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check file size before every eval-import.","Keep per-run exports small by summarizing records.","Split large history files into <4 MiB chunks proactively."],"tags":["cli","audit","eval","file-size","limits"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}