Repository navigation
perf(cli): load host-mode selection without the full CLI graph - #7996
Conversation
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com> Co-authored-by: TRAE CLI <traecli@bytedance.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com> Co-authored-by: TRAE CLI <traecli@bytedance.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
动机 / Motivation
需要预览宿主运行方式的 CLI 用户,在查看帮助或合法方案时承担了与选择任务无关的完整 CLI、Chat 和 benchmark 加载成本。 原来只请求宿主模式帮助或预览,也会加载完整 CLI;现在合法请求只加载原选择器依赖,非法语法仍由完整 parser 给出原诊断。 独立验证中,合法 help 和 preview 的 LoopX 加载模块从1149降到57;28组输入的完整输出与退出状态保持一致,没有生成调用方状态。 本 PR 仅交付现有发现命令的加载切片,不改宿主选择、权限、预览默认值或持久协议,也不证明 managed minimal、真实宿主采用或长期净收益。 完整 V1 双预设及拒绝路径的最小加载、V10 暖路径与完整成本、M1 包迁移和 R1 实际托管工作仍未完成。
改动思路 / Approach
沿用原 registrar、handler 和选择器,把加载分支放回既有 CLI runtime;语法拒绝保留完整 parser,避免以复制 grammar 换取启动优化。 当前边界是合法 host-mode-plan 的依赖加载与原结果保持;状态、权限、宿主启动和后续 Turn 执行仍由原 owner 负责。 不改选择器而只缩小加载入口,已经能让原命令直接完成原任务;另建配置、插件注册表或第二个宿主选择器没有必要。最强反对理由是它仍未完成最小内核,非法语法仍走较重入口,但这并不妨碍当前发现操作形成可独立验证、直接回滚的有用切片。下列是实测加载差异,不是运行宿主或长期收益证明。
| 合法请求 | base LoopX 模块 | head LoopX 模块 | 完整结果 |
|---|---|---|---|
| help | 1149 | 57 | 字节相同 |
| ready preview | 1149 | 57 | 字节相同 |
具体改动 / Changes
规范依据 docs/architecture/rfcs/monorepo-distribution-split-v0.md,固定已接受版本 6a6a8590e09822b254ae615fd4b64c9e047508f1;先读原规范,再判断新增记录,未用本 PR 的记录反向定义验收。I2:复用原选择器和执行 owner,无第二份状态权威。I7:合法发现路径的进程、网络和写文件激活被实际 audit hook 阻止,原预览继续不启动宿主。I9:只陈述具名环境的加载测量。V3:当前调用面的完整输入与错误诊断已实现兼容。V1:只资格化这个合法发现入口,双预设、非法语法最小加载仍 deferred。V10:完整暖路径、文件 IO、IPC、模型上下文与真实 Turn 成本仍 deferred;M1/R1 和 D1–D7 不关闭。
关键代码讲解
_build_selected_parser:310复用原register_host_mode_plan_command,保留同一组全局选项、子命令参数与禁止缩写规则;没有复制 grammar。_dispatch_common_command:417把解析结果交给未改的 handler,再由原build_host_mode_plan生成 readiness、identity 和预览命令;没有启动、扣额或写状态。_run_command:752在 selected parser 拒绝语法时仍返回完整 parser,保留详细 stderr 与错误优先级;语义错误仍由原HostModePlanError返回。
全 diff 四文件 +132/0,生产11行、测试81行、双语记录40行。独立的28组输入覆盖五种意图、五种可见宿主身份、缺失与模糊身份、重复意图、空值、未知语义、非法/缩写参数、重叠错误以及输出格式优先级;同一数据在普通与 outer-controller 环境均保持完整 stdout、stderr 和退出码一致。基线实际公共 help/preview 会触发“不得导入完整 CLI”的反例,隔离 oracle 退出97,head 均退出0;这与结果值相等分别验证加载变化和语义保持。
对主干的风险 / Risks
最强回归反例是合法方案看似正常,却改变错误恢复或暗中激活可选运行时。PASS:真实 CLI 比较未做文本归一化,缺少 Node 时仍可给出原预览与拒绝信息;调用方目录保持空。另行构建真实前端前置产物后制作并隔离安装物理 wheel,1410个 Python 成员与本 head 一致;28组 source/wheel 完整输出相同,另有6个原生 console 调用通过,没有借用源码 checkout。初次未准备前端的 wheel 构建拒绝缺失 bundle,原失败保留,随后执行真实 build,未用占位物或跳过验证。
PASS:36项架构/导入边界/模块预算检查、两处 Python Ruff、已提交双语 diff 和四文件公开边界扫描。FAIL:扩展 CLI 套件 head125通过/1失败,base114通过/同一失败;test_steward_endpoint_vocabulary_is_read_without_the_chat_layer 仍只期待 codex/dsh,而两端均返回 antigravity/codex/dsh。完整测试函数 AST 与 endpoint owner 未变,失败发生在新路由前的直接词汇断言;本次新增路由另有真实调用独立覆盖。严格 CQR 仍 FAIL,未把基线归因作为必检豁免。原生 premerge 的6项直接检查通过,11项选中检查无阻塞测试失败;其中1项维护性 advisory 失败,两端完整诊断相同,均指向未改的 machine_section_projection.render_canonical_todo_sections 超大函数,且无 magnitude regression。最终结果仍因 quality_invalid_receipt 为 FAIL,原失败保留。原生 smoke 初次在两端均因隐式默认 runtime 冲突拒绝,使用同一显式隔离 HOME/runtime 后均通过;未修改本机活动配置。未查询、轮询或等待 CI。
语义与 CI 对齐
私有命令集合复用已存在 token,既有 parser、错误类型、预览 schema 和 authority 边界不变;没有 substring 或 prose 状态分类。完整输出对照覆盖原有权限、验证、回写和 no-spend 指令,不能以相同枚举代替这些检查。语义 advisory 未发现其支持范围内的新词汇载体;这不声称穷尽动态语义。CQR 与 premerge 的实际结果继续作为独立合并门保留,批准代码不解除门禁。
我的整体评价 / Verdict
未发现本 PR 引入的阻塞问题,APPROVE;交付判定 justified_increment。long_horizon 判定 preserved:本次不改准入、恢复或结算,不能从更快帮助推断目标净收益。user_experience 判定 improved,仅指相同发现任务的本地加载开销下降且没有新增准备或确认回合。8组成对新进程、交替顺序、每端一次预热、关闭遥测、禁写字节码的独立测量中,macOS arm64/Python3.14.8 的 help 中位376.5→68.1ms,preview379.4→71.4ms;文件缓存为热、共享机器负载未控制,样本小,不作为跨平台 p95 门或完整成本结论。现有 parser/handler 复用已应用;完整 parser 为诊断兼容保留,旧 cli.main 后部现不可达的宿主转发可随相邻 common-command 清理,不是当前合并豁免或新的跟踪任务。
仅检查 CLI 文本与 RFC 记录,cli_runtime 和既有 host-mode-plan 输出没有渲染页面改动;无需新增截图。真实 Windows、已安装桌面或宿主采用未验证。required 套件失败、严格质量限制和后续完整 V1/V10/M1/R1 验收继续开放;本审查不授予合并或安装权限。
English verdict: APPROVE at 7d48a07096204b2a6bdecb623c6f36f2a29d5240. Independent native CLI and physical-wheel evidence supports the scoped loading improvement with complete output parity; the pre-existing required failure and strict quality hold remain.
7d48a07 to
cc2ac42
Compare
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
动机 / Motivation
需要预览宿主运行方式的 CLI 用户,在查看帮助或合法方案时承担了与选择任务无关的完整 CLI、Chat 和 benchmark 加载成本。 原来只请求宿主模式帮助或预览,也会加载完整 CLI;现在合法请求只加载原选择器依赖,非法语法仍由完整 parser 给出原诊断。 独立验证中,合法 help 和 preview 的 LoopX 加载模块从1149降到57;28组输入的完整输出与退出状态保持一致,没有生成调用方状态。 本 PR 仅交付现有发现命令的加载切片,不改宿主选择、权限、预览默认值或持久协议,也不证明 managed minimal、真实宿主采用或长期净收益。 完整 V1 双预设及拒绝路径的最小加载、V10 暖路径与完整成本、M1 包迁移和 R1 实际托管工作仍未完成。
改动思路 / Approach
沿用原 registrar、handler 和选择器,把加载分支放回既有 CLI runtime;语法拒绝保留完整 parser,避免以复制 grammar 换取启动优化。 当前边界是合法 host-mode-plan 的依赖加载与原结果保持;状态、权限、宿主启动和后续 Turn 执行仍由原 owner 负责。 与上次评审相比,当前 head 已整合 M1 的17个内部 Chat owner 迁移,并补充双语结构检查点;这改变了依赖图,不能直接继承旧批准。本轮重新读完整四文件 +139/0 diff,核对生产11行和测试81行新增内容仍相同,再在当前不可变 base/head 重验实际入口与独立物理包。另建 grammar、状态或插件框架仍无必要;语法拒绝的重入口保留,完整最小内核不在本切片内。
| 当前请求 | base 加载的 LoopX 模块 | head | 完整输出 |
|---|---|---|---|
| help / ready preview | 1149 | 57 | 字节相同 |
具体改动 / Changes
规范依据 docs/architecture/rfcs/monorepo-distribution-split-v0.md,固定预变更版本 ffe84a693b464ef228596aef94722e9b6c35a7b8;已确认其规范文本与此前已读版本相同,新 checkpoint 不能反向认证自己。I2:复用选择器和原执行权威;I7:合法发现路径没有进程、网络或写文件激活;I9:测量限定环境和范围。V3:当前完整参数、输出、拒绝与纠正路径保持兼容。V1:只确认这个合法入口,完整双预设和语法拒绝最小加载仍 deferred。V10:暖路径、文件 IO、IPC、模型上下文与真实 Turn 完整成本仍 deferred;结构迁移不等于完整 M1/R1 合格。
关键代码讲解
_build_selected_parser:310调用同一 registrar,复用完整参数、全局/局部 format 及禁止缩写规则,没有第二份 grammar。_dispatch_common_command:417调用未改的 handler 和build_host_mode_plan,只生成 identity、readiness、错误或预览,后续执行权仍不属于选择器。_run_command:752保留_SelectedParseRejected到完整 parser 的失败路径;语义错误仍是原HostModePlanError,没有笼统捕获并吞掉异常。
独立28组输入覆盖五种意图、五种可见身份、缺失/模糊身份、重复与空值、未知语义、缩写/重叠非法参数、格式优先级和无关命令。当前 base/head 在普通及 outer-controller 条件下,完整 stdout、stderr、退出码均相同,未做文本归一化,调用方目录保持空。合法 help/preview 的隔离 oracle 在当前 base 退出97、head退出0,分别证明旧 eager 加载反例与修复敏感性。
对主干的风险 / Risks
最强风险是整合模块迁移后,合法预览成功但安装包的错误恢复或依赖定位失败。PASS:当前九个完整测试文件覆盖 CLI、host、M1布局、transport、configuration及架构,head229通过、当前 base218通过,均无失败/跳过;两处 Python Ruff、已提交双语检查、四文件公开边界扫描和原生 host smoke 通过。真实前端前置构建后独立制作 wheel,1410个 Python 成员与 head 一致;28组 source/wheel 完整输出相同,6个原生 console 调用及17个迁移后内部 Chat owner 的 audit 导入通过。包在源码目录外、无 Node 的环境运行,audit 拒绝进程、网络和写文件;没有实际启动宿主或付费模型。
上次 7d48a07096204b2a6bdecb623c6f36f2a29d5240 的独立运行仍是 head125通过/1失败、旧 base114通过/同一词汇断言失败,旧严格 CQR FAIL 继续保留。本次新 base 已包含三种 endpoint 的正向与未知值拒绝断言;当前 base/head 的该测试 AST 相同,实际重跑通过,不能把这个后续修正改写为旧结果通过。新的 exact-scope CQR PASS 仅对应当前 head。原生 premerge 当前直接/选中阻塞检查与严格收据通过;既有超大投影函数的维护性 advisory 仍失败,不冒称全树无债务。作者在 PR 中补充的 CI 失败说明仅作为已供应诊断;我未查询、轮询或等待 CI,也未以作者说明取代本地验证。
语义与 CI 对齐
复用原命令 token、parser、预览 schema 和 authority owner,不新增共享状态词汇或 substring/prose 分类。完整结果对照保留原权限、独立验证、回写和 no-spend 指令,不仅比较决策码。双语新增记录只说明17个内部 owner、128顶层模块的结构边界,并明确不等于性能或完整 M1 验收;相关源码/布局测试和安装包分别验证其当前含义。未借模块迁移重写门禁或放宽原准入义务。
我的整体评价 / Verdict
当前完整 head 未发现阻塞问题,APPROVE;交付判定 justified_increment。long_horizon 判定 preserved,不由更快帮助推断连续工作收益;user_experience 判定 improved,仅指相同任务的本地加载减少,零新增准备或确认回合。当前8组成对新进程交替测量、每端一次预热、关闭遥测/字节码写入,macOS arm64/Python3.14.8 下 help 中位475.6→83.6ms、preview515.1→91.6ms,模块1149→57。热缓存、共享机器负载和小样本都限制解释,不构成可移植 p95 或全成本门。原 parser/handler 复用已经应用;不可达的旧末端转发可随相邻 common-command 清理,完整 parser 的诊断兼容仍应保留。
仅检查 CLI 文本与 RFC 记录,cli_runtime 和既有 host-mode-plan 输出没有渲染页面改动;无需新增截图。真实 Windows、已安装桌面或宿主采用未验证。完整 V1/V10、实际采用、长期净收益及最终合并授权继续分别判定。
English verdict: APPROVE at cc2ac42c62ff29491631d3e73d55c8e6ca818e1b. Fresh native CLI, M1 integration and physical-wheel evidence supports the scoped loading improvement with complete output parity. Historical failures, advisory debt and unverified host/outcome costs remain separate.
Delivery brief
Goal/source: advance the accepted small-kernel RFC through its independently executable demand-loading seam. This is an R0-style discovery extension, not a claim that M1 or executable minimal is complete.
Gap:
host-mode-planis a read-only selector but entered the full CLI graph, loading Chat, benchmark and unrelated capability owners before producing a preview.Observable result / owner: register and dispatch this existing command through
cli_runtimeusingcli_commands.host_mode_plan. The selector, grammar, preview commands, readiness and authority owner are unchanged. Valid help/plans do not load the full CLI; rejected syntax deliberately retains full-parser diagnostics. No new module, capability, preset, shim, state or default is introduced.Current validation (head
cc2ac42c62ff29491631d3e73d55c8e6ca818e1b, baseffe84a693)test_cli_entrypoint,test_host_mode_planner,test_host_parity_smoke,test_chat_internal_module_layout,test_chat_transport_composition,test_chat_machine_configuration_api, and top-level/package/kernel import checks.7d48a0709on6a6a8590e: 163 passed, 1 failed in the CLI/host suite. The obsolete steward endpoint assertion failed on pristine base too. Current main corrected that test, and it now passes in the combined suite; the earlier failure is not relabeled as a pass.examples/host-mode-plan-smoke.py: passed.df5a52c15dae31bbd2b50ab10cbf557215bfc86e62a3439415de7f27495d2ab6.Replay focused semantics with:
Rebased measured loading boundary
Same interpreter, macOS arm64/Python 3.13.5, 20 fresh processes per revision/workload, one discarded warm-up, alternating base/head order, warm filesystem caches, telemetry disabled and empty disposable HOME/runtime/registry. Process wall time includes interpreter launch. These are local observations under shared-machine load, not portable CI budgets; bytecode generation was disabled consistently. Output bytes and SHA-256 matched in every pair.
These pairs compare base
ffe84a693with the current source, using the same harness as the initial measurement. Initial6a6a8590e/7d48a0709observations remain historical: help median 3632→119 ms; preview median 3586→128 ms. No earlier observation was replaced or reclassified.The diff narrows this dependency closure only. It does not reduce installed wheel size, top-level module count, model tokens, status/admission/settlement cost, or prove long-horizon outcome benefit. Full V10 warm-path/file-I/O/IPC/context qualification remains open; the proposed selected-help p95 target is not established by these measurements.
Scope / remaining gates
ffe84a693: 17 internal-only Chat owners moved; top-level count/budget are 128 rather than 145. The public-import compatibility frontier and wider M1 acceptance remain open. This PR is rebased onto that result; Add provider-aware capability and extension registry #2212 does not steer its work.CI reconciliation / remaining holds
kernel-static-checksfailed on two inherited F811 fixture annotations. fix(tests): mark injected Lark fixtures for lint #7991 is merged and fixes those two cases. The latest main has a different F811 attests/test_lark_private_conversations.py:817; the CI-equivalent lint run still fails there. That file is unchanged by this PR, and the remaining main-owned hold is disclosed, not bypassed.Worker status row is structured via flex), not a host-mode or timing error. That contract passes on current main after the rebase. The new CI run remains required; local wheel success does not turn the old failed run green.