JuliusBrussee/caveman · error
cacheengine: invalid cache economics
Error message
cacheengine: invalid cache economics
What it means
While scoring breakpoint candidates, the net-savings computation produced NaN or ±Inf — the economics inputs (cumulative tokens, calls, write/read multipliers) combine to a non-finite number, so the profit model cannot be trusted.
Solutions
- Use finite, sane write/read multipliers in the profile economics
- Shrink segment token counts and expected calls to non-overflowing magnitudes
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at cacheengine/engine.go:298 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18).
Data as JSON: /api/errors/2d7798ad5b55a85a.
Report an issue: GitHub.
Appendix: source
Thrown at cacheengine/engine.go:298
}
profile := normalizedProfile(request.Profile)
if !validIdentity(profile.ID, 256, false) || !validIdentity(profile.Provider, 64, true) || !validIdentity(profile.OptimizerID, 256, true) {
return errors.New("cacheengine: invalid profile identity")
}
if profile.Mode != ModeUnsupported && profile.Mode != ModeImplicit && profile.Mode != ModeAffinity && profile.Mode != ModeExplicit {
return fmt.Errorf("cacheengine: unknown mode %q", profile.Mode)
}
if profile.Mode != ModeUnsupported {
if profile.MaxBreakpoints <= 0 || profile.MinPrefixTokens < 0 || profile.MaxRPMPerKey < 0 || profile.TTL < 0 {
return errors.New("cacheengine: invalid cache thresholds")
}
switch profile.Attribution {
case AttributionNone, AttributionOrganic, AttributionAffinity, AttributionCausal:
default:
return fmt.Errorf("cacheengine: unknown attribution %q", profile.Attribution)
}
if profile.EconomicsKnown && (!finiteNonNegative(profile.WriteMultiplier) || !finiteNonNegative(profile.ReadMultiplier)) {
return errors.New("cacheengine: invalid cache economics")
}
}
return nil
}
func normalizedProfile(profile Profile) Profile {
if profile.Mode == ModeUnsupported {
if profile.ID == "" {
profile.ID = "unsupported"
}
return profile
}
if profile.MaxBreakpoints == 0 {
profile.MaxBreakpoints = 1
}
if profile.MaxRPMPerKey == 0 {
profile.MaxRPMPerKey = 15
}View on GitHub (pinned to 766dce6b13)