Repository navigation
Let heartbeat benchmarks use their full remaining phase budget - #8148
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: actor_kind=model_agent; model=gpt-6.1-sol; provider=OpenAI; runtime_reported; reasoning_effort=max.
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
两个 P2 阻塞项:请求准入仍使用旧的 160 秒截止规则;六个已有规划/交接测试没有随新预算语义更新。评审范围为完整 head 46e4167ee544fa36bbc21a5f7af9ac76fe06d6e9,目标基线 faab5f5c291c5359216a0f944fe63fcfbaacdedc。
动机 / Motivation
运行 heartbeat 基准的操作者在一个阶段只剩 140 秒时仍有合法的求解时间。 同一隔离任务剩余 140 秒:主干直接 budget stop;当前 head 在普通路径可完成一次请求,但启用 provider request admission 后请求立即被旧截止时间拒绝。 已验证默认路径能使用短剩余预算;可选请求准入路径仍产生 unknown、不可重试失败,完整承诺尚未达到。 固定丢弃每个阶段最后一段时间会反复减少实际求解机会;只让进程启动而不能发出请求也无法交付这个改进。本次不改变总阶段时限、Stop/quota 权限、原生评分或终态判定,也不证明真实模型长时运行收益。 请求准入仍扣除旧预留时间,规划与调度测试仍保留旧截止规则;这些缺口需要在本 PR 修复。
改动思路 / Approach
阶段截止时间由现有 runner 产生,worker 根据执行模式和显式 timeout 推导当前可用窗口,再通过现有进程与 session owner 调用 host。计划阶段、实际执行、请求转发与清理仍共享原始阶段边界。一个共享的模式预留函数足以完成这次预算分配,HTTP 准入与进程清理继续由现有 owner 负责;不需要新状态或新开关。 当前 PR 必须同时覆盖 worker、runner、请求准入和现有规划测试,才构成可用的预算窗口变更。
不修改代码会继续浪费已配置的合法预算;只改 worker 会留下 runner 的提前截断。集中一个模式函数的范围合理,但搜索全部常量消费者发现,请求网关尚未采用这个规则。网关对 Stop/quota、进程存活及单次调用身份的检查仍然必要;应修复其时间推导,保留这些检查。
以下是两个不可变版本上同一公共 worker 入口的实际对照;SQLite、子进程和 HTTP 均使用隔离本地实例,模型为合成程序,未测试外部模型效果。
| 输入 | 基线 | 当前 head |
|---|---|---|
| heartbeat 剩余 140/160 秒,默认路径 | 不启动 host,budget stop | 启动一次并正常完成 |
| heartbeat 剩余 0 或负数 | 不启动 host | 相同 |
| 其他四种模式剩余 160 秒 | 不启动 host | 相同 |
| heartbeat 300 秒,显式 timeout 0.4 秒 | 超时失败、回收子进程 | 相同 |
| 请求准入开启,剩余 140 秒 | 不启动 host | 启动后请求被拒绝,upstream POST=0 |
| 请求准入开启,剩余 300 秒 | HTTP 200、一个 POST | 相同 |
具体改动 / Changes
关键代码讲解
phase_work_reserve将 heartbeat 预留设为零,其他执行模式继续保留 160 秒;它返回工作分配规则,不授予执行权限。run_once在准备前后使用原始绝对截止时间,较早的显式 cap 仍生效。零预算不启动 host,已启动超时保留部分输出并清理。新的完整窗口会进入仍扣除 160 秒的请求网关,这是第一项遗漏。BenchmarkCodex.run的默认执行 cap 改为 None,显式 cap 才取剩余预算的较小值;外层 timeout 与 kill-after 仍约束总阶段。SForge 复用该 adapter,避免再派生一个重复 cap。prepare_entry及最终 handoff 采用相同模式函数;已验证计划与 Todo lineage 的复用、失败/阻塞计划不得转为执行等原有义务继续存在。正剩余时间的新定义需要反映到现有测试。
规范依据是 benchmark/runtime/RUNTIME.md,不可变规范版本 faab5f5c291c5359216a0f944fe63fcfbaacdedc,见原始契约。使用原有段落标题作 criterion_id:Task entry and planning ablation 在本 head 为 not_met,因为 worker 与请求网关的同一阶段时钟不一致,规划边界测试也未同步;Results, timeout and recovery 的部分输出、独立超时及子进程回收路径已验证,记为 implemented;Migration and qualification 的原始配置时限、来源与结果资格边界保留,记为 implemented。PR 自己改写的文档不能替代独立验收依据。
对主干的风险 / Risks
[P2] 让请求准入采用相同的 heartbeat 截止时间。 当剩余 140 秒且开启文档已有的 provider_request_admission 时,worker 允许启动,但 ProviderRequestAdmission.__init__ 仍以 phase deadline 减 160 秒计算请求截止时间。真实公共入口对照得到 FirstPartyHostRuntimeRejected(provider_request_budget_exhausted),ok=false、host_failure.kind=unknown、retryable=false,实际 upstream 没有收到 POST。相同任务关闭此选项可完成一次 HTTP 200,开启后剩余 300 秒也正常。这是新窗口暴露的消费者遗漏,不能用默认路径成功来覆盖。最小修复是复用共同阶段 deadline/模式规则,同时保留独立较早 cap、Stop/quota、存活检查与两秒 dispatch 上限;补充开启/关闭选项的短预算和真正过期用例。
[P2] 同步六个已有规划/交接预算测试。 test_task_entry.py 中 ready planning 的 140→250、later host cap 的 40→60、Harbor 的 440→500,以及原本把剩余 150 秒判作耗尽的路径,都因本 PR 的有意变化失败。六项应更新为新规则,并把真正的零/过期预算、blocked plan、不重新充时和无错误 dispatch 的负例保留下来;不应跳过或删除这些测试。复核命令为 python -m pytest -q benchmark/tests/test_task_entry.py benchmark/tests/test_provider_request_admission.py。
本地验证:PASS 初选三个 runtime 模块共 529 项(首轮 524 通过、5 项测试导入路径错误;补齐 tests/ 路径后原 5 项全部通过,保留首次结果)。FAIL 扩展规划/准入模块 head 为 116 passed / 11 failed;相同命令的不可变 base 为 122 passed / 5 failed,五个同名 scheduler case 均在 test_task_entry.py:663 的 should_run 预检发生相同 KeyError;不归为本 PR 新缺陷,另外六项是本次新增失败。PASS changed-source Ruff、5 个 premerge direct checks 和 semantic vocabulary smoke;catalog 的另外 8 项 smoke 通过。maintainability ratchet 的同一 interaction_contract._admitted_interaction_next_cli_actions 失败在不可变 base/head 均存在且没有新增 magnitude regression,单独保留为既有诊断;premerge 整体仍是 manual_review_required,不能宣称全绿。未读取或等待远端 CI。
语义与 CI 对齐
改动复用既有 Execution 模式和 receipt 字段,没有新增共享枚举、权限或 Goal 状态。完整语义 smoke 通过;changed inventory 对 benchmark 选择零快照,本身不能证明语义安全。实际请求探针已经给出同一 budget 契约不一致的反例,优先修复该行为。相关 #8151 处理 no-host budget stop 后的阶段恢复,边界独立,不能替代这里的网关修复或测试。
我的整体评价 / Verdict
默认路径交付了可复现的有用增量,范围和代码量合理;long_horizon 与 user_experience 在启用请求准入的短剩余窗口发生回归,启动成本后得到不可重试未知失败,尚未满足完整承诺。对比保留了 phase deadline、canonical fixture 状态和其他模式的行为,未把不同预算归一化为相同结果。共享函数是合适的局部收敛,修复遗漏消费者即可,无需增加新开关或扩大重构。
视觉审查不适用:已检查 benchmark adapter 与 RUNTIME 文档,没有渲染页面变更;渲染范围无未核验项。真实外部模型的全时长运行、Linux remote Harbor/Docker 和分数收益未验证,本次合成 conformance 不作这些声明。修复上述两项后,在新精确 head 重新运行短预算 gate on/off、既有负例及规划测试,再复审。合并权限和 readiness 独立于本评审。
English verdict: REQUEST_CHANGES — unify the request-gateway deadline and update the six affected budget tests.
| return receipt | ||
| if execution.mode == "heartbeat": | ||
| phase_work_deadline = float(env["LOOPX_PHASE_DEADLINE_EPOCH"]) - PHASE_WORK_RESERVE_SECONDS | ||
| phase_work_deadline = float(env["LOOPX_PHASE_DEADLINE_EPOCH"]) |
There was a problem hiding this comment.
[P2] 请求准入仍扣除旧的 160 秒
新的完整 phase deadline 会让剩余 140 秒的 heartbeat 启动,但 native_child_process 随后创建的 ProviderRequestAdmission 仍在 provider_request_admission.py:70–71 从同一个截止时间减去 PHASE_WORK_RESERVE_SECONDS。真实 SQLite/native child/本地 HTTP 对照中,选项关闭时成功 POST,开启时立即 provider_request_budget_exhausted,upstream POST=0,最终是 unknown、retryable=false 的 Host failure;剩余 300 秒开启选项则正常。请让网关复用相同 heartbeat deadline/模式规则,同时保留显式较早 cap、存活及 Stop/quota 检查,并补 gate on/off 短剩余窗口回归。
| return 1 | ||
| # A successful plan may itself consume the remaining execution allowance. | ||
| if float(env["LOOPX_PHASE_DEADLINE_EPOCH"]) - time.time() <= PHASE_WORK_RESERVE_SECONDS: | ||
| if float(env["LOOPX_PHASE_DEADLINE_EPOCH"]) - time.time() <= phase_work_reserve(env.get("LOOPX_EXECUTION_MODE", "heartbeat")): |
There was a problem hiding this comment.
[P2] 更新受新截止规则影响的现有规划测试
这里将 heartbeat 耗尽边界改为零,但 test_task_entry.py 仍把剩余 150 秒视为耗尽,Harbor/worker 的其他断言也仍期望旧预留后的 140/40/440。相同 planning+request-admission suite 在不可变 base 为 122 passed/5 failed,当前 head 为 116 passed/11 failed;额外六项正是这些 cutoff/cap 断言,五项相同的 quota preflight KeyError 单独保留。请更新这六项 oracle,保留真正零/过期预算、blocked plan、不可重新充时和无错误 dispatch 的负例。复核 python -m pytest -q benchmark/tests/test_task_entry.py benchmark/tests/test_provider_request_admission.py。
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Self-review after fixes — exact head 511a4318f8f41152c331afbab15360544644ac22.
Both prior P2 findings are closed:
- Provider request admission now uses the same mode-specific
phase_work_reserveas worker/Harbor/SForge, so heartbeat requests use the full positive remaining phase instead of reapplying the old 160-second reserve. - Budget test oracles now reflect heartbeat zero reserve while retaining expired/zero-budget and non-heartbeat reserve cases.
- Added a real HTTP/canonical-authority regression for a 140-second heartbeat request with admission enabled.
Verification: the focused task-entry/admission set passes apart from five independently reproduced baseline should_run envelope failures; 77 passed, 47 skipped, 5 deselected. The changed provider/worker regression is 23 passed; Ruff and diff checks pass. Current main was merged with DCO.
huangruiteng
left a comment
There was a problem hiding this comment.
Independent approval of exact head 511a431 after shared-reserve and regression fixes.
Keep the imported fixtures accessible while marking the three intentional parameter-name reuse sites for Ruff F811, restoring kernel-static-checks after #8148. Signed-off-by: huangruiteng <huangrt01@163.com>
Heartbeat benchmark workers could stop about 160 seconds before the phase deadline, and a continuation with less than 160 seconds remaining was rejected before it could run. Harbor also derived an independent wake cap from the initial trial allowance.
This change shares the mode-specific reserve between planning and execution, lets heartbeat work consume every positive remaining phase interval, and leaves cleanup bounded by the existing process transport. Harbor and SForge now leave the default wake cap unset; explicit Harbor caps, native Goal/managed-turn reserves, provider failures, Stop, and terminal LoopX decisions retain their semantics. This fixes budget deductions; it does not certify an early terminal decision as a full-duration run.
Validation: 508 SForge/shared-runtime tests passed against the pinned native provider, plus 20 phase-budget tests and the new short-allowance real-process/SQLite case. Restoring the old 160-second rule makes that case fail before any host invocation. Ruff and diff checks passed. The first provider test attempt used the wrong checkout/dependency/PATH; it is excluded from the qualified result.
Placement: this remains in the existing research runtime adapters and shares their reserve calculation. No product scheduler policy, native scoring, checkpoint frequency, or machine acceptance vocabulary is added.