Skip to content

perf(cli): load goal-acceptance through the selected runtime - #7741

Open
cocolord wants to merge 2 commits into
mainfrom
codex/goal-acceptance-demand-loading-20261030
Open

cocolord wants to merge 2 commits into
mainfrom
codex/goal-acceptance-demand-loading-20261030

Conversation

@cocolord

Copy link
Copy Markdown
Collaborator

Summary

goal-acceptance was dispatched only by the full CLI, so every goal-acceptance call — including --help and argument errors — imported the whole loopx.cli graph before reaching a handler that needs only its own owner. This PR routes the command through the selected CLI runtime, the same demand-loading path already used by status, quota, todo, handoff and performance-diagnosis:

  • loopx/cli_runtime.py: adds goal-acceptance to _SELECTED_COMMANDS, registers its parser from loopx.cli_commands.goal_acceptance on demand, and dispatches handle_goal_acceptance_command from _dispatch_common_command with the same arguments the full CLI used.
  • loopx/cli.py: keeps the parser registration for full-CLI help and the command catalog, and drops its own handle_goal_acceptance_command call. The full CLI already calls the shared dispatch_common_command before its own handlers, so both entrypoints now reach one dispatch site.

loopx/cli_commands/goal_acceptance.py is unchanged. Registry resolution, the effect-runtime request scope, authority ownership (TS lease/CAS), scheduling, settlement, defaults and output contracts are unchanged.

Measurements

These are fresh-process probes of goal-acceptance --help through loopx.entrypoint, run against the exact base 26f73056c and this head. Each side ran 6 times; the first, cold run is discarded, and the table reports the median of the other 5. mods counts imported loopx.* modules.

Route Base mods New mods Base median New median loopx.cli loaded
goal-acceptance --help 1147 164 3.43 s 0.19 s base yes, head no

Execution routes (inspect, verify, …) now pay for the goal-acceptance owner instead of the full CLI graph. Their remaining cost is the owner's own authority reads.

Behavior parity

  • Parser parity: --help, a missing --goal-id, an unknown action and an unknown option produce byte-identical stdout, stderr and exit codes through loopx.entrypoint and loopx.cli. These cases join the existing test_selected_parser_matches_full_help_and_diagnostics batch.
  • Refusal parity: inspect, inspect-proposal and verify with --proposal-id against a missing Goal return identical stdout, stderr and exit code 1 on both entrypoints. The selected run must not import loopx.cli, and the registry bytes stay unchanged.
  • The existing goal-acceptance CLI tests invoke python -m loopx.cli, which delegates to the entrypoint, so they exercise the new selected route end to end.

Tests

tests/test_cli_entrypoint.py adds 5 cases; 4 fail on the base and pass on this head:

  • goal-acceptance --help loads only loopx.cli_commands.goal_acceptance, without loopx.cli, benchmark dispatch, content-ops or turn run-once;
  • 3 refusal-parity cases (inspect, inspect-proposal, verify --proposal-id) without loading loopx.cli.

The extended parser-parity batch passes on both base and head, which is expected: it checks that routing did not change behavior.

Validation

  • tests/test_cli_entrypoint.py plus all 9 tests/control_plane/test_goal_acceptance*.py files: 321 passed.
  • Every other test module that invokes goal-acceptance (28 files, including objective revision, outcome refinement, research continuity, quota acceptance references and replan composition): 616 passed.
  • loopx canary premerge --from-git-diff --git-diff-base origin/main: passed. That is 6 direct checks and 5 selected catalog smokes, with 0 failures, 0 warnings and 0 manual holds, on surface python. The selected smokes were the maintainability ratchet, semantic vocabulary drift, CLI output budget, CLI version modularization and CLI control-plane command modularization. Two earlier runs failed for environment reasons only:
    • the first because semantic-vocabulary-drift-smoke.py needs the TypeScript dev dependencies; it passed after a local npm ci --ignore-scripts;
    • the second because cli-output-budget-regression-smoke.py hit its timeout while the 616-test suite ran in parallel. Run alone, it passed in 96 s, and the final premerge run passed it in 89 s.

Follow-up and future-facing pass

  • Applied: one dispatch site for goal-acceptance, shared by both entrypoints. No new modules, wrappers or options.
  • Unnecessary: changes to goal_acceptance.py itself. Its imports are already limited to the goal-acceptance owners.
  • Deferred: other full-CLI-only commands still pay the full import graph. Each should move only with its own parity tests.

Runtime self-merge is not requested; this needs ordinary review.

Route goal-acceptance help and execution through the selected command
parser so the command no longer imports the full CLI graph. The full CLI
keeps registration and reaches the same handler through the shared
common-command dispatch.

Cover owner-only help loading, parser diagnostic parity, and refusal
parity without loading loopx.cli.

Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>

@songoow songoow 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 Astra Pro — OpenAI — self_reported

动机 / Motivation

使用 goal-acceptance 查看、配置、校验和清除 Goal 验收合同的 CLI 用户与自动化调用方,当前每次调用都会加载完整命令图。

原来已有公共解析器仍把 goal-acceptance 送进 full CLI;本 PR 让公开入口在 selected runtime 中调用同一个验收 handler。默认配置、预览、执行、权限与错误语义保持原有行为。

真实 File/SQLite 的 30 次配对 CLI 调用获得一致的规范化完整结果;候选不再加载 loopx.cli,旧基线每次都会加载。收益是移除无关导入,未将它外推为固定启动时间或模型成本。

本次不增加验收权限,不改持久化合同、校验流程或共享 provider;不声称完整应用冷启动、原生远程数据库或真实模型资格。

改动思路 / Approach

这是执行路由的归位:原 selected runtime 已有公共注册和请求作用域,只缺验收命令接入。把命令送进该边界后,授权、合同和持久化继续由原 owner 决定,既减少无关导入,也避免两份业务分派。

范围止于一个现有命令的 lazy registration/common dispatch 及实际入口回归;不引入新的状态模型、能力安装或事务机制。

用户参数经 selected parser 进入既有 guard 与 registry,再在统一 effect request scope 中调用原验收 handler。预览只读,显式执行才写;验证失败、权限拒绝和 stale revision 继续沿原错误路径返回,后续修复也不需新增恢复协议。

共享 selected dispatcher 已承担同类命令的解析、registry、native guard 和 effect request scope;这次把原 handler 接到已有分支即可。另建启动器或复制验收 owner 都会增加无必要的规则分叉。

具体改动 / Changes

关键代码讲解

  • _dispatch_common_command:复用既有命令分派边界。goal-acceptance 分支在需要时导入原 handler,参数、registry 和输出格式直接传入;完整 CLI 也进入这个共享分派。
  • dispatch_common_command:维持请求作用域。选中的验收调用仍包在既有 effect_runtime_request_scope 内,未另造 socket、provider 或事务路径。
  • _dispatch_selected:维持入口的 guard 与 registry。在共享分派前沿用原 native controller guard、配置与 registry;新增 selected command 不绕过验收授权。
  • handle_goal_acceptance_command:沿用验收业务 owner。配置、预览、校验、清除及失败读回仍由这个未改动的 handler 处理,路由变化不重新解释合同。

规范基准:docs/reference/goal-acceptance-observations.md;修订 26f7305。用改动前已存在的验收 observation/preview/execute 契约作基准;下列标签是对原段落的定位说明,不虚构新的 RFC 验收编号。迁移 RFC 中既有 selected parser/common dispatcher 是复用依据。

Criterion 当前结论 对应实现或剩余边界
canonical authority only implemented cli_runtime._dispatch_common_command -> unchanged goal_acceptance.handle_goal_acceptance_command
preview versus execute implemented unchanged goal_acceptance handler under selected effect_runtime_request_scope
owner authorization and stable errors implemented _dispatch_selected guard/registry then original handler

实际验证 / Validation

本轮在 exact head 跑了三个既有验收模块,共 130 个案例全部通过;在不可变基线也跑了相同 130 个案例,全部通过。另有 4 个 selected-entrypoint 案例通过。验证没有修改断言、超时或 authority 数据。

补充真实 public-entrypoint 路径:每个版本 30 次独立 subprocess 调用,覆盖 File/SQLite 的配置预览/执行、失败与成功校验、读回、清除,以及 agent 写拒绝和 stale-CAS 拒绝。完整规范化 stdout、stderr、退出码一致(SHA256 20c636cc536a4d006719b74e4c7c21d4049f09e6aa99c4789c39f84080e18cca);规范化只处理临时根、时钟和保持引用关系的生成身份。基线每次加载 full CLI,head 每次都不加载;在实际 --help 路径加入导入缺席断言,基线失败、候选通过。

对主干的风险 / Risks

最危险的回归是 selected 路径绕过授权或请求作用域,或仅在动作/错误分支丢参数。代码仍复用同一 guard、registry、scope 和 handler,且真正执行了双 provider 的 mutation/rejection/readback。未发现阻断性实现问题;这不是对远程 provider、完整应用启动性能或任意调用组合的穷尽证明。

语义与 CI 对齐

改动前的验收合同是独立标准;完整结果和诊断配对保留权限、修订及验证含义,没有以删输出换性能,也没有调整验收目标。

当前 CI 快照中 dashboard-browser(2) 在未修改的 research-display-language.mjs:146 等待“Expand judgment details”后的页面条件超时(30 秒),aggregate checks 也红,其他分片尚未结束。这是独立的合并就绪风险;本轮保留失败事实,没有证明其基线同样失败,故不称为已排除的历史问题。当前路由结论来自上面的直接 File/SQLite 证据,不能表述成整套 CI 通过。

当前阻断是验证缺口,不是凭红灯虚构的代码 finding。 仓库当前 verdict_policy 明确未归因的 current failures 阻止批准;仅证明变更文件不在失败路径,尚不足以归类 pre_existing。最小解除条件是对上述具体失败提供不可变 base/head 的同命令、同签名对照,或独立证明外部/环境原因并补齐受影响合同的当前资格;若归因确属回归,再修相应代码。本轮不要求为未归因失败修改无关代码,也不放宽已有预算。

我的整体评价 / Verdict

REQUEST_CHANGES:未发现阻断性的代码缺陷;当前 CI 失败尚缺政策要求的归因证据,因此暂不具备批准资格。 审查绑定 exact head 8a06403。

长期执行所需的验收读回、配置身份与失败恢复保持在原 owner 中;本次没有增加状态副本或另一个重试入口。观察到的改善限于重复命令的导入负担,不能代表整个长期执行链提速。

用户继续使用原命令和参数,权限拒绝、校验失败及后续修复路径保留;没有增加交互步骤。正常输出与错误诊断的完整配对比较比仅核对退出码更能约束兼容性。 改动仅为 CLI 分派与导入,不涉及页面或视觉交互。

这次已采用最小共享分派,不需要新 adapter 或复制 handler。保留原 full parser 注册是帮助与完整 CLI 兼容所需;可以独立审阅,不与验收业务重构捆绑。

未执行安装后真实 provider/模型工作,也未把模块减少当作冷启动或长期延迟资格;远程全套 CI 尚未完成,本次针对这个路由改动的独立证据与最终合并就绪分开。

English verdict: REQUEST_CHANGES — exact head 8a06403; Current required CI failures lack the repository-required attribution, so approval is withheld. No blocking code defect was found in the exercised change; resolve the named validation gap rather than changing unrelated code.

…-demand-loading-20261030

Signed-off-by: huangruiteng <huangrt01@163.com>
@huangruiteng

Copy link
Copy Markdown
Collaborator

The failing dashboard-browser (2) job has the same existing goal-workspace-m2 1s timing-gate signature as current main. Exact base 04c5799b8 reproduced the assertion with a 1648.5ms switch; exact head 451236f08 reproduced it with a 1102.8ms switch. The PR does not change Dashboard/scenario sources.

This is base/head parity evidence for an environment-sensitive performance gate, not a goal-acceptance routing regression. No browser threshold is relaxed in this PR; the failed job will be rerun after the pending long shards make the workflow terminal.

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.

3 participants