{"record":{"id":"d2ae49f6f08d4cfa","repo":"Hmbown/CodeWhale","slug":"budget-metric-representative-context-fixture-id-must-be","errorCode":null,"errorMessage":"budget metric `representative_context.fixture_id` must be `{REPRESENTATIVE_FIXTURE_ID}`, got {fixture_id!r}","messagePattern":"budget metric `representative_context\\.fixture_id` must be `(.+?)`, got (.+?)","errorType":"exception","errorClass":"RuntimeContractError","httpStatus":null,"severity":"error","filePath":"scripts/check-runtime-contract-budget.py","lineNumber":295,"sourceCode":"        )\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        )\n    validate_identity_structure(receipt, \"receipt\")\n\n\ndef validate_budget(budget: dict[str, Any]) -> None:\n    validate_document(budget, BUDGET_KIND, \"budget\")\n    representative = budget.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            \"budget metric `representative_context.fixture_id` must be \"\n            f\"`{REPRESENTATIVE_FIXTURE_ID}`, got {fixture_id!r}\"\n        )\n    validate_identity_structure(budget, \"budget\")\n\n\ndef metric_value(document: dict[str, Any], path: MetricPath, kind: str) -> int:\n    value = required_value(document, path, kind)\n    dotted = \".\".join(path)\n    if isinstance(value, bool) or not isinstance(value, int) or value < 0:\n        raise RuntimeContractError(\n            f\"{kind} metric `{dotted}` must be a non-negative integer\"\n        )\n    return value\n\n\ndef compare(\n    receipt: dict[str, Any], budget: dict[str, Any]","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-runtime-contract-budget.py#L277-L313","documentation":"check-runtime-contract-budget.py enforces that the measured receipt's representative context is tied to a single pinned fixture (`representative-v1`) so byte/token budgets stay comparable across runs. If `representative_context.fixture_id` in the budget document is missing, has the wrong type, or names a different fixture, validate_budget raises RuntimeContractError. This keeps the stored budget from silently describing a different measurement corpus.","triggerScenarios":"Calling validate_budget (directly or via compare) on a budget JSON whose `representative_context.fixture_id` is absent, not a dict parent, or any value other than \"representative-v1\"; also hand-editing scripts/runtime-contract-budget.json and renaming the fixture.","commonSituations":"A developer regenerates or edits the budget file by hand; a new fixture version was introduced elsewhere but the budget was updated without bumping fixture_id (or vice versa); an older budget file predates the fixture_id field.","solutions":["Set `representative_context.fixture_id` to exactly \"representative-v1\" in the budget JSON (or run with `--update` to regenerate the budget from a current receipt).","Check `scripts/runtime-contract-budget.json` for a stale or typo'd fixture id and correct it.","If the fixture itself legitimately changed, update REPRESENTATIVE_FIXTURE_ID in the script and regenerate the budget in the same change.","Ensure the parent `representative_context` key is a JSON object, not a list or scalar."],"exampleFix":"// before (budget JSON)\n\"representative_context\": { \"fixture_id\": \"representative-v2\", ... }\n// after\n\"representative_context\": { \"fixture_id\": \"representative-v1\", ... }","handlingStrategy":"validation","validationCode":"import json\nbudget = json.load(open(\"scripts/runtime-contract-budget.json\"))\nassert budget.get(\"representative_context\", {}).get(\"fixture_id\") == \"representative-v1\", \"stale or wrong fixture_id in budget\"","typeGuard":"def has_valid_fixture(budget: dict) -> bool:\n    rc = budget.get(\"representative_context\")\n    return isinstance(rc, dict) and rc.get(\"fixture_id\") == \"representative-v1\"","tryCatchPattern":"try:\n    subprocess.run([\"python3\", \"scripts/check-runtime-contract-budget.py\", \"--receipt\", receipt], check=True)\nexcept subprocess.CalledProcessError:\n    # fixture id drifted: regenerate budget via --update after review\n    ...","preventionTips":["Never hand-edit the budget JSON; regenerate it with --update.","Bump fixture_id and REPRESENTATIVE_FIXTURE_ID together in one commit.","Run the budget checker in CI so drift is caught before merge."],"tags":["budget","validation","contract-check","fixture-id"],"backgroundTag":"invalid-config-value","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"}