Skip to content

refactor(cli): demand-load heartbeat prequota transport - #8240

Merged
loopx-agent merged 2 commits into
mainfrom
codex/small-kernel-heartbeat-prequota-20261107
Nov 7, 2026
Merged

loopx-agent merged 2 commits into
mainfrom
codex/small-kernel-heartbeat-prequota-20261107

Conversation

@cocolord

@cocolord cocolord commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

heartbeat-prequota is 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.

  • Outcome basis / optional anchor: accepted small-kernel RFC R0, V1/V3/V10 caller qualification.
  • Goal/source and gap: remove unrelated startup work from the shipped prequota caller while preserving its best-effort continuation and zero quota consumption.
  • Observable before → after: help loads 1,158 → 29 LoopX modules; execution loads 1,160 → 277. The source/wheel corpus and paired measurements below qualify this caller.
  • Issue/task and intended base: related to the accepted RFC; base main, verified target loopx-project/loopx at 79665b97a0a453380da02e15b1b62eee895147df.

Author Declaration

  • Written by: model_agent (GPT-6 via TRAE).

Implemented against

Criterion (spec clause) Disposition Symbol / path Test or command
I2/I6/I7: retain decision/permission ownership and unselected isolation implemented cli_runtime.py, existing heartbeat transport and reconciliation owners Real File/SQLite off/merged/degraded consoles; retained work/replay/zero-debit oracles
V1/V3: demand loading and CLI compatibility for the selected caller implemented Existing registrar and handle_heartbeat_prequota_command tests/test_cli_entrypoint.py; four real consoles, 22 cases each
V10: matched local overhead census for this caller implemented Selected source and freshly built monolithic-wheel consoles 30 interleaved base/head pairs per workload/distribution, 360 samples
I3: established compatibility through at least one minor release implemented Complete support facade explicitly forwards its original globals Runner/renderer/global-resolver patch-point tests; no public module removed
Full presets, M1/R1, context/model, split install, installed adoption and complete task cost deferred Existing RFC milestones; M1 proposal #8011 Outside this independently reversible caller proposal
  • Self-check before submission: read legacy branch semantics and direct owners; baseline characterization precedes extraction. Review covered explicit/omitted/environment/empty registry, aliases, global/subcommand formats, integer/default/negative/zero timeouts, canonical parser fallback, propagated exceptions, degraded exit zero, controller handling, opaque values, hook permissions/order and unchanged decision owners. The bounded companion refactor shares transport in the existing heartbeat module and preserves full-facade globals; no dispatcher framework was added.

Scope And Continuation

  • Completed scope and remaining work: complete author proposal for this prequota caller. Its measured local startup benefit does not close the small-kernel milestone or establish long-horizon outcome/adoption benefit.
  • Slice boundary / successor: revert this single transport/selection change for rollback. Existing M1 work remains with refactor(chat): move public status owner with identity-compatible imports #8011; broader R0/V10/R1 qualification follows the same RFC. This proposal introduces no preset, provider or authority decision.

Validation

  • Tested revision: 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.
  • Run state: finished for local qualification; remote CI/review pending at submission.
  • Input classes: synthetic.
Check kind Result Public-safe evidence / limitation
unit passed 50 new transport/loading/backend cases, including original facade patch points, empty input, exceptions and controller behavior; all 202 CLI entrypoint cases passed in the full selection
unit failed Initial relevant selection: 378 passed, 2 route fixtures failed with missing inline interaction_contract; both failed identically on the immutable baseline
unit passed The route helper now reads the original digest-bound progressive capture without rerunning admission; all 17 cases in test_heartbeat_registry_route.py pass after repair
integration passed Existing issue-fix-pr-review-reconcile-smoke.py exercises both CLI facades and both real stores; existing heartbeat/prompt/PR-wait/lifecycle coverage ran in the full selection
regression_parity passed Four independently verified source/wheel consoles, 22 same-input cases each; full parser/format/exception compatibility retained. Dropped-continuation mutation is rejected by an independent public-console oracle on both stores
real_entrypoint / real_backend passed 16 configured/degraded File/SQLite console scenarios with synthetic external metadata, real canonical stores, replay, retained original work and zero quota debit. Operational providers were not invoked
static passed Focused Ruff, configured mypy (17 source files), diff-scoped semantic advisory (no supported new carrier), public boundary scan, staged and final paired RFC checks
static / integration passed Exact final quick canary: 6 direct checks and 4 selected checks, all passed, no advisory failures. Combined with the full relevant suite, real console/backend and mutation coverage
real_backend not_applicable PostgreSQL authority implementation/transport semantics are unchanged; this does not qualify a new PostgreSQL profile
manual passed Bilingual checkpoint reviewed and measured runtime fingerprints matched the committed source; no private state, generated bundles, environments, locks or raw evidence staged
static not_run Complete remote CI is pending. Existing F841 fixes are tracked separately in #8210/#8174; any failed/skipped CI remains a qualification hold and is not waived
  • Coverage and gaps: source semantics, packaged consoles, negative cases and state readback qualify the changed caller. Real-model/full-task costs, installed-host recovery, task adoption, service CPU and isolated Node readiness remain unknown. A source/wheel result does not certify an existing installation or complete minimal/standard composition.

Matched 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 --help and JSON heartbeat-prequota -g <synthetic-goal> -a <synthetic-agent> against the same File/SQLite fixtures.

Workload / distribution Base median / p95 (s) Candidate median / p95 (s) Median RSS (MiB)
source/prequota-help 1.433 / 1.889 0.172 / 0.226 91.5 → 24.7
source/prequota-file-off 1.494 / 1.927 0.545 / 0.667 92.0 → 47.0
source/prequota-sqlite-off 1.547 / 1.977 0.507 / 0.640 91.9 → 46.3
wheel/prequota-help 1.555 / 1.967 0.170 / 0.210 91.7 → 24.5
wheel/prequota-file-off 1.545 / 2.155 0.536 / 0.650 91.7 → 46.7
wheel/prequota-sqlite-off 1.397 / 1.866 0.531 / 0.667 92.0 → 46.9

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

  • UI impact: none. This adapts an existing automation CLI caller and appends a non-normative RFC checkpoint; product UI, documentation chrome and caller journeys are unchanged. The Chat bundle was generated only to build complete validation wheels.
  • Before / After / First viewport and preview / States and viewports shown: N/A for this scope.
  • Source data: synthetic.
  • Attention / Craft review: N/A; no UI layout changed.

Type of Change

  • Refactoring (no functional changes)
  • Documentation update
  • Test update

LoopX Area

  • Control plane (CLI entry and existing heartbeat transport)
  • Host or runtime integration

Technical Direction

  • Direction / acceptance reference: accepted monorepo/distribution RFC R0/V1/V3/V10; Python is CLI transport only. Full migration and minimal composition remain separate acceptance.

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

  • Diff/body/attachments disclose no private state, credentials, raw traces, internal links or local paths.
  • No maintainer-owned benchmark run duplicated.
  • Scope follows the accepted caller request.
  • Both RFC mirrors changed and staged/final bilingual checks pass.
  • UI impact is none.
  • Every commit includes DCO sign-off.

Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
loopx-agent
loopx-agent previously approved these changes Nov 7, 2026

@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

定时运行 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.

@mergify

mergify Bot commented Nov 7, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @cocolord.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

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 HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 7, 2026
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.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.

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.

@loopx-agent
loopx-agent merged commit 3e4cf70 into main Nov 7, 2026
4 of 7 checks passed
@loopx-agent
loopx-agent deleted the codex/small-kernel-heartbeat-prequota-20261107 branch November 7, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Mergify: the pull request has merge conflicts with its base branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants