Grant the bench's runs only the tools a review needs, in place of skipping every permission
This commit is contained in:
+16
-2
@@ -33,6 +33,17 @@ CASES = {
|
||||
ATTEMPTS = 4
|
||||
|
||||
|
||||
def allowed_tools(clone, version_dir, report):
|
||||
"""The tools a review needs and the paths each reaches; anything else is denied, not asked."""
|
||||
agents = pathlib.Path.home() / ".claude" / "agents"
|
||||
# A rule names an absolute path as "//<path>", and "/**" takes a whole tree.
|
||||
reads = [f"/{root}/**" for root in (clone, version_dir, agents)]
|
||||
return [
|
||||
"Agent", "Skill(security-review)", "Bash(git *)", f"Edit(/{clone}/**)", f"Edit(/{report})",
|
||||
*(f"{tool}({tree})" for tool in ("Read", "Grep", "Glob") for tree in reads),
|
||||
]
|
||||
|
||||
|
||||
def git(repo, *args):
|
||||
return subprocess.run(["git", "-C", str(repo), *args], check=True, capture_output=True, text=True).stdout.strip()
|
||||
|
||||
@@ -73,13 +84,16 @@ def run(name):
|
||||
if report.exists():
|
||||
return f"{name}: done"
|
||||
base, head = fresh_clone(case, clone)
|
||||
version_dir = BENCH / "versions" / version
|
||||
prompt = (BENCH / "run-prompt.md").read_text().format(
|
||||
version_dir=BENCH / "versions" / version, base=base, head=head, case=case, report=report)
|
||||
version_dir=version_dir, 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"],
|
||||
["claude", "-p", prompt, "--permission-mode", "dontAsk", "--permission-prompts", "none",
|
||||
"--allowedTools", *allowed_tools(clone, version_dir, report),
|
||||
"--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}"
|
||||
|
||||
@@ -15,7 +15,7 @@ Report: write it to `{report}`.
|
||||
|
||||
- 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.
|
||||
- Do not run the repo's code or test suites: the shell is limited to git.
|
||||
- Skip the comprehension check; 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.
|
||||
|
||||
Reference in New Issue
Block a user