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

Anti-cheat

After the agent exits, before anything is measured:

  1. Purge ignored files (git clean -X). A planted .pyc or cache file can't shadow a frozen module.
  2. Scope. Every changed, added or deleted path must match an editable glob. Anything else rejects the attempt and names the path.
  3. Frozen hashes. At run start, every tracked file matching a frozen glob (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 with git update-index --assume-unchanged or --skip-worktree. The committed blob is checked again.
  4. Held-out absent. Held-out files must still be absent from the worktree.
  5. No symlinks in changed paths.
  6. 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.

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:

hillclimb run --new starts a new run from the tip of hillclimb/best.