{"record":{"id":"ee4f160edbc2c961","repo":"Hmbown/CodeWhale","slug":"kind-tool-surface-profile-must-be-tool-surface-profile-got","errorCode":null,"errorMessage":"{kind} tool surface_profile must be `{TOOL_SURFACE_PROFILE}`, got {profile!r}","messagePattern":"(.+?) tool surface_profile must be `(.+?)`, got (.+?)","errorType":"exception","errorClass":"RuntimeContractError","httpStatus":null,"severity":"error","filePath":"scripts/check-runtime-contract-budget.py","lineNumber":208,"sourceCode":"\ndef required_value(document: dict[str, Any], path: MetricPath, kind: str) -> Any:\n    value: Any = document\n    dotted = \".\".join(path)\n    for part in path:\n        if not isinstance(value, dict) or part not in value:\n            raise RuntimeContractError(f\"{kind} is missing required field `{dotted}`\")\n        value = value[part]\n    return value\n\n\ndef tool_identity_digest(names: list[str]) -> str:\n    return hashlib.sha256(\"\\0\".join(names).encode(\"utf-8\")).hexdigest()\n\n\ndef validate_identity_structure(document: dict[str, Any], kind: str) -> None:\n    profile = required_value(document, (\"tool_catalog\", \"surface_profile\"), kind)\n    if profile != TOOL_SURFACE_PROFILE:\n        raise RuntimeContractError(\n            f\"{kind} tool surface_profile must be `{TOOL_SURFACE_PROFILE}`, \"\n            f\"got {profile!r}\"\n        )\n\n    shell = required_value(document, (\"tool_catalog\", \"execution_shell\"), kind)\n    if shell != \"bash\":\n        raise RuntimeContractError(\n            f\"{kind} tool execution_shell must be `bash`, got {shell!r}\"\n        )\n\n    for mode, _label in VISIBLE_MODES:\n        for surface, _surface_label in TOOL_SURFACES:\n            base = (\"tool_catalog\", \"modes\", mode, surface)\n            names = required_value(document, (*base, \"tool_names\"), kind)\n            dotted_names = \".\".join((*base, \"tool_names\"))\n            if (\n                not isinstance(names, list)\n                or any(not isinstance(name, str) or not name for name in names)","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-runtime-contract-budget.py#L190-L226","documentation":"validate_identity_structure pins the tool catalog to the script's canonical surface profile constant TOOL_SURFACE_PROFILE. If the document's tool_catalog.surface_profile differs, the contract identity is not comparable with the current script version, so it throws. This prevents mixing receipts from different catalog shapes.","triggerScenarios":"validate_receipt or validate_budget finds tool_catalog.surface_profile set to any value other than TOOL_SURFACE_PROFILE (or missing, which surfaces as error 800 first).","commonSituations":"Receipt generated by an older/newer script version where the profile string was bumped; manually crafted JSON with a guessed profile value; a document from another repo/copy with a divergent constant.","solutions":["Regenerate the receipt with the current script so surface_profile matches TOOL_SURFACE_PROFILE","Read TOOL_SURFACE_PROFILE in check-runtime-contract-budget.py and correct the JSON value to that exact string","If the profile change is intentional, update TOOL_SURFACE_PROFILE and regenerate all receipts consistently"],"exampleFix":"// before\n{\"tool_catalog\": {\"surface_profile\": \"codewhale-v1\"}}\n// after (value = TOOL_SURFACE_PROFILE in the script)\n{\"tool_catalog\": {\"surface_profile\": \"codewhale-v2\"}}","handlingStrategy":"validation","validationCode":"from scripts.check_runtime_contract_budget import TOOL_SURFACE_PROFILE\nassert doc.get(\"tool_catalog\", {}).get(\"surface_profile\") == TOOL_SURFACE_PROFILE, \\\n    f\"expected surface_profile {TOOL_SURFACE_PROFILE!r}\"","typeGuard":null,"tryCatchPattern":"try:\n    validate_receipt(receipt)\nexcept RuntimeContractError as e:\n    if \"surface_profile must be\" in str(e):\n        receipt = regenerate_receipt()  # version skew: rebuild with current script\n    else:\n        raise","preventionTips":["Never hardcode the profile string; import TOOL_SURFACE_PROFILE","Regenerate all receipts whenever the surface profile constant changes","Store the script version in receipts to detect version skew early"],"tags":["python","schema-validation","version-skew"],"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"}