Overview
Each item is a code change on a real, mature software project, graded by whether the project’s maintainers would merge it. The request is written in a maintainer’s voice and followed by the repository’s own test, lint and style guidelines; a weighted rubric checks behaviour, existing functionality, tests, scope and code quality, and any failed blocker scores the change 0. Each item has two parts: a Harbor task (the Dockerfile and build scripts of an offline development environment, the request, the rubric with its hidden tests, and a reference solution), ready for reinforcement learning; and trajectories of Claude Opus 5.5 at max effort in Claude Code, recorded request by request with a grade for every criterion, for supervised fine-tuning.
Difficulty and quality
- Hard tier: Claude Opus 5.5 at max effort succeeds in at most 1 of 3 attempts.
- Failures are the model’s, not the task’s: when the agent gets a task wrong, the cause lies in its own change, not in the request or the grader.
- Reference scores 1.0: every task comes with a reference solution that gets reward 1.0 under Harbor’s oracle agent, so you can check each task yourself.
What you get
tasks/ # Harbor tasks, one directory each
└── <task>/
├── instruction.md # request and repository guidelines: the agent's only input
├── task.toml # project, language, skills, base commit; resources and timeouts
├── environment/ # Dockerfile, build scripts, the repository at the base commit
├── solution/ # reference.patch; solve.sh for the oracle agent
└── tests/ # the grader, never seen by the agent
├── test.sh # grades the agent's diff in a fresh container; writes reward.json
└── task/
├── rubric.json # criteria: category, how each is checked, blocker or not, weight
└── hidden_tests/ # hidden tests, injected at grading time
trajectories/ # Claude Opus 5.5's trajectories
└── <task>/attempt_<k>/
├── traj/ # requests.jsonl.zst: full context and reply of every request
├── steps.jsonl # turn by turn: thinking summaries, text, tool calls and results
├── final.patch # the agent's final change
├── grade.json # result of every criterion; reasons for the model-judged ones
└── result.json # turns, tool calls, time, the agent's final message
index.json # tasks and trajectories
SHA256SUMS # checksums of every file
README.md # running and grading
Running with Harbor
# the reference solutions
harbor run -p tasks -a oracle
# your agent
harbor run -p tasks -a <agent> -m <model>
- Rubric: 12 to 19 criteria per task in six categories: behavioural correctness, regression safety, build/lint/format, test quality, scope, and code quality and conventions. Each is checked by hidden tests, a project command, a fail-before/pass-after run of the agent’s own tests, a scope check on the diff, or reviewer models; weights are relative (the cards show them as percentages). A change scores only if every blocker passes; otherwise it scores 0.
- Bundled solutions: besides the reference, each task can come with other correct designs (must pass), shortcuts that game the checks, cut corners or break the repository’s rules (must fail a blocker), and near misses that look complete but miss a requirement (must fail too), each with the grader’s verdict.
- Grading: when the agent stops, its change is exported as a diff against the base commit and graded in a fresh container; reward.json records pass (all blockers held), reward (the score) and reward_raw (the weighted score, blockers ignored).
- Isolation: the agent never sees the rubric, the hidden tests or the bundled solutions, and the environment runs offline.
Samples
Five tasks from the hard tier, each on a different project, across Java, Python, C++ and JavaScript: three features, a bug fix and an API change; reference changes span 480–1,016 lines. The bundled solutions show how strict the grader is: ignoring blockers, shortcuts reach weighted scores of up to 97 and near misses up to 95, yet they score 0 because a blocker fails.
| Sample | Language | Project | Type | Reference change | Criteria (blockers) |
|---|---|---|---|---|---|
| 1 | Java | jsoup | Bug fix | 14 files, 480 lines | 19 (10) |
| 2 | Java | feign | Feature | 16 files, 1,016 lines | 18 (10) |
| 3 | C++ | ninja | Feature | 9 files, 832 lines | 15 (10) |
| 4 | JavaScript | webpack | Feature | 59 files, 678 lines | 17 (10) |
| 5 | Python | scrapy | API change | 33 files, 702 lines | 19 (9) |
Each card shows the prompt exactly as the agent received it, the rubric and the grader’s verdicts on the bundled solutions.
Sample 1 of 5
Tokenize RCDATA, RAWTEXT and script data as the HTML spec does
Tokenize the content of RCDATA (title, textarea), RAWTEXT (style, xmp and others) and script data (script, with its <!-- escaped and double-escaped sections) as the HTML spec does: only the element’s own end tag closes it, anything else after </ stays text, and the input after it is read as content again. <style></t</style><img> must yield an img element, and <textarea><img> must keep <img> as text. Custom tags set up with Tag.Data or Tag.RcData close only on an end tag with their full name, ASCII case-insensitively in HTML and exactly in the XML parser; Tag.set(int) and Tag.name(String) must reject names that cannot form an end tag and leave the tag unchanged. With position tracking on, the endSourceRange() of these elements covers just the end tag.
The task prompt, verbatim
Task description
jsoup doesn't tokenize the content of text elements the way the HTML spec does: RCDATA (title, textarea), RAWTEXT (style, xmp, iframe, noembed, noframes) and script data (script, including its <!-- escaped and double-escaped sections). Please align it. Only the element's own end tag should close it; anything else after </ stays text, and the input after it is read as the element's content again. Today <style></t</style><img> swallows the img, and <textarea><img> breaks out of the textarea early instead of keeping <img> as text.
Tags configured with Tag.Data or Tag.RcData must close only on an end tag with their full name, whatever its length or characters (-, _, :, digits, non-ASCII letters): ASCII case-insensitively in HTML, exactly in the XML parser. Otherwise they behave like the built-in elements. Tag.set(int) setting either option, and Tag.name(String) on a tag that has one, must throw a ValidationException and leave the tag unchanged if the name is empty, doesn't start with an ASCII letter, or contains whitespace, <, >, /, NUL or U+FFFD. Other tags still accept any name.
Also, with position tracking on, the endSourceRange() of these elements starts at their start tag; it should cover just the end tag.
Rest of the prompt: test, lint and style guidelines
Test guidelines
Tests are JUnit 5 and live under src/test/java, mirroring the main packages. Tokenizer and parser behaviour is covered in src/test/java/org/jsoup/parser (TokeniserStateTest, HtmlParserTest, TagTest, PositionTest, ...); new *Test classes are picked up automatically, nothing needs registering. Cover the change with new or updated tests, and update existing tests whose expectations encode the old behaviour.
Run a subset offline with:
mvn -B -o clean test -Dtest=TokeniserStateTest,HtmlParserTest,TagTest -Dsurefire.failIfNoSpecifiedTests=false
(a single method: -Dtest=TagTest#isCaseSensitive). The full CI run, mvn -B -o clean verify (about 35s), adds the integration tests, javadoc and the API compatibility check. Keep clean in every command: the build compiles non-incrementally and can otherwise leave stale classes in target/.
Lint guidelines
jsoup has no formatter or style linter. The build enforces API rules instead: code in src/main/java is compiled with --release 8 and must pass animal-sniffer's Java 8 and Android API 21 signature checks, javadoc must generate, and japicmp fails the build on binary- or source-incompatible changes to the public API (compared with 1.23.1). Check all of these offline with mvn -B -o clean package -DskipTests (about 10s); mvn -B -o clean verify runs them too.
Style guidelines
Follow the surrounding code. Tokenizer states live in TokeniserState, with shared static helpers for states that behave alike; reuse and extend those rather than duplicating logic per state. Argument checks go through org.jsoup.helper.Validate, and character classes use the helpers in org.jsoup.internal.StringUtil. Per .github/CONTRIBUTING.md, keep the change focused: no reformatting or import reshuffling, and remove code the change leaves unused. Document new exceptions on public methods with @throws, and add an entry to CHANGES.md under the pending release, in the fitting section.
You are already on the correct base commit. Create your branch from this commit. Do not rebase or start from master, main, or any other branch.
Rubric
| # | Criterion | Category | Check | Blocker | Weight |
|---|---|---|---|---|---|
| C1 | Non-matching end tags in built-in RCDATA, RAWTEXT and script data elements stay text; what follows is re-read as content | Behavioural correctness | Hidden tests | yes | 10% |
| C2 | Unclosed RCDATA elements, built-in and custom, keep the rest of the input as text up to EOF | Behavioural correctness | Hidden tests | yes | 7% |
| C3 | Custom Data and RcData tags close only on their full name, whatever its characters or length; near misses stay content | Behavioural correctness | Hidden tests | yes | 8% |
| C4 | Text tags’ end tags match exactly in the XML parser, ASCII case-insensitively in HTML whatever the case settings | Behavioural correctness | Hidden tests | yes | 6% |
| C5 | Tag.set and Tag.name reject Data and RcData names that cannot form an end tag with a ValidationException, tag unchanged |
Behavioural correctness | Hidden tests | yes | 5% |
| C6 | Double-escaped script sections start and end on <script and </script in any ASCII case |
Behavioural correctness | Hidden tests | yes | 8% |
| C7 | Every HTML script’s content is tokenized as script data (body, fragments, noscript); only scripts get escaped sections | Behavioural correctness | Hidden tests | yes | 12% |
| C8 | With position tracking, each RCDATA, RAWTEXT and script data element’s end tag reports its own source range | Behavioural correctness | Hidden tests | yes | 10% |
| C9 | Full CI build passes: all unit and integration tests, javadoc, Java 8 and Android API checks, API compatibility | Regression safety | Project command | yes | 10% |
| C10 | The solution’s own tests fail without the change and pass with it | Test quality | Fail before, pass after | — | 4% |
| C11 | Tests cover each requested behaviour | Test quality | Reviewer judgement | — | 3% |
| C12 | Existing tests that asserted the old behaviour are updated, not deleted or disabled | Test quality | Reviewer judgement | — | 2% |
| C13 | RCDATA, RAWTEXT and script data end tag name states share one implementation | Code quality & conventions | Reviewer judgement | — | 2% |
| C14 | Obsolete RCDATA lookahead scan (CharacterReader.containsIgnoreCase and its cache) removed |
Build / lint / format | Project command | — | 2% |
| C15 | CHANGES.md gains an entry in the pending 1.23.2 section |
Code quality & conventions | Project command | — | 2% |
| C16 | Javadoc of Tag.set(int) and Tag.name(String) documents the new exception |
Code quality & conventions | Reviewer judgement | — | 2% |
| C17 | Change stays within the parser package, its tests and the changelog | Scope | Diff scope check | yes | 3% |
| C18 | Main-code change stays at a reviewable size | Scope | Diff scope check | — | 2% |
| C19 | No debug leftovers, commented-out code, narrating comments or unrelated reformatting | Build / lint / format | Reviewer judgement | — | 2% |
The grader’s verdicts on the bundled solutions
| Solution | Count | Score | Weighted score ignoring blockers |
|---|---|---|---|
| Reference solution | 1 | 100 | 100 |
| Other correct designs | 2 | 100 | 100 |
| Near misses | 5 | 0 | 85–94 |
| Shortcuts | 5 | 0 | 21–90 |
| Unchanged code | 1 | 0 | 15 |
Scores are out of 100. A failed blocker sets the score to 0.
Sample 2 of 5
Add decodeErrorResponses() to return decoded 4xx/5xx bodies instead of throwing
Add an opt-in builder option, decodeErrorResponses(), on BaseBuilder, marked @Experimental: an error response (status 400 or above, except 404) is then decoded into the method’s return type like a successful one and returned instead of thrown, on synchronous, AsyncFeign and CoroutineFeign clients alike. The ErrorDecoder still runs once per error response, and retryable errors still reach the Retryer. With nothing to decode or return (a void method; a missing, empty or unreadable body; a decode failure; a null value), the call throws the ErrorDecoder’s exception as before, with the decode failure attached as suppressed; responses the decoder declares it rejects and bodies over 8 KiB keep throwing too.
The task prompt, verbatim
Task description
Some HTTP APIs report a failure in the same envelope they use for success, e.g. a 500 whose JSON body is {"isFailed": true, "errorCode": 42}. Reading it today takes a custom ErrorDecoder and a try/catch around every call.
Add an opt-in builder option decodeErrorResponses() on BaseBuilder, marked @Experimental. With it, an error response (status 400 or above, except 404) is decoded into the method's return type the way a successful response is, and that value is returned instead of thrown.
The option must never turn a failure into a silent success. The ErrorDecoder still runs once per error response, and responses it classifies as retryable still go to the Retryer. Whenever there is no error body to decode or no decoded value to return, the call throws exactly what it throws today, the exception the ErrorDecoder returned, with the decode failure, if any, attached to it as suppressed. A decoder that declares what it accepts is never handed an error response it rejects, while a decoder that declares nothing (a plain lambda, say) accepts them all. The error body is read no further than 8 KiB; a larger one keeps throwing.
Rest of the prompt: test, lint and style guidelines
Test guidelines
Tests live in each module's src/test tree (core: core/src/test/java/feign/) and use JUnit 5 + AssertJ with okhttp3.mockwebserver.MockWebServer or a stub Client returning canned Responses, as the existing tests do. Surefire picks up any *Test class. Cover the change with tests that would fail without it, including the cases that must keep throwing.
Run the tests of one class (-pl takes the module; use -am, clean and the package phase, not test):
mvn -o -B -ntp -T 1C clean package -pl core -am -Dtest=MyTest -Dsurefire.failIfNoSpecifiedTests=false -Dlicense.skip=true
Run the unit tests of every module this change can reach (about 2 minutes). The excluded modules are slow or flaky offline (Spring Boot on a fixed port, racy static state), and vertx has its own response pipeline:
mvn -o -B -ntp -T 1C clean package -Dlicense.skip=true -pl '!vertx/feign-vertx,!vertx/feign-vertx4-test,!vertx/feign-vertx5-test,!form,!form-spring,!example-wikipedia-with-springboot,!ribbon'
Do not run mvn install: it puts SNAPSHOT jars into ~/.m2 that later builds would silently pick up.
Lint guidelines
CI runs ./mvnw verify, which fails on a missing license header, on Java sources that are not google-java-format formatted and on unsorted poms. Check offline before you finish:
mvn -o -B -ntp -T 1C validate
mvn -o -B -ntp -T 1C com.cosium.code:git-code-format-maven-plugin:validate-code-format com.github.ekryd.sortpom:sortpom-maven-plugin:verify -Dsort.verifyFail=Stop
mvn -o license:format adds missing headers and mvn -o git-code-format:format-code reformats Java sources. src/main of core is compiled with a real JDK 8 javac.
Style guidelines
Follow the surrounding code and the way existing builder options are implemented, tested and documented. Public API must stay binary-compatible: japicmp fails the CI build on incompatible changes to public, non-@Experimental API, and it cannot run offline here. Keep the change focused on this feature.
You are already on the correct base commit. Create your branch from this commit. Do not rebase or start from master, main, or any other branch.
Rubric
| # | Criterion | Category | Check | Blocker | Weight |
|---|---|---|---|---|---|
| C1 | With the option, 4xx/5xx bodies decode like successes and are returned: TypedResponse, Optional, async, unannounced length |
Behavioural correctness | Hidden tests | yes | 14% |
| C2 | 404, 3xx, oversized, rejected, retryable or undecodable responses and option off throw as before; raw Response untouched |
Behavioural correctness | Hidden tests | yes | 9% |
| C3 | No silent success: void methods and missing, empty, unreadable or null-decoding bodies throw the ErrorDecoder’s exception; it runs once |
Behavioural correctness | Hidden tests | yes | 9% |
| C4 | A decoder that declares what it accepts, set through mapAndDecode(), never gets error responses it rejects; the mapper still applies |
Behavioural correctness | Hidden tests | yes | 10% |
| C5 | Takes effect when set on a CoroutineFeign builder; suspend functions returning Unit still throw |
Behavioural correctness | Hidden tests | yes | 7% |
| C6 | Existing suites pass with the original tests; the touched classes keep all their public API | Regression safety | Project command | yes | 9% |
| C7 | The solution’s own tests pass, and fail when the option is a no-op or decodes every error response | Test quality | Project command | yes | 7% |
| C8 | License headers, google-java-format and sortpom checks pass | Build / lint / format | Project command | yes | 4% |
| C9 | Touches only the files this feature belongs in | Scope | Diff scope check | yes | 6% |
| C10 | README.md documents decodeErrorResponses() |
Code quality & conventions | Project command | yes | 4% |
| C11 | StreamDecoder and the reactive decoders also forward canDecode, asking about the type they decode |
Behavioural correctness | Hidden tests | — | 4% |
| C12 | decodeErrorResponses() is annotated @Experimental |
Code quality & conventions | Project command | — | 2% |
| C13 | CHANGELOG.md has an entry for the option in the unreleased section |
Code quality & conventions | Project command | — | 2% |
| C14 | Built into the response-handling chain, reusing its helpers, flag threaded like the existing options | Code quality & conventions | Reviewer judgement | — | 5% |
| C15 | Tests cover a decoded value, at least three must-still-throw cases and an async or coroutine client | Test quality | Reviewer judgement | — | 3% |
| C16 | README section and Javadoc explain how to use the option and when it still throws | Code quality & conventions | Reviewer judgement | — | 2% |
| C17 | No debug output, commented-out code, narrating comments or unrelated edits | Code quality & conventions | Reviewer judgement | — | 2% |
| C18 | Non-test change stays proportionate in size | Scope | Diff scope check | — | 1% |
The grader’s verdicts on the bundled solutions
| Solution | Count | Score | Weighted score ignoring blockers |
|---|---|---|---|
| Reference solution | 1 | 100 | 100 |
| Other correct designs | 3 | 96–100 | 96–100 |
| Near misses | 9 | 0 | 84–93 |
| Shortcuts | 6 | 0 | 41–92 |
| Unchanged code | 1 | 0 | 20 |
Scores are out of 100. A failed blocker sets the score to 0.
Sample 3 of 5
Let Ninja serve a GNU make jobserver pool
Ninja can already act as a GNU make jobserver client; this task adds the server side. With the new --jobserver-pool flag or the top-level manifest variable enable_jobserver_pool = 1, Ninja creates a pool with as many slots as parallel jobs (a FIFO on POSIX, a named semaphore on Windows) and adds it as --jobserver-auth= to the MAKEFLAGS of every command it runs, keeping what was already there. Ninja’s own jobs draw from the same pool, so Ninja and nested Ninja or Make builds together stay within its size; under an existing jobserver no second pool is created; manifest regeneration needs the pool too, and no exit path may leave the FIFO behind.
The task prompt, verbatim
Task description
Ninja can already act as a GNU make jobserver client. Add the server side, so that a top-level Ninja can bound the parallelism of the jobserver-aware tools it launches (e.g. nested Ninja or Make builds) together with its own jobs.
- Pool mode is enabled by a new
--jobserver-poolflag, or by the new top-level manifest variableenable_jobserver_pool = 1(other values are ignored). - In pool mode, Ninja creates a pool with as many job slots as its parallel job count (
-j, or the default) and adds it to theMAKEFLAGSof every command it runs, the way GNU make 4.4 does:--jobserver-auth=fifo:PATHon Posix, a named semaphore (--jobserver-auth=NAME) on Windows. WhateverMAKEFLAGSalready holds is kept. - When Ninja already runs under a jobserver, it must not create a second pool.
Document the flag in ninja -h, and both the flag and the variable in the manual.
Rest of the prompt: test, lint and style guidelines
Test guidelines
- C++ unit tests are
src/*_test.cc(GoogleTest), all linked intobuild-cmake/ninja_test; a new test file must be added to the test lists in bothCMakeLists.txtandconfigure.py. Python integration tests live inmisc/*_test.pyandtests/; they run./ninjafrom the current directory, so run them frombuild-cmake/. - Build and run everything (works offline):
cmake -S . -B build-cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug && cmake --build build-cmake && build-cmake/ninja_test --gtest_brief=1 && (cd build-cmake && python3 -m pytest -p no:cacheprovider -q ..) ninja-test-files FILE...builds and runs only the tests in the given files, e.g.ninja-test-files src/build_test.cc misc/output_test.py.- Cover your change with new or updated tests.
Lint guidelines
CI runs the following, and they must pass:
python3 misc/ci.py(whitespace and final newlines) andcodespell --count --ignore-words-list fo,wee,addin,notin --skip ./.git,./build,./build.ninja,./build-cmake,./build-tidy- clang-tidy on Ninja's sources:
cmake -S . -B build-tidy -G Ninja -DCMAKE_BUILD_TYPE=Debug -DNINJA_CLANG_TIDY=1 -DBUILD_TESTING=OFF && cmake --build build-tidy - The
configure.pybuild must keep working alongside CMake:python3 configure.py && ninja -f build.ninja ninja(with the installed re2c this regeneratessrc/lexer.ccandsrc/depfile_parser.cc; do not commit those).
Style guidelines
Follow CONTRIBUTING.md. Keep both the Posix and the Windows code paths compiling.
You are already on the correct base commit. Create your branch from this commit. Do not rebase or start from master, main, or any other branch.
Rubric
| # | Criterion | Category | Check | Blocker | Weight |
|---|---|---|---|---|---|
| C1 | Flag or variable enables pool mode: a FIFO pool with one slot per job, advertised to commands, bounding Ninja’s own jobs; ninja -h lists the flag |
Behavioural correctness | Hidden tests | yes | 13% |
| C2 | Ninja’s own jobs take pool slots: with nested clients never above the pool size, also with an explicit -j; nested pool-mode Ninjas join the outer pool |
Behavioural correctness | Hidden tests | yes | 10% |
| C3 | MAKEFLAGS handled like GNU make: an existing jobserver is used, no second pool; existing content kept in its layout, flag letters first, jobserver options before -- |
Behavioural correctness | Hidden tests | yes | 14% |
| C4 | -j0 (unlimited) neither hangs nor falls back to the default: with the variable all jobs run at once; --jobserver-pool -j0 may be rejected |
Behavioural correctness | Hidden tests | yes | 7% |
| C5 | Manifest regeneration gets a live pool and takes slots from it, as does the build after it; no FIFO or temp files left after success, failure, interruption or a tool run | Behavioural correctness | Hidden tests | yes | 15% |
| C6 | CI checks pass: misc/ci.py, codespell, clang-tidy, CMake build with unit and Python tests, configure.py build |
Regression safety | Project command | yes | 6% |
| C7 | Changes stay within the sources, build files, tests and docs the feature needs | Scope | Diff scope check | yes | 3% |
| C8 | Adds tests that fail without the change and pass with it | Test quality | Fail before, pass after | yes | 5% |
| C9 | The manual documents pool mode, the --jobserver-pool flag and the enable_jobserver_pool variable |
Code quality & conventions | Reviewer judgement | yes | 4% |
| C10 | Windows gets a real pool: a named semaphore advertised as --jobserver-auth=NAME; no POSIX-only API in code built on Windows |
Behavioural correctness | Reviewer judgement | yes | 4% |
| C11 | A job count too large for a FIFO (e.g. 200,000) does not hang Ninja: smaller pool, no pool, or an error exit | Behavioural correctness | Hidden tests | — | 3% |
| C12 | No ninja: warning: from ninja -v -j2, ninja -v -n or plain pool-mode builds; the documented pipe-jobserver warning still shows without -v |
Behavioural correctness | Hidden tests | — | 3% |
| C13 | Under an existing jobserver, an explicit -jN still caps Ninja at N jobs in pool mode, as documented for client mode |
Behavioural correctness | Hidden tests | — | 4% |
| C14 | enable_jobserver_pool is top-level only: a subninja file neither enables nor disables pool mode |
Behavioural correctness | Hidden tests | — | 3% |
| C15 | Follows the codebase’s structure: pool code in its own class or functions, creation failures reported, no large duplication or unrelated refactoring | Code quality & conventions | Reviewer judgement | — | 4% |
The grader’s verdicts on the bundled solutions
| Solution | Count | Score | Weighted score ignoring blockers |
|---|---|---|---|
| Reference solution | 1 | 100 | 100 |
| Other correct designs | 5 | 96–100 | 96–100 |
| Near misses | 10 | 0 | 53–86 |
| Shortcuts | 6 | 0 | 29–97 |
| Unchanged code | 1 | 0 | 10 |
Scores are out of 100. A failed blocker sets the score to 0.
Sample 4 of 5
Expose all CSS collected without a DOM as __webpack_css_server_styles__, in import order
Expose the CSS a universal (["web", "node"]) bundle collects without a DOM as a read-only string module variable, __webpack_css_server_styles__, readable from any module of any bundle and declared in module.d.ts. Each read returns, as one string, all the CSS the build has applied so far without a DOM, hot updates and style modules applied by a lazily loaded chunk included, and keeps import order in every case: production builds with numeric ids and module concatenation, CSS chunks requested together whose reads finish in any order. It is "" when nothing was collected. Unless output.environment.globalThis is set, neither collecting nor reading may rely on the host having globalThis. The prompt asks for import order in every build mode but does not name lazy chunks, numeric ids, concatenation or chunks requested together; several of these first need latent bugs in the existing CSS runtime found and fixed.
The task prompt, verbatim
Task description
When a universal bundle (target: ["web", "node"] with experiments.css) runs without a DOM, the CSS runtime keeps the styles it would have put into the document in a registry on the global object, under an internal key derived from output.uniqueName. Getting them back out, to inline them into server-rendered HTML, currently means scanning the global for that key.
Expose them as a read-only module variable, __webpack_css_server_styles__, of type string, usable from any module of any bundle and declared in module.d.ts. Every read returns, as one string, all the CSS the current build has applied so far without a DOM, hot updates included, in import order so that the cascade survives in every build mode. That covers exportType: "style" modules of any CSS module type. It is "" when nothing was collected: the styles went into a document, the bundle has no CSS, or the target is not universal.
Unless output.environment.globalThis is set, neither collecting nor reading may rely on the host having globalThis (Node.js 10 has none).
Rest of the prompt: test, lint and style guidelines
Test guidelines
- Tests are jest suites run through
yarn test:base(seeAGENTS.mdandTESTING_DOCS.md).webpack-test-files <test paths...>(onPATHin this environment) runs every suite that picks up the given files. - Fixture cases are picked up automatically:
test/configCases/<category>/<case>/(anindex.jswhoseit()blocks run inside the emitted bundle, awebpack.config.js, optionally atest.config.js) and HMR cases intest/hotCases/<category>/<case>/(universal-target ones intest/hotCases/universal/). - A
["web", "node"]config case runs once without a DOM; with ES module output it runs twice, with a fake DOM and without. Universal HMR cases always run both ways. - New behaviour needs tests that fail without your change and pass with it. Prefer fixture cases over unit tests, and cover each branch you add, the ordering guarantee and the empty result included.
- Before you finish,
yarn test:unit --ci,yarn test:basic --ciandyarn test:base --ci test/HotTestCasesUniversal.test.js test/HotTestCasesWeb.test.jsmust be green.
Lint guidelines
yarn lintmust pass; it is CI's lint job (ESLint, generated-file checks, thetscprojects, Prettier, cspell). Regenerate generated files withyarn fix:special, or runyarn fix.- A user-facing change needs a changeset (
AGENTS.md, "Adding a Changeset").
Style guidelines
- Follow
AGENTS.md(its git and pull-request sections do not apply to this task). - Runtime code emitted into bundles must honour
output.environment; build it with theruntimeTemplatehelpers. - Wire the variable the way webpack's other module variables and runtime globals are wired, and reuse existing helpers instead of duplicating their logic.
- Limit the change to what the contract above requires, and leave the shared test harness alone. Don't loosen or delete existing tests; the universal CSS tests that read the registry directly may switch to the new variable.
You are already on the correct base commit. Create your branch from this commit. Do not rebase or start from master, main, or any other branch.
Rubric
| # | Criterion | Category | Check | Blocker | Weight |
|---|---|---|---|---|---|
| C1 | Returns the CSS collected so far without a DOM (style modules, later chunks, hot updates); "" without crashing if none |
Behavioural correctness | Hidden tests | yes | 20% |
| C2 | Import order holds with numeric module ids; style modules and CSS chunks share one order | Behavioural correctness | Hidden tests | yes | 8% |
| C3 | Collects default and plain css style modules applied by a lazy chunk; hot updates replace or drop them in place |
Behavioural correctness | Hidden tests | yes | 9% |
| C4 | Production builds keep import order when a stylesheet is applied outside the importer’s concatenated module | Behavioural correctness | Hidden tests | yes | 9% |
| C5 | CSS chunks requested together come back in request order, whichever read ends first; pending or failed reads add nothing | Behavioural correctness | Hidden tests | yes | 8% |
| C6 | Unless output.environment.globalThis is set, injection, chunk loading, their HMR handlers and the reader run without globalThis |
Regression safety | Hidden tests | yes | 5% |
| C7 | ES5 target: the bundle using the variable contains only ES5 syntax | Code quality & conventions | Hidden tests | — | 2% |
| C8 | Existing unit, config-case, stats and universal/web HMR suites pass with the original tests | Regression safety | Project command | yes | 8% |
| C9 | Adds tests that fail without the change and pass with it | Test quality | Fail before, pass after | yes | 7% |
| C10 | Executed assertions in new tests cover ordering under numeric ids and the empty result | Test quality | Reviewer judgement | — | 3% |
| C11 | yarn lint clean: ESLint, up-to-date generated files, type checks, Prettier, spelling |
Build / lint / format | Project command | — | 4% |
| C12 | Includes a minor changeset for webpack with a description, in the format the validator accepts |
Build / lint / format | Project command | — | 2% |
| C13 | module.d.ts declares __webpack_css_server_styles__ as string |
Build / lint / format | Hidden tests | — | 2% |
| C14 | Reader gets the registry from the writers’ single helper; its expression and contents are not rebuilt or mirrored elsewhere | Code quality & conventions | Reviewer judgement | yes | 4% |
| C15 | Wired like other module variables: APIPlugin table entry, new RuntimeGlobals constant, RuntimeModule subclass added only when needed |
Code quality & conventions | Reviewer judgement | yes | 4% |
| C16 | Comments follow AGENTS.md: short, informative, new RuntimeGlobals constant documented like its neighbours, no leftovers |
Code quality & conventions | Reviewer judgement | — | 3% |
| C17 | Proportionate diff: source, tests, changeset, declarations; harness untouched, existing tests not weakened | Scope | Diff scope check + reviewer judgement | — | 3% |
The grader’s verdicts on the bundled solutions
| Solution | Count | Score | Weighted score ignoring blockers |
|---|---|---|---|
| Reference solution | 1 | 100 | 100 |
| Other correct designs | 4 | 100 | 100 |
| Near misses | 8 | 0 | 74–95 |
| Shortcuts | 6 | 0 | 8–92 |
| Unchanged code | 1 | 0 | 12 |
Scores are out of 100. A failed blocker sets the score to 0.
Sample 5 of 5
Make Scrapy's download handlers raise Scrapy exceptions instead of Twisted ones
Add seven download exceptions with no Twisted base class to scrapy/exceptions.py (timeout, cancellation, response data loss, refused connection, unresolvable host, any other download failure, unsupported URL scheme), and make download_request() of the built-in handlers (HTTP/1.1, HTTP/2, FTP; only timeouts for the deprecated HTTP/1.0 one) raise no Twisted exception any more: each failure becomes the matching new exception, with the original message and the Twisted exception as __cause__. When an HTTP/2 connection cannot be established, the requests waiting for it must fail the same way. The RETRY_EXCEPTIONS and HttpCacheMiddleware.DOWNLOAD_EXCEPTIONS defaults list the new exceptions, so failures that were retried or served from the cache by default still are, while cancellations and unsupported schemes still are not; the docs change with it.
The task prompt, verbatim
Task description
The download handlers report failures with Twisted exceptions (DNSLookupError, ResponseFailed, ...), so errbacks, middlewares and settings such as RETRY_EXCEPTIONS depend on Twisted, which won't hold for non-Twisted handlers.
Add these to scrapy/exceptions.py, as plain classes like the others there (optional message, no Twisted base class):
DownloadTimeoutError: the download timeout was exceededDownloadCancelledError: the download was cancelled, e.g. the response exceedsDOWNLOAD_MAXSIZEResponseDataLossError: the response is incomplete (seeDOWNLOAD_FAIL_ON_DATALOSS)DownloadConnectionRefusedError: the connection was refusedCannotResolveHostError: the hostname couldn't be resolvedDownloadFailedError: any other download failureUnsupportedURLSchemeError: the URL scheme isn't supported
No Twisted exception should come out of download_request() of the built-in download handlers any more: they report each failure with the matching one of these, keeping the existing message and the original exception as __cause__. The deprecated HTTP10DownloadHandler only needs DownloadTimeoutError for timeouts.
List the new exceptions in the default RETRY_EXCEPTIONS and HttpCacheMiddleware.DOWNLOAD_EXCEPTIONS instead of the Twisted ones they supersede. With every built-in handler, failures that were retried, or served from the HTTP cache, by default must still be; cancellations and unsupported schemes still must not. Update the docs.
Rest of the prompt: test, lint and style guidelines
Test guidelines
Tests live in tests/ and run with pytest (configured in pyproject.toml, Twisted asyncio reactor via pytest-twisted), with the session-scoped mockserver fixture from conftest.py.
The HTTP download handler tests are written once in the base classes of tests/test_downloader_handlers_http_base.py and run through the per-handler modules; a handler that doesn't support a case by design (e.g. HTTP/2 ignores DOWNLOAD_FAIL_ON_DATALOSS) overrides it with pytest.skip() in its own module.
Update the existing tests that assert the old Twisted exceptions and add tests for the new behaviour.
- Run a subset:
env -u no_proxy -u NO_PROXY scrapy-test-files <test files>(it ignores non-test modules, so when you change the base module pass the per-handler modules too). - Before finishing, run the full suite the way CI does (about 6 minutes):
env -u http_proxy -u https_proxy -u ftp_proxy -u all_proxy -u no_proxy -u HTTP_PROXY -u HTTPS_PROXY -u FTP_PROXY -u ALL_PROXY -u NO_PROXY python -m pytest scrapy tests --doctest-modules. - There is no network and no IPv6 loopback here: use
127.0.0.1, notlocalhost, for local servers and closed ports.TestHttp11Proxy::test_download_with_proxy_https_timeoutis occasionally flaky here (a TLS error instead of the timeout); rerun it before investigating.
Lint guidelines
CI runs these checks; run them before finishing:
ruff checkandruff format --check --diff(configuration inpyproject.toml).SKIP=ruff-check,ruff-format pre-commit run --all-files --show-diff-on-failure(pre-commit only checks files tracked by git, sogit addnew files first).pylint conftest.py docs extras scrapy tests(about 45 seconds).mypy scrapy tests(themypyonPATHis CI's Python 3.10 one) and/home/ubuntu/.venvs/scrapy-typing-tests/bin/python -m pytest -q tests_typing.
Style guidelines
Follow the conventions of the surrounding code (from __future__ import annotations, type hints, typing-only imports under TYPE_CHECKING). Keep the change focused (see docs/contributing.rst), and don't duplicate the same logic in several handlers. Release notes (docs/news.rst) are written by the maintainers at release time, so don't edit them.
You are already on the correct base commit. Create your branch from this commit. Do not rebase or start from master, main, or any other branch.
Rubric
| # | Criterion | Category | Check | Blocker | Weight |
|---|---|---|---|---|---|
| C1 | HTTP11DownloadHandler raises the matching new exception for every failure kind; HTTP10DownloadHandler for timeouts |
Behavioural correctness | Hidden tests | yes | 12% |
| C2 | H2DownloadHandler does the same for every failure kind, refused connections and DNS failures included |
Behavioural correctness | Hidden tests | yes | 11% |
| C3 | A failed HTTP/2 connection fails every request waiting on it without blocking later ones; no Twisted bind errors | Behavioural correctness | Hidden tests | — | 4% |
| C4 | No Twisted leaks from rarer failures (bind, TLS, invalid response, unreachable proxy); StopDownload untouched |
Behavioural correctness | Hidden tests | yes | 11% |
| C5 | FTPDownloadHandler raises the new exceptions too: refused connections, DNS failures, failed logins |
Behavioural correctness | Hidden tests | yes | 9% |
| C6 | With default settings, every built-in handler’s failures are retried as before | Regression safety | Hidden tests | yes | 10% |
| C7 | HttpCacheMiddleware still serves a stale cached response on the same failures as before |
Regression safety | Hidden tests | yes | 6% |
| C8 | Translated exceptions keep the original message, with the Twisted exception as __cause__ |
Behavioural correctness | Hidden tests | — | 4% |
| C9 | The new exceptions are plain classes in scrapy.exceptions with an optional message |
Behavioural correctness | Hidden tests | — | 2% |
| C10 | Every new exception is in the exceptions reference; the documented RETRY_EXCEPTIONS default matches the real one |
Code quality & conventions | Hidden tests | yes | 4% |
| C11 | DOWNLOAD_FAIL_ON_DATALOSS docs and the errback example no longer describe Twisted exceptions |
Code quality & conventions | Hidden tests | — | 2% |
| C12 | The default lists drop the Twisted exceptions no built-in handler raises any more | Code quality & conventions | Hidden tests | — | 2% |
| C13 | Full test suite passes; affected test modules keep at least as many passing tests as before | Regression safety | Project command | yes | 8% |
| C14 | Adds tests that fail without the change and pass with it | Test quality | Fail before, pass after | yes | 5% |
| C15 | Ruff lint and format, pre-commit hooks and pylint pass |
Build / lint / format | Project command | — | 2% |
| C16 | mypy and the typing tests pass |
Build / lint / format | Project command | — | 2% |
| C17 | Handlers that translate Twisted exceptions share one mapping instead of copies | Code quality & conventions | Reviewer judgement | — | 2% |
| C18 | Existing assertions move to the new exceptions; newly translated failures tested through real handlers | Test quality | Reviewer judgement | — | 3% |
| C19 | Stays in scope: exceptions, built-in handlers and their client code, retry and cache defaults, tests, docs | Scope | Diff scope check + reviewer judgement | — | 1% |
The grader’s verdicts on the bundled solutions
| Solution | Count | Score | Weighted score ignoring blockers |
|---|---|---|---|
| Reference solution | 1 | 100 | 100 |
| Other correct designs | 2 | 100 | 100 |
| Near misses | 5 | 0 | 81–91 |
| Shortcuts | 5 | 0 | 17–84 |
| Unchanged code | 1 | 0 | 12 |
Scores are out of 100. A failed blocker sets the score to 0.
Customization
Including, but not limited to, the following; anything else is open for discussion.
- Languages and projects: language mix, domains (web frameworks, compilers, databases, front-end apps, CLI tools and more), size of the change.
- Task types and emphasis: features, bug fixes, refactors, cross-cutting changes; how much weight goes to test quality, scope discipline or conventions.
- Grading: blockers and weights, the mix of hidden tests, project commands and reviewer judgements, and the judging model.
- Difficulty: the reference model and the pass-rate band to hit.
- Trajectories: native Claude Code tool calls, or rewritten for your evaluation harness (for example a bash-only agent); one or several per task.
- Volume and schedule: how many and by when.