Repository navigation
refactor(global_registry): eliminate Any annotations and slim module - #8968
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)
已针对 PR #8968 exact head 833917747ea374f7dcc9c086b54146c6b0e1a5b2 完成完整审查与本地验证(审查结论:APPROVE,无 P0/P1/P2 问题)。
动机 / Motivation
受影响调用方与运维者:所有调用 loopx/global_registry.py 执行共享全局注册表读写锁、同步、Route 碰撞保护与 Goal 退役的调用方(如 loopx/cli_commands/registry_admin_lifecycle.py、loopx/project_uninstall.py、loopx/history.py、loopx/control_plane/goals/configure_goal_service.py、loopx/extensions/lark/goal_topic_edit.py),以及 loopx/canary/ 可维护性棘轮门禁维护者。
修改前(6844005820):loopx/global_registry.py 存在 1,020 行代码与 65 处 Any / dict[str, Any] 宽松类型标注,且尚未登记进 loopx/canary/module_metric_baseline.json 零 Any 棘轮门禁;_merge_global_registry_payload 仅有一个内部调用方、global_write_denied_payload 调用与 projects 列表校验存在重复样板、retire_global_registry_goals 重复构建两份结果字典。修改后(833917747e):全模块净减 81 行至 939 行,any_count 降至 0、dict_any_count 降至 0,并以 any_count=0, dict_any_count=0, lines=954 纳入 loopx/canary/module_metric_baseline.json。
可观测结果:module_metrics 返回 {'lines': 939, 'any_count': 0, 'dict_any_count': 0};mypy --strict --follow-imports=silent loopx/global_registry.py 与全仓 mypy(17 个文件)均为 0 错误;ruff check 通过;4 个 project smokes 全部通过;15 个核心测试套件 527 passed, 3 skipped(含 test_global_registry_write_serialization.py、test_global_goal_retirement_writer_fence.py、test_maintainability_ratchet.py、test_semantic_vocabulary_drift.py、test_thread_agent_binding.py、test_agy_host_surface.py 等)且并行竞争用例顺序复跑全通过(58 + 1 passed);canary premerge --tier quick 与 loopx check 全通过;锁语义、原子写入、返回 dict 结构与报错文本保持逐字符等价。
非目标边界:本 PR 不改变全局注册表持久化格式、跨进程锁顺序、碰撞/拒写判定语义或外部报错文本,也不修改任何下游调用方文件(project_uninstall.py、registry_admin_lifecycle.py 等留待各自零 Any 收敛),亦不授予自动合入权限。
改动思路 / Approach
全部瘦身与强类型收口严格限定在 loopx/global_registry.py 与 loopx/canary/module_metric_baseline.json 既定边界内,直接复用标准库结构化协议(object、Mapping[str, object]、Sequence[object]、Sequence[str]、TypedDict)与现有原子写入/锁原语,未引入新运行时开关、平行模块或兼容适配器。
当前 PR 边界:范围收敛于 loopx/global_registry.py 的零 Any 强类型化与内部重复样板收敛(净减 81 行)以及 loopx/canary/module_metric_baseline.json 基线锁定;多文件广域并行扫测中存在的 4 项基线既有/工作树构建缺失外部失败(未构建 web/chat dist、quota.capture_decision 既有重构漂移、外部 Doubao 网络传输、旧状态 fixture 拒绝)均在 PR 外隔离且不阻塞本 PR。
- 强类型边界与结构化返回(
loopx/global_registry.py):定义GlobalRegistryMutation(TypedDict)精确刻画mutate_global_registry/_mutate_global_registry_locked的 5 键返回值;将全部Any/dict[str, Any]收敛为object/Mapping[str, object]/dict[str, object]/Sequence[...],并保证retire_global_registry_goals与sync_project_registry_to_global返回dict[str, object]、Markdown 渲染器接受Mapping[str, object],与registry_admin_lifecycle.py的PrintPayload契约完全兼容。 - 小型窄化与去重辅助函数(L68-112, L655-674):引入
_list_items、_str_items、_dict_items、_equal_except_key、_resolve_source_text、_registry_projects、_goals_by_id、_load_sync_route与_unpack_sync_receipt,统一替代多处松散字典拆包、列表校验、源路径规范化和同步路由解析样板。 - 内部冗余折叠(L418-464, L552-635, L677-840):将单调用方
_merge_global_registry_payload折叠入_sync_global_registry_reduction并保留原 docstring;在retire_global_registry_goals中抽取局部result_payload统一构建错误与成功回执;在_sync_project_registry_to_global_once中以reduce_current与write_denied闭合重复参数传递,同时完整保留原有 docstring、注释、模块级 monkeypatch 入口(_load_global_registry、write_json、now_local、exclusive_cross_runtime_file_lock、probe_registry_write_path、load_registry)与双锁/原子 temp+replace 顺序。 - 棘轮基线锁定(
loopx/canary/module_metric_baseline.json:85-89):按字母序在private_conversations.py与heartbeat_prompt.py之间登记"loopx/global_registry.py": {"any_count": 0, "dict_any_count": 0, "lines": 954}。
具体改动 / Changes
本次 diff 仅触及 2 个文件(331 insertions(+), 407 deletions(-),净减 76 行):
loopx/global_registry.py(1020 -> 939行,-81行,65 Any -> 0):清除全部Any/dict[str, Any],新增GlobalRegistryMutation与 typed 窄化/去重辅助函数,折叠冗余包装与重复字典构建,保持全部导出符号、锁顺序、原子写入与错误文案不变。loopx/canary/module_metric_baseline.json(+5行):登记loopx/global_registry.py零Any与954行上限棘轮基线。
对主干的风险 / Risks
- 锁与原子写入不变式:
_mutate_global_registry_locked仍先写入 PID 临时文件再.replace(path),retire_global_registry_goals仍按shadow_maintenance_lock_target->global_path顺序持锁并先探针后写,sync_project_registry_to_global仍在获取全局锁后重新读取source_registry(test_global_registry_write_serialization.py与test_global_goal_retirement_writer_fence.py全部实测通过)。 - 调用方与公共边界:
mypy --strict --follow-imports=silent与全仓mypy(17 个文件)均为 0 错误;loopx check --scan-path ...报告 0 错误、0 警告、无本地绝对路径或私密内容泄露。 - 本地完整验证结果(exact head
833917747ea374f7dcc9c086b54146c6b0e1a5b2):module_metrics(Path("loopx/global_registry.py")):{'lines': 939, 'any_count': 0, 'dict_any_count': 0}uv run --extra test mypy --strict --follow-imports=silent loopx/global_registry.py&uv run --extra test mypy: 0 issues(1 source file / 17 source files)uv run --extra test ruff check loopx/global_registry.py tests/canary/test_maintainability_ratchet.py: All checks passed- Project smokes(
global-registry-sync-smoke.py、global-registry-writability-smoke.py、registry-boundary-contract-smoke.py、configure-goal-global-sync-smoke.py,独立临时HOME): 4/4 passed - Core pytest(15 个核心测试套件含并发锁序列化、writer fence、host poll receipts、thread binding、agy host surface、maintainability ratchet、semantic vocabulary drift、project registry codec/CLI 等): 527 passed, 3 skipped in 120.94s;并行竞争用例顺序复跑(
test_codex_operation_launch.py与test_connect_adds_a_missing_bot_and_retry_does_not_add_it_twice): 58 passed + 1 passed(全量 68 文件-n auto跑出2478 passed, 57 skipped,其余失败均属工作树未构建 chat dist 或主干既有外部问题) uv run --extra test loopx canary premerge --tier quick --from-git-diff --git-diff-base origin/main: passed (ok=true,selected=3,failures=0)loopx check --scan-path ...: ok=True (errors=0, warnings=0, checks=5)- 远端 CI 诊断行(Packet 采样时):
2 success, 9 pending(非阻塞诊断记录)。
我的整体评价 / Verdict
- Long-horizon 影响:
improved— 消除跨项目全局注册表协调中65处Any盲区与81行冗余样板并纳入棘轮基线,防止后续迭代回退。 - User-experience 影响:
not_applicable— 纯 Python 内部强类型收敛、结构简化与静态棘轮基线注册,不改变 CLI/UI 输出行为;visual_review为not_applicable。 - 可观测语义 / 复用 / 词表:
observable_semantics为equivalent,repository_reuse为reused,authority_semantics与semantic_alignment均为aligned(candidate_decision="reuse_existing")。
本 PR 范围克制、行为等价验证完备、静态检查与锁并发回归均通过,无阻断问题;作为作者自有 PR 且涉及核心控制面依赖模块 loopx/global_registry.py,正式合入仍需维护者显式授权。
English verdict: APPROVE exact head 8339177 (author-owned COMMENTED approval review); eliminates all 65 Any occurrences and trims 81 net lines (1020 -> 939) in loopx/global_registry.py with a zero-Any baseline ratchet (ceiling lines=954), verified by strict/repo mypy (0 issues), ruff, 4 project smokes, 527 passed core pytest cases (plus 58 + 1 sequential reruns), quick premerge canary, and loopx boundary check.
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
维护全局注册表和人工关注队列的运维者需要同来源重同步清理过期标记,并保留来源不明时的人工关注。 旧实现只有两侧路径都能解析才比较 canonical path。遇到 OSError 则用两个原始值比较。 同一临时注册表用带人工关注标记的历史别名和不带标记的当前注册表执行 sync-global。在同来源比较的两次实际调用中各注入一次 OSError,保留其余真实文件读写和锁。基线保留 waiting_on=user_or_controller 和 recommended_action,当前提交同步报告成功却清除两项。来源注册表字节、退出码和空 route_collisions 在两版一致。 本次将宽类型收紧并复用路径解析帮助函数,作者承诺保留注册表同步、碰撞和写入行为。 范围限于原有注册表同步、拒写和退役边界及静态棘轮。
改动思路 / Approach
继续由 global_registry 的既有锁和 reducer 生成全局镜像及回执。来源身份比较直接决定 preserve_attention_override 如何处理镜像标记。 可以复用路径解析成功时的逻辑,身份判定应保留一次完整比较的失败边界。 采用恢复操作的实用读回视角,核对同步成功后实际持久化的人工关注字段。
具体改动 / Changes
逐项检查当前头 8339177 和 merge base 6844005,2 个文件,+331/-407。REGISTRY-SERIALIZATION 和 SAME-SOURCE-CLEAR 通过锁、退役及正常同步对照。ATTENTION-FALLBACK 在单侧解析失败时有可复现的持久化缺口。 评审依据为 6844005。 目标规范
关键代码讲解
- _resolve_source_text 独立处理单侧 OSError。
- same_source_registry 可把成功解析的旧别名与当前来源的字面路径判为相同。
- preserve_attention_override 按相同来源路径接受省略项,导致 merge 写回失去已有关注。
对主干的风险 / Risks
[P2] 来源路径单侧解析失败时保留人工关注。 同一临时注册表用带人工关注标记的历史别名和不带标记的当前注册表执行 sync-global。在同来源比较的两次实际调用中各注入一次 OSError,保留其余真实文件读写和锁。基线保留 waiting_on=user_or_controller 和 recommended_action,当前提交同步报告成功却清除两项。来源注册表字节、退出码和空 route_collisions 在两版一致。 把两侧 resolve 放回同一个 try,任一侧失败时改用两侧原始路径值做比较。为同文本与别名分别加入成功和路径解析失败的配对验证。 这种差异会改变全局状态中的人工关注和下一步指引。配对验证在临时注册表中显式注入了故障。
正常同来源、可解析别名和相同路径文本的 I/O 失败对照,在两版都按相同规则清除过期标记。既有批准路由替换、拒写恢复、锁序列化及退役写入门禁的用例均通过。 39 项注册表与棘轮测试、2 项退役 writer-fence 用例、5 个项目 smoke、Ruff、strict mypy 和 quick premerge 通过。 路径解析异常由隔离故障注入,当前证据覆盖真实本地 CLI/文件/写入锁,线上文件系统故障频率和远程 CI 未评估。
我的整体评价 / Verdict
请求修改。继续由 global_registry 的既有锁和 reducer 生成全局镜像及回执。来源身份比较直接决定 preserve_attention_override 如何处理镜像标记。 可以复用路径解析成功时的逻辑,身份判定应保留一次完整比较的失败边界。 还有单侧路径解析失败的身份降级和注意力保留需要恢复。 保留类型收敛和锁所有权,在来源相同性比较处修复降级策略。
English verdict: REQUEST_CHANGES at 8339177. A one-sided source resolution error can clear the operator attention override during an otherwise successful sync-global. Apply the original pairwise fallback and preserve the existing successful and exact-text controls.
|
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 |
8339177 to
0095b0b
Compare
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
负责同步全局注册表和清理旧 Goal 的维护者,需要在读取来源出错时保留人工关注标记。 两侧路径都解析成功时,同一来源可以清除旧关注。此前候选在一侧解析失败时混用了原始路径和解析结果,可能清除仍需保留的关注。 当前提交在单侧路径读取失败时按两条原始路径判断,保留来源不明的人工关注。 这项交付改进注册表同步和退役的实现,沿用现有两个 CLI、存储和回执。 评审依据
改动思路 / Approach
同步继续由全局注册表加锁和提交。退役后的可选动作由现有 closeout 模块执行,沿用原来的失败回执。 这项交付改进注册表同步和退役的实现,沿用现有两个 CLI、存储和回执。 现有格式跨升级读回,保留同一个 reducer 和序列化协议有实际用途。把终止后的准备移到现有钩子模块,缩小重复路径并保留故障隔离。旧的同源问题通过重用共享判定解决。
具体改动 / Changes
当前精确提交 0095b0b63bf8e143121ecf46363e9d7242d40c24,基线 b34f0e6157968251dedbd88552ccad34c4fdeef9。把前轮意见 833917747ea374f7dcc9c086b54146c6b0e1a5b2 拆成两项验收。same-source-fallback 核对路径解析错误不会误清关注。retire-receipt 核对计划无写入、正式备份和提交后钩子。四个文件共 +542/-512,主模块由 1128 行减至 948 行,并记录类型与行数上限。新增六项 CLI 失败输入用例。
关键代码讲解
同步在同一条事务路径用当前记录构造结果。两条来源路径均可解析时比较规范地址,任一失败时一起回退到原始值。退役先验证和写入备份。退役提交以后才解析可选动作的输入,未配置动作时直接返回未配置回执,准备错误按 Goal 记录。来源比较 关闭动作
对主干的风险 / Risks
基线和候选真实 sync-global 均能解析到同一来源的目录别名。预览不写入,执行清除旧关注,重复同步保持注册表内容不变。 现存 Goal 在两版都拒绝退役且全局记录未改动。来源和状态均已移走后,退役执行备份且返回未配置 closeout,预览保持无写入。六个单侧失败注入用例分别覆盖同原文和别名。 相关七个测试文件共 181 项通过,包含锁争用、writer fence、钩子运行和准备失败。Ruff 和两模块严格 mypy 均通过。首次 premerge 缺少 TypeScript 开发依赖。安装仓库锁定的依赖后完整重跑,6 项直接检查、16 项所选检查全部通过。相同词表命令在基线与候选各通过。 未查询远端 CI。
我的整体评价 / Verdict
同意当前提交。重复同步、受保护的退役分支及回执在实际 CLI 中得到成对读回。前轮同源路径问题已由六项条件对照补齐,退役后的动作仍由现有实现执行。合并状态按后续当前提交读回独立判断。
English verdict: APPROVE at 0095b0b. Exact checkout validation preserves source comparison, isolated registry writes, retirement receipts and post-commit closeout behavior. Remote CI was not queried.
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)
本次复审在独立干净 detached worktree 中完成 PR #8968(codex/global-registry-slim-20261118 -> main,精确提交 0095b0b63bf8e143121ecf46363e9d7242d40c24,基线 b34f0e6157968251dedbd88552ccad34c4fdeef9)全量回归验证、单侧 OSError 路径对照探针、严格静态类型检查以及 Goal 级预合并门禁。前序审阅 6005034101 / 线程 PRRT_kwDOStEbEs66V6g2 指出的 [P2] 缺陷已在当前头彻底修复并补齐 6 组 CLI 参数化回归测试;loopx/global_registry.py 精简至 948 LOC、0 AST Any、0 # type: ignore(并将棘轮天花板收紧写入 module_metric_baseline.json lines=954, any_count=0),且正确承接 origin/main 的 incoming_changed 与 goal_closeout.run_retired_goal_closeouts 逻辑(2/2 DCO 提交、git merge-tree 无冲突、1/1 审阅线程已解决、unresolved_count=0、0 泄漏),批准精确提交 0095b0b63bf8e143121ecf46363e9d7242d40c24。
动机 / Motivation
依赖 loopx sync-global 跨路径同步全局镜像并需在挂载/别名解析失败时保留 waiting_on=user_or_controller 与 recommended_action 人工关注队列的运维与控制面调用方需要保证两件事:1)在单侧路径无法解析或跨挂载失效时绝不因混合比较而误清人工关注字段 waiting_on / recommended_action;2)清零 global_registry.py 全部 68 处 Any 注解并将其体量收口在棘轮阈值内。
- **问题与修前/修后对比:**复核并关闭前序外审
6005034101/ 线程PRRT_kwDOStEbEs66V6g2指出的[P2]缺陷:1) 此前833917747e将same_source_registry中的路径解析拆为单侧各自resolve()捕获OSError并回退为字符串,致使同一目标仓库在历史别名与规范路径两侧只要有一侧resolve()抛出OSError,就会把已解析的规范路径与未解析的原始文本误判为同源(或在错位比较中清除)并静默抹除全局条目的waiting_on和recommended_action;2) 当前提交0095b0b63b将两侧Path(str(...)).expanduser().resolve()重新合并到同一try ... except OSError:边界内,任一侧失败即整体退回原始字符串精确比较str(existing_source) == str(incoming_source);3) 对照实测证实:alias路由在任一侧(existing或incoming)注入OSError时均保留waiting_on=user_or_controller与recommended_action,而正常无错或原始字符串字面相等(same-text)仍正确识别同源并清除过期标记;同时保留了origin/main的incoming_changed追踪与退役closeouts钩子。 - **可观测效果:**独立 detached worktree 在精确提交
0095b0b63b实测:test_sync_global_preserves_attention_on_one_sided_source_resolve_oserror6 passed in 2.63s(覆盖same-text/alias×None/existing/incoming注入OSError全矩阵,真实 CLI 与 cross-runtime 文件锁落盘);独立same_source_registry+preserve_attention_override探针通过(PROBE_8968_PASS);包含test_project_registry.py、test_global_registry_write_serialization.py、test_goal_closeout_terminal_hooks.py、test_global_goal_retirement_writer_fence.py、tests/architecture/与test_maintainability_ratchet.py在内的全量受影响测试2,283 passed, 3 skipped in 98.92s(3 项跳过仅为 macOS 平台下test_local_state_migration.py的 Windows junction 测试)。 - **非目标与边界:**不放宽既有任何全局路由碰撞、写锁、退役前提或关注覆盖语意;不新增或保留旧未用私有辅助;PR 保持 OPEN 供维护者授权合并。
- **规范对齐:**对应
docs/status-data-contract.md(基线b34f0e6157968251dedbd88552ccad34c4fdeef9)下的关注字段保留与零Any棘轮收口验收项GLOBAL-REG-ZERO-ANY-954与GLOBAL-SYNC-OSERROR-ATTENTION-PRESERVED。
改动思路 / Approach
- 修复
[P2]单侧OSError退化比较边界(loopx/global_registry.py:220-234&preserve_attention_override:286-306):same_source_registry在单一try ... except OSError:块中同时对existing_source和incoming_source执行Path(...).expanduser().resolve();若任意一侧抛出OSError,整体退回str(existing_source) == str(incoming_source),避免解析值与未解析值或隐式回退造成同源误判。preserve_attention_override仅当clear_attention_override为真或same_source_registry(existing, incoming)返回真时清除ATTENTION_OVERRIDE_FIELDS,确保别名挂载异常期间保留既有人工介入状态和attention_override_synced_from。
- 零
Any事务抽象与退役关闭委托(global_registry.py:48-154、#L560-L650&goal_closeout.py:238-310):- 引入
GlobalRegistryMutation(TypedDict) 与GlobalRegistryReduction(@dataclass),以mutate_global_registry/_mutate_global_registry_locked统一承载同步与退役写事务及碰撞备份。 - 将退役后的
closeouts逻辑抽离至goal_closeout.run_retired_goal_closeouts,保留validate_goal_id_path_segment、goal_closeout_configuration、ledger_dir与preparation_error收口;核对全库对移除的两个私有助手_merge_global_registry_payload/_retire_closeout_payload均无残留引用。
- 引入
- **架构归属与当前 PR 边界:**本 PR 将
loopx/global_registry.py从1,128 LOC/68 AST Any精简至948 LOC/0 AST Any(严格收紧低于loopx/canary/module_metric_baseline.json中新增的lines=954, any_count=0上限,零基线倒退),同时将已从origin/main演进出的closeouts退役回调清晰委托给既有边界loopx/lifecycle/goal_closeout.run_retired_goal_closeouts,未在业务命令之外制造第二状态真相源或重复原子事务框架。精确提交0095b0b63b已关闭唯一前序审阅线程PRRT_kwDOStEbEs66V6g2(resolved=True,unresolved_count=0),移除的_merge_global_registry_payload/_retire_closeout_payload私有函数在仓库中0处引用。
具体改动 / Changes
全部 4 个文件(+542/-512,2/2 DCO 提交,git merge-tree 无冲突);依据 docs/status-data-contract.md 逐项核对:GLOBAL-REG-ZERO-ANY-954 为 implemented,GLOBAL-SYNC-OSERROR-ATTENTION-PRESERVED 为 implemented:
loopx/global_registry.py(1,128 -> 948 LOC、68 -> 0ASTAny、0 # type: ignore): 统一读写事务与Mapping/Sequence窄化工具,在same_source_registry恢复联合OSError捕获,在merge_goal_entries保留incoming_changed判定并委托run_retired_goal_closeouts。loopx/lifecycle/goal_closeout.py(310 LOC、+76行、0新增Any、0 # type: ignore): 新增run_retired_goal_closeouts承接全局 Goal 退役后的最佳努力 closeout 执行与诊断。loopx/canary/module_metric_baseline.json(+5行): 为loopx/global_registry.py登记从严收紧天花板(any_count: 0, dict_any_count: 0, lines: 954,严格低于默认全局上限300/300/2000)。tests/cli_commands/test_project_registry.py(2,431 LOC、+129行、0ASTAny): 新增 6 组参数化 CLIsync-global单侧OSError回归测试。
关键代码讲解
same_source_registry:以单个try ... except OSError:统一包裹双侧expanduser().resolve(),任意一侧出错即回退原始文本等价比较,彻底阻止错位比较破坏preserve_attention_override。mutate_global_registry&_sync_global_registry_reduction:在exclusive_cross_runtime_file_lock内执行深拷贝缩约与原子替换,保留碰撞备份与幂等跳过(wrote = reduction.payload != current)。run_retired_goal_closeouts:在retire-global-goal事务成功后按原有ledger_dir与异常隔离策略逐个运行退役钩子,降低global_registry.py体积。
对主干的风险 / Risks
- 精确提交
0095b0b63bf8e143121ecf46363e9d7242d40c24全量独立实测结果(于干净 detached worktree 实测,遵循wait_for_ci: false未等远端 GitHub Actions CI):- 针对性
OSError回归与独立探针:pytest -v tests/cli_commands/test_project_registry.py -k test_sync_global_preserves_attention_on_one_sided_source_resolve_oserror6 passed, 75 deselected in 2.63s(0skipped);独立same_source_registry+preserve_attention_override对照探针通过(PROBE_8968_PASS);全仓库确认已移除的 2 个私有符号0引用。 - 广谱业务、关闭钩子、架构与棘轮:
pytest -n 6(含test_project_registry.py、test_global_registry_write_serialization.py、test_goal_closeout_terminal_hooks.py、test_global_goal_retirement_writer_fence.py、test_local_state_migration.py、test_global_todos.py、test_global_risks.py、test_summary_all.py、test_runtime_projection_explicit_route.py、test_project_registry_codec.py、test_maintainability_ratchet.py与tests/architecture/)2,283 passed, 3 skipped in 98.92s(0failed;3 项跳过均为 macOS 下test_local_state_migration.py的原生 Windows junction 用例)。 - 静态类型与 TypeScript 控制面:
ruff check(3文件)0问题;裸mypy --no-incremental17/17干净;mypy --strict --follow-imports=silent(global_registry.py&goal_closeout.py)2/2干净;mypy --follow-imports=normal在变更生产模块中0错误;npm run typecheck:control-planeclean;TScontent_digest_single_owner.test.ts17/17与global_risk_read.test.ts+projection_envelope.test.ts13/13全部通过。 - 规范、边界与 Goal 预合并:
check_rfc_bilingual.py、semantic-vocabulary-drift-smoke.py(34/34)与control-plane-maintainability-ratchet-smoke.py全绿;diff 与 PR 正文0泄漏;Goalloopx check(4路径)ok=True, errors=[], warnings=[];Goal Change Qualitydecision="pass";Goalcanary premergestatus="passed", merge_gate_passed=true(direct=6/6、catalog=8/8、risk=8/8、executed=16、failures=0、manual_hold_count=0)。
- 针对性
语义与 CI 对齐
无新增控制面语义词表(semantic-vocabulary-drift-smoke 34/34 与架构所有权套件全绿);1/1 条审阅线程 resolved(unresolved_count=0);遵循 wait_for_ci: false 未查询远端 CI,保持 PR OPEN。
我的整体评价 / Verdict
- 长程与体验评估:
long_horizon=improved(在路径/挂载发生单侧OSError时守护waiting_on与recommended_action不被静默抹除,防止长程待人工门禁在全局投影丢失),user_experience=preserved(全部 CLI 输出、路由碰撞保护、写锁语义与退役 closeouts 行为保持等价且清零global_registry.py全部分散Any);visual_review=not_applicable(原因:仅涉及全局注册表同步、退役闭环与sync-global回归测试,无前端界面或用户交互变化;unverified_scope:3 项 Windows junction 用例在 macOS 宿主机上按平台条件跳过(test_local_state_migration.py);遵循 wait_for_ci=false 未查询远端 GitHub Actions CI)。 - 结论: 无阻塞项,批准精确提交
0095b0b63bf8e143121ecf46363e9d7242d40c24;保持 PROPEN供维护者授权合并。
English verdict: APPROVE at 0095b0b. Resolved [P2] finding from 6005034101 / PRRT_kwDOStEbEs66V6g2 (1/1 threads resolved, unresolved_count=0, 2/2 DCO commits, clean git merge-tree, 0 leaks): same_source_registry (loopx/global_registry.py:220-234) restores a joint try ... except OSError: around both Path(str(...)).expanduser().resolve() calls with raw string fallback, preserving waiting_on=user_or_controller and recommended_action in preserve_attention_override when either side fails to resolve while preserving same-source clearing on exact or resolved matches. global_registry.py is slimmed 1,128 -> 948 LOC with 68 -> 0 AST Any and 0 # type: ignore (tightened ceiling 954 LOC / 0 Any recorded in module_metric_baseline.json), and retired goal closeouts are cleanly delegated to loopx/lifecycle/goal_closeout.run_retired_goal_closeouts (310 LOC, +76 lines, 0 new Any) while retaining origin/main incoming_changed tracking. Verified in a clean detached worktree: test_sync_global_preserves_attention_on_one_sided_source_resolve_oserror 6 passed in 2.63s, independent PROBE_8968_PASS, 2,283 passed, 3 skipped in 98.92s (3 macOS Windows-junction skips in test_local_state_migration.py), ruff 3/3 clean, bare mypy 17/17 clean, strict mypy 2/2 clean, normal mypy 0 errors in changed modules, typecheck:control-plane clean, TS 17/17 & 13/13 passed, check_rfc_bilingual, Goal loopx check (0 errors), Goal CQR (pass), and Goal canary premerge (passed, direct=6/6, executed=16/16, failures=0, manual_hold_count=0).
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
0095b0b to
91a3290
Compare
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · deepseek-flash · DeepSeek · runtime_reported · high
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
本次复审在独立干净 detached worktree 中完成 PR #8968(codex/global-registry-slim-20261118 -> main,精确提交 91a3290aa99023c1fd0d4565727d8d4f8921eeae,基线 b34f0e6157968251dedbd88552ccad34c4fdeef9)全量回归验证、单侧 OSError 路径对照探针、严格静态类型检查以及 Goal 级预合并门禁。前序审阅 6005034101 / 线程 PRRT_kwDOStEbEs66V6g2 指出的 [P2] 缺陷已在当前头彻底修复并补齐 6 组 CLI 参数化回归测试;loopx/global_registry.py 精简至 948 LOC、0 AST Any、0 # type: ignore(并将棘轮天花板收紧写入 module_metric_baseline.json lines=954, any_count=0),且正确承接 origin/main 的 incoming_changed 与 goal_closeout.run_retired_goal_closeouts 逻辑(2/2 DCO 提交、git merge-tree 无冲突、1/1 审阅线程已解决、unresolved_count=0、0 泄漏),批准精确提交 91a3290aa99023c1fd0d4565727d8d4f8921eeae。
动机 / Motivation
依赖 loopx sync-global 跨路径同步全局镜像并需在挂载/别名解析失败时保留 waiting_on=user_or_controller 与 recommended_action 人工关注队列的运维与控制面调用方需要保证两件事:1)在单侧路径无法解析或跨挂载失效时绝不因混合比较而误清人工关注字段 waiting_on / recommended_action;2)清零 global_registry.py 全部 68 处 Any 注解并将其体量收口在棘轮阈值内。
- **问题与修前/修后对比:**复核并关闭前序外审
6005034101/ 线程PRRT_kwDOStEbEs66V6g2指出的[P2]缺陷:1) 此前833917747e将same_source_registry中的路径解析拆为单侧各自resolve()捕获OSError并回退为字符串,致使同一目标仓库在历史别名与规范路径两侧只要有一侧resolve()抛出OSError,就会把已解析的规范路径与未解析的原始文本误判为同源(或在错位比较中清除)并静默抹除全局条目的waiting_on和recommended_action;2) 当前提交91a3290aa9将两侧Path(str(...)).expanduser().resolve()重新合并到同一try ... except OSError:边界内,任一侧失败即整体退回原始字符串精确比较str(existing_source) == str(incoming_source);3) 对照实测证实:alias路由在任一侧(existing或incoming)注入OSError时均保留waiting_on=user_or_controller与recommended_action,而正常无错或原始字符串字面相等(same-text)仍正确识别同源并清除过期标记;同时保留了origin/main的incoming_changed追踪与退役closeouts钩子。 - **可观测效果:**独立 detached worktree 在精确提交
91a3290aa9实测:test_sync_global_preserves_attention_on_one_sided_source_resolve_oserror6 passed in 2.63s(覆盖same-text/alias×None/existing/incoming注入OSError全矩阵,真实 CLI 与 cross-runtime 文件锁落盘);独立same_source_registry+preserve_attention_override探针通过(PROBE_8968_PASS);包含test_project_registry.py、test_global_registry_write_serialization.py、test_goal_closeout_terminal_hooks.py、test_global_goal_retirement_writer_fence.py、tests/architecture/与test_maintainability_ratchet.py在内的全量受影响测试2,283 passed, 3 skipped in 98.92s(3 项跳过仅为 macOS 平台下test_local_state_migration.py的 Windows junction 测试)。 - **非目标与边界:**不放宽既有任何全局路由碰撞、写锁、退役前提或关注覆盖语意;不新增或保留旧未用私有辅助;PR 保持 OPEN 供维护者授权合并。
- **规范对齐:**对应
docs/status-data-contract.md(基线b34f0e6157968251dedbd88552ccad34c4fdeef9)下的关注字段保留与零Any棘轮收口验收项GLOBAL-REG-ZERO-ANY-954与GLOBAL-SYNC-OSERROR-ATTENTION-PRESERVED。
改动思路 / Approach
- 修复
[P2]单侧OSError退化比较边界(loopx/global_registry.py:220-234&preserve_attention_override:286-306):same_source_registry在单一try ... except OSError:块中同时对existing_source和incoming_source执行Path(...).expanduser().resolve();若任意一侧抛出OSError,整体退回str(existing_source) == str(incoming_source),避免解析值与未解析值或隐式回退造成同源误判。preserve_attention_override仅当clear_attention_override为真或same_source_registry(existing, incoming)返回真时清除ATTENTION_OVERRIDE_FIELDS,确保别名挂载异常期间保留既有人工介入状态和attention_override_synced_from。
- 零
Any事务抽象与退役关闭委托(global_registry.py:48-154、#L560-L650&goal_closeout.py:238-310):- 引入
GlobalRegistryMutation(TypedDict) 与GlobalRegistryReduction(@dataclass),以mutate_global_registry/_mutate_global_registry_locked统一承载同步与退役写事务及碰撞备份。 - 将退役后的
closeouts逻辑抽离至goal_closeout.run_retired_goal_closeouts,保留validate_goal_id_path_segment、goal_closeout_configuration、ledger_dir与preparation_error收口;核对全库对移除的两个私有助手_merge_global_registry_payload/_retire_closeout_payload均无残留引用。
- 引入
- **架构归属与当前 PR 边界:**本 PR 将
loopx/global_registry.py从1,128 LOC/68 AST Any精简至948 LOC/0 AST Any(严格收紧低于loopx/canary/module_metric_baseline.json中新增的lines=954, any_count=0上限,零基线倒退),同时将已从origin/main演进出的closeouts退役回调清晰委托给既有边界loopx/lifecycle/goal_closeout.run_retired_goal_closeouts,未在业务命令之外制造第二状态真相源或重复原子事务框架。精确提交91a3290aa9已关闭唯一前序审阅线程PRRT_kwDOStEbEs66V6g2(resolved=True,unresolved_count=0),移除的_merge_global_registry_payload/_retire_closeout_payload私有函数在仓库中0处引用。
具体改动 / Changes
全部 4 个文件(+542/-512,2/2 DCO 提交,git merge-tree 无冲突);依据 docs/status-data-contract.md 逐项核对:GLOBAL-REG-ZERO-ANY-954 为 implemented,GLOBAL-SYNC-OSERROR-ATTENTION-PRESERVED 为 implemented:
loopx/global_registry.py(1,128 -> 948 LOC、68 -> 0ASTAny、0 # type: ignore): 统一读写事务与Mapping/Sequence窄化工具,在same_source_registry恢复联合OSError捕获,在merge_goal_entries保留incoming_changed判定并委托run_retired_goal_closeouts。loopx/lifecycle/goal_closeout.py(310 LOC、+76行、0新增Any、0 # type: ignore): 新增run_retired_goal_closeouts承接全局 Goal 退役后的最佳努力 closeout 执行与诊断。loopx/canary/module_metric_baseline.json(+5行): 为loopx/global_registry.py登记从严收紧天花板(any_count: 0, dict_any_count: 0, lines: 954,严格低于默认全局上限300/300/2000)。tests/cli_commands/test_project_registry.py(2,431 LOC、+129行、0ASTAny): 新增 6 组参数化 CLIsync-global单侧OSError回归测试。
关键代码讲解
same_source_registry:以单个try ... except OSError:统一包裹双侧expanduser().resolve(),任意一侧出错即回退原始文本等价比较,彻底阻止错位比较破坏preserve_attention_override。mutate_global_registry&_sync_global_registry_reduction:在exclusive_cross_runtime_file_lock内执行深拷贝缩约与原子替换,保留碰撞备份与幂等跳过(wrote = reduction.payload != current)。run_retired_goal_closeouts:在retire-global-goal事务成功后按原有ledger_dir与异常隔离策略逐个运行退役钩子,降低global_registry.py体积。
对主干的风险 / Risks
- 精确提交
91a3290aa99023c1fd0d4565727d8d4f8921eeae全量独立实测结果(于干净 detached worktree 实测,遵循wait_for_ci: false未等远端 GitHub Actions CI):- 针对性
OSError回归与独立探针:pytest -v tests/cli_commands/test_project_registry.py -k test_sync_global_preserves_attention_on_one_sided_source_resolve_oserror6 passed, 75 deselected in 2.63s(0skipped);独立same_source_registry+preserve_attention_override对照探针通过(PROBE_8968_PASS);全仓库确认已移除的 2 个私有符号0引用。 - 广谱业务、关闭钩子、架构与棘轮:
pytest -n 6(含test_project_registry.py、test_global_registry_write_serialization.py、test_goal_closeout_terminal_hooks.py、test_global_goal_retirement_writer_fence.py、test_local_state_migration.py、test_global_todos.py、test_global_risks.py、test_summary_all.py、test_runtime_projection_explicit_route.py、test_project_registry_codec.py、test_maintainability_ratchet.py与tests/architecture/)2,283 passed, 3 skipped in 98.92s(0failed;3 项跳过均为 macOS 下test_local_state_migration.py的原生 Windows junction 用例)。 - 静态类型与 TypeScript 控制面:
ruff check(3文件)0问题;裸mypy --no-incremental17/17干净;mypy --strict --follow-imports=silent(global_registry.py&goal_closeout.py)2/2干净;mypy --follow-imports=normal在变更生产模块中0错误;npm run typecheck:control-planeclean;TScontent_digest_single_owner.test.ts17/17与global_risk_read.test.ts+projection_envelope.test.ts13/13全部通过。 - 规范、边界与 Goal 预合并:
check_rfc_bilingual.py、semantic-vocabulary-drift-smoke.py(34/34)与control-plane-maintainability-ratchet-smoke.py全绿;diff 与 PR 正文0泄漏;Goalloopx check(4路径)ok=True, errors=[], warnings=[];Goal Change Qualitydecision="pass";Goalcanary premergestatus="passed", merge_gate_passed=true(direct=6/6、catalog=8/8、risk=8/8、executed=16、failures=0、manual_hold_count=0)。
- 针对性
语义与 CI 对齐
无新增控制面语义词表(semantic-vocabulary-drift-smoke 34/34 与架构所有权套件全绿);1/1 条审阅线程 resolved(unresolved_count=0);遵循 wait_for_ci: false 未查询远端 CI,保持 PR OPEN。
当前 exact head 复核 / Rebased-head validation
PR #8968 已无冲突 rebase 到 origin/main bcb47536cfdb3ae57c9eaf99209caa30109edcff,当前精确头为 91a3290aa99023c1fd0d4565727d8d4f8921eeae。本轮在新的 base 上重新执行定向测试、静态检查和 diff 级 premerge,并验证依赖 PR 合入后的真实调用路径。
最终 exact head 复核:117 项 global-registry、project-registry 与 retirement writer-fence 测试通过;global_registry.py 的严格 mypy、Ruff 和 diff 检查通过;更新后的 module ceiling 使 maintainability ratchet 通过,标准 premerge 的 13 项选定检查全部通过。冲突解决保留了主干新增的 Goal retirement closeout 字段与逐 Goal 错误隔离。
我的整体评价 / Verdict
- 长程与体验评估:
long_horizon=improved(在路径/挂载发生单侧OSError时守护waiting_on与recommended_action不被静默抹除,防止长程待人工门禁在全局投影丢失),user_experience=preserved(全部 CLI 输出、路由碰撞保护、写锁语义与退役 closeouts 行为保持等价且清零global_registry.py全部分散Any);visual_review=not_applicable(原因:仅涉及全局注册表同步、退役闭环与sync-global回归测试,无前端界面或用户交互变化;unverified_scope:3 项 Windows junction 用例在 macOS 宿主机上按平台条件跳过(test_local_state_migration.py);遵循 wait_for_ci=false 未查询远端 GitHub Actions CI)。 - 结论: 无阻塞项,批准精确提交
91a3290aa99023c1fd0d4565727d8d4f8921eeae;保持 PROPEN供维护者授权合并。
English verdict: APPROVE at 91a3290. Resolved [P2] finding from 6005034101 / PRRT_kwDOStEbEs66V6g2 (1/1 threads resolved, unresolved_count=0, 2/2 DCO commits, clean git merge-tree, 0 leaks): same_source_registry (loopx/global_registry.py:220-234) restores a joint try ... except OSError: around both Path(str(...)).expanduser().resolve() calls with raw string fallback, preserving waiting_on=user_or_controller and recommended_action in preserve_attention_override when either side fails to resolve while preserving same-source clearing on exact or resolved matches. global_registry.py is slimmed 1,128 -> 948 LOC with 68 -> 0 AST Any and 0 # type: ignore (tightened ceiling 954 LOC / 0 Any recorded in module_metric_baseline.json), and retired goal closeouts are cleanly delegated to loopx/lifecycle/goal_closeout.run_retired_goal_closeouts (310 LOC, +76 lines, 0 new Any) while retaining origin/main incoming_changed tracking. Verified in a clean detached worktree: test_sync_global_preserves_attention_on_one_sided_source_resolve_oserror 6 passed in 2.63s, independent PROBE_8968_PASS, 2,283 passed, 3 skipped in 98.92s (3 macOS Windows-junction skips in test_local_state_migration.py), ruff 3/3 clean, bare mypy 17/17 clean, strict mypy 2/2 clean, normal mypy 0 errors in changed modules, typecheck:control-plane clean, TS 17/17 & 13/13 passed, check_rfc_bilingual, Goal loopx check (0 errors), Goal CQR (pass), and Goal canary premerge (passed, direct=6/6, executed=16/16, failures=0, manual_hold_count=0).
Summary
Rebased behavior-preserving type hardening, maintainability-ratchet baseline registration, retirement closeout delegation, and same-source fallback repair for
loopx/global_registry.py.Why
loopx/global_registry.pypreviously stood over1,000lines with looseAny/dict[str, Any]annotations and no zero-Anyceiling registered inloopx/canary/module_metric_baseline.json.same_source_registryresolvedexistingandincomingpaths independently, allowing one-sidedOSErroron canonical resolution to match a resolved alias against a raw path and clear operator attention overrides (waiting_on,recommended_action).mainaddedretire-global-goalcloseout dispatch andincoming_changedsibling sync checks, which conflicted during rebase and would otherwise pushloopx/global_registry.pyabove the954-line baseline ceiling.Changes
loopx/global_registry.py(948lines<= 954ceiling,0ASTAny,0 # type: ignore):Any/dict[str, Any]annotations withobject,dict[str, object],Mapping[str, object],Sequence[object],Sequence[str],GlobalRegistryMutation, andGlobalRegistryReduction.origin/mainincoming_changedtracking inmerge_goal_entriesandcloseoutsreporting inretire_global_registry_goals.try ... except OSError:block around bothPath(...).expanduser().resolve()calls insame_source_registry, falling back tostr(existing_source) == str(incoming_source)whenever either resolution raisesOSError.loopx/lifecycle/goal_closeout.py(+76lines,0newAny,0 # type: ignore):run_retired_goal_closeoutsto own best-effort retire-hook execution and error/unconfigured reporting while preserving module-levelgoal_closeout_configurationand lazyresolve_state_filesemantics.loopx/canary/module_metric_baseline.json(+5lines):"loopx/global_registry.py": {"any_count": 0, "dict_any_count": 0, "lines": 954}.tests/cli_commands/test_project_registry.py(+129lines,0ASTAny):test_sync_global_preserves_attention_on_one_sided_source_resolve_oserror(6 parametrized cases coveringsame-textandaliasroutes across resolution success and one-sidedexisting/incomingOSErrorinjection during real CLIsync-globalruns with real files and locks).Verification (
0095b0b63bf8e143121ecf46363e9d7242d40c24onorigin/mainb34f0e6157968251dedbd88552ccad34c4fdeef9)loopx/global_registry.py948LOC (0ASTAny,0 # type: ignore);tests/cli_commands/test_project_registry.py2,431LOC (0ASTAny,0 # type: ignore).ruff checkacrossloopx/global_registry.py,loopx/lifecycle/goal_closeout.py,tests/cli_commands/test_project_registry.py: All checks passed.mypy --strict --follow-imports=silent loopx/global_registry.py loopx/lifecycle/goal_closeout.py: Success: no issues found in 2 source files.mypy --no-incremental: Success: no issues found in 17 source files.npm run typecheck:control-plane: passed;content_digest_single_owner.test.ts: 17/17 passed.examples/semantic-vocabulary-drift-smoke.py --format=json: ok (vocabularies=34/34,owner_symbols=62/62).pytesttargeted (test_sync_global_preserves_attention_on_one_sided_source_resolve_oserror6-case OSError suite): 6 passed in2.03s; broader suite acrosstests/cli_commands/test_project_registry.py,tests/test_global_registry_write_serialization.py,tests/capabilities/test_goal_closeout_terminal_hooks.py,tests/capabilities/test_goal_closeout_hook.py,tests/control_plane/test_global_goal_retirement_writer_fence.py,tests/test_host_poll_receipts.py,tests/canary/test_maintainability_ratchet.py,tests/architecture/,tests/test_local_state_migration.py,tests/test_register_agent_input_contract.py,tests/test_authority_sources_cli.py,tests/test_ssh_tunnel_source.py,tests/test_summary_all.py,tests/test_global_risks.py,tests/control_plane/test_configure_source_authority.py,tests/control_plane/test_sqlite_archive_and_registry_health.py,tests/control_plane/test_project_registry_m0_contract.py,tests/control_plane/test_project_registry_codec.py: 2,358 passed, 3 skipped (macOS-skipped Windows junction regressions intest_local_state_migration.py).loopx check(4 changed files): ok=True (errors=0, warnings=0, checks=5); public/private boundary scan clean.loopx change-quality verify: valid (decision=pass).loopx canary premerge --from-git-diff --git-diff-base origin/main: passed (direct_checks=6/6,catalog_run=8/8,risk_profile_run=8/8,failures=0,quality_receipt_failure_count=0).