Raven-1/benchmarks/__init__.py
ethanwwwwwwww e3ca5d9e4f feat(*): self-evolution stack: evolver, appworld bench, unified entry (#140)
## Summary

Port the harness self-evolution framework onto Raven and grow it into a
runnable, benchmark-pluggable stack: a budget-bounded loop that
diagnoses
failing trajectories, designs candidate patches as real git commits,
screens
them cheaply, confirms survivors, and promotes only what passes three
verification gates -- with a sealed test set for an honest
generalisation
number.

- **Evolution machinery** (`raven/evolver/`): orchestrator state machine
  (seven-step funnel), three verification gates (infra validity, beacon
  attribution, paired significance), sealed-test runner with retention,
  git-backed candidate tree, judge, taxonomy, activation ledger.
- **AppWorld bench** (`benchmarks/appworld/`): agent_cli, batch scorer
with trial-level resume and an infra-rerun ladder, plus the evolve glue
(designer, diagnosis, adapter, Gate0 precheck with real-generation
probing).
- **Unified entry**: `python -m raven.evolver
{check,run,status,finalize}`
drives cold start -> rounds -> terminate -> unseal as a resumable state
machine. Config drift and unseal one-wayness are mechanized in run meta;
benches plug in via a documented contract
(`docs/specs/evolve-bench-contract.md`).
- **Designer feedback**: inert-death loop (pruned_inert status, per-WHY
  history, gentle decay) so unreachable triggers teach the next attempt.
- **Launch hygiene**: `check` runs the bench Gate0 precheck, so a dead
subject endpoint fails at check time instead of at cold start; ephemeral
eval/edit worktrees live under `work_dir/tmp` and hard-kill leftovers
are
  swept on the next launch of the same run.
- **Docs**: SOP translation (internal details redacted), SOP-to-code
map,
  bench plugin contract, and a user README with security notes and known
  limitations.

## Type

- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other

## Verification

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed

Commands run:

- `uv run pytest tests/test_evolver_launch.py
tests/test_evolver_launch_e2e.py -q`
-> 56 passed (config, guards, trial-level idempotency, interrupt ->
resume ->
  finalize with a fake bench, check precheck pass/fail, worktree sweep).
- `uv run ruff check` on all touched files -> no new findings versus
base
  (one S607 partial-path git call matching the file's existing idiom).
- Real AppWorld end-to-end through the unified entry, from a fresh
config
written by following the README user path: `check` -> `run --smoke` (~16
min:
cold start on 3 tasks, one full round with real diagnose/design, a real
1-line candidate commit, focused probe + confirm, promoted with an
honest
  `credited=False` Gate-b verdict) -> termination.
- Real `check` both ways: live subject endpoint -> `bench precheck: OK`;
config pointed at a dead (NXDOMAIN) endpoint -> exit 1 at check time
with
  an actionable `subject endpoint unreachable` message.
- The bench placement (repo-root `benchmarks/`, outside the wheel,
matching
this directory's decoupling convention) was verified with a second real
smoke: all three phases ran against a checkout of this layout, worktree
evals resolved `python -m benchmarks.appworld.batch` from the checkout,
  and the designer wrote its candidate to the new whitelist path
  (`benchmarks/appworld/agent_cli.py`) as a real commit.

## Risk

- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

Security: this system has an LLM edit and execute code. Candidate edits
are
constrained to a per-bench path whitelist, an immutable kernel protects
the
measurement surface (the evolver itself and the scorer), and the README
documents the threat model plus the recommendation to run evolutions in
an
isolated environment. Backward compatibility: purely additive -- new
packages
plus one optional `BenchBundle.precheck` field; nothing existing changes
behavior. Rollback: revert the branch; no migrations, no config changes
to
existing features.

## Related Issues

N/A

---

Reviewer notes:

- Exercised at smoke scale only: a full-size run (90 tasks x K=3,
multi-round,
hours) and the sealed-test unseal/retention path on a real benchmark are
covered by tests but not yet by a production run; the README states this
  under "Status and known limitations".
- One bench ships today (AppWorld, built-in scorer line); a
framework-line
  example (external scorer) is planned as a follow-up.

---------

Co-authored-by: Ethan Wang <ethan.wang@evermind.ai>
Co-authored-by: Claude (claude-fable-5) <noreply@anthropic.com>
Co-authored-by: Elliot Chen <2340896+cyfyifanchen@users.noreply.github.com>
2026-07-17 19:37:05 +08:00

9 lines
407 B
Python

"""Repo-root benchmark harnesses (see README.md in this directory).
This __init__ exists so evolvable benches (e.g. ``benchmarks.appworld``) are
importable with the repo checkout root on ``sys.path`` — the evolver inserts
the subject repo root before loading a bench plugin, and worktree evals rely
on cwd-first ``python -m`` resolution. The directory still ships in neither
the wheel nor the sdist.
"""