Skip to content

fix(explore): reject ambiguous resource portfolio inputs - #7564

Merged
huangruiteng merged 1 commit into
loopx-project:mainfrom
shangzh0:codex/explore-resource-validation
Oct 28, 2026
Merged

huangruiteng merged 1 commit into
loopx-project:mainfrom
shangzh0:codex/explore-resource-validation

Conversation

@shangzh0

Copy link
Copy Markdown
Contributor

Goal And Delivered Outcome

Resource-aware Explore plans accept mapping inputs as well as CLI flags. Unlike the CLI parser, mapping normalization silently overwrites aliases: with capacity long_pool=2, usage {"long_pool": 2, "long-pool": 0} reports two free slots; reversing the same entries reports none. It also truncates fractional counts, accepts booleans, and leaks OverflowError for infinite counts.

Reject repeated normalized lane keys and invalid whole-number counts in the existing shared resource normalizer before either Todo or worker branch planning. Both key orders reject, ordinary integers/integer strings/integral numbers remain accepted, and capacity-free planning retains its behavior. Document these input constraints in both capability READMEs.

  • Roadmap anchor: S7's separation of configured capacity, consumption and estimates. This repairs an existing forecast; it does not qualify fleet-scale admission.
  • RFC boundary: research-exploration-control-plane-v0.md section 1, choice 6: Explore remains read-only; Todo, quota, claim, lease and spend keep execution authority.
  • Base: loopx-project/loopx:main, source pin 1ad00d895ddc8d4b0e30f554e1e78afcafbc0ee6.

Author Declaration

  • Written by: model_agent (OpenAI Codex), at the contributor's request.
  • Specification: the reproduced defect above and the existing loopx/capabilities/explore/README.md Resource-Aware Portfolio Planning contract at the base revision.
Criterion Disposition Owner Validation
Capacity and occupancy cannot change through normalized-key overwrite implemented normalize_resource_counts both planners, both input fields, alias spellings and both entry orders
Non-negative whole counts; malformed input has a field-specific error implemented same shared owner boolean, fractional, negative, non-finite, missing and malformed counts
Valid inputs, no-resource behavior and analysis-only authority preserved implemented existing planner APIs valid CLI/API parity, existing capacity/backfill/monitor/readiness tests and installed API checks

Scope And Continuation

Complete within this scope. The existing Explore Python planner helper owns both callers; no parallel decision owner, new vocabulary, state write, worker launch or scoring change is introduced. The related refactoring pass found that tightening this shared boundary is sufficient. This does not implement deferred portfolio research, enforce physical resource reservations or establish benchmark benefit.

Validation

  • Published head: cb1acd019ed5ccdf187d770ee7b95a3c3bb313c9. Tests/build ran against the identical tree committed as 103d17b; publication only normalized commit dates to UTC. Remote blob, tree and commit hashes were verified against local objects.
  • Run state: finished. Inputs: synthetic.
Check kind Result Evidence / limitation
unit / integration passed pytest -q tests/test_explore_resource_portfolio.py tests/test_explore_todo_readiness.py tests/test_explore_monitor_lane_budget.py tests/capabilities/test_explore_turn_context.py: 128 passed
regression_parity passed 65 focused tests pass after repair. Of the 61 new cases, 44 fail and 17 pass against the original normalizer loaded in isolation; unchanged valid inputs remain accepted.
real_entrypoint passed Built the required Chat bundle and wheel, installed the wheel into a clean environment, then exercised both installed planner APIs outside the checkout plus invalid/ambiguous input rejection. No model, network provider or benchmark job was launched.
static passed Ruff on changed Python; mypy on the helper; semantic diff advisory (no supported vocabulary carriers); bilingual RFC check (no paired RFC changed); diff whitespace check
static passed Public-boundary scan on all four paths: clean. Two local-registry warnings reflect the disposable checkout's absent registry.
unit not_run Full repository suite and native Windows qualification; required CI/review remain outstanding.

Frontend / Visual Evidence

UI impact: none. No new setting or product journey; this repairs existing planner API validation. Screenshots/viewports: N/A. Existing capability documentation is updated below its first viewport.

Type And Area

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

Boundary Checklist

  • No private state, credentials, raw trajectories/verifier output, internal links or machine paths in this PR.
  • No live benchmark duplicated or launched.
  • Change is scoped to the reproduced resource-input defect.
  • No paired RFC changed; bilingual check passed.
  • UI impact is none.
  • Commit carries 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

未发现阻塞问题,批准本次完整 head cb1acd019ed5ccdf187d770ee7b95a3c3bb313c9。

动机 / Motivation

直接向 Todo 或 worker 分支规划 API 传入容量与占用映射的开发者会得到依赖输入顺序的预测名额。 容量为2、占用映射依次给出 long_pool=2 和 long-pool=0 时,旧版会报告2个空位,反序则为0;新版两种顺序都明确拒绝重复键。 两条真实规划 API 的别名覆盖被阻止,合法输入和关闭态完整输出保持相等;没有启动 worker 或新增执行权。 不改变物理资源预留、quota、claim、lease、worker 启动或模型策略,也不新增界面。

预测名额若随字典顺序变化,会误导后续选择。这里修复的是可重复的输入错误;真实执行仍需原有准入,不能把预测空位当作资源预留。

改动思路 / Approach

共用输入检查留在现有资源 normalizer,两个消费者无需各自维护一份规则。 本提案只修复既有映射输入并同步双语约束,不扩展调度、状态或执行权限。 CLI 的 KEY=N 解析原来已拒绝重复键,API 映射现在补齐同一条身份规则。数值检查在转换后核对原值:整数、整数文本及2.0继续可用,布尔和0.5不会再伪装成整数。没有额外配置、状态副本、网络或重试层;本次边界采用现有 owner 已足够。

具体改动 / Changes

完整四路径 +86/-3:生产逻辑 +8/-2、既有测试 +71/-1、两份 README 共7行。先读基线规格 loopx/capabilities/explore/README.md#resource-aware-portfolio-planning,修订 1ad00d895ddc8d4b0e30f554e1e78afcafbc0ee6;Resource-Aware Portfolio Planning 的容量/占用与只读边界、Explore Harness Modes 的关闭态均已映射到当前实现。未把尚待研究的 fleet admission 或 Jev 项目当作本修复前置。

关键代码讲解

  • normalize_resource_counts 在赋值前查规范化键,容量和占用都拒绝别名碰撞;捕获 OverflowError 并保持字段级错误。检查只影响结构输入,没有依赖任务正文。
  • resolve_resource_portfolio 继续使用同一组合法计数计算容量减占用、超占与剩余名额;两个 planner 共用,analysis_only、零 score_delta 及所有执行权字段未变。
  • parse_resource_counts 保留 CLI 原有语法/重复检测;Todo/worker 与 CLI 的相关 caller blob 相对不可变基线全部相同,未另建解析或调度权威。

我独立运行128项资源、readiness、monitor 与 Turn context 用例,全部 PASS。另以同一输入直接调用两种真实 planner,基线/head 各52次观察:28组完整返回/错误完全相等,包括无容量、关闭、有效别名、零容量和超占;8组重复键旧版都返回、当前全部 ValueError。容量/占用、两种输入顺序均覆盖,输入对象未被修改。Ruff零问题、focused mypy通过,标准 premerge 的6直接与18选中检查全部 PASS、无人工 hold,严格 CQR 有效。另以当前源码重新构建 Chat bundle 和 wheel,隔离解包导入的3个产品模块与精确head逐字一致,两种planner合法调用及6个非法输入拒绝通过,未改变共享安装。

对主干的风险 / Risks

主要风险是把合法数值错拒或在默认关闭时改变普通规划。我比较了完整输出,包含候选、名额、现有错误和权限字段;没有只看状态码。NaN、负数及文本的既有错误保持,Infinity现在转成相同字段级 ValueError。新输入限制已明确写入中英 README,属于结构验证,规划建议依然不具有执行权。

实际入口为现有 API/CLI,已有前端设置入口没有新增任务,因此不需要制造新页面。未运行全仓、原生Windows或长期资源试验;当前没有受影响的存储/provider变更,不把这些未测项改称通过。当前双语差分检查、公开边界检查及贡献签署均成立。源码改动仅6净行,沿原 owner 留下直接判断是足够小的完整修复,无需继续抽象。

语义与 CI 对齐

复用现有词汇和 schema,无新共享枚举;合法关闭路径保持,重复输入拒绝是已说明并验证的有意变化。CI按当前策略未查询;这里的PASS来自本地真实检查,合并资格仍需独立读取。

我的整体评价 / Verdict

本次有界输入修复达到目标。long_horizon为preserved:没有新增历史或持续循环,只读预测仍回到正常执行准入;user_experience为preserved:合法调用不增加准备、确认或恢复步骤。检查了既有 API、CLI 分支与文档变更;没有渲染页面或用户控件变化,截图不适用。 未验证范围为原生Windows、正式安装App及长期资源/模型收益。做到了明确错误与正常调用兼容,未证明完整成本或策略提升。相关记忆建议面向恢复RFC的分阶段交付,此处是既有API修复,只采用其检查实际消费者的原则,不附加无关产品门。

English verdict: APPROVE — cb1acd019ed5ccdf187d770ee7b95a3c3bb313c9. Both real planners reject ambiguous mappings; 128 focused tests, 52 paired observations, lint/type checks and applicable premerge pass. Read-only authority and ordinary disabled behavior remain intact; no merge or long-horizon benefit is implied.

@huangruiteng
huangruiteng merged commit 5b6dcfb into loopx-project:main Oct 28, 2026
26 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