How Hillclimb works
Hillclimb runs one loop: take the current best version of your code, ask an agent for one hypothesis, let it implement that in an isolated checkout, measure the result, and keep it only if it is really better. Every attempt lands in a SQLite journal, and the next prompt is built from that journal.
baseline (N repeats, noise estimate) ─┐
▼
┌──────────── journal (SQLite) ◄───────────────┐
▼ │
prompt: goal + journal + current best + rules │
▼ │
agent edits a git worktree branched from the best │
▼ │
anti-cheat: scope, frozen hashes, held-out absent, │
no symlinks, no forbidden code, ignored files purged ────┤ rejected
▼ │
dev metric on a fresh, pristine checkout (repeats) ──────┤ not better than best + margin
▼ │
held-out gate on another fresh checkout ─────────────────┤ regressed held-out (number withheld from agent)
▼ │
accept: move hillclimb/best to the commit ───────────────┘
Isolation from your checkout
- Hillclimb never runs
git checkoutin your working tree. Every attempt gets its owngit worktree add --detachunder$TMPDIR/hillclimb-<id>/, which is removed when the attempt ends, whether it succeeded or not. - Accepted changes are committed in that worktree and recorded by moving
hillclimb/bestwithgit update-ref <new> <old>, a compare-and-swap. If your checkout is onhillclimb/best, Hillclimb refuses to start. - Rejected attempts leave no branch behind. Their diffs are kept in the journal.
Anti-cheat
After the agent exits, before anything is measured:
- Purge ignored files (
git clean -X). A planted.pycor cache file can't shadow a frozen module. - Scope. Every changed, added or deleted path must match an
editableglob. Anything else rejects the attempt and names the path. - Frozen hashes. At run start, every tracked file matching a
frozenglob (and every held-out path) is copied out of the base commit and hashed with sha256. After the attempt, each file on disk is re-hashed, which catches edits hidden withgit update-index --assume-unchangedor--skip-worktree. The committed blob is checked again. - Held-out absent. Held-out files must still be absent from the worktree.
- No symlinks in changed paths.
- Forbidden patterns. Optional regexes, such as
open\(, are checked against every added line.
Then the metric runs on a fresh checkout of the candidate commit, not the agent's worktree. Frozen files are overwritten from the pristine copy and hash-verified first. "The metric runs from a pristine copy of frozen files" is literal.
What this can't stop: code inside the editable globs that games the metric's
semantics. An example is a rule that reads labels from disk at runtime. Keep the
editable globs narrow, make the scorer check its inputs (the demo's score.py lints
the rule's imports and names), and add forbid_patterns for the obvious escapes. The
held-out gate is the backstop for everything else.
Held-out isolation
The agent must never see held-out files, outputs or scores.
- Files. Tracked files matching
[heldout] pathsare deleted from the agent's worktree and markedskip-worktree, so git doesn't report them as deleted. They stay in every commit and only exist on disk in the gate checkout. That checkout is created after the agent's process has exited. - Sandbox. The Claude backend runs
claude -pwith--restricted, which confines file tools to the worktree, so the agent can't read your main checkout or the journal. It also passes--safe-mode(no CLAUDE.md, hooks, skills or plugins from your machine),--strict-mcp-config,--permission-prompts none, and an--allowedToolslist in which Bash is allowed only for the exact commands inallowed_bash. Denied tool calls are recorded in the experiment's log. - Prompts. Rows go through
prompt.agent_viewbefore rendering, which dropsheldout_scoreandheldout_status. A candidate blocked by the gate appears as "not kept after validation (details withheld)". The agent learns one bit, that the idea was not kept, and never the number. - Order. Held-out runs only for candidates that already beat the best on dev, so the number of held-out consultations is small. The report shows it, so you know how much the held-out set has been "used".
Noise policy
The baseline runs baseline_repeats times, which gives a standard deviation σ. Each
candidate runs repeats times, stopping early if the first run is hopeless. To be
kept, a candidate's mean must beat the best by more than
margin = max(min_improvement, sigmas × σ × sqrt(2 / repeats))
σ·sqrt(2/repeats) is the standard error of the difference between two means of
repeats runs each. For a deterministic metric σ is 0, so the margin is
min_improvement.
Parallel workers and de-duplication
max_workers threads each run attempts. All of them see the same journal, plus an
"in flight" list of what the other workers are trying. Optional directions give each
attempt a distinct focus, rotating through the list.
If an attempt beats the commit it started from, but another worker moved the best in the meantime, Hillclimb cherry-picks the attempt onto the new best and measures it again. Independent wins stack this way. Conflicting ones are rejected, and the reason is recorded.
Duplicates: an attempt whose patch is byte-identical to one already measured on the same parent is rejected without re-measuring. A hypothesis whose wording is very close to an earlier one (token Jaccard ≥ 0.6) is marked as a near-duplicate in the journal and the prompt.
Resume
Everything is in state_dir/hillclimb.db (SQLite, WAL). On hillclimb run:
- if the latest run isn't
done, it resumes. Attempts caught mid-flight are markedinterruptedand don't count against the iteration budget. Stale worktrees are removed. The baseline isn't re-measured. - an acceptance is written to the journal (
accepting) before the branch moves. After a crash, anacceptingrow whose commit is the branch tip becomesaccepted, and any other becomesinterrupted. - Ctrl-C once: stop starting new attempts, kill agent and metric process groups, mark in-flight attempts interrupted, write the report. Ctrl-C twice: exit immediately. The next run repairs the state.
hillclimb run --new starts a new run from the tip of hillclimb/best.