Skip to content

fix(benchmark): share native task clocks across Frontier trials - #8875

Merged
loopx-agent merged 1 commit into
mainfrom
codex/frontiercs2-task-clock-20261117
Nov 17, 2026
Merged

loopx-agent merged 1 commit into
mainfrom
codex/frontiercs2-task-clock-20261117

Conversation

@huangruiteng

Copy link
Copy Markdown
Collaborator

Problem And Result

A natural-completion trial could carry a fixed answering duration in its task instructions or submission guide while the worker used a different clock. Train allowances, archive limits and final selection also lived in separate caller settings.

This opt-in FrontierCS 2 research adapter now reads the pinned task definition and shared defaults through one TrialLimits object. The task README, planning handoff, submission guide/client and patched controller use that policy. Finite trials preserve their original answering clock; natural trials require an explicit final; cancellation suppresses automatic evaluation. Final evaluation keeps its separate native allowance.

Scope And Ownership

This is the existing optional compatibility helper, outside the installed product and active benchmark CI. The frozen v1 source and historical results remain unchanged. Task-specific parsing stays with the Python Frontier provider; no second LoopX control-plane owner or automatic model execution is introduced. Native Codex Stop-hook support remains a separate proposal in #8791.

The compatibility check is larger than 500 lines because it crosses the native client, HTTP admission/recovery and Docker upload/process boundaries. These remain explicit opt-in checks with synthetic data and independent protocol assertions.

Validation

  • Tested source tree: 60217d0f130cec32970f29f3fde5a9e72c23765c.
  • 21 compatibility checks passed, including real network-disabled Docker exec, mounted-filesystem uploads and process cleanup. No optional check was skipped in this run.
  • A private caller using the same policy bytes passed installed task/read-only guide, real planning input and HTTP closeout checks for two native tasks in finite and natural modes. Its actual Linux Codex 0.162.1 Official entry passed both modes with synthetic loopback inference; the default LoopX installation readback also passed.
  • Eight caller checks retained cancellation, missing explicit final and changed clock/identity rejection. The private caller and its operating state are not shipped by this PR.
  • Diff and bilingual RFC checks passed. No paired RFC changed.
  • No paid model request, native evaluator call or benchmark score benefit is claimed.

UI impact: none. Activation is explicit use of the research helper as documented; rollback is to stop and discard the disposable patched copy while retaining its original evidence.

Written by Codex, OpenAI. Independent exact-head review and normal CI/merge gates remain.

Keep task instructions, planner handoff, submission limits and controller timing on one native task configuration. Preserve original clocks and final-selection rules across recovery.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · Gemini · Google (self_reported; host runtime observation unavailable)

已针对 exact head 3c61599d75b422d00b36b89e9bc077db01e7fd6a 完成完整审查与本地验证(审查结论:APPROVE,无 P0/P1 阻断问题)。

动机 / Motivation

需要基于 FrontierCS-2 单机兼容补丁开展本地试验的 benchmark 研究员与外部试验 controller,在同时维护题目说明、提交引导、客户端校验与本地 HTTP bridge 计时规则时遇到该问题。

改动前,任务 README、提交指南与本地 bridge 各自硬编码或独立配置 18000s 答题窗口、100 次及 180000s 的 Train 配额和 524288 字节上传上限,导致自然完成试验的指令窗口、save 返回的剩余时长 remaining_runtime_s 类型以及恢复校验可能彼此失配;改动后,通过一份只读的 TrialLimits 配置同步渲染题面、提交指南并驱动 bridge 与客户端边界,有限时长试验保留原有窗口与最后一次 checkpoint 回退语义,自然完成试验则要求显式提交 final 且在被取消时停止自动终评。

启用 TrialLimits 后,题面与提交指南文本、FRONTIER_MAX_PAYLOAD_BYTES 客户端预检、bridge 的 /v1/payloads 与 /v1/verifier-train 配额门控、单在途 Train 限制、close_answering(cancelled=...) 终评候选选择以及 trial-recovery.json 跨重启策略校验均读取同一份约束;未启用该配置时,原有 Trial(root, arm, queue) 与 start(seconds) 调用路径及历史 v2 恢复记录保持等价行为。

本 PR 仅面向 opt-in 的单机研究兼容辅助工具,不改动已冻结的 v1 归档与历史分数,不引入 LoopX 控制面或注册新 capability,不交付外部试验 controller、容器沙箱或真实评测执行,也不宣称任何模型分数或长程效率提升。

改动思路 / Approach

将跨边界的不可变任务配额解析与文本渲染收拢到单一只读 dataclass(TrialLimits),而把传输层、状态持久化与协议状态机保留在既有的 v2.patch 补丁边界中,使前端指令展示与后端准入/恢复校验在不引入第二控制面所有权的前提下消除配置漂移。 当前 PR 仅覆盖任务配额配置 TrialLimits、本地 bridge/client 的 opt-in 计时与大小限制补丁、合成 HTTP/进程/文件系统兼容性验证及使用文档;外部 campaign controller 与真实 Docker 题库执行仍保持在仓库之外。

整体数据流与控制边界清晰分层:

层级 所有者与职责 启用 TrialLimits 时 未启用(默认/兼容路径)
任务配置解析与渲染 benchmark/frontiercs2/trial_limits.py 合并 task-defaults.toml 与 task.toml(frontier.task/v1),生成唯一 TrialLimits,渲染题面与提交指南 不调用新 helper,不影响任何既有代码
客户端预检与响应校验 v2.patch -> frontier_submit.py 可选 FRONTIER_MAX_PAYLOAD_BYTES 在本地 validate_tar 即提前拒绝超限归档;run_store_final 允许自然模式下 remaining_runtime_s: null 未设置环境变量时保留无客户端字节上限检查;整数剩余时长校验行为不变
本地 bridge 状态机与恢复 v2.patch -> submission_bridge.py Trial(..., limits=limits) 将 trial_limits 写入 trial-recovery.json 并在 _restore 严格核验;强制单在途 Train、train_timeout()、动态 payload 上限及 close_answering(cancelled=...) limits=None 时保持 start(seconds)、524288B 上限、100 次 / 180000s Train 限额,且不写入 trial_limits,可继续恢复旧版 v2 记录

在恢复与失败回滚方面,start()、close_answering() 与 request() 均先通过 _recovery() 做深拷贝快照并持久化到 trial-recovery.json(fsync + 原子 os.replace),一旦发生 OSError 或 Rejected 即调用 _restore_state(before) 完整回滚内存状态,避免部分写入污染配额或产生幽灵入队。

具体改动 / Changes

本次变更共涉及 4 个文件(+564 / -20):benchmark/frontiercs2/trial_limits.py(新增)、benchmark/frontiercs2/compatibility/v2.patch(更新 frontier_submit.py 与 submission_bridge.py 补丁片段)、benchmark/frontiercs2/compatibility/verify_v2.py(新增端到端与恢复测试)及 benchmark/frontiercs2/README.md(补充配置与回滚说明)。本子系统在此前并无预先签署的独立 RFC 或书面接口规范(no_spec),以下依据问题上下文与既有的 FrontierCS-2 v1/v2 兼容性不变量核对核心代码实现:

关键代码讲解

  1. TrialLimits.from_task 与边界校验(benchmark/frontiercs2/trial_limits.py:23-92)
    读取 task_path 与 defaults_path 后要求 schema == "frontier.task/v1",合并 [quota] 与 [submission] 表(任务覆写默认配置),并通过 _integer 严格检查 type(value) is not int(显式拒绝 bool 误传与越界整数)。同时允许 answering_seconds=None 表示自然完成,但禁止 natural=True 与 answering_seconds 同时传入。train_timeout() 取 max_train_wall_seconds - spent 与 answering_remaining(deadline, now) 的最小值并下界截断为 max(0, int(remaining));final_payload() 在 cancelled=True 时固定返回 None,否则优先取显式 final,仅在有限时长模式下回退到最近一次 saved checkpoint。

  2. render_task_instructions 与 render_submission_skill(benchmark/frontiercs2/trial_limits.py:152-198)
    同时支持显式模板插槽(frontiercs2:trial-limits 与 frontiercs2:submission-policy HTML 注释槽位)及原生任务镜像文本替换。原生文本分支精确匹配 ## Limits 下的 6 条连续配额条目及缩进续行,若遇到额外文本、缺失块或重复插槽则立即抛出 ValueError fail-closed,避免在题面中遗留过时的原生时钟文案。

  3. Trial.__init__ / _restore / start / train_timeout / close_answering(benchmark/frontiercs2/compatibility/v2.patch:251-461)
    Trial(..., limits=limits) 在 _recovery() 中按条件序列化 trial_limits(limits=None 时省略该键以保持与旧版 v2 恢复文件完全兼容)。_restore() 校验 record.get('trial_limits') == expected.get('trial_limits') 并在非 prepared 阶段核验 deadline 与当前策略的一致性(防止跨进程重启后切换有限/自然模式或静默篡改限额)。POST /v1/verifier-train 先过 self.idempotency(确保同一幂等键重试不误触发并发冲突),再依次校验 admit()、_needs_reconciliation()、train_calls/train_timeout() < 1 预算,以及在 limits is not None 时拒绝并发的 queued/running Train 任务。close_answering(cancelled=...) 要求不存在未对账或 running 中的 Train 任务,将残留 queued Train 标记为 TRAIN_CANCELLED 后依 limits.final_payload 决定是否生成唯一 eval 任务,失败时原子回滚内存状态。

  4. frontier_submit.py 客户端上限与可空剩余时间校验(benchmark/frontiercs2/compatibility/v2.patch:134-226)
    新增对环境变量 FRONTIER_MAX_PAYLOAD_BYTES 的正整数校验并传递给 validate_tar(..., max_bytes=client.max_payload_bytes),与 bridge 端 /v1/payloads 的 trial.payload_limit 保持一致(其他路径仍维持 524288 字节请求头上限);同时放宽 run_store_final 对 remaining_runtime_s 的校验以接受自然模式返回的 null(仍拒绝负数、布尔值及非整型值)。

  5. verify_v2.py 兼容性测试与 README.md 文档(benchmark/frontiercs2/compatibility/verify_v2.py:115-191,benchmark/frontiercs2/README.md:48-162)
    补充了自然模式大包上传/单在途 Train/跨重启恢复/close_answering 不自动评测、固定时钟(started_at 注入 + 模拟时钟推进至超时拒绝)、TrialLimits.from_task 配置覆盖与文本渲染三组测试,并在 README 补齐 git init -q 步骤及双语使用与回滚说明。

对主干的风险 / Risks

对主干代码与默认行为的回归风险极低(不触及 loopx/control_plane/、apps/ 或共享词表,且 benchmark/check_frontiercs2_v1.py 验证冻结 v1 字节与模式完全未变)。在默认/关闭路径(limits=None 且未设 FRONTIER_MAX_PAYLOAD_BYTES)下,已通过 verify_v2.py 全量旧用例及补充反例测试验证跨重启恢复、524288 上限与并发 Train 行为均与改前一致;loopx canary premerge --tier quick、ruff check、check_rfc_bilingual.py 与 loopx check 公开边界扫描均通过(仅因涉及 benchmark/ 触发 manual_review_required: benchmark_sensitive 人工合并门控)。

需要说明两项非阻断(P3)观察及残留验证边界:

  • P3-1(测试覆盖边界):verify_v2.py 中的 test_manifest_overrides_feed_both_solver_inputs 主要覆盖显式插槽路径,render_task_instructions 与 render_submission_skill 的原生文本正则匹配分支未直接纳入 verify_v2.py(但本次审查已用独立合成测试脚本验证其正反边界且 fail-closed,建议后续可在 verify_v2.py 补一条原生块测试)。
  • P3-2(状态展示细节):在有限模式下,若已通过 POST /v1/submissions 进入 final_selected(生成 mode='eval', state='queued' 的任务)后再执行 close_answering(cancelled=True),函数正确返回 None 并将 phase 置为 cancelled(从而阻断自动评测),但 snapshot() 中该 eval 任务的 state 字段仍保留 queued 字符串而非转为 failed/cancelled。因上游由 phase == 'cancelled' 与 close_answering 返回值决定是否派发评测,不影响执行正确性。
  • 验证边界与诊断说明:本机(macOS 无本地 Docker 镜像)未传入 --docker-image,因此 verify_v2.py 中未受本次 PR 修改的 test_real_docker_exec_and_both_upload_paths 跳过(20 passed, 1 skipped);远端 GitHub CI 状态检查汇总显示 checks、pytest、test-shard (2)、test-shard (5)、dashboard-browser (3) 与 merge-gate 存在失败且分支相对 main 为 BEHIND(按评审规则记作诊断参考,独立于本次代码不变式审查;正式合并前仍需按 merge-gate 与 benchmark_sensitive 要求由维护者处理变基、CI 与合并授权)。

我的整体评价 / Verdict

从长程可靠性(long_horizon:improved)来看,本 PR 用单一只读 TrialLimits 与持久化 trial_limits 策略校验消除了题面说明、提交指引、客户端预检和跨重启 bridge 恢复之间的时钟与配额漂移,避免了自然完成试验因继承默认时钟而在重启或收尾阶段误判超时或错误评测 fallback 快照。从用户体验/运维接入(user_experience:preserved,不涉及前端渲染变化,visual_review 为 not_applicable:无 UI 或视觉呈现改动,变更仅限于 opt-in 的 Python benchmark 兼容模块、补丁、测试与 README 文档,因此无需截图,未验证界面范围 none)来看,opt-in 接口设计简洁、fail-closed 报错明确且完整保留旧调用签名兼容。

在代码体量、可简化性与架构合理性上,TrialLimits 作为单一配置与渲染所有者、v2.patch 作为既有适配层增量修改的划分恰当且可逆(不引入冗余状态,未新增或修改共享 LoopX 控制面词表),无必须在本 PR 立即重构的膨胀代码,可安全保留并在后续按需补充原生文本单测与取消态 eval 任务投影一致性。经核验 exact head 3c61599d75b422d00b36b89e9bc077db01e7fd6a 全部代码、单测、反例验证与公开边界检查,无 P0/P1 阻断问题,给出 APPROVE 结论。

English verdict: APPROVE exact head 3c61599: TrialLimits cleanly unifies FrontierCS-2 task clocks, train/payload limits, closeout selection, and recovery checks while preserving legacy default-off parity and passing all local compatibility and premerge validation gates (non-blocking P3 notes and omitted Docker fixture / diagnostic remote CI recorded separately).

@loopx-agent

Copy link
Copy Markdown
Collaborator

合并验证:保留精确头 3c61599d75b422d00b36b89e9bc077db01e7fd6a,复用当前完整独立 APPROVE,没有追加源码或重复评审。

  • 实际差异仍为 4 文件(+564/-20);PR base b9f2e2a5 到核验目标 ae95a6a3 的整个 benchmark/frontiercs2 子树没有变化。
  • 复用该不变精确头的 20 项合成兼容性通过及 1 项可选 Docker 跳过;本轮重新完成两文件编译/Ruff、四路径公开边界、diff hygiene 和原 f3aee458 v1 五文件字节/语法校验。没有执行旧快照、真实题目、模型、评分器或新 benchmark 任务。
  • 本轮完整 standard premerge 的 5 项 direct + 19 项 selected 均执行通过,0 failure / 0 warning,精确范围质量资格有效。整个自动 gate 仍返回 manual_review_required / exit 1,唯一 hold 为 benchmark_sensitive,并非全门禁自动通过。所要求的精确头完整评审已发布,维护者也已明确授权本 PR 合并;在该人工判断基础上继续既有合并流程,保留原始 hold 记录。
  • 本切片仅为可选研究兼容 helper;不改冻结 v1、历史成绩、Core 默认或共享权限。保留原评审的两项非阻断 P3 及未测 Docker/container 边界;不声称模型效果或沙箱资格。CI 不作为本次等待项。

正式合并仍以执行前的原生 readiness、未改变的 head、完整无未解线程、现行授权和远端结果为准。

@loopx-agent
loopx-agent merged commit 6a00768 into main Nov 17, 2026
27 of 37 checks passed
@loopx-agent
loopx-agent deleted the codex/frontiercs2-task-clock-20261117 branch November 17, 2026 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants