{"record":{"id":"fecdb4c4addf655f","repo":"Hmbown/CodeWhale","slug":"expected-a-hand-written-impl-provider-for-variant-name-with","errorCode":null,"errorMessage":"expected a hand-written `impl Provider for {variant_name}` with id {id_literal!r}; the guard's floor is stale","messagePattern":"expected a hand-written `impl Provider for (.+?)` with id (.+?); the guard's floor is stale","errorType":"console","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/check-provider-registry.py","lineNumber":198,"sourceCode":"        (\"Openmodel\", \"openmodel\"),\n        (\"MinimaxAnthropic\", \"minimax-anthropic\"),\n        (\"OpencodeZen\", \"opencode-zen\"),\n        # Alibaba Model Studio ships four plan/dialect identities, each with a\n        # hand-written impl Provider for the same reason as the rows above:\n        # the wire policy is not fixed, so provider!() cannot express them.\n        (\"ModelstudioTokenPlan\", \"modelstudio-token-plan\"),\n        (\"ModelstudioTokenPlanAnthropic\", \"modelstudio-token-plan-anthropic\"),\n        (\"ModelstudioCodingPlan\", \"modelstudio-coding-plan\"),\n        (\"ModelstudioCodingPlanAnthropic\", \"modelstudio-coding-plan-anthropic\"),\n    ]:\n        match = re.search(\n            rf'impl\\s+Provider\\s+for\\s+{variant_name}.*?fn\\s+id.*?\\\"({id_literal})\\\"',\n            provider_rs, re.DOTALL,\n        )\n        if match:\n            ids[variant_name] = match.group(1)\n        elif variant_name not in ids:\n            raise ValueError(\n                f\"expected a hand-written `impl Provider for {variant_name}` \"\n                f\"with id {id_literal!r}; the guard's floor is stale\"\n            )\n    if not ids:\n        raise ValueError(\"provider!() invocations returned no providers\")\n    return ids\n\n\ndef provider_kind_catalog_ids(\n    provider_kind_rs: str, variant_to_id: dict[str, str]\n) -> set[str]:\n    catalog = re.search(\n        r\"pub const ALL:\\s*\\[Self;\\s*\\d+\\]\\s*=\\s*\\[(.*?)\\];\",\n        provider_kind_rs,\n        flags=re.DOTALL,\n    )\n    if catalog is None:\n        raise ValueError(\"crates/config/src/provider_kind.rs: missing ProviderKind::ALL\")","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-provider-registry.py#L180-L216","documentation":"provider_kind_ids() pairs each provider!() invocation's variant with the id from the hand-written `impl Provider for <Variant>` (its fn id). This error means the regex found no such impl returning the expected id literal for a variant, so the guard's floor list is out of date with the actual Rust code. The message explicitly says the guard's floor is stale.","triggerScenarios":"Called from api_provider_ids or main when a variant listed in provider!() invocations has no `impl Provider for <Variant>` containing `fn id` returning the expected id literal — e.g. the id string changed, the impl is now generated by macro, or the variant's impl was removed.","commonSituations":"Renaming a provider id string in Rust without updating the guard; switching from hand-written impls to macro-generated ids; deleting a provider while the guard still expects it; a repo state from before/after the config module split.","solutions":["Update the guard's expected id literal list to match the current `fn id` return values in the Rust source","Restore the hand-written `impl Provider for <Variant>` with the expected id if it was accidentally removed or macro-generated","Sync the provider!() invocations and impls after any provider rename so both sides agree"],"exampleFix":"// before: guard expects id \"huggingface\" but impl returns \"hf\"\n// after:  update guard floor to (\"Huggingface\", \"hf\") or change fn id to \"huggingface\" in the impl","handlingStrategy":"validation","validationCode":"for variant, expected_id in floor:\n    if not re.search(rf'impl\\s+Provider\\s+for\\s+{variant}.*?fn\\s+id.*?\"{expected_id}\"', provider_rs, re.DOTALL):\n        print(f\"stale floor: {variant}\")","typeGuard":null,"tryCatchPattern":"try:\n    ids = provider_kind_ids(provider_rs)\nexcept ValueError as e:\n    print(f\"registry guard out of date: {e}\", file=sys.stderr)\n    sys.exit(1)","preventionTips":["Update the guard's expected id list whenever a provider id string changes","Keep provider impls hand-written and greppable (fn id with a literal)","Run cargo fmt/test plus this guard together after provider changes"],"tags":["python","rust","provider-registry","stale-guard","ci-guard"],"backgroundTag":"internal-invariant-violation","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"}