{"record":{"id":"8171fed962295db4","repo":"Hmbown/CodeWhale","slug":"identity-changed-for-label-join-path-detail","errorCode":null,"errorMessage":"identity changed for {label} [`{'.'.join(path)}`]{detail}","messagePattern":"identity changed for (.+?) \\[`(.+?)`\\](.+?)","errorType":"exception","errorClass":"RuntimeContractError","httpStatus":null,"severity":"error","filePath":"scripts/check-runtime-contract-budget.py","lineNumber":329,"sourceCode":"\ndef compare(\n    receipt: dict[str, Any], budget: dict[str, Any]\n) -> tuple[list[MetricResult], list[MetricResult]]:\n    \"\"\"Return (increases, decreases) as path/label/current/ceiling tuples.\"\"\"\n    validate_receipt(receipt)\n    validate_budget(budget)\n    for path, label in IDENTITIES:\n        receipt_value = required_value(receipt, path, \"receipt\")\n        budget_value = required_value(budget, path, \"budget\")\n        if receipt_value != budget_value:\n            detail = \"\"\n            if isinstance(receipt_value, list) and isinstance(budget_value, list):\n                added = [str(item) for item in receipt_value if item not in budget_value]\n                removed = [\n                    str(item) for item in budget_value if item not in receipt_value\n                ]\n                detail = f\" (added={added} removed={removed})\"\n            raise RuntimeContractError(\n                f\"identity changed for {label} [`{'.'.join(path)}`]{detail}\"\n            )\n    increases: list[MetricResult] = []\n    decreases: list[MetricResult] = []\n    for path, label in METRICS:\n        current = metric_value(receipt, path, \"receipt\")\n        ceiling = metric_value(budget, path, \"budget\")\n        result = (\".\".join(path), label, current, ceiling)\n        if current > ceiling:\n            increases.append(result)\n        elif current < ceiling:\n            decreases.append(result)\n    return increases, decreases\n\n\ndef set_path_value(document: dict[str, Any], path: MetricPath, value: Any) -> None:\n    target = document\n    for part in path[:-1]:","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-runtime-contract-budget.py#L311-L347","documentation":"compare() diffs identity fields (paths of the receipt vs the stored budget that must be byte-identical, e.g. tool surface profile, fixture id, identity hashes). When any identity value differs it raises RuntimeContractError naming the label, the dotted path, and — for list-valued identities — which items were added/removed. Identity drift means the measurement no longer describes the same contract the budget was pinned to, so metric comparison would be meaningless.","triggerScenarios":"Running the checker (or calling compare from main) where a receipt identity list/string differs from the budget's — e.g. the tool surface profile changed, a stage was added/removed from REPRESENTATIVE_STAGES, or the budget was generated on a different configuration.","commonSituations":"A PR changed visible modes, tool surfaces, or representative stages without regenerating the budget; a developer merged a budget from another branch; measuring on a checkout with locally modified prompts/tool catalog.","solutions":["Read the added=/removed= detail and either revert the identity change or intentionally accept it by running with `--update` to re-pin the budget to the new identity.","Diff scripts/runtime-contract-budget.json against a freshly generated receipt to see exactly which identity field moved.","If the change is legitimate, regenerate the budget in the same commit as the identity change.","Ensure you are not comparing a receipt measured on a dirty checkout against a budget from clean CI state."],"exampleFix":"// before\nidentity changed for tool surface [`tool_surface_profile`] (added=['mcp'] removed=[])\n// after: rebuild budget to match, or drop the mcp surface\npython3 scripts/check-runtime-contract-budget.py --update","handlingStrategy":"validation","validationCode":"import json\nreceipt, budget = json.load(open(\"receipt.json\")), json.load(open(\"scripts/runtime-contract-budget.json\"))\nfor key in (\"tool_surface_profile\", \"fixture_id\"):\n    assert receipt.get(key) == budget.get(key), f\"identity drift on {key}\"","typeGuard":"def identities_match(receipt: dict, budget: dict, keys: list[str]) -> bool:\n    return all(receipt.get(k) == budget.get(k) for k in keys)","tryCatchPattern":"try:\n    compare_receipt_against_budget(receipt, budget)\nexcept IdentityDrift as e:\n    if not user_confirms(e.details):\n        raise\n    regenerate_budget(receipt)  # --update, after review","preventionTips":["Regenerate the budget in the same commit that changes identity inputs (modes, stages, tool surfaces).","Measure on a clean checkout so identity matches CI.","Review the added=/removed= list before accepting any --update."],"tags":["contract-check","identity-drift","budget","diff"],"backgroundTag":"schema-validation-failed","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"}