Skip to content

perf(cli): load the existing version owner on demand - #8203

Open
cocolord wants to merge 5 commits into
mainfrom
codex/small-kernel-json-version-20261106
Open

cocolord wants to merge 5 commits into
mainfrom
codex/small-kernel-json-version-20261106

Conversation

@cocolord

@cocolord cocolord commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

loopx --format json version loads the full CLI and command-export graph before returning four version fields. This proposal selects the existing version registrar/handler through cli_runtime, reusing the canonical global grammar, format precedence, usage hooks and controller guard. Invalid parsing retains full-CLI fallback and diagnostics. Explicitly bound cli_commands or full-CLI exports retain their registrar/handler patch points. Public imports, function identity and types remain compatible; no capability/provider, framework, default authority or TypeScript decision owner is added.

This is an independently reviewable R0 slice of the accepted small-kernel RFC. #8185 remains the separate DSH/helper proposal; #8011 remains the public-status proposal. Neither merge is a prerequisite for this version-query change.

At immutable baseline 5a58635028fbef1316dc66531daf5fdb655e9b13 and corrected runtime proposal 8a79d8602e699e51452ca1f43dc9b9527c81aa1b, source and freshly installed monolithic wheels each complete 30 interleaved pairs. The 120 accepted observations take 62.246 seconds; including the retained initial study, aggregate sampling is 166.191 seconds, within the unchanged 1,200-second cap. Both revisions share CPython 3.13.5, macOS arm64, identical 57 dependency versions and verified source/wheel provenance. Stdlib, dependencies and all 1,421 LoopX sources have prepared valid timestamp bytecode in owned prefixes; post-run inventories match. Every sample has fresh Python and disables bytecode writes. Disk cache is uncontrolled; no cold-disk or warm-broker qualification is claimed. Host one-minute load is 8.25–9.06.

Distribution Baseline median / p95 seconds Proposal median / p95 seconds Median CPU seconds, base → proposal Median RSS MiB, base → proposal
Source 0.980 / 1.056 0.055 / 0.075 0.520 → 0.037 90.17 → 16.81
Monolithic wheel 0.948 / 1.147 0.056 / 0.077 0.511 → 0.038 89.89 → 16.60

The observed median query latency falls about 94% in both distributions. The bilingual E9 checkpoint records paired deltas separately from differences of medians. Independent instrumentation confirms 1,157 → 10 LoopX modules, with no new module, source read-opens 1,286 → 28 and wheel 1,289 → 29. Stdout stays 81 bytes; captures have no write-opens, subprocesses, local socket connections or covered socket bytes. Existing performance-diagnosis recipes inspect four parent captures separately from timing; baseline observations include export loading/full parser construction. Stack weights are not latency or a causal proof. Full native/authoring/model/maintenance costs remain unknown; these results qualify the selected query under frozen conditions, without portable D6 budgets or managed-Turn/long-horizon benefit claims.

Compatibility and regression sensitivity:

  • Actual source/wheel console comparison covers 27 cases per distribution with identical stdout, stderr and exit codes: global/local/repeated formats, explicit paths, help, unknown/abbreviated options, missing/empty values and fallback. Independent invalid-command/option oracles reject with exit 2 and no result. Version works without Node in all four variants; outer-controller read behavior matches.
  • Seven selected-loading cases fail at the baseline and pass after the change. Full-CLI patch points and diagnostics pass in both. A later independent package-export fixture exposes a real initial regression: baseline returns the patched handler's 37, while 55e3ef45a returns 0. The correction preserves both package registrar and handler adoption and passes this fixture in source/wheel. The initial 120 query observations, failed fixture and frozen inputs remain retained; they never certify facade compatibility or become the corrected comparison.
  • The complete entrypoint suite passes 161 cases; focused lint passes. Owner-scoped mypy with --follow-imports=skip fails with 33 identical diagnostics at baseline/proposal after line normalization. Full configured typing remains untested; the failed scope is not waived.
  • Initial premerge lacks repository TypeScript dev dependencies and fails the semantic inventory. After the documented root npm ci --ignore-scripts, that candidate premerge passes. The exact final integrated head still receives its own premerge and console readback; those results are recorded below. A passing premerge did not detect the package-facade regression, so independent caller qualification remains necessary.

Final integrated head 41cfb7e94a29c745911bf9116197d3684097816f merges target main at 3a0c9608cc068cebcdeadf45217be8b5e4196341. This later Chat-runtime integration is outside the immutable timing study. At this head, the source-checkout premerge passes six direct checks, two catalog canaries, eight risk smokes and the public-boundary check, with zero failures/manual holds. Goal change-quality policy is disabled; no receipt enforcement is claimed. The separately rebuilt and freshly installed final wheel and source each match the original 27-case console corpus, adopt package registrar/handler patches, preserve selected loading and work without Node. Focused Ruff, the committed bilingual diff gate, version modularization smoke and diff-scoped semantic advisory pass; the advisory finds no supported new vocabulary carrier and does not certify all dynamic semantics. The final complete entrypoint suite passes 161 tests in 179.90 seconds. Initial remote readback confirms normal OPEN PR #8203, unchanged head/base and six checks in progress (DCO, dependency review, Frontstage build, Python changes, release build and Mergify). No current failure is observed in that initial snapshot; CI is not declared green and no gate is waived. Independent review, complete required CI and merge readiness remain separate adoption gates; no runtime self-merge or installed-host upgrade is performed.

Remote CI hold at this unchanged head: kernel-static-checks fails Ruff F841 at tests/control_plane/test_goal_create_completion.py:184:9 because result is unused. The file blob c03bb2060036cac787751313014d8ec98c2b2666 is identical at target 3a0c9608c and this head; the same complete CI Ruff scope reproduces exactly one error locally. Focused version lint remains passing. This is an unchanged target-file failure and still holds merge. Stage2C aggregate fails on STAGE2C_RESULT=skipped; its suite did not execute. The pytest aggregate reports CHECKS_RESULT=failure and SHARDS_RESULT=skipped. No missing-test cause is inferred for this run, no skipped lane is counted as passing and no CI gate is waived. DCO/dependency review pass; remaining build checks were still running at readback. Independent review, full required CI and maintainer merge remain necessary.

中文 CI 限制:远端静态检查在未改变的 tests/control_plane/test_goal_create_completion.py:184:9 报 Ruff F841;目标主线与候选该文件 blob 相同,本地完整 CI lint scope 同样只有这一错误。Stage2C 与 pytest 汇总因上游失败/跳过而失败,实际测试 lane 未运行;本次不推断缺失测试文件原因,不将跳过算通过。DCO/依赖审查通过,其他构建在回读时仍运行;合并仍需解决 CI、独立评审与维护者授权。
The bounded refactoring pass is applied within one existing Python dispatcher, with its existing registrar/handler and full-facade fallback. Raw harnesses, profiles, journals, caches, logs and generated lockfiles remain excluded. I3's minimum one minor release remains in force; no D3/expiry decision is made. Wider R0/V10, R1/minimal, D2/D5/D6, hard-lease/context/model and split installation remain open.

中文:loopx --format json version 原先在返回版本字段前加载完整 CLI/export 图。本提案在既有 cli_runtime 选择原 version parser/handler,保留规范全局参数、format 优先级、usage/controller guard、错误 fallback,以及已绑定 package/完整 CLI 的 registrar/handler patch 点。源码和新安装单体 wheel 各完成 30 对匹配依赖/字节码对照,修正后 120 个观察采样 62.246 秒;计入首轮合计 166.191 秒,未超过原 20 分钟上限。源码中位数/p95 为 0.980/1.056 → 0.055/0.075 秒,wheel 0.948/1.147 → 0.056/0.077 秒,中位延迟均约下降 94%,CPU/RSS 同步下降,模块 1,157 → 10。27 项 console corpus、独立错误参数、缺少 Node 和控制器读路径一致。初始候选忽略 package handler patch,基线 37/候选 0 的失败已保留并修复;修正后的 registrar/handler 在源码/wheel 均验证,原数据未重解释。完整入口 161 项和聚焦 lint 通过,mypy 保留基线/候选相同 33 项错误。最终 head 的 premerge、主线集成及远端 CI 单独记录;独立评审和采纳仍必要。收益范围为版本查询,完整小内核、真实 Turn、D2/D5/D6、I3/D3、上下文/模型及拆包安装验收仍开放,无新 owner/default、宿主升级或 runtime self-merge。

cocolord and others added 5 commits November 7, 2026 01:03
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>
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>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>

@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.1-sol · OpenAI · runtime_reported · reasoning_effort=max

动机 / Motivation

脚本和 CLI 使用者查询已安装版本时,只需要版本字段,却原先会加载完整命令和导出图。同样执行 loopx --format json version,旧路径加载 1,157 个 LoopX 模块,新路径加载 10 个,返回的四个字段、标准输出和退出码保持相同。27 组真实控制台输入在基线和 head 的 stdout、stderr、退出码完全一致;缺少 Node 时仍能查询,公开 package patch 点也继续生效。本片仅交付版本查询的加载边界,不交付完整小内核、minimal、拆包安装、宿主升级或受管任务的长程收益,也不授予合并。

改动思路 / Approach

直接复用既有 parser、version registrar/handler 和完整 CLI fallback,消除了普通查询的额外加载;一个已有 dispatcher 的小分支足以解决问题,无需复制语法或新增 owner。当前 PR 边界是 version 路由、原公开导出和错误 fallback;其余命令及更大的运行时拆分保持原 owner。普通调用沿已有 selected parser 进入原 version handler;解析拒绝时回到完整 CLI 产生原诊断。显式加载完整 CLI,或绑定 package 的 registrar/handler 时,继续走原完整 facade,以保留调用方的 patch 点。只检查已绑定的模块属性,不触发 lazy facade 本身。这比继续加载全部命令更符合短查询需求,也比维护第二套版本解析和输出实现更简单。

具体改动 / Changes

规范依据为 docs/architecture/rfcs/monorepo-distribution-split-v0.md,判定 revision 为 3a0c9608cc068cebcdeadf45217be8b5e4196341。I2:没有增加工作或效果权威;I3:保留公开 imports、函数身份及显式 patch 点;I7、V1:普通版本查询只加载所选闭包;V3:同输入的格式、诊断和退出码保持。I9:新增双语 E9 区分初始 facade 失败、修正后的测量及未取得资格的完整 Turn/minimal;我独立验证当前加载与兼容性,没有重做作者的 30 对时延实验。

关键代码讲解

  • _build_selected_parser 调用原 register_version_command,继续使用唯一全局语法和 add_subcommand_format。没有复制版本字段或改变全局/局部 format 的优先级。
  • _dispatch_selected 先走原 usage/format/controller guard,再调用原 handle_version_command。只读版本查询不需要启动 Effect runtime,缺少 Node 的真实 console 用例仍成功。
  • _run_command 从 sys.modules 和已绑定的 package 属性判断是否保留完整 facade。基线和 head 都调用我替换的 package registrar/handler 并返回 37;刻意绕开这段兼容分支后返回 0,独立 oracle 以 exit 9 拒绝,证明该反例能发现 facade 回归。

完整四文件 diff 中,生产代码为既有 dispatcher 的 +22/-2,测试 +77/-5,另有双语非规范性 ledger。测试覆盖 selected loading、合法/非法参数、help 和完整/package facade;没有加入新模块、持久化字段、命令语法或自动加载的 Agent 指令。

对主干的风险 / Risks

未发现阻断项。 最重要的风险是短路完整 parser 时丢掉既有格式、诊断或公开 patch 行为。本次独立执行 27 组实际 console 对照,逐字比较 stdout/stderr 和退出码,包含空值、缺值、重复/局部 format、未知/缩写选项、合法 -- 分隔、显式路径、缺少 Node 和 outer-controller 只读场景。两端完全一致,package patch 的正常和 mutation 对照亦通过。161 个完整 entrypoint 测试通过。

原配置 mypy 的 17 个入口在不可变基线和精确 head 都通过,changed-file Ruff、双语 gate、diff 检查通过,5 个提交均有 DCO trailer。strict CQR 有效,premerge 六个直接检查及十一个选择检查全部通过,无 manual hold。按当前策略未查询、轮询或等待远端 CI;作者正文报告的 F841 和依赖 lane 失败保留为其快照,未将其算通过,也没有以当前本地结果豁免远端门。原始 owner-scoped mypy 的历史失败仍是历史结果,不由本次完整配置通过改写。

语义与 CI 对齐

仅把既有 version 名字加入本地 loading selector;它是已有 CLI 词汇,未新增共享状态或义务。默认输出、权限、provider、调度/扣额和其他命令的 authority owner 不变;没有 default-off 功能被隐式激活。必要兼容保留在原 facade,进一步整体迁移应按规范单独资格化。

我的整体评价 / Verdict

APPROVE。 当前精确 head 完成了可独立审查和回滚的版本查询加载片段;真实控制台对照支持兼容结论,加载闭包减少是本次直接观察。长程工作和用户交互的既有语义保持,没有新增确认或操作步骤;未测量模型收益、完整运行成本或可移植时延预算。完整 R0/V10、R1、D2/D5/D6、模型与 hard-lease 资格继续保留;本次不把作者的 94% 时延观察扩大为这些结果。直接复用既有 parser、version registrar/handler 和完整 CLI fallback,消除了普通查询的额外加载;一个已有 dispatcher 的小分支足以解决问题,无需复制语法或新增 owner。当前 PR 边界是 version 路由、原公开导出和错误 fallback;其余命令及更大的运行时拆分保持原 owner。没有修改渲染页面;检查的展示面是 CLI stdout/stderr、help 和 RFC 非规范性证据记录,无需新增截图。未验证任何新 UI、Windows 或已安装宿主升级;本 PR 没有宣称交付这些展示面。审批结论不等于 CI/merge readiness 或维护者合并授权。

English verdict: APPROVE, head 41cfb7e. All 27 paired console cases, facade mutation controls, 161 entrypoint tests, configured mypy and local premerge pass; the selected version path loads 10 rather than 1157 LoopX modules. CI and merge authority remain separate.

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