# Caveman Direct vs `trim-2` Benchmark End-to-end, reproducible 2-arm benchmark comparing raw agent traffic against Caveman `trim-2`: 1. **`direct`** — `mode: record`, `trim_level: off` (uncompressed baseline) 2. **`caveman`** — `mode: compress`, `trim_level: smart_max` (real `caveman-proxy` + `caveman-mcp` CCR + `codemode`) Every arm compiles and spawns real `caveman-proxy`, `caveman-mcp`, and `codemode` binaries with isolated `CAVEMAN_HOME`, real SQLite `PrefixCache` and `CCR` stores, and real Anthropic Messages wire framing (`tool_use`/`tool_result`, ``, parallel calls, `cache_control: ephemeral`). Pass `--all-arms` to include optional ablation arms. ## 32-Task Universal Real-World Corpus (SWE + Non-SWE Knowledge Work) - **Real repo code comprehension (4):** `engine/compressors/json.go`, `proxy/internal/gateway/epoch.go`, `proxy/internal/store/store.go` (Claude `N→` Read gutters), plus zero-overlap symptom-to-code mutex deadlock. - **Executable `Edit` patches (3):** Go (`PaginateItems`), Python (`issue_prorated_refund`), and Rust (`CreditLedger::drain_credits` checked arithmetic) — graded by real `Edit` on disk + execution/checks. - **UI & Frontend engineering (2):** 460-line React+TSX+Tailwind dashboard (`UpgradePlanModal` ARIA dialog + Escape handler + `BillingSummaryBanner` dark-mode contrast); 450-line CSS design tokens (`tokens.css`) + `checkout.html` sticky header vs modal `z-index` stacking bug. - **Long-horizon multi-file & multi-session agent trajectories (4):** 5-file Go checkout repo (~1,450 lines, `Read`+`Edit`+`Bash` `go test ./...`); 2-session 4-file Node/JS API refactor (~1,150 lines, sliding-window rate limiter + burst verified by `node test.mjs`); 5-file Python pricing package (~1,200 lines, coupon precedence + post-discount tax verified by `python3 test_pricing.py`); 760-line noisy CI build log (`vite`/`eslint`/unit tests/docker) + `formatters.mjs` bugfix verified by `node`. - **SQL & Infrastructure / DevSecOps (3):** 480-line Postgres migration (`0042_tenant_rls.sql`) auditing 25 tables to patch a missing `WITH CHECK` RLS policy; multi-file Kubernetes incident (`deployment.yaml` + `network_policy.yaml` + `kubectl_describe.txt`); 500-line OpenAPI 3.1 YAML + 300-line Terraform HCL remediating a public S3 bucket. - **Monorepo docs, diffs, logs & structured payloads (6):** 550-line Markdown RFC + 260-line `rg` grep output; 7-file git diff HMAC bypass; 500-line mixed logfmt+NDJSON incident; 60-test `pytest` + 35-frame `KeyError` traceback; committed `tool_output.json` + `dashboard.html`; 250-row CSV + 4-env YAML. - **Non-SWE knowledge & operations work (5):** 600-line Enterprise SaaS Legal MSA/DPA redline extraction; Finance 300-row GL ledger anomaly reconciliation + Q3 Board Memo; SecOps 350-line CloudTrail JSONL attack-chain + Slack incident postmortem; Product/Support 85-ticket Zendesk P0 triage + Q4 Roadmap; Data Science 380-line Python A/B stats bugfix + 200-row experiment metrics TSV regression. - **Proxy cache safety, fail-closed control, adversarial & CodeMode MCP (5):** 2-session + 2-turn `PrefixCache` (0 busts + 0 cross-session poisoning); parallel `Read` with ``; whole-file line-by-line review fail-closed control (kept in aggregate); 50 query-echo decoys vs rare `WARN`; real `caveman-mcp codemode` on 400-line CI log. ## Latest Results - **Live wrapped Claude Code (`claude-sonnet-5-5`, 32 tasks):** [results/claude-REPORT.md](./results/claude-REPORT.md) · [results/claude-latest.json](./results/claude-latest.json) - **Offline proxy wire gate (`o200k_base`, `inferred`, 32 tasks):** [results/offline-REPORT.md](./results/offline-REPORT.md) · [results/offline-latest.json](./results/offline-latest.json) ## Commands ### Offline proxy benchmark (0 API cost, ~10s) ```bash go run ./benchmarks/trim2-bench --mode offline ``` ### Real wrapped Claude Code CLI benchmark (recommended live mode) Spawns real `caveman-proxy` + `caveman-mcp` instances for `direct` and `caveman`, warms the Anthropic system-prompt cache once, rotates arm order per task to remove cache-ordering bias, and drives real `claude -p` sessions (`Read`, `Edit`, `Bash` test runs, and real `mcp__caveman__caveman_retrieve` recovery counted in full against provider-reported `modelUsage`): ```bash go run ./benchmarks/trim2-bench --mode claude --model claude-sonnet-5-5 --trials 1 ``` ### Live direct Anthropic API benchmark (BYOK) Reads `ANTHROPIC_API_KEY` from the environment or repo-root `.env.local`. Every `caveman_retrieve` recovery call and follow-up turn is counted in full against that arm's provider-reported input/cache/output tokens and USD cost. ```bash go run ./benchmarks/trim2-bench --mode live --model claude-sonnet-5-5 --trials 1 ``` Outputs `results/-latest.json`, `results/-REPORT.md`, and `results/-report.html`.