Repository navigation
refactor(cli): demand-load heartbeat prequota transport - #8240
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
定时运行 LoopX heartbeat 的维护者会在配额判断前调用 heartbeat-prequota,检查已确认的评审和 PR 依赖。
之前,即使只看帮助或在未配置 PR 观察的项目运行,入口也会加载完整 CLI 和 Chat。现在这条入口按需加载。
独立复测中,帮助加载的 LoopX 模块从 1,158 降到 29,未配置观察的执行从 1,160 降到 273。11 组命令对照的输出和退出码一致。
本轮只验证这一条入口的加载与兼容性。拆包、实际安装采用和完整任务成本仍有各自的验收。
wheel 耗时和 RSS 来自作者配对测量,本轮独立复核覆盖源码入口。实际安装、完整成本与其余 R0/V10 仍待验证。
改动思路 / Approach
解析沿用原 registrar,两个入口复用同一 transport,回执对账和权限判断继续由既有 runner 和 hook 负责。 当前改动覆盖一条既有 heartbeat-prequota CLI 路径及其测试和 RFC 记录。
显式 registry、旧的隐式全局 resolver 和原 parser 回退仍可用。独立对照覆盖了工作目录与环境变量冲突、显式坏 registry 和错误参数。实际 File/SQLite 测试覆盖已合并、观察超时和重放。 选择入口 共享 transport
具体改动 / Changes
8 个文件共 +373/-43,其中三个生产文件 +62/-18。完整 CLI 的 runner、renderer 和 resolver 替换点保留,仍由原 runner 对账。适用规范为基线 I2/I6/I7 与 R0/V1/V3。Full R0/V10, M1/R1 仍按现有 RFC 和 #8011 验收。 原 runner 基线规范
实际源码 console 的 11 组对照保持输出和退出码。两版均通过隔离的 File/SQLite 对账 smoke。当前 219 项通过,基线 167 项通过和两项旧 fixture 失败。新 fixture 从同一次准入的 digest-bound capture 读回,两个旧失败消失。配置内超时仍返回降级和继续,重放保留原 Todo 且零扣费。 入口和存储测试 原捕获读取
对主干的风险 / Risks
quick premerge 6 项直接检查和 4 项选中检查通过,改动文件 Ruff 和配置内 Mypy 通过。全量必检 Ruff 在不可变基线与当前头出现完全相同的 F841,严格质量回执仍失败。此项保留为合并资格限制。 未改动的失败位置
本次使用合成 provider 输入和真实本地存储。未查询托管 CI,实际安装采用、外部调用及完整任务成本待验证。视觉审阅不适用,变化集中在 CLI,已比较实际输出和退出码。
我的整体评价 / Verdict
同意准确头 4df990c。所减少的是重复启动时的依赖加载,实际授权、路由、继续与失败行为保持一致。当前全量必检 Ruff 和严格质量回执仍约束合并。继续沿现有 RFC 验证安装后的采用与完整成本。
English verdict: APPROVE. The selected prequota route reduces imports and preserves CLI routing, failure handling, reconciliation and zero quota debit. The independently reproduced baseline Ruff failure remains a merge-readiness 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 2061c00678d454c5e46c0bd66f88fd7f92ff86ad.
Re-reviewed after integrating current main 1175fc0f.
- The only conflicts were independent English/Chinese RFC checkpoint insertions for heartbeat-prequota and registry inspection; both full records are preserved.
- Runtime code remains the previously approved heartbeat-prequota selected-loading implementation.
- Exact-head verification: CLI entrypoint plus heartbeat registry-route suites pass
247 passed; changed-file Ruff and diff checks pass; the merge commit carries DCO.
Approval is limited to merge readiness at this exact head.
Goal And Delivered Outcome
heartbeat-prequotais generated by the existing heartbeat builder, but its help and unconfigured execution loaded the complete CLI and Chat. This proposal demand-loads its existing registrar and heartbeat transport, keeping reconciliation and capability/permission decisions with their current owners.main, verified targetloopx-project/loopxat79665b97a0a453380da02e15b1b62eee895147df.Author Declaration
Implemented against
cli_runtime.py, existing heartbeat transport and reconciliation ownershandle_heartbeat_prequota_commandtests/test_cli_entrypoint.py; four real consoles, 22 cases eachScope And Continuation
Validation
4df990c9e66465171f980176fba4e3602d41f826. Runtime files match the frozen source fingerprints used for the wheel and matched measurements. Earlier full-suite runs used the same runtime code; the final change to a route-test helper was then verified across its complete file.interaction_contract; both failed identically on the immutable baselinetest_heartbeat_registry_route.pypass after repairissue-fix-pr-review-reconcile-smoke.pyexercises both CLI facades and both real stores; existing heartbeat/prompt/PR-wait/lifecycle coverage ran in the full selectionMatched local overhead
macOS 27.0 arm64, Python 3.13.5, Node 26.0.0; identical dependencies/fixtures, precompiled bytecode, fresh Python processes, warm filesystem caches and isolated reused Node services. Thirty AB/BA pairs per workload/distribution produce 360 samples in 339 seconds; study setup/validation took 260 seconds separately. Measurements include interpreter startup on a shared development host, with no OS cache reset. Commands are
heartbeat-prequota --helpand JSONheartbeat-prequota -g <synthetic-goal> -a <synthetic-agent>against the same File/SQLite fixtures.Help median wall time falls 88–89%; execution falls 62–67%. Candidate median user/system process CPU is 0.04/0.02 seconds for help and 0.13–0.14/0.065–0.08 for execution, versus 0.40–0.42/0.16–0.185 at base. Python open observations fall from 1,292–1,312 to 81–395; opened-file size sums are footprints, not actual read bytes. Outputs remain 737 help bytes and 827 JSON bytes.
A separate SQLite loopback profile observes 1,362 sent and 668 received bytes on each revision; cold-service version/server discovery starts two Node processes, reused service starts none. Single instrumented cold/warm observations do not isolate readiness or service CPU. The first IPC probe assumed Unix sockets and failed; corrected loopback instrumentation passed without a product change. Help p95 of 0.226/0.210 seconds still exceeds the RFC's nonbinding proposed 0.200-second target; that D6 proposal is not promoted or relabeled.
Initial wheel setup required a current generated Chat bundle. Equal build inputs were verified before building both wheels; generated assets stay outside the diff. Initial setup/probe failures are retained as failed observations, not converted to passes.
Frontend / Visual Evidence
Type of Change
LoopX Area
Technical Direction
Shared-authority RFC fixture impact
N/A: no TypeScript/shared-authority migration or provider/default promotion is claimed. The real File/SQLite evidence above verifies the existing canonical owners.
中文说明
现有 heartbeat builder 会生成
heartbeat-prequota,但该入口原先连同完整 CLI/Chat 一起加载。现在复用原 registrar,在现有 heartbeat transport 中共享适配,完整 facade 显式保留 runner、renderer、全局 registry resolver 的 patch points;原 reconciliation/hook 顺序、权限及 typed owners 均保持。源码与新构建 wheel 的四个真实 console 各运行 22 个对照场景,16 个配置/降级 File/SQLite 场景验证重放、原 opaque 工作保留和零扣费。完整测试初轮 378 pass、两个基线同样失败的旧路由 fixture;改为读原 digest-bound progressive capture 后,受影响文件 17 pass,未重跑准入或放宽断言。最终 quick canary 为 6 direct + 4 selected 全过。
30 配对、360 样本显示 help 中位耗时下降 88–89%,默认关闭的执行下降 62–67%;模块分别 1,158→29、1,160→277,RSS 约 92→24–47 MiB。help p95 仍超过提议的 200ms;Node readiness/service CPU、完整内核、M1/R1、installed-host、context/model、采纳与完整任务成本仍未通过资格。该结果支持这条 caller 的局部降耗,不能外推长程收益。需要最终 exact-head review 和 CI;本提案不授予 merge 权限。
Boundary Checklist