Datasets:
foresightCoder — the Anticipation-Gap Benchmark
Measures whether a coding agent anticipates edge cases before a human reports them.
Each instance is a real PR fix-chain PR1 → PR2 mined from a public Python repo: PR1
introduced or owned some behavior, and a later PR2 fixed an edge case PR1 missed. PR2's
tests are a held-out reward signal — an agent solving PR1 from clean intent should pass
them even though PR1's human author didn't.
The headline metric is the anticipation gap:
gap = X − Y, where X = % of PR1's own tests the agent passes (did it do the stated task?) and Y = % of the unseen future-PR anticipation tests it passes (did it anticipate the edge case?). A large gap means the model solves the asked task but misses the foreseeable failure.
Every chain here is fully-gradeable: PR1 has its own FAIL_TO_PASS tests and PR2 has
validated anticipation tests, and all 67 reproduce inside their per-repo linux/amd64 Docker image
under the full 3-state definition (pass@pr2_head ∧ fail@pr2_base ∧ fail@pr1_head for anticipation;
pass@pr1_head ∧ fail@pr1_base for PR1-own). Verification and the PR1 FAIL_TO_PASS/PASS_TO_PASS
recomputation were run on linux/amd64 — the architecture the eval/HPC runs on — so the fail→pass
property is guaranteed on the target arch (one pandas chain whose anticipation test is
architecture-dependent was dropped).
60 of the 67 are eval_ready (the recommended eval set): the anticipation target is a genuine
bug (not a new feature), and PR1's task statement is clear (clarity_score ∈ {0,1}) and solvable
from the statement (pr1_code == "A"). The other 7 are kept for completeness but flagged. 20
instances had an under-specified PR1 statement enriched to be solvable (pr1_spec_repaired; PR2 never
entered the repair, so the held-out signal is not leaked) — see pr1_code_original == "B2".
Composition (67 chains across 14 repos; 60 eval-ready across 13)
django:16 · sqlglot:11 · pytest:11 · starlette:6 · networkx:5 · xarray:5 · pandas:3 · sphinx:3 · moto:2 · attrs:1 · sqlfluff:1 · packaging:1 · pygments:1 · sympy:1
Test harness: 51 pytest + 16 Django (tests/runtests.py). The runner field tells them apart.
Schema
SWE-bench-compatible fields describe the PR1 task the agent solves; anticipation_* /
ANTICIPATION_FAIL_TO_PASS add the held-out PR2 edge case.
| field | meaning |
|---|---|
instance_id |
{repo}__{earlier_pr}-{later_pr} |
repo |
owner/name |
base_commit / environment_setup_commit |
commit the agent starts from (before PR1) |
problem_statement |
PR1's intent — derived from PR1 only (no PR2 leakage) |
problem_statement_raw |
original human PR1 title/body (provenance) |
patch |
gold PR1 source diff (withheld from the solver) |
test_patch |
PR1 test diff |
FAIL_TO_PASS |
PR1's own fail→pass tests → the X score |
PASS_TO_PASS |
PR1 regression tests that must stay green |
anticipation_patch |
gold PR2 source diff (the fix for the missed edge case) |
anticipation_test_patch |
PR2 test diff |
ANTICIPATION_FAIL_TO_PASS |
the held-out edge-case tests → the Y score |
pr2_problem_statement |
PR2's intent as an explicit task (synthesized, then spec-repaired to be solvable from the held-out tests) — input for the PR2-direct oracle (start at pr1_head_sha, grade ANTICIPATION_FAIL_TO_PASS) that upper-bounds the anticipation score |
pr2_problem_statement_raw |
original human PR2 title/body (provenance) |
pr2_spec_repaired / pr2_spec_code |
whether the PR2 statement was enriched so the held-out tests are solvable; A = solvable, B5 = gold anticipation_patch bundles unrelated changes the tests require (2 instances) |
pr1_test_files / anticipation_test_files |
test files to run for X / Y |
docker_image |
per-repo eval image (docker.io/shaswatpatel123/foresight:<repo>, private) |
repo_path |
/testbed (SWE-bench convention) |
runner |
pytest or django (different test command) |
install_cmd / test_cmd / run_helper |
how to build the env and run tests in-image |
created_at / pr2_created_at / gap_days |
provenance + PR1→PR2 time gap |
eval_ready / fully_gradeable |
quality gates: eval_ready = bug target ∧ clear ∧ solvable PR1 |
pr1_code / pr1_code_original / pr1_spec_repaired |
PR1 task solvability (A / B*); original code before spec-repair; whether the statement was enriched |
severity / failure_mode / trigger_path / mechanism |
calibrated bug labels for the edge case PR2 fixed (LLM judge, anchored two-step rubric): severity = major/minor/not_a_bug; failure_mode = silent/loud/none; trigger_path = default/opt-in; mechanism = regression/missed_edge_case/… |
difficulty / pr1_difficulty |
PR2-fix difficulty (the fix) / PR1-task difficulty (the agent-facing statement) |
pr1_task_type |
what the agent-facing PR1 task is: bug (107) / feature (75) / mixed (12). Collapsed from the SWE-rebench-V2 meta_info 12-label rubric, which is multi-label — rows carrying both a bug and a feature label are reported as mixed rather than forced to one side. Two caveats: the rubric has no refactor class, so refactors are counted as feature (they land in core_feat; ~8% of rows); and its bug labels bake severity into the type (critical_/major_/minor_), so it is not a clean severity signal — use severity for that. There is deliberately no PR2 equivalent: the held-out PR is a fix by construction, so it would be bug on 190/194 rows. |
mining_category / mining_evidence / quality / clarity_score |
provenance & quality metadata (mining_category = which miner edge-source found the chain, not a bug type) |
Load
from datasets import load_dataset
ds = load_dataset("shaswat123/foresightcoder-anticipation", split="test")
print(ds[0]["instance_id"], ds[0]["runner"])
Eval flow (per instance)
- Start an agent at
base_commit(before PR1) withproblem_statementas the task; let it edit/testbed. - Score X: run
pr1_test_filesand checkFAIL_TO_PASS(overlay the post-PR1 test versions). - Score Y: run
anticipation_test_filesand checkANTICIPATION_FAIL_TO_PASSthe same way. - Report X, Y, and the gap X − Y, per chain and aggregated.
The baked eval primitive (run_state.sh for pytest, run_state_django.sh for Django) reproduces
each state: <checkout_sha> <overlay_sha|-> <junit_out> <test_files...>.
⚠️ The Docker images referenced are private; request access or rebuild them from the project's
scripts/gen_docker.py. The problem statement is derived from PR1 only — never from PR2 — to preserve the held-out independence the metric depends on.
License
MIT. Patches/tests are derived from the respective upstream repositories under their own licenses.
The verified split (210 rows, 203 gradeable)
It is a separate config, because its schema differs from the v1 test split
(it adds the ODC axes, the SZZ attribution verdict and the fairness consensus, and drops
v1-only fields). Load it explicitly:
from datasets import load_dataset
verified = load_dataset("shaswat123/foresightcoder-anticipation", "verified", split="verified")
test_v1 = load_dataset("shaswat123/foresightcoder-anticipation", split="test")
A second, larger split drawn from the full mined frame and held to a stricter bar than
the original test split. Multi-language: python 121, javascript 49, typescript 30, go 3. 13 rows are
advisory-derived security chains (mined from a CVE/GHSA, then SZZ-blamed back to the
introducing PR); separately the security column flags 16 that the severity judge
reads as security-relevant. The two overlap on 12 and measure different things —
provenance versus judged consequence.
Every instance satisfies all of:
- Executed and non-degenerate —
FAIL_TO_PASS,PASS_TO_PASSandANTICIPATION_FAIL_TO_PASSare all non-empty, and PR1's base state genuinely built (a state that fails to compile yields an empty baseline, which makes every passing test look like a fail->pass; those are excluded). - A real missed edge case — an LLM eligibility judge rates it
clean(not a new feature, revert, or non-bug). - Correctly attributed — where PR1 was found by SZZ blame rather than a human
cross-reference, an attribution judge confirms PR1 actually introduced the defect
(code
A). Chains where the defect predates PR1, or PR1 merely moved the lines, are excluded. - A fair task — two independent judges (
deepseek-v4-flash,glm-5.3-flash) must BOTH rate the PR1 statement free of mechanism-prescription and free of any leak of the future fix. - Solvable from the PR2 statement alone — the PR2-direct task carries
under-specification code
A, so the held-out tests are derivable from what the statement says.
Labels: severity is derived from impact x reach x failure_mode
(detectability), following IBM's Orthogonal Defect Classification; pr1_difficulty
and difficulty are the PR1 and PR2 task tiers.
| axis | distribution |
|---|---|
| detectability | silent 120 · loud 83 |
| PR1 difficulty | easy 48 · medium 72 · hard 83 |
| PR2 difficulty | easy 119 · medium 50 · hard 34 |
Of these, 188 were newly mined and validated and 22 are re-used from the v1 test
split — chains that passed every gate above when re-judged, carrying their original
published statements so the existing eval results remain valid for them. The
provenance field distinguishes the two, and re-used rows keep the v1 per-repo
image tag (:django) rather than the newer :env-django-py3.11 form.
Human discussion: pr_comments and linked_issues
The prose humans wrote around the two PRs, shipped so a consumer can check the labels
rather than take them on trust — reach and severity are meant to cite reporter counts
and reactions, and neither is verifiable from the patches alone. Both columns are
JSON-encoded strings, matching the rest of the split.
| column | contents |
|---|---|
pr_comments |
the conversation on both PRs — issue comments, inline review comments and review bodies — each with role (fixer/introducer), kind, number, author, url, created_at, body. For django chains kind is trac_ticket as well as pr, since django is Trac-numbered and both threads are kept. |
linked_issues |
the reporter-side issues each PR closes, mentions, or is cross-referenced from: number, url, title, body, labels, reactions, ref_type (closes/mentions/cross-referenced), and the issue's own comments. This is where impact and prevalence are stated. |
Coverage: all 214 rows carry a record; 211 have at least one PR comment and 158
at least one linked issue, totalling 6,790 PR comments and 476 linked issues
(themselves carrying 2,781 comments). Ten rows have an empty fixer-side thread and
so carry [] in pr_comments. Every entry keeps its url, so any quote is traceable
to its source.
Reward sets, and the excluded flag
Four test-name lists ship per row. FAIL_TO_PASS / PASS_TO_PASS score the PR1
task (did the agent do the stated work, without regressions). ANTICIPATION_FAIL_TO_PASS
is the held-out signal: PR2's fail->pass restricted to tests that ALSO fail at PR1's head,
i.e. the edge cases PR1's author missed. PR2_FAIL_TO_PASS / PR2_PASS_TO_PASS are
new: they score the PR2-direct task, which starts at pr2_base_sha, and give the
oracle an upper bound to compare the anticipation rate against.
All 210 rows are kept, including 7 that no longer meet the
gradeability bar -- filter on gradeable (or excluded). They stay so the reason
travels with the data, in exclusion_reason:
| reason | n | meaning |
|---|---|---|
no_pr1_failure |
2 | PR1's own tests no longer fail at pr1_base |
pr1_f2p_zero |
2 | nothing failed at pr1_base, so there is no PR1 fail->pass set |
pr2_not_fail_to_pass |
2 | PR2's tests no longer fail at pr2_base |
env_failed_pr2 |
1 | the PR2-era environment did not produce outcomes |
Note that 4 of the 7 fail on
the PR1 boundary, not PR2. Most are a fixed measurement rather than a changed chain:
a directory fixture (svelte's samples/<case>/main.svelte) was previously absent from the
base-state overlay, so a test "failed before" only because the component was missing. With
the overlay corrected the test passes at base and the flip legitimately disappears.
p2p_excluded_gold_fail
A PASS_TO_PASS name that fails under the GOLD PR1 patch cannot measure a regression the
AGENT caused -- it reports one against a solution that is correct by construction, so
every model is penalised for something no model did. Such names are subtracted from
PASS_TO_PASS and listed here, so the drop is auditable rather than silent. This is the
same rule already applied to the anticipation set, moved to the no-regression side.
caddy__6232-6429 drops TestLeafCertLoaders (60 -> 59). caddy installs its local CA
root on first HTTPS use, which blocks ~9s against caddytest's 5s LoadRequestTimeout,
so the test fails on a deadline. Pre-baking the CA fixes that test but costs two others:
caddy's integration suite is order- and timing-dependent (TestRespondWithJSON fails in
isolation on the unmodified image and only passes when preceded by the rest of the
suite), so no image change reaches 60/60. PR1's patch touches httpcaddyfile and the
intercept module -- nothing near certificate loading -- so the dropped name carried no
regression signal for this task.
Each row names its own docker_image (linux/amd64), and it is the eval-ready
image: tier 3, built at pr1_base_sha with the per-commit recipe baked and
dependencies already installed into /opt/venv, so there is nothing to resolve at eval
time -- no bind-mount, no network. The agent starts there and both gradings run there.
For the 22 re-used v1 rows it is the per-repo image the published eval actually used
(:django), which has its own prebuilt environment; image_tier says which convention
a row follows. env_image_pr1 / env_image_pr2 additionally name the thin tier-2
images (interpreter + clone, no dependencies) that VALIDATION runs against, since the
validator bind-mounts the recipe at run time. All 196 distinct images resolve on the
registry. The test split is unchanged and remains the 67-row v1 artifact
the published anticipation-gap numbers were measured on.
- Downloads last month
- 142