{"record":{"id":"da268b674d6b017d","repo":"Hmbown/CodeWhale","slug":"tui-fragment-module-must-include-projectinstructio","errorCode":null,"errorMessage":"TUI fragment module must include ProjectInstructions variant (unified with core)","messagePattern":"TUI fragment module must include ProjectInstructions variant \\(unified with core\\)","errorType":"exception","errorClass":"RuntimeContractError","httpStatus":null,"severity":"error","filePath":"scripts/check-runtime-contract-budget.py","lineNumber":599,"sourceCode":"    if \"MAX_FRAGMENT_BYTES\" not in text or \"enforce_byte_cap\" not in text:\n        raise RuntimeContractError(\n            \"bounded fragment module must enforce byte caps via enforce_byte_cap and MAX_FRAGMENT_BYTES\"\n        )\n\n    # TUI must be unified with the core boundary (shared crates/core module)\n    tui_fragment = REPO_ROOT / \"crates\" / \"tui\" / \"src\" / \"model_context\" / \"fragment.rs\"\n    try:\n        tui_text = tui_fragment.read_text(encoding=\"utf-8\")\n    except FileNotFoundError as error:\n        raise RuntimeContractError(\n            f\"missing TUI fragment module: {tui_fragment} ({error})\"\n        ) from error\n    if \"codewhale_core::fragments\" not in tui_text:\n        raise RuntimeContractError(\n            \"TUI model_context/fragment.rs must re-export caps from codewhale_core::fragments (shared crates/core boundary)\"\n        )\n    if \"ProjectInstructions\" not in tui_text:\n        raise RuntimeContractError(\n            \"TUI fragment module must include ProjectInstructions variant (unified with core)\"\n        )\n    if \"MAX_FRAGMENT_BYTES\" not in tui_text:\n        raise RuntimeContractError(\n            \"TUI fragment module must enforce MAX_FRAGMENT_BYTES (10K-token ceiling)\"\n        )\n    if \"matches_text\" not in tui_text:\n        raise RuntimeContractError(\n            \"TUI fragment module must expose a matches_text recognizer\"\n        )\n\n\ndef main(argv: Sequence[str] | None = None) -> int:\n    parser = argparse.ArgumentParser(description=__doc__)\n    parser.add_argument(\n        \"--receipt\",\n        type=Path,\n        help=\"check an existing measurement JSON instead of compiling\",","sourceCodeStart":581,"sourceCodeEnd":617,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/scripts/check-runtime-contract-budget.py#L581-L617","documentation":"The TUI fragment module must reference 'ProjectInstructions' so the TUI's fragment set stays unified with core's injection types (the typed project-instruction import from #3978). A substring check over crates/tui/src/model_context/fragment.rs; dropping the variant from re-exports or a TUI-side enum fails.","triggerScenarios":"Removing ProjectInstructions from a 'pub use codewhale_core::fragments::...' list; deleting a TUI-local enum member; feature-gating the variant so the literal disappears from the file.","commonSituations":"Trimming re-export lists that look unused; splitting the TUI-side enum during a refactor.","solutions":["Keep ProjectInstructions in the re-export or enum used by crates/tui/src/model_context/fragment.rs","If the TUI enum is generated, ensure the generator emits all core variants","Verify: 'grep -n ProjectInstructions crates/tui/src/model_context/fragment.rs'"],"exampleFix":"// before (crates/tui/src/model_context/fragment.rs)\npub use codewhale_core::fragments::FragmentId::{Workspace, Permissions, Route};\n\n// after\npub use codewhale_core::fragments::FragmentId::{Workspace, Permissions, Route, ProjectInstructions};","handlingStrategy":"try-catch","validationCode":"from pathlib import Path\ntui = Path(\"crates/tui/src/model_context/fragment.rs\").read_text(encoding=\"utf-8\")\nassert \"ProjectInstructions\" in tui, \"TUI fragment set lost ProjectInstructions\"","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":["Use glob re-exports ('pub use codewhale_core::fragments::*') or keep explicit lists in sync with core variants","When core adds a FragmentId variant, mirror it into the TUI surface in the same commit","Grep ProjectInstructions in the TUI module after enum refactors"],"tags":["python","ci","static-analysis","rust","tui","enum"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}