Repository navigation
refactor(testing): retire unused quota and envelope packet factories - #8963
loopx-agent wants to merge 1 commit into
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google (self_reported)
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
已针对 PR #8963 exact head ac63488684c23fcd4cc246032e79d292353b0f10 完成完整证据核验与本地验证(审查结论:APPROVE,无 P0/P1/P2 阻断问题)。
动机 / Motivation
受影响调用方与维护者:使用 loopx/control_plane/testing/ 场景构造器的模型行为评测、release qualifier 脚本(scripts/qualify-doubao-model-behavior-live.py)与控制面测试维护者。
修改前(6a007683b7dd):actual_default_model_behavior_portfolio.py 与 control_plane_composition_scenarios.py 各自保留了一个在全仓已无任何调用者的冗余 packet factory——build_actual_default_model_behavior_scenario_packets 仅对 build_actual_default_model_behavior_scenario_inputs 做丢弃 sources 的二次包装,build_control_plane_composition_scenario_packets 仅在单测外重建 v0 build_turn_envelope;两者继续滞留不仅增加维护面,还可能误导后续迁移继续沿用旁路工厂。修改后(ac63488684c2):直接删除上述两个无调用者工厂函数及唯一因此变为未用的 build_turn_envelope 导入,净减 25 行。
可观测结果:全仓 rg 确认 0 处残留引用;AST 对比确认两文件除删除这两个定义及该导入外其余结构完全不变;10 组相关测试套件 444 passed(含语义词表漂移与可维护性棘轮测试)、ruff、mypy(17 个核心文件)、release qualifier --help 与 canary premerge --tier quick 全部通过。
非目标边界:本 PR 仅退役这两个已确认无调用者的测试支持工厂,不改变 build_actual_default_model_behavior_scenario_inputs、build_control_plane_composition_scenario_sources、v0 envelope 对照测试或生产默认行为,也不授予自动合入权限。
改动思路 / Approach
本片改动严格在现有测试支持所有者 loopx/control_plane/testing/ 内部完成减法收敛:经全仓检索确认现有调用链(test_actual_default_model_behavior_portfolio.py 与 scripts/qualify-doubao-model-behavior-live.py)均已直接消费 build_actual_default_model_behavior_scenario_inputs 与 build_control_plane_composition_scenario_sources,不存在保留兼容 wrapper 的外部或持久化契约需求,因此直接删除死代码与失效导入,不引入新 shim 或抽象层。
当前 PR 边界:范围锁定于删除 build_actual_default_model_behavior_scenario_packets、build_control_plane_composition_scenario_packets 及失去调用方的 build_turn_envelope 导入(-25 行);与本片无关的远端共有 kernel-static-checks 基线 F401(test_contract_health.py:10)以及真实 Ark live 模型调用保持在独立边界之外。
- 淘汰端口袋包包装器(
loopx/control_plane/testing/actual_default_model_behavior_portfolio.py):移除原 L780-788 仅转调build_actual_default_model_behavior_scenario_inputs(root)返回第二元素的build_actual_default_model_behavior_scenario_packets(root),主调用方保留直接解包(sources, packets)的单一路径。 - 淘汰组合场景 v0 envelope 旁路工厂(
loopx/control_plane/testing/control_plane_composition_scenarios.py):移除原 L214-226 的build_control_plane_composition_scenario_packets及 L6 不再被调用的from ..quota.turn_envelope import build_turn_envelope,model_behavior_corpus.py等仍实际需要的build_turn_envelope调用保持不动。
具体改动 / Changes
本次 diff 仅触及 2 个 Python 测试支持模块(0 insertions(+), 25 deletions(-)):
关键代码讲解
loopx/control_plane/testing/actual_default_model_behavior_portfolio.py(L771-785 附近):保留build_actual_default_model_behavior_scenario_inputs(root: Path)及其上游build_control_plane_composition_scenario_sources组合调用(L730-735),删除无调用者的build_actual_default_model_behavior_scenario_packets(root: Path)(9 行)。经rg与 AST 校验,其余导出常量与场景评估函数(如_turn_expected_contract)均保持原样。loopx/control_plane/testing/control_plane_composition_scenarios.py(L1-210):保留build_control_plane_composition_scenario_sources(*, goal_id: str, agent_id: str)及其 3 个组合场景源(_required_vision_replan_source、_scoped_gate_successor_replan_source、_capability_monitor_repair_source),删除无调用者的build_control_plane_composition_scenario_packets(15 行)与唯一失效导入build_turn_envelope(1 行)。
规范依据与条款映射:对照 docs/architecture/rfcs/controller-executor-unified-contract-v0/contract-and-context.md(baseline revision 6a007683b7dd90545a93ff7d00732c4518a21d54)与仓库范围收敛原则:
C1-SHARED-OWNERS:implemented — 既有build_actual_default_model_behavior_scenario_inputs与build_control_plane_composition_scenario_sources及下游单测与 qualifier 入口保持原样,未新增平行适配器。SCOPE-FIT-RETIRE-DEAD-FACTORIES:implemented — 全仓检索确认零活跃调用方后直接删除两处冗余 factory 及无用导入,无兼容 shim。
对主干的风险 / Risks
- 符号引用完整性:全仓
rg(含loopx/、tests/、examples/、scripts/、benchmark/)对build_actual_default_model_behavior_scenario_packets与build_control_plane_composition_scenario_packets均返回0命中;唯一残余build_turn_envelope导入仍在loopx/control_plane/testing/model_behavior_corpus.py:8正常使用且未被误删。 - 公共边界与默认行为:纯内部测试支持函数清理,不涉及任何运行时默认路径、权限、持久化或外部边界;
loopx check --scan-path ...报ok=True(errors=0, warnings=0)。 - 远端 CI 失败归因(
kernel-static-checksdiagnostic):gh run view --job 134437049389 --log-failed显示远端仅在基线共享测试文件tests/control_plane/test_contract_health.py:10触发F401(loopx.paths.display_report_textimported but unused),该文件在6a007683b7dd已存在相同未用导入且本 PR 未触碰,属pre_existing_unrelated。 - 本地完整验证结果(exact head
ac63488684c23fcd4cc246032e79d292353b0f10):rg -n 'build_actual_default_model_behavior_scenario_packets|build_control_plane_composition_scenario_packets' .:0 matchesuv run --extra test ruff check loopx/control_plane/testing/actual_default_model_behavior_portfolio.py loopx/control_plane/testing/control_plane_composition_scenarios.py:PASS(All checks passed)uv run --extra test mypy:PASS(Success: no issues found in 17 source files)uv run --extra test python -m pytest -q(10 个套件:test_actual_default_model_behavior_portfolio.py、test_actual_default_model_behavior_live.py、test_model_behavior_corpus.py、test_model_behavior_retained_cases.py、test_model_behavior_qualification.py、test_host_prompt_behavior.py、test_goal_task_map_composition.py、test_quota_action_portfolio.py、test_semantic_vocabulary_drift.py、test_maintainability_ratchet.py):PASS(444 passed in 142.10s,0 failed,0 skipped)uv run --extra test python scripts/qualify-doubao-model-behavior-live.py --help:PASS(exit 0,0 model calls)uv run --extra test loopx canary premerge --tier quick --from-git-diff --git-diff-base 6a007683b7dd90545a93ff7d00732c4518a21d54:PASS(ok=true,failures=0,selected=2,manual_holds=0,覆盖 4 项 direct checks、py_compile、control-plane-maintainability-ratchet-smoke.py与semantic-vocabulary-drift-smoke.py)loopx check --scan-path ...:PASS(ok=True,errors=0, warnings=0)
我的整体评价 / Verdict
- Long-horizon 影响:
preserved— 清除 2 个已无调用者的测试支持旁路工厂与 1 处无用导入,保留全部现役 source/paired-input 调用链与历史测试契约。 - User-experience 影响:
not_applicable— 仅影响内部测试支持模块loopx/control_plane/testing/,无 CLI/UI/用户流程改动;visual_review为not_applicable(无视觉或前端渲染改动,unverified_scope:none)。 - 可观测语义 / 兼容与范围 / 词表:
observable_semantics为equivalent,repository_reuse为reused,code_volume为necessary(compatibility_assessment为not_applicable,全仓零外部/持久化消费方),default_off_isolation为not_applicable(无功能开关),authority_semantics为not_applicable(无角色或权限语义变更),semantic_alignment为not_applicable(未增改任何共享状态词表或契约键)。
本 PR 为干净的无行为变化减法重构(-25 行),全部静态扫描、444 项单测与 premerge quick 门禁在 exact head ac63488684c23fcd4cc246032e79d292353b0f10 均已通过;无任何阻断问题。由于属于作者自有 loopx/control_plane/** PR,正式合入仍需维护者授权及主干 test_contract_health.py 上游 lint 同步。
English verdict: APPROVE exact head ac63488 (author-owned COMMENTED approval review); cleanly removes two unreferenced testing packet factories and one dead import (-25 lines) with zero remaining callers, 444 passing pytest cases, clean ruff/mypy, and passing quick premerge canary (remote kernel-static-checks failure is pre-existing F401 in untouched test_contract_health.py:10).
Goal And Delivered Outcome
清理 C1 迁移旁路中两个已经没有树内调用者的 packet factory:
build_actual_default_model_behavior_scenario_packets和build_control_plane_composition_scenario_packets。后者仍能重建 v0 envelope;两者均已被现有 source/paired-input 调用链替代。本次直接删除它们及唯一失去用途的 constructor import。Author Declaration
Scope And Continuation
本片独立完成无调用生成器退役;source 和 paired-input builders 继续由原消费者使用,TypeScript 组合与校验 owner 保持原边界。普通 quota 默认完整 C1 的生产切换仍由 #8956 交付;本片不包含其历史,也不将这次清理视为 C1 全部完成、安装采用或成果/完整成本资格。没有新增任务、协议、配置或测试框架。
Validation
ac63488684c23fcd4cc246032e79d292353b0f10;base 为6a007683b7dd90545a93ff7d00732c4518a21d54。finished;Input classes:synthetic,public_fixture。regression_paritypassedae95a6a3与最终 head 的同一组 74 项测试均通过;中间主干集成只变更 Frontier clock 文件,未变本片模块/测试。排除删除的定义和 import 后,两模块其余 AST 相同unit/integrationpassedtest_actual_default_model_behavior_portfolio.py、test_model_behavior_corpus.py、test_model_behavior_retained_cases.py、test_host_prompt_behavior.py、test_actual_default_model_behavior_live.py:74 passed,0 skipped;保留拒绝/漂移、历史对照及真实 File fixture 准备,provider 使用 test doublereal_entrypointpassed--help正常;原 runner fixture 测试验证实际脚本及物理/符号链接目录入口,0 model calls;不声称真实模型资格staticpassedstaticpassedcqr_5dee9eca003b433d61b5为 pass/valid;本地 quick premerge:6 direct + 2 catalog,全过,0 timeout/skip/manual hold;默认 120s 未改manualnot_runFrontend / Visual Evidence
none。本片仅删除无 caller 的内部测试生成器;没有新增或修改用户操作路径,截图不适用。Type of Change
LoopX Area
Shared-authority RFC fixture impact
N/A:未改 authority、provider、runtime routing 或兼容投影。
Boundary Checklist