{"record":{"id":"03eb68e0cc030631","repo":"HKUDS/Vibe-Trading","slug":"label-must-be-non-negative-got-value-r","errorCode":null,"errorMessage":"{label} must be non-negative, got {value!r}","messagePattern":"(.+?) must be non-negative, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/fundmath.py","lineNumber":1173,"sourceCode":"        catch_up_rate: GP share of each catch-up dollar, in ``[0, 1]``. Pass\n            ``0.0`` for a fund with no catch-up tier; any other value must\n            exceed ``carry_rate``, or the tier could never complete.\n\n    Returns:\n        A :class:`WaterfallResult` whose tiers sum exactly to ``distributable``.\n\n    Raises:\n        ValueError: If any amount is negative, if ``carry_rate`` is outside\n            ``[0, 1)``, if ``catch_up_rate`` is outside ``[0, 1]``, or if a\n            non-zero ``catch_up_rate`` does not exceed ``carry_rate``.\n    \"\"\"\n    for label, value in (\n        (\"distributable\", distributable),\n        (\"contributed_capital\", contributed_capital),\n        (\"preferred_amount\", preferred_amount),\n    ):\n        if value < 0.0:\n            raise ValueError(f\"{label} must be non-negative, got {value!r}\")\n    if not 0.0 <= carry_rate < 1.0:\n        raise ValueError(f\"carry_rate must be in [0, 1), got {carry_rate!r}\")\n    if not 0.0 <= catch_up_rate <= 1.0:\n        raise ValueError(f\"catch_up_rate must be in [0, 1], got {catch_up_rate!r}\")\n    if catch_up_rate > 0.0 and catch_up_rate <= carry_rate:\n        raise ValueError(\n            f\"catch_up_rate={catch_up_rate!r} must exceed carry_rate=\"\n            f\"{carry_rate!r}, otherwise the catch-up tier can never complete. \"\n            \"Pass catch_up_rate=0.0 for a fund with no catch-up.\"\n        )\n\n    remaining = float(distributable)\n\n    return_of_capital = min(remaining, float(contributed_capital))\n    remaining -= return_of_capital\n\n    preferred_paid = min(remaining, float(preferred_amount))\n    remaining -= preferred_paid","sourceCodeStart":1155,"sourceCodeEnd":1191,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/fundmath.py#L1155-L1191","documentation":"waterfall_split requires distributable, contributed_capital, and preferred_amount to be non-negative; these are dollar magnitudes and a negative value would break every downstream tier calculation.","triggerScenarios":"Calling waterfall_split(distributable=-100.0, ...) or passing a negative preferred_amount computed by an accrual bug, via european_waterfall/_pooled_entitlement or directly in tests.","commonSituations":"Sign-convention mix-ups (treating distributions as negative); a preferred-return accrual that went negative; feeding gross instead of net values with offsets applied twice.","solutions":["Verify the sign convention: all three arguments are non-negative dollar amounts","Clamp tiny negative floats from floating-point drift: max(0.0, value)","Trace where the negative number originated (accrual, aggregation, or parse) and fix it"],"exampleFix":"# before\nwaterfall_split(distributable=dist, contributed_capital=paid, preferred_amount=pref)  # pref=-1e-12\n\n# after\nwaterfall_split(\n    distributable=max(0.0, dist),\n    contributed_capital=max(0.0, paid),\n    preferred_amount=max(0.0, pref),\n)","handlingStrategy":"validation","validationCode":"distributable = max(0.0, distributable)\ncontributed_capital = max(0.0, contributed_capital)\npreferred_amount = max(0.0, preferred_amount)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Establish one sign convention document for the pipeline","Clamp float drift to zero before waterfall calls"],"tags":["fund-math","waterfall","validation","sign-convention"],"backgroundTag":"invalid-argument-range","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}