Skip to content

Record per-arm bench cost and apply the cost check - #1980

Closed
remigiusz-antczak wants to merge 1 commit into
mainfrom
land/1962b
Closed

remigiusz-antczak wants to merge 1 commit into
mainfrom
land/1962b

Conversation

@remigiusz-antczak

Copy link
Copy Markdown
Collaborator

Supersedes #1962. The same change, rebuilt as one commit on current main.

The bench recorded spend_usd: 0.0 for every arm, so the cost half of the keep rule could never be applied.

  • scripts/rival_eval_cost.py (new) wraps the hash-pinned scripts/rival_eval.py. It records prompt and completion tokens per item, and spend in USD when the provider reports it. An arm counts as measured only when every item has usage. Unlike Record per-arm bench cost and apply the cost check #1962, rival_eval.py itself is left unchanged, so its pinned hash still holds.
  • scripts/bench_verdict.py --cost results.json reports the Perun-to-rival cost ratio. It exits 0 when Perun costs no more than the rival, 1 when it costs more, 2 on a usage error and 3 when either arm is unmeasured, the units differ, or the rival cost is zero. Older results read as unmeasured.
  • scripts/rival-eval-premerge.sh calls the wrapper. docs/perun-vs-rivals.md documents the harness entry point.
  • Tests live in scripts/test_bench_cost_capture.py and run from scripts/ci-tests.d/bench-cost-capture.sh.

The review of #1962 found one 🔴: a partial run could read as measured. It is fixed here, because every item must carry usage.

Local CI repro on this commit: size-ratchet ok against main, mustload ok, and every scripts/ci-tests.d hook passes. run-ledger.sh failed once only because a second copy ran at the same time; run alone it passes 26/26. test-ci-gates.sh shows 295 passed and 9 failed. The 9 are the known sandbox-only failures (dcr-gates opt-in, peer pains, reap_own pgrep, tracker socket bind).

🤖 Generated with Claude Code

https://claude.ai/code/session_014QNFFPWVcPUbeuvwM5fk2Z

rival_eval_cost.py (a wrapper around the unchanged, hash-pinned rival_eval.py; rival-eval-premerge.sh now runs it) writes cost_per_arm (prompt_tokens, completion_tokens, spend_usd) taken from the PCSS response or claude -p JSON, never estimated, with a per-output sidecar so resumed runs keep it. bench_verdict.py --cost prints per-arm cost per item and the Perun/rival ratio; exit 0 Perun cost <= rival, 1 Perun costs more, 2 usage error, 3 unmeasured.

Tests: 18/18 (test_bench_cost_capture)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014QNFFPWVcPUbeuvwM5fk2Z
@remigiusz-antczak

Copy link
Copy Markdown
Collaborator Author

Superseded by #1981 (review fixes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant