Hmbown/CodeWhale · error · RuntimeContractError

receipt metric…

Error message

receipt metric `representative_context.prompts_byte_identical` must be true

What it means

Like the skill-discovery check (807), the representative-context prompts across the measured runs must be byte-identical for the budget to be trustworthy. validate_receipt requires representative_context.prompts_byte_identical to be literally True.

Solutions

  1. Diff the prompts from the two runs, remove the nondeterminism, and re-measure
  2. Regenerate the receipt via run_measurement once prompts are stable
  3. Set the flag to true only for genuinely byte-identical runs; never hand-edit it

Example fix

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

Strategy: validation

Validate before calling

rep = doc.get("representative_context", {})
assert isinstance(rep, dict) and rep.get("prompts_byte_identical") is True, \
    "representative-context prompts not byte-identical; re-measure"

Type guard

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

Try / catch

try:
    compare(receipt, budget)
except RuntimeContractError as e:
    if "representative_context.prompts_byte_identical" in str(e):
        raise SystemExit("context assembly is nondeterministic; stabilize and re-measure")
    raise

Prevention

When it happens

Trigger: validate_receipt finds representative_context.prompts_byte_identical absent, false, or a non-boolean truthy value while the fixture_id check (808) already passed.

Common situations: System prompt or context assembly changed between runs; unstable ordering in context fragments; a template receipt with the flag left false.

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/5aa7a16c4e2c9459. Report an issue: GitHub.

Appendix: source

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

    )
    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"
        )
    validate_identity_structure(receipt, "receipt")


def validate_budget(budget: dict[str, Any]) -> None:
    validate_document(budget, BUDGET_KIND, "budget")
    representative = budget.get("representative_context")
    fixture_id = (
        representative.get("fixture_id")
        if isinstance(representative, dict)
        else None
    )
    if fixture_id != REPRESENTATIVE_FIXTURE_ID:
        raise RuntimeContractError(
            "budget metric `representative_context.fixture_id` must be "
            f"`{REPRESENTATIVE_FIXTURE_ID}`, got {fixture_id!r}"
        )

View on GitHub (pinned to 433685b202)