{"record":{"id":"cb1fa1a65746fe17","repo":"Hmbown/CodeWhale","slug":"bounded-fragment-module-must-define-project-instru","errorCode":null,"errorMessage":"bounded fragment module must define PROJECT_INSTRUCTION_CANDIDATES","messagePattern":"bounded fragment module must define PROJECT_INSTRUCTION_CANDIDATES","errorType":"exception","errorClass":"RuntimeContractError","httpStatus":null,"severity":"error","filePath":"scripts/check-runtime-contract-budget.py","lineNumber":553,"sourceCode":"    # 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\",\n        \".github/copilot-instructions.md\",\n    ]\n    for candidate in required_candidates:\n        if candidate not in text:\n            raise RuntimeContractError(\n                f\"PROJECT_INSTRUCTION_CANDIDATES missing required entry {candidate!r}\"\n            )\n\n    # matches_text recognizer must exist on the fragment trait\n    if \"fn matches_text\" not in text:","sourceCodeStart":535,"sourceCodeEnd":571,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/scripts/check-runtime-contract-budget.py#L535-L571","documentation":"Requires the const PROJECT_INSTRUCTION_CANDIDATES to be defined in crates/core/src/fragments.rs (plain substring check). This array enumerates the well-known instruction files scanned at startup; the gate keeps it a named, typed surface instead of inline literals scattered at call sites.","triggerScenarios":"Renaming the const (e.g. INSTRUCTION_FILES); inlining the list at each call site; deleting it in favor of only ADDITIONAL_PROJECT_INSTRUCTION_CANDIDATES.","commonSituations":"Cleanup passes that 'simplify' the candidate list; merges restructuring candidate handling after #3978.","solutions":["Restore 'pub const PROJECT_INSTRUCTION_CANDIDATES: &[&str] = &[...];' in crates/core/src/fragments.rs","Keep supplementary lists under separate names (ADDITIONAL_PROJECT_INSTRUCTION_CANDIDATES) - allowed, but the base const must stay","Verify: 'grep -n PROJECT_INSTRUCTION_CANDIDATES crates/core/src/fragments.rs'"],"exampleFix":"// before (crates/core/src/fragments.rs)\npub const INSTRUCTION_FILES: &[&str] = &[\".cursorrules\", \".clinerules\"];\n\n// after\npub const PROJECT_INSTRUCTION_CANDIDATES: &[&str] = &[\".cursorrules\", \".clinerules\"];","handlingStrategy":"try-catch","validationCode":"from pathlib import Path\ntext = Path(\"crates/core/src/fragments.rs\").read_text(encoding=\"utf-8\")\nassert \"PROJECT_INSTRUCTION_CANDIDATES\" in text, \"PROJECT_INSTRUCTION_CANDIDATES const missing\"","typeGuard":"def is_runtime_contract_error(exc: BaseException) -> bool:\n    return isinstance(exc, ValueError) and type(exc).__name__ == \"RuntimeContractError\"","tryCatchPattern":"try:\n    check_fragment_caps()\nexcept RuntimeContractError as error:\n    print(f\"[gate] {error}\", file=sys.stderr)\n    raise SystemExit(2)","preventionTips":["Keep the candidate list as the named const PROJECT_INSTRUCTION_CANDIDATES (extras may go in ADDITIONAL_...)","Do not inline candidate paths at call sites","Verify with a grep before pushing changes to fragments.rs"],"tags":["python","ci","static-analysis","rust","config"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}