Repository navigation
perf(cli): keep capability discovery out of the full CLI and Chat graph - #8012
Conversation
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
未发现本 PR 引入的阻塞性代码问题。技术结论为 APPROVE;既有类型检查和额外全树 lint 失败仍使本轮 CQR 保持失败,不能据此合并。
动机 / Motivation
需要先发现 LoopX 能力及其权限边界,再决定是否使用的 CLI 用户与自动化调用者。
同样运行 capability list、show 或帮助,旧路径先加载完整 CLI 与 Chat 图;新路径直接复用能力目录注册器,输出和拒绝诊断保持一致,减少每次发现能力的启动等待。
独立的真实命令、隔离 wheel、默认关闭及错误回退验证支持这个有限的发现入口提速;不代表完整分包或实际任务效率已验收。
本 PR 不完成 Python core 隔离、独立物理分包、现有 Host 升级或模型任务收益验证,也不改变 capability inspect、bind、invoke 的授权。
剩余边界:完整 R0/M1/M3 与独立分发、实际 Host 采用及长期任务收益仍未验收。
改动思路 / Approach
发现入口只改变加载路线:list/show/help → 原有注册器/目录处理器;inspect/bind/invoke → 完整 CLI;解析或目录拒绝 → 完整解析器生成原有错误。这是根据源码梳理的路径说明,不是额外运行证据。共享语法与处理器避免了第二套参数、权限或配置真相。
加载选择放在现有 CLI transport;语法、目录、绑定与执行权限继续由原有 owner 决定,保留完整解析器回退有实测兼容理由。
本次只交付 capability 的 list/show/help 发现路径,受保护操作继续走完整 CLI;完整分包与运行时隔离属于原有后续验收。
仓库投递的既有经验只用于检验实际调用任务、最短合法路径和可回读结果;本次按当前代码采纳这些检查,不继承旧案例结论,也不将内部维护强制扩大成整套新前端。经验被投递或写入评审不等于实际采用、任务收益或长期效果。
具体改动 / Changes
四个文件为 CLI +29/-5、测试 +136、英文/中文 RFC ledger +34/+26。检查了 _build_selected_parser、_dispatch_selected、_run_command 及未改动的 register_capability_commands/handle_capability_command、extension state 和完整 CLI。新 frozenset 只按完整子命令名选择加载,不从散文或子串推断状态。外部 manifest、默认关闭、注册/已安装/启用/ready 的区别仍由原 owner 表达。
验收依据为 docs/architecture/rfcs/monorepo-distribution-split-v0.md,固定 revision 79b7818,检查的 head 为 58442be;不以本次 ledger 或作者声明倒改原有验收要求。
- I2:保留一个 kernel/decision owner。 已按上述当前 head 验证。
- I3:保留旧的公共导入兼容路径。 已按上述当前 head 验证。
- I4:关闭或不可用时保留原有安全结果。 已按上述当前 head 验证。
- I5:无 Node 时允许轻入口;需要 Node 的路径返回原有失败而不隐式激活。 已按上述当前 head 验证。
- I7:按选择加载,不能因发现而激活未选择的扩展或启动外部副作用。 已按上述当前 head 验证。
- I8:required context/authority 不被加载优化省略。 已按上述当前 head 验证。
- I9:开销测量限定于具体工作负载,不从帮助提速推出任务收益。 已按上述当前 head 验证。
- V1:发现/帮助入口需求加载。 已按上述当前 head 验证。
- V3:CLI 参数、默认值、诊断与退出保持兼容。 已按上述当前 head 验证。
- V10:用相同范围衡量实际固定开销。 已按上述当前 head 验证。
- M3:物理分包和发布前组合验收。 Accepted demand-loading section and partial ledger do not treat a command dispatcher increment as completed physical package split.
PASS:169 项相关测试;12 组独立 base/head console 参数/拒绝对照,完整 stdout、stderr、退出码一致;3 个旧基线 import oracle 失败在新 head 全部通过;隔离 wheel 真实安装后,Node 不可用时 6 组 entrypoint/完整解析器对照通过;原生 premerge 为 6 direct + 11 selected 通过;CI 配置范围 Ruff 通过。
开销单独测量:同一 Mac、Python 3.14.8、warm filesystem、Node 不可用、禁止 bytecode 写入,三个操作各 8 轮交替且无并行测试负载。list 中位 .395→.170 秒,show .390→.162 秒,help .395→.162 秒。另用隔离 Pyinstrument 5.1.3 采样并原生 inspect,两个目标退出 0、profile 非空:旧路径包含完整 CLI/parser/Chat,新路径仍有 catalog 的部分 core 导入。profile 时间不充当基线或 p95,也不能推出完整分包与任务收益。
FAIL 保留:原始 configured mypy 在同一基线/head 都是 789 errors/126 files,完整诊断逐字相同且不落在本 PR 两个改动的 Python 文件;额外全树 Ruff 同为 122 errors/35 unchanged paths。后者不同于已通过的 CI lint 根目录命令。本轮 CQR 如实写入失败并保持 held,不豁免 required 检查。初次 wheel 构建拒绝旧 Chat bundle,按仓库正常 build:chat 重建后才打包;初始对照因不同 -m 名称导致 usage 的 prog/换行差异,改用相同 argv[0] 后比较,未归一化产品值。作者较大测试集合的历史失败仍仅是提供的诊断,不宣称已修复。
对主干的风险 / Risks
最强反例是目录输出虽正确却激活 provider、绕过受保护入口或丢失错误细节;本次用真实参数拒绝、module import、文件/进程/网络 audit 和完整解析器对照分别覆盖。保护调用继续使用原 handler。未观察到新增持久状态、quota/scheduler 改动或隐藏默认启用。完整 catalog 仍依赖部分 core 图,本次没有声称完全隔离。
Existing required mypy and broader Ruff failures keep CQR held; no full parent split, Host adoption or task-cost claim.
不因公开 review 或本地 receipt 授予 merge、provider 执行、真实 Host 采用或父级目标验收。远端 CI 按当前评审策略未查询、未轮询、未等待;所有通过、失败、跳过和未验证范围分别保留。
我的整体评价 / Verdict
这是有独立用户收益、可回滚的 demand-loading 增量,设计复用了原 owner,未发现由本 PR 引入的阻塞性代码问题。APPROVE 与现有 required static/CQR 集成限制分开;合并资格仍需如实保持 held。
加载选择放在现有 CLI transport;语法、目录、绑定与执行权限继续由原有 owner 决定,保留完整解析器回退有实测兼容理由。
本次只交付 capability 的 list/show/help 发现路径,受保护操作继续走完整 CLI;完整分包与运行时隔离属于原有后续验收。
仅改变 loopx/cli_runtime.py 加载路径;同命令文本输出保持一致,没有网页、布局、样式或首屏改动。
No visual surface changed; no screenshot or rendered UI acceptance is claimed.
English verdict: APPROVE at 58442be. No introduced blocking code finding; discovery and compatibility checks pass. Existing identical baseline static failures keep CQR and integration on hold; no merge authorization.
Delivery brief
Goal/source: advance the accepted small-kernel composition RFC with an independently usable demand-loading slice, not another directory-only move.
Gap: metadata-only
capability list/showrequests loaded the full CLI and Chat graph.Result: valid catalog discovery and help now reuse the existing capability registrar/handler without that unselected graph. Output, extension readiness/default-off semantics and protected execution remain unchanged. This is a scoped loading proposal, not completed M1, split packaging or an executable minimal preset.
Tested head:
58442be4dc9c6c5217c80c2a4b34b63eaee069a1. PR base:main, verified baseline79b7818653bc4105ea27a8946de04a9ba997ff03.Ownership and compatibility
list/showuse selected execution.inspect/bind/invokecontinue through the original full CLI, including its handler patch point and existing permission/Goal/Turn checks._CAPABILITY_DISCOVERY_COMMANDSis local boot-selection data using already registered command names, not an operation-authority rule. Python stays the existing bootstrap/transport adapter; no TypeScript authority owner is duplicated.Decisive qualification
PYTHONPATH/LOOPX_RELEASE_ROOT. Four additional installed-console requests validate list/show/help and unknown-id refusal. Interpreter/package provenance was checked. The installed harness and wheel's changed code are byte-identical to the committed head. Existing Chat assets were built as a packaging prerequisite; no existing host was upgraded.test_settlement_plan_import_does_not_load_native_capture_iofails identically on the immutable base and candidate. This is retained as a failure, not skipped or weakened.Measured source-path overhead
Replayable checks
Run from the intended clean checkout with its test environment prepared:
For baseline sensitivity, copy only the head's
tests/test_cli_entrypoint.pyinto a separate test-only checkout of79b781865; leave product code unchanged. The same harness has 18 semantic passes and five expected loading-oracle failures there, versus 23 passes at the head. The latter two commands retain identical failures on both product revisions. This does not authorize editing another worktree or relaxing an oracle.Paired measurements
macOS arm64 / Python 3.13.5; Node absent and telemetry off. Each workload uses 20 fresh processes per revision, alternating order and one discarded warm-up. Both matched source snapshots have warm filesystem caches and no bytecode. The real
entrypoint.main()path is invoked; interpreter startup and equal audit/RSS instrumentation are included. Builds and regression tests did not overlap these samples.capability list --helpcapability list --format jsoncapability show performance-diagnosis --format jsonAll three paths load 362 rather than 1,149 LoopX modules, with 832 rather than 2,494 read-open observations. Output bytes are identical; observed file writes, subprocesses, network connections and thread starts are zero. These instrumented source measurements are not portable D6 thresholds, installed-host latency guarantees, model-token savings or managed-task/long-horizon benefit. Installation size and dependencies are unchanged.
Holds and remaining boundary
Author implementation/integration is complete; this is a normal review proposal. The inherited import-oracle/type-check failures remain explicit validation holds. Root development-tooling
npm ci --ignore-scriptsreports four moderate advisories with an unchanged lockfile; no automatic dependency fix was applied. Remote CI, independent exact-head review, merge readiness and maintainer merge remain separate gates. No self-merge, CI bypass, timeout increase, scoring change or installed-host rollout is performed.This extends R0-style V1/V3 discovery evidence only. Full R0/V10, wider M1, I3/D3, split-installation and R1 managed minimal remain open; #8011's separate status-owner proposal and its holds are not absorbed. Frontend operations/rendering and HTTP routes are unchanged; this adds no caller-facing capability requiring a new product screen. Other platforms and PostgreSQL were not exercised; no authority-store implementation changes. Both RFC mirrors record the delivered delta, measured boundary and failures. Only the four source/test/RFC paths are included; generated assets, dependencies, local measurements/logs and
uv.lockare excluded.