{"record":{"id":"b06a1ddc2462cfe5","repo":"JuliusBrussee/caveman","slug":"cachebench-invalid-stable-identity-boundary","errorCode":null,"errorMessage":"cachebench: invalid stable identity boundary","messagePattern":"cachebench: invalid stable identity boundary","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/corpus.go","lineNumber":698,"sourceCode":"\t}\n\tsort.SliceStable(requests, func(i, j int) bool { return requests[i].At.Before(requests[j].At) })\n\treturn Trace{\n\t\tProvider: provider,\n\t\tScenario: Scenario{Name: corpus.Metadata.Name, Turns: len(requests), AssumedTTL: 5 * time.Minute, Step: time.Second},\n\t\tRequests: requests, TokenBasis: counter.Name() + \" estimate over normalized OpenAI messages\",\n\t\tTimingBasis: TimingPerPartition,\n\t}, nil\n}\n\nfunc corpusStableIdentity(messages []CorpusMessage, stableCount int) (string, error) {\n\tif len(messages) == 0 {\n\t\treturn \"\", errors.New(\"cachebench: empty stable identity\")\n\t}\n\tif stableCount == 0 {\n\t\tstableCount = 1\n\t}\n\tif stableCount > len(messages) {\n\t\treturn \"\", errors.New(\"cachebench: invalid stable identity boundary\")\n\t}\n\tdigest := sha256.New()\n\tencoder := json.NewEncoder(digest)\n\tencoder.SetEscapeHTML(false)\n\tfor _, message := range messages[:stableCount] {\n\t\tif err := encoder.Encode(message); err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\treturn hex.EncodeToString(digest.Sum(nil)), nil\n}\n\nfunc corpusProviderBody(provider ProviderConfig, messages []CorpusMessage) ([]byte, error) {\n\tswitch provider.Provider {\n\tcase \"openai\":\n\t\treturn json.Marshal(map[string]any{\"model\": provider.Model, \"max_completion_tokens\": 256, \"messages\": messages})\n\tcase \"anthropic\":\n\t\treturn anthropicCorpusBody(provider.Model, messages)","sourceCodeStart":680,"sourceCodeEnd":716,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cachebench/corpus.go#L680-L716","documentation":"Raised in corpusStableIdentity when the stableCount boundary is invalid for the given message slice (e.g. stableCount == 0 or negative, or exceeding the number of messages available). The stable-prefix length must be a positive index within the conversation.","triggerScenarios":"Thrown at cacheengine/cachebench/corpus.go:698 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Clamp the stable segment count to [1, len(messages)] before computing identity","Fix the stable-segment derivation logic that produced 0 or an out-of-range count","Log the row/session where the boundary failed to locate the malformed conversation"],"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"}