mirror of
https://github.com/aicodeking/leanrea.git
synced 2026-11-28 01:10:22 +08:00
feat: leanrea skill, README and REA benchmark harness
This commit is contained in:
commit
a07ed0ebf1
12 files changed
+473
No files matched your search
@@ -0,0 +1,79 @@
|
||||
# REA vs a lean skill: benchmark (2026-10-16)
|
||||
|
||||
Setup: Claude Code 2.1.301 headless (`claude -p`), Sonnet 5.5, macOS arm64. REA is rea-agents@6.5.0 (207 MCP tools, run as `rea --mcp`) plus its own skill (`/reverse-engineer-anything`). Every run starts in a fresh copy of the targets. Answers were graded by regex against answer keys I made by hand.
|
||||
|
||||
Arms:
|
||||
- **none**: no skill, no MCP.
|
||||
- **leanrea** (shown as `lean` in `results/final.jsonl`): `/leanrea`, the 8 KB `leanrea/SKILL.md`, no MCP.
|
||||
- **rea**: REA MCP plus the REA skill.
|
||||
|
||||
Tasks (3 reps per arm per task, 36 runs, arms run side by side):
|
||||
- **electron**: Notion app.asar. Trace mic/meeting detection: native fn, class, IPC channels.
|
||||
- **native**: mac_utils.node. Exports, the TCC check, the single-instance lock.
|
||||
- **go**: `gh`. Toolchain version, main path, two dependency versions.
|
||||
- **deep**: mac_utils.node, from the disassembly. Socket path format, wire protocol, peer authentication.
|
||||
|
||||
## Results (median wall time; means for turns, cost, tokens)
|
||||
|
||||
| task | arm | wall s | turns | cost $ | tokens k | score |
|
||||
|---|---|---|---|---|---|---|
|
||||
| electron | leanrea | **35.3** | **4.7** | **0.171** | **196** | 14/15 |
|
||||
| electron | none | 52.8 | 9.7 | 0.173 | 342 | 15/15 |
|
||||
| electron | rea | 82.9 | 13.3 | 0.341 | 725 | 15/15 |
|
||||
| native | leanrea | 43.4 | **5.3** | 0.201 | **239** | 24/24 |
|
||||
| native | none | **36.7** | 6.7 | **0.173** | 245 | 24/24 |
|
||||
| native | rea | 46.0 | 11.3 | 0.268 | 511 | 24/24 |
|
||||
| go | leanrea | **12.4** | 2.3 | 0.110 | 87 | 12/12 |
|
||||
| go | none | 13.8 | **2.0** | **0.092** | **67** | 12/12* |
|
||||
| go | rea | 25.9 | 6.0 | 0.171 | 233 | 12/12 |
|
||||
| deep | leanrea | **38.6** | **6.0** | **0.241** | **278** | 24/24 |
|
||||
| deep | none | 45.3 | 8.7 | 0.298 | 383 | 16/24 (1 refusal) |
|
||||
| deep | rea | 45.7 | 10.7 | 0.339 | 509 | 24/24 |
|
||||
|
||||
Totals over 12 runs per arm:
|
||||
|
||||
| arm | wall | cost | turns | tokens | score |
|
||||
|---|---|---|---|---|---|
|
||||
| **leanrea** | **388 s** | **$2.17** | **55** | **2.40 M** | 74/75 |
|
||||
| none | 479 s | $2.21 | 81 | 3.11 M | 67/75 |
|
||||
| rea | 627 s | $3.36 | 124 | 5.93 M | 75/75 |
|
||||
|
||||
\* One "none/go" answer wrote "Go 1.27.1" and the regex wanted "go1.27.1". That is a grader false negative, corrected above.
|
||||
|
||||
The lean skill against REA:
|
||||
- 38% less wall time.
|
||||
- 35% lower cost.
|
||||
- 56% fewer turns.
|
||||
- 60% fewer tokens.
|
||||
- Same accuracy. The lean skill's only miss: one run named the v1 change channel instead of the v2 one. Both channels exist.
|
||||
|
||||
The lean skill against no skill:
|
||||
- 19% faster, with 32% fewer turns and 23% fewer tokens.
|
||||
- Cost is the same.
|
||||
- It avoided the one refusal the bare model gave on the deep task.
|
||||
|
||||
## Context overhead ("Reply with exactly OK")
|
||||
|
||||
| config | context tokens | cost |
|
||||
|---|---|---|
|
||||
| nothing | 31.4k | $0.08 |
|
||||
| lean skill invoked | 34.5k (+3.1k) | $0.09 |
|
||||
| REA MCP, deferred tool search (CC default) | 34.9k (+3.5k) | $0.09 |
|
||||
| REA skill invoked + MCP | 42.7k (+11.3k) | $0.13 |
|
||||
| **REA MCP, tool search off (all tools loaded)** | **400.7k (+369k)** | **$1.60** |
|
||||
|
||||
REA's raw `tools/list`: 207 tools, 3.35 MB JSON (745 KB input schemas, 2.46 MB output schemas, 90 KB descriptions).
|
||||
|
||||
## Tool-level microbenchmark (same operation, same file)
|
||||
|
||||
| operation | REA CLI | raw command |
|
||||
|---|---|---|
|
||||
| Go build info, `gh` | 0.56 s, 62.5 KB | `go version -m`: 0.06 s, 15.6 KB |
|
||||
| Mach-O overview, mac_utils.node | 3.32 s, 52.8 KB | otool/dyld_info/nm: 0.04 s, 28.3 KB |
|
||||
| Electron app analysis, Notion | fails `artifact_integrity_mismatch` unless you add `--integrity-policy record-and-continue`; then **47.9 s, 140 MB** | asar extract + `rg -uu` IPC sweep: 4.8 s, 24 KB |
|
||||
|
||||
## Caveats
|
||||
- n=3 per cell, one model (Sonnet), one machine, three targets. The REA arm used Claude Code's deferred tool search, which is REA's best case. Agents that load every tool pay the 369k-token row above.
|
||||
- Native providers (Ghidra, Hopper, IDA) are not installed, so REA used its built-in native path. The lean arm used otool.
|
||||
|
||||
Reproduce: `./setup.sh`, then `./run_all.sh` (or `python3 -I run.py <none|leanrea|rea> <task> <rep>`) and `./ctx.sh`.
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
# Context overhead probe: one "Reply with exactly OK." per config; prints total context tokens and cost.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"; W="${LEANREA_WORK:-$PWD/work}"; C="$W/ctx"; MODEL="${BENCH_MODEL:-sonnet}"
|
||||
mkdir -p "$C/none" "$C/leanrea/.claude/skills" "$C/rea/.claude/skills"
|
||||
cp -R ../leanrea "$C/leanrea/.claude/skills/"
|
||||
cp -R "$W/rea-install/node_modules/rea-agents/skills/reverse-engineer-anything" "$C/rea/.claude/skills/"
|
||||
probe() { local dir=$1 prompt=$2; shift 2
|
||||
(cd "$C/$dir" && echo "$prompt" | claude -p --model "$MODEL" --output-format json --strict-mcp-config --no-session-persistence "$@" \
|
||||
| jq -c '{cost: .total_cost_usd, ctx_tokens: (.usage.input_tokens + .usage.cache_creation_input_tokens + .usage.cache_read_input_tokens)}'); }
|
||||
echo -n "nothing: "; probe none "Reply with exactly OK."
|
||||
echo -n "leanrea skill invoked: "; probe leanrea "/leanrea Reply with exactly OK."
|
||||
echo -n "REA skill + MCP: "; probe rea "/reverse-engineer-anything Reply with exactly OK." --mcp-config "$W/rea-mcp.json"
|
||||
echo -n "REA MCP, tool search auto: "; probe rea "Reply with exactly OK." --mcp-config "$W/rea-mcp.json"
|
||||
echo -n "REA MCP, tool search OFF: "; ENABLE_TOOL_SEARCH=false probe rea "Reply with exactly OK." --mcp-config "$W/rea-mcp.json"
|
||||
@@ -0,0 +1,25 @@
|
||||
"""Dump an MCP server's tools/list and size it: python3 mcp_list.py node .../rea.mjs --mcp (writes rea_tools.json)"""
|
||||
import json, subprocess, sys, time
|
||||
cmd = sys.argv[1:]
|
||||
t0 = time.time()
|
||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True)
|
||||
def send(o): p.stdin.write(json.dumps(o)+"\n"); p.stdin.flush()
|
||||
def recv(want):
|
||||
while True:
|
||||
l = p.stdout.readline()
|
||||
if not l: raise SystemExit("eof")
|
||||
m = json.loads(l)
|
||||
if m.get("id") == want: return m
|
||||
send({"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"b","version":"1"}}})
|
||||
init = recv(1); t1 = time.time()
|
||||
send({"jsonrpc":"2.0","method":"notifications/initialized"})
|
||||
tools, cur, i = [], None, 2
|
||||
while True:
|
||||
send({"jsonrpc":"2.0","id":i,"method":"tools/list","params":({"cursor":cur} if cur else {})})
|
||||
r = recv(i)["result"]; tools += r["tools"]; cur = r.get("nextCursor"); i += 1
|
||||
if not cur: break
|
||||
t2 = time.time(); p.kill()
|
||||
instr = init["result"].get("instructions") or ""
|
||||
blob = json.dumps(tools)
|
||||
json.dump({"tools": tools, "instructions": instr}, open("rea_tools.json", "w"))
|
||||
print(f"tools={len(tools)} defs_bytes={len(blob)} input_schema_bytes={len(json.dumps([t.get('inputSchema') for t in tools]))} output_schema_bytes={len(json.dumps([t.get('outputSchema') for t in tools if t.get('outputSchema')]))} desc_bytes={sum(len(t.get('description','')) for t in tools)} instructions_bytes={len(instr)} startup_s={t1-t0:.2f} list_s={t2-t1:.2f}")
|
||||
@@ -0,0 +1,36 @@
|
||||
{"arm": "lean", "task": "electron", "rep": "11", "wall_s": 35.3, "turns": 4, "cost": 0.17429050000000001, "in": 8, "cache_w": 34522, "cache_r": 132465, "out": 2294, "score": "5/5", "miss": [], "err": false, "tools": ["Bash:cd", "Bash:cd", "Bash:cd"]}
|
||||
{"arm": "rea", "task": "electron", "rep": "11", "wall_s": 47.5, "turns": 12, "cost": 0.3422452, "in": 20, "cache_w": 62547, "cache_r": 621872, "out": 2983, "score": "5/5", "miss": [], "err": false, "tools": ["ToolSearch", "Bash:ls", "mcp__rea__analyze_javascript_application", "Bash:cd", "Bash:cd", "Bash:ls", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd"]}
|
||||
{"arm": "none", "task": "electron", "rep": "11", "wall_s": 97.6, "turns": 9, "cost": 0.1600189, "in": 18, "cache_w": 26580, "cache_r": 298229, "out": 2384, "score": "5/5", "miss": [], "err": false, "tools": ["Bash:ls", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd"]}
|
||||
{"arm": "lean", "task": "native", "rep": "11", "wall_s": 44.1, "turns": 7, "cost": 0.2132568, "in": 14, "cache_w": 36080, "cache_r": 274788, "out": 4143, "score": "8/8", "miss": [], "err": false, "tools": ["Bash:T=./mac_utils.node;", "Bash:T=./mac_utils.node;", "Bash:T=./mac_utils.node;", "Bash:D=$TMPDIR/re/mac_utils;", "Bash:D=$TMPDIR/re/mac_utils;", "Bash:D=$TMPDIR/re/mac_utils;"]}
|
||||
{"arm": "none", "task": "native", "rep": "11", "wall_s": 44.5, "turns": 8, "cost": 0.1881618, "in": 14, "cache_w": 33452, "cache_r": 237658, "out": 3056, "score": "8/8", "miss": [], "err": false, "tools": ["Bash:ls", "Bash:strings", "Bash:D=$(otool", "Bash:strings", "Bash:otool", "Bash:sed", "Bash:sed"]}
|
||||
{"arm": "rea", "task": "native", "rep": "11", "wall_s": 46.0, "turns": 12, "cost": 0.2676244, "in": 20, "cache_w": 47355, "cache_r": 472244, "out": 3094, "score": "8/8", "miss": [], "err": false, "tools": ["Bash:ls", "ToolSearch", "mcp__rea__open_binary", "Bash:strings", "Bash:strings", "Bash:strings", "mcp__rea__search_strings", "mcp__rea__search_strings", "Bash:which", "Bash:sed", "Bash:sed"]}
|
||||
{"arm": "lean", "task": "go", "rep": "11", "wall_s": 10.4, "turns": 2, "cost": 0.1072636, "in": 4, "cache_w": 24806, "cache_r": 49716, "out": 306, "score": "4/4", "miss": [], "err": false, "tools": ["Bash:cd"]}
|
||||
{"arm": "none", "task": "go", "rep": "11", "wall_s": 13.8, "turns": 2, "cost": 0.0924126, "in": 4, "cache_w": 21206, "cache_r": 45706, "out": 301, "score": "4/4", "miss": [], "err": false, "tools": ["Bash:ls"]}
|
||||
{"arm": "rea", "task": "go", "rep": "11", "wall_s": 25.9, "turns": 6, "cost": 0.17320800000000003, "in": 10, "cache_w": 35383, "cache_r": 196360, "out": 1202, "score": "4/4", "miss": [], "err": false, "tools": ["ToolSearch", "Bash:ls", "mcp__rea__inspect_go_binary", "Bash:jq", "Bash:jq"]}
|
||||
{"arm": "lean", "task": "deep", "rep": "11", "wall_s": 38.0, "turns": 6, "cost": 0.23191330000000002, "in": 12, "cache_w": 43454, "cache_r": 238233, "out": 3425, "score": "8/8", "miss": [], "err": false, "tools": ["Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd"]}
|
||||
{"arm": "rea", "task": "deep", "rep": "11", "wall_s": 44.8, "turns": 11, "cost": 0.3438066, "in": 18, "cache_w": 66559, "cache_r": 463146, "out": 3122, "score": "8/8", "miss": [], "err": false, "tools": ["ToolSearch", "Bash:ls", "mcp__rea__open_binary", "Bash:strings", "mcp__rea__search_procedures", "Bash:which", "Bash:otool", "Bash:cd", "Bash:cd", "Bash:cd"]}
|
||||
{"arm": "none", "task": "deep", "rep": "11", "wall_s": 45.3, "turns": 10, "cost": 0.26775269999999995, "in": 18, "cache_w": 49379, "cache_r": 368807, "out": 3332, "score": "8/8", "miss": [], "err": false, "tools": ["Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:sed", "Bash:sed", "Bash:sed", "Bash:sed"]}
|
||||
{"arm": "lean", "task": "electron", "rep": "12", "wall_s": 30.1, "turns": 4, "cost": 0.1624606, "in": 8, "cache_w": 32018, "cache_r": 132526, "out": 2112, "score": "5/5", "miss": [], "err": false, "tools": ["Bash:cd", "Bash:X=$TMPDIR/re/asar;", "Bash:X=$TMPDIR/re/asar;"]}
|
||||
{"arm": "none", "task": "electron", "rep": "12", "wall_s": 48.1, "turns": 10, "cost": 0.1847057, "in": 20, "cache_w": 30214, "cache_r": 337497, "out": 3006, "score": "5/5", "miss": [], "err": false, "tools": ["Bash:ls", "Bash:cd", "Grep", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd"]}
|
||||
{"arm": "rea", "task": "electron", "rep": "12", "wall_s": 82.9, "turns": 15, "cost": 0.2847268, "in": 28, "cache_w": 45563, "cache_r": 680188, "out": 3440, "score": "5/5", "miss": [], "err": false, "tools": ["ToolSearch", "Bash:ls", "Bash:find", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd"]}
|
||||
{"arm": "none", "task": "native", "rep": "12", "wall_s": 36.7, "turns": 5, "cost": 0.1378211, "in": 10, "cache_w": 24496, "cache_r": 151771, "out": 2464, "score": "8/8", "miss": [], "err": false, "tools": ["Bash:ls", "Bash:strings", "Bash:strings", "Bash:strings"]}
|
||||
{"arm": "lean", "task": "native", "rep": "12", "wall_s": 43.4, "turns": 5, "cost": 0.20968940000000003, "in": 10, "cache_w": 38990, "cache_r": 188094, "out": 3490, "score": "8/8", "miss": [], "err": false, "tools": ["Bash:T=$(ls", "Bash:T=<work>/runs/lean-native-12/mac_", "Bash:D=$TMPDIR/re/mac_utils;", "Bash:D=$TMPDIR/re/mac_utils;"]}
|
||||
{"arm": "rea", "task": "native", "rep": "12", "wall_s": 67.3, "turns": 14, "cost": 0.2931939, "in": 24, "cache_w": 47502, "cache_r": 595779, "out": 4356, "score": "8/8", "miss": [], "err": false, "tools": ["Bash:ls", "ToolSearch", "mcp__rea__open_binary", "Bash:strings", "mcp__rea__search_procedures", "Bash:which", "Bash:strings", "Bash:nm", "Bash:cd", "Bash:cd", "Bash:strings", "Bash:cd", "Bash:cd"]}
|
||||
{"arm": "none", "task": "go", "rep": "12", "wall_s": 18.3, "turns": 2, "cost": 0.09197860000000001, "in": 4, "cache_w": 20900, "cache_r": 45706, "out": 380, "score": "3/4", "miss": ["go ver"], "err": false, "tools": ["Bash:ls"]}
|
||||
{"arm": "lean", "task": "go", "rep": "12", "wall_s": 19.7, "turns": 2, "cost": 0.1073856, "in": 4, "cache_w": 24819, "cache_r": 49716, "out": 313, "score": "4/4", "miss": [], "err": false, "tools": ["Bash:cd"]}
|
||||
{"arm": "rea", "task": "go", "rep": "12", "wall_s": 30.0, "turns": 6, "cost": 0.16971640000000002, "in": 10, "cache_w": 34922, "cache_r": 196284, "out": 1038, "score": "4/4", "miss": [], "err": false, "tools": ["ToolSearch", "Bash:ls", "mcp__rea__inspect_go_binary", "Bash:jq", "Bash:f=~/.claude/projects/-private-tmp-claude-501-rea-b"]}
|
||||
{"arm": "none", "task": "deep", "rep": "12", "wall_s": 26.9, "turns": 5, "cost": 0.2619723, "in": 8, "cache_w": 59919, "cache_r": 79534, "out": 961, "score": "0/8", "miss": ["prefix", "euid", "hash", "exe", "sock", "len", "peer", "json"], "err": false, "tools": ["Bash:ls", "Bash:which", "Bash:otool"]}
|
||||
{"arm": "lean", "task": "deep", "rep": "12", "wall_s": 43.0, "turns": 6, "cost": 0.23992989999999997, "in": 12, "cache_w": 45380, "cache_r": 253059, "out": 3308, "score": "8/8", "miss": [], "err": false, "tools": ["Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd"]}
|
||||
{"arm": "rea", "task": "deep", "rep": "12", "wall_s": 45.7, "turns": 9, "cost": 0.35485500000000003, "in": 14, "cache_w": 71188, "cache_r": 348550, "out": 3522, "score": "8/8", "miss": [], "err": false, "tools": ["Bash:ls", "ToolSearch", "mcp__rea__open_binary", "Bash:cd", "mcp__rea__search_procedures", "Bash:cd", "Bash:cd", "Bash:cd"]}
|
||||
{"arm": "lean", "task": "electron", "rep": "13", "wall_s": 41.1, "turns": 6, "cost": 0.17774530000000005, "in": 12, "cache_w": 32583, "cache_r": 216093, "out": 2578, "score": "4/5", "miss": ["event ch"], "err": false, "tools": ["Bash:A=./app.asar;", "Bash:X=$TMPDIR/re/asar;", "Bash:X=$TMPDIR/re/asar;", "Bash:X=$TMPDIR/re/asar;", "Bash:X=$TMPDIR/re/asar;"]}
|
||||
{"arm": "none", "task": "electron", "rep": "13", "wall_s": 52.8, "turns": 10, "cost": 0.1738069, "in": 18, "cache_w": 29737, "cache_r": 296429, "out": 2518, "score": "5/5", "miss": [], "err": false, "tools": ["Bash:ls", "Bash:mkdir", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd"]}
|
||||
{"arm": "rea", "task": "electron", "rep": "13", "wall_s": 122.4, "turns": 13, "cost": 0.3970981, "in": 20, "cache_w": 72637, "cache_r": 681901, "out": 3832, "score": "5/5", "miss": [], "err": false, "tools": ["ToolSearch", "Bash:ls", "mcp__rea__analyze_javascript_application", "Bash:find", "mcp__rea__analyze_javascript_application", "Bash:grep", "Bash:grep", "Bash:grep", "Bash:python3", "Bash:python3", "Bash:python3", "Bash:python3"]}
|
||||
{"arm": "lean", "task": "native", "rep": "13", "wall_s": 31.6, "turns": 4, "cost": 0.17991970000000002, "in": 8, "cache_w": 34204, "cache_r": 134877, "out": 2960, "score": "8/8", "miss": [], "err": false, "tools": ["Bash:T=./mac_utils.node;", "Bash:T=./mac_utils.node;", "Bash:T=./mac_utils.node;"]}
|
||||
{"arm": "none", "task": "native", "rep": "13", "wall_s": 34.7, "turns": 7, "cost": 0.19220610000000002, "in": 14, "cache_w": 34340, "cache_r": 243481, "out": 3047, "score": "8/8", "miss": [], "err": false, "tools": ["Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd"]}
|
||||
{"arm": "rea", "task": "native", "rep": "13", "wall_s": 38.1, "turns": 8, "cost": 0.24213279999999998, "in": 14, "cache_w": 45215, "cache_r": 313348, "out": 2991, "score": "8/8", "miss": [], "err": false, "tools": ["Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd"]}
|
||||
{"arm": "none", "task": "go", "rep": "13", "wall_s": 11.1, "turns": 2, "cost": 0.0923706, "in": 4, "cache_w": 21098, "cache_r": 45706, "out": 340, "score": "4/4", "miss": [], "err": false, "tools": ["Bash:ls"]}
|
||||
{"arm": "lean", "task": "go", "rep": "13", "wall_s": 12.4, "turns": 3, "cost": 0.114097, "in": 6, "cache_w": 25135, "cache_r": 87150, "out": 483, "score": "4/4", "miss": [], "err": false, "tools": ["Bash:cd", "Bash:cd"]}
|
||||
{"arm": "rea", "task": "go", "rep": "13", "wall_s": 22.7, "turns": 6, "cost": 0.1706506, "in": 10, "cache_w": 35153, "cache_r": 196386, "out": 1038, "score": "4/4", "miss": [], "err": false, "tools": ["ToolSearch", "Bash:ls", "mcp__rea__inspect_go_binary", "Bash:f=~/.claude/projects/-private-tmp-claude-501-rea-b", "Bash:f=~/.claude/projects/-private-tmp-claude-501-rea-b"]}
|
||||
{"arm": "lean", "task": "deep", "rep": "13", "wall_s": 38.6, "turns": 6, "cost": 0.2502242, "in": 10, "cache_w": 49379, "cache_r": 194882, "out": 3320, "score": "8/8", "miss": [], "err": false, "tools": ["Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd"]}
|
||||
{"arm": "none", "task": "deep", "rep": "13", "wall_s": 49.0, "turns": 11, "cost": 0.3640726, "in": 20, "cache_w": 68395, "cache_r": 514726, "out": 3898, "score": "8/8", "miss": [], "err": false, "tools": ["Bash:cd", "Bash:cd", "Bash:cd", "Bash:cd", "Bash:sed", "Bash:sed", "Bash:sed", "Bash:cd", "Bash:cd", "Bash:cd"]}
|
||||
{"arm": "rea", "task": "deep", "rep": "13", "wall_s": 54.1, "turns": 12, "cost": 0.317392, "in": 20, "cache_w": 57839, "cache_r": 508760, "out": 3512, "score": "8/8", "miss": [], "err": false, "tools": ["Bash:ls", "ToolSearch", "mcp__rea__open_binary", "mcp__rea__search_strings", "Bash:which", "Bash:otool", "Bash:sed", "Bash:sed", "Bash:sed", "Bash:sed", "Bash:sed"]}
|
||||
@@ -0,0 +1,51 @@
|
||||
"""Run one benchmark cell: python3 -I run.py <arm> <task_id> <rep>. Arms: rea | leanrea | none.
|
||||
Needs ./setup.sh first. Work dir: $LEANREA_WORK (default ./work)."""
|
||||
import json, os, re, shutil, subprocess, sys, time
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
REPO = os.path.dirname(HERE)
|
||||
B = os.path.abspath(os.environ.get("LEANREA_WORK", os.path.join(HERE, "work")))
|
||||
ARM, TID, REP = sys.argv[1], sys.argv[2], sys.argv[3]
|
||||
MODEL = os.environ.get("BENCH_MODEL", "sonnet")
|
||||
task = next(t for t in json.load(open(f"{HERE}/tasks.json")) if t["id"] == TID)
|
||||
ws = f"{B}/runs/{ARM}-{TID}-{REP}"
|
||||
shutil.rmtree(ws, ignore_errors=True); os.makedirs(ws)
|
||||
for f in ["app.asar", "mac_utils.node", "gh"]:
|
||||
subprocess.run(["cp", "-c", f"{B}/targets/{f}", ws], check=True)
|
||||
subprocess.run(["cp", "-cR", f"{B}/targets/app.asar.unpacked", ws], check=True)
|
||||
cmd = ["claude", "-p", "--model", MODEL, "--output-format", "stream-json", "--verbose", "--strict-mcp-config",
|
||||
"--no-session-persistence", "--max-budget-usd", "4",
|
||||
"--allowedTools", "Bash,Read,Grep,Glob,Write,Skill,mcp__rea"]
|
||||
prompt = task["prompt"]
|
||||
skills = os.path.join(ws, ".claude", "skills")
|
||||
if ARM == "rea":
|
||||
shutil.copytree(f"{B}/rea-install/node_modules/rea-agents/skills/reverse-engineer-anything", f"{skills}/reverse-engineer-anything")
|
||||
cmd += ["--mcp-config", f"{B}/rea-mcp.json"]
|
||||
prompt = "/reverse-engineer-anything " + prompt
|
||||
elif ARM == "leanrea":
|
||||
shutil.copytree(f"{REPO}/leanrea", f"{skills}/leanrea")
|
||||
prompt = "/leanrea " + prompt
|
||||
t0 = time.time()
|
||||
p = subprocess.run(cmd, input=prompt, cwd=ws, capture_output=True, text=True, timeout=1500)
|
||||
wall = time.time() - t0
|
||||
r, tools = {"result": p.stdout[-2000:] + p.stderr[-2000:], "is_error": True}, []
|
||||
for line in p.stdout.splitlines():
|
||||
try:
|
||||
ev = json.loads(line)
|
||||
except Exception:
|
||||
continue
|
||||
if ev.get("type") == "result":
|
||||
r = ev
|
||||
if ev.get("type") == "assistant":
|
||||
for c in ev["message"].get("content", []):
|
||||
if c.get("type") == "tool_use":
|
||||
n = c["name"]
|
||||
tools.append(n if n != "Bash" else "Bash:" + c["input"].get("command", "")[:60].split()[0] if c["input"].get("command") else n)
|
||||
ans = r.get("result") or ""
|
||||
hits = {k: bool(re.search(v, ans, re.I)) for k, v in task["key"].items()}
|
||||
u = r.get("usage", {})
|
||||
row = {"arm": ARM, "task": TID, "rep": REP, "wall_s": round(wall, 1), "turns": r.get("num_turns"),
|
||||
"cost": r.get("total_cost_usd"), "in": u.get("input_tokens", 0), "cache_w": u.get("cache_creation_input_tokens", 0),
|
||||
"cache_r": u.get("cache_read_input_tokens", 0), "out": u.get("output_tokens", 0),
|
||||
"score": f"{sum(hits.values())}/{len(hits)}", "miss": [k for k, v in hits.items() if not v], "err": r.get("is_error"), "tools": tools}
|
||||
json.dump({**row, "answer": ans}, open(f"{ws}.json", "w"), indent=1)
|
||||
print(json.dumps(row))
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Full benchmark: 3 arms x 4 tasks x REPS reps, arms run side by side. Appends to results/run.jsonl.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"; REPS="${REPS:-3}"
|
||||
for r in $(seq 1 "$REPS"); do for t in electron native go deep; do
|
||||
for a in none leanrea rea; do python3 -I run.py "$a" "$t" "$r" & done; wait
|
||||
done; done | tee -a results/run.jsonl
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
# Prepares bench/work: installs rea-agents@6.5.0 and copies the three targets.
|
||||
# Targets (macOS): Notion.app's app.asar + mac_utils.node, and Homebrew's gh.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
W="${LEANREA_WORK:-$PWD/work}"; mkdir -p "$W/targets" "$W/rea-install"
|
||||
NOTION=/Applications/Notion.app/Contents/Resources
|
||||
GH="$(command -v gh)"
|
||||
[ -f "$NOTION/app.asar" ] || { echo "Notion.app not found"; exit 1; }
|
||||
[ -n "$GH" ] || { echo "gh not found (brew install gh)"; exit 1; }
|
||||
cp "$NOTION/app.asar" "$W/targets/"
|
||||
cp -R "$NOTION/app.asar.unpacked" "$W/targets/"
|
||||
cp "$(find "$NOTION/app.asar.unpacked" -name mac_utils.node | head -1)" "$W/targets/"
|
||||
cp "$GH" "$W/targets/gh"
|
||||
(cd "$W/rea-install" && npm init -y >/dev/null && npm install rea-agents@6.5.0 --ignore-scripts >/dev/null)
|
||||
node -e 'const [,p,o]=process.argv;require("fs").writeFileSync(o,JSON.stringify({mcpServers:{rea:{command:"node",args:[p,"--mcp"]}}}))' "$W/rea-install/node_modules/rea-agents/scripts/rea.mjs" "$W/rea-mcp.json"
|
||||
echo "ready: $W"
|
||||
echo "NOTE: answer keys in tasks.json match Notion 7.35.1 and gh built with go1.27.1; other versions need new keys."
|
||||
@@ -0,0 +1,51 @@
|
||||
[
|
||||
{
|
||||
"id": "electron",
|
||||
"prompt": "app.asar in this folder is the Notion desktop app (Electron). Find out how Notion detects that another app is using the microphone (meeting detection). Report: (1) the native module file and the native function(s) it calls, (2) the main-process class that drives detection and its two modes, (3) the IPC channel a renderer sends to START detection, (4) the IPC channel main broadcasts when the process list changes. Keep the answer short; cite file paths.",
|
||||
"key": {
|
||||
"native fn": "getRunningInputAudioProcesses",
|
||||
"module": "mac_utils",
|
||||
"class": "AudioController",
|
||||
"start ch": "notion:initialize-running-input-audio-process-detection",
|
||||
"event ch": "notion:running-input-audio-processes-changed-v2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "native",
|
||||
"prompt": "mac_utils.node in this folder is a macOS Node native addon from a desktop app. Report: (1) every JS-callable function name it exports, (2) exactly how checkAudioCaptureAccess decides the permission state (framework, function, service name), (3) how requestSingleInstanceLock works (mechanism and filesystem path). Keep the answer short.",
|
||||
"key": {
|
||||
"TCC fw": "TCC\\.framework|TCC framework",
|
||||
"preflight": "TCCAccessPreflight",
|
||||
"service": "kTCCServiceAudioCapture",
|
||||
"socket": "(unix|domain|AF_UNIX|local) ?(domain )?socket",
|
||||
"path": "/tmp/com\\.notion\\.singleinstance",
|
||||
"fn1": "isWindowOccluded",
|
||||
"fn2": "getProcessesAccessingSpeakersWithResult",
|
||||
"fn3": "isSchemeHandlerPresent"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "go",
|
||||
"prompt": "gh in this folder is a compiled binary. Without running it, report: the language/toolchain version it was built with, its main package path, and the exact versions of the dependencies github.com/cli/go-gh/v2 and golang.org/x/crypto. Keep the answer short.",
|
||||
"key": {
|
||||
"go ver": "go1\\.27\\.1",
|
||||
"path": "github\\.com/cli/cli/v2/cmd/gh",
|
||||
"go-gh": "v2\\.16\\.1",
|
||||
"crypto": "v0\\.57\\.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "deep",
|
||||
"prompt": "mac_utils.node in this folder is a macOS Node native addon. Reverse engineer its single-instance lock (requestSingleInstanceLock) precisely from the binary: (1) the exact socket path format and what each variable part is computed from, (2) the wire protocol a second instance uses to send its data, (3) how the first instance authenticates the connecting peer. Keep the answer short.",
|
||||
"key": {
|
||||
"prefix": "/tmp/com\\.notion\\.singleinstance\\.",
|
||||
"euid": "geteuid|effective (user|uid)|euid",
|
||||
"hash": "hash",
|
||||
"exe": "proc_pidpath|executable('s)? path|exe(cutable)? path|binary path",
|
||||
"sock": "\\.sock",
|
||||
"len": "length[- ]prefix|4[- ]byte|uint32|size prefix|length header",
|
||||
"peer": "getpeereid",
|
||||
"json": "JSON"
|
||||
}
|
||||
}
|
||||
]
|
||||
Reference in new issue
Block a user