Skip to content

fix(explore): reject non-finite replay planning evidence - #7563

Merged
huangruiteng merged 1 commit into
loopx-project:mainfrom
shangzh0:codex/replay-planner-finite-evidence
Oct 28, 2026
Merged

huangruiteng merged 1 commit into
loopx-project:mainfrom
shangzh0:codex/replay-planner-finite-evidence

Conversation

@shangzh0

Copy link
Copy Markdown
Contributor

Goal And Delivered Outcome

FailureReplayObservation(weight=nan) currently reaches replay-point ranking, producing non-finite scores and suffix estimates. Infinite weights and overflow from individually finite observations have the same problem; a NaN minimum score also disables threshold filtering.

Reject invalid weights and thresholds with field-specific ValueError, and reject non-finite aggregates before constructing proposals. Share finite-number conversion with the existing cost validator while preserving its error text. Finite rankings, fractional weights, signed finite thresholds, fidelity checks and candidate boundaries retain their existing behavior.

  • Basis: a directly reproduced defect in the shipped adaptive replay planner; related prior cost validation: fix(explore): reject non-finite replay costs #6095 (completed separately).
  • Intended base: loopx-project/loopx:main, verified at 3d9e492690a2449fe548fd665ece9ab83d52e7d2.

Author Declaration

  • Written by: model_agent (OpenAI Codex), at the contributor's request.
  • Specification: the reproduced defect and before/after requirements in this PR; the existing planner ownership is also identified in docs/architecture/rfcs/optional-semantic-assistance-jev-v0.md, section 4, at the base revision above.
Criterion Disposition Symbol / path Validation
Finite, positive observation weights implemented FailureReplayObservation.__post_init__ invalid-weight parameterizations
Finite score threshold, including valid negatives implemented plan_adaptive_replay_points invalid thresholds and negative-threshold parity
No non-finite proposal aggregates implemented existing planner accumulation boundary three independent overflow cases
Existing cost validation and ordinary ranking preserved implemented local _finite / _nonnegative owner existing planner and composed replay tests

Scope And Continuation

Complete within this scope. This repairs the existing Python replay arithmetic owner and adds no protocol vocabulary, scheduling authority, model calls, default changes or frontend behavior. The shared conversion removes duplicate input validation; no larger refactor is needed. No RFC milestone or benchmark-score improvement is claimed. This is not evidence that a live heartbeat route uses this planner or that Explore's decision policy improves.

Validation

  • Published revision: ba74b71e335f508f24fbe7f6ad4bca26e033adb6. Relevant tests, Ruff, diff and bilingual checks were repeated at a0f97a9d003e7cc691849b22476bf9b38c5939f2; publication normalized commit dates to UTC without changing its tree. Both changed files are also identical to the earlier tested head 99ad1fd32f65d5ded681426da68fb6dc8a0caafe.
  • Run state: finished. Input classes: synthetic.
Check kind Result Evidence / limitation
unit / integration passed pytest -q tests/test_explore_replay_runtime.py tests/test_explore_counterfactual_runtime.py tests/test_explore_replay_compatibility.py tests/test_explore_episode_runtime.py: 87 passed, including composed capture/child execution/promotion using synthetic adapters
regression_parity passed Run the 22 added cases against the base planner loaded in isolation: 21 fail, finite parity passes; all 22 pass with the repair. Existing 36 replay tests also pass.
static passed Ruff on both changed files; mypy on the planner; git diff --check; diff semantic advisory (no supported new vocabulary); bilingual RFC check (no paired RFC changed)
real_entrypoint passed At earlier head 99ad1fd, build the required Chat bundle, build wheel, install into a clean environment, and import/use the installed planner outside the checkout: invalid weights reject, finite ranking and strict JSON serialization pass. The two changed files are identical after rebasing; the entire new-base wheel was not rebuilt.
static passed loopx check on the two changed files: public-boundary scan clean; two warnings concern the intentionally absent local registry.
unit not_run Full repository suite; CI remains required. No paid model, real provider, benchmark or Windows qualification was run.

Coverage targets malformed input, arithmetic overflow and unchanged finite behavior through the existing replay API. There is no changed database, authority, CLI or UI path requiring a new provider/browser journey.

Frontend / Visual Evidence

UI impact: none. Before/after screenshots, viewports and source data: N/A; no presentation files changed.

Type And Area

Bug fix and regression tests in the Explore capability. Shared-authority RFC fixture impact: N/A.

Boundary Checklist

  • No private state, credentials, raw traces, verifier output, internal links or machine paths in the diff or PR.
  • No benchmark jobs duplicated or launched.
  • Scoped to the reproduced replay-planner defect.
  • No paired RFC changed; bilingual check passed.
  • UI impact is none.
  • Commit includes DCO sign-off.

Signed-off-by: shangzh0 <97216392+shangzh0@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; gpt-6.1-sol; OpenAI; runtime_reported; reasoning_effort=max.

动机 / Motivation

直接调用现有 ReplayPoint 规划 API 的开发者会遇到非有限权重、阈值或累计值污染候选排名的问题。 NaN 阈值会绕过分数过滤,有限输入的加权求和也可能溢出为 Infinity。 这会让无效候选继续参与排序或在严格 JSON 输出时失败,后续调用方要为错误证据反复排查。同一条十事件轨迹中,合法权重仍按预期选出候选;NaN、Infinity 和三类聚合溢出现在返回明确的 ValueError,避免把无效分数交给后续选择。

现有数值 API 的有限性缺口已由不可变基线反例、当前 API 和新构建 wheel 验证;不声称已接入新的自动调度或取得长期策略收益。 这是现有 API 的有界正确性修复;不捕获或恢复环境,不新增模型、预算、权限、自动 caller 或前端页面。

改动思路 / Approach

有限数值约束留在现有算术 owner,复用一个私有转换 helper;没有新增能力、状态机、模型调用或迁移窗口。 本 PR 仅修复既有 Python 规划 API 的非法数值边界;当前仓库未发现生产 CLI、App 或自动 runner 直接调用该规划函数,不把它描述为新的端到端重放能力。

调用链仍是轨迹边界与适配器估计进入原规划函数,经 fidelity 与位置筛选后累计收益、扣除捕获成本,再排序输出。新检查在转换入口和累计完成处拒绝坏值;阈值转换本身不要求非负,所以合法的负收益候选仍能由负阈值显式选择。没有借这个修复重写评分公式,也没有把数值合法性变成执行授权。

具体改动 / Changes

规格依据先于 diff 读取:docs/architecture/rfcs/optional-semantic-assistance-jev-v0.md#4-placement-and-domain-boundaries,不可变版本 3d9e492690a2449fe548fd665ece9ab83d52e7d2。映射其 Deferred replay placement 行:回放收益、fidelity 和成本由已有算术 owner 处理,当前实现保持该边界。该 RFC 的未来 Jev 研究要求不提升为这个修复的前置门。

独立使用不可变基线与当前 API 做了 36 项观察:合法加权算术输出完全相同,两候选顺序为 6、2,分数为 7、1.75;8 组原成本错误文字相同。9 个 NaN/Infinity/bool 或累计溢出反例在基线被接受,当前全部拒绝。新构建 wheel 的模块与当前源码逐字节一致,真实包 API 的合法结果和 6 个非法输入也验证通过。

四个相关模块 87 passed / 0 skipped;Ruff、目标 mypy、标准 premerge 的 6 direct + 5 selected 检查全部通过,无人工 hold。精确作用域 CQR cqr_58348cbf384b87435f54 有效。没有查询或等待远端 CI。

对主干的风险 / Risks

有意收紧的是原先能混入的非法数值;合法有限输入、负阈值、位置/fidelity 筛选、排序和成本错误保持。没有持久化 schema、公共签名、权限、调度或默认配置变化。Python 留在已有专门数值计算 owner,毋须扩成控制面语言迁移。

首次 wheel 构建因本地前一分支留下的旧前端 bundle 被正常拒绝;用准确 head 的未改 UI 源重新构建后,fresh wheel 成功并完成 API 验证。该准备失败保留,不当作作者回归或完整部署资格。

我的整体评价 / Verdict

APPROVE,适用于 ba74b71e335f508f24fbe7f6ad4bca26e033adb6 的完整两文件提案。有限性缺口已由真实 API、独立基线反例与 fresh wheel 验证,未发现阻断问题。

长程效果判断为 preserved:检查提高数值可靠性,未测量策略收益或完整运行成本。用户体验判断为 preserved:非法输入错误清楚,合法输出保持,不增加交互。视觉审查不适用:已检查 API、包内容与 CLI/App caller,当前不改变任何渲染页面、提示或控件。尚未验证的是生产自动 caller 采用、真实恢复与模型收益;本 PR 没有新增这些路径。批准不授予合并或安装权限。

English verdict: APPROVE — the complete exact-head numerical fix rejects non-finite evidence and aggregate overflow while preserving valid ranking, negative thresholds and existing cost diagnostics. No new automated replay consumer or long-horizon benefit is claimed. Head: ba74b71e335f508f24fbe7f6ad4bca26e033adb6.

@huangruiteng
huangruiteng merged commit 03ec78e into loopx-project:main Oct 28, 2026
28 of 42 checks passed
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.

3 participants