Repository navigation
perf(cli): share selected lifecycle command dispatch - #7202
Conversation
loopx-agent
left a comment
There was a problem hiding this comment.
动机
未发现阻断项,建议批准当前精确提交 785a4d02cf5849db9785d41bcc4e93fe27340b95。
反复调用状态刷新、检查点、只读地图、奖励或操作门命令的 CLI 使用者与自动化调用方。 例如一次状态刷新原本先加载整套命令,再到已有处理器;本提交直接注册该组命令,并让轻量入口和完整入口共用原处理器,减少每次启动等待。 独立测量观察到刷新预览和正式写入的启动到完成时延下降,完整参数诊断、真实写入回读及已有后置钩子的行为保持。 本 PR 不新增命令、权限或状态格式,也不完成整个 TypeScript 迁移、生产升级、真实模型采用或长期净收益验收。
验收依据来自本次改动之前已接受的迁移 RFC:spec_ref docs/architecture/rfcs/typescript-control-plane-migration-v0.md#28-change-locality-as-migration-payoff,spec_revision e3fa61956b6e374b4475162039b7bf9f4282be01,criterion_id 2.8。这条要求核对实际 owner/caller、完整事务跨 runtime 请求、兼容路径、失败归属及同负载成本,不能用目录移动或类型数量证明收益。本轮把其中的 CLI 调用成本归并作为有界交付,未把新增 checkpoint 当作给本提交自证的规格。
改动思路
轻量入口和完整入口现在共用同一个派发点,业务判断、canonical state 和后置钩子仍由已有 owner 负责;删除旧分支比增加另一套生命周期实现更容易维护和回滚。 当前可交付边界是五个既有命令的派发归并及完整入口兼容;不新增状态、协议或迁移层。后续整个控制面的语言迁移与跨平台性能资格不属于本 PR 的完成条件。
最有力的反对理由是:若只让帮助命令变快,或把后置钩子省掉,收益就不成立。保留现状会继续支付整套命令加载成本;另建一个 fast lifecycle 实现又会复制权限、状态与恢复规则。这里选择现有 selected parser 和 shared dispatcher,删除完整入口的旧派发分支,属于同一 owner 内的收敛。依据源码的路径对照如下;它是说明,不是执行证据,未另作图形渲染验收。
| 触发 | 基线 | 本提交 |
|---|---|---|
| 合法生命周期命令 | 导入完整 CLI,再调用原处理器 | 注册原命令组,经共享派发调用同一处理器 |
| 无效参数 | 完整 parser 给出错误 | 回退同一 parser,保留完整错误与退出码 |
| 所属 Goal 被原生 controller 控制 | 写入前拒绝 | 同一 Goal guard 仍先拒绝,独立 Goal 不被扩大拦截 |
具体改动
关键代码讲解
_build_selected_parser 对原有五个命令复用 register_project_lifecycle_commands。命令集合只是移到公共派发模块,并由原模块导出同一个集合;没有新增配置、业务状态或第二份命令定义。无效 grammar 继续进入完整 parser,完整入口也能正常到达共享派发点。
_dispatch_common_command 搬入原处理器调用。独立比对 AST 后,参数、输出函数、rollout 和 refresh-only hooks 条件均相同;effective_runtime_root 仍决定钩子使用的 runtime。非 refresh 命令继续没有这些钩子。cli.py 的旧 33 行分支删除,业务仍在 handle_project_lifecycle_command 及已有原生 owner,后续策略修改不必同步两个实现。
146 个定向 Python 测试通过;File/SQLite 实际 CLI 预览不写、正式写各追加一次,独立读取真实 Run 和 canonical Todo;两个版本相同初始物理 fixture 的完整业务结果与 Run 相等。 15 组帮助/无效参数/互斥条件完整 stdout、stderr、退出码逐项相等;File/SQLite 各 6 个真实作用域场景共 12 对 base/head 对照通过,覆盖所属 Goal、同 runtime 的非所属 Goal、新 Agent、改 Agent/说明尝试绕过以及解除所属控制后的继续执行。 实际写入对照保留 read_basis 和 step_revision,没有为了等价去掉这些语义字段;仅归一化生成时间、由时间派生的 Run 文件名及 rollout 事件身份。预览、控制面源、显示文件、registry 和 index 的无副作用断言分别回读。基线真实调用加载 loopx.cli,head 不加载,因而反例对旧实现有辨别力。
macOS / CPython 3.12.15,真实新进程、同物理 fixture、ABBA、每块首样本预热后排除,每 arm/后端/负载保留 6 样本;File 预览 median 412.9→210.1 ms、写入 420.6→226.3 ms,SQLite 预览 418.6→207.9 ms、写入 440.1→212.0 ms。对应 p95(n=6 的最近秩即最大值)422.8→216.9、435.6→231.7、436.9→211.5、517.5→221.4 ms。 测量期间未同时运行本评审的测试或构建。另行计数的真实原生请求在 File/SQLite 均为预览 21、正式写入 23,两版顺序相同;没有通过省略业务事务换取低时延,也没有把作者其他平台的数字当成本轮证据。
本地标准 premerge 的 6 direct 与 19 selected(10 catalog、8 risk、1 public-boundary)全部通过;修复当前工作树生成 bundle 的构建前置后,正常构建并安装 wheel 到隔离环境,在源码工作树外运行全部五命令帮助、File/SQLite 预览和正式写入及真实 Run 回读;三个交付模块与 exact head 字节相同。 修改仅涉及 9 个文件 +111/-52;产品代码三个文件 +28/-43,净减 15 行。测试调整继续保护钩子 runtime 与失败重试,既有 smoke 改为检查共享派发路径;双语 RFC checkpoint 含义一致,没有删掉旧语义覆盖来满足预算。
对主干的风险
主要风险是更早派发时丢失参数、错用 runtime,或在轻量入口绕过原生 controller 的写入所有权。上述完整写入/独立回读、钩子恢复测试与所属/非所属/新 Agent/绕过/恢复场景覆盖这些边界。完整 parser 保留为一般入口和错误回退,兼容的是同一命令定义与现有持久回执,不是另一套业务决策。回滚可直接撤销派发归并,canonical schema 和原业务 owner 不变。
初次独立 harness 曾把预览后显示文件与更早的写入前快照比较、只设置 controller 开关却未设置其所属 Goal,并遇到跨秒 prospective Run 文件名差异;按实际契约纠正前置状态和仅时间字段归一化后,完整断言通过,失败日志保留。构建最初被工作树旧生成 bundle 正常拒绝,按原构建流程重新生成并验证后完成 wheel,未跳过包验证。它们不作为产品缺陷或已知红项掩盖。未跑全库套件、Windows、最低 Python 版本、冷原生 runtime、真实模型或自然时间长期净收益实验;仅验证 wheel,未独立重跑 sdist。时延是本机暖原生 runtime 的有界观察,系统及其他进程噪声仍存在,不能外推为所有平台或整个 Goal 的收益;未查询或等待远端 CI。
我的整体评价
当前这一步有可独立验证的调用收益:同输入真实事务和恢复不变,重复新进程调用耗时减少,派发决策集中且旧分支确实删除;没有要求用户新增配置、复制数据或确认权限。前置意图和授权已经存在时,仍是原来一次 CLI 操作即可获得结果,没有新增交互轮次。接受的是这一有界默认路由优化,不代表完成父级迁移、安装推广或长期整体收益验收。
检查 loopx.entrypoint → cli_runtime → project_lifecycle 及完整九文件 diff,未改变 UI 渲染、页面布局或可见文案;这是既有 CLI 的派发路径调整。 未进行 GUI 截图或页面可读性资格,本 diff 无相应呈现改动;CLI 帮助和错误已逐字节比较。 最强未验证项仍是跨平台/冷 runtime 及长期实际采用,已明确保留范围,不把局部时延结果扩大成通用承诺。批准结论还须与原生 merge-readiness、独立的合并授权及安装授权分开;本评审未执行合并或更新共享 CLI。
English verdict: APPROVE 785a4d02cf5849db9785d41bcc4e93fe27340b95. The five existing lifecycle commands reuse one dispatcher and their existing handlers. Independent real File/SQLite parity, negative scope/recovery, packaged-wheel checks and local premerge passed; matched warm-runtime CLI measurements show a bounded latency reduction without fewer business RPCs. Cross-platform, cold-runtime and whole-goal benefits remain unqualified.
Reviewer: model_agent; gpt-6.1-sol; OpenAI; runtime_reported; reasoning_effort=max.
|
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: aihop <4408344+hhyykk@users.noreply.github.com>
785a4d0 to
02ca83d
Compare
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
Rebase self-review of 02ca83d52112db91430b60c36e34a4b803eae59b. 已亲自复核全部九个文件和冲突解决,未继承旧提交的批准。结论为 APPROVE,无阻塞性发现。
动机
反复调用状态刷新、检查点、地图、奖励与操作门命令的 CLI 用户和自动化会承担这项启动成本。例如一次状态刷新原来先导入并注册整套 CLI;现在只注册所属命令组,完整入口也复用同一处理器,保留参数、后置钩子与写入约束。独立验证看到真实 File/SQLite 预览和写入耗时下降,业务请求序列、完整输出与持久化结果保持一致。本 PR 不增加命令、权限或状态格式,不完成父级 TypeScript 迁移、跨平台性能资格或长程模型收益验收。
验收依据为本次改动之前接受的 docs/architecture/rfcs/typescript-control-plane-migration-v0.md,revision a5f06aac1ee9ffc1a58a7a251f0e2aacf09738db,criterion_id 2.8 Change locality as migration payoff:核对实际 caller/owner、完整事务跨 runtime 请求、兼容分支、失败归属和同负载成本。这次交付是已有命令的路由归并,不能以类型或调用数量替代收益。
改动思路
复用现有 selected parser 和 shared dispatcher,让两条入口调用同一组 lifecycle handler,删除完整 CLI 的旧分支。权限、canonical 数据和恢复由既有 owner 决定,Python 仅保留原 CLI 适配与钩子组合;没有新缓存、桥接或并行语义实现。当前边界是五命令的完整路由及兼容,而非整个控制面迁移。
下表来自当前源码,只说明结构;执行证据在后文。
| 触发 | 基线 | 当前提交 |
|---|---|---|
| 合法生命周期命令 | 完整 CLI 注册后调用 handler | 选定命令组,经共享 dispatcher 调用原 handler |
| 非法或不完整参数 | 完整 parser 输出规范诊断 | 同一规范 parser 回退,诊断与退出码相同 |
| controller 所属 Goal 写入 | 先被既有 guard 拒绝 | guard 仍在派发前拒绝;独立 Goal 仍可写入 |
具体改动
关键代码讲解
_build_selected_parser复用register_project_lifecycle_commands注册五个已有命令。命令集合从 lifecycle module 移到路由 owner,原 import 保留同一对象的 re-export;没有第二份命令定义。_dispatch_common_command接入原 handler 调用与 refresh-only 的钩子、projection builder、rollout 参数;我与基线完整调用做 AST 对照,参数和条件相同。既有 request scope 包住共享派发;只复用 executable revision,业务状态仍由 owner 实时读写。handle_project_lifecycle_command及其注册函数 AST 保持;cli.py删除旧 33 行分支。完整入口和轻量入口先执行相同 native-controller guard,再进入共享路由,handler 的错误、scope 与写入语义未改。
rebase 的三个冲突涉及 cli_runtime.py 和中英 RFC:保留最新 main 的 agent-context/agent-directory/agent-capabilities 派发及其说明,再加入 lifecycle 路由和说明。range-diff 仅改变相邻 hunk 的上下文,产品增减仍为 +28/-43;全 PR 为 +111/-52。原作者 DCO 保留。测试中的 effective-runtime-root hook 检查覆盖两条入口;外部交付恢复 fixture 调用既有 canonical 初始化器,没有删除失败/恢复断言。既有 modularization smoke 改为检查真实共享派发位置。
本轮执行 160 个入口/生命周期/钩子/外部交付测试和 40 个源码 CLI 测试,均通过。另用同一物理合成 fixture 在不可变 base/head 做独立真实 CLI 对照:15 组帮助/错误命令的完整 stdout、stderr、退出码相同;File/SQLite 的预览与写入业务 payload 相同,已独立读取 committed Run,canonical Todo 和 registry 保持不变。仅归一化生成时间、时间派生的 Run 路径和 rollout 事件生成身份,保留 read_basis、step_revision 等语义字段。实际 Run 内容除 generated_at 外相等。
两后端各有 covered Goal、同 registry 的独立 Goal、改变 Agent 的绕过尝试、解除 controller 后真实写入,以及 controller 声明后新建的独立 Goal,均按原 scope 拒绝或继续。原生 RPC 方法及顺序在两版完全相同:预览 21 次、正式写入 23 次。基线真实调用加载完整 loopx.cli,新版本不加载;独立 import oracle 因而能识别旧路径,不仅检查成功返回。
macOS/CPython 3.14.8/Node 24.21.0,使用新 Python 进程、暖 native runtime 和 ABBA 顺序;每块五次排除首样本,每 arm/后端/负载保留八样本。每次计时前恢复同一 canonical seed,测完整命令:
| 负载 | median ms:base → head | p95 ms:base → head |
|---|---|---|
| file preview | 548.07 → 253.74 | 582.71 → 307.35 |
| file write | 530.73 → 244.74 | 563.07 → 265.97 |
| sqlite preview | 499.78 → 240.93 | 5105.97 → 413.25 |
| sqlite write | 436.59 → 229.11 | 444.94 → 236.89 |
p95 为 n=8 最近秩最大值。SQLite preview 基线含一次约 5.1 秒离群,原样保留;未归因或剔除它,也不从此推断尾延迟因果收益。其余中位数仍显示有界调用收益,系统上其他进程噪声未排除。计时期间没有同时跑本审查的测试、构建或 premerge。
正常构建并安装 wheel 后,在源码目录外验证五命令帮助、File/SQLite 预览与正式写入及 committed Run 读回;安装来源确为 site-packages,三个产品模块与审查 head 字节相等,均未加载完整 CLI。未升级共享 CLI 或运行模型。
对主干的风险
主要风险是提前派发漏掉 hook、用错 runtime,或绕过/扩大 controller scope。参数 AST、两入口 hook 测试、真实写入独立读回、失败/重试以及 scope 反例覆盖这些路径。完整 parser 继续处理其他命令和规范错误;一次策略修改仍落到原 handler/typed owner,不需维护两份业务分支。有界重构已随本 PR 完成,无需再加 dispatcher 框架。
standard premerge 的 6 direct 和 19 selected 全部通过,无 warning 或 manual hold;Ruff、双语 RFC、完整 semantic smoke 通过。第一次 premerge 的 semantic check 因 worktree 未装 TypeScript dev dependency 失败,base 同样复现;按既有 npm ci 准备后,本检查及完整 standard 重跑通过,保留早期日志。
额外配置的 python -m mypy 没有通过:同解释器、同配置在基线有 5,230 项错误,在 head 为 5,228;逐路径与完整错误信息比较无新增诊断,少的两项来自删除的旧 CLI 分支。只忽略诊断行列位置,未按总数认定等价。这是独立证实的基线类型债务,不声称已修复或检查绿色;本变更的语义另有上述完整调用证据。未跑全仓 pytest、Windows、最低 Python、冷 runtime、sdist 或长程模型实验;这些限制不被 wheel 或本机时延代替。
语义与 CI 对齐
五个命令字符串是已有局部路由集合的搬迁,语义 advisory 的候选不构成新增共享状态词汇;复用原集合并保留旧 import。没有新 default-off 能力、激活声明、义务或授权。已检视的 help、diagnostic、recovery 文案保持原义,当前 parser 真实输出逐字节对照;旧有机器 guard 并未被改称建议。遵循当前 wait_for_ci=false,未读取、轮询或等待远端 CI。
我的整体评价
当前提交交付了有用且可回滚的调用优化,保留真实事务、权限与恢复,减少重复 CLI 启动成本;没有额外用户配置或确认轮次。能力 owner、状态、协议和 UI 入口均不增加。已核对 entrypoint → cli_runtime → project_lifecycle 及九文件 diff,没有页面、布局或可见 UI 文案变化,因此 visual_review 不适用,不需要 GUI 截图;图形呈现未验证范围为无,CLI 帮助/错误已验证。整体长程效果和跨平台收益仍未验证,局部调用提速不能代替它们。
合并仍以本次公开审查读回、用户已给的 rebase/merge 授权和当前 native merge-readiness 为条件。期间 main 的后续改动与这九个文件不重叠,merge-tree 干净,双语检查再次通过;保留已审查 head,不用旧批准覆盖这次 rebase。
English verdict: APPROVE — 02ca83d; rebase retains both collaboration and lifecycle dispatch. Reviewer-executed 200 tests, real File/SQLite parity/guards/readback, equal RPC sequences, installed-wheel checks and standard premerge passed. Existing baseline mypy failures remain with no new diagnostics. Warm CLI median gains are bounded local evidence, not whole-Goal or cross-platform gains.
|
Rebase and independent current-head validation are complete at Merge is held separately: the repository ruleset requires Code Owner review and approval of the last push by another eligible reviewer ( rebase 后的当前提交已完成验证与公开审查;合并单独等待非本次推送者的合格 Code Owner 批准。没有把自审或 admin 权限当成原生合并门已通过。 |
Current rebase qualification — 2026-10-24
Current head:
02ca83d52112db91430b60c36e34a4b803eae59b, rebased on target maina5f06aac1ee9ffc1a58a7a251f0e2aacf09738db. Resolved the shared dispatcher and bilingual RFC conflicts by retaining both Agent-collaboration and lifecycle routes. The product delta and original DCO are preserved. Later main changes do not overlap the nine changed files; merge-tree integration is clean.Independent qualification on the rebased head: 200 focused tests passed; full diagnostics and actual File/SQLite preview/write/committed-Run parity passed; controller scope, escape and recovery cases passed. Actual RPC sequences remain 21 for preview and 23 for write on both backends. Standard premerge passed all 6 direct and 19 selected checks after preparing the missing TypeScript dev dependency. Ruff, RFC pairing and semantic checks passed. Built and installed the current wheel, then checked all five help paths and real File/SQLite preview/write outside the source checkout.
Matched fresh-process ABBA measurements on macOS / CPython 3.14.8 / Node 24.21.0 retained 8 observations per arm/backend/workload. Preview/write medians: File 548/531 ms → 254/245 ms; SQLite 500/437 ms → 241/229 ms. The SQLite preview baseline includes a preserved unexplained 5.1-second outlier; these are bounded warm-runtime observations.
Configured mypy still fails on independently verified baseline debt: 5,230 base errors versus 5,228 on head, with no new diagnostic path/message and two errors removed with the old CLI branch. This is not a passing typing claim. Full-repository, minimum-platform, cold-runtime, sdist and live-model qualification were not rerun. Remote CI was not consulted under the resolved policy.
The author validation below remains historical evidence for
785a4d02cf5849db9785d41bcc4e93fe27340b95; it is not relabeled as execution on the rebased head.Goal And Delivered Outcome
Lifecycle commands still imported and registered the entire CLI before reaching their handlers.
refresh-state,checkpoint-context,read-only-map,rewardandoperator-gatenow use the existing selected parser and shared dispatcher. The full-parser entry uses that same dispatcher; its old lifecycle branch is removed.Parser definitions, handler arguments, conditional writeback hooks, registry/runtime resolution and native-controller guards remain with their existing owners. The moved handler call is AST-identical to the baseline. The lifecycle module retains its command-set import through a local re-export.
Basis:
docs/architecture/rfcs/typescript-control-plane-migration-v0.md, caller-adoption/payoff direction, at maine3fa61956b6e374b4475162039b7bf9f4282be01. Intended base:main.Author Declaration
Payoff And Scope
This is caller adoption, not another Python-to-TypeScript semantic migration. Product diff: 28 added / 43 deleted, net −15 lines. No new cross-runtime bridge, RPC method, domain rule or state cache; one local alias preserves the old command-set import.
An instrumented
refresh-statewrite makes 23 business RPCs before and after, on both File and SQLite. Existing typed owners remain unchanged. Removing the full parser for other commands is not part of this slice.Checked 33 open PRs and their changed files, including refreshed heads. #4023/#3200 touch CLI registration and Goal closure; #3834 adds an optional command; #5677 changes refresh delivery semantics. Their overlapping files do not implement this selected lifecycle dispatch. New/updated #7196/#7198/#7199 and publication-time #7200/#7201 do not touch this diff.
Validation
785a4d02cf5849db9785d41bcc4e93fe27340b95.refresh-stateworkloadWrites assert successful append; both workloads preserve canonical Todo state. Preview also preserves the state file. These are command-latency results for this fixture, not model or whole-Goal effectiveness gains.
loopx.cliThe initial package attempt failed because generated frontend assets were absent; the verified build and installed probes above resolve that prerequisite. Full repository CI, minimum-version/platform matrices, cold-native-runtime latency and live provider behavior are not claimed.
Fixture And Presentation Impact
The existing external-delivery fixture imported a Markdown-only authoring helper. Explicit canonical initialization restores the notification-failure/retry check needed by this slice; production admission is unchanged. No authority schema, provider route or UI presentation change.
Boundary Checklist