{"record":{"id":"9495399c6a3aee64","repo":"JuliusBrussee/caveman","slug":"cache-replay-trace-and-positive-request-token-tr","errorCode":null,"errorMessage":"cache-replay: -trace and positive request/token/trace/response/verifier limits required","messagePattern":"cache-replay: -trace and positive request/token/trace/response/verifier limits required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cmd/cache-replay/main.go","lineNumber":219,"sourceCode":"\ttimeScale := flag.Float64(\"time-scale\", 1, \"trace timing multiplier; 1 preserves grounded timing\")\n\tallowUngrounded := flag.Bool(\"allow-ungrounded-timing\", false, \"permit synthetic/per-partition schedules; evidence is not timing-faithful\")\n\tallowEstimatedTokens := flag.Bool(\"allow-estimated-token-budget\", false, \"permit non-provider token estimates; input ceiling is not provider-grounded\")\n\tmaxResponseBytes := flag.Int64(\"max-response-bytes\", 16<<20, \"maximum retained provider response bytes/request\")\n\tproviderTimeout := flag.Duration(\"provider-timeout\", 2*time.Minute, \"hard timeout per provider request (1s-1h)\")\n\tverifierPath := flag.String(\"verifier-command\", \"\", \"task verifier executable; receives one JSON object on stdin\")\n\tverifierOutputBytes := flag.Int64(\"max-verifier-output-bytes\", 16<<20, \"maximum verifier JSON bytes/request\")\n\ttargetRate := flag.Float64(\"target\", .97, \"required request and token cache-hit rate\")\n\tminEligible := flag.Int(\"min-requests\", 100, \"minimum eligible requests/provider\")\n\tallowInsecureLoopback := flag.Bool(\"allow-insecure-loopback\", false, \"allow HTTP only for explicit loopback test base URLs\")\n\tallowCustomBaseURL := flag.Bool(\"allow-custom-base-url\", false, \"confirm credentials may be sent to explicit custom HTTPS base URLs\")\n\tverifierTimeout := flag.Duration(\"verifier-timeout\", 5*time.Minute, \"hard timeout per task-verifier invocation\")\n\tflag.Var(&verifierArgs, \"verifier-arg\", \"verifier argument; repeatable, no shell parsing\")\n\tflag.Var(&verifierEnv, \"verifier-env\", \"environment variable exposed to verifier; repeatable\")\n\tflag.Var(&baseURLs, \"base-url\", \"test/custom provider base URL as provider=https://host; repeatable\")\n\tflag.Parse()\n\n\tif *tracePath == \"\" || !filepath.IsAbs(*tracePath) || *maxRequests <= 0 || *maxRequests > maxReplayRequests || *maxTokens <= 0 || *maxTraceBytes <= 0 || *maxTraceBytes > maxReplayTraceBytes || *maxResponseBytes <= 0 || *maxResponseBytes > 256<<20 || *providerTimeout < time.Second || *providerTimeout > time.Hour || *verifierOutputBytes <= 0 || *verifierOutputBytes > 256<<20 || *verifierTimeout <= 0 || *maxScheduleDrift <= 0 || *maxConcurrency <= 0 || *maxConcurrency > 1024 {\n\t\tfatalConfig(errors.New(\"cache-replay: -trace and positive request/token/trace/response/verifier limits required\"))\n\t}\n\tif (*maxResponseBytes+*verifierOutputBytes)*int64(*maxConcurrency) > maxReplayInflightBytes {\n\t\tfatalConfig(fmt.Errorf(\"cache-replay: concurrent response and verifier buffers exceed %d bytes\", maxReplayInflightBytes))\n\t}\n\tif len(baseURLs) > 0 && !*allowCustomBaseURL {\n\t\tfatalConfig(errors.New(\"cache-replay: custom base URLs require -allow-custom-base-url\"))\n\t}\n\trecords, traceSHA, err := readTrace(*tracePath, *maxTraceBytes, *maxRequests)\n\tif err != nil {\n\t\tfatalConfig(err)\n\t}\n\tlimits := cachebench.ReplayLimits{\n\t\tMaxRequests: *maxRequests, MaxDeclaredBilledTokens: *maxTokens, MaxGap: *maxGap, MaxScheduleDrift: *maxScheduleDrift,\n\t\tMaxConcurrency:        *maxConcurrency,\n\t\tRequireGroundedTiming: !*allowUngrounded, RequireProviderTokens: !*allowEstimatedTokens,\n\t}\n\tpreflight, err := cachebench.ValidateReplay(records, limits, *timeScale)\n\tif err != nil {","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/cacheengine/cmd/cache-replay/main.go#L201-L237","documentation":"Fatal configuration error from cache-replay main(): a single combined guard over many flags failed. -trace must be non-empty and an absolute path; -max-requests in (0, maxReplayRequests]; -max-tokens > 0; -max-trace-bytes in (0, maxReplayTraceBytes]; -max-response-bytes in (0, 256MiB]; -provider-timeout in [1s, 1h]; -max-verifier-output-bytes in (0, 256MiB]; -verifier-timeout > 0; -max-schedule-drift > 0; -max-concurrency in (0, 1024]. fatalConfig means the process exits before any replay work.","triggerScenarios":"Passing a relative -trace path like ./trace.jsonl; leaving a numeric flag at 0 or negative; exceeding a ceiling such as -max-concurrency 2048 or -max-response-bytes above 256MiB; -provider-timeout 500ms; omitting -trace entirely.","commonSituations":"Copy-pasted command lines from another machine with different paths; default-zero flags someone assumed were optional; scaling concurrency up in CI and hitting the 1024 cap; scripting with unquoted relative paths.","solutions":["Make -trace an absolute path (prefix with $(realpath ...) or $PWD/)","Set every numeric flag positive and within ceilings; start from defaults and change one at a time","For concurrency above 1024 or larger buffers, you must reduce per-request sizes instead — the caps are hard limits","Run with -h to list all flags and their defaults, then re-issue the command"],"exampleFix":"# before\ncache-replay -trace traces/t.jsonl -max-concurrency 2000\n\n# after\ncache-replay -trace \"$PWD/traces/t.jsonl\" -max-concurrency 1024","handlingStrategy":"validation","validationCode":"func validReplayFlags(trace string, maxReq, maxTok, maxTrace, maxResp int64, timeout, vTimeout time.Duration, drift time.Duration, conc int) bool {\n\treturn trace != \"\" && filepath.IsAbs(trace) &&\n\t\tmaxReq > 0 && maxTok > 0 && maxTrace > 0 && maxResp > 0 && maxResp <= 256<<20 &&\n\t\ttimeout >= time.Second && timeout <= time.Hour && vTimeout > 0 && drift > 0 &&\n\t\tconc > 0 && conc <= 1024\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wrap the CLI in a shell function that realpath's the trace and clamps numerics before exec","Keep a known-good command template in the repo and diff against it when flags change"],"tags":["go","cli","configuration","validation"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}