{"record":{"id":"5752f9c2970ca22a","repo":"JuliusBrussee/caveman","slug":"cacheengine-cache-economics-overflow","errorCode":null,"errorMessage":"cacheengine: cache economics overflow","messagePattern":"cacheengine: cache economics overflow","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/engine.go","lineNumber":391,"sourceCode":"\t\tif calls == 0 {\n\t\t\tcalls = defaultCalls\n\t\t}\n\t\tif calls > previousCalls {\n\t\t\treturn nil, false, false, errors.New(\"cacheengine: longer prefix cannot have higher expected reuse\")\n\t\t}\n\t\tpreviousCalls = calls\n\t\tif calls < 2 {\n\t\t\tcontinue\n\t\t}\n\t\tif cumulativeTokens > 0 && cumulativeTokens < profile.MinPrefixTokens {\n\t\t\tbelowMinimum = true\n\t\t\tcontinue\n\t\t}\n\t\tnet := 0.0\n\t\tif cumulativeTokens > 0 && profile.EconomicsKnown {\n\t\t\trawNet := float64(cumulativeTokens) * (float64(calls) - profile.WriteMultiplier - float64(calls-1)*profile.ReadMultiplier)\n\t\t\tif math.IsNaN(rawNet) || math.IsInf(rawNet, 0) {\n\t\t\t\treturn nil, false, false, errors.New(\"cacheengine: cache economics overflow\")\n\t\t\t}\n\t\t\tnet = roundUnits(rawNet)\n\t\t\tif net <= 0 {\n\t\t\t\tnegative = true\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tsum := sha256.Sum256(prefix)\n\t\tcandidate := Breakpoint{\n\t\t\tAfterSegment:              segment.Name,\n\t\t\tPrefixSHA256:              hex.EncodeToString(sum[:]),\n\t\t\tPrefixTokens:              cumulativeTokens,\n\t\t\tExpectedCalls:             calls,\n\t\t\tBreakEvenCalls:            breakEvenCalls(profile),\n\t\t\tExpectedNetInputRateUnits: net,\n\t\t\tindex:                     index,\n\t\t}\n\t\tif len(candidates) > 0 && candidates[len(candidates)-1].ExpectedCalls == calls {","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/engine.go#L373-L409","documentation":"The breakpoint-economics computation produced a non-finite net-savings value (NaN/Inf) from cumulative tokens, calls, and the profile's write/read multipliers — the profit model refuses to rank candidates on non-finite economics.","triggerScenarios":"Thrown at cacheengine/engine.go:391 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use finite multipliers and realistic token/call magnitudes in the profile","Audit EconomicsKnown profiles for zero or overflowing multiplier values"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}