Keep handoff material in the repo, and move the bench scripts the plan points at into workflow-bench/
This commit is contained in:
Executable
+83
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Run larv-review bench runs: bench.py <case>-<version>-<n> ..."""
|
||||
import concurrent.futures
|
||||
import json
|
||||
import pathlib
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
BENCH = pathlib.Path(__file__).resolve().parent
|
||||
SOURCES = BENCH.parent.parent / "2026-09-29" / "bench"
|
||||
CASES = {
|
||||
"cjk": ("151bf38^", "6c49912"),
|
||||
"35b": ("692433b", "1d369ec"),
|
||||
"brlan": ("59ce55b^", "92e466a"),
|
||||
"mypy": ("89a66d3", "b32d131"),
|
||||
}
|
||||
ATTEMPTS = 4
|
||||
|
||||
|
||||
def git(repo, *args):
|
||||
return subprocess.run(["git", "-C", str(repo), *args], check=True, capture_output=True, text=True).stdout.strip()
|
||||
|
||||
|
||||
def fresh_clone(case, dest):
|
||||
if dest.exists():
|
||||
shutil.rmtree(dest)
|
||||
source = SOURCES / f"{case}-main"
|
||||
base_ref, head_ref = CASES[case]
|
||||
base = git(source, "rev-parse", base_ref)
|
||||
head = git(source, "rev-parse", head_ref)
|
||||
subprocess.run(["git", "clone", "-q", "--no-local", str(source), str(dest)], check=True)
|
||||
git(dest, "checkout", "-q", "-B", "chunk", head)
|
||||
for branch in git(dest, "for-each-ref", "--format=%(refname:short)", "refs/heads").split():
|
||||
if branch != "chunk":
|
||||
git(dest, "branch", "-D", branch)
|
||||
for tag in git(dest, "tag").split():
|
||||
git(dest, "tag", "-d", tag)
|
||||
git(dest, "remote", "remove", "origin")
|
||||
git(dest, "reflog", "expire", "--expire=now", "--all")
|
||||
git(dest, "gc", "-q", "--prune=now")
|
||||
return base, head
|
||||
|
||||
|
||||
def rate_limit_reset(log):
|
||||
resets = [0]
|
||||
for line in log.read_text().splitlines():
|
||||
if '"status":"rejected"' in line:
|
||||
resets.append(json.loads(line)["rate_limit_info"]["resetsAt"])
|
||||
return max(resets)
|
||||
|
||||
|
||||
def run(name):
|
||||
case, version, _ = name.split("-")
|
||||
clone = BENCH / name
|
||||
report = BENCH / f"{name}.md"
|
||||
for attempt in range(1, ATTEMPTS + 1):
|
||||
if report.exists():
|
||||
return f"{name}: done"
|
||||
base, head = fresh_clone(case, clone)
|
||||
prompt = (BENCH / "run-prompt.md").read_text().format(
|
||||
version_dir=BENCH / "versions" / version, base=base, head=head, case=case, report=report)
|
||||
log = BENCH / "logs" / f"{name}.{attempt}.jsonl"
|
||||
log.parent.mkdir(exist_ok=True)
|
||||
with log.open("w") as out:
|
||||
subprocess.run(
|
||||
["claude", "-p", prompt, "--dangerously-skip-permissions", "--model", "claude-opus-5-5", "--output-format", "stream-json", "--verbose"],
|
||||
cwd=clone, stdout=out, stderr=subprocess.STDOUT)
|
||||
if report.exists():
|
||||
return f"{name}: done on attempt {attempt}"
|
||||
time.sleep(max(1200, rate_limit_reset(log) + 120 - time.time()))
|
||||
return f"{name}: FAILED after {ATTEMPTS} attempts"
|
||||
|
||||
|
||||
def main():
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=4) as pool:
|
||||
for result in pool.map(run, sys.argv[1:]):
|
||||
print(result, flush=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user