Repository navigation
fix(explore): reject ambiguous resource portfolio inputs - #7564
Conversation
Signed-off-by: shangzh0 <97216392+shangzh0@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
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.
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 leaksOverflowErrorfor 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.
research-exploration-control-plane-v0.mdsection 1, choice 6: Explore remains read-only; Todo, quota, claim, lease and spend keep execution authority.loopx-project/loopx:main, source pin1ad00d895ddc8d4b0e30f554e1e78afcafbc0ee6.Author Declaration
loopx/capabilities/explore/README.mdResource-Aware Portfolio Planning contract at the base revision.normalize_resource_countsScope 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
cb1acd019ed5ccdf187d770ee7b95a3c3bb313c9. Tests/build ran against the identical tree committed as103d17b; publication only normalized commit dates to UTC. Remote blob, tree and commit hashes were verified against local objects.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 passedFrontend / 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