{"record":{"id":"0ddb1776e80eb736","repo":"Hmbown/CodeWhale","slug":"codewhale-terminal-receipt-exceeded-its-total-bound","errorCode":null,"errorMessage":"Codewhale terminal receipt exceeded its total bound","messagePattern":"Codewhale terminal receipt exceeded its total bound","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"integrations/verifiers-codewhale/codewhale_harness/harness.py","lineNumber":272,"sourceCode":"\ndef _bounded_terminal(meta: dict[str, Any]) -> dict[str, Any]:\n    terminal: dict[str, Any] = {}\n    for key in _TERMINAL_FIELDS:\n        if key not in meta or meta[key] is None:\n            continue\n        value = meta[key]\n        if isinstance(value, str):\n            if len(value) > MAX_TERMINAL_STRING_CHARS:\n                raise RuntimeError(\"Codewhale terminal receipt exceeded its string bound\")\n        elif isinstance(value, int) and not isinstance(value, bool):\n            if value < 0 or value > 2**63 - 1:\n                raise RuntimeError(\"Codewhale terminal receipt contained an invalid count\")\n        else:\n            raise RuntimeError(\"Codewhale terminal receipt contained a non-scalar field\")\n        terminal[key] = value\n    encoded = json.dumps(terminal, sort_keys=True, separators=(\",\", \":\")).encode()\n    if len(encoded) > MAX_TERMINAL_RECEIPT_BYTES:\n        raise RuntimeError(\"Codewhale terminal receipt exceeded its total bound\")\n    return terminal\n\n\ndef _install_script(version: str) -> str:\n    version_q = shlex.quote(version)\n    install_q = shlex.quote(INSTALL_DIR)\n    release_q = shlex.quote(RELEASE_ROOT)\n    return f\"\"\"\nset -eu\nversion={version_q}\ninstall_dir={install_q}\nrelease_root={release_q}\nif [ \"$(uname -s)\" != Linux ]; then\n    echo \"automatic Codewhale installation supports Linux runtimes; set binary_path\" >&2\n    exit 1\nfi\ncase \"$(uname -m)\" in\n    x86_64|amd64) platform=linux-x64 ;;","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/integrations/verifiers-codewhale/codewhale_harness/harness.py#L254-L290","documentation":"After per-field checks, the canonicalized terminal receipt is JSON-encoded and must be at most MAX_TERMINAL_RECEIPT_BYTES = 8192 bytes. This RuntimeError means the receipt as a whole exceeded that budget even though individual fields passed. The harness throws it because it stores the receipt in trace.info and refuses unbounded metadata.","triggerScenarios":"_bounded_terminal finished collecting all _TERMINAL_FIELDS from the metadata event but json.dumps(terminal, sort_keys=True, separators=(',',':')) serialized to more than 8192 bytes.","commonSituations":"A wrapped/patched binary stuffing many or very long (but individually <=512 char) fields; a future schema adding fields beyond the byte budget; debugging builds emitting verbose identifiers across all sha256/config fields.","solutions":["Dump the encoded receipt length per field to find what dominates the 8KB budget","Use the official pinned binary rather than a wrapper that adds fields","If the schema legitimately grew, raise MAX_TERMINAL_RECEIPT_BYTES in the harness deliberately","Trim receipt content at the source (shorter identifiers, fewer optional fields set)","Verify STREAM_SCHEMA_VERSION handling matches the emitting binary's schema"],"exampleFix":"# before\nMAX_TERMINAL_RECEIPT_BYTES = 8_192\n# after (only if the receipt schema legitimately grew)\nMAX_TERMINAL_RECEIPT_BYTES = 16_384","handlingStrategy":"validation","validationCode":"import json\nencoded = json.dumps(meta, sort_keys=True, separators=(\",\", \":\")).encode()\nassert len(encoded) <= 8192, f\"receipt too large: {len(encoded)} bytes\"","typeGuard":null,"tryCatchPattern":"try:\n    receipt = await harness.launch(ctx, trace, runtime, endpoint, secret, mcp_urls)\nexcept RuntimeError as e:\n    if \"exceeded its total bound\" in str(e):\n        logger.error(\"terminal receipt >8KB; audit emitter fields\")\n    raise","preventionTips":["Budget the receipt: sum of field sizes must stay under 8KB","Avoid adding unbounded fields (paths, prompts, lists) to the terminal receipt","Review any schema addition against MAX_TERMINAL_RECEIPT_BYTES","Strip optional fields (set to null) when they carry no verification value"],"tags":["validation","limits","serialization"],"backgroundTag":"payload-too-large","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}