You need to agree to share your contact information to access this dataset

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this dataset content.

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)
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)

  1. Start an agent at base_commit (before PR1) with problem_statement as the task; let it edit /testbed.
  2. Score X: run pr1_test_files and check FAIL_TO_PASS (overlay the post-PR1 test versions).
  3. Score Y: run anticipation_test_files and check ANTICIPATION_FAIL_TO_PASS the same way.
  4. 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 instances)

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 54, typescript 31, go 4. 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-degenerateFAIL_TO_PASS, PASS_TO_PASS and ANTICIPATION_FAIL_TO_PASS are 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 125 · loud 85
PR1 difficulty easy 49 · medium 72 · hard 89
PR2 difficulty easy 122 · medium 50 · hard 38

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.

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
5