{"record":{"id":"61a6766b016f5d38","repo":"JuliusBrussee/caveman","slug":"cachebench-replay-gap-overflow","errorCode":null,"errorMessage":"cachebench: replay gap overflow","messagePattern":"cachebench: replay gap overflow","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/replay.go","lineNumber":789,"sourceCode":"\t\tTimingBasis: record.TimingBasis, TokenBasis: record.TokenBasis, TimeScale: scale,\n\t\tTimingFaithful: record.TimingBasis == TimingGrounded && scale == 1 && drift <= tolerance,\n\t\tScheduledAt:    scheduled.Format(time.RFC3339Nano), ScheduleDriftMilliseconds: drift.Milliseconds(),\n\t\tScheduleToleranceMilliseconds: tolerance.Milliseconds(),\n\t\tStartedAt:                     started.Format(time.RFC3339Nano), Applied: optimized.Applied,\n\t\tDecision: optimized.Decision, Reason: optimized.Reason, Attribution: optimized.Profile.Attribution,\n\t\tOptimizerIDs: append([]string(nil), optimized.OptimizerIDs...),\n\t}\n}\n\nfunc scaledReplayGap(gap time.Duration, scale float64) (time.Duration, error) {\n\tif gap < 0 || scale <= 0 || math.IsNaN(scale) || math.IsInf(scale, 0) {\n\t\treturn 0, errors.New(\"cachebench: invalid replay gap\")\n\t}\n\tif gap == 0 {\n\t\treturn 0, nil\n\t}\n\tif scale > float64(math.MaxInt64)/float64(gap) {\n\t\treturn 0, errors.New(\"cachebench: replay gap overflow\")\n\t}\n\treturn time.Duration(float64(gap) * scale), nil\n}\n\nfunc sleepContext(ctx context.Context, delay time.Duration) error {\n\tif delay <= 0 {\n\t\treturn nil\n\t}\n\ttimer := time.NewTimer(delay)\n\tdefer timer.Stop()\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\tcase <-timer.C:\n\t\treturn nil\n\t}\n}\n","sourceCodeStart":771,"sourceCodeEnd":807,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cachebench/replay.go#L771-L807","documentation":"Raised when a replay gap value cannot be represented as a time.Duration milliseconds count without int64 overflow. Individual gaps large enough (or scaled sums) to exceed the duration range trip this before evidence emission.","triggerScenarios":"Thrown at cacheengine/cachebench/replay.go:789 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Clamp trace gap values to sane bounds during corpus validation","Split extremely long idle periods into separate replay sessions","Verify the gap derivation isn't double-counting elapsed time across rows"],"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"}