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()
|
||||
@@ -0,0 +1,23 @@
|
||||
You judge a bench of two code-review processes, A and B, on one real chunk of work. Each process reviewed the same chunk three times, independently: runs A1–A3 and B1–B3. Rule whether B reviews at least as well as A, and whether A reviews at least as well as B.
|
||||
|
||||
Everything is under `{dir}`; read nothing outside it:
|
||||
|
||||
- `truth-issues.md`: what the chunk's real review found and fixed, one row per issue.
|
||||
- `truth.diff`: the real review's fixes.
|
||||
- `<run>/report.md`: the run's own account of its passes, findings and outcomes. Its claims are not evidence.
|
||||
- `<run>/fixes.diff`: what the run actually changed. This is the evidence.
|
||||
|
||||
Judge each run on:
|
||||
|
||||
1. **Truth coverage**: for each truth issue, caught and fixed ✔, partly ◐, or missed ✘, checked against `fixes.diff`. A filed or declined issue with a sound reason counts ◐.
|
||||
2. **Other real defects**: a finding the truth lacks that is a real defect in the chunk, fixed or filed.
|
||||
3. **Damage**: a change that makes the chunk worse — a regression, a false claim written, a needless churn of lines outside the chunk.
|
||||
4. **Cost**: agents launched and rounds, from the report.
|
||||
|
||||
Then, per process, weigh the three runs together: what it catches reliably (two or more runs), what it catches by luck (one run), and its spread. A difference one run makes is variance, not the process.
|
||||
|
||||
Write your ruling to `{ruling}`:
|
||||
|
||||
1. A table per run: each truth issue's mark, other real defects, damage, cost.
|
||||
2. Per process: reliable catches, lucky catches, damage, cost range.
|
||||
3. **Ruling**: one line each — `B at least as good as A: yes|no` and `A at least as good as B: yes|no` — each followed by the decisive evidence, citing runs and diff lines. "No" needs a difference that holds across runs, not one run's miss.
|
||||
Executable
+74
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Blind-judge each case's six runs: judge.py <case> ..."""
|
||||
import concurrent.futures
|
||||
import json
|
||||
import pathlib
|
||||
import random
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import bench
|
||||
|
||||
BENCH = bench.BENCH
|
||||
TRUTH_END = {"cjk": "160c2a7", "35b": "a4b6b48", "brlan": "8f6e22d", "mypy": "628ee30"}
|
||||
PREFIX = {"cjk": "C", "35b": "B", "brlan": "R", "mypy": "M"}
|
||||
|
||||
|
||||
def runs(case, version):
|
||||
"""The version's first three runs as (report, clone), main's 2026-09-29 run last."""
|
||||
found = []
|
||||
for n in range(1, 4):
|
||||
report = BENCH / f"{case}-{version}-{n}.md"
|
||||
if report.exists():
|
||||
found.append((report, BENCH / f"{case}-{version}-{n}"))
|
||||
if version == "main":
|
||||
found.append((bench.SOURCES / f"{case}-main.md", bench.SOURCES / f"{case}-main"))
|
||||
return found[:3]
|
||||
|
||||
|
||||
def blind(text):
|
||||
return re.sub(r"\S*versions/(main|rebuild)\S*|\b(main|rebuild)\b(?=[`\s]*(process|version))", "VERSION_DIR", text)
|
||||
|
||||
|
||||
def prepare(case):
|
||||
folder = BENCH / "judge" / case
|
||||
if folder.exists():
|
||||
shutil.rmtree(folder)
|
||||
folder.mkdir(parents=True)
|
||||
source = bench.SOURCES / f"{case}-main"
|
||||
head = bench.git(source, "rev-parse", bench.CASES[case][1])
|
||||
(folder / "truth.diff").write_text(bench.git(source, "diff", head, TRUTH_END[case]) + "\n")
|
||||
rows = [line.split("|")[1:3] for line in (bench.SOURCES / "comparison.md").read_text().splitlines()
|
||||
if re.match(rf"\| {PREFIX[case]}\d+ \|", line)]
|
||||
(folder / "truth-issues.md").write_text("".join(f"-{i.strip()}: {t.strip()}\n" for i, t in rows))
|
||||
groups = ["main", "rebuild"]
|
||||
random.shuffle(groups)
|
||||
mapping = {}
|
||||
for label, version in zip("AB", groups):
|
||||
for n, (report, clone) in enumerate(runs(case, version), 1):
|
||||
run = folder / f"{label}{n}"
|
||||
run.mkdir()
|
||||
(run / "report.md").write_text(blind(report.read_text()))
|
||||
(run / "fixes.diff").write_text(bench.git(clone, "diff", head, "chunk") + "\n")
|
||||
mapping[f"{label}{n}"] = str(report)
|
||||
(BENCH / "judge" / f"{case}.mapping.json").write_text(json.dumps(mapping, indent="\t") + "\n")
|
||||
return folder
|
||||
|
||||
|
||||
def judge(case):
|
||||
folder = prepare(case)
|
||||
ruling = BENCH / "judge" / f"{case}.ruling.md"
|
||||
prompt = (BENCH / "judge-prompt.md").read_text().format(dir=folder, ruling=ruling)
|
||||
with (BENCH / "logs" / f"judge-{case}.jsonl").open("w") as out:
|
||||
subprocess.run(
|
||||
["claude", "-p", prompt, "--model", "claude-opus-5-5", "--allowedTools", "Read,Grep,Glob,Write", "--output-format", "stream-json", "--verbose"],
|
||||
cwd=folder, stdout=out, stderr=subprocess.STDOUT)
|
||||
return f"{case}: {'ruled' if ruling.exists() else 'FAILED'}"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=4) as pool:
|
||||
for result in pool.map(judge, sys.argv[1:]):
|
||||
print(result, flush=True)
|
||||
@@ -0,0 +1,31 @@
|
||||
You are one run of a bench comparing two versions of the larv-review process. Review the chunk in this repository (your working directory) exactly as the process below says, then write a report.
|
||||
|
||||
VERSION_DIR = {version_dir}
|
||||
Chunk: commits `{base}..chunk` on branch `chunk` (head at start: `{head}`). Case `{case}`.
|
||||
Report: write it to `{report}`.
|
||||
|
||||
## The process
|
||||
|
||||
- `VERSION_DIR/skills/larv-review/SKILL.md` is larv-review. Do not invoke the installed `larv-review` skill.
|
||||
- Wherever a text cites `~/.claude/<path>`, read `VERSION_DIR/<path>` instead. `VERSION_DIR/CLAUDE.md` replaces `~/.claude/CLAUDE.md`, which you already have loaded: where the two differ, VERSION_DIR's wins.
|
||||
- Launch every reviewer named `<name>` under `~/.claude/agents/` as a `general-purpose` agent whose prompt opens with the body of `VERSION_DIR/agents/<name>.md` (frontmatter dropped), then the task. A reviewer the process names that has no file there gets the process's own description of it as its prompt.
|
||||
- `/security-review`: use the Skill tool's `security-review` if it is available; otherwise emulate it with a `general-purpose` agent, told to review the branch diff for exploitable vulnerabilities and report only those at ≥0.8 confidence.
|
||||
|
||||
## Bench rules
|
||||
|
||||
- Launch every agent in the foreground (`run_in_background: false`): background agents die when this headless turn ends.
|
||||
- No remote and no forge: skip the PR, CI, the external auto-reviewer and the merge; review locally.
|
||||
- Do not run the repo's test suites. A targeted probe is fine, in the repo's own container tooling.
|
||||
- Skip the comprehension floor's scoring run; say so in the report.
|
||||
- No human is reachable. Where the process names a no-human branch, take it; where it names none, take your recommendation and list the question in the report.
|
||||
- Commit each round's fixes on `chunk`, messages prefixed `{case} - review: `. Touch nothing outside this repository except the report.
|
||||
|
||||
## Report
|
||||
|
||||
Sections, in order:
|
||||
|
||||
1. **Passes**: a table of each pass, run or skipped, and why.
|
||||
2. **Findings**: per pass and round, each finding's severity, location, one-line summary and outcome (fixed in `<sha>`, answered, declined, filed, disproved).
|
||||
3. **Questions for the human**: each ask you could not put, with your recommendation.
|
||||
4. **Totals**: agents launched per pass, rounds per pass, commits.
|
||||
5. **Ambiguities**: every place the process text was unclear, contradicted itself, or could not be followed, and how you read it.
|
||||
Reference in New Issue
Block a user