FrontierCode 式可合并代码任务

成熟真实项目里的代码改动,按维护者会不会合并来评分:带阻断项和权重细则的 Harbor 任务,另附 Agent 轨迹。

对应:FrontierCode 2.0格式:Harbor

索取样例
难题档 Claude Opus 5.5 单次通过率
< 40%max effort,3 次尝试至多解出 1 次
每题评分细则条目
12–⁠19其中阻断项 4–⁠10 条,任一不过即记 0 分
参考解改动行数
195–⁠1,016另附其他正确解法、遗漏个别要求的解法和取巧解,均带评分结果
每条轨迹的回合数
53–⁠196用时 34–⁠111 分钟
编程语言
8Java、JavaScript、TypeScript、Python、C++、Go、Rust、PHP
一条数据
一个 Harbor 任务 + Agent 轨迹
环境
由任务的 Dockerfile 构建的开发环境镜像,含基线提交的项目代码;测试、lint 和构建均可离线运行
需求
以维护者口吻写成,881–⁠2,254 字符,后附仓库的测试、lint 和代码风格规范
评分器
带权重的细则,分别由隐藏测试、项目命令、“改前失败、改后通过”检查、改动范围检查或评审模型判定
轨迹
Claude Code + Claude Opus 5.5,max effort
格式
Harbor 任务目录 + 请求级 JSONL 轨迹(zstd 压缩)

概览

每条数据是一道代码改动任务,改的是真实、成熟的软件项目,按“维护者会不会合并这份改动”评分:需求以维护者的口吻写成,后附仓库自己的测试、lint 和代码风格规范;带权重的评分细则从行为正确、已有功能、测试、改动范围和代码质量几方面检查,任一阻断项不过即记 0 分。每条数据包含两部分:一是 Harbor 任务(离线开发环境的 Dockerfile 与构建脚本、需求、评分细则及其隐藏测试、参考解),可直接用于强化学习;二是 Claude Opus 5.5 以 max effort 在 Claude Code 中完成该任务的轨迹,逐请求完整记录,附逐条细则的评分,可用于监督微调。

难度与质量

  • 难题档:Claude Opus 5.5(max effort)3 次尝试至多解出 1 次。
  • 失败出在模型,不在题目:没做对的题,原因都在 Agent 自己,不在题面或评分器。
  • 参考解满分:每题附参考解,用 Harbor 的 oracle 运行即得 reward 1.0,可自行复核。

交付内容

tasks/                         # Harbor 任务,每题一个目录
└── <任务>/
    ├── instruction.md         # 需求和仓库规范:Agent 收到的唯一输入
    ├── task.toml              # 项目、语言、题型、考察点、基线提交;资源与时限
    ├── environment/           # Dockerfile、构建脚本、基线提交的仓库
    ├── solution/              # 参考解 reference.patch;solve.sh 供 oracle 运行
    └── tests/                 # 评分器,Agent 看不到
        ├── test.sh            # 评分入口:在全新容器中按细则评 Agent 的改动,写出 reward.json
        └── task/
            ├── rubric.json    # 评分细则:类别、检查方式、是否阻断、权重
            └── hidden_tests/  # 隐藏测试,评分时注入
trajectories/                  # Claude Opus 5.5 的轨迹
└── <任务>/attempt_<k>/
    ├── traj/                  # requests.jsonl.zst:请求级记录,每次请求的完整上下文与回复,含思考摘要
    ├── steps.jsonl            # 逐回合视图:思考摘要、说明、工具调用及结果
    ├── final.patch            # Agent 的最终改动
    ├── grade.json             # 每条细则的结果,评审模型判定的细则附理由
    └── result.json            # 回合、工具调用、用时、Agent 的最终回复
index.json                     # 任务与轨迹总览
SHA256SUMS                     # 全部文件的校验和
README.md                      # 运行和评分说明

用 Harbor 运行

# 跑参考解
harbor run -p tasks -a oracle

# 跑你的 Agent
harbor run -p tasks -a <agent> -m <model>
  • 评分细则:每题 12 到 19 条,分六类:行为正确、不破坏已有行为、构建/lint/格式、测试质量、改动范围、代码质量与规范。每条由隐藏测试、项目命令、对 Agent 自写测试的“改前失败、改后通过”检查、改动范围检查或评审模型判定;权重为相对值(卡片中折算为百分比)。阻断项全部通过才计分,否则记 0 分。
  • 随附解法:参考解之外,每题可另附其他正确解法(须通过)、取巧解(钻空子、偷工减料或违反仓库规范,须被阻断项拦下)和遗漏个别要求的解法(看似完整,同样须被拦下),均带评分器的判定。
  • 评分:Agent 结束后,改动以相对基线的 diff 导出,在全新容器中评分;reward.json 记录 pass(阻断项是否全过)、reward(得分)和 reward_raw(不计阻断项的加权分)。
  • 隔离:Agent 看不到评分细则、隐藏测试和随附解法;环境可离线运行。

样例

5 道样题全部来自难题档,项目各不相同,覆盖 Java、Python、C++ 和 JavaScript:3 道新功能、1 道缺陷修复、1 道 API 变更,参考解改动 480–⁠1,016 行。从随附解法的判定可以看出评分器有多严:不计阻断项时,取巧解的加权得分最高达 97,遗漏个别要求的解法最高达 95,但因阻断项不过,得分都是 0。

样题 语言 项目 题型 参考解改动 细则(阻断项)
1 Java jsoup 缺陷修复 14 个文件,480 行 19(10)
2 Java feign 新功能 16 个文件,1,016 行 18(10)
3 C++ ninja 新功能 9 个文件,832 行 15(10)
4 JavaScript webpack 新功能 59 个文件,678 行 17(10)
5 Python scrapy API 变更 33 个文件,702 行 19(9)

每张卡片给出 Agent 收到的题面原文、评分细则和评分器对随附解法的判定。

样例 1 / 5

按 HTML 规范修正 RCDATA、RAWTEXT 和 script 的分词

  • Java
  • jsoup
  • 缺陷修复
  • 参考解 14 个文件、改动 480 行
  • HTML 分词状态机
  • 插入模式与片段解析
  • 源码位置跟踪
  • 兼容既有签名的 API 校验
  • 改写断言旧行为的测试
  • 难点
  • body、片段和 noscript 中的 script 同样按 script data 分词
  • 双重转义段的 <script 和 </script 不区分 ASCII 大小写
  • HTML 在保留大小写的设置下也不区分大小写,XML 须精确匹配
  • 未闭合的 RCDATA 元素直到 EOF 都是文本
  • 名称被拒时标签保持不变

按 HTML 规范对 RCDATA(title、textarea)、RAWTEXT(style、xmp 等)和 script data(script,含 <!-- 转义段和双重转义段)的内容分词(tokenize):只有元素自己的结束标签能关闭它,</ 后的其他内容留作文本,随后的输入仍按元素内容读取。例如 <style></t</style><img> 中的 img 应成为元素,<textarea><img> 中的 <img> 应留在文本里。用 Tag.Data 或 Tag.RcData 配置的自定义标签只认完整名称的结束标签,HTML 中不区分 ASCII 大小写,XML 解析器中精确匹配;Tag.set(int) 和 Tag.name(String) 须拒绝无法构成结束标签的名称,并保持标签不变。开启位置跟踪时,这些元素的 endSourceRange() 只覆盖结束标签。

题面(Agent 收到的原文)

instruction.md

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.

题面后半:测试、lint 和代码风格规范
instruction.md(续)

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.

评分细则

# 细则 类别 检查方式 阻断项 权重
C1 内置 RCDATA、RAWTEXT、script data 元素中不匹配的结束标签留作文本,其后仍读作内容 行为正确 隐藏测试 是 10%
C2 未闭合的 RCDATA 元素(内置和自定义)把余下输入直到 EOF 都留作文本 行为正确 隐藏测试 是 7%
C3 自定义 Data、RcData 标签只按完整名称关闭,不限名称的字符和长度;相近的结束标签仍是内容 行为正确 隐藏测试 是 8%
C4 文本标签的结束标签在 XML 解析器中精确匹配,在 HTML 中不论大小写设置都不区分 ASCII 大小写 行为正确 隐藏测试 是 6%
C5 Tag.set 和 Tag.name 以 ValidationException 拒绝无法构成结束标签的 Data、RcData 名称,标签不变 行为正确 隐藏测试 是 5%
C6 双重转义段在任意 ASCII 大小写的 <script 和 </script 处开始和结束 行为正确 隐藏测试 是 8%
C7 HTML 中所有 script(含 body、片段、noscript 中的)按 script data 分词,且只有 script 有转义段 行为正确 隐藏测试 是 12%
C8 开启位置跟踪时,每个 RCDATA、RAWTEXT、script data 元素的结束标签报告自己的源码范围 行为正确 隐藏测试 是 10%
C9 完整 CI 构建通过:全部单元和集成测试、javadoc、Java 8 与 Android API 检查、API 兼容性 不破坏已有行为 项目命令 是 10%
C10 解法自带的测试在没有该改动时失败,有改动时通过 测试质量 改前失败、改后通过 — 4%
C11 测试覆盖题面要求的每一项行为 测试质量 评审判定 — 3%
C12 断言旧行为的已有测试改为新的预期,而不是删除或禁用 测试质量 评审判定 — 2%
C13 RCDATA、RAWTEXT 和 script data 的结束标签名状态共用一套实现 代码质量与规范 评审判定 — 2%
C14 删去过时的 RCDATA 前瞻扫描(CharacterReader.containsIgnoreCase 及其缓存) 构建/lint/格式 项目命令 — 2%
C15 CHANGES.md 待发布的 1.23.2 一节新增条目 代码质量与规范 项目命令 — 2%
C16 Tag.set(int) 和 Tag.name(String) 的 Javadoc 写明新增的异常 代码质量与规范 评审判定 — 2%
C17 改动只涉及 parser 包、测试和变更日志 改动范围 改动范围检查 是 3%
C18 主代码的改动规模便于评审 改动范围 改动范围检查 — 2%
C19 无调试残留、注释掉的代码、复述改动的注释或无关的格式调整 构建/lint/格式 评审判定 — 2%

评分器对随附解法的判定

解法 份数 得分 不计阻断项的加权得分
参考解 1 100 100
其他正确解法 2 100 100
遗漏个别要求的解法 5 0 85–⁠94
取巧解 5 0 21–⁠90
未改动的代码 1 0 15

满分 100。任一阻断项不过,得分即为 0。

样例 2 / 5

新增 decodeErrorResponses(),将错误响应体解码为返回值

  • Java
  • feign
  • 新功能
  • 参考解 16 个文件、改动 1,016 行
  • ErrorDecoder 与 Retryer 语义
  • PredicatedDecoder 与解码器包装
  • 同步、异步与协程客户端
  • 二进制兼容的 API 演进
  • 锁定安全行为的测试
  • README 与 CHANGELOG
  • 难点
  • void 方法、返回 Unit 的挂起函数、解码结果为 null 时照旧抛出
  • 解码失败时抛 ErrorDecoder 的异常,失败附为 suppressed
  • mapAndDecode() 包装的解码器也不得收到它拒绝的响应
  • CoroutineFeign 构建器上设置同样生效
  • 超过 8 KiB 的 body 只读到上限,异常里仍是完整 body

在 BaseBuilder 上新增可选的构建器选项 decodeErrorResponses(),标注 @Experimental:开启后,状态码 400 及以上(404 除外)的错误响应像成功响应一样解码为方法的返回类型并直接返回,不再抛出;同步、AsyncFeign 和 CoroutineFeign 客户端都要生效。ErrorDecoder 对每个错误响应仍只运行一次,判为可重试的照旧交给 Retryer。没有可解码的 body 或没有可返回的值时(void 方法,body 缺失、为空或无法读取,解码失败,解码结果为 null),调用照旧抛出 ErrorDecoder 返回的异常,解码失败作为 suppressed 附在其上;解码器声明不接受的响应和超过 8 KiB 的 body 也照旧抛出。

题面(Agent 收到的原文)

instruction.md

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.

题面后半:测试、lint 和代码风格规范
instruction.md(续)

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.

评分细则

# 细则 类别 检查方式 阻断项 权重
C1 开启后 4xx/5xx 响应体像成功响应一样解码并返回,含 TypedResponse、Optional、异步调用及未声明长度的 body 行为正确 隐藏测试 是 14%
C2 404、3xx、超限、解码器拒绝、可重试或无法解码的错误响应及未开启时照旧抛出,返回 Response 的方法不变 行为正确 隐藏测试 是 9%
C3 不得静默成功:void 方法,body 缺失、为空、无法读取或解码为 null 时仍抛 ErrorDecoder 返回的异常,且它只运行一次 行为正确 隐藏测试 是 9%
C4 经 mapAndDecode() 设置、声明了接受范围的解码器不会收到它拒绝的错误响应,映射函数仍作用于它解码的 body 行为正确 隐藏测试 是 10%
C5 在 CoroutineFeign 构建器上设置同样生效,返回 Unit 的挂起函数仍抛出 行为正确 隐藏测试 是 7%
C6 在原有测试下各模块测试套件仍通过,所改类原有的公共 API 均保留 不破坏已有行为 项目命令 是 9%
C7 新增测试本身通过,并在选项不起作用或对所有错误响应都解码时失败 测试质量 项目命令 是 7%
C8 许可证头、google-java-format 格式和 sortpom 检查通过 构建/lint/格式 项目命令 是 4%
C9 只改动该功能所属的文件 改动范围 改动范围检查 是 6%
C10 README.md 写明 decodeErrorResponses() 代码质量与规范 项目命令 是 4%
C11 StreamDecoder 和响应式解码器也转发 canDecode,询问的是它们实际解码的类型 行为正确 隐藏测试 — 4%
C12 decodeErrorResponses() 标注 @Experimental 代码质量与规范 项目命令 — 2%
C13 CHANGELOG.md 的未发布部分有该选项的条目 代码质量与规范 项目命令 — 2%
C14 在响应处理链中实现,复用其已有逻辑,开关像现有选项一样逐层传入 代码质量与规范 评审判定 — 5%
C15 测试覆盖解码返回值、至少三种须照旧抛出的情形,以及异步或协程客户端 测试质量 评审判定 — 3%
C16 README 章节和 Javadoc 说明用法及仍会抛出的情形 代码质量与规范 评审判定 — 2%
C17 无调试输出、注释掉的代码、复述代码的注释或无关改动 代码质量与规范 评审判定 — 2%
C18 非测试代码的改动规模适度 改动范围 改动范围检查 — 1%

评分器对随附解法的判定

解法 份数 得分 不计阻断项的加权得分
参考解 1 100 100
其他正确解法 3 96–⁠100 96–⁠100
遗漏个别要求的解法 9 0 84–⁠93
取巧解 6 0 41–⁠92
未改动的代码 1 0 20

满分 100。任一阻断项不过,得分即为 0。

样例 3 / 5

让 Ninja 充当 GNU make jobserver 服务端

  • C++
  • ninja
  • 新功能
  • 参考解 9 个文件、改动 832 行
  • GNU make jobserver 协议
  • FIFO 与 Win32 命名信号量
  • 与现有参数和模式的交互
  • 资源生命周期与清理
  • Python 集成测试
  • 难点
  • Ninja 自己的任务也要从池中取槽位
  • -j0 下既不能卡死也不能退回默认并行数
  • 重新生成清单时也要有池,任何退出路径都不留 FIFO
  • 保留的 MAKEFLAGS 须符合 GNU make 的布局
  • Windows 信号量的令牌比槽位少一个

Ninja 已能作为 GNU make jobserver 的客户端,本题要补上服务端。用新参数 --jobserver-pool 或顶层清单变量 enable_jobserver_pool = 1 开启池模式后,Ninja 创建一个槽位数等于并行任务数的池(POSIX 上是 FIFO,Windows 上是命名信号量),以 --jobserver-auth= 的形式加进它启动的每条命令的 MAKEFLAGS,原有内容保留。Ninja 自己的任务也从这个池取槽位,与嵌套的 Ninja、Make 构建合计不超过池的大小;已在 jobserver 下运行时不另建池;重新生成清单时同样要有池,任何退出路径都不留下 FIFO。

题面(Agent 收到的原文)

instruction.md

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-pool flag, or by the new top-level manifest variable enable_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 the MAKEFLAGS of every command it runs, the way GNU make 4.4 does: --jobserver-auth=fifo:PATH on Posix, a named semaphore (--jobserver-auth=NAME) on Windows. Whatever MAKEFLAGS already 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.

题面后半:测试、lint 和代码风格规范
instruction.md(续)

Test guidelines

  • C++ unit tests are src/*_test.cc (GoogleTest), all linked into build-cmake/ninja_test; a new test file must be added to the test lists in both CMakeLists.txt and configure.py. Python integration tests live in misc/*_test.py and tests/; they run ./ninja from the current directory, so run them from build-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) and codespell --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.py build must keep working alongside CMake: python3 configure.py && ninja -f build.ninja ninja (with the installed re2c this regenerates src/lexer.cc and src/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.

评分细则

# 细则 类别 检查方式 阻断项 权重
C1 参数或变量开启池模式:按任务数建 FIFO 池,告知所启动的命令并约束自身任务;ninja -h 列出该参数 行为正确 隐藏测试 是 13%
C2 Ninja 自己的任务从池中取槽位,与嵌套客户端合计不超过池大小,显式 -j 时亦然;嵌套的池模式 Ninja 加入外层池 行为正确 隐藏测试 是 10%
C3 像 GNU make 一样处理 MAKEFLAGS:已有 jobserver 时沿用、不另建池;原有内容保留,标志字母在前,jobserver 选项在 -- 之前 行为正确 隐藏测试 是 14%
C4 -j0(不限并行)既不卡死,也不退回默认并行数:用变量开启时全部任务并行,显式 --jobserver-pool -j0 可报错拒绝 行为正确 隐藏测试 是 7%
C5 重新生成清单时已有池并占槽位,之后的构建也有池;成功、失败、中断或运行工具后都不留 FIFO 和临时文件 行为正确 隐藏测试 是 15%
C6 CI 检查通过:misc/ci.py、codespell、clang-tidy、CMake 构建及单元测试和 Python 测试、configure.py 构建 不破坏已有行为 项目命令 是 6%
C7 只改动该功能需要的源码、构建文件、测试和文档 改动范围 改动范围检查 是 3%
C8 新增测试在没有该改动时失败,有改动时通过 测试质量 改前失败、改后通过 是 5%
C9 手册介绍池模式、--jobserver-pool 参数和 enable_jobserver_pool 变量 代码质量与规范 评审判定 是 4%
C10 Windows 上建出真正的池:命名信号量以 --jobserver-auth=NAME 告知;在 Windows 上编译的代码不用 POSIX 专有 API 行为正确 评审判定 是 4%
C11 FIFO 容纳不下的超大任务数(如 200,000)不让 Ninja 卡死:缩小池、不建池或报错退出均可 行为正确 隐藏测试 — 3%
C12 ninja -v -j2、ninja -v -n 和普通池模式构建不打印 ninja: warning:;不带 -v 时仍打印文档所述的管道式 jobserver 警告 行为正确 隐藏测试 — 3%
C13 已有 jobserver 时,池模式下显式 -jN 仍把 Ninja 限制在 N 个任务,与客户端模式的文档一致 行为正确 隐藏测试 — 4%
C14 enable_jobserver_pool 只在顶层生效:subninja 文件既不能开启也不能关闭池模式 行为正确 隐藏测试 — 3%
C15 符合代码库结构:池的实现独立成类或函数,建池失败有提示,无大段重复和无关重构 代码质量与规范 评审判定 — 4%

评分器对随附解法的判定

解法 份数 得分 不计阻断项的加权得分
参考解 1 100 100
其他正确解法 5 96–⁠100 96–⁠100
遗漏个别要求的解法 10 0 53–⁠86
取巧解 6 0 29–⁠97
未改动的代码 1 0 10

满分 100。任一阻断项不过,得分即为 0。

样例 4 / 5

将无 DOM 时收集的全部 CSS 按导入顺序暴露为 __webpack_css_server_styles__

  • JavaScript
  • webpack
  • 新功能
  • 参考解 59 个文件、改动 678 行
  • 从简短需求推断意图
  • 运行时代码生成
  • 模块拼接与数字 id
  • 异步加载顺序
  • 旧版 Node 与 ES5 兼容
  • 测试夹具编写
  • 难点
  • 懒加载 chunk 中默认和 css 类型的样式模块也要收集
  • 在拼接模块之外应用的样式仍须按导入顺序
  • 同时请求的 CSS chunk 按请求顺序,与读取先后无关
  • 数字 id 下样式模块与 CSS chunk 共用一个顺序
  • 原有写入方和热更新处理也不能假定有 globalThis

把通用(universal)目标 ["web", "node"] 的包在没有 DOM 时收集的 CSS 暴露为只读 string 模块变量 __webpack_css_server_styles__,任何包的任何模块都能读取,并在 module.d.ts 中声明。每次读取以一个字符串返回当前构建至此在无 DOM 时应用过的全部 CSS,包括热更新和懒加载 chunk 应用的样式模块,并始终保持导入顺序:使用数字 id 和模块拼接的生产构建、同时请求而读取先后不定的 CSS chunk 都不例外;未收集到样式时为 ""。未设置 output.environment.globalThis 时,收集和读取都不能依赖宿主提供 globalThis。题面只要求在各种构建模式下都保持导入顺序,没有点明懒加载 chunk、数字 id、模块拼接和同时请求的 CSS chunk 这些情形;其中几种须先找出并修复现有 CSS 运行时里的潜在缺陷才能做到。

题面(Agent 收到的原文)

instruction.md

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

题面后半:测试、lint 和代码风格规范
instruction.md(续)

Test guidelines

  • Tests are jest suites run through yarn test:base (see AGENTS.md and TESTING_DOCS.md). webpack-test-files <test paths...> (on PATH in this environment) runs every suite that picks up the given files.
  • Fixture cases are picked up automatically: test/configCases/<category>/<case>/ (an index.js whose it() blocks run inside the emitted bundle, a webpack.config.js, optionally a test.config.js) and HMR cases in test/hotCases/<category>/<case>/ (universal-target ones in test/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 --ci and yarn test:base --ci test/HotTestCasesUniversal.test.js test/HotTestCasesWeb.test.js must be green.

Lint guidelines

  • yarn lint must pass; it is CI's lint job (ESLint, generated-file checks, the tsc projects, Prettier, cspell). Regenerate generated files with yarn fix:special, or run yarn 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 the runtimeTemplate helpers.
  • 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.

评分细则

# 细则 类别 检查方式 阻断项 权重
C1 无 DOM 时返回已收集的样式模块、后加载 chunk 与热更新 CSS,未收集时为 "" 且不崩溃 行为正确 隐藏测试 是 20%
C2 使用数字模块 id 时按导入顺序返回,样式模块与 CSS chunk 共用同一顺序 行为正确 隐藏测试 是 8%
C3 无 DOM 时收集懒加载 chunk 应用的默认和 css 类型样式模块,热更新原位替换或移除 行为正确 隐藏测试 是 9%
C4 生产构建中,样式表由导入方所在拼接模块之外的模块应用时,仍按导入顺序 行为正确 隐藏测试 是 9%
C5 同时请求的 CSS chunk 按请求顺序返回,不论哪个先读完;读取未完成或失败时不留内容 行为正确 隐藏测试 是 8%
C6 未启用 output.environment.globalThis 时,样式注入、chunk 加载、二者的热更新处理及读取都不依赖 globalThis 不破坏已有行为 隐藏测试 是 5%
C7 ES5 目标下,使用该变量的包只含 ES5 语法 代码质量与规范 隐藏测试 — 2%
C8 在原有测试下,单元、配置用例、stats 以及通用和 web 目标的 HMR 套件仍通过 不破坏已有行为 项目命令 是 8%
C9 新增测试在没有该改动时失败,有改动时通过 测试质量 改前失败、改后通过 是 7%
C10 新增测试中实际执行的断言覆盖数字 id 下的顺序与空结果 测试质量 评审判定 — 3%
C11 yarn lint 无报错:ESLint、生成文件最新、类型检查、Prettier、拼写检查 构建/lint/格式 项目命令 — 4%
C12 附带 webpack 的 minor changeset 及说明,格式能通过项目的校验 构建/lint/格式 项目命令 — 2%
C13 module.d.ts 将 __webpack_css_server_styles__ 声明为 string 构建/lint/格式 隐藏测试 — 2%
C14 读取方与写入方经同一个辅助函数取得注册表,别处不重建注册表表达式、不另存其内容 代码质量与规范 评审判定 是 4%
C15 像其他模块变量一样接入:APIPlugin 替换表项、新 RuntimeGlobals 常量、按需加入的 RuntimeModule 子类 代码质量与规范 评审判定 是 4%
C16 注释符合 AGENTS.md:简短、言之有物,新 RuntimeGlobals 常量像相邻项一样带文档注释,无残留 代码质量与规范 评审判定 — 3%
C17 规模适度,只改源码、测试、changeset 和声明;不动测试框架、不削弱已有测试 改动范围 改动范围检查 + 评审判定 — 3%

评分器对随附解法的判定

解法 份数 得分 不计阻断项的加权得分
参考解 1 100 100
其他正确解法 4 100 100
遗漏个别要求的解法 8 0 74–⁠95
取巧解 6 0 8–⁠92
未改动的代码 1 0 12

满分 100。任一阻断项不过,得分即为 0。

样例 5 / 5

让 Scrapy 下载处理器以自有异常取代 Twisted 异常

  • Python
  • scrapy
  • API 变更
  • 参考解 33 个文件、改动 702 行
  • Twisted 异步错误处理
  • 异常转换与异常链
  • 找全同类代码路径
  • 向后兼容的默认设置
  • 改写基类共享的测试
  • 难点
  • HTTP/2 建连失败须让等待中的请求全部失败
  • FTP 处理器也要转换,登录失败也算在内
  • 绑定错误、TLS 失败、代理不可达也不能漏出 Twisted 异常
  • 默认重试和缓存回退覆盖的失败保持不变
  • 各处理器共用一份异常映射

在 scrapy/exceptions.py 中新增 7 个不继承 Twisted 的下载异常(超时、取消、响应数据丢失、连接被拒、域名无法解析、其他下载失败、不支持的 URL 协议),让内置下载处理器(HTTP/1.1、HTTP/2、FTP;已弃用的 HTTP/1.0 只管超时)的 download_request() 不再抛出任何 Twisted 异常:每种失败换成对应的新异常,保留原消息,原异常作为 __cause__;HTTP/2 建连失败时,等待该连接的请求也要以对应的异常失败。RETRY_EXCEPTIONS 和 HttpCacheMiddleware.DOWNLOAD_EXCEPTIONS 的默认值改列新异常,默认设置下原本会重试或回退到缓存响应的失败仍然如此,取消和不支持的协议仍然不会;文档随之更新。

题面(Agent 收到的原文)

instruction.md

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 exceeded
  • DownloadCancelledError: the download was cancelled, e.g. the response exceeds DOWNLOAD_MAXSIZE
  • ResponseDataLossError: the response is incomplete (see DOWNLOAD_FAIL_ON_DATALOSS)
  • DownloadConnectionRefusedError: the connection was refused
  • CannotResolveHostError: the hostname couldn't be resolved
  • DownloadFailedError: any other download failure
  • UnsupportedURLSchemeError: 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.

题面后半:测试、lint 和代码风格规范
instruction.md(续)

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, not localhost, for local servers and closed ports. TestHttp11Proxy::test_download_with_proxy_https_timeout is 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 check and ruff format --check --diff (configuration in pyproject.toml).
  • SKIP=ruff-check,ruff-format pre-commit run --all-files --show-diff-on-failure (pre-commit only checks files tracked by git, so git add new files first).
  • pylint conftest.py docs extras scrapy tests (about 45 seconds).
  • mypy scrapy tests (the mypy on PATH is 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.

评分细则

# 细则 类别 检查方式 阻断项 权重
C1 HTTP11DownloadHandler 对每类失败抛出对应的新异常(HTTP10DownloadHandler 只看超时) 行为正确 隐藏测试 是 12%
C2 H2DownloadHandler 对每类失败抛出对应的新异常,包括连接被拒和域名解析失败 行为正确 隐藏测试 是 11%
C3 HTTP/2 建连失败时,等待它的请求全部失败,之后发往该主机的请求不受阻;绑定错误不是 Twisted 异常 行为正确 隐藏测试 — 4%
C4 绑定错误、TLS 失败、无效响应、代理不可达等少见失败也不漏出 Twisted 异常;StopDownload 不受影响 行为正确 隐藏测试 是 11%
C5 FTPDownloadHandler 同样抛出新异常(连接被拒、域名解析失败、登录失败) 行为正确 隐藏测试 是 9%
C6 默认设置下,各内置处理器的失败仍和原来一样重试 不破坏已有行为 隐藏测试 是 10%
C7 HttpCacheMiddleware 仍在与原来相同的失败上返回过期的缓存响应 不破坏已有行为 隐藏测试 是 6%
C8 转换后的异常保留原消息,__cause__ 为原 Twisted 异常 行为正确 隐藏测试 — 4%
C9 新异常是 scrapy.exceptions 中的普通类,消息参数可选 行为正确 隐藏测试 — 2%
C10 每个新异常都写进异常参考文档,文档中 RETRY_EXCEPTIONS 的默认值与实际一致 代码质量与规范 隐藏测试 是 4%
C11 DOWNLOAD_FAIL_ON_DATALOSS 的说明和 errback 示例不再描述 Twisted 异常 代码质量与规范 隐藏测试 — 2%
C12 默认列表去掉内置处理器已不再抛出的 Twisted 异常 代码质量与规范 隐藏测试 — 2%
C13 完整测试套件通过,受影响的测试模块通过的用例数不少于改动前 不破坏已有行为 项目命令 是 8%
C14 新增测试在没有该改动时失败,有改动时通过 测试质量 改前失败、改后通过 是 5%
C15 ruff 检查与格式、pre-commit 钩子和 pylint 均通过 构建/lint/格式 项目命令 — 2%
C16 mypy 和类型测试通过 构建/lint/格式 项目命令 — 2%
C17 多个处理器转换 Twisted 异常时共用一份映射,不各写一份 代码质量与规范 评审判定 — 2%
C18 原有断言改为断言新异常,新转换的失败经真实处理器测试覆盖 测试质量 评审判定 — 3%
C19 只改异常、内置处理器及其客户端代码、重试与缓存默认值、测试和文档 改动范围 改动范围检查 + 评审判定 — 1%

评分器对随附解法的判定

解法 份数 得分 不计阻断项的加权得分
参考解 1 100 100
其他正确解法 2 100 100
遗漏个别要求的解法 5 0 81–⁠91
取巧解 5 0 17–⁠84
未改动的代码 1 0 12

满分 100。任一阻断项不过,得分即为 0。

可定制

包括但不限于以下几项,其他需求都可以商量。

  • 语言与项目:语言配比,领域(Web 框架、编译器、数据库、前端应用、CLI 工具等),单题改动规模。
  • 题型与侧重:新功能、缺陷修复、重构、跨模块一致性改动;更看重测试质量、改动范围还是代码规范。
  • 评分方式:阻断项与权重,隐藏测试、项目命令、评审判定各占多少,以及评审所用的模型。
  • 难度:对标的模型和要达到的通过率区间。
  • 轨迹:Claude Code 原生工具调用,或按你的评测框架转写(如只用 bash 的 Agent 框架);每题一条或多条。
  • 数量和排期:交付数量和时间安排。

想提升模型的哪项能力?

来信告诉我们,我们会回复样例和规格说明。