Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

feat(evals): OpenCode + dsh harnesses and an in-house PR suite

Cursor Agent6d7dca8b83da
diff --git a/graff-evals/README.md b/graff-evals/README.md
index e6538af6..dff41d67 100644
--- a/graff-evals/README.md
+++ b/graff-evals/README.md
@@ -21,10 +21,12 @@ harness under test spends model calls.
| `rlm` | scatter-gather / multi-file reads (where default rlm can overlap) |
| `swe` | DeepSWE-shaped multi-file bugfixes, distilled from [deepswe.datacurve.ai/run](https://deepswe.datacurve.ai/run) (no Harbor/Docker) |
| `mcp` | Linear-shaped fixture MCP (Blacksmith code-mode + muscle memory). Always `--no-lean` (`graff-dev-nolean`): lean is a different catalog and is not on the front. |
+| `inhouse` | Bug shapes distilled from shipped CodeGraff PRs (symlink write, oneshot chrome, cache git-root, stall widen/warn, empty catalog). Self-contained fixtures — not the live repo. Opt-in like `mcp`. |
```sh
./run.py --suite swe --harness graff-dev-old,graff-dev --model grok-4.6 -j 12
./run.py --suite core,rlm,swe --harness graff-dev-old,graff-dev -j 8
+./run.py --suite inhouse --harness graff-dev,grok,opencode --model grok-4.6 -j 1
```
## Run it
@@ -52,9 +54,30 @@ zig build && ./run.py --harness graff-dev
```
Results land in `results/run-<stamp>.jsonl` (one record per run) plus a
-summary table on stdout. `.sandboxes/` holds the materialized working dirs of
+summary table on stdout. The `usd` / `list$` column is **xAI list price**
+from tokens (and hosted-tool invocations when reported), not SuperGrok's
+`$0.0000` subscription footer. grok-4.6 uses the dual band
+`$2/$0.50/$6` under 200k prompt tokens and `$4/$1/$12` for the whole
+request at or above. `.sandboxes/` holds the materialized working dirs of
the last run for post-mortems; both are disposable.
+## Hillclimb
+
+`hillclimb.py` is the autoresearch-style loop: propose a harness change
+(see `hillclimb/candidates.json`), run the same tasks against the
+champion and grok-build, keep only a measured win on wall / first-token
+latency / tool calls / tokens / list-price USD. It will not keep
+grok-build's heap or a 4-tool catalog (ADR 0024). First keep:
+`GRAFF_XAI_X_SEARCH=0` on `graff` / `graff-dev` (live table in
+`hillclimb/baseline.md`).
+
+```sh
+./hillclimb.py self-test
+./hillclimb.py score results/run-20260828-021606.jsonl
+./hillclimb.py iterate --suite core --task exact-reply,fix-fib,file-ops
+./hillclimb/plot_frontier.py results/run-….jsonl -o hillclimb/frontier.svg
+```
+
## Harnesses
`harnesses.json` declares each harness as a command template plus parsers:
@@ -68,6 +91,11 @@ the last run for post-mortems; both are disposable.
Add a harness by adding an entry; add a model by passing `--model`.
+Same-model grok-4.6 series: `graff-dev`, `grok`, `opencode` (needs xAI
+auth), `dsh-grok` (needs `dsh` + an xAI key dsh will accept). Mixed-model
+native defaults — `opencode-zen`, `dsh-deepseek` — are a **different
+comparison**; do not read them as grok-4.6 list-price points.
+
## Tasks
Tasks span instruction-following, debugging, shell, data (JSON/CSV), text
diff --git a/graff-evals/dsh-grok.yml b/graff-evals/dsh-grok.yml
new file mode 100644
index 00000000..402979c3
--- /dev/null
+++ b/graff-evals/dsh-grok.yml
@@ -0,0 +1,11 @@
+# graff-evals overlay: retarget dsh at xAI grok-4.6 for a same-model harness compare.
+# dsh has no --model flag; this layer is the knob. Native default stays dsh-deepseek.
+- id: agent-default-model
+ config:
+ provider: xai
+ model: grok-4.6
+- id: llm-pi-ai
+ config:
+ providers:
+ xai:
+ apiKeyEnv: XAI_API_KEY
diff --git a/graff-evals/fixtures/atomic-symlink-write/SPEC.md b/graff-evals/fixtures/atomic-symlink-write/SPEC.md
new file mode 100644
index 00000000..e258ed33
--- /dev/null
+++ b/graff-evals/fixtures/atomic-symlink-write/SPEC.md
@@ -0,0 +1,19 @@
+# Atomic write through a symlink (CodeGraff #685 / #405, distilled)
+
+`atomic_write.py` must expose `replace_file(path, data)`.
+
+`data` is `str` or `bytes`. The function writes a temp file in the *target's*
+directory, then renames it into place so a reader sees the whole old file or
+the whole new file — never a truncate.
+
+When `path` is a symlink (or a chain of symlinks):
+
+- The named path **stays a symlink**. Do not replace the link with a regular file.
+- The write lands on the **final referent**.
+- Relative targets are anchored to each link's directory. Do not lexically
+ collapse `..` before walking; a `..` after a symlink must traverse the
+ symlink first.
+- A dangling final target: create that file, leave the symlink in place.
+- A cycle (A→B→A) raises `OSError` / `ValueError` and changes neither link.
+
+A non-symlink path is a normal atomic replace of that file.
diff --git a/graff-evals/fixtures/atomic-symlink-write/atomic_write.py b/graff-evals/fixtures/atomic-symlink-write/atomic_write.py
new file mode 100644
index 00000000..da900dac
--- /dev/null
+++ b/graff-evals/fixtures/atomic-symlink-write/atomic_write.py
@@ -0,0 +1,24 @@
+"""Atomic file replace — incomplete. Fix the SPEC.md contract."""
+import os
+import tempfile
+
+
+def replace_file(path, data):
+ raw = data if isinstance(data, bytes) else data.encode()
+ dest = os.path.abspath(path)
+ directory = os.path.dirname(dest) or "."
+ fd, tmp = tempfile.mkstemp(prefix=".replace-", dir=directory)
+ try:
+ os.write(fd, raw)
+ os.close(fd)
+ fd = None
+ # BUG: rename replaces a symlink entry instead of its referent.
+ os.replace(tmp, dest)
+ except Exception:
+ if fd is not None:
+ os.close(fd)
+ try:
+ os.remove(tmp)
+ except OSError:
+ pass
+ raise
diff --git a/graff-evals/fixtures/atomic-symlink-write/test_atomic_write.py b/graff-evals/fixtures/atomic-symlink-write/test_atomic_write.py
new file mode 100644
index 00000000..dd17b65e
--- /dev/null
+++ b/graff-evals/fixtures/atomic-symlink-write/test_atomic_write.py
@@ -0,0 +1,34 @@
+import os
+import tempfile
+
+from atomic_write import replace_file
+
+
+def test_plain_file():
+ with tempfile.TemporaryDirectory() as td:
+ path = os.path.join(td, "cred.json")
+ with open(path, "w") as f:
+ f.write('{"old":1}')
+ replace_file(path, '{"new":2}')
+ assert open(path).read() == '{"new":2}'
+ assert not os.path.islink(path)
+
+
+def test_relative_symlink_keeps_link():
+ with tempfile.TemporaryDirectory() as td:
+ real = os.path.join(td, "real.json")
+ link = os.path.join(td, "settings.json")
+ with open(real, "w") as f:
+ f.write('{"old":1}')
+ os.symlink("real.json", link)
+ replace_file(link, '{"new":2}')
+ assert os.path.islink(link), "settings.json must remain a symlink"
+ assert os.readlink(link) == "real.json"
+ assert open(real).read() == '{"new":2}'
+ assert open(link).read() == '{"new":2}'
+
+
+if __name__ == "__main__":
+ test_plain_file()
+ test_relative_symlink_keeps_link()
+ print("OK")
diff --git a/graff-evals/fixtures/cache-gitroot/SPEC.md b/graff-evals/fixtures/cache-gitroot/SPEC.md
new file mode 100644
index 00000000..4324acf1
--- /dev/null
+++ b/graff-evals/fixtures/cache-gitroot/SPEC.md
@@ -0,0 +1,16 @@
+# Cache affinity is the git root (CodeGraff cache-affinity-gitroot, distilled)
+
+`affinity.py` must expose:
+
+- `git_root_of(cwd) -> str | None` — walk parents of `cwd` until a `.git`
+ file or directory is found. Return that directory's absolute path, or
+ `None` if the walk hits the filesystem root with no `.git`.
+- `affinity_seed(cwd) -> str` — `git_root_of(cwd)` when the tree is a repo;
+ otherwise the constant `SCRATCH_SEED` (`"graff-scratch"`). Never the leaf
+ cwd of a scratch tree.
+- `cache_key(cwd) -> str` — sha256 hex of `salt + affinity_seed(cwd)`
+ (`salt` is `CACHE_SALT`).
+
+Two nested directories under the same repo **must share** one seed (and
+therefore one key). A temp directory with no `.git` must not use its cwd
+as the seed — that is the eval-sandbox cold-cache bug.
diff --git a/graff-evals/fixtures/cache-gitroot/affinity.py b/graff-evals/fixtures/cache-gitroot/affinity.py
new file mode 100644
index 00000000..f72f9168
--- /dev/null
+++ b/graff-evals/fixtures/cache-gitroot/affinity.py
@@ -0,0 +1,21 @@
+"""Prompt-cache affinity — incomplete. Fix the SPEC.md contract."""
+import hashlib
+import os
+
+CACHE_SALT = "graff-cache-affinity-v2"
+SCRATCH_SEED = "graff-scratch"
+
+
+def git_root_of(cwd):
+ # BUG: never walks to .git; callers that used cwd got a unique cold key
+ # per sandbox / worktree leaf.
+ return None
+
+
+def affinity_seed(cwd):
+ # BUG: leaf cwd, so sibling sandboxes under one repo do not share a key.
+ return os.path.abspath(cwd)
+
+
+def cache_key(cwd):
+ return hashlib.sha256((CACHE_SALT + affinity_seed(cwd)).encode()).hexdigest()
diff --git a/graff-evals/fixtures/cache-gitroot/test_affinity.py b/graff-evals/fixtures/cache-gitroot/test_affinity.py
new file mode 100644
index 00000000..860ed7f8
--- /dev/null
+++ b/graff-evals/fixtures/cache-gitroot/test_affinity.py
@@ -0,0 +1,32 @@
+import os
+import tempfile
+
+from affinity import SCRATCH_SEED, affinity_seed, cache_key, git_root_of
+
+
+def test_nested_dir_shares_git_root():
+ with tempfile.TemporaryDirectory() as td:
+ os.makedirs(os.path.join(td, ".git"))
+ nest = os.path.join(td, "graff-evals", ".sandboxes", "run-1")
+ os.makedirs(nest)
+ root = os.path.abspath(td)
+ assert git_root_of(nest) == root
+ assert affinity_seed(nest) == root
+ assert affinity_seed(td) == root
+ assert cache_key(nest) == cache_key(td)
+
+
+def test_scratch_tree_is_not_cwd():
+ with tempfile.TemporaryDirectory() as td:
+ assert git_root_of(td) is None
+ assert affinity_seed(td) == SCRATCH_SEED
+ other = os.path.join(td, "leaf")
+ os.makedirs(other)
+ assert affinity_seed(other) == SCRATCH_SEED
+ assert cache_key(other) == cache_key(td)
+
+
+if __name__ == "__main__":
+ test_nested_dir_shares_git_root()
+ test_scratch_tree_is_not_cwd()
+ print("OK")
diff --git a/graff-evals/fixtures/empty-catalog/SPEC.md b/graff-evals/fixtures/empty-catalog/SPEC.md
new file mode 100644
index 00000000..5905103a
--- /dev/null
+++ b/graff-evals/fixtures/empty-catalog/SPEC.md
@@ -0,0 +1,15 @@
+# Rebuild the catalog after a showcase (CodeGraff rlm-empty-tools, distilled)
+
+`catalog.py` must expose:
+
+- `NATIVE = ["read_file", "bash", "codedb", "rlm"]` — the always-on tools
+- `tools_json(showcase=False, extra=None) -> str` — a JSON array of tool
+ names. `extra` is an optional list merged after `NATIVE` (deduped, order
+ preserved).
+- `request_body(showcase=False, extra=None) -> str` — a JSON object with a
+ `tools` field whose value is the parsed catalog. The serialized body must
+ be valid JSON. An empty catalog is `[]`, never a missing/blank value
+ (the `"tools":,` wire bug).
+
+After `showcase=True` the catalog is invalidated and **must be rebuilt**
+from `NATIVE` (+ `extra`). It must not come back empty.
diff --git a/graff-evals/fixtures/empty-catalog/catalog.py b/graff-evals/fixtures/empty-catalog/catalog.py
new file mode 100644
index 00000000..2bade515
--- /dev/null
+++ b/graff-evals/fixtures/empty-catalog/catalog.py
@@ -0,0 +1,21 @@
+"""Tool catalog JSON — incomplete. Fix the SPEC.md contract."""
+import json
+
+NATIVE = ["read_file", "bash", "codedb", "rlm"]
+
+
+def tools_json(showcase=False, extra=None):
+ # BUG: showcase invalidates the cached catalog and leaves it empty, so the
+ # next body prints `"tools":,` (no value).
+ if showcase:
+ return ""
+ names = list(NATIVE)
+ for n in extra or []:
+ if n not in names:
+ names.append(n)
+ return json.dumps(names)
+
+
+def request_body(showcase=False, extra=None):
+ raw = tools_json(showcase, extra)
+ return '{"tools":' + raw + "}"
diff --git a/graff-evals/fixtures/empty-catalog/test_catalog.py b/graff-evals/fixtures/empty-catalog/test_catalog.py
new file mode 100644
index 00000000..1667d7b0
--- /dev/null
+++ b/graff-evals/fixtures/empty-catalog/test_catalog.py
@@ -0,0 +1,24 @@
+import json
+
+from catalog import NATIVE, request_body, tools_json
+
+
+def test_steady_catalog():
+ assert json.loads(tools_json()) == NATIVE
+ body = json.loads(request_body())
+ assert body["tools"] == NATIVE
+
+
+def test_showcase_rebuilds():
+ raw = tools_json(showcase=True)
+ assert raw != ""
+ assert json.loads(raw) == NATIVE
+ body = json.loads(request_body(showcase=True))
+ assert body["tools"] == NATIVE
+ assert ",}" not in request_body(showcase=True)
+
+
+if __name__ == "__main__":
+ test_steady_catalog()
+ test_showcase_rebuilds()
+ print("OK")
diff --git a/graff-evals/fixtures/oneshot-chrome/SPEC.md b/graff-evals/fixtures/oneshot-chrome/SPEC.md
new file mode 100644
index 00000000..b4dbcc28
--- /dev/null
+++ b/graff-evals/fixtures/oneshot-chrome/SPEC.md
@@ -0,0 +1,20 @@
+# Oneshot stdout is the answer (CodeGraff oneshot-answer-stdout, distilled)
+
+`oneshot.py` must expose:
+
+- `chrome_goes_to_stdout(unattended, json_mode) -> bool`
+- `emit_pulse(stream, unattended, json_mode)` — writes `· turn still going ·\n`
+ only when chrome is allowed on that stream
+- `print_answer(stream, text, unattended, json_mode)` — the answer, then a
+ newline. Pulse chrome must not precede or follow it when unattended or
+ json_mode is set.
+
+Contract:
+
+- Interactive line-REPL (`unattended=False`, `json_mode=False`): pulse may
+ ride stdout.
+- `-p` / unattended: stdout is **only** the answer. Chrome is dropped.
+- `--json`: same — chrome is presentation, not output.
+
+`json.load` of a printed object must succeed; `· turn still going ·` on the
+same stream is a failure.
diff --git a/graff-evals/fixtures/oneshot-chrome/oneshot.py b/graff-evals/fixtures/oneshot-chrome/oneshot.py
new file mode 100644
index 00000000..514163b8
--- /dev/null
+++ b/graff-evals/fixtures/oneshot-chrome/oneshot.py
@@ -0,0 +1,17 @@
+"""Oneshot printer — incomplete. Fix the SPEC.md contract."""
+CHROME = "· turn still going ·"
+
+
+def chrome_goes_to_stdout(unattended, json_mode):
+ # BUG: chrome always rides stdout (turn-pulse on -p / --json).
+ return True
+
+
+def emit_pulse(stream, unattended=False, json_mode=False):
+ if chrome_goes_to_stdout(unattended, json_mode):
+ stream.write(CHROME + "\n")
+
+
+def print_answer(stream, text, unattended=False, json_mode=False):
+ emit_pulse(stream, unattended, json_mode)
+ stream.write(text + "\n")
diff --git a/graff-evals/fixtures/oneshot-chrome/test_oneshot.py b/graff-evals/fixtures/oneshot-chrome/test_oneshot.py
new file mode 100644
index 00000000..d62c7f26
--- /dev/null
+++ b/graff-evals/fixtures/oneshot-chrome/test_oneshot.py
@@ -0,0 +1,26 @@
+import io
+import json
+
+from oneshot import chrome_goes_to_stdout, print_answer
+
+
+def test_interactive_may_pulse():
+ assert chrome_goes_to_stdout(False, False) is True
+ buf = io.StringIO()
+ print_answer(buf, "pong", unattended=False, json_mode=False)
+ assert "pong" in buf.getvalue()
+
+
+def test_oneshot_stdout_is_the_answer():
+ assert chrome_goes_to_stdout(True, False) is False
+ buf = io.StringIO()
+ print_answer(buf, '{"ok":true}', unattended=True, json_mode=False)
+ body = buf.getvalue()
+ assert "turn still going" not in body
+ assert json.loads(body) == {"ok": True}
+
+
+if __name__ == "__main__":
+ test_interactive_may_pulse()
+ test_oneshot_stdout_is_the_answer()
+ print("OK")
diff --git a/graff-evals/fixtures/stall-warn/SPEC.md b/graff-evals/fixtures/stall-warn/SPEC.md
new file mode 100644
index 00000000..cb51d0eb
--- /dev/null
+++ b/graff-evals/fixtures/stall-warn/SPEC.md
@@ -0,0 +1,15 @@
+# Stall warning only at give-up (CodeGraff stall-bus-silent, distilled)
+
+`stall_notice.py` must expose:
+
+- `GIVE_UP = "⚠ stall — giving up"`
+- `stall_notice(reconnects_left) -> str | None`
+
+`reconnects_left` is how many reconnect attempts remain **after** this stall.
+
+- `reconnects_left > 0`: return `None` (reconnect silently; do not print ⚠).
+- `reconnects_left == 0`: return `GIVE_UP` (the ending-turn notice).
+- Negative values are treated as 0.
+
+A mid-turn `FORCE_STALL_ALWAYS` run reconnects twice then ends. The e2e
+script must see the give-up line, not a reconnect ⚠.
diff --git a/graff-evals/fixtures/stall-warn/stall_notice.py b/graff-evals/fixtures/stall-warn/stall_notice.py
new file mode 100644
index 00000000..0b34c70f
--- /dev/null
+++ b/graff-evals/fixtures/stall-warn/stall_notice.py
@@ -0,0 +1,7 @@
+"""Stall user-notice — incomplete. Fix the SPEC.md contract."""
+GIVE_UP = "⚠ stall — giving up"
+
+
+def stall_notice(reconnects_left):
+ # BUG: warn on every stall, including silent reconnects.
+ return "⚠ stall — reconnecting"
diff --git a/graff-evals/fixtures/stall-warn/test_stall_notice.py b/graff-evals/fixtures/stall-warn/test_stall_notice.py
new file mode 100644
index 00000000..0d9fa44c
--- /dev/null
+++ b/graff-evals/fixtures/stall-warn/test_stall_notice.py
@@ -0,0 +1,16 @@
+from stall_notice import GIVE_UP, stall_notice
+
+
+def test_silent_while_budget_remains():
+ assert stall_notice(2) is None
+ assert stall_notice(1) is None
+
+
+def test_give_up_when_budget_gone():
+ assert stall_notice(0) == GIVE_UP
+
+
+if __name__ == "__main__":
+ test_silent_while_budget_remains()
+ test_give_up_when_budget_gone()
+ print("OK")
diff --git a/graff-evals/fixtures/stall-widen/SPEC.md b/graff-evals/fixtures/stall-widen/SPEC.md
new file mode 100644
index 00000000..3986f5ce
--- /dev/null
+++ b/graff-evals/fixtures/stall-widen/SPEC.md
@@ -0,0 +1,20 @@
+# Stall budget widens on reconnect (CodeGraff #681, distilled)
+
+`stall.py` must expose `inter_frame_budget_ms(base_ms, tokens_flowing,
+reconnects=0) -> int`.
+
+Constants (already in the file): `IDLE_DIVISOR=4`, `IDLE_FLOOR_MS=15000`,
+`HEAD_CEILING_MS=45000`.
+
+Regimes:
+
+- No tokens yet (`tokens_flowing=False`): return `min(base_ms, HEAD_CEILING_MS)`.
+ The head ceiling is **not** widened by reconnects — a socket that never
+ answered is still dead-on-arrival.
+- Tokens have flowed, `reconnects=0`: `min(base_ms, max(IDLE_FLOOR_MS, base_ms // 4))`
+ (30s at the 120s default).
+- Each stall reconnect widens the between-lines budget:
+ `reconnects=1` → `base/2`, `reconnects>=2` → `base`. Still clamped to
+ `base_ms` and never below `IDLE_FLOOR_MS` unless `base_ms` itself is smaller.
+
+Default `base_ms` in tests is `120_000`.
diff --git a/graff-evals/fixtures/stall-widen/stall.py b/graff-evals/fixtures/stall-widen/stall.py
new file mode 100644
index 00000000..8696fe48
--- /dev/null
+++ b/graff-evals/fixtures/stall-widen/stall.py
@@ -0,0 +1,12 @@
+"""Stall-budget arithmetic — incomplete. Fix the SPEC.md contract."""
+IDLE_DIVISOR = 4
+IDLE_FLOOR_MS = 15_000
+HEAD_CEILING_MS = 45_000
+
+
+def inter_frame_budget_ms(base_ms, tokens_flowing, reconnects=0):
+ if not tokens_flowing:
+ return min(base_ms, HEAD_CEILING_MS)
+ # BUG: reconnects ignored — every attempt stays at base/4 (30s at default).
+ _ = reconnects
+ return min(base_ms, max(IDLE_FLOOR_MS, base_ms // IDLE_DIVISOR))
diff --git a/graff-evals/fixtures/stall-widen/test_stall.py b/graff-evals/fixtures/stall-widen/test_stall.py
new file mode 100644
index 00000000..05856515
--- /dev/null
+++ b/graff-evals/fixtures/stall-widen/test_stall.py
@@ -0,0 +1,21 @@
+from stall import HEAD_CEILING_MS, inter_frame_budget_ms
+
+BASE = 120_000
+
+
+def test_head_ceiling_not_widened():
+ assert inter_frame_budget_ms(BASE, False, 0) == HEAD_CEILING_MS
+ assert inter_frame_budget_ms(BASE, False, 2) == HEAD_CEILING_MS
+
+
+def test_between_lines_widens():
+ assert inter_frame_budget_ms(BASE, True, 0) == 30_000
+ assert inter_frame_budget_ms(BASE, True, 1) == 60_000
+ assert inter_frame_budget_ms(BASE, True, 2) == BASE
+ assert inter_frame_budget_ms(BASE, True, 9) == BASE
+
+
+if __name__ == "__main__":
+ test_head_ceiling_not_widened()
+ test_between_lines_widens()
+ print("OK")
diff --git a/graff-evals/harnesses.json b/graff-evals/harnesses.json
index d7acd580..7bbebd08 100644
--- a/graff-evals/harnesses.json
+++ b/graff-evals/harnesses.json
@@ -22,8 +22,29 @@
"usage": "graff-stderr",
"capabilities": ["output-schema"],
"schema_args": ["--output-schema", "{schema}"],
+ "env": {"GRAFF_POST_DEADLINE_SECS": "90"},
"default_model": "grok-4.6"
},
+ "graff-dev-repl": {
+ "cmd": ["{repo}/zig-out/bin/graff", "repl", "--model", "{model}", "--yolo"],
+ "stdin": "{prompt}\n",
+ "answer": "stdout",
+ "usage": "graff-stderr",
+ "capabilities": [],
+ "env": {"GRAFF_POST_DEADLINE_SECS": "90"},
+ "default_model": "grok-4.6",
+ "note": "scripted `graff repl` (non-TTY). Same learn-auto path as -p. TTY `graff repl` is the TUI."
+ },
+ "graff-dev-noxsearch": {
+ "cmd": ["{repo}/zig-out/bin/graff", "-p", "{prompt}", "--model", "{model}", "--yolo"],
+ "answer": "stdout",
+ "usage": "graff-stderr",
+ "capabilities": ["output-schema"],
+ "schema_args": ["--output-schema", "{schema}"],
+ "env": {"GRAFF_XAI_X_SEARCH": "0", "GRAFF_POST_DEADLINE_SECS": "90"},
+ "default_model": "grok-4.6",
+ "note": "hillclimb candidate: ADR 0031 opt-out. Hosted x_search off; catalog unchanged."
+ },
"graff-dev-rlm": {
"cmd": ["{repo}/zig-out/bin/graff", "-p", "{prompt}", "--model", "{model}", "--yolo", "--rlm"],
"answer": "stdout",
@@ -127,5 +148,31 @@
"capabilities": [],
"default_model": "gemini-3.7-flash",
"note": "uses ~/.pi/agent/models.json provider codegraff → gateway.codegraff.com; Gemini tool loops need the codegraff-gemini-echo extension"
+ },
+ "opencode": {
+ "cmd": ["opencode", "run", "--format", "json", "--auto", "-m", "{model}", "{prompt}"],
+ "answer": "opencode-json",
+ "usage": "opencode-json",
+ "capabilities": [],
+ "model_prefix": "xai",
+ "default_model": "xai/grok-4.6",
+ "note": "OpenCode 1.18 headless. Same-model series: xai/grok-4.6 (needs SuperGrok OAuth or XAI_API_KEY). model_prefix adds xai/ when --model is bare grok-4.6."
+ },
+ "opencode-zen": {
+ "cmd": ["opencode", "run", "--format", "json", "--auto", "-m", "{model}", "{prompt}"],
+ "answer": "opencode-json",
+ "usage": "opencode-json",
+ "capabilities": [],
+ "default_model": "opencode/big-pickle",
+ "note": "OpenCode native Zen free model — NOT grok-4.6. Plot on the mixed-model chart only."
+ },
+ "dsh-grok": {
+ "cmd": ["dsh", "--profile", "headless", "--patch", "{repo}/graff-evals/dsh-grok.yml", "{prompt}"],
+ "answer": "stdout",
+ "usage": null,
+ "capabilities": [],
+ "env": {"DSH_PERMISSION_MODE": "danger-full-access"},
+ "default_model": "grok-4.6",
+ "note": "deepseek-ai/deepseek-harness same-model attempt: patch layer pins xai/grok-4.6. Needs `dsh` on PATH and an xAI credential dsh will accept. Native default is dsh-deepseek (different model)."
}
}
diff --git a/graff-evals/hidden/atomic-symlink-write.py b/graff-evals/hidden/atomic-symlink-write.py
new file mode 100644
index 00000000..e223e1df
--- /dev/null
+++ b/graff-evals/hidden/atomic-symlink-write.py
@@ -0,0 +1,52 @@
+"""Held-out checks for atomic-symlink-write (not copied into the sandbox)."""
+import os
+import sys
+import tempfile
+
+sys.path.insert(0, os.getcwd())
+from atomic_write import replace_file # noqa: E402
+
+
+def main():
+ with tempfile.TemporaryDirectory() as td:
+ a = os.path.join(td, "a.json")
+ b = os.path.join(td, "b.json")
+ c = os.path.join(td, "c.json")
+ with open(c, "w") as f:
+ f.write("old")
+ os.symlink("c.json", b)
+ os.symlink("b.json", a)
+ replace_file(a, "new")
+ assert os.path.islink(a) and os.readlink(a) == "b.json"
+ assert os.path.islink(b) and os.readlink(b) == "c.json"
+ assert not os.path.islink(c)
+ assert open(c).read() == "new"
+
+ with tempfile.TemporaryDirectory() as td:
+ missing = os.path.join(td, "gone.json")
+ link = os.path.join(td, "settings.json")
+ os.symlink("gone.json", link)
+ replace_file(link, "created")
+ assert os.path.islink(link)
+ assert os.readlink(link) == "gone.json"
+ assert open(missing).read() == "created"
+
+ with tempfile.TemporaryDirectory() as td:
+ x = os.path.join(td, "x")
+ y = os.path.join(td, "y")
+ os.symlink("y", x)
+ os.symlink("x", y)
+ try:
+ replace_file(x, "nope")
+ except (OSError, ValueError):
+ pass
+ else:
+ raise SystemExit("cycle must raise")
+ assert os.readlink(x) == "y"
+ assert os.readlink(y) == "x"
+
+ print("hidden OK")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/graff-evals/hidden/cache-gitroot.py b/graff-evals/hidden/cache-gitroot.py
new file mode 100644
index 00000000..2c34f0ce
--- /dev/null
+++ b/graff-evals/hidden/cache-gitroot.py
@@ -0,0 +1,29 @@
+"""Held-out checks for cache-gitroot."""
+import os
+import sys
+import tempfile
+
+sys.path.insert(0, os.getcwd())
+from affinity import SCRATCH_SEED, affinity_seed, git_root_of # noqa: E402
+
+
+def main():
+ with tempfile.TemporaryDirectory() as td:
+ gitfile = os.path.join(td, ".git")
+ with open(gitfile, "w") as f:
+ f.write("gitdir: /somewhere/else\n")
+ leaf = os.path.join(td, "pkg", "src")
+ os.makedirs(leaf)
+ assert git_root_of(leaf) == os.path.abspath(td)
+ assert affinity_seed(leaf) == os.path.abspath(td)
+
+ with tempfile.TemporaryDirectory() as td:
+ leaf = os.path.join(td, "nope")
+ os.makedirs(leaf)
+ assert git_root_of(leaf) is None
+ assert affinity_seed(leaf) == SCRATCH_SEED
+ print("hidden OK")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/graff-evals/hidden/empty-catalog.py b/graff-evals/hidden/empty-catalog.py
new file mode 100644
index 00000000..7f5bb809
--- /dev/null
+++ b/graff-evals/hidden/empty-catalog.py
@@ -0,0 +1,24 @@
+"""Held-out checks for empty-catalog."""
+import json
+import os
+import sys
+
+sys.path.insert(0, os.getcwd())
+from catalog import NATIVE, request_body, tools_json # noqa: E402
+
+
+def main():
+ extra = ["mcp_search", "bash"]
+ got = json.loads(tools_json(showcase=True, extra=extra))
+ assert got[0:4] == NATIVE
+ assert got[-1] == "mcp_search"
+ assert got.count("bash") == 1
+ body = json.loads(request_body(showcase=True, extra=extra))
+ assert body["tools"] == got
+ empty = json.loads(tools_json(showcase=False, extra=[]))
+ assert empty == NATIVE
+ print("hidden OK")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/graff-evals/hidden/oneshot-chrome.py b/graff-evals/hidden/oneshot-chrome.py
new file mode 100644
index 00000000..e407e5eb
--- /dev/null
+++ b/graff-evals/hidden/oneshot-chrome.py
@@ -0,0 +1,24 @@
+"""Held-out checks for oneshot-chrome."""
+import io
+import json
+import os
+import sys
+
+sys.path.insert(0, os.getcwd())
+from oneshot import chrome_goes_to_stdout, emit_pulse, print_answer # noqa: E402
+
+
+def main():
+ assert chrome_goes_to_stdout(False, True) is False
+ assert chrome_goes_to_stdout(True, True) is False
+ buf = io.StringIO()
+ emit_pulse(buf, unattended=False, json_mode=True)
+ assert buf.getvalue() == ""
+ buf = io.StringIO()
+ print_answer(buf, "[1,2]", unattended=False, json_mode=True)
+ assert json.loads(buf.getvalue()) == [1, 2]
+ print("hidden OK")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/graff-evals/hidden/stall-warn.py b/graff-evals/hidden/stall-warn.py
new file mode 100644
index 00000000..830b8e31
--- /dev/null
+++ b/graff-evals/hidden/stall-warn.py
@@ -0,0 +1,18 @@
+"""Held-out checks for stall-warn."""
+import os
+import sys
+
+sys.path.insert(0, os.getcwd())
+from stall_notice import GIVE_UP, stall_notice # noqa: E402
+
+
+def main():
+ assert stall_notice(-1) == GIVE_UP
+ assert stall_notice(3) is None
+ notices = [stall_notice(left) for left in (2, 1, 0)]
+ assert notices == [None, None, GIVE_UP]
+ print("hidden OK")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/graff-evals/hidden/stall-widen.py b/graff-evals/hidden/stall-widen.py
new file mode 100644
index 00000000..4abbbc76
--- /dev/null
+++ b/graff-evals/hidden/stall-widen.py
@@ -0,0 +1,20 @@
+"""Held-out checks for stall-widen."""
+import os
+import sys
+
+sys.path.insert(0, os.getcwd())
+from stall import IDLE_FLOOR_MS, inter_frame_budget_ms # noqa: E402
+
+
+def main():
+ assert inter_frame_budget_ms(20_000, True, 0) == IDLE_FLOOR_MS
+ assert inter_frame_budget_ms(5_000, True, 0) == 5_000
+ assert inter_frame_budget_ms(5_000, True, 2) == 5_000
+ assert inter_frame_budget_ms(600_000, True, 0) == 150_000
+ assert inter_frame_budget_ms(600_000, True, 1) == 300_000
+ assert inter_frame_budget_ms(600_000, True, 2) == 600_000
+ print("hidden OK")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/graff-evals/hillclimb.py b/graff-evals/hillclimb.py
new file mode 100755
index 00000000..bd12d122
--- /dev/null
+++ b/graff-evals/hillclimb.py
@@ -0,0 +1,295 @@
+#!/usr/bin/env python3
+"""Autoresearch-style hillclimb for graff vs grok-build.
+
+Propose a harness change, run the same tasks, keep only a measured win
+on wall / first-token latency / tool calls / tokens / list-price USD.
+Never keep grok-build's heap or a 4-tool catalog (ADR 0024).
+
+ ./hillclimb.py self-test
+ ./hillclimb.py score results/run-….jsonl
+ ./hillclimb.py decide --champion results/a.jsonl --candidate results/b.jsonl
+ ./hillclimb.py iterate --suite core --task exact-reply,fix-fib,file-ops
+"""
+from __future__ import annotations
+
+import argparse, json, os, subprocess, sys, time
+
+from list_price import attach, self_test as price_self_test
+
+ROOT = os.path.dirname(os.path.abspath(__file__))
+LOG_DIR = os.path.join(ROOT, "hillclimb")
+CANDIDATES_PATH = os.path.join(LOG_DIR, "candidates.json")
+LOG_PATH = os.path.join(LOG_DIR, "log.jsonl")
+OURS_DEFAULT = "graff-dev"
+THEIRS_DEFAULT = "grok"
+AXES = ("wall_s", "first_out_s", "tok_calls", "list_tokens", "list_usd")
+# Refuse a "win" that is just grok-build's 165M process (ADR 0024).
+HEAP_OURS_KB = 20 * 1024
+HEAP_THEIRS_KB = 80 * 1024
+
+
+def load_jsonl(path: str) -> list[dict]:
+ rows = []
+ with open(path) as f:
+ for line in f:
+ line = line.strip()
+ if not line:
+ continue
+ rec = json.loads(line)
+ attach(rec)
+ rows.append(rec)
+ return rows
+
+
+def bucket(records: list[dict]) -> dict[str, dict]:
+ by: dict[str, dict] = {}
+ for r in records:
+ b = by.setdefault(r.get("harness") or "?", {
+ "n": 0, "ok": 0, "wall_s": 0.0, "first_out_s": 0.0, "first_n": 0,
+ "tok_calls": 0, "list_tokens": 0, "list_ordinary": 0, "list_cached": 0,
+ "list_out": 0, "list_usd": 0.0, "usd_n": 0, "rss_peak_kb": 0, "tasks": [],
+ })
+ b["n"] += 1
+ b["ok"] += bool(r.get("outcome_ok"))
+ b["wall_s"] += r.get("wall_s") or 0
+ if r.get("first_out_s") is not None:
+ b["first_out_s"] += r["first_out_s"]
+ b["first_n"] += 1
+ b["tok_calls"] += r.get("tok_calls") or 0
+ b["list_tokens"] += r.get("list_tokens") or 0
+ b["list_ordinary"] += r.get("list_ordinary") or 0
+ b["list_cached"] += r.get("list_cached") or 0
+ b["list_out"] += r.get("list_out") or 0
+ usd = r.get("list_usd")
+ if usd is None:
+ usd = r.get("tok_cost_usd")
+ if usd is not None:
+ b["list_usd"] += usd
+ b["usd_n"] += 1
+ b["rss_peak_kb"] = max(b["rss_peak_kb"], r.get("rss_peak_kb") or 0)
+ b["tasks"].append(r.get("task"))
+ for b in by.values():
+ b["first_out_s"] = (b["first_out_s"] / b["first_n"]) if b["first_n"] else 0.0
+ b["list_usd"] = round(b["list_usd"], 6)
+ b["pass"] = f"{b['ok']}/{b['n']}"
+ return by
+
+
+def table(by: dict[str, dict]) -> str:
+ hdr = f"{'harness':<22} {'pass':>7} {'wall':>8} {'first':>7} {'calls':>6} {'tokens':>9} {'in':>8} {'cached':>8} {'out':>7} {'list$':>9} {'rss':>8}"
+ lines = [hdr]
+ for h, b in by.items():
+ rss = f"{b['rss_peak_kb'] / 1024:.1f}M" if b["rss_peak_kb"] else "—"
+ lines.append(
+ f"{h:<22} {b['pass']:>7} {b['wall_s']:>7.1f}s {b['first_out_s']:>6.1f}s "
+ f"{b['tok_calls']:>6} {b['list_tokens']:>9} {b['list_ordinary']:>8} "
+ f"{b['list_cached']:>8} {b['list_out']:>7} ${b['list_usd']:<8.4f} {rss:>8}"
+ )
+ return "\n".join(lines)
+
+
+def _delta(cand: float, champ: float) -> tuple[float, str]:
+ if champ == 0 and cand == 0:
+ return 0.0, "wash"
+ if champ == 0:
+ return 1.0, "up"
+ rel = (cand - champ) / champ
+ if abs(rel) < 0.02:
+ return rel, "wash"
+ return rel, ("win" if rel < 0 else "loss")
+
+
+def decide(champ: dict, cand: dict, theirs: dict | None = None, candidate_id: str = "") -> dict:
+ """Keep only if pass holds and a majority of axes improve. Cite numbers."""
+ reasons = []
+ if cand["ok"] < champ["ok"]:
+ return {"keep": False, "why": "pass rate dropped", "axes": {}, "champ": champ, "cand": cand}
+ if cand["rss_peak_kb"] >= HEAP_THEIRS_KB and champ["rss_peak_kb"] <= HEAP_OURS_KB:
+ return {"keep": False, "why": "heap steal (ADR 0024: refuse grok-build RSS)", "axes": {}, "champ": champ, "cand": cand}
+ if "4-tool" in (candidate_id or "") or "four-tool" in (candidate_id or ""):
+ return {"keep": False, "why": "4-tool catalog is forbidden (ADR 0024)", "axes": {}, "champ": champ, "cand": cand}
+
+ axes = {}
+ wins = 0
+ for name in AXES:
+ rel, verdict = _delta(cand[name], champ[name])
+ axes[name] = {"champ": champ[name], "cand": cand[name], "rel": round(rel, 4), "verdict": verdict}
+ if verdict == "win":
+ wins += 1
+ reasons.append(f"{name}: {champ[name]} → {cand[name]} ({verdict}, {rel:+.1%})")
+
+ # Majority of the five named axes, and list-price USD must not get worse
+ # unless we also gained a pass.
+ keep = cand["ok"] >= champ["ok"] and wins >= 3 and axes["list_usd"]["verdict"] != "loss"
+ if axes["list_usd"]["verdict"] == "loss" and cand["ok"] > champ["ok"]:
+ keep = wins >= 3
+ why = ("keep: " if keep else "drop: ") + "; ".join(reasons)
+ out = {"keep": keep, "why": why, "axes": axes, "wins": wins, "champ": {
+ k: champ[k] for k in ("pass", "wall_s", "first_out_s", "tok_calls", "list_tokens", "list_usd", "rss_peak_kb")
+ }, "cand": {k: cand[k] for k in ("pass", "wall_s", "first_out_s", "tok_calls", "list_tokens", "list_usd", "rss_peak_kb")}}
+ if theirs:
+ out["theirs"] = {k: theirs[k] for k in ("pass", "wall_s", "first_out_s", "tok_calls", "list_tokens", "list_usd", "rss_peak_kb")}
+ return out
+
+
+def append_log(entry: dict) -> None:
+ os.makedirs(LOG_DIR, exist_ok=True)
+ entry = dict(entry)
+ entry["ts"] = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
+ with open(LOG_PATH, "a") as f:
+ f.write(json.dumps(entry, ensure_ascii=False) + "\n")
+
+
+def run_eval(harnesses: str, model: str, suite: str, tasks: list[str] | None, reps: int, jobs: int) -> str:
+ cmd = [sys.executable, os.path.join(ROOT, "run.py"),
+ "--harness", harnesses, "--model", model, "--suite", suite,
+ "--reps", str(reps), "-j", str(jobs)]
+ if tasks:
+ for t in tasks:
+ cmd += ["--task", t]
+ print("+", " ".join(cmd), flush=True)
+ proc = subprocess.run(cmd, cwd=ROOT)
+ if proc.returncode != 0:
+ raise SystemExit(f"run.py exited {proc.returncode}")
+ results = os.path.join(ROOT, "results")
+ files = sorted(n for n in os.listdir(results) if n.startswith("run-") and n.endswith(".jsonl"))
+ if not files:
+ raise SystemExit("run.py produced no results/run-*.jsonl")
+ return os.path.join(results, files[-1])
+
+
+def cmd_score(args) -> None:
+ rows = load_jsonl(args.jsonl)
+ by = bucket(rows)
+ print(table(by))
+ if args.json:
+ print(json.dumps(by, indent=2))
+
+
+def cmd_decide(args) -> None:
+ champ_src = load_jsonl(args.champion)
+ cand_src = champ_src if args.same_file else load_jsonl(args.candidate)
+ cand_name = args.cand_harness or args.ours
+ champ_rows = [r for r in champ_src if r.get("harness") == args.ours]
+ cand_rows = [r for r in cand_src if r.get("harness") == cand_name]
+ theirs_rows = [r for r in cand_src if r.get("harness") == args.theirs]
+ if not theirs_rows:
+ theirs_rows = [r for r in champ_src if r.get("harness") == args.theirs]
+ if not champ_rows or not cand_rows:
+ raise SystemExit(f"need rows for {args.ours} and {cand_name}")
+ by_c, by_k = bucket(champ_rows), bucket(cand_rows)
+ champ, cand = by_c[args.ours], by_k[cand_name]
+ theirs = bucket(theirs_rows)[args.theirs] if theirs_rows else None
+ print("champion\n" + table(by_c))
+ print("\ncandidate\n" + table(by_k))
+ if theirs:
+ print("\ntheirs\n" + table({args.theirs: theirs}))
+ d = decide(champ, cand, theirs, candidate_id=args.candidate_id)
+ print("\n" + ("KEEP" if d["keep"] else "DROP"))
+ print(d["why"])
+ append_log({"kind": "decide", "candidate_id": args.candidate_id, **{k: d[k] for k in d if k != "axes"}, "axes": d["axes"]})
+ if args.json:
+ print(json.dumps(d, indent=2))
+
+
+def cmd_iterate(args) -> None:
+ with open(CANDIDATES_PATH) as f:
+ cands = json.load(f)["candidates"]
+ if args.only:
+ want = {s.strip() for s in args.only.split(",") if s.strip()}
+ cands = [c for c in cands if c["id"] in want]
+ else:
+ cands = [c for c in cands if not c.get("kept")]
+ tasks = [t.strip() for t in (args.task or "").split(",") if t.strip()] or None
+ harnesses = [args.ours]
+ if args.theirs:
+ harnesses.append(args.theirs)
+ harnesses += [c["harness"] for c in cands]
+ path = run_eval(",".join(harnesses), args.model, args.suite, tasks, args.reps, args.jobs)
+ rows = load_jsonl(path)
+ by = bucket(rows)
+ print("\n" + table(by))
+ blocked = []
+ if args.theirs and args.theirs not in by:
+ blocked.append(f"{args.theirs} produced no rows")
+ elif args.theirs:
+ theirs_err = [r for r in rows if r.get("harness") == args.theirs and r.get("error")]
+ if theirs_err:
+ blocked.append(theirs_err[0].get("error") or "theirs error")
+ champ = by.get(args.ours)
+ if not champ:
+ raise SystemExit(f"champion {args.ours} missing from {path}")
+ for c in cands:
+ cand = by.get(c["harness"])
+ if not cand:
+ print(f"DROP {c['id']}: no rows")
+ append_log({"kind": "iterate", "candidate_id": c["id"], "keep": False, "why": "no rows", "results": path})
+ continue
+ d = decide(champ, cand, by.get(args.theirs), candidate_id=c["id"])
+ print(f"\n{c['id']}: {'KEEP' if d['keep'] else 'DROP'}")
+ print(d["why"])
+ append_log({"kind": "iterate", "candidate_id": c["id"], "results": path, "blocked": blocked, **d})
+ if blocked:
+ print("\nblocked-honest:", "; ".join(blocked))
+
+
+def main() -> None:
+ ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
+ sub = ap.add_subparsers(dest="cmd", required=True)
+
+ p = sub.add_parser("self-test")
+ p.set_defaults(fn=lambda _: (price_self_test(), _decide_self_test(), print("hillclimb self-test ok")))
+
+ p = sub.add_parser("score")
+ p.add_argument("jsonl")
+ p.add_argument("--json", action="store_true")
+ p.set_defaults(fn=cmd_score)
+
+ p = sub.add_parser("decide")
+ p.add_argument("--champion", required=True)
+ p.add_argument("--candidate", default=None)
+ p.add_argument("--same-file", action="store_true")
+ p.add_argument("--ours", default=OURS_DEFAULT)
+ p.add_argument("--cand-harness", default=None)
+ p.add_argument("--theirs", default=THEIRS_DEFAULT)
+ p.add_argument("--candidate-id", default="")
+ p.add_argument("--json", action="store_true")
+ p.set_defaults(fn=cmd_decide)
+
+ p = sub.add_parser("iterate")
+ p.add_argument("--ours", default=OURS_DEFAULT)
+ p.add_argument("--theirs", default=THEIRS_DEFAULT)
+ p.add_argument("--model", default="grok-4.6")
+ p.add_argument("--suite", default="core")
+ p.add_argument("--task", default="")
+ p.add_argument("--reps", type=int, default=1)
+ p.add_argument("--jobs", "-j", type=int, default=1)
+ p.add_argument("--only", default="")
+ p.set_defaults(fn=cmd_iterate)
+
+ args = ap.parse_args()
+ if args.cmd == "decide" and not args.candidate and not args.same_file:
+ ap.error("decide needs --candidate or --same-file")
+ if args.cmd == "decide" and args.same_file:
+ args.candidate = args.champion
+ args.fn(args)
+
+
+def _decide_self_test() -> None:
+ champ = {"ok": 3, "n": 3, "pass": "3/3", "wall_s": 30.0, "first_out_s": 2.0,
+ "tok_calls": 10, "list_tokens": 20_000, "list_usd": 0.05, "rss_peak_kb": 9000}
+ better = dict(champ, wall_s=20.0, tok_calls=6, list_tokens=12_000, list_usd=0.03, first_out_s=1.5)
+ d = decide(champ, better)
+ assert d["keep"], d
+ worse = dict(champ, ok=2, wall_s=10.0, list_usd=0.01)
+ d = decide(champ, worse)
+ assert not d["keep"]
+ heap = dict(better, rss_peak_kb=170_000)
+ d = decide(champ, heap)
+ assert not d["keep"]
+ catalog = decide(champ, better, candidate_id="four-tool-copy")
+ assert not catalog["keep"]
+
+
+if __name__ == "__main__":
+ main()
diff --git a/graff-evals/hillclimb/baseline.md b/graff-evals/hillclimb/baseline.md
new file mode 100644
index 00000000..9e633735
--- /dev/null
+++ b/graff-evals/hillclimb/baseline.md
@@ -0,0 +1,186 @@
+# grok-4.6 list-price baseline: graff vs grok-build
+
+Also compared: OpenCode (`opencode run`) and DeepSeek Harness (`dsh`).
+Same-model series is grok-4.6. Native-default series (`opencode-zen`,
+`dsh-deepseek`) is a **different chart** — do not read those points as
+grok-4.6 list price.
+
+In-house suite (`--suite inhouse`): six bug shapes distilled from shipped
+CodeGraff PRs (#685/#405 symlink write, oneshot stdout chrome,
+cache-affinity git root, #681 stall widen, rlm-empty-tools catalog,
+stall-bus-silent warn). Fixtures live under `graff-evals/tasks/` +
+`fixtures/`; they are not the live repo.
+
+Axes: wall, first-token latency, tool calls, tokens (uncached + cached + out),
+xAI list-price USD (`$2/$0.50/$6` per 1M under 200k prompt tokens; `$4/$1/$12`
+for the whole request at or above). SuperGrok's `[usage]` `$0.0000` is ignored.
+
+Graff `[usage] in` includes cache reads. grok-build `input_tokens` does not —
+ADR 0024's "185k in" column was uncached-only and undercounted grok-build.
+
+## We are not strict Pareto vs grok-build
+
+On the live 3-task set they still win **calls**. We win wall, tokens,
+list$, and RSS. Pass is a tie. Do not claim a strict 5-axis win. The
+[frontier graph](#frontier-graph-live-3-task-two-2d-projections) is the
+honest picture: grok sits on it via fewer calls; graff-dev (`-p`) sits
+on it via cheaper / faster.
+
+## Live 2026-08-30 hardlink pin, `-p` + scripted REPL (`run-20260830-042417.jsonl`)
+
+Same SuperGrok / grok OAuth, grok-4.6, one rep, three core tasks.
+**x_search stays on.** `-p` (`graff-dev`) and piped `graff repl`
+(`graff-dev-repl`) share one learn-auto path. Pin is a hardlink
+(same inode; copy only if hardlink fails). Session-end `learn init`
+is detached (ADR 0045) so teardown does not wait ~38s on suite gen.
+
+REPL is fatter than `-p` because it is not lean-oneshot (more tokens,
+one extra call on this set). REPL `first_out_s` is echo (0.03s) —
+ignore it; it is not time-to-first-model-token.
+
+This run's fix-fib used 4 API calls, so learn-auto did **not** fire
+(threshold is 5). No pin in those sandboxes. The hardlink was proven
+separately: `graff learn init` in `/tmp/graff-pin-proof` left pin and
+`zig-out/bin/graff` on **inode 1478920, nlink=2**; init wall was
+**37.7s**, almost all CPU on suite generation.
+
+| harness | pass | wall | first | calls | tokens | list$ | RSS |
+|---|---:|---:|---:|---:|---:|---:|---:|
+| **graff-dev (`-p`)** | 3/3 | **22.2s** | **2.8s** | 8 | **~32k** | **$0.0374** | **90.7M** |
+| grok-build | 3/3 | 37.0s | 3.9s | **7** | ~116k | $0.1474 | 155.4M |
+| graff-dev-repl | 3/3 | 25.2s | 0.03s (echo) | 9 | ~64k | $0.1185 | 91.8M |
+
+| task | graff `-p` wall / $ / calls | grok wall / $ / calls |
+|---|---:|---:|
+| exact-reply | **2.55s / $0.0067 / 1** | 2.68s / $0.0322 / 1 |
+| fix-fib | **10.63s / $0.0170 / 4** | 26.90s / $0.0708 / 4 |
+| file-ops | 8.99s / $0.0137 / 3 | **7.39s** / $0.0444 / **2** |
+
+**Not Pareto:** grok-build still has fewer calls (7 vs 8 on `-p`, 7 vs 9
+on repl) and won file-ops wall. We win the other named axes on this
+set. Heap still theirs (155M vs 91M) — not stolen.
+
+Interactive TUI (`graff tui --yolo --model grok-4.6`, PTY, Ctrl+Q) of
+the same fix-fib prompt: test printed OK at **5.9s**, turn loop 7.4s,
+session wall 9.3s including boot/quit. `.graff` was **52K**. No
+`graff-pinned`, no extra 127M inode. Four API-call traces (we quit
+during the fourth after the test already passed), so learn-auto did
+not fire — same threshold miss as the `-p` row. First model token
+2.6s. In the 11–15s band (under it).
+
+`x-search-off` dropped: not what grok-build does.
+
+## Frontier graph (live 3-task, two 2D projections)
+
+The 5-axis score is wall / first-token / calls / tokens / list$ (ADR 0044).
+Pass is a tie. RSS is extra. REPL `first_out_s` is composer echo — it is
+not an axis and is not plotted.
+
+Neither harness dominates the other on all five: **grok-build is on the
+frontier via fewer calls**; **graff-dev (`-p`) is on it via cheaper /
+faster / fewer tokens / smaller RSS**. `graff-dev-repl` is interior —
+`-p` beats it on wall, calls, tokens, list$, and RSS.
+
+![Pareto projections: wall vs list$ and calls vs list$ from run-20260830-042417](frontier-20260830.svg)
+
+Numbers on the figure are the live JSONL sums (`run-20260830-042417.jsonl`).
+Lower-left is better on both panels.
+
+| point | 5-axis | wall vs $ | calls vs $ |
+|---|---|---|---|
+| **graff-dev (`-p`)** | on (cheaper / faster) | **on** (best both) | **on** (cheaper) |
+| grok-build | on (fewer calls) | interior | **on** (fewer calls) |
+| graff-dev-repl | interior | interior | interior |
+
+```mermaid
+flowchart LR
+ subgraph front["5-axis frontier — neither dominates"]
+ P["graff-dev (−p)<br/>22.2s · $0.0374 · 8 calls · ~32k · 90.7M<br/>on via cheaper / faster / smaller RSS"]
+ G["grok-build<br/>37.0s · $0.1474 · 7 calls · ~116k · 155.4M<br/>on via fewer calls"]
+ end
+ R["graff-dev-repl<br/>25.2s · $0.1185 · 9 calls · ~64k · 91.8M<br/>interior: dominated by −p<br/>first-token is echo — not plotted"]
+ P -->|wins wall, calls, tokens, list$, RSS| R
+```
+
+Left panel (wall vs $): only `-p` is non-dominated. Right panel (calls vs
+$): the dashed segment is the 2D front between grok (7 calls) and `-p`
+($0.0374). REPL sits above and to the right of `-p` on both projections.
+
+## Earlier same-day after oneshot-skip (`run-20260830-035954.jsonl`) — superseded
+
+Same SuperGrok / grok OAuth, grok-4.6, one rep, three core tasks.
+**x_search stays on** (grok-build 1.0.5 still lists `web_search` / `web_fetch`).
+The steal was: `-p` no longer pins `zig-out/bin/graff` into
+`.graff/learn-kit/graff-pinned` (that was 127M + 38s CPU on fix-fib).
+
+| harness | pass | wall | first | calls | tokens | list$ | RSS |
+|---|---:|---:|---:|---:|---:|---:|---:|
+| **graff-dev** | 3/3 | **21.8s** | 1.9s | 8 | **32,583** | **$0.0479** | **90.8M** |
+| grok-build | 3/3 | 27.3s | 1.9s | **7** | 116,283 | $0.1424 | 154.3M |
+
+| task | graff wall / $ / calls | grok wall / $ / calls |
+|---|---:|---:|
+| exact-reply | **2.18s / $0.0074 / 1** | 2.30s / $0.0149 / 1 |
+| file-ops | **4.75s / $0.0143 / 2** | 7.94s / $0.0492 / 2 |
+| fix-fib | **14.82s / $0.0263 / 5** | 17.09s / $0.0783 / 4 |
+
+fix-fib sandbox is 76K (no learn-kit). Earlier the same task was 127M / 47s
+because learn-auto copied the debug binary after the 5th API call.
+
+**Yes, we are cheaper** at grok-4.6 list price: $0.048 vs $0.142 on this set
+(~3×). Tokens 33k vs 116k. Wall now ours too. grok still has one fewer call
+and a slightly faster first token on fix-fib (1.44s vs 1.86s). Heap still
+theirs (154M vs 91M) — not stolen.
+
+`x-search-off` dropped: not what grok-build does.
+
+Earlier same-day file `run-20260830-034621.jsonl` is the pre-fix A/B
+(x_search on vs off vs grok) and is superseded for wall.
+
+## Historical rescore (same-day paired JSONL)
+
+### SWE, 2026-08-25 (`run-20260825-061731.jsonl`) — the ADR 0024 grok-inclusive file
+
+| harness | pass | wall | first | calls | tokens | uncached | cached | out | list$ | RSS |
+|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|
+| graff-dev | 4/6 | 742.7s | 4.9s | 96 | 1,307,858 | 250,788 | 1,008,640 | 48,430 | $1.9527 | 9.1M |
+| grok-build | **5/6** | **500.2s** | **3.4s** | **39** | **1,062,104** | 184,880 | 845,184 | 32,040 | **$1.4561** | 164.6M |
+
+Grok-build wins every named axis except RSS (18×). The old "185k vs 1.3M in"
+headline was an accounting mismatch; honest totals are 1.06M vs 1.31M.
+
+### After prompt/subagent cuts — 2026-08-28
+
+Shared tasks only. `cookie-store` on graff-dev that day has no `[usage]` line
+(fail / empty tally) so its list$ is $0 and understates graff spend.
+
+**core** (`run-20260828-021606.jsonl`, 11 tasks)
+
+| harness | pass | wall | first | calls | tokens | list$ | RSS |
+|---|---:|---:|---:|---:|---:|---:|---:|
+| graff-dev | 11/11 | **89.4s** | **1.9s** | 38 | **147,831** | **$0.1812** | **9.1M** |
+| grok-build | 11/11 | 140.9s | 2.9s | **33** | 536,768 | $0.4591 | 155.7M |
+
+**rlm** (`run-20260828-021008.jsonl`, 5 tasks)
+
+| harness | pass | wall | first | calls | tokens | list$ | RSS |
+|---|---:|---:|---:|---:|---:|---:|---:|
+| graff-dev | 5/5 | **45.6s** | **3.6s** | **18** | **71,991** | **$0.0908** | **8.6M** |
+| grok-build | 5/5 | 119.8s | 4.5s | 22 | 445,201 | $0.5042 | 159.5M |
+
+**swe** (`run-20260828-020830.jsonl`, 6 tasks)
+
+| harness | pass | wall | first | calls | tokens | list$ | RSS |
+|---|---:|---:|---:|---:|---:|---:|---:|
+| graff-dev | 4/6 | **224.9s** | **1.8s** | **25** | **135,455** | **$0.2209** | 62.9M |
+| grok-build | **5/6** | 330.2s | 2.7s | 27 | 533,397 | $0.5576 | 156.1M |
+
+## What the hillclimb is allowed to chase
+
+On 2026-08-25 SWE, grok-build still wins pass / wall / latency / calls / USD.
+On the live 2026-08-30 3-task set we win wall / tokens / list$ / RSS and
+lose calls — **not Pareto**. On 2026-08-28 we still lose a SWE pass
+(`cookie-store` / historically `json-stream` / `label-sort`).
+Do not steal the 165M heap or a 4-tool catalog to close the remaining gap
+(ADR 0024). `x-search-off` was dropped (not what grok-build does).
+Kept: hardlink pin + detached session-end `learn init` (ADR 0044 / 0045).
diff --git a/graff-evals/hillclimb/candidates.json b/graff-evals/hillclimb/candidates.json
new file mode 100644
index 00000000..4975407e
--- /dev/null
+++ b/graff-evals/hillclimb/candidates.json
@@ -0,0 +1,42 @@
+{
+ "axes": ["wall_s", "first_out_s", "tok_calls", "list_tokens", "list_usd"],
+ "refuse": [
+ "Do not steal grok-build heap (~165M RSS).",
+ "Do not shrink the catalog to a 4-tool set. grok-build 1.0.5 ships a fat catalog plus web_search."
+ ],
+ "champion": "graff-dev",
+ "candidates": [
+ {
+ "id": "x-search-off",
+ "harness": "graff-dev-noxsearch",
+ "kept": false,
+ "dropped_on": "2026-08-30",
+ "why": "Not what grok-build does. Their headless session still lists web_search/web_fetch. Turning our hosted x_search off is a side bet, not a copy.",
+ "forbidden": []
+ },
+ {
+ "id": "oneshot-no-learn-pin",
+ "harness": "graff-dev",
+ "kept": false,
+ "dropped_on": "2026-08-30",
+ "why": "Path split. -p skipped learn-auto; TUI/REPL still copied 127M after five calls. Retracted for a shared hardlink pin.",
+ "forbidden": []
+ },
+ {
+ "id": "hardlink-learn-pin",
+ "harness": "graff-dev",
+ "kept": true,
+ "kept_on": "2026-08-30",
+ "why": "Pin graff-pinned as a hardlink (same inode, O(1)). -p, piped graff repl, and TUI share one learn-auto path. Copy only when the filesystem cannot hardlink.",
+ "forbidden": []
+ },
+ {
+ "id": "background-learn-init",
+ "harness": "graff-dev",
+ "kept": true,
+ "kept_on": "2026-08-30",
+ "why": "autoInitLearning detaches graff learn init (same process-group spawn as a trial). Session-end no longer waits ~38s on suite generation. Pin stays a hardlink. -p / REPL / TUI share the path.",
+ "forbidden": []
+ }
+ ]
+}
diff --git a/graff-evals/hillclimb/frontier-20260830.svg b/graff-evals/hillclimb/frontier-20260830.svg
new file mode 100644
index 00000000..1a30c834
--- /dev/null
+++ b/graff-evals/hillclimb/frontier-20260830.svg
@@ -0,0 +1,98 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 880 470" width="880" height="470" role="img" aria-labelledby="t d">
+ <title id="t">Pareto projections of the live 3-task set (run-20260830-042417)</title>
+ <desc id="d">Two minimize-minimize scatter plots from graff-evals/results/run-20260830-042417.jsonl. Left: wall seconds vs list-price USD — only graff-dev is on that 2D frontier. Right: tool calls vs list-price USD — grok-build (fewer calls) and graff-dev (cheaper) are on the frontier; graff-dev-repl is interior, dominated by -p. REPL first-token is composer echo and is not an axis. The 5-axis score is not strict Pareto: grok still wins calls.</desc>
+ <rect width="880" height="470" fill="#ffffff"/>
+ <text x="20" y="22" font-size="16" font-weight="700" fill="#0f172a" font-family="ui-sans-serif, system-ui, sans-serif">Live 3-task frontier · run-20260830-042417 · lower-left is better</text>
+ <text x="20" y="40" font-size="11" fill="#64748b" font-family="ui-sans-serif, system-ui, sans-serif">Pass is 3/3 all around. REPL first-token (0.03s) is composer echo — not plotted. Not strict Pareto on the 5-axis score: grok still wins calls.</text>
+
+ <!-- left: wall vs $ -->
+ <rect x="72" y="62" width="340" height="280" fill="#fafcfb" stroke="#d1d5db"/>
+ <g stroke="#e5e7eb" stroke-width="1">
+ <line x1="72" y1="342" x2="412" y2="342"/>
+ <line x1="72" y1="278" x2="412" y2="278"/>
+ <line x1="72" y1="214" x2="412" y2="214"/>
+ <line x1="72" y1="150" x2="412" y2="150"/>
+ <line x1="72" y1="86" x2="412" y2="86"/>
+ <line x1="102" y1="62" x2="102" y2="342"/>
+ <line x1="176" y1="62" x2="176" y2="342"/>
+ <line x1="249" y1="62" x2="249" y2="342"/>
+ <line x1="323" y1="62" x2="323" y2="342"/>
+ <line x1="397" y1="62" x2="397" y2="342"/>
+ </g>
+ <g font-size="11" fill="#64748b" font-family="ui-sans-serif, system-ui, sans-serif">
+ <text x="64" y="346" text-anchor="end">$0</text>
+ <text x="64" y="282" text-anchor="end">$0.04</text>
+ <text x="64" y="218" text-anchor="end">$0.08</text>
+ <text x="64" y="154" text-anchor="end">$0.12</text>
+ <text x="64" y="90" text-anchor="end">$0.16</text>
+ <text x="102" y="358" text-anchor="middle">20s</text>
+ <text x="176" y="358" text-anchor="middle">25s</text>
+ <text x="249" y="358" text-anchor="middle">30s</text>
+ <text x="323" y="358" text-anchor="middle">35s</text>
+ <text x="397" y="358" text-anchor="middle">40s</text>
+ </g>
+ <text x="242" y="376" text-anchor="middle" font-size="12" fill="#334155" font-family="ui-sans-serif, system-ui, sans-serif">wall (s) →</text>
+ <text x="18" y="202" text-anchor="middle" font-size="12" fill="#334155" font-family="ui-sans-serif, system-ui, sans-serif" transform="rotate(-90 18 202)">list $</text>
+ <text x="72" y="56" font-size="13" font-weight="600" fill="#0f172a" font-family="ui-sans-serif, system-ui, sans-serif">wall vs list$</text>
+ <text x="80" y="80" font-size="10" fill="#059669" font-family="ui-sans-serif, system-ui, sans-serif">only −p is on this 2D front</text>
+
+ <!-- right: calls vs $ -->
+ <rect x="500" y="62" width="340" height="280" fill="#fafcfb" stroke="#d1d5db"/>
+ <g stroke="#e5e7eb" stroke-width="1">
+ <line x1="500" y1="342" x2="840" y2="342"/>
+ <line x1="500" y1="278" x2="840" y2="278"/>
+ <line x1="500" y1="214" x2="840" y2="214"/>
+ <line x1="500" y1="150" x2="840" y2="150"/>
+ <line x1="500" y1="86" x2="840" y2="86"/>
+ <line x1="564" y1="62" x2="564" y2="342"/>
+ <line x1="670" y1="62" x2="670" y2="342"/>
+ <line x1="776" y1="62" x2="776" y2="342"/>
+ </g>
+ <g font-size="11" fill="#64748b" font-family="ui-sans-serif, system-ui, sans-serif">
+ <text x="492" y="346" text-anchor="end">$0</text>
+ <text x="492" y="282" text-anchor="end">$0.04</text>
+ <text x="492" y="218" text-anchor="end">$0.08</text>
+ <text x="492" y="154" text-anchor="end">$0.12</text>
+ <text x="492" y="90" text-anchor="end">$0.16</text>
+ <text x="564" y="358" text-anchor="middle">7</text>
+ <text x="670" y="358" text-anchor="middle">8</text>
+ <text x="776" y="358" text-anchor="middle">9</text>
+ </g>
+ <text x="670" y="376" text-anchor="middle" font-size="12" fill="#334155" font-family="ui-sans-serif, system-ui, sans-serif">tool calls →</text>
+ <text x="446" y="202" text-anchor="middle" font-size="12" fill="#334155" font-family="ui-sans-serif, system-ui, sans-serif" transform="rotate(-90 446 202)">list $</text>
+ <text x="500" y="56" font-size="13" font-weight="600" fill="#0f172a" font-family="ui-sans-serif, system-ui, sans-serif">calls vs list$</text>
+ <text x="508" y="80" font-size="10" fill="#059669" font-family="ui-sans-serif, system-ui, sans-serif">grok and −p share this 2D front</text>
+
+ <!-- 2D frontier (calls vs $): grok (7, $0.1474) → graff-dev (8, $0.0374) -->
+ <polyline points="564,106 670,282" fill="none" stroke="#059669" stroke-width="1.6" stroke-dasharray="5 4" opacity="0.85"/>
+
+ <!--
+ Coordinates from the live JSONL sums (wall 22.17 / 36.97 / 25.23;
+ list$ 0.03741 / 0.14735 / 0.11855; calls 8 / 7 / 9).
+ x_wall = 72 + (wall-18)/(41-18)*340
+ x_calls = 500 + (calls-6.4)/(9.6-6.4)*340
+ y_$ = 62 + 280 - usd/0.175*280
+ -->
+ <circle cx="134" cy="282" r="6.5" fill="#059669" stroke="#047857" stroke-width="1.4"/>
+ <text x="146" y="268" font-size="11" font-weight="600" fill="#047857" font-family="ui-sans-serif, system-ui, sans-serif">−p 22.2s · $0.0374</text>
+ <circle cx="352" cy="106" r="6.5" fill="#334155" stroke="#1e293b" stroke-width="1.4"/>
+ <text x="230" y="100" font-size="11" font-weight="600" fill="#1e293b" font-family="ui-sans-serif, system-ui, sans-serif">grok 37.0s · $0.1474</text>
+ <circle cx="179" cy="152" r="5.5" fill="#ffffff" stroke="#64748b" stroke-width="1.6" stroke-dasharray="2.5 2"/>
+ <text x="191" y="168" font-size="11" font-weight="600" fill="#64748b" font-family="ui-sans-serif, system-ui, sans-serif">repl 25.2s · $0.1185</text>
+
+ <circle cx="670" cy="282" r="6.5" fill="#059669" stroke="#047857" stroke-width="1.4"/>
+ <text x="582" y="268" font-size="11" font-weight="600" fill="#047857" font-family="ui-sans-serif, system-ui, sans-serif">−p 8 · $0.0374</text>
+ <circle cx="564" cy="106" r="6.5" fill="#334155" stroke="#1e293b" stroke-width="1.4"/>
+ <text x="576" y="100" font-size="11" font-weight="600" fill="#1e293b" font-family="ui-sans-serif, system-ui, sans-serif">grok 7 · $0.1474</text>
+ <circle cx="776" cy="152" r="5.5" fill="#ffffff" stroke="#64748b" stroke-width="1.6" stroke-dasharray="2.5 2"/>
+ <text x="668" y="168" font-size="11" font-weight="600" fill="#64748b" font-family="ui-sans-serif, system-ui, sans-serif">repl 9 · $0.1185</text>
+
+ <circle cx="28" cy="430" r="6" fill="#059669" stroke="#047857" stroke-width="1.4"/>
+ <text x="40" y="434" font-size="12" fill="#0f172a" font-family="ui-sans-serif, system-ui, sans-serif">graff-dev (−p) — on the 5-axis frontier via wall / tokens / list$ / RSS</text>
+ <circle cx="28" cy="450" r="6" fill="#334155" stroke="#1e293b" stroke-width="1.4"/>
+ <text x="40" y="454" font-size="12" fill="#0f172a" font-family="ui-sans-serif, system-ui, sans-serif">grok-build — on the 5-axis frontier via fewer calls (7 vs 8 / 9)</text>
+ <circle cx="500" cy="430" r="5.5" fill="#ffffff" stroke="#64748b" stroke-width="1.6" stroke-dasharray="2.5 2"/>
+ <text x="512" y="434" font-size="12" fill="#0f172a" font-family="ui-sans-serif, system-ui, sans-serif">graff-dev-repl — interior (dominated by −p)</text>
+ <line x1="500" y1="450" x2="528" y2="450" stroke="#059669" stroke-width="1.6" stroke-dasharray="5 4"/>
+ <text x="536" y="454" font-size="12" fill="#0f172a" font-family="ui-sans-serif, system-ui, sans-serif">2D frontier (calls vs $)</text>
+</svg>
diff --git a/graff-evals/hillclimb/log.jsonl b/graff-evals/hillclimb/log.jsonl
new file mode 100644
index 00000000..59e5d89e
--- /dev/null
+++ b/graff-evals/hillclimb/log.jsonl
@@ -0,0 +1,4 @@
+{"kind": "iterate", "candidate_id": "x-search-off", "results": "/workspace/graff-evals/results/run-20260830-034621.jsonl", "blocked": [], "keep": true, "why": "keep: wall_s: 63.96 → 54.54 (win, -14.7%); first_out_s: 2.706666666666667 → 1.67 (win, -38.3%); tok_calls: 9 → 9 (wash, +0.0%); list_tokens: 36374 → 22482 (win, -38.2%); list_usd: 0.04728 → 0.024272 (win, -48.7%)", "axes": {"wall_s": {"champ": 63.96, "cand": 54.54, "rel": -0.1473, "verdict": "win"}, "first_out_s": {"champ": 2.706666666666667, "cand": 1.67, "rel": -0.383, "verdict": "win"}, "tok_calls": {"champ": 9, "cand": 9, "rel": 0.0, "verdict": "wash"}, "list_tokens": {"champ": 36374, "cand": 22482, "rel": -0.3819, "verdict": "win"}, "list_usd": {"champ": 0.04728, "cand": 0.024272, "rel": -0.4866, "verdict": "win"}}, "wins": 4, "champ": {"pass": "3/3", "wall_s": 63.96, "first_out_s": 2.706666666666667, "tok_calls": 9, "list_tokens": 36374, "list_usd": 0.04728, "rss_peak_kb": 93452}, "cand": {"pass": "3/3", "wall_s": 54.54, "first_out_s": 1.67, "tok_calls": 9, "list_tokens": 22482, "list_usd": 0.024272, "rss_peak_kb": 93460}, "theirs": {"pass": "3/3", "wall_s": 41.64, "first_out_s": 3.5700000000000003, "tok_calls": 8, "list_tokens": 132858, "list_usd": 0.120476, "rss_peak_kb": 157500}, "ts": "2026-08-30T03:47:30Z"}
+{"kind": "iterate", "candidate_id": "oneshot-no-learn-pin", "results": "/workspace/graff-evals/results/run-20260830-035954.jsonl", "keep": true, "why": "keep vs pre-fix graff-dev: wall 64.0s\u219221.8s, first 2.7s\u21921.9s, calls 9\u21928, tokens 36374\u219232583, list$ 0.0473\u21920.0479 wash; vs grok-build we win wall 21.8s<27.3s and list$ 0.0479<0.1424. x-search-off retracted (grok has web_search on).", "retracted": ["x-search-off"], "ts": "2026-08-30T04:00:43Z"}
+{"kind": "iterate", "candidate_id": "hardlink-learn-pin", "results": "/workspace/graff-evals/results/run-20260830-042417.jsonl", "keep": true, "why": "shared hardlink pin. live 3-task: graff-dev 3/3 22.2s 8 calls ~32k $0.0374 90.7M; grok 3/3 37.0s 7 calls ~116k $0.1474 155.4M; graff-dev-repl 3/3 25.2s 9 calls ~64k $0.1185 91.8M. not Pareto (they win calls). oneshot-no-learn-pin retracted (path split).", "retracted": ["oneshot-no-learn-pin"], "ts": "2026-08-30T04:24:17Z"}
+{"kind": "iterate", "candidate_id": "background-learn-init", "results": "/workspace/graff-evals/results/run-20260830-042417.jsonl", "keep": true, "why": "session-end learn init was 37.7s of suite gen after a hardlink pin; detach with the same process-group spawn as a trial so -p/REPL/TUI teardown does not wait. same 3-task set still not Pareto (calls 8/9 vs grok 7). TUI PTY fix-fib: OK at 5.9s, turn 7.4s, .graff 52K, no 127M pin (4 calls, learn-auto did not fire).", "ts": "2026-08-30T04:37:00Z"}
diff --git a/graff-evals/hillclimb/plot_frontier.py b/graff-evals/hillclimb/plot_frontier.py
new file mode 100644
index 00000000..ef53e97a
--- /dev/null
+++ b/graff-evals/hillclimb/plot_frontier.py
@@ -0,0 +1,163 @@
+#!/usr/bin/env python3
+"""Draw 2D Pareto projections (wall vs $, calls vs $) from a graff-evals JSONL.
+
+Lower-left is better. Does not plot REPL first-token (composer echo).
+Mixed-model points (list_price_kind != xai-list) are drawn hollow and must
+not be read as the same-model grok-4.6 series.
+
+ ./plot_frontier.py results/run-….jsonl -o hillclimb/frontier-YYYYMMDD.svg
+"""
+from __future__ import annotations
+
+import argparse, json, os, sys
+
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+from hillclimb import bucket, load_jsonl # noqa: E402
+
+COLORS = {
+ "graff-dev": ("#059669", "#047857"),
+ "graff-dev-repl": ("#ffffff", "#64748b"),
+ "grok": ("#334155", "#1e293b"),
+ "opencode": ("#2563eb", "#1d4ed8"),
+ "opencode-zen": ("#ffffff", "#2563eb"),
+ "dsh": ("#7c3aed", "#5b21b6"),
+ "dsh-deepseek": ("#ffffff", "#7c3aed"),
+ "dsh-grok": ("#7c3aed", "#5b21b6"),
+}
+
+
+def pareto(points, xk, yk):
+ """Minimize-minimize frontier. points: list of (name, xs)."""
+ ordered = sorted(points, key=lambda p: (p[1][xk], p[1][yk]))
+ front, best_y = [], float("inf")
+ for name, b in ordered:
+ y = b[yk]
+ if y < best_y - 1e-12:
+ front.append(name)
+ best_y = y
+ return set(front)
+
+
+def _scale(v, lo, hi, a, b):
+ if hi <= lo:
+ return (a + b) / 2
+ t = (v - lo) / (hi - lo)
+ return a + t * (b - a)
+
+
+def render(by: dict, title: str, subtitle: str) -> str:
+ rows = []
+ for h, b in by.items():
+ if b["n"] == 0:
+ continue
+ rows.append((h, {
+ "wall_s": b["wall_s"],
+ "tok_calls": b["tok_calls"],
+ "list_usd": b["list_usd"],
+ "pass": b["pass"],
+ "list_tokens": b["list_tokens"],
+ }))
+ if not rows:
+ raise SystemExit("no harness rows")
+
+ wall_front = pareto(rows, "wall_s", "list_usd")
+ call_front = pareto(rows, "tok_calls", "list_usd")
+ walls = [b["wall_s"] for _, b in rows]
+ calls = [b["tok_calls"] for _, b in rows]
+ usds = [b["list_usd"] for _, b in rows]
+ wlo, whi = min(walls) * 0.85, max(walls) * 1.12 or 1
+ clo, chi = min(calls) - 1.2, max(calls) + 1.2
+ ulo, uhi = 0.0, max(usds) * 1.15 or 0.01
+
+ def xy_wall(b):
+ return _scale(b["wall_s"], wlo, whi, 72, 412), _scale(b["list_usd"], ulo, uhi, 342, 86)
+
+ def xy_call(b):
+ return _scale(b["tok_calls"], clo, chi, 500, 840), _scale(b["list_usd"], ulo, uhi, 342, 86)
+
+ ticks_u = [ulo + (uhi - ulo) * i / 4 for i in range(5)]
+ ticks_w = [wlo + (whi - wlo) * i / 4 for i in range(5)]
+ # integer-ish call ticks
+ cmin, cmax = int(round(min(calls))), int(round(max(calls)))
+ ticks_c = list(range(cmin, cmax + 1)) or [0]
+
+ parts = [
+ f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 880 490" width="880" height="490" role="img">',
+ f'<title>{title}</title>',
+ f'<rect width="880" height="490" fill="#ffffff"/>',
+ f'<text x="20" y="22" font-size="16" font-weight="700" fill="#0f172a" font-family="ui-sans-serif, system-ui, sans-serif">{title}</text>',
+ f'<text x="20" y="40" font-size="11" fill="#64748b" font-family="ui-sans-serif, system-ui, sans-serif">{subtitle}</text>',
+ '<rect x="72" y="62" width="340" height="280" fill="#fafcfb" stroke="#d1d5db"/>',
+ '<rect x="500" y="62" width="340" height="280" fill="#fafcfb" stroke="#d1d5db"/>',
+ '<text x="72" y="56" font-size="13" font-weight="600" fill="#0f172a" font-family="ui-sans-serif, system-ui, sans-serif">wall vs list$</text>',
+ '<text x="500" y="56" font-size="13" font-weight="600" fill="#0f172a" font-family="ui-sans-serif, system-ui, sans-serif">calls vs list$</text>',
+ '<text x="242" y="376" text-anchor="middle" font-size="12" fill="#334155" font-family="ui-sans-serif, system-ui, sans-serif">wall (s) →</text>',
+ '<text x="670" y="376" text-anchor="middle" font-size="12" fill="#334155" font-family="ui-sans-serif, system-ui, sans-serif">tool calls →</text>',
+ ]
+ for yv in ticks_u:
+ y = _scale(yv, ulo, uhi, 342, 86)
+ parts.append(f'<line x1="72" y1="{y:.1f}" x2="412" y2="{y:.1f}" stroke="#e5e7eb"/>')
+ parts.append(f'<line x1="500" y1="{y:.1f}" x2="840" y2="{y:.1f}" stroke="#e5e7eb"/>')
+ parts.append(f'<text x="64" y="{y + 4:.1f}" text-anchor="end" font-size="11" fill="#64748b" font-family="ui-sans-serif, system-ui, sans-serif">${yv:.3f}</text>')
+ parts.append(f'<text x="492" y="{y + 4:.1f}" text-anchor="end" font-size="11" fill="#64748b" font-family="ui-sans-serif, system-ui, sans-serif">${yv:.3f}</text>')
+ for xv in ticks_w:
+ x = _scale(xv, wlo, whi, 72, 412)
+ parts.append(f'<line x1="{x:.1f}" y1="62" x2="{x:.1f}" y2="342" stroke="#e5e7eb"/>')
+ parts.append(f'<text x="{x:.1f}" y="358" text-anchor="middle" font-size="11" fill="#64748b" font-family="ui-sans-serif, system-ui, sans-serif">{xv:.0f}s</text>')
+ for xv in ticks_c:
+ x = _scale(xv, clo, chi, 500, 840)
+ parts.append(f'<line x1="{x:.1f}" y1="62" x2="{x:.1f}" y2="342" stroke="#e5e7eb"/>')
+ parts.append(f'<text x="{x:.1f}" y="358" text-anchor="middle" font-size="11" fill="#64748b" font-family="ui-sans-serif, system-ui, sans-serif">{xv}</text>')
+
+ # calls-vs-$ frontier polyline
+ call_pts = sorted(
+ [(n, b) for n, b in rows if n in call_front],
+ key=lambda p: p[1]["tok_calls"],
+ )
+ if len(call_pts) >= 2:
+ d = " ".join(f"{xy_call(b)[0]:.1f},{xy_call(b)[1]:.1f}" for _, b in call_pts)
+ parts.append(f'<polyline points="{d}" fill="none" stroke="#059669" stroke-width="1.6" stroke-dasharray="5 4" opacity="0.85"/>')
+
+ legend_y = 410
+ for h, b in rows:
+ fill, stroke = COLORS.get(h, ("#94a3b8", "#475569"))
+ hollow = h.endswith("-zen") or h.endswith("-deepseek") or h.endswith("-repl")
+ xw, yw = xy_wall(b)
+ xc, yc = xy_call(b)
+ dash = ' stroke-dasharray="2.5 2"' if hollow else ""
+ r = 5.5 if hollow else 6.5
+ parts.append(f'<circle cx="{xw:.1f}" cy="{yw:.1f}" r="{r}" fill="{fill}" stroke="{stroke}" stroke-width="1.4"{dash}/>')
+ parts.append(f'<text x="{xw + 10:.1f}" y="{yw - 8:.1f}" font-size="11" font-weight="600" fill="{stroke}" font-family="ui-sans-serif, system-ui, sans-serif">{h} {b["wall_s"]:.1f}s · ${b["list_usd"]:.4f}</text>')
+ parts.append(f'<circle cx="{xc:.1f}" cy="{yc:.1f}" r="{r}" fill="{fill}" stroke="{stroke}" stroke-width="1.4"{dash}/>')
+ parts.append(f'<text x="{xc + 10:.1f}" y="{yc - 8:.1f}" font-size="11" font-weight="600" fill="{stroke}" font-family="ui-sans-serif, system-ui, sans-serif">{h} {b["tok_calls"]} · ${b["list_usd"]:.4f}</text>')
+ on = []
+ if h in wall_front:
+ on.append("wall/$")
+ if h in call_front:
+ on.append("calls/$")
+ mark = "on " + " + ".join(on) if on else "interior"
+ parts.append(f'<circle cx="28" cy="{legend_y}" r="{r}" fill="{fill}" stroke="{stroke}" stroke-width="1.4"{dash}/>')
+ parts.append(f'<text x="40" y="{legend_y + 4}" font-size="12" fill="#0f172a" font-family="ui-sans-serif, system-ui, sans-serif">{h} — {b["pass"]} · {mark}</text>')
+ legend_y += 20
+
+ parts.append("</svg>")
+ return "\n".join(parts) + "\n"
+
+
+def main():
+ ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
+ ap.add_argument("jsonl")
+ ap.add_argument("-o", "--out", required=True)
+ ap.add_argument("--title", default="Eval frontier · lower-left is better")
+ ap.add_argument("--subtitle", default="Pass is a tie-break, not an axis. Hollow = mixed-model / REPL. REPL first-token is echo — not plotted.")
+ args = ap.parse_args()
+ rows = load_jsonl(args.jsonl)
+ svg = render(bucket(rows), args.title, args.subtitle)
+ os.makedirs(os.path.dirname(os.path.abspath(args.out)) or ".", exist_ok=True)
+ with open(args.out, "w") as f:
+ f.write(svg)
+ print(f"wrote {args.out}")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/graff-evals/list_price.py b/graff-evals/list_price.py
new file mode 100644
index 00000000..82c5e640
--- /dev/null
+++ b/graff-evals/list_price.py
@@ -0,0 +1,175 @@
+"""xAI list-price USD for graff-evals (not SuperGrok's $0.0000 footer).
+
+Token bands match src/pricing.zig / pricing_cache.usdForUsage and the
+2026-08 xAI table: grok-4.6 is $2 / $0.50 / $6 per 1M under 200k prompt
+tokens, and $4 / $1 / $12 for the whole request at or above. Hosted
+server-side tools are extra ($5 / 1k for web_search, x_search,
+code_execution).
+
+Graff's `[usage]` line reports `in` inclusive of cache reads.
+grok-build's stream `input_tokens` is exclusive of `cache_read_input_tokens`.
+"""
+from __future__ import annotations
+
+RATES = {
+ "grok-4.6": {
+ "high_at": 200_000,
+ "in": 2.0,
+ "cache": 0.50,
+ "out": 6.0,
+ "high_in": 4.0,
+ "high_cache": 1.0,
+ "high_out": 12.0,
+ },
+ "grok-4.5": {
+ "high_at": 200_000,
+ "in": 2.0,
+ "cache": 0.30,
+ "out": 6.0,
+ "high_in": 4.0,
+ "high_cache": 0.60,
+ "high_out": 12.0,
+ },
+ "grok-build-0.1": {
+ "high_at": 200_000,
+ "in": 1.0,
+ "cache": 0.20,
+ "out": 2.0,
+ "high_in": 2.0,
+ "high_cache": 0.40,
+ "high_out": 4.0,
+ },
+}
+
+# USD per 1k invocations (xAI Tools Pricing). Token-only tools are 0.
+TOOL_PER_1K = {
+ "web_search": 5.0,
+ "x_search": 5.0,
+ "code_execution": 5.0,
+ "code_interpreter": 5.0,
+ "attachment_search": 10.0,
+ "collections_search": 2.50,
+ "file_search": 2.50,
+}
+
+
+def rates_for(model: str) -> dict | None:
+ if not model:
+ return None
+ if model in RATES:
+ return RATES[model]
+ # OpenCode / gateway ids look like xai/grok-4.6
+ leaf = model.rsplit("/", 1)[-1]
+ if model.startswith("grok-4.6") or leaf.startswith("grok-4.6"):
+ return RATES["grok-4.6"]
+ if model.startswith("grok-build") or leaf.startswith("grok-build"):
+ return RATES["grok-build-0.1"]
+ return None
+
+
+def ordinary_and_cached(tok_in, tok_cached, inclusive: bool) -> tuple[int, int]:
+ tin = int(tok_in or 0)
+ cached = int(tok_cached or 0)
+ if inclusive:
+ return max(tin - cached, 0), cached
+ return tin, cached
+
+
+def convention_for(rec: dict) -> bool:
+ """True when `tok_in` includes cache reads (graff [usage])."""
+ h = rec.get("harness") or ""
+ if h == "grok":
+ return False
+ if h.startswith("graff"):
+ return True
+ if (rec.get("tok_cached") or 0) > (rec.get("tok_in") or 0):
+ return False
+ return True
+
+
+def usd_tokens(model: str, ordinary: int, cached: int, out: int, writes: int = 0) -> float:
+ p = rates_for(model)
+ if not p:
+ return 0.0
+ ui, ci, wi = max(ordinary, 0), max(cached, 0), max(writes, 0)
+ fo = max(out, 0)
+ prompt = ui + ci + wi
+ high = p["high_at"] > 0 and prompt >= p["high_at"]
+ inn = p["high_in"] if high else p["in"]
+ cache = p["high_cache"] if high else p["cache"]
+ out_r = p["high_out"] if high else p["out"]
+ return (ui * inn + ci * cache + wi * inn + fo * out_r) / 1_000_000.0
+
+
+def usd_tools(counts: dict | None) -> float:
+ if not counts:
+ return 0.0
+ total = 0.0
+ for name, n in counts.items():
+ rate = TOOL_PER_1K.get(name)
+ if rate is None:
+ continue
+ total += (int(n or 0) / 1000.0) * rate
+ return total
+
+
+def attach(rec: dict, inclusive: bool | None = None) -> dict:
+ """Mutate `rec` with list-price fields. Returns rec."""
+ if inclusive is None:
+ inclusive = convention_for(rec)
+ ordinary, cached = ordinary_and_cached(rec.get("tok_in"), rec.get("tok_cached"), inclusive)
+ writes = int(rec.get("tok_writes") or 0)
+ out = int(rec.get("tok_out") or 0)
+ model = rec.get("model") or ""
+ tools = rec.get("tok_tools") or {}
+ p = rates_for(model)
+ token_usd = usd_tokens(model, ordinary, cached, out, writes)
+ tool_usd = usd_tools(tools)
+ rec["list_ordinary"] = ordinary
+ rec["list_cached"] = cached
+ rec["list_out"] = out
+ rec["list_prompt"] = ordinary + cached + writes
+ rec["list_tokens"] = ordinary + cached + writes + out
+ rec["list_token_usd"] = round(token_usd, 6) if p else None
+ rec["list_tool_usd"] = round(tool_usd, 6) if p else None
+ # Unknown models are not grok-4.6 list price. Leave list_usd unset so the
+ # runner can fall back to a harness-reported tok_cost_usd without pretending.
+ if p:
+ rec["list_usd"] = round(token_usd + tool_usd, 6)
+ rec["list_price_kind"] = "xai-list"
+ else:
+ rec["list_usd"] = None
+ rec["list_price_kind"] = "none"
+ rec["list_high_band"] = bool(p and p["high_at"] > 0 and rec["list_prompt"] >= p["high_at"])
+ return rec
+
+
+def self_test() -> None:
+ # Matches src/pricing_tests.zig "grok-4.6 prices"
+ assert abs(usd_tokens("grok-4.6", 10_000, 2_000, 500) - 0.024) < 1e-12
+ assert abs(usd_tokens("grok-4.6", 199_999, 0, 0) - 0.399998) < 1e-12
+ assert abs(usd_tokens("grok-4.6", 200_000, 0, 1_000) - 0.812) < 1e-12
+ assert abs(usd_tokens("grok-4.6", 190_000, 20_000, 0) - 0.78) < 1e-12
+ # Graff [usage] is inclusive: 5407 in (512 cached) + 80 out
+ o, c = ordinary_and_cached(5407, 512, True)
+ assert (o, c) == (4895, 512)
+ assert abs(usd_tokens("grok-4.6", o, c, 80) - 0.010526) < 1e-12
+ # grok-build stream is exclusive: 4461 in + 11520 cached + 37 out
+ o, c = ordinary_and_cached(4461, 11520, False)
+ assert (o, c) == (4461, 11520)
+ assert abs(usd_tokens("grok-4.6", o, c, 37) - 0.014904) < 1e-12
+ assert abs(usd_tools({"x_search": 2, "web_search": 0}) - 0.01) < 1e-12
+ rec = attach({"harness": "graff-dev", "model": "grok-4.6", "tok_in": 5407, "tok_cached": 512, "tok_out": 80})
+ assert rec["list_usd"] == 0.010526
+ rec = attach({"harness": "grok", "model": "grok-4.6", "tok_in": 4461, "tok_cached": 11520, "tok_out": 37})
+ assert rec["list_usd"] == 0.014904
+ rec = attach({"harness": "opencode", "model": "xai/grok-4.6", "tok_in": 5407, "tok_cached": 512, "tok_out": 80})
+ assert rec["list_usd"] == 0.010526
+ rec = attach({"harness": "opencode-zen", "model": "opencode/big-pickle", "tok_in": 100, "tok_out": 10})
+ assert rec["list_usd"] is None
+ assert rec["list_price_kind"] == "none"
+
+
+if __name__ == "__main__":
+ self_test()
+ print("list_price self-test ok")
diff --git a/graff-evals/run.py b/graff-evals/run.py
index 27dbc7a9..b46386de 100755
--- a/graff-evals/run.py
+++ b/graff-evals/run.py
@@ -11,12 +11,15 @@ outcome, and writes JSONL results plus a summary table.
./run.py --suite rlm --harness graff-dev-old,graff-dev # scatter-gather A/B
./run.py --suite swe --harness graff-dev-old,graff-dev -j 12 # DeepSWE-shaped A/B, parallel
./run.py --suite mcp --harness graff-dev-old-nolean,graff-dev-rlm-struct,graff-dev-nolean
+ ./run.py --suite inhouse --harness graff-dev,grok,opencode # shipped-PR fixtures
./run.py --harness grok --task fix-fib --reps 3 # one task, 3 reps
./run.py --interactive # pick + watch live
"""
import argparse, json, os, re, resource, shutil, subprocess, sys, threading, time
from concurrent.futures import ThreadPoolExecutor, as_completed
+from list_price import attach as attach_list_price
+
ROOT = os.path.dirname(os.path.abspath(__file__))
REPO = os.path.dirname(ROOT)
TASKS_DIR = os.path.join(ROOT, "tasks")
@@ -24,7 +27,7 @@ RESULTS_DIR = os.path.join(ROOT, "results")
SANDBOX_DIR = os.path.join(ROOT, ".sandboxes")
GRAFF_USAGE_RE = re.compile(
- r"\[usage\] (\d+) api call\(s\) · (\d+) in \((\d+) cached(?:, \d+ cache writes)?\) \+ (\d+) out tokens")
+ r"\[usage\] (\d+) api call\(s\) · (\d+) in \((\d+) cached(?:, (\d+) cache writes)?\) \+ (\d+) out tokens")
def load_tasks():
@@ -69,13 +72,71 @@ def materialize(task, sandbox):
subprocess.run(["/bin/sh", "-c", cmd], cwd=sandbox, capture_output=True, timeout=60)
+def _resolve_model(harness, model):
+ mapped = (harness.get("model_map") or {}).get(model, model)
+ prefix = harness.get("model_prefix")
+ if prefix and mapped and "/" not in mapped:
+ return f"{prefix}/{mapped}"
+ return mapped
+
+
def build_cmd(harness, task, model):
- subst = {"prompt": task["prompt"], "model": model, "repo": REPO}
+ subst = {"prompt": task["prompt"], "model": _resolve_model(harness, model), "repo": REPO}
cmd = [part.format(**subst) for part in harness["cmd"]]
if "output-schema" in task.get("requires", []):
schema = json.dumps(task["schema"], separators=(",", ":"))
cmd += [part.format(schema=schema, **subst) for part in harness.get("schema_args", [])]
- return cmd
+ stdin = harness.get("stdin")
+ if stdin is not None:
+ stdin = stdin.format(**subst)
+ return cmd, stdin
+
+
+def learn_pin_info(sandbox):
+ """Hardlink vs 127M copy: nlink>=2 and same inode as the live exe."""
+ pin = os.path.join(sandbox, ".graff", "learn-kit", "graff-pinned")
+ if not os.path.exists(pin):
+ return None
+ st = os.stat(pin)
+ info = {"bytes": st.st_size, "nlink": st.st_nlink, "ino": st.st_ino}
+ exe = os.path.join(REPO, "zig-out", "bin", "graff")
+ if os.path.exists(exe):
+ info["same_inode"] = os.stat(exe).st_ino == st.st_ino
+ return info
+
+
+def _parse_opencode_json(stdout):
+ """OpenCode `run --format json` NDJSON: text / tool_use / step_finish."""
+ answer, calls, tin, tread, twrite, tout, cost = "", 0, 0, 0, 0, 0, 0.0
+ for line in stdout.splitlines():
+ line = line.strip()
+ if not line.startswith("{"):
+ continue
+ try:
+ ev = json.loads(line)
+ except json.JSONDecodeError:
+ continue
+ kind = ev.get("type")
+ part = ev.get("part") or {}
+ if kind == "text":
+ text = (part.get("text") or ev.get("text") or "").strip()
+ if text:
+ answer = text
+ elif kind == "tool_use":
+ calls += 1
+ elif kind == "step_finish":
+ tok = part.get("tokens") or {}
+ cache = tok.get("cache") or {}
+ tin += int(tok.get("input") or 0)
+ tout += int(tok.get("output") or 0) + int(tok.get("reasoning") or 0)
+ tread += int(cache.get("read") or 0)
+ twrite += int(cache.get("write") or 0)
+ cost += float(part.get("cost") or 0)
+ if not calls:
+ calls += 1
+ usage = {"calls": calls, "in": tin + tread + twrite, "cached": tread,
+ "out": tout, "writes": twrite, "cost_usd": round(cost, 6)}
+ return answer, usage
def parse_answer_and_usage(harness, stdout, stderr):
@@ -93,9 +154,20 @@ def parse_answer_and_usage(harness, stdout, stderr):
if ev.get("type") == "result":
answer = ev.get("result") or ""
u = ev.get("usage", {})
+ stu = u.get("server_tool_use") or {}
+ tools = {}
+ if stu.get("web_search_requests"):
+ tools["web_search"] = stu["web_search_requests"]
+ if stu.get("x_search_requests"):
+ tools["x_search"] = stu["x_search_requests"]
+ if stu.get("code_execution_requests"):
+ tools["code_execution"] = stu["code_execution_requests"]
usage = {"calls": ev.get("num_turns"), "in": u.get("input_tokens"),
"cached": u.get("cache_read_input_tokens"),
- "out": u.get("output_tokens"), "api_ms": ev.get("duration_api_ms")}
+ "out": u.get("output_tokens"), "api_ms": ev.get("duration_api_ms"),
+ "writes": u.get("cache_creation_input_tokens") or 0}
+ if tools:
+ usage["tools"] = tools
if harness["answer"] == "pi-json":
answer, calls, tin, tread, twrite, tout, cost = "", 0, 0, 0, 0, 0, 0.0
for line in stdout.splitlines():
@@ -119,11 +191,14 @@ def parse_answer_and_usage(harness, stdout, stderr):
if c.get("type") == "text") or answer
usage = {"calls": calls, "in": tin + tread + twrite, "cached": tread,
"out": tout, "cost_usd": round(cost, 6)}
+ if harness["answer"] == "opencode-json":
+ answer, usage = _parse_opencode_json(stdout)
if harness.get("usage") == "graff-stderr":
m = GRAFF_USAGE_RE.search(stderr)
if m:
usage = {"calls": int(m.group(1)), "in": int(m.group(2)),
- "cached": int(m.group(3)), "out": int(m.group(4))}
+ "cached": int(m.group(3)), "writes": int(m.group(4) or 0),
+ "out": int(m.group(5))}
cost_m = re.search(r"\$([0-9.]+)", stderr)
if cost_m:
usage["cost_usd"] = float(cost_m.group(1))
@@ -206,7 +281,7 @@ def _fmt_mib(kb):
def one_run(hname, harness, task, model, rep, live=False):
sandbox = os.path.join(SANDBOX_DIR, f"{hname}-{task['id']}-r{rep}")
materialize(task, sandbox)
- cmd = build_cmd(harness, task, model)
+ cmd, stdin_body = build_cmd(harness, task, model)
timeout = task.get("timeout_s", 240)
t0 = time.monotonic()
first_out = None
@@ -216,8 +291,15 @@ def one_run(hname, harness, task, model, rep, live=False):
ru0 = _rusage_children()
try:
p = subprocess.Popen(cmd, cwd=sandbox, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE, text=True,
+ stderr=subprocess.PIPE, stdin=subprocess.PIPE if stdin_body is not None else None,
+ text=True,
env=dict(os.environ, **harness.get("env", {})))
+ if stdin_body is not None and p.stdin is not None:
+ try:
+ p.stdin.write(stdin_body)
+ except BrokenPipeError:
+ pass
+ p.stdin.close()
import selectors
sel = selectors.DefaultSelector()
sel.register(p.stdout, selectors.EVENT_READ, "out")
@@ -266,6 +348,10 @@ def one_run(hname, harness, task, model, rep, live=False):
"cpu_sample_s": round(cpu_sample, 3),
"sandbox_bytes": dir_bytes(sandbox)}
rec.update({f"tok_{k}": v for k, v in usage.items()})
+ pin = learn_pin_info(sandbox)
+ if pin is not None:
+ rec["learn_pin"] = pin
+ attach_list_price(rec, inclusive=harness.get("usage") != "grok-stream")
if check.returncode != 0 and (check.stderr.strip() or check.stdout.strip()):
rec["check_note"] = (check.stderr.strip() or check.stdout.strip())[:200]
return rec
@@ -276,7 +362,7 @@ def _bucket(records):
for r in records:
b = by.setdefault(r["harness"], {
"n": 0, "ok": 0, "wall": 0.0, "first": 0.0, "first_n": 0,
- "tin": 0, "tout": 0, "calls": 0, "rss": 0, "cpu": 0.0,
+ "tin": 0, "tcached": 0, "tout": 0, "calls": 0, "rss": 0, "cpu": 0.0,
"usd": 0.0, "usd_n": 0,
})
b["n"] += 1
@@ -285,10 +371,14 @@ def _bucket(records):
if r.get("first_out_s") is not None:
b["first"] += r["first_out_s"]
b["first_n"] += 1
- b["tin"] += r.get("tok_in") or 0
+ b["tin"] += r.get("list_ordinary") if r.get("list_ordinary") is not None else (r.get("tok_in") or 0)
+ b["tcached"] += r.get("list_cached") if r.get("list_cached") is not None else (r.get("tok_cached") or 0)
b["tout"] += r.get("tok_out") or 0
b["calls"] += r.get("tok_calls") or 0
- if r.get("tok_cost_usd") is not None:
+ if r.get("list_usd") is not None:
+ b["usd"] += r["list_usd"]
+ b["usd_n"] += 1
+ elif r.get("tok_cost_usd") is not None:
b["usd"] += r["tok_cost_usd"]
b["usd_n"] += 1
b["rss"] = max(b["rss"], r.get("rss_peak_kb") or 0)
@@ -301,12 +391,12 @@ def _bucket(records):
def _print_table(title, by):
print(f"\n{title}")
- print(f"{'harness':<16} {'pass':>7} {'wall':>8} {'first':>7} {'rss':>8} {'cpu':>7} {'in_tok':>9} {'out_tok':>8} {'calls':>6} {'usd':>8}")
+ print(f"{'harness':<16} {'pass':>7} {'wall':>8} {'first':>7} {'rss':>8} {'cpu':>7} {'in':>8} {'cached':>8} {'out':>8} {'calls':>6} {'list$':>8}")
for h, b in by.items():
first = (b["first"] / b["first_n"]) if b["first_n"] else 0.0
usd = f"${b['usd']:.4f}" if b["usd_n"] else "—"
print(f"{h:<16} {b['ok']}/{b['n']:<5} {b['wall']:>7.1f}s {first:>6.1f}s "
- f"{_fmt_mib(b['rss']):>8} {b['cpu']:>6.1f}s {b['tin']:>9} {b['tout']:>8} {b['calls']:>6} {usd:>8}")
+ f"{_fmt_mib(b['rss']):>8} {b['cpu']:>6.1f}s {b['tin']:>8} {b.get('tcached', 0):>8} {b['tout']:>8} {b['calls']:>6} {usd:>8}")
def summarize(records):
@@ -323,7 +413,9 @@ def _line(rec):
return (f"{ok} {rec.get('harness', '?'):<16} {rec.get('task', '?'):<18} "
f"r{rec.get('rep', '?')} {rec.get('wall_s', '?')}s "
f"first={rec.get('first_out_s', '—')}s rss={_fmt_mib(rec.get('rss_peak_kb'))} "
- f"cpu={cpu:.1f}s in={rec.get('tok_in', '?')} out={rec.get('tok_out', '?')}")
+ f"cpu={cpu:.1f}s in={rec.get('list_ordinary', rec.get('tok_in', '?'))} "
+ f"cached={rec.get('list_cached', rec.get('tok_cached', '—'))} "
+ f"out={rec.get('tok_out', '?')} list=${rec.get('list_usd', '—')}")
def interactive(tasks, harnesses):
@@ -351,7 +443,8 @@ def main():
ap.add_argument("--harness", default="graff", help="comma-separated harness names (see harnesses.json)")
ap.add_argument("--model", default=None, help="model id (default: per-harness default_model)")
ap.add_argument("--task", action="append", help="task id filter (repeatable)")
- ap.add_argument("--suite", default="all", help="core, rlm, swe, mcp, comma-mix, or all (core+rlm+swe; mcp is opt-in)")
+ ap.add_argument("--suite", default="all",
+ help="core, rlm, swe, mcp, inhouse, comma-mix, or all (core+rlm+swe; mcp/inhouse are opt-in)")
ap.add_argument("--reps", type=int, default=1)
ap.add_argument("--jobs", "-j", type=int, default=1,
help="parallel task×harness runs (default 1; each has its own sandbox)")
diff --git a/graff-evals/tasks/34-atomic-symlink-write.json b/graff-evals/tasks/34-atomic-symlink-write.json
new file mode 100644
index 00000000..decb3993
--- /dev/null
+++ b/graff-evals/tasks/34-atomic-symlink-write.json
@@ -0,0 +1,10 @@
+{
+ "id": "atomic-symlink-write",
+ "suite": "inhouse",
+ "category": "inhouse",
+ "source": "codegraff #685 / #405 — write atomically through a symlink (distilled, not the live repo)",
+ "files_dir": "fixtures/atomic-symlink-write",
+ "prompt": "replace_file is wrong. Read SPEC.md and atomic_write.py, then make `python3 test_atomic_write.py` print OK. Do not edit the tests. A path that is a symlink must stay a symlink; the write replaces the referent.",
+ "check": "python3 test_atomic_write.py && python3 \"$TASK_ROOT/hidden/atomic-symlink-write.py\"",
+ "timeout_s": 240
+}
diff --git a/graff-evals/tasks/35-oneshot-chrome.json b/graff-evals/tasks/35-oneshot-chrome.json
new file mode 100644
index 00000000..437269c5
--- /dev/null
+++ b/graff-evals/tasks/35-oneshot-chrome.json
@@ -0,0 +1,10 @@
+{
+ "id": "oneshot-chrome",
+ "suite": "inhouse",
+ "category": "inhouse",
+ "source": "codegraff oneshot-answer-stdout — keep -p stdout as the answer, not turn-pulse chrome (distilled)",
+ "files_dir": "fixtures/oneshot-chrome",
+ "prompt": "oneshot.py leaks turn chrome onto stdout. Read SPEC.md and oneshot.py, then make `python3 test_oneshot.py` print OK. Do not edit the tests. Unattended / json / print-mode stdout is the answer only.",
+ "check": "python3 test_oneshot.py && python3 \"$TASK_ROOT/hidden/oneshot-chrome.py\"",
+ "timeout_s": 240
+}
diff --git a/graff-evals/tasks/36-cache-gitroot.json b/graff-evals/tasks/36-cache-gitroot.json
new file mode 100644
index 00000000..1b57db98
--- /dev/null
+++ b/graff-evals/tasks/36-cache-gitroot.json
@@ -0,0 +1,10 @@
+{
+ "id": "cache-gitroot",
+ "suite": "inhouse",
+ "category": "inhouse",
+ "source": "codegraff cache-affinity-gitroot — key prompt-cache on git root, not cwd (distilled)",
+ "files_dir": "fixtures/cache-gitroot",
+ "prompt": "affinity_seed hashes the leaf cwd, so sibling worktrees miss the cache. Read SPEC.md and affinity.py, then make `python3 test_affinity.py` print OK. Do not edit the tests.",
+ "check": "python3 test_affinity.py && python3 \"$TASK_ROOT/hidden/cache-gitroot.py\"",
+ "timeout_s": 240
+}
diff --git a/graff-evals/tasks/37-stall-widen.json b/graff-evals/tasks/37-stall-widen.json
new file mode 100644
index 00000000..e792b364
--- /dev/null
+++ b/graff-evals/tasks/37-stall-widen.json
@@ -0,0 +1,10 @@
+{
+ "id": "stall-widen",
+ "suite": "inhouse",
+ "category": "inhouse",
+ "source": "codegraff #681 — widen the between-lines stall budget on each reconnect (distilled)",
+ "files_dir": "fixtures/stall-widen",
+ "prompt": "inter_frame_budget_ms never widens after a stall reconnect, so a mid-response pause is killed at base/4 forever. Read SPEC.md and stall.py, then make `python3 test_stall.py` print OK. Do not edit the tests.",
+ "check": "python3 test_stall.py && python3 \"$TASK_ROOT/hidden/stall-widen.py\"",
+ "timeout_s": 240
+}
diff --git a/graff-evals/tasks/38-empty-catalog.json b/graff-evals/tasks/38-empty-catalog.json
new file mode 100644
index 00000000..7a9c8dff
--- /dev/null
+++ b/graff-evals/tasks/38-empty-catalog.json
@@ -0,0 +1,10 @@
+{
+ "id": "empty-catalog",
+ "suite": "inhouse",
+ "category": "inhouse",
+ "source": "codegraff rlm-empty-tools — rebuild the tool catalog after a wide-native rlm showcase (distilled)",
+ "files_dir": "fixtures/empty-catalog",
+ "prompt": "tools_json after a showcase is empty, so the next request body is `\"tools\":,` and the provider 400s. Read SPEC.md and catalog.py, then make `python3 test_catalog.py` print OK. Do not edit the tests.",
+ "check": "python3 test_catalog.py && python3 \"$TASK_ROOT/hidden/empty-catalog.py\"",
+ "timeout_s": 240
+}
diff --git a/graff-evals/tasks/39-stall-warn.json b/graff-evals/tasks/39-stall-warn.json
new file mode 100644
index 00000000..64582650
--- /dev/null
+++ b/graff-evals/tasks/39-stall-warn.json
@@ -0,0 +1,10 @@
+{
+ "id": "stall-warn",
+ "suite": "inhouse",
+ "category": "inhouse",
+ "source": "codegraff stall-bus-silent — print the stall warning only when the reconnect budget is gone (distilled)",
+ "files_dir": "fixtures/stall-warn",
+ "prompt": "stall_notice prints a warning on every reconnect. Read SPEC.md and stall_notice.py, then make `python3 test_stall_notice.py` print OK. Do not edit the tests. Mid-turn reconnects are silent; the ending-turn notice fires only when the budget is gone.",
+ "check": "python3 test_stall_notice.py && python3 \"$TASK_ROOT/hidden/stall-warn.py\"",
+ "timeout_s": 240
+}