Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
ef70351
verify: fc-verify with status, classify, report, review and automatic…
ArjunS07 Oct 19, 2026
7fcb5eb
verify: precheck stage (patch applies, base edits, benchmark coverage…
ArjunS07 Oct 19, 2026
61f41a8
verify: build, pin, scrub and publish stages for task images
ArjunS07 Oct 19, 2026
37fb966
verify: measure stage, measure gate service and NopTouch; template lo…
ArjunS07 Oct 19, 2026
964e046
verify: test reads the job config with Path
ArjunS07 Oct 19, 2026
c5f37e1
verify: release readiness (registry, template commits, runs, CPU type…
ArjunS07 Oct 19, 2026
3d3c26b
verify: snapshot capture stage
ArjunS07 Oct 19, 2026
2ed3f64
verify: port the build guard, disk stop and image check tests
ArjunS07 Oct 19, 2026
493750c
verify: PR number from the image name too
ArjunS07 Oct 19, 2026
6759111
verify: an empty pin reads as no pin
ArjunS07 Oct 19, 2026
08dca8a
datasmith: load dotenv only when tokens.env exists, so the verify sta…
ArjunS07 Oct 19, 2026
f76f520
verify: the command imports with the standard library, so build hosts…
ArjunS07 Oct 19, 2026
c8ace12
verify: push verified manifest rows to the registry as they are
ArjunS07 Oct 19, 2026
a2faa02
verify: select (records, database candidates, sampler) and env-image …
ArjunS07 Oct 19, 2026
764896c
verify: port the sampler order and replacement tests
ArjunS07 Oct 19, 2026
7887c21
Merge remote-tracking branch 'origin/release/template-v1' into verify…
ArjunS07 Oct 19, 2026
fe662ba
verify: apply approved prompt text to rendered tasks
ArjunS07 Oct 19, 2026
10eeee4
prompts: short (symptom-only) prompts by default for new tasks, a pro…
ArjunS07 Oct 19, 2026
38c2048
Revert an unrelated lint change to harbor_healthcheck.py
ArjunS07 Oct 19, 2026
9f97aa9
Pin harbor to formulacode/harbor-reliability e7d19622, the commit for…
ArjunS07 Oct 19, 2026
4ea5848
docs: delete dated plans, handoffs and the duplicate rl-prep folder
ArjunS07 Oct 19, 2026
1cdf23a
docs: tasks are rendered by datasmith.harbor_adapter and run on Harbor
ArjunS07 Oct 19, 2026
aea844e
docs: end-to-end pipeline overview and the PR template
ArjunS07 Oct 19, 2026
7bb47bb
task template: shorter comments in parser.py and lsv_measure.py
ArjunS07 Oct 19, 2026
b93d432
src: comments say what and why in one or two lines; no host paths
ArjunS07 Oct 19, 2026
2135c52
docs: overview covers short prompts and the prompt commands
ArjunS07 Oct 19, 2026
7669372
verify: a measure time limit ends a task as too_slow and frees its ga…
ArjunS07 Oct 19, 2026
d10e6a6
Merge remote-tracking branch 'origin/release/template-v1' into verify…
ArjunS07 Oct 19, 2026
510067c
Merge remote-tracking branch 'origin/verify/core' into cleanup/docs-a…
ArjunS07 Oct 19, 2026
328fdc2
docs: render from template-v1.2
ArjunS07 Oct 19, 2026
8d6388b
lint: sorted imports in orchestrator.py; URL opens marked as intended…
ArjunS07 Oct 19, 2026
dd9767f
verify prompt: apply only entries approved with a review date; skip t…
ArjunS07 Oct 19, 2026
cd0519f
task template: restore test files before tests, and run the changed p…
ArjunS07 Oct 19, 2026
94a3838
pytest runner: a test file that stops importing is a regression; coll…
ArjunS07 Oct 19, 2026
a3fc7fc
pytest runner: keep the end of the wider run's output when it gives n…
ArjunS07 Oct 19, 2026
336fda5
pytest runner: the wider check also runs the tests folder above a cha…
ArjunS07 Oct 19, 2026
e92ffab
pytest runner: pytest 9 has no config.rootdir; use rootpath
ArjunS07 Oct 19, 2026
d3b18e6
tests: ruff format
ArjunS07 Oct 19, 2026
fa3ae71
verify: count oracle test failures from the test rerun (oracle_tests_…
ArjunS07 Oct 19, 2026
8f0db18
prompts: rewrite handles an empty problem text
ArjunS07 Oct 19, 2026
5d56364
prompts: keep the blank line before the next heading when the problem…
ArjunS07 Oct 19, 2026
52bf6a1
Merge verify/core into docs/overview-and-comments (keep this branch's…
ArjunS07 Oct 19, 2026
498c2bd
Merge origin/release/template-v1 (template-v1.4) into verify/core
ArjunS07 Oct 19, 2026
3964b62
measurement: new package with the noise rule and the NopTouch agent, …
ArjunS07 Oct 19, 2026
1963ea7
harbor healthcheck: keep the oracle snapshot reference in a folder; d…
ArjunS07 Oct 19, 2026
f80f61e
measurement: the measure job moves to measurement/run.py; trials take…
ArjunS07 Oct 19, 2026
c4dbcf6
measurement: precheck decides from the image build check fields (temp…
ArjunS07 Oct 19, 2026
2f98e4e
images: task image build in docker/, the build loop as BuildTaskImage…
ArjunS07 Oct 19, 2026
6dce9d6
prompts: RenderShortProblemsRunner renders the symptom only, refuses …
ArjunS07 Oct 19, 2026
6cf5990
measurement: write the harbor job config as JSON (drops the yaml impo…
ArjunS07 Oct 19, 2026
7f5dda7
verify: delete the package and fc-verify; fc-measure (precheck, measu…
ArjunS07 Oct 19, 2026
13b98a0
build_task_images: look up Docker's data dir once, and fall back to /…
ArjunS07 Oct 19, 2026
91f7789
Merge verify/core into docs/overview-and-comments (accept the verify/…
ArjunS07 Oct 19, 2026
277de35
measurement: fc-measure measure --time-limit stops a job past the lim…
ArjunS07 Oct 19, 2026
62a736f
render_problems: IPython display hooks such as _repr_html_ are public…
ArjunS07 Oct 19, 2026
0a66766
docs: overview and CLAUDE.md describe fc-measure, fc-build-tasks and …
ArjunS07 Oct 19, 2026
abe8074
lint: ruff format huggingface.py and harbor_healthcheck.py
ArjunS07 Oct 19, 2026
7854274
measurement, harbor_adapter: type annotations for mypy; ruff format; …
ArjunS07 Oct 19, 2026
b53b292
Merge verify/core (mypy and lint fixes) into docs/overview-and-comments
ArjunS07 Oct 19, 2026
4d1aa7d
Merge pull request #68 from formula-code/fix/protect-test-files
ArjunS07 Oct 20, 2026
5d7ebe7
Merge pull request #66 from formula-code/verify/core
ArjunS07 Oct 20, 2026
18aaa8b
Merge pull request #67 from formula-code/docs/overview-and-comments
ArjunS07 Oct 20, 2026
791fa89
Merge remote-tracking branch 'origin/verify/core' into fix-stack-merge
ArjunS07 Oct 20, 2026
9579842
test: run the import regression test from the repo, as test.sh does
ArjunS07 Oct 20, 2026
fc6ac81
format: pre-commit on all files
ArjunS07 Oct 20, 2026
de89d89
scrub_git: remove nested .git dirs too, as the old verify scrub did
ArjunS07 Oct 20, 2026
f153113
apply_oracle_patch: drop the docstring reference to the deleted cover…
ArjunS07 Oct 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!-- Style rules: docs/PR_STYLE.md. Delete any section that adds nothing. -->

## Purpose

<!-- 2 to 4 sentences: the problem, then what this PR does. -->

## How it works

<!-- Mermaid diagram for flows. `text` file tree for new or changed files. -->

```text
path/
└── file.py # new: what it does
```

## Changes

<!-- Numbered, grouped by area. Each item: what, Effect:, Before:. -->

1. **What changed.**
Effect: what is different now.
Before: what happened before.

## Usage

```bash
# exact commands or config
```

## Verification

<!-- Real commands and real numbers. Never invented. -->

## Notes

<!-- Merge order, dependencies on other PRs, what is not done, decisions for the reviewer. -->
47 changes: 20 additions & 27 deletions CLAUDE.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion DATASET_CARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</a>
</p>

[FormulaCode](https://formula-code.github.io/) is a *live* benchmark for evaluating the holistic ability of LLM agents to optimize codebases. FormulaCode consists of two parts: a [pipeline](https://github.com/formula-code/datasmith) to construct performance optimization tasks, and an [execution harness](https://github.com/formula-code/terminal-bench) that connects a language model to our terminal sandbox.
[FormulaCode](https://formula-code.github.io/) is a *live* benchmark for evaluating the holistic ability of LLM agents to optimize codebases. FormulaCode consists of two parts: a [pipeline](https://github.com/formula-code/datasmith) to construct performance optimization tasks, and an [execution harness](https://github.com/formula-code/harbor) (Harbor) that connects a language model to our terminal sandbox.

This dataset contains **{total_rows}** enriched performance optimization tasks derived from real open-source Python projects, spanning {num_months} months of merged PRs.

Expand Down
6 changes: 0 additions & 6 deletions HANDOFF.md

This file was deleted.

63 changes: 19 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
</a>
</p>

[FormulaCode](https://formula-code.github.io/) is a *continually updating* benchmark for evaluating the holistic ability of LLM agents to optimize codebases. FormulaCode consists of two parts: a [pipeline](https://github.com/formula-code/datasmith) to construct performance optimization tasks, and an [execution harness](https://github.com/formula-code/terminal-bench) that connects a language model to our terminal sandbox. _This repository contains the task generation pipeline._
[FormulaCode](https://formula-code.github.io/) is a *continually updating* benchmark for evaluating the holistic ability of LLM agents to optimize codebases. FormulaCode consists of two parts: a [pipeline](https://github.com/formula-code/datasmith) to construct performance optimization tasks, and an [execution harness](https://github.com/formula-code/harbor) (Harbor) that connects a language model to our terminal sandbox. _This repository contains the task generation pipeline._

The end-to-end pipeline, from task selection to RL training, is described in [docs/OVERVIEW.md](docs/OVERVIEW.md).

`fc-data` is a python package for automatically curating and managing [FormulaCode](https://formula-code.github.io/) tasks. After installation, fc-data is designed to run as a monthly CRON job that updates the FormulaCode dataset with new commits and repositories.

Expand Down Expand Up @@ -231,30 +233,26 @@ hf = HuggingFacePublisher()
hf.publish(records, version="formulacode@2026-03")
```

We define tasks using `terminal-bench`'s formulacode adapter for evaluation:
Tasks are Harbor task folders rendered by `datasmith.harbor_adapter`. Render them from a records file with
`fc-render-tasks`, then run them with [Harbor](https://github.com/formula-code/harbor) (Harbor's `adapters/formulacode`
imports this package):
```bash
fc-render-tasks render --records records.jsonl --out tasks/ --cpus 2 --memory 16G --storage 20G
harbor run -p tasks/<owner>__<repo>__<N> -a oracle # the oracle agent applies the human patch
```

Or from Python:
```python
from terminal_bench.adapters.formulacode import FormulaCodeAdapter
from terminal_bench.harness.harness import Harness

adapter = FormulaCodeAdapter(task_dir="fctasks/", force=True)
adapter.generate_task(pr.to_record())

run = Harness(
output_path="fcevals/",
dataset_path="dataset_path",
task_ids=[pr.to_record().task_id],
agent_configs=[
{"agent_name": "nop", "model_name": "nop"},
{"agent_name": "oracle", "model_name": "oracle"},
],
)
from datasmith.harbor_adapter.adapter import FormulaCodeAdapter, FormulaCodeRecord

print(run.results[0].is_resolved) # Did the oracle get a speedup > 1.00 over baseline?
FormulaCodeAdapter(harbor_tasks_root="tasks/").generate_task(FormulaCodeRecord(**record))
```

How a rendered task becomes an approved, measured task is in [docs/OVERVIEW.md](docs/OVERVIEW.md).

## Database schema

There are xix tables in Supabase (Postgres):
The main tables in Supabase (Postgres):

| Table | Primary key | Purpose |
|-------|-------------|---------|
Expand Down Expand Up @@ -391,29 +389,6 @@ $ fc-data --start-date 2026-02-01 --end-date 2026-03-01 --stage 5 \
| `--force` | Re-run synthesis even for tasks that already have a container or cached context (stage 5 only) |


## Dataset verification

Each task lives in `dataset/formulacode_verified/<owner_repo>/<sha>/` with a multi-stage Dockerfile and shell build scripts. The verification loop:

```bash
$ python dataset/verify.py --task dataset/formulacode_verified/<owner_repo>/<sha>
# Check failure.json for errors -> edit docker_build_pkg.sh / docker_build_run.sh -> rerun
# Done when verification_success.json appears
```

Only modify `docker_build_pkg.sh` and `docker_build_run.sh` during verification fixes.

```bash
$ python scratch/scripts/prepare_formulacode_dataset.py \
--input scratch/artifacts/pipeflush/perfonly_commits_master.parquet \
--output scratch/artifacts/pipeflush/perfonly_enriched.parquet \
--dockerhub-repository formulacode/all \
--upload-to-hf formulacode/formulacode-all \
--hf-verified-filter /path/to/valid_tasks.json
```

> Requires `HF_TOKEN` in `tokens.env`. The upload creates `default`, `verified`, and per-month (`YYYY-MM`) configs on Hugging Face.

### Evaluation
## Evaluation

Evaluation is done in FormulaCode's fork of the [terminal-bench](https://github.com/formula-code/fc-eval) evaluation framework.
Tasks run on [Harbor](https://github.com/formula-code/harbor). The steps from a rendered task to measurement, review, agent trials and RL training are in [docs/OVERVIEW.md](docs/OVERVIEW.md).
95 changes: 95 additions & 0 deletions docs/OVERVIEW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# FormulaCode pipeline overview

This page describes how one FormulaCode task goes from a merged pull request to an approved task that agents and RL
training use. The work spans five repositories. This repository (datasmith) holds the steps up to review and release.

| Repository | What it does in the pipeline |
|---|---|
| [formula-code/datasmith](https://github.com/formula-code/datasmith) | Collects PRs, renders problem texts and builds environment images (`fc-data`), renders Harbor task folders (`fc-render-tasks`), builds task images (`fc-build-tasks`), and prechecks and measures tasks (`fc-measure`) |
| [formula-code/lsv](https://github.com/formula-code/lsv) | The fork of asv that selects the benchmarks a patch affects and times them |
| [formula-code/snapshot-tester](https://github.com/formula-code/snapshot-tester) | Records benchmark outputs and checks that a patch did not change them |
| [formula-code/harbor](https://github.com/formula-code/harbor) | Runs trials: starts the task container, runs the agent, then runs the task's `tests/test.sh` |
| [formula-code/formulacode-verified-rl](https://github.com/formula-code/formulacode-verified-rl) | Runs the survey (measure, review), keeps the approved list, runs agent trials and the RL recipe |
| [formula-code/skyrl](https://github.com/formula-code/skyrl) | The RL trainer |

## The steps

```mermaid
flowchart TD
A["collect, problem text, environment image<br/>fc-data"] --> B["records<br/>fc-render-tasks export --from-db"]
B --> C["render<br/>fc-render-tasks render<br/>(template tag)"]
C --> D["build<br/>fc-build-tasks"]
D --> E["pin<br/>fc-render-tasks render --images"]
E --> F["precheck<br/>fc-measure precheck<br/>coverage, base edits, patch applies"]
F --> G["measure<br/>fc-measure measure<br/>3 oracle + 3 no-change runs,<br/>paired A-B-B-A, host lock folder"]
G --> H["classify, review, release<br/>formulacode-verified-rl"]
H --> I["Phase 2 agent trials and RL training<br/>formulacode-verified-rl, skyrl, harbor"]
```

1. **Collect.** `fc-data` collects performance PRs into the task database. Its `render_problems` stage uses
`RenderShortProblemsRunner`, which writes a short problem text that describes only the symptom. It does not store a
text that names benchmarks, PR or issue links, code, a diff or internal code the patch changes. Its image stages
build the environment image at the base commit.
2. **Records.** `fc-render-tasks export --from-db --ids-file IDS --out records.jsonl` writes one render record per
`owner/repo#N` from the task database.
3. **Render.** `fc-render-tasks render --records records.jsonl --out TASKS_ROOT` writes one Harbor task folder per record
from `src/datasmith/harbor_adapter/template/`. Render from a template tag, so every task of a release has the same
test scripts. Each folder gets `render_stamp.json`; `fc-render-tasks check` finds folders that no longer match the
installed template.
4. **Build.** `fc-build-tasks TASKS_ROOT OUT` builds and checks one image per task from its `environment/` folder. The
image tag is a digest of that folder. Each result is a row in `OUT/manifest.jsonl`; a failure is a row in
`OUT/failures.jsonl`.
5. **Pin.** `fc-render-tasks render ... --force --images OUT/manifest.jsonl` renders again and writes `docker_image` in
`task.toml` when the task's last verified image has the same `environment/` digest.
6. **Precheck.** `fc-measure precheck TASKS_ROOT TASK` loads the image build check from the database: does the oracle
patch apply, did the image already contain part of it, and does at least one benchmark run the changed code. A task
that fails ends as `uncovered`, `base_edited` or `patch_failed` and is not timed.
7. **Measure.** `fc-measure measure TASKS_ROOT OUT TASK` runs one Harbor job per task: 3 oracle runs and 3 no-change
runs. Each run times the base and the patched code in one container in the order A-B-B-A. Each timing step takes a
slot file of the host lock folder (`FC_MEASURE_LOCK_DIR`, `FC_MEASURE_LOCK_SLOTS` files), because timing is
sensitive to memory bandwidth. `--time-limit S` stops a job after `S` seconds and ends the task as `too_slow`. The
result is `OUT/oracle/<task>.json`.
8. **Classify, review and release.** formulacode-verified-rl applies the noise rule
(`src/datasmith/measurement/noise.py`). All values are natural-log speedups. For each benchmark $b$, the no-change
runs give a spread $\sigma_b$ (pooled with the repo's spread), and the threshold is
$\theta_b = \mathrm{clip}(k\sigma_b, \theta_{\min}, \theta_{\max})$ with $k = 2$. A benchmark is **up** when at least
2 of the 3 oracle runs are above $+\theta_b$, and **down** when at least 2 are below $-\theta_b$. The user then
reviews each measured task, and approved gold prompts are applied there (`apply_gold_prompt.py`).
9. **Agent trials and RL training.** formulacode-verified-rl runs agents on the approved tasks (Phase 2) and trains
with skyrl. Trials run on Harbor with the same task folders and images, and mount the same lock folder at
`/fc-measure-lock`.

## What "approved" means

A task is **approved** when it was measured and the user approved it after reading its per-benchmark table. Only the
user approves. The automatic rules only mark tasks `not_approved`, and they never change a row that has a decision.

The approved list is `verified_survey/approved.csv` in formulacode-verified-rl. Each row gives the task, its pinned
image, the render and template commits, the CPU models of the runs, the license and the PR author.

## Rebuild one task

```bash
echo "- owner/repo#N" > ids.md
git -C datasmith checkout template-v1.4 # render with the release template
fc-render-tasks export --from-db --ids-file ids.md --out records.jsonl
fc-render-tasks render --records records.jsonl --out tasks/ --cpus 2 --memory 16G --storage 20G
fc-build-tasks tasks/ images/ --ids-file ids.md
fc-render-tasks render --records records.jsonl --out tasks/ --force --images images/manifest.jsonl
fc-measure precheck tasks/ owner/repo#N
fc-measure measure tasks/ out/ owner/repo#N --time-limit 21600
```

The survey pipeline in formulacode-verified-rl (`verified_survey/pipeline.py`, see `verified_survey/README.md`) runs
the precheck and measure steps for many tasks at once and keeps the review decisions.

## Branches and pins

| Repository | Branch or commit | Where it is set |
|---|---|---|
| datasmith | `main`; release template on `release/template-v1` (tags `template-v1` to `template-v1.4`) | the tag you render from |
| lsv | `main` at `9702a48` | `LSV_REF` in `harbor_adapter/template/environment/Dockerfile` and `docker/templates/docker_build_final.sh` |
| snapshot-tester | `f08bb0c` | `SNAPSHOT_TESTER_REF` in the same two files |
| harbor | `formulacode/harbor-reliability` | the harbor checkout that runs trials |
| skyrl | `main` | the trainer checkout |
| formulacode-verified-rl | `main` | the survey and recipe checkout |
50 changes: 0 additions & 50 deletions docs/design/archived/ARCHIVED Datasmith - Docker Manager.md

This file was deleted.

Loading
Loading