{"record":{"id":"d96d0935d2bf39bd","repo":"Hmbown/CodeWhale","slug":"codewhale-terminal-receipt-omitted-a-valid-field","errorCode":null,"errorMessage":"Codewhale terminal receipt omitted a valid {field}","messagePattern":"Codewhale terminal receipt omitted a valid (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"integrations/verifiers-codewhale/codewhale_harness/harness.py","lineNumber":389,"sourceCode":"        if event_type == \"metadata\":\n            if terminal is not None:\n                raise RuntimeError(\"Codewhale emitted more than one terminal metadata receipt\")\n            meta = event.get(\"meta\")\n            if not isinstance(meta, dict) or meta.get(\"receipt_kind\") != \"terminal\":\n                raise RuntimeError(\"Codewhale metadata event was not a terminal receipt\")\n            terminal = _bounded_terminal(meta)\n\n    if terminal is None:\n        raise RuntimeError(\"Codewhale stream-json omitted terminal metadata\")\n    if counts[\"done\"] != 1 or not ordered_types or ordered_types[-1] != \"done\":\n        raise RuntimeError(\"Codewhale stream-json did not end with exactly one done event\")\n    if ordered_types[-2:-1] != [\"metadata\"]:\n        raise RuntimeError(\"Codewhale terminal metadata did not immediately precede done\")\n    for field in [\"binary_sha256\", \"prompt_sha256\"]:\n        if not isinstance(terminal.get(field), str) or not _SHA256.fullmatch(\n            terminal[field]\n        ):\n            raise RuntimeError(f\"Codewhale terminal receipt omitted a valid {field}\")\n    return {\n        \"schema\": STREAM_SCHEMA,\n        \"schema_version\": STREAM_SCHEMA_VERSION,\n        \"events\": dict(sorted(counts.items())),\n        \"terminal\": terminal,\n    }\n","sourceCodeStart":371,"sourceCodeEnd":396,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/integrations/verifiers-codewhale/codewhale_harness/harness.py#L371-L396","documentation":"The terminal receipt must contain binary_sha256 and prompt_sha256 as strings matching the strict form sha256:<64 lowercase hex> (the _SHA256 pattern). This error names the offending field when it is missing, not a string, or malformed — the hashes are how the harness proves which binary and prompt produced the rollout.","triggerScenarios":"The receipt omits one of the two hash fields; the value is a raw 64-hex digest without the 'sha256:' prefix; uppercase hex; a 'sha512:...' value; or a placeholder like 'unknown' left in a stub facade.","commonSituations":"Custom binary_path facades that skip computing hashes for speed; binaries that hash with a different algorithm or encoding; receipts copied from older versions where the fields were optional; test fixtures with dummy hash strings.","solutions":["Print the terminal receipt from captured stdout and check both fields against the pattern ^sha256:[0-9a-f]{64}$.","In the facade, compute hashlib.sha256(...).hexdigest() over the binary bytes and the prompt, then store f\"sha256:{hexdigest}\".","Remove placeholder values like 'n/a' — the regex rejects anything but lowercase hex.","If the algorithm legitimately changed, update _SHA256 and the harness contract together."],"exampleFix":"# before\nmeta['binary_sha256'] = hashlib.sha256(data).hexdigest()   # missing prefix\nmeta['prompt_sha256'] = 'unknown'\n\n# after\nmeta['binary_sha256'] = 'sha256:' + hashlib.sha256(data).hexdigest()\nmeta['prompt_sha256'] = 'sha256:' + hashlib.sha256(prompt_bytes).hexdigest()","handlingStrategy":"validation","validationCode":"import re\n\nSHA256_RE = re.compile(r\"^sha256:[0-9a-f]{64}$\")\n\ndef receipt_hashes_valid(terminal: dict) -> bool:\n    return all(\n        isinstance(terminal.get(f), str) and SHA256_RE.fullmatch(terminal[f])\n        for f in (\"binary_sha256\", \"prompt_sha256\")\n    )","typeGuard":"def is_sha256_prefixed_digest(value: object) -> bool:\n    return isinstance(value, str) and bool(SHA256_RE.fullmatch(value))","tryCatchPattern":null,"preventionTips":["Always store hashes as 'sha256:' + hexdigest() with lowercase hex.","Never ship placeholder values ('unknown', 'n/a') in the two hash fields.","Assert receipt_hashes_valid() in facade tests before integrating with the harness."],"tags":["hashing","sha256","validation","codewhale-harness","metadata"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}