{"record":{"id":"f25094734f9c37a3","repo":"Hmbown/CodeWhale","slug":"default-fragment-max-bytes-must-be-fragment-default-max","errorCode":null,"errorMessage":"DEFAULT_FRAGMENT_MAX_BYTES must be {FRAGMENT_DEFAULT_MAX_BYTES_CEILING}, got {default_bytes}","messagePattern":"DEFAULT_FRAGMENT_MAX_BYTES must be (.+?), got (.+?)","errorType":"exception","errorClass":"RuntimeContractError","httpStatus":null,"severity":"error","filePath":"scripts/check-runtime-contract-budget.py","lineNumber":501,"sourceCode":"            )\n    elif not has_multiplication:\n        raise RuntimeContractError(\n            \"MAX_FRAGMENT_BYTES must be defined as MAX_FRAGMENT_TOKENS * 4 or as 40000\"\n        )\n    # DEFAULT is defined as 4 * 1024 (canonical) or 4096 literal\n    has_default_multiplication = re.search(\n        r\"pub const DEFAULT_FRAGMENT_MAX_BYTES:\\s*usize\\s*=\\s*4\\s*\\*\\s*1024\", text\n    )\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(","sourceCodeStart":483,"sourceCodeEnd":519,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-runtime-contract-budget.py#L483-L519","documentation":"When DEFAULT_FRAGMENT_MAX_BYTES is written as a numeric literal, the checker requires it to equal 4096 (FRAGMENT_DEFAULT_MAX_BYTES_CEILING, i.e. 4*1024). The default per-fragment byte limit is pinned so a fresh configuration never produces oversized fragments. A different literal fails the contract gate.","triggerScenarios":"Running scripts/check-runtime-contract-budget.py when fragments.rs contains `pub const DEFAULT_FRAGMENT_MAX_BYTES: usize = <literal>` with a value other than 4096 (the `4 * 1024` multiplication form is accepted as canonical and bypasses this check).","commonSituations":"Tuning the default fragment size upward for bigger context imports; copying a value from another project; bumping the default during a refactor without updating the gate.","solutions":["Set the literal in crates/core/src/fragments.rs back to 4096","Or use the canonical spelling `pub const DEFAULT_FRAGMENT_MAX_BYTES: usize = 4 * 1024;` which the checker accepts unconditionally","If 4096 must change, update FRAGMENT_DEFAULT_MAX_BYTES_CEILING in scripts/check-runtime-contract-budget.py as part of a reviewed budget change"],"exampleFix":"// before\npub const DEFAULT_FRAGMENT_MAX_BYTES: usize = 8192;\n// after\npub const DEFAULT_FRAGMENT_MAX_BYTES: usize = 4 * 1024; // 4096","handlingStrategy":"validation","validationCode":"import re\nsrc = open('crates/core/src/fragments.rs').read()\nm = re.search(r'pub const DEFAULT_FRAGMENT_MAX_BYTES:\\s*usize\\s*=\\s*([0-9_]+)', src)\nif m and int(m.group(1).replace('_','')) != 4096:\n    raise SystemExit('DEFAULT_FRAGMENT_MAX_BYTES must be 4096')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the canonical `4 * 1024` spelling accepted unconditionally by the checker","Run the budget check before pushing changes to fragments.rs","Keep default/max caps in sync with the ceilings in the script"],"tags":["static-check","rust","config","ci"],"backgroundTag":"invalid-config-value","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"}