Skip to content

Preserve CLI usage errors after lazy dispatch - #9719

Open
cocolord wants to merge 1 commit into
loopx-project:mainfrom
cocolord:codex/selected-cli-usage-boundary-20261201
Open

cocolord wants to merge 1 commit into
loopx-project:mainfrom
cocolord:codex/selected-cli-usage-boundary-20261201

Conversation

@cocolord

@cocolord cocolord commented Dec 1, 2026

Copy link
Copy Markdown
Member

Goal And Delivered Outcome

  • Mainline Python qualification recorded six failures after the lazy CLI began handling Benchmark Experiment Board commands. A handler's rejected input escaped as an internal exception and changed the exit code from 2 to 1. Python Tests run · #9567
  • Post-parse validation renders the registered subcommand's usage and exits with code 2. Argument parsing retains its full-parser fallback. Related to Start a checked local task directly from a goal #9053 and based on main.

Author Declaration

  • Written by the Codex agent (OpenAI GPT-6).
  • The behavior is specified by the mainline CLI error and privacy cases in tests/capabilities/test_benchmark_experiment_board.py at d19a0d7e0d.
Criterion Disposition Evidence
Report rejected input through the public usage diagnostic Implemented The existing rejection and correction cases and the selected/full stderr parity case
Avoid dispatching twice or loading the full facade for a handler rejection Implemented The parity test forbids the facade import on the selected route

Validation

Tested 395f1bd1ff6c3d29d07fcb7d26fd7788e699b23f with synthetic data.

Check Result Evidence
Regression parity Passed Six failures reproduced on main. All six and the new parity case passed on this revision.
Source CLI Passed 164 related cases on Python 3.13 and 141 scoped cases on Python 3.14 with coverage. The two suites overlap.
Installed CLI Passed Six standalone Core cases passed. Locally built matching Core and Benchmark Toolkit wheels installed in a clean environment and returned code 2 without a traceback, input path, or ledger write.
Standard premerge Passed Six direct and two selected checks. The existing maintainability advisory remains.

The complete hosted Python qualification remains with the integration gate. UI impact is none. Both changed files are covered by the signed-off commit.

@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.2-sol · OpenAI · runtime_reported · xhigh

动机 / Motivation

使用轻量 CLI 写实验看板的操作者和自动化,需要用退出码区分用法错误,并能从同一条安全提示修正输入。主干的已解析请求被 Benchmark handler 以用法错误拒绝时,轻量 CLI 让私有异常越过命令边界。基线六个原有测试实际从预期退出 2 变成退出 1。候选异常携带实际子命令 parser。handler 拒绝由原用法渲染打印到 stderr,退出 2。源轻量、完整 CLI 和独立安装的返回一致。变化集中在源和完整安装的轻量分派边界。解析前拒绝仍进 canonical full parser,Core-only 匹配扩展使用原入口。每个测试使用隔离工作区和合成记录,覆盖正常入口及双包 wheel。

改动思路 / Approach

分派前 parse_args 保留原 fallback。已进入 handler 后只捕获 _SelectedParseRejected,沿异常持有的子命令 parser 调用 argparse 的公共 error,保留原 usage 字样和退出行为。明确区分普通运行错误和已由业务拒绝的用法错误。 保留原有私有异常,多携带 parser 引用即可。对已经执行过的 handler 再走完整 CLI 可能重跑命令,也有不必要的导入成本。 现有子命令拥有输入和权限检查。新路径只输出已决定的拒绝类型,不扩充 registry、写入或执行范围。 变化集中在源和完整安装的轻量分派边界。解析前拒绝仍进 canonical full parser,Core-only 匹配扩展使用原入口。

具体改动 / Changes

审阅提交 395f1bd,diff 基线 d19a0d7,2 个文件,+26/-11。用法错误与隐私沿原子命令 formatter,单次分派在进入 handler 后单独捕获异常。完整 parser 仍拥有未解析的未知参数。回归以相同非对象输入比较轻量、完整和安装版,并监测导入和实际 handler 调用。独立测试还复核了 Capability manifest 报错以及匹配 Core 包的缺包提示、安装和移除行为。 入口契约 · 已有命令拒绝用例 · 分派保护 · 回归对照

对主干的风险 / Risks

最强回归是把 handler 的拒绝又交给完整 CLI,令拒绝前操作重复或打印错 parser。独立计数同时覆盖 Board 和原有 Capability 分支。

六个基线失败在候选恢复。独立观察无效 Experiment Board 输入返回相同 stdout/stderr,退出 2,调用一次,轻量过程未导入 loopx.cli。Capability list 的无效 manifest 同样只调用一次并与旧完整 CLI 的诊断一致。 源基线用相同非对象输入返回 1,重现 _SelectedParseRejected。候选用法错误 stdout 为空,受控输入标记、文件路径和 traceback 未进入 stderr,执行模式没有创建 ledger。未知 flag 仍走完整 parser,未调用 handler。 378 项源 CLI 与 Experiment Board 测试、7 项安装版 Core/Benchmark Toolkit 测试及 standard premerge 的 6 项直接、2 项选中检查通过全部阻断门。保留一项既有维护性提示。

我的整体评价 / Verdict

APPROVE。 无阻塞发现。退出状态、用法正文、单次分派及无额外写入均在正常入口上得到复验。 CLI 用法和进程退出边界。 在 macOS / Python 3.11 和隔离 wheel 上复验。未运行任何真实模型、Benchmark run 或 Hosted 全仓分片。

English verdict: APPROVE at 395f1bd. The selected handler reports normal code-2 usage errors once, with full-CLI and installed-wheel parity. Unknown flags still use the canonical parser, and rejected Board input remains private and unwritten.

This branch has not been deployed

No deployments
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