SWE-bench adapter, stage 1: fetch, fresh-snapshot colony runs, budget envelope, scoring with a controls checklist - #493
Merged
Conversation
… envelope, scoring with a controls checklist Refs #331 Co-Authored-By: Colonizer Settlers <331648616+colonizer-settlers@users.noreply.github.com>
ParallelEntrepreneur
force-pushed
the
colonizer/issue-331-f89da331
branch
from
September 24, 2026 16:13
5963bc6 to
29eec2c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First slice of #331. The issue is an epic: real Lite, Verified and Multilingual runs and a leaderboard submission need a live mothership, Docker and real spend. They also depend on the gold-sanity gate (#330) and a trajectory monitor, which don't exist yet. This PR delivers the plumbing those runs go through, with unit tests. The first real run can then be a 5-task Lite slice.
What changed
scripts/swebench.mjs(new): a CLI in the same style asscripts/bench.mjs, with three subcommands:fetch <dataset>takes a local.json/.jsonlfile or a HuggingFace id (princeton-nlp/SWE-bench_Lite,…_Verified,SWE-bench/SWE-bench_Multilingual), fetched through the HF datasets-server rows API with pagination. It supports--split/--offset/--limit/--ids. It normalizes each instance: checks the required fields and parses the JSON-string-encodedFAIL_TO_PASS/PASS_TO_PASS.run <instances.json> --owner … --task-budget … --total-budget …refuses to start unless both caps are declared. For each instance:base_commit, then the upstream.gitis dropped and the tree is re-initialized as a single commit with no remote and no later history. That commit is pushed to a private<owner>/swebench-<id>repo, which is reused if its tree matches.instructions, so no GitHub issue is created. Gold patch, test patch and F2P/P2P lists never reach the scratch repo or the session.model_patchfrom the colony's branch against the pushed snapshot.cost_usd/routed_cost_usdfromGET /api/sessions/{id}and callsPOST /api/sessions/{id}/stoponce the cap is passed.budgetGatebefore each task. When it trips, the rest of the instances are recorded asskipped-budget. They are reported separately and nothing is extrapolated.swebench-<label>.jsonandswebench-<label>.predictions.jsonlin the official SWE-bench predictions format.score <run.json> --dataset …runs the official harness (python -m swebench.harness.run_evaluation) in its own Docker environment, which the colony never touched. It can also ingest an existing report with--report. The result is merged into the record:Score record: it carries the suite, the colony configuration (model tier and overrides), the budget envelope (
task_usd,total_usd,spent_usd,stopped_at_cap), per-task outcomes and flags, and acontrolschecklist.calibratedis true only when every control holds. As of this PR:test_patch(touches-eval-tests), and those tasks are excluded from the clean countSo every run from this slice is labeled uncalibrated in both the record and the printed summary. That follows the issue's rule: a run missing any control is never compared.
Other files:
scripts/test/swebench.test.mjs(new): tests for dataset parsing (JSON, JSONL, string-encoded lists, missing fields, envelope round-trip),--offset/--limitselection, and the snapshot builder. The snapshot test runs on a localfile://repo with two commits and checks for exactly one commit, a tree identical to the base, no remotes, and no later file. It also covers patch flags, including a deliberately leaked answer being caught and excluded from clean, the budget gate stopping at the cap, prediction shape, report scoring math (raw/clean/per-language/harness errors), andisCalibrated.scripts/bench.mjs:apiis now exported (one word) so the adapter reuses the auth/fetch wrapper instead of copying it.docs/bench.md: new "External suites (SWE-bench)" section. It covers the three stages and their order, the commands, the budget envelope, the controls table with what is enforced vs not, and prerequisites (ghallowed to create repos; Docker pluspip install swebenchfor scoring).CHANGELOG.md: Unreleased → Added entry.Verification
node --test scripts/test/*.test.mjs: 68/68 pass (11 new) andnode --check scripts/swebench.mjsis clean. The new script is executable, likebench.mjs.cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace --locked(904 + 4 tests) and webtsc --noEmitall pass. No Rust or web code changed.fetch princeton-nlp/SWE-bench_Lite --limit 5gives 5 normalized instances (astropy__astropy-12907,-14182,-14365,-14995,-6938). The full 300-row fetch,--idsand--offset/--limitwere checked as well.score --reportwas run end to end on a synthetic run.--instance_idstakes space-separated values, and the report is written to--report_diras<model with / → __>.<run_id>.json.run) or a live Dockerscore. There is no mothership or Docker in this sandbox. The 5-task Lite dry run from the issue's test plan is the next step, on a real host.For reviewers
runcallsgh repo create --privateon the host, one scratch repo per instance (300 for full Lite), and pushes to it. It also stops colonies based on client-side cost polling. Please look closely atbuildSnapshot/scratch-repo reuse and the poll-and-stop loop.NewSession(crates/colonizer/src/sessions.rs:877) has no per-session budget field, so the adapter polls live cost and stops the colony. A server-side per-session cap would be stricter. That's follow-up work in this epic.languagecolumn in the HF dataset (checked against datasets-server), so its per-language breakdown groups underunknownfor now. Stage 3 needs a repo → language map and per-language sandbox presets.CHANGELOG.md(one entry under Unreleased → Added) is shared with sibling colonies.ci.ymlandREADME.mdare untouched, since CI already runsscripts/test/*.test.mjs.What remains for #331
controls; network answer-source controls for colonies. Until then every run is uncalibrated.presets.rs, but a session can't pick one yet)Closes #331
🤖 Generated by Colonizer in a microVM
Co-Authored-By: Colonizer Settlers 331648616+colonizer-settlers@users.noreply.github.com