{"record":{"id":"d89d252010e4be55","repo":"Hmbown/CodeWhale","slug":"fragmentid-missing-required-variant-name","errorCode":null,"errorMessage":"FragmentId missing required variant {name}","messagePattern":"FragmentId missing required variant (.+?)","errorType":"exception","errorClass":"RuntimeContractError","httpStatus":null,"severity":"error","filePath":"scripts/check-runtime-contract-budget.py","lineNumber":539,"sourceCode":"        )\n\n    # Ensure every injection type is in FragmentId::all() and the\n    # project-instruction import is present as a typed fragment.\n    required_fragments = [\n        \"Workspace\",\n        \"Permissions\",\n        \"Route\",\n        \"AgentTopology\",\n        \"SkillsTools\",\n        \"TokenBudget\",\n        \"ProjectInstructions\",\n        \"Constitution\",\n    ]\n    for name in required_fragments:\n        if f\"Self::{name}\" not in text and f\"{name} =>\" not in text and f'\"{name.lower()}\"' not in text.lower():\n            # Fallback: search for enum variant declaration\n            if not re.search(rf\"\\b{name}\\b\", text):\n                raise RuntimeContractError(\n                    f\"FragmentId missing required variant {name}\"\n                )\n    # Marker stability — these strings are pinned by tests / prefix cache\n    required_markers = [\n        \"<!-- cw:ctx:workspace -->\",\n        \"<!-- cw:ctx:project_instructions -->\",\n        \"<!-- cw:ctx:constitution -->\",\n    ]\n    for marker in required_markers:\n        if marker not in text:\n            raise RuntimeContractError(\n                f\"bounded fragment module missing required marker {marker!r}\"\n            )\n\n    # Project-instruction import must be a typed fragment, not ad-hoc\n    if \"load_project_instruction_fragment\" not in text:\n        raise RuntimeContractError(\n            \"bounded fragment module must expose load_project_instruction_fragment (project-instruction import as typed fragment)\"","sourceCodeStart":521,"sourceCodeEnd":557,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-runtime-contract-budget.py#L521-L557","documentation":"The FragmentId enum in crates/core/src/fragments.rs must include every required injection type (Workspace, Permissions, Route, AgentTopology, SkillsTools, TokenBudget, ProjectInstructions, Constitution). The checker looks for the variant in several textual forms (Self::<Name>, a match arm `<Name> =>`, a quoted lowercase tag, or a bare word) and fails if none appear — meaning a required fragment type was removed or renamed from the enum.","triggerScenarios":"Running scripts/check-runtime-contract-budget.py after deleting or renaming one of the eight required FragmentId variants in fragments.rs, or after a refactor that renames a variant (e.g. ProjectInstructions -> ProjectDocs) without a match-arm or string tag preserving the old name.","commonSituations":"Renaming variants during a fragment-module refactor; removing a fragment type believed unused; syncing fragments.rs from another fork where a variant was dropped.","solutions":["Re-add the missing variant to the FragmentId enum in crates/core/src/fragments.rs with the exact required name","If a variant was renamed, keep the required name in a match arm (`Name =>`) or lowercase string tag for contract continuity, or update required_fragments in the script as a reviewed contract change","Run `grep -n '<Name>' crates/core/src/fragments.rs` to confirm which textual form the checker needs"],"exampleFix":"// before (variant renamed)\nenum FragmentId { Workspace, ..., ProjectDocs }\n// after\nenum FragmentId { Workspace, ..., ProjectInstructions }","handlingStrategy":"validation","validationCode":"import re\nREQUIRED = [\"Workspace\",\"Permissions\",\"Route\",\"AgentTopology\",\"SkillsTools\",\"TokenBudget\",\"ProjectInstructions\",\"Constitution\"]\nsrc = open('crates/core/src/fragments.rs').read()\nfor name in REQUIRED:\n    if not re.search(rf'\\b{name}\\b', src):\n        raise SystemExit(f'FragmentId missing required variant {name}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep all eight required variants in FragmentId; treat renames as contract changes","Update required_fragments in the script alongside any deliberate variant rename","Run the contract check whenever the enum is edited"],"tags":["static-check","rust","enum","ci"],"backgroundTag":"invalid-enum-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"}