{"record":{"id":"7e3ef6c9b71a9cbf","repo":"Hmbown/CodeWhale","slug":"default-fragment-max-bytes-definition-not-found","errorCode":null,"errorMessage":"DEFAULT_FRAGMENT_MAX_BYTES definition not found","messagePattern":"DEFAULT_FRAGMENT_MAX_BYTES definition not found","errorType":"exception","errorClass":"RuntimeContractError","httpStatus":null,"severity":"error","filePath":"scripts/check-runtime-contract-budget.py","lineNumber":509,"sourceCode":"    )\n    default_literal = re.search(\n        r\"pub const DEFAULT_FRAGMENT_MAX_BYTES:\\s*usize\\s*=\\s*([0-9_]+)\", text\n    )\n    if has_default_multiplication:\n        # canonical 4*1024 == 4096, which equals ceiling\n        pass\n    elif default_literal:\n        default_bytes = int(default_literal.group(1).replace(\"_\", \"\"))\n        if default_bytes != FRAGMENT_DEFAULT_MAX_BYTES_CEILING:\n            raise RuntimeContractError(\n                f\"DEFAULT_FRAGMENT_MAX_BYTES must be {FRAGMENT_DEFAULT_MAX_BYTES_CEILING}, got {default_bytes}\"\n            )\n        if default_bytes > FRAGMENT_MAX_BYTES_CEILING:\n            raise RuntimeContractError(\n                f\"DEFAULT_FRAGMENT_MAX_BYTES ({default_bytes}) must not exceed MAX_FRAGMENT_BYTES ({FRAGMENT_MAX_BYTES_CEILING})\"\n            )\n    else:\n        raise RuntimeContractError(\"DEFAULT_FRAGMENT_MAX_BYTES definition not found\")\n\n    max_count = const_value(\n        r\"pub const MAX_FRAGMENTS_PER_CONTEXT:\\s*usize\\s*=\\s*([0-9_]+)\"\n    )\n    if max_count != FRAGMENT_MAX_COUNT_CEILING:\n        raise RuntimeContractError(\n            f\"MAX_FRAGMENTS_PER_CONTEXT must be {FRAGMENT_MAX_COUNT_CEILING}, got {max_count}\"\n        )\n    if max_count > FRAGMENT_MAX_COUNT_CEILING:\n        raise RuntimeContractError(\n            f\"MAX_FRAGMENTS_PER_CONTEXT ({max_count}) must not exceed {FRAGMENT_MAX_COUNT_CEILING}\"\n        )\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\",","sourceCodeStart":491,"sourceCodeEnd":527,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-runtime-contract-budget.py#L491-L527","documentation":"The checker requires an explicit `pub const DEFAULT_FRAGMENT_MAX_BYTES: usize = ...` definition in crates/core/src/fragments.rs, matching either the `4 * 1024` form or a numeric literal. If neither regex matches — the constant is missing, renamed, reformatted, or commented out — the gate fails closed rather than assuming a default. This keeps the per-fragment default byte cap auditable.","triggerScenarios":"Running scripts/check-runtime-contract-budget.py after removing or renaming DEFAULT_FRAGMENT_MAX_BYTES in fragments.rs, or after a reformat that splits the definition so the regexes `DEFAULT_FRAGMENT_MAX_BYTES:\\s*usize\\s*=\\s*4\\s*\\*\\s*1024` and `=\\s*([0-9_]+)` no longer match.","commonSituations":"Deleting the constant while switching to a runtime-provided default; renaming it during a config refactor; moving the definition to another module.","solutions":["Restore `pub const DEFAULT_FRAGMENT_MAX_BYTES: usize = 4 * 1024;` in crates/core/src/fragments.rs","Or restore the literal form `= 4096` with the exact name and type annotation on one line","Check the constant was not moved/renamed — the regex only matches the exact identifier in the fragment module"],"exampleFix":"// before (constant removed during refactor)\n// default now supplied by config layer\n// after\npub const DEFAULT_FRAGMENT_MAX_BYTES: usize = 4 * 1024;","handlingStrategy":"validation","validationCode":"import re\nsrc = open('crates/core/src/fragments.rs').read()\nif not re.search(r'pub const DEFAULT_FRAGMENT_MAX_BYTES:\\s*usize\\s*=', src):\n    raise SystemExit('DEFAULT_FRAGMENT_MAX_BYTES definition missing')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not remove or rename contract-checked constants without updating the script","Keep each const on a single line matching `pub const NAME: usize = value;`","Grep the module after refactors to confirm all pinned constants survive"],"tags":["static-check","rust","missing-constant","ci"],"backgroundTag":"missing-required-config-field","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"}