Hmbown/CodeWhale · error · RuntimeContractError

receipt metric `skill_discovery.prompts_byte_identical`…

Error message

receipt metric `skill_discovery.prompts_byte_identical` must be true

What it means

A valid receipt must assert that the skill-discovery prompts were byte-identical across the measured runs; otherwise the budget measurement is not reproducible. validate_receipt requires this field to be literally True (not truthy).

Solutions

  1. Fix the nondeterminism so both runs produce byte-identical prompts, then regenerate the receipt
  2. Set the field to literal true only when the runs genuinely produced identical prompts
  3. Regenerate the receipt with run_measurement instead of flipping the flag by hand

Example fix

// before
"skill_discovery": {"prompts_byte_identical": false}
// after
"skill_discovery": {"prompts_byte_identical": true}
Defensive patterns

Strategy: validation

Validate before calling

sd = doc.get("skill_discovery", {})
assert isinstance(sd, dict) and sd.get("prompts_byte_identical") is True, \
    "skill-discovery prompts were not byte-identical; re-measure"

Type guard

def is_true(v) -> bool:
    return v is True

Try / catch

try:
    budget = budget_from_receipt(receipt)
except RuntimeContractError as e:
    if "prompts_byte_identical" in str(e):
        raise SystemExit("nondeterministic prompts: fix prompt source before re-measuring")
    raise

Prevention

When it happens

Trigger: validate_receipt (via compare, budget_from_receipt, or run_measurement) sees skill_discovery.prompts_byte_identical set to false, missing, or a non-boolean truthy value.

Common situations: Prompt text changed between the compared runs (tool description edits, locale/env differences); a generator writing 1/0 instead of true; an older receipt predating this assertion.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/ed5a874b40512187. Report an issue: GitHub.

Appendix: source

Thrown at scripts/check-runtime-contract-budget.py:264

    for stage, _label in REPRESENTATIVE_STAGES:
        path = ("representative_context", "stages", stage, "identity_sha256")
        digest = required_value(document, path, kind)
        if not isinstance(digest, str) or re.fullmatch(r"[0-9a-f]{64}", digest) is None:
            raise RuntimeContractError(
                f"{kind} field `{'.'.join(path)}` must be a lowercase SHA-256 digest"
            )


def validate_receipt(receipt: dict[str, Any]) -> None:
    validate_document(receipt, RECEIPT_KIND, "receipt")
    skill_discovery = receipt.get("skill_discovery")
    identical = (
        skill_discovery.get("prompts_byte_identical")
        if isinstance(skill_discovery, dict)
        else None
    )
    if identical is not True:
        raise RuntimeContractError(
            "receipt metric `skill_discovery.prompts_byte_identical` must be true"
        )
    representative = receipt.get("representative_context")
    fixture_id = (
        representative.get("fixture_id")
        if isinstance(representative, dict)
        else None
    )
    if fixture_id != REPRESENTATIVE_FIXTURE_ID:
        raise RuntimeContractError(
            "receipt metric `representative_context.fixture_id` must be "
            f"`{REPRESENTATIVE_FIXTURE_ID}`, got {fixture_id!r}"
        )
    representative_identical = representative.get("prompts_byte_identical")
    if representative_identical is not True:
        raise RuntimeContractError(
            "receipt metric `representative_context.prompts_byte_identical` must be true"
        )

View on GitHub (pinned to 433685b202)