Repository navigation
refactor: separate complete quota and Host request phases - #7490
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
Reviewer: model_agent; gpt-6.1-sol; OpenAI; runtime_reported; reasoning_effort=max
APPROVE,精确head 5704275b0da061122b73fd55bd310ef889038af9。未发现阻塞问题。两个完整阶段分别归入既有Monitor适配器与有真实调用者的内部Host参数helper;quota.py降至984行,turn_run_once.py降至1000行,原行数阈值和所有决策、限制、IO顺序保持。 长程行为与用户体验均为preserved,不将可维护性变化推算为模型效果或效率收益。
动机 / Motivation
维护quota、Monitor观察、Turn Host适配与公开Host集成smoke的开发者。 quota.py 和 turn_run_once.py 分别达到1080与1050行,完整的自动心跳观察和Host请求准备仍混在命令编排中,超过既有1000行维护边界。 两个完整阶段分别归入既有Monitor适配器与有真实调用者的内部Host参数helper;quota.py降至984行,turn_run_once.py降至1000行,原行数阈值和所有决策、限制、IO顺序保持。 不修改配额、选择、lease、调度、状态持久化、Host权限、提示条款或UI,不声称模型收益或性能加速。
改动思路 / Approach
保留原决策与receipt owner,把完整阶段移出命令编排;Monitor复用既有适配器,Host helper只做既有CLI参数解析和绑定,原callable由调用方显式传入。 Monitor适配器已有观察与receipt恢复职责;新Host helper只处理CLI参数与适配器绑定,有唯一真实调用者,Python没有新增决策owner。四个公开Host fixture在作者完成源数据后,通过既有saved-plan import一次性建立canonical SQLite,再执行原场景;未替换断言或结果。
具体改动 / Changes
规格为 31d61bff11474e60726b87a756170feee122e0d1 的 docs/reference/protocols/quota-monitor-observation-receipt-v0.md,并对照同一revision的 docs/reference/protocols/loopx-turn-v0.md:OBSERVATION-PARITY保持Turn绑定、观察/重载/重投影顺序;CONTEXT-PRESERVATION保持三种hook证据和无消费限制;HOST-BOUNDARY保持Host匹配、native连接、命令JSON数组与独立validator限制;BOUNDED-OWNER保持1000行上限且完整移走阶段。两个完整阶段AST一致;仅反向替换原依赖名,并移除两个已通过dict分支证明的typing.cast身份调用。没有排除语句、条件、参数或指令。
record_automatic_heartbeat_stall接收原context、selection和hooks,handle_quota_command传入原find/record/status/decision/host-observer五个callable,保留测试接缝与原四值返回。prepare_turn_host_request完成原project路径、计划Host匹配、native连接、argv与validator检查,并返回原envelope;execute_turn_run_once继续使用原driver、效果与结算。两处typing.cast只缩窄已证明的dict类型,运行时返回原对象。managed binding、自愈、DSH与TraeX四个已有fixture只补齐一次canonical前提。最终5704275的33个Monitor/context用例零skip通过;8项公开CLI检查(模块预算、managed binding、自愈、DSH外部与内建、TraeX、heartbeat、Monitor)全部通过;6项direct与19项selected premerge、规定Ruff命名空间加全部改动文件、17个配置mypy文件、新helper定向mypy、8文件公开边界与CQR均通过。
对主干的风险 / Risks
主要风险是依赖绑定变化、丢失hook信息或Host拒绝顺序变化;完整AST比较和实际canonical backend CLI路径覆盖这些边界。原append/replay、full/compact输出、notify、required_reads和不可消费断言均保留。没有新增存储、重试、配置、UI或首次屏幕变化。此前单独Monitor阶段留下的Turn模块超限已在本head修复;历史失败仍保留在其原head证据中。CI按Goal配置未查询。本切片已合格;正式发布仍需统一候选的全量回归、打包UI、真实模型与制品渠道核验,不将本PR的局部通过替代发布资格。
我的整体评价 / Verdict
本PR边界仅含两个既有CLI适配阶段和四个已有Host smoke的一次canonical初始化。该变化复用既有语义owner,以两个完整阶段降低命令编排复杂度,范围包含必要的四个既有Host fixture前提,能够独立评审并整体回滚。原决策、效果顺序和权限边界保留;局部维护性缺口已解决,正式发布仍需统一来源的后续资格验证。
English verdict: APPROVE 5704275b0da061122b73fd55bd310ef889038af9. Both complete CLI phases preserve original behavior and authority. Full AST comparison,33Monitor cases,eight real public checks and required local gates passed;whole-release qualification remains separate.
The quota and Turn CLI owners exceeded the existing1,000-line budget (1,080 and1,050 lines). Two complete preparation phases were mixed into command orchestration.
Automatic no-spend heartbeat observation now lives in the existing Monitor adapter. Host request parsing and adapter/validator binding live in one internal CLI helper with an active caller. Original dependencies,Host restrictions,effect order,receipts and guidance are preserved. Both complete phase bodies have AST parity after explicit dependency renaming and removal of two runtime-identity typing casts. quota.py is984 lines and turn_run_once.py is1,000;the cap is unchanged.
Four existing managed-Host fixtures initialize canonical SQLite once through the saved-plan import before their original complete scenarios. No assertions or Host outcomes are replaced.
Validation at
5704275b0da061122b73fd55bd310ef889038af9:33Monitor lifecycle cases,8actual public checks,6direct+19selected premerge,required Ruff/configured mypy,new-helper scoped mypy and all8files' public boundary passed. No UI changes. Final whole-release,packaged UI and live-model qualification remain separate.