Repository navigation
refactor(cli): load history reads on demand - #8212
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; model=gpt-6.1-sol; provider=OpenAI; runtime_reported; reasoning_effort=max.
当前 exact head 的代码结论:8212@eb6f3eb177ced2200344554e41fa32d86f5cbf67。
未发现阻塞本代码切片的 finding。
动机 / Motivation
受影响的是反复查询工作历史的 CLI 使用者;即使只看帮助,原入口也先加载完整命令树。
旧入口查询 history 帮助会加载 1,157 个 LoopX 模块;新入口复用原 history 命令,只加载 155 个,帮助输出与旧入口一致。
已验证普通查询、帮助、维护子命令与错误处理保持原输出和退出码,同时帮助启动的受控样本明显变快。
本 PR 不完成整个 R0 包拆分,也不证明跨平台安装、冷启动 p95、模型效果或长程完整成本收益。
完整 R0 性能资格、其他命令闭包与分发拆包仍由原路线图负责,本切片只交付 history 的按需加载。
召回的经验建议在这里用于核对第一个有用的用户结果和失败后的可用入口;没有继承历史case结论,也不把未来产品阶段变成当前切片的新门禁。材料送达不代表已验证记忆改善效果。
改动思路 / Approach
loader只负责选择加载;原handler继续拥有过滤、维护与错误规则,19行生产增量与收益相称。
只交付history按需加载,不完成整个R0拆包。
普通history/help进入selected parser,复用注册器与原handler;维护子命令、preloaded full CLI和解析拒绝继续走完整入口。原index、过滤、顺序、错误和写入owner都不移动。这个分支变化可用一张路径表表达,不需要额外图形服务。
| 分支 | 当前观察 |
|---|---|
| ordinary history/help | selected loading,原handler输出逐字不变。 |
| maintenance/parser/preloaded CLI | 完整CLI兼容与原拒绝路径保留。 |
具体改动 / Changes
完整差异 5 文件,+315/-0;行为实验共同基线 22b0f6c25a0450a66bd93f05954808dc0a5800ed,当前head eb6f3eb177ced2200344554e41fa32d86f5cbf67。19行生产代码改加载,181行入口测试与24行smoke保护原业务;51/40行双语ledger只记录该增量,不是独立验收依据。
接受的规范是 docs/architecture/rfcs/monorepo-distribution-split-v0.md,固定在修改前 revision 22b0f6c25a0450a66bd93f05954808dc0a5800ed;当前新增的规范/ledger内容不能自证实现已满足合同。
| criterion_id | 当前核验 |
|---|---|
| I2 | implemented:register_history_command/handle_history_command reuse and 207 tests |
| I3 | implemented:13 real-console paired cases, exact stdout/stderr/exit |
| I7 | implemented:155 vs1157 module observation and deliberate route removal |
| V1 | implemented:fresh subprocess module inventory |
| V3 | implemented:13 paired console cases and preloaded-handler tests |
| V10 | deferred:本次五对帮助启动样本只验证该入口,不能认证完整 R0、p95 或跨平台。 |
关键代码讲解
_build_selected_parser:使用已有register_history_command建立单命令parser。_dispatch_selected:保留Kunlun outer guard并调用已有history handler。_run_command:preloaded cli和维护子命令回full;普通history进入selected;解析拒绝回canonical错误。
本次独立运行207项相关测试全部通过,另13组成对真实console覆盖帮助、JSON/Markdown、Agent与UTC排序、零/负limit、未知Goal/Agent、复合拒绝precedence、parser错误、维护入口、空与倒序index;stdout、stderr、exit逐字相同,没有normalize。输入index和registry保持不变,原生backend进程已停止。
额外5组成对交错fresh-process history --help 样本:基线中位数约661ms,新head约139ms;这是单机warm-filesystem的小样本,不是p95或完整成本资格。基线加载1,157个LoopX模块,新head155个且不加载 loopx.cli;在独立进程仅移除history selected membership后,完整CLI/1,157模块重新出现,oracle能检出加载退化。
对主干的风险 / Risks
最强反例是优化只让help变快却改变查询过滤、拒绝优先级或维护owner。上述真实console同时固定25条foreign记录与limit,检查不同UTC偏移排序,负limit和复合错误;207项原生测试还覆盖Node缺失、原handler patchpoint与evidence窗口。没有新增授权开关或将domain判断塞入genericCore。
| 本次仓库原生检查 | 结果 |
|---|---|
| 原始17根 mypy、完整control-plane TypeScript 6.0.3 | PASS;Python3.14.8/Node24.21.0,隔离review worktree环境。 |
| 标准premerge机械项 | PASS:6 direct +15 selected,含DCO、双语RFC、diff与语义检查;整体premerge仍exit1。 |
| 全树Ruff | FAIL:B/H完整109个规范化path/code/location/message一致,31个失败source及配置blob不变;独立changed-invariant验证另列。没有把原失败改写成pass。 |
| 严格exact-scope质量回执 | FAIL已写入;verify为invalid_receipt,保留required Ruff失败。没有CQR pass或门禁豁免。 |
| 远端CI | UNVERIFIED/not_consulted;当前wait_for_ci=false,未查询、轮询或等待。 |
语义与 CI 对齐
history加载选择保持local-only词汇;公开参数、诊断、原外层guard与维护生命周期都复用现有owner。当前独立证据已覆盖本改动;policy26允许将已独立归因且未触及的required red检查与review verdict分开。严格CQR仍因required Ruff失败阻断资格,不能据此合并。
我的整体评价 / Verdict
long_horizon preserved:历史只读、scope/排序与原维护authority保持,重复查询减少无关加载;user_experience improved:仍用同一命令,一轮输入即可得到原结果,拒绝后的修正路径不变。最高价值的有界简化是共用现有registrar/handler,本PR已经采取;不需再建路由状态或复制业务实现。加载集合是本地命令分类,未扩展通用状态词汇。
检查的是 console CLI 与生成的宿主指令,没有修改页面、布局或 App 导航。 无受影响的图形界面;实际模型遵循与平台安装未验证。
本head review为APPROVE;没有阻塞本代码切片的finding。严格质量门仍FAIL,完整R0、wheel/平台、模型与完整成本资格没有完成;本结论不授予merge。
English verdict: APPROVE. Exact head eb6f3eb: history demand loading preserves all thirteen real-console comparisons and passes 207 relevant tests; quality/merge qualification remains held.
|
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 7f9e235cd80d73bf4f4f76ac18467bfa3c4b04b9.
Re-reviewed after integrating current main 2659e5f7.
historyremains a selected reader whileregistry,version, andheartbeat-prequotaretain their independent routes.- All parallel English/Chinese RFC checkpoints and evidence remain intact.
- Exact-head verification: the CLI entrypoint suite passes
264; the modularization smoke, changed-file Ruff, diff hygiene, and bilingual RFC verifier pass; the merge commit carries DCO.
Approval is limited to merge readiness at this exact head.
Goal And Delivered Outcome
Ordinary
historyhelp and Agent reads currently import the complete CLI and more than 1,150 LoopX modules. This proposal reuses the existing history registrar/handler throughcli_runtimeselected loading. The same registered Agent read falls from 1,603 to 417 ms median in the source checkout and from 1,648 to 414 ms in the installed monolithic wheel.main, baseline22b0f6c25a0450a66bd93f05954808dc0a5800ed.中文:普通 history 帮助与 Agent 读取按需复用既有 owner;源码/已安装 wheel 的注册读取中位耗时分别降低约 74%/75%。维护、parser 拒绝及预加载完整 CLI 保留原路径,双语 RFC 记录实测收益与限制。
Author Declaration
docs/architecture/rfcs/monorepo-distribution-split-v0.mdand its Chinese mirror at baseline22b0f6c25.loopx/cli_runtime.py::_build_selected_parser,_dispatch_selected,_run_commandcli_commands.historyregistrar/handler remain unchanged; maintenance and preloaded facade fallbackScope And Continuation
Validation
eb6f3eb177ced2200344554e41fa32d86f5cbf67. Final console/timing runs used identical source bytes before the evidence-only checkpoint commit.loopxconsole entry in source and newly installed monolithic wheel; reader, negative, fallback and facade pathsloopx.extensions.process_runtimeThe wider first local selection had 258 passes and three failures. Two newly added negative tests incorrectly allowed native service reuse; they were corrected to isolate all temporary-runtime variables and both reruns passed. The remaining source-denial failure reproduced on the untouched baseline. A separate import/budget selection had 33 passes and the Turn-preview failure, also reproduced on that baseline. These failures are retained and are not waived.
中文:最终真实 console 与兼容性矩阵通过。两项主线已有架构失败均在未修改基线上复现,保留为资格限制;完整 CI 尚待完成,帮助 p95 也未达到提出的目标。
On Apple M4 Pro / 48 GiB, macOS 27 arm64, Python 3.13.5 and Node 26.0.0, each workload has 30 interleaved baseline/candidate pairs with matched dependencies, source, fixtures and precompiled bytecode. Python processes are fresh; native-service reuse is warm. Final sampling took 229 seconds, and all three rounds total 698 seconds under the frozen 20-minute sampling bound. Setup, validation and tracing costs are separate.
Help loads 155 rather than 1,157 LoopX modules, registered reads 208 rather than 1,158, and evidence reads 210 rather than 1,159. Help has zero observed writes/process starts/connections. Cold registered reads preserve six write-opens, two process starts, one connection and 252/355 client IPC bytes sent/received; evidence reads preserve one write-open, two connections and 1377/804 IPC bytes. Output bytes match. Descendant CPU/RSS/I/O, full model cost and human attention cost remain unknown; module count alone is not an outcome claim.
Frontend / Visual Evidence
Type of Change
LoopX Area
Technical Direction
Shared-authority RFC fixture impact
N/A: no authority-store, routing or compatibility-projection change. Existing native ownership is retained.
Boundary Checklist