{"record":{"id":"a56f15196d3e68de","repo":"JuliusBrussee/caveman","slug":"cachebench-invalid-scenario-timing","errorCode":null,"errorMessage":"cachebench: invalid scenario timing","messagePattern":"cachebench: invalid scenario timing","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/trace.go","lineNumber":94,"sourceCode":"\t\t\t},\n\t\t)\n\t}\n\treturn Trace{\n\t\tProvider: provider, Scenario: scenario, Requests: requests,\n\t\tTokenBasis:  \"deterministic declared fixture tokens; provider counts required for observed evidence\",\n\t\tTimingBasis: TimingSynthetic,\n\t}, nil\n}\n\nfunc validateScenario(provider ProviderConfig, scenario Scenario) error {\n\tif strings.TrimSpace(provider.Provider) == \"\" || strings.TrimSpace(provider.Model) == \"\" || strings.TrimSpace(provider.Endpoint) == \"\" {\n\t\treturn errors.New(\"cachebench: provider, model, and endpoint required\")\n\t}\n\tif scenario.Turns < 2 || scenario.StaticTokens <= 0 || scenario.UserTokens <= 0 || scenario.AssistantTokens < 0 || scenario.ToolResultTokens < 0 || scenario.SummaryTokens < 0 {\n\t\treturn errors.New(\"cachebench: invalid scenario token or turn count\")\n\t}\n\tif scenario.CompactionEvery < 0 || scenario.Step <= 0 || scenario.AssumedTTL <= 0 {\n\t\treturn errors.New(\"cachebench: invalid scenario timing\")\n\t}\n\treturn nil\n}\n\nfunc nativeRequest(provider ProviderConfig, scenario Scenario, epoch string, body []byte) cacheengine.NativeRequest {\n\texpectedCalls := scenario.Turns\n\tif scenario.CompactionEvery > 0 && expectedCalls > scenario.CompactionEvery {\n\t\texpectedCalls = scenario.CompactionEvery\n\t}\n\treturn cacheengine.NativeRequest{\n\t\tScope: \"cachebench/real-agent\", Epoch: epoch, PartitionKey: \"agent-session-1\",\n\t\tExpectedRequestsPerMinute: 20, ExpectedCalls: expectedCalls,\n\t\tProvider: provider.Provider, Model: provider.Model, Region: provider.Region, Endpoint: provider.Endpoint,\n\t\tBody: body, RuntimeMode: \"optimize\", AuthMode: \"payg\", PrefixTokens: scenario.StaticTokens,\n\t}\n}\n\nfunc fixtureText(label string, declaredTokens int) string {","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cachebench/trace.go#L76-L112","documentation":"validateScenario rejects scenarios whose turn count, static token count, or user token counts are outside valid bounds (e.g. fewer than 2 turns, non-positive static tokens). Synthetic traces must be structurally sound to yield valid cache evidence.","triggerScenarios":"Thrown at cacheengine/cachebench/trace.go:94 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set valid positive timing values on the Scenario (per-turn timing within documented bounds)","Use the default scenario timing values if custom timing is not required"],"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"}