{"record":{"id":"84d429086cff7df1","repo":"Hmbown/CodeWhale","slug":"missing-tui-fragment-module-tui-fragment-erro","errorCode":null,"errorMessage":"missing TUI fragment module: {tui_fragment} ({error})","messagePattern":"missing TUI fragment module: (.+?) \\((.+?)\\)","errorType":"exception","errorClass":"RuntimeContractError","httpStatus":null,"severity":"error","filePath":"scripts/check-runtime-contract-budget.py","lineNumber":591,"sourceCode":"            \"bounded fragment module must define a matches_text recognizer on the fragment trait\"\n        )\n    if \"trait ContextFragment\" not in text:\n        raise RuntimeContractError(\n            \"bounded fragment module must define trait ContextFragment with matches_text\"\n        )\n\n    # No unbounded fragment — enforce that creation clamps to MAX_FRAGMENT_BYTES\n    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        )","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/scripts/check-runtime-contract-budget.py#L573-L609","documentation":"After gating crates/core/src/fragments.rs, the checker reads the TUI-side module crates/tui/src/model_context/fragment.rs; a FileNotFoundError raises this (the raw OS error is embedded in the message). It means the unified TUI fragment module was deleted, moved, or renamed while the contract still requires the TUI and core to share one fragment boundary.","triggerScenarios":"Moving or deleting crates/tui/src/model_context/fragment.rs during a tui reorganization; an incomplete unification that removed the TUI file; renaming fragment.rs to fragments.rs (path is case-sensitive).","commonSituations":"Crates reshuffles; merging a branch that relocated model_context; accidental deletions in dirty worktrees.","solutions":["Restore the file: 'git checkout HEAD -- crates/tui/src/model_context/fragment.rs' if the move was accidental","If the move is intentional, update tui_fragment in scripts/check-runtime-contract-budget.py:587 to the new path in the same commit","Confirm exact path/casing: 'ls crates/tui/src/model_context/'"],"exampleFix":"# before (scripts/check-runtime-contract-budget.py)\ntui_fragment = REPO_ROOT / \"crates\" / \"tui\" / \"src\" / \"context\" / \"fragment.rs\"\n\n# after (matches the moved file)\ntui_fragment = REPO_ROOT / \"crates\" / \"tui\" / \"src\" / \"model_context\" / \"fragment.rs\"","handlingStrategy":"validation","validationCode":"from pathlib import Path\np = Path(\"crates/tui/src/model_context/fragment.rs\")\nassert p.is_file(), f\"TUI fragment module missing at {p}\"","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":["Before moving crates/tui/src/model_context/fragment.rs, update tui_fragment in the checker in the same commit","CI: assert both fragment module paths exist before running the gate","Treat the core and TUI fragment files as a pair - any path change touches both sides"],"tags":["python","ci","static-analysis","file-not-found","tui"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}