{"record":{"id":"201f2743401c8ea5","repo":"Hmbown/CodeWhale","slug":"bounded-fragment-module-missing-required-marker-marker-r","errorCode":null,"errorMessage":"bounded fragment module missing required marker {marker!r}","messagePattern":"bounded fragment module missing required marker (.+?)","errorType":"exception","errorClass":"RuntimeContractError","httpStatus":null,"severity":"error","filePath":"scripts/check-runtime-contract-budget.py","lineNumber":550,"sourceCode":"        \"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)\"\n        )\n    if \"PROJECT_INSTRUCTION_CANDIDATES\" not in text:\n        raise RuntimeContractError(\n            \"bounded fragment module must define PROJECT_INSTRUCTION_CANDIDATES\"\n        )\n    # Required candidate files from #3978\n    required_candidates = [\n        \".cursorrules\",\n        \".clinerules\",\n        \".windsurf/rules\",\n        \".gemini\",","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-runtime-contract-budget.py#L532-L568","documentation":"The fragment module must contain three exact HTML-comment markers (`<!-- cw:ctx:workspace -->`, `<!-- cw:ctx:project_instructions -->`, `<!-- cw:ctx:constitution -->`). These markers are pinned by tests and the prompt prefix cache (KV-cache stability), so they must not change shape. A missing marker means the fragment renderer no longer emits the pinned string, which would invalidate cached prefixes or break tests.","triggerScenarios":"Running scripts/check-runtime-contract-budget.py when any of the three `cw:ctx:` marker strings is absent from fragments.rs — e.g. after changing marker formatting, renaming a marker, or removing the code path that defines it.","commonSituations":"Rebranding or reformatting context markers; 'cleaning up' comments that are actually load-bearing contract strings; a merge that dropped one marker's definition.","solutions":["Restore the exact marker string in crates/core/src/fragments.rs (copy the literal from required_markers in scripts/check-runtime-contract-budget.py)","If markers must change, it is a deliberate cache-breaking migration: update tests, the prefix cache contract, and required_markers together with review","Check for whitespace differences — the comparison is exact substring, so `<!--cw:ctx:workspace-->` without spaces fails"],"exampleFix":"// before\nconst WORKSPACE_MARKER: &str = \"<!--cw:ctx:workspace-->\"; // spaces removed\n// after\nconst WORKSPACE_MARKER: &str = \"<!-- cw:ctx:workspace -->\";","handlingStrategy":"validation","validationCode":"MARKERS = [\"<!-- cw:ctx:workspace -->\", \"<!-- cw:ctx:project_instructions -->\", \"<!-- cw:ctx:constitution -->\"]\nsrc = open('crates/core/src/fragments.rs').read()\nmissing = [m for m in MARKERS if m not in src]\nif missing:\n    raise SystemExit(f'missing pinned markers: {missing}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat the cw:ctx: markers as API, not comments — never 'clean them up'","Copy marker literals from the script or tests rather than retyping them","Remember the markers are pinned by the prefix cache; changes are cache-breaking migrations"],"tags":["static-check","rust","cache","compatibility"],"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"}