Repository navigation
refactor(cli): demand-load registry inspection commands - #8233
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
动机 / Motivation
维护者或自动化通过 registry 查看登记的 Goal,或者用 registry-boundary 判断文件能否安全纳入 Git。
此前这两个只读命令连帮助也会加载完整 CLI。现在有效请求只加载检查所需的解析和读取代码,错误请求仍走既有完整解析器。
源码和独立安装的 wheel 各 32 组对照通过。两个 help 入口的 LoopX 模块数从 1,158 降至 9,真实 Git 边界和拒绝诊断保留。
本片验收范围是两个既有 CLI 入口及显式完整解析器。实测使用 macOS 上的源码与单体 wheel,并在隔离目录中提供 Git 和合成 registry。
完整 R0/V10 清点、M1、真实受管 Turn、拆包安装、活跃宿主采用和完整成本继续由既有 RFC 验收。
改动思路 / Approach
在既有 selected dispatcher 中注册两个读命令,复用 registry owner。显式完整 CLI 也使用同一组参数及检查适配器,保留原检查函数和 renderer 注入点。 当前 PR 的边界是这两个现有检查命令的加载成本和相同结果。
沿用既有 selected route 就能减少每次检查的启动工作。操作者仍用原命令和原选项完成检查。保留完整解析器负责拒绝路径,也保留明确的回调入口。
具体改动 / Changes
两条 help 的模块数由 1,158 降至 9,registry 和 boundary 读取分别降至 148 和 44。真实 Git boundary 两版都执行 3 个 Git 查询。独立 audit 没有观察到写入、socket 或额外子进程。另做每条路径、每种分发 5 对交替进程计时,源码 registry help 中位数 606→50 ms,registry read 为 623→143 ms。作者的 30 对每路径大样本单独保留。此处计时只描述当前 macOS/Python 3.14.8 条件下的中位数,模块数和打开文件计数来自独立 audit。
预变更规格为 docs/architecture/rfcs/monorepo-distribution-split-v0.md,版本 ac62962255322cd80a5b701a4187c6f47bc17d8c。R0=implemented、V1=implemented、V3=implemented、I3=implemented、V10=implemented。中英文 RFC 增量记录相同边界和未验收项。#8011 的公开 Chat status 迁移使用不同生产路径。 预变更规格
关键代码讲解
- 两个入口现在共享原参数注册。完整参数名与默认值一致。 _register_registry_inspection_commands
- 原检查和 require 分支移至共享适配器。检查结果和 Git 退出码沿用原条件。 _handle_registry_inspection_command
- 有效检查在原 guard 和 registry route 解析后才导入所需模块。只调用所选命令及其依赖。 _dispatch_selected
- 完整 CLI 转发原检查函数及 renderer 回调。保留支持层已有的检查和输出注入点。 handle_support_control_command
对主干的风险 / Risks
独立构建两版单体 wheel,从仓库外调用各自安装的控制台。源码与 wheel 各对照 32 个输入,涵盖省略和显式 registry、空 path、损坏文件、真实 Git 以及缺少 Node。原解析错误逐字一致。异常比较保留类型和消息,调用栈随实现位置变动。对同一文件撤去 Git 后,require 拒绝。恢复 Git 后重试成功。另在一次性 repo 只新增目标 ignore,再次执行原命令也成功,registry 和索引未改。
当前源码 197 项测试通过,基线 169 项。两个版本绑定到隔离 registry 后均通过真实 Git smoke。首次无绑定 smoke 遇到既有默认路由冲突,首次 wheel 构建缺少生成的 dashboard bundle。原失败保留,并以显式隔离路径和正常前端构建复验。配置的 17 项 Mypy、bilingual RFC、6 个直接和 4 个选择检查均通过。
必检 Ruff 在两个不可变版本中都报同一个 F841,位置为未改动的 tests/control_plane/test_goal_create_completion.py:184。独立对照覆盖了本 PR 改动的入口。严格质量回执 cqr_1307f444ef9e1fc6f9af 仍为失败,合并门保留。
语义与 CI 对齐
两条有效读取走同一 registry owner。原 require 分支、现有授权语义、完整解析器和显式支持层回调仍生效。基线与当前头的加载对照使用同一真实入口,未知参数在两版都走完整解析器。审查未查询或触发 CI。
我的整体评价 / Verdict
没有阻塞性代码发现。两条只读 CLI 的加载减少及结果兼容经独立验证,支持当前头的源码切片。 当前头 d54cdef3a3a7042225417f4e23f8c618fa1f19ca。
在既有 selected dispatcher 中注册两个读命令,复用 registry owner。显式完整 CLI 也使用同一组参数及检查适配器,保留原检查函数和 renderer 注入点。 当前 PR 的边界是这两个现有检查命令的加载成本和相同结果。 检查了两个现有 CLI 的 help、Markdown、JSON 和拒绝输出,内容保持一致,改动没有涉及渲染页面,视觉审阅不适用。 独立证据覆盖 macOS 的源码和单体 wheel。Windows、实际宿主升级、拆包部署、完整 CI 和长期运行成本未验证。
English verdict: APPROVE — The two read-only routes preserve CLI semantics while reducing the import closure. The unchanged required Ruff failure keeps strict merge qualification on hold.
|
This pull request has merge conflicts with Choose the remote for the base repository, not an out-of-date fork. git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEADFor a same-repository clone whose Keep the DCO |
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
APPROVE — exact head 93998797cd2fc04fc91bf3b196bd8c71e141c71e.
Re-reviewed after integrating current main b9faf8da.
- The only conflicts were independent English/Chinese RFC checkpoint insertions; both records are preserved.
- The CLI implementation and tests are unchanged from the previously approved exact code revision.
- Exact-head verification: the three CLI/support ownership suites pass
197 passed; changed-file Ruff and diff checks pass; the merge commit carries DCO.
This approval is limited to merge readiness at the exact head above.
Goal And Delivered Outcome
registry --helpandregistry-boundary --helpcurrently load the full CLI and 1,158 LoopX modules. This proposal selects their existing registry inspection grammar and handler directly, reducing help to 9 modules while preserving successful/rejected request semantics. It also shares the grammar and inspection transport adapter with the full CLI, retaining the existing support-control inspection and renderer patch points.ac62962255322cd80a5b701a4187c6f47bc17d8c; unrelated execution owners are loaded by two read-only inspection callers.loopx-project/loopx:main; baselineac62962255322cd80a5b701a4187c6f47bc17d8c. Related M1 public-status proposal: refactor(chat): move public status owner with identity-compatible imports #8011; this change does not depend on its merge.Author Declaration
loopx/cli_runtime.pyloopx/cli_commands/support_control.pyand existing registry ownerScope And Continuation
Validation
d54cdef3a3a7042225417f4e23f8c618fa1f19ca. Source/wheel measurements use its unchanged production files; final RFC-only edits do not change them.uv run --extra test python -m pytest -q tests/test_cli_entrypoint.py tests/test_support_control_update_ownership.py tests/test_support_control_promotion_ownership.py --no-cov: 197 pass. New inspection cases: 26 pass, plus two help cases. Original CLI baseline: 152 pass before edits.uv run --extra test python examples/project/registry-boundary-contract-smoke.pyon base/head with disposable temporary Git repositories;examples/cli-support-control-command-modularization-smoke.pypasses. Registry files and fixtures remain unchanged.npm ci --ignore-scriptsrepairs that environment gap. An archived baseline scan lacked an independent Git index and produced stale classification diagnostics; the corrected detached baseline and candidate scans pass with matched locked dependencies. Initial failed probes are retained separately.tests/control_plane/test_goal_create_completion.py:184; separate fixes #8210/#8174 already exist. Base/head diagnostics match. Broaderruff check loopx testsalso has the same five diagnostics on both revisions.6 direct checks, 0 direct failures; 4 selected checks, 0 failures. Failures/advisories are disclosed below.The relevant suite preserves normal and rejected paths, full-parser fallback, support ownership, Git guard precedence and read-only fixture state. Registry authority/provider semantics and shared persisted state are unchanged; this slice does not need a PostgreSQL authority migration rehearsal. Incremental coverage generation returned no applicable threshold; the existing full-suite CI coverage gate is unqualified after upstream lint failure and skipped shards.
Cost measurements compare immutable base with the unchanged candidate on macOS arm64/Python 3.13.5, identical dependency versions/fixtures, precompiled bytecode, warmed filesystem caches and a fresh interpreter per sample. AB/BA alternates and workload/distribution order rotates.
/usr/bin/time -lwraps the actual console; parent monotonic wall timing is uninstrumented. Audit/loading probes are separate from timing samples. There are 480 samples; sampling took 416.7s within the frozen 1,200s limit. Measurement setup/compatibility/profiling took 278.1s; environment and wheel preparation and earlier tests are separate costs. The 197-case source suite took 236.49s and the original 152-case characterization took 197.28s. Full preparation, agent/model and human-attention costs are unmeasured.Separate audit probes observe no Node starts/IPC or socket events. Boundary reads retain the same three Git subprocess queries; other workloads start none. Time reports zero block-input/block-output operations with warm filesystem caches. Audit open counts and summed opened-file sizes describe loading footprint, not exact bytes consumed; native subprocess/socket activity outside Python audit and exact logical read bytes remain unknown. Output byte counts and hashes match across revisions. These are local CLI cost reductions, not portable D6 thresholds or whole-kernel/long-horizon/adoption gains.
Frontend / Visual Evidence
Type of Change / LoopX Area
Shared-authority RFC fixture impact
N/A: no shared authority, provider or TypeScript decision semantics change.
Boundary Checklist
Signed-off-bytrailer included.