{"record":{"id":"ed5a874b40512187","repo":"Hmbown/CodeWhale","slug":"receipt-metric-skill-discovery-prompts-byte-ident","errorCode":null,"errorMessage":"receipt metric `skill_discovery.prompts_byte_identical` must be true","messagePattern":"receipt metric `skill_discovery\\.prompts_byte_identical` must be true","errorType":"exception","errorClass":"RuntimeContractError","httpStatus":null,"severity":"error","filePath":"scripts/check-runtime-contract-budget.py","lineNumber":257,"sourceCode":"    for stage, _label in REPRESENTATIVE_STAGES:\n        path = (\"representative_context\", \"stages\", stage, \"identity_sha256\")\n        digest = required_value(document, path, kind)\n        if not isinstance(digest, str) or re.fullmatch(r\"[0-9a-f]{64}\", digest) is None:\n            raise RuntimeContractError(\n                f\"{kind} field `{'.'.join(path)}` must be a lowercase SHA-256 digest\"\n            )\n\n\ndef validate_receipt(receipt: dict[str, Any]) -> None:\n    validate_document(receipt, RECEIPT_KIND, \"receipt\")\n    skill_discovery = receipt.get(\"skill_discovery\")\n    identical = (\n        skill_discovery.get(\"prompts_byte_identical\")\n        if isinstance(skill_discovery, dict)\n        else None\n    )\n    if identical is not True:\n        raise RuntimeContractError(\n            \"receipt metric `skill_discovery.prompts_byte_identical` must be true\"\n        )\n    representative = receipt.get(\"representative_context\")\n    fixture_id = (\n        representative.get(\"fixture_id\")\n        if isinstance(representative, dict)\n        else None\n    )\n    if fixture_id != REPRESENTATIVE_FIXTURE_ID:\n        raise RuntimeContractError(\n            \"receipt metric `representative_context.fixture_id` must be \"\n            f\"`{REPRESENTATIVE_FIXTURE_ID}`, got {fixture_id!r}\"\n        )\n    representative_identical = representative.get(\"prompts_byte_identical\")\n    if representative_identical is not True:\n        raise RuntimeContractError(\n            \"receipt metric `representative_context.prompts_byte_identical` must be true\"\n        )","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/scripts/check-runtime-contract-budget.py#L239-L275","documentation":"validate_receipt requires receipt skill_discovery.prompts_byte_identical to be exactly boolean True (the check is `is not True`, so 1, \"true\", or a missing field all fail). The measure harness sets this flag only when skill-discovery passes on unchanged turns produce byte-identical prompt fragments. False therefore means nondeterministic skill discovery, not a budget problem; budgets are never checked for this flag.","triggerScenarios":"A freshly measured receipt where the harness observed differing bytes between two skill-discovery passes; a hand-written receipt that omits skill_discovery or sets the flag to a truthy non-boolean; a measure script older than the field itself.","commonSituations":"Refactoring the skill-discovery cache (ordering, hashmap iteration, timestamps, env leakage) so unchanged turns no longer render identical fragments; testing the checker with a minimal hand-made receipt; version skew between the checker and scripts/measure-runtime-contract.py.","solutions":["Run scripts/measure-runtime-contract.py directly - if the flag comes out false, fix the nondeterminism in the Rust skill-discovery path (stable ordering, no clock/env data) instead of editing the receipt","If the receipt is a hand-authored test fixture, set the field to literal JSON true and re-check with --receipt","Update to a checker/measure pair from the same commit (both live in scripts/ of this repo)"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def has_identical_skill_prompts(receipt: dict) -> bool:\n    sd = receipt.get(\"skill_discovery\")\n    return isinstance(sd, dict) and sd.get(\"prompts_byte_identical\") is True","tryCatchPattern":null,"preventionTips":["Treat a false flag as a determinism bug to fix upstream, never as a field to overwrite","When hand-authoring test receipts, build them from a real measured receipt and mutate only the fields under test","Keep checker and measure-runtime-contract.py at the same commit so the field always exists"],"tags":["python","determinism","receipt","skill-discovery"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}