Repository navigation
refactor(chat): move ACP, endpoint, and provider leaves under loopx.chat and ratchet module budget (#5072) - #9196
Conversation
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)
动机 / Motivation
LoopX Chat 运行时(ChatRuntimeController、open_chat_session)、原生模型设置模块(model_settings)、CLI chat-endpoint 命令以及 loopx-core 与 loopx-workspace 分包维护者。
迁移前:loopx/chat_acp.py、loopx/chat_endpoints.py 与 loopx/chat_providers.py 三个仅服务于内部 Chat 传输与端点的模块仍扁平放置在 loopx/ 顶层,使 loopx/*.py 保持在 122 个并模糊包内归属边界;迁移后:三者直接通过 git mv 并入 loopx/chat/{acp,endpoints,providers}.py,同步更新全仓 25 个文件内的相对导入、测试与示例引用,删除顶层旧模块且不留兼容 shim,并将 top_level_module_budget.json 从 122 收紧至 119。
全仓 loopx/*.py 顶层模块数精确降为 119 且与 top_level_module_budget.json(119)一致;importlib.util.find_spec 对 loopx.chat_acp、loopx.chat_endpoints 与 loopx.chat_providers 均返回 None;跨模块导入、ACP/Claude/直连模型适配器行为、AgentEndpointRegistry 读写权限(0600)与 chat-endpoint list CLI 均与迁移前等价。
本 PR 不改动任何运行时会话语义、协议 schema、ACP/Provider 行为逻辑或 loopx.chat_action_store 边界,也不合并并行 PR #9179 的搬迁批次或修改远端分支保护策略。
loopx/ 顶层仍保留其余待迁出的 chat_*.py 与主机模式目录(例如 chat_action_store.py 受当前 loopx-core 边界测试约束留在后续批次),且主干已推进至 PR #9193 后本分支处于 BEHIND(无文件冲突)。
改动思路 / Approach
围绕仓库既定分包与减法规范(docs/architecture/rfcs/monorepo-distribution-split-v0.md @ 16f418837c87ab40f04ff303962598f5bd71a034),对 loopx/chat_acp.py、loopx/chat_endpoints.py 与 loopx/chat_providers.py 三个内部叶子模块执行“无兼容 shim 的直接迁入 + 全量调用点同步 + 单向预算棘轮”策略。由于原计划中的 chat_action_store.py 仍被 tests/control_plane/test_installed_core_context.py 与 packages/loopx-core/prepare.py 的核心分包边界断言显式引用,作者将其替换为与并行 PR #9179 无重叠的 chat_acp.py,避免了在搬迁 PR 中夹带跨分包契约变更。
将仅在内部使用的 ACP stdio 适配器、本地端点注册表和 Claude/直连模型适配器作为纯代码组织内移并入 loopx/chat/,既不新增适配层、注册表或运行时开关,又直接把顶层模块上限按净删减量从 122 压低至 119,是符合 M1 与 I3 的最小可逆边界。
当前 PR 边界(current_pr_boundary):当前 PR 仅搬迁 chat_acp、chat_endpoints、chat_providers 三枚非 loopx-core 约束叶子模块并更新全仓内部调用方与预算棘轮,故意把受 test_installed_core_context.py 边界断言约束的 chat_action_store.py 与其余叶子模块留待 #5072 后续独立批次。
搬迁前后导入流向对比:
迁移前: loopx/chat/{session_open,endpoint_catalog} / loopx/chat_runtime / model_settings / support_control_chat_endpoint
──▶ loopx.chat_acp / loopx.chat_endpoints / loopx.chat_providers (top-level 122)
迁移后: loopx/chat/{session_open} / loopx/chat_runtime / model_settings / support_control_chat_endpoint
──▶ loopx.chat.acp / loopx.chat.endpoints / loopx.chat.providers (top-level 119, 旧路径 find_spec=None)
具体改动 / Changes
依据规范 docs/architecture/rfcs/monorepo-distribution-split-v0.md(修订 16f418837c87ab40f04ff303962598f5bd71a034)逐条核对以下验收标准:
M1(implemented):通过git mv将loopx/chat_acp.py、loopx/chat_endpoints.py、loopx/chat_providers.py分别迁入loopx/chat/acp.py、loopx/chat/endpoints.py与loopx/chat/providers.py,由tests/test_chat_internal_module_layout.py校验新模块归属loopx.chat.*。I3(implemented):全仓不存在对这 3 个模块的对外公开重导出(loopx/__init__.py与loopx/chat.py均未暴露);PR 同步更新所有内部调用方、monkeypatch 字符串目标、3 个离线 smoke、1 个浏览器 smoke 脚本及kiro_cli_goal_mode文档注释,且不保留任何顶层兼容 shim。Section 9 row 1(implemented):tests/architecture/top_level_module_budget.json将max_top_level_modules从122精确下调 3 至119(实测ls -1 loopx/*.py | wc -l为119),tests/architecture/test_top_level_module_budget.py验证通过。
关键代码讲解
ACPStdioAdapter(loopx/chat/acp.py#L42-L593):负责通过 stdio JSON-RPC 2.0 启动、恢复和关闭本地/远程 ACP Agent 会话并流式转发事件。迁移后仅将其顶部对loopx.chat与loopx.chat_agent的相对导入从单点改为from ..chat import ...与from ..chat_agent import ...,内部超时控制、权限请求拒绝与优雅退出逻辑一字未改。AgentEndpointRegistry(loopx/chat/endpoints.py#L221-L274):管理 owner-local 自定义 ACP 端点的endpoints.json读写(0600原子写入、文件锁、RESERVED_AGENT_IDS防覆盖保护)。迁入后将内部相对导入更新为from ..chat_store import utc_now、from ..file_lock import ...、from ..kiro_cli_goal_mode import KIRO_CLI_CHAT_AGENT_ID,同时保持ChatRuntimeController(loopx/chat_runtime.py#L49,L280,L330)与handle_chat_endpoint_command(loopx/cli_commands/support_control_chat_endpoint.py#L8,L49)的单一所有权不变。ClaudeCodeAdapter与codex_model_options(loopx/chat/providers.py#L25-L60,L154-L330):分别封装 Codex 模型目录探测、Claude Code 只读 CLI 会话以及 Anthropic/OpenAI 直连只读工具循环。迁入后将from .chat/from .chat_agent改为from ..chat/from ..chat_agent,同步在loopx/chat/session_open.py#L51,L63使用同包相对导入from .acp import ACPStdioAdapter与from .providers import ClaudeCodeAdapter, direct_model_from_environment。observed_model_settings与inspect_agent_model_options(loopx/capabilities/native_chat/model_settings.py#L100-L239):分别在模型选项查询、会话模型配置以及会话恢复校验时懒导入from ...chat import providers与from ...chat.acp import ACPStdioAdapter。同时tests/test_chat_agent_model_http.py与tests/test_chat_reasoning_selection.py中的monkeypatch.setattr("loopx.chat_providers.codex_model_options", ...)字符串路径也全部同步为"loopx.chat.providers.codex_model_options"。
对主干的风险 / Risks
- 全仓残留引用与负向/反事实检查(PASS):在独立干净工作树中(重装可编辑
loopx确认loopx.__file__与loopx.chat.__path__指向当前 PR 检出目录后),对全仓执行rg -n "\bchat_(acp|endpoints|providers)\b"验证零残留旧路径调用或字符串 monkeypatch;Python 负向检查确认importlib.util.find_spec对loopx.chat_acp、loopx.chat_endpoints与loopx.chat_providers均返回None;AgentEndpointRegistry实测拒绝保留 ID"codex"并允许正常端点写入/列表,loopx.cli chat-endpoint list返回空列表 JSON(ok: true)。 - 验证矩阵与覆盖边界(PASS):
- 架构与 Chat 定向
pytest(21 个文件):1120 passed, 6 skipped in 532.97s(6 项skipped为tests/control_plane/test_installed_core_context.py需外部LOOPX_CORE_TEST_PYTHON环境的用例)。 - 本地真实入口 smoke:
examples/loopx-chat-acp-adapter-smoke.py(ok)、examples/loopx-chat-provider-adapters-smoke.py(ok)、与构建仪表盘资源后的examples/loopx-chat-server-smoke.py(ok)全部通过;examples/personal-workspace-browser/first-goal-agent-unavailable.mjs通过node --check。 - 静态与公开边界检查:
ruff check(22 个.py文件全通过)、mypy(pyproject.toml17 个 strict 文件全通过)、scripts/check_rfc_bilingual.py --base origin/main --head HEAD通过、git diff --check通过、loopx check(25 个文件errors=0)通过、canary premerge在隔离HOME下 6/6 直接检查 + 10/10 目录 canary + 8/8 风险 smoke + 1/1 边界检查全部 PASS。
- 架构与 Chat 定向
- 并发批次与分支推进观察(非阻断):审查期间
origin/main已合入 PR#9193推进至202d7bdb05,致使canary premerge相对最新origin/main的scope_fingerprint未命中作者先前在db76a91f0c记录的 CQR(cqr_62b712366d71f399f220),但#9193与本 PR 零文件重叠,GitHub 状态仍为MERGEABLE(BEHIND)。另top_level_module_budget.json的baseline_commit记录为00f47ed364(db76a91f0c^1,顶层模块同样为 122 个),与并行的 PR #9179 合入其中之一后,后合入方只需按合并后计数(119 -> 116)与test_chat_internal_module_layout.py/chat_runtime.py重演单行 rebase 即可。
我的整体评价 / Verdict
本 PR 为 justified_increment:严格遵循 #5072 / monorepo-distribution-split-v0.md 的 M1 与 I3 规则,在不改变任何运行时或对外契约的前提下完成 3 个内部 Chat 叶子模块归位与预算棘轮下调。
- Long-horizon(
improved):loopx/顶层模块从 122 稳定降至 119 且禁止顶层兼容 shim 回流,降低了后续分包重构与调用方定位的长期维护成本。 - User experience(
preserved)与 Visual review(not_applicable):本次仅调整内部 Python 模块布局、测试导入与文档引用,不涉及前端 UI 组件或视觉呈现改动(已核对loopx/chat/acp.py、loopx/chat/endpoints.py、loopx/chat/providers.py与examples/personal-workspace-browser/first-goal-agent-unavailable.mjs,unverified_scope:none)。 - 语义词表与兼容决策:未新增、扩展或改变任何状态枚举或协议字段(
semantic_alignment:not_applicable);compatibility_assessment为not_applicable(纯内部模块,无公开重导出);observable_semantics与default_off_isolation均验证等价/不适用(equivalent/not_applicable)。 - Exact-head freshness:复核远端
HEAD仍为993ecae82ddf0b19185e8e99e4468a1788e181c4(OPEN、MERGEABLE、wait_for_ci: false),全部本地定向测试、smoke 与静态边界检查均已在该精确 head 独立跑通。
English verdict: APPROVE at exact head 993ecae (published as COMMENTED review because PR #9196 is author-owned; 3 internal Chat leaf modules moved cleanly to loopx/chat/{acp,endpoints,providers}.py with zero shims, all callers/monkeypatches/smokes updated, top_level_module_budget ratcheted 122 -> 119, 1120 pytest cases + 3 chat smokes + ruff + mypy + canary premerge 19/19 PASS).
|
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 |
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
动机 / Motivation
维护者正在按 M1 迁移 Chat 内部模块,每批还要通过顶层实际数量门禁。 #5072 将可兼容迁移和精确模块计数绑定在同一 PR,避免为降低表面数字留出新增长空间。 当前 main 有 121 个顶层 Python 模块,合入本提案的三个搬迁后实际为 118。临时整合树只选择主干的 121 或提案的 119 作为预算时,原精确计数测试均失败。把预算改为实测 118 后,预算与模块布局合计 9 项通过。 这批把 ACP、端点登记和 provider 适配迁进 loopx.chat,更新内建调用点。源分支固定的 119 对应旧分叉。 本轮只核验 M1 的三个模块和兼容边界。剩余 Chat 模块与发行分包仍由 #5072 跟踪。
改动思路 / Approach
保留原 Chat 架构与接口责任,更新相对导入和已有启动路径。 内部模块从同一分发包重新归位。公开命令、配置和效果所有者仍沿现有入口。 整合时只需在现有精确计数 owner 设置实际数值,现有生产模块的组合可保留。
具体改动 / Changes
逐项检查当前头 993ecae 和 merge base db76a91,25 个文件,+50/-39。主干 a6ffb3b 的合并预演只在模块预算 fixture 有内容冲突。其余生产文件由 Git 自动整合。我分别用两侧 fixture 跑了同一项门禁,再在临时树按实测值对照。 评审依据为 a6ffb3b。 目标规范
- m1-chat-leaf-relocation · Move internal ACP, endpoint, and provider modules into the existing Chat package.
- i3-active-callers · Preserve established public interfaces and update existing internal callers with no stale imports.
- current-main-module-budget · Pin the real merged top-level count after the three moves.
关键代码讲解
对主干的风险 / Risks
[P2] 当前主干整合的精确模块预算应为 118。 在当前 main 上重基并把预算更新到实际的 118,保留现有 allowlist。用同一提交重跑准确计数、内部导入和包边界。 选择任一冲突侧都会使 mandatory architecture gate 失败。无需扩大迁移范围即可恢复。
分叉基线有 122 个顶层模块,提案准确头有 119。该头通过 110 项定向 Python 测试及本地 quick premerge,覆盖无旧 shim 的布局、ACP 启动、端点和聊天配置。 隔离 Core wheel 的命令帮助在无 Node 的 PATH 可启动。 重建标准 wheel 后,三个新模块均由已安装包加载,ACP stdio 和 provider fixture 实跑通过。 整合树使用主干值和提案值时分别为 1 项失败、5 项通过。按同一生产树实际数量收紧后,预算和布局 9 项通过。 临时整合只用于验证。远端 PR 分支仍含内容冲突。
我的整体评价 / Verdict
请求修改。保留原 Chat 架构与接口责任,更新相对导入和已有启动路径。 内部模块从同一分发包重新归位。公开命令、配置和效果所有者仍沿现有入口。 搬迁可在旧分叉基线上通过,当前分支的规范预算和主干组合仍待提交。 请在新基线记录整合后的精确预算,并在不改动 MCP、provider 或 Chat 权限的前提下复验同一头。
English verdict: REQUEST_CHANGES at 993ecae. The exact relocation passes focused Chat tests. Current main plus these moves contains 118 top-level modules. The architecture gate fails with either side's conflicting budget and passes when the integrated budget is set to the measured count.
…hat and ratchet module budget Implements the next monorepo-distribution-split-v0 (#5072) M1 internal leaf migration batch without permanent top-level compatibility shims: - Move loopx/chat_acp.py -> loopx/chat/acp.py - Move loopx/chat_endpoints.py -> loopx/chat/endpoints.py - Move loopx/chat_providers.py -> loopx/chat/providers.py - Update internal relative imports, callers, tests, smokes, layout guards, and kiro_cli_goal_mode references - Ratchet tests/architecture/top_level_module_budget.json from 118 to 115 at baseline 4052e3f Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
993ecae to
fc76e46
Compare
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)
本次针对精确头 fc76e46fcb72dfc3574fbaa2ec0e5e6906e1316a 执行独立复审,核验了前一轮(993ecae82d)[P2] 顶层模块预算滞后问题(thread PRRT_kwDOStEbEs66auIk 所在问题已通过 rebase 至 #9179 合入后的 4052e3ffd2 并将预算更新为 115 解决),结论为 无未决阻塞项,建议通过(APPROVE)。
动机 / Motivation
受影响的调用方与维护者包括 LoopX Chat 运行时(ChatRuntimeController 与会话打开入口 open_chat_session)、原生模型配置模块(model_settings)、CLI 命令 loopx chat-endpoint,以及推进 loopx-core 与工作区拆分的仓库维护者。
搬迁前,loopx/chat_acp.py、loopx/chat_endpoints.py 与 loopx/chat_providers.py 三个仅服务内部 Chat 传输、本地端点登记与模型 provider 适配的叶子模块散落在 loopx/ 顶层,使包顶层仍保留 118 个平铺 .py 文件、模块归属不清且每次新增拆分批次都需要与顶层预算竞争;搬迁后,三者通过 git mv 并入 loopx/chat/{acp,endpoints,providers}.py,同步切换全仓 25 个文件内的导入、monkeypatch 目标、smoke 与注释,删除旧顶层模块且不留兼容 shim,并将顶层模块预算从 118 精确下调至 115(实测 loopx/*.py 为 115 个)。
在精确头 fc76e46fcb72dfc3574fbaa2ec0e5e6906e1316a 上,loopx/*.py 数量实测为 115 个且与 tests/architecture/top_level_module_budget.json 一致,旧模块名 loopx.chat_acp、loopx.chat_endpoints、loopx.chat_providers 的 importlib.util.find_spec 均返回 None;同时 ACPStdioAdapter、AgentEndpointRegistry(含 0o600 持久化写入)与 ClaudeCodeAdapter 从 loopx.chat.* 加载且 CLI chat-endpoint、模型设置与 3 个离线 Chat smoke 行为与基线一致。
本 PR 不改动 ACP 协议协商、provider 模型路由、端点注册表 schema、权限边界或会话持久化语义,也不搬迁受 loopx-core 安装边界测试 pins 约束的 loopx/chat_action_store.py 或其余待拆 chat_*.py 模块。
loopx/ 顶层仍保留 chat_action_store.py 等其余待迁移 chat_*.py 模块(受 tests/control_plane/test_installed_core_context.py 与 packages/loopx-core/prepare.py 边界约束留待 #5072 后续独立批次),且浏览器端到端脚本 examples/personal-workspace-browser/first-goal-agent-unavailable.mjs 仅完成语法检查而未运行完整 Playwright 浏览器链路;此外当前分支相对 main(77af2b21f54329c837912e084f8d581ad519d92e)处于 BEHIND(无文本或计数冲突)。
改动思路 / Approach
将仅在内部消费的 ACP stdio 适配器、本地端点注册表与 Claude/直连模型适配层直接迁入已有 loopx/chat/ 命名空间(由 loopx/chat.py 的 __path__ 承载)并删除顶层旧文件,复用现有单向预算棘轮与布局测试 owner,不引入额外兼容 shim、桥接开关或状态副本,在行为零漂移前提下实现可独立验证、可整批回退的结构减法。
当前 PR 边界仅覆盖 chat_acp.py、chat_endpoints.py、chat_providers.py 三枚内部 Chat 叶子模块迁入 loopx/chat/、全仓内部调用方/测试/smoke/注释同步以及 top_level_module_budget.json(118 → 115)与 test_chat_internal_module_layout.py 更新,刻意将 chat_action_store.py 及后续 M1/M2 分包迁移留归 #5072 后续独立批次。
架构所有者判定与机制分解:在职责划分上,loopx.chat 由 loopx/chat.py 继续作为公共包入口并通过 __path__ 挂载 loopx/chat/ 内部子模块,未引入 loopx/chat/__init__.py,因此既不改变外部 import loopx.chat 语义,又把 3 个仅服务内部传输、端点持久化与 provider 适配的模块收拢到统一子树;packages/loopx-core/prepare.py 对 loopx/chat/ 与 loopx/chat_*.py 均持排除策略,搬迁前后分包隔离边界完全等价。对于为何不纳入 loopx/chat_action_store.py,已核实 tests/control_plane/test_installed_core_context.py 与 packages/loopx-core/prepare.py 显式依赖其顶层分发边界,留在后续批次处理是最小风险选择。
迁移前 (4052e3ffd2, top-level 118):
chat_runtime / chat.session_open / model_settings / support_control_chat_endpoint
──▶ loopx.chat_acp / loopx.chat_endpoints / loopx.chat_providers
迁移后 (fc76e46fcb, top-level 115, 旧路径 find_spec=None):
chat_runtime / chat.session_open / model_settings / support_control_chat_endpoint
──▶ loopx.chat.acp / loopx.chat.endpoints / loopx.chat.providers
上表为基于源码导入关系的示意对比(非运行期证明);所有变更均由相对/包内路径导入与架构门禁实测支撑。
具体改动 / Changes
依据规范 docs/architecture/rfcs/monorepo-distribution-split-v0.md(固定修订 16f418837c87ab40f04ff303962598f5bd71a034)逐条核对当前头 fc76e46fcb72dfc3574fbaa2ec0e5e6906e1316a(25 个文件,+50/-39):
M1(implemented):通过git mv将loopx/chat_acp.py、loopx/chat_endpoints.py、loopx/chat_providers.py移入loopx/chat/acp.py、loopx/chat/endpoints.py、loopx/chat/providers.py,并将模块内原本的平级相对导入(.chat、.chat_agent、.chat_store、.file_lock、.kiro_cli_goal_mode)同步调整为上一级包相对导入(..*),由 tests/test_chat_internal_module_layout.py 断言三者__module__均归属于loopx.chat.*。I3(implemented):核查全仓git grep结果与loopx/__init__.py/loopx/chat.py,确认这 3 个模块无对外公开重导出;同步更新生产调用方(loopx/chat/session_open.py、loopx/chat_runtime.py、loopx/capabilities/native_chat/model_settings.py、loopx/cli_commands/support_control_chat_endpoint.py)、loopx/kiro_cli_goal_mode/注释与 README、8 个测试文件(含monkeypatch.setattr("loopx.chat.providers.codex_model_options", ...)字符串路径)、3 个 Python smoke 与 1 个浏览器 smoke 脚本,未保留顶层兼容 shim。S9-R1(implemented):在 tests/architecture/top_level_module_budget.json 将baseline_commit更新为 rebase 基线4052e3ffd24decd03680abcc79de1b956c6f5ba1、将max_top_level_modules从118精确下调 3 至115(保留allowlist为["__init__.py", "entrypoint.py", "cli.py"]),同时在test_chat_internal_module_layout.py完整保留 #9179 已合入叶子的无 shim 断言并追加本批 3 个旧路径find_spec(...) is None校验。
关键代码讲解
ACPStdioAdapter:迁入loopx/chat/acp.py后将内部依赖切换为..chat与..chat_agent,继续承担 ACP v1 stdio 进程启动、协议初始化(initialize/initialized、session/new/session/resume/session/load)及空闲/硬超时控制;由 session_open._start_acp_adapter 与 model_settings.observed_model_settings 直接消费,超时/断流统一抛出CodexChatAgentError/CodexChatTimeoutError并经_terminate()先关 stdin EOF 再温和退出。AgentEndpointRegistry:迁入loopx/chat/endpoints.py后改用..chat_store、..file_lock与..kiro_cli_goal_mode,在upsert/delete写路径保持exclusive_file_lock与0o600文件 /0o700目录原子写权限,并保留RESERVED_AGENT_IDS冲突拒绝分支;被 ChatRuntimeController 与 handle_chat_endpoint_command 调用。ClaudeCodeAdapter与codex_model_options:迁入loopx/chat/providers.py后切换为..chat与..chat_agent,保持ClaudeCodeAdapter.start(含不可用时_provider_error、tool_scope校验)与direct_model_from_environment(ANTHROPIC_API_KEY/OPENAI_API_KEY缺失即 fail-closed)语义不变;由session_open._start_adapter与model_settings.{inspect_agent_model_options,configure_session_model}调用。observed_model_settings与inspect_agent_model_options:将函数内局部导入同步更新为from ...chat import providers与from ...chat.acp import ACPStdioAdapter,确保对自定义 ACP 端点模型/推理强度回读的isinstance(..., ACPStdioAdapter)检查与 Codex 模型目录校验继续命中同一个真实类对象而不会静默跳过。open_chat_session/_start_adapter:使用同包相对导入.acp.ACPStdioAdapter与.providers.{ClaudeCodeAdapter, direct_model_from_environment},保持会话创建/恢复/provider 不可用拒绝对外路径与错误码完全等价。
对主干的风险 / Risks
对基线(4052e3ffd2)与当前远端主干(77af2b21f54329c837912e084f8d581ad519d92e)的对照检查显示,整体主干回归风险低,未发现阻塞项:
- 已解决的前置
[P2]预算滞后风险:前一提交993ecae82d未包含 #9179 的减法更新(当时主干由 121 降至 118),导致合入冲突。本次精确头fc76e46fcb72dfc3574fbaa2ec0e5e6906e1316a已基于4052e3ffd2干净重基并将max_top_level_modules设为115;同时实测当前origin/main(77af2b21f54329c837912e084f8d581ad519d92e,含 #9198 workbench 改动)顶层loopx/*.py仍为118且未新增任何chat_acp/chat_endpoints/chat_providers引用,本地只读git merge-tree origin/main HEAD干净无冲突且合并树顶层模块数精确为115。 - 动态导入与 monkeypatch 路径一致性风险:若遗漏任意字符串形式的
monkeypatch.setattr("loopx.chat_providers...")或函数内局部导入,运行期将在inspect_agent_model_options/configure_session_model/observed_model_settings或测试中触发ModuleNotFoundError。全仓git grep已证实除test_chat_internal_module_layout.py的负向断言外不存在旧模块引用,且正反向导入探针(find_spec对 3 个旧名均为None,新路径导入与__module__均正确)及 17 个架构/Chat 测试文件共 821 项在基线与精确头全部通过(821 passed)。 - 残余风险与未覆盖边界:目标分支相对
origin/main为BEHIND(虽经merge-tree确认无冲突);examples/personal-workspace-browser/first-goal-agent-unavailable.mjs仅执行了node --check语法校验,未跑真实 Playwright 浏览器会话;按 Goal 策略未查询远端 GitHub CI(wait_for_ci: false)。
独立本地验证清单(全部运行于隔离评审工作树 fc76e46fcb72dfc3574fbaa2ec0e5e6906e1316a):
- 顶层计数与合入树核验(PASS):
ls -1 loopx/*.py | wc -l==115(基线4052e3ffd2与origin/main均为118);git merge-tree origin/main HEAD干净且合并树顶层.py为115。 - 架构与 Chat 定向 pytest(PASS):覆盖
test_top_level_module_budget.py、test_control_plane_import_boundaries.py、test_package_kernel_import_ratchet.py、test_chat_internal_module_layout.py及 13 个关联 Chat/端点/ACP 测试文件,精确头821 passed in 15.64s(基线4052e3ffd2对等运行821 passed in 18.02s)。 - CLI 与持久化真实路径对照(PASS):基线与精确头分别在隔离目录执行
loopx chat-endpoint add/list/remove,endpoints.json权限均为0o600、JSON schema 与输出完全一致。 - 代码质量、类型与脚本校验(PASS):22 个改动 Python 文件
ruff check0 错误;python -m mypy(配置 17 个严格检查文件)Success: no issues found(另对 8 个改动loopx/*.py运行--follow-imports=silent显示 56 条既有未标注/Protocol 错误,与基线4052e3ffd2完全一致、未引入新错误);check_rfc_bilingual.py、git diff --check、node --check全部通过。 - Chat 与 Pre-Merge Smoke(PASS):3 个 Chat smoke(
loopx-chat-acp-adapter-smoke.py、loopx-chat-provider-adapters-smoke.py、以及在隔离工作树构建前端产物后运行的loopx-chat-server-smoke.py)全部通过;loopx check --scan-path ...(25 文件)0 errors / 0 warnings;loopx canary premerge --from-git-diff --git-diff-base origin/main通过(19/19选定检查全过:10/10catalog canaries、8/8risk-profile smokes、1/1public boundary)。 - 远端 GitHub CI(UNVERIFIED,诊断记录
required=false):未向分支上报 status check rollup;按仓库 Goal 策略wait_for_ci: false(ci_policy: not_consulted),本地全套架构门禁、定向单测、CLI 真实路径与canary premerge已完整覆盖变更不变量。
我的整体评价 / Verdict
从 长程任务连续性(long_horizon) 与 用户体验(user_experience) 两个维度评估,两者均 保持等价(preserved):会话创建、恢复、ACP 超时保护、本地端点注册与模型设置热切换的行为、错误码和持久化结构未发生变化;因本 PR 仅涉及内部模块目录整理与预算棘轮、不更改任何渲染界面或交互文案,视觉评审(visual_review)判定为 not_applicable(unverified_scope: none,仅浏览器脚本 first-goal-agent-unavailable.mjs 未做实机渲染复跑但核心 UI 未修改)。
在可观测语义(observable_semantics)上,基线 4052e3ffd2 与精确头 fc76e46fcb72dfc3574fbaa2ec0e5e6906e1316a 对同一 chat-endpoint CLI 请求、文件权限(0o600)、端点注册表 schema、Chat/ACP 测试矩阵与 3 个 smoke 输出完全一致(唯一预期变化是 3 个内部模块名从 loopx.chat_* 迁至 loopx.chat.* 且旧路径无 shim)。在代码体积与架构评估上,50 行新增 / 39 行删减全部属于路径调整、包边界测试与预算棘轮,无新增兼容层或控制面状态;按 monorepo-distribution-split-v0.md 既有词汇与 loopx_top_level_module_budget_v0 契约复用执行(reuse_existing),无需新增 RFC 或词汇注册。当前精确头 fc76e46fcb72dfc3574fbaa2ec0e5e6906e1316a 已完整解决前置 [P2] 预算问题且全部独立验证通过,建议批准。
English verdict: APPROVE at fc76e46. The PR cleanly relocates three internal Chat leaf modules under loopx/chat/, updates all callers and tests without shims, lowers max_top_level_modules to 115 after the #9179 rebase, and passes local architecture, Chat pytest (821 passed), CLI parity, mypy/ruff, all three Chat smokes, and canary premerge (19/19 checks).
Goal And Delivered Outcome
docs/architecture/rfcs/monorepo-distribution-split-v0.md(Milestone M1, Invariant I3, and Section 9 top-level module budget ratchet; related to RFC: split LoopX distributions inside the monorepo (loopx-core / loopx-workspace / capability packages) and pin top-level module growth #5072).loopx/chat_acp.py,loopx/chat_endpoints.py,loopx/chat_providers.py) still sat at the package top level (118top-level modules onmainafter refactor(chat): colocate leaf chat helpers under loopx.chat and ratchet module budget (#5072) #9179) instead of co-locating underloopx/chat/.(Note:
loopx/chat_action_store.pywas intentionally skipped in this batch becausepackages/loopx-core/prepare.pyandtests/control_plane/test_installed_core_context.pycurrently assert the top-levelloopx.chat_action_storedistribution boundary.)loopx/held118top-level*.pymodules (tests/architecture/top_level_module_budget.jsonpinned118at4052e3ffd24decd03680abcc79de1b956c6f5ba1after refactor(chat): colocate leaf chat helpers under loopx.chat and ratchet module budget (#5072) #9179).loopx/chat/(acp.py,endpoints.py,providers.py) viagit mvwith zero top-level compatibility shims, updated all internal callers, monkeypatches, tests, smokes, andkiro_cli_goal_modedocs/comments, preserved both refactor(chat): colocate leaf chat helpers under loopx.chat and ratchet module budget (#5072) #9179 and refactor(chat): move ACP, endpoint, and provider leaves under loopx.chat and ratchet module budget (#5072) #9196 no-shim assertions intests/test_chat_internal_module_layout.py, and ratchetedmax_top_level_modulesdown to115(baseline_commit4052e3ffd24decd03680abcc79de1b956c6f5ba1,allowlistpreserved). Proven on exactHEADfc76e46fcb72dfc3574fbaa2ec0e5e6906e1316abytests/architecture/test_top_level_module_budget.py,tests/test_chat_internal_module_layout.py, targeted chat/architecture pytest (821 passed), Goal-bound CQRcqr_c9c3481af1b333546746, andcanary premerge(19/19selected checks passed).main(rebased onto4052e3ffd24decd03680abcc79de1b956c6f5ba1).Author Declaration
Implemented against
docs/architecture/rfcs/monorepo-distribution-split-v0.md(M1,I3, Section 9) at4052e3ffd24decd03680abcc79de1b956c6f5ba1loopx/chat/loopx/chat/acp.py,loopx/chat/endpoints.py,loopx/chat/providers.pypytest -q --no-cov tests/test_chat_internal_module_layout.pyloopx/chat/session_open.py,loopx/capabilities/native_chat/model_settings.py,loopx/chat_runtime.py,loopx/cli_commands/support_control_chat_endpoint.py,loopx/kiro_cli_goal_mode/*,tests/*,examples/*rg -n "loopx\\.chat_(acp|endpoints|providers)|chat_(acp|endpoints|providers)\\.py"+tests/test_chat_internal_module_layout.pytests/architecture/top_level_module_budget.json(118→115)pytest -q --no-cov tests/architecture/test_top_level_module_budget.pyls -1 loopx/*.py | wc -l==115, verified zero dangling old-module imports/monkeypatches across code/tests/examples/docs viarg, verified bilingual RFC check, ranruff, configured strictmypy(17files), affected chat smokes (acp-adapter,provider-adapters,chat-server), browser smoke syntax check (node --check), targeted pytest (821 passed in 15.90s),loopx check(0errors on25files), Goal-boundchange-quality(cqr_c9c3481af1b333546746), andcanary premerge(19/19selected checks passed,0failures).Scope And Continuation
118→115), resolving thetop_level_module_budget.jsonrebase/count finding on4052e3ffd24decd03680abcc79de1b956c6f5ba1after refactor(chat): colocate leaf chat helpers under loopx.chat and ratchet module budget (#5072) #9179 landed. Remaining top-levelloopx/chat_*.pymodules and M1–M5 distribution split work stay open under RFC: split LoopX distributions inside the monorepo (loopx-core / loopx-workspace / capability packages) and pin top-level module growth #5072.Validation
fc76e46fcb72dfc3574fbaa2ec0e5e6906e1316a(rebased cleanly onto4052e3ffd24decd03680abcc79de1b956c6f5ba1; all checks below ran directly on exactHEADfc76e46fcb72dfc3574fbaa2ec0e5e6906e1316a)finishedsynthetic,public_fixtureunitpassedpytest -q --no-cov -n auto tests/architecture/test_top_level_module_budget.py tests/architecture/test_control_plane_import_boundaries.py tests/architecture/test_package_kernel_import_ratchet.py tests/test_chat_internal_module_layout.py tests/test_atomic_write_modes.py tests/test_chat_acp_startup_timeout.py tests/test_chat_agent.py tests/test_chat_agent_model_http.py tests/test_chat_codex_defaults.py tests/test_chat_endpoint_readiness.py tests/test_chat_goal_workspace_selection.py tests/test_chat_long_running.py tests/test_chat_machine_configuration_api.py tests/test_chat_path_redaction.py tests/test_chat_reasoning_selection.py tests/test_chat_startup_isolation.py tests/test_kiro_cli_host_surface.py→821 passed in 15.90sstaticpassedruff checkon all changed.pyfiles (All checks passed!),python -m mypy(Success: no issues found in 17 source files),python scripts/check_rfc_bilingual.py --base origin/main --head HEAD(RFC bilingual diff check passed.),node --check examples/personal-workspace-browser/first-goal-agent-unavailable.mjs(exit 0),loopx check --scan-path ...(ok: true,errors: 0,25files clean)real_entrypointpassedpython examples/loopx-chat-acp-adapter-smoke.py(ok),python examples/loopx-chat-provider-adapters-smoke.py(ok),python examples/loopx-chat-server-smoke.py(ok),loopx canary premerge --from-git-diff --git-diff-base origin/main --goal-id personal-loopx-maintenance(ok: true,direct_checks: 6/6,selected_checks: 19/19,failure_count: 0,change_qualityreceiptcqr_c9c3481af1b333546746valid)chat_acp,chat_endpoints, orchat_providerswere checked and exercised;examples/personal-workspace-browser/first-goal-agent-unavailable.mjswas syntax-checked (node --check) rather than executed end-to-end in Playwright (full-repo pytest and remote CI were not run).Frontend / Visual Evidence
nonenoneType of Change
LoopX Area
Technical Direction
docs/architecture/rfcs/monorepo-distribution-split-v0.md(M1,I3, Section 9)Shared-authority RFC fixture impact
N/A
Boundary Checklist
.loopx/,.codex/goals/, and liveACTIVE_GOAL_STATE.md).python3 scripts/check_rfc_bilingual.py --base origin/main --head HEADpasses, or no paired RFC changed.none.Signed-off-bytrailer (git commit -s).