JuliusBrussee/caveman · error
cachebench: nil cache engine
Error message
cachebench: nil cache engine
What it means
RunSimulated was called with a nil *cacheengine.Engine. The simulation drives the real cache engine to model prefix reuse, so a nil engine (uninitialized pointer or zero-value Engine) is rejected before any scenario runs.
Solutions
- Construct the engine with cacheengine.New (or NewChecked) and pass the non-nil result to RunSimulated
- Check for a nil engine after construction error handling before calling RunSimulated
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at cacheengine/cachebench/simulate.go:26 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/3341bb6898187a26.
Report an issue: GitHub.
Appendix: source
Thrown at cacheengine/cachebench/simulate.go:26
"fmt"
"math"
"strings"
"time"
"github.com/JuliusBrussee/caveman/cacheengine"
)
type cachedPrefix struct {
segments []PrefixSegment
expiresAt time.Time
}
type cachedPrefixGroup map[string]cachedPrefix
// RunSimulated evaluates deterministic agent workload without provider calls.
func RunSimulated(ctx context.Context, engine *cacheengine.Engine, providers []ProviderConfig, scenario Scenario, target Target) (Report, error) {
if engine == nil {
return Report{}, errors.New("cachebench: nil cache engine")
}
if err := validateTarget(target); err != nil {
return Report{}, err
}
if len(providers) == 0 {
return Report{}, errors.New("cachebench: no providers")
}
if len(providers) > 1024 {
return Report{}, errors.New("cachebench: provider population exceeds 1024")
}
report := baseReport(BasisSimulated, scenario, target, QualityEquivalence)
for _, provider := range providers {
trace, err := GenerateTrace(provider, scenario)
if err != nil {
return Report{}, err
}
providerReport := evaluateSimulatedTrace(ctx, engine, trace, target)
report.Providers = append(report.Providers, providerReport)View on GitHub (pinned to 766dce6b13)