Repository navigation
refactor(native-chat): eliminate Any and slim conversation_bindings - #8970
loopx-agent wants to merge 10 commits into
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 #8970 exact head e254a70dbf03dbbac04524df12c9e35ba838b0be 完成完整审查与本地验证(审查结论:APPROVE,无 P0/P1/P2 问题)。
动机 / Motivation
受影响调用方与维护者:所有依赖 loopx/capabilities/native_chat/conversation_bindings.py 管理外部会话授权绑定、输入准入、Steward 执行器对齐以及原生 Peer 会话请求的协调控制路径,以及 loopx/canary/ 可维护性棘轮检查。
修改前(6844005820):loopx/capabilities/native_chat/conversation_bindings.py 体积达到 1,155 行,内部散布 69 处 Any / dict[str, Any] / Mapping[str, Any] 宽松标注,在 mypy --strict --follow-imports=silent 下产生 73 个类型错误,且尚未登记入 loopx/canary/module_metric_baseline.json;大量字段校验、状态发布、前置绑定复核与原子 JSON 校验写入分散在重复模板分支中。修改后(e254a70dbf):全模块净减 62 行至 1,093 行,any_count 与 dict_any_count 均降至 0,mypy --strict 错误清零,并在 module_metric_baseline.json 锁定 lines <= 1108, any_count = 0。
可观测结果:module_metrics 实测为 {'lines': 1093, 'any_count': 0, 'dict_any_count': 0};mypy --strict --follow-imports=silent 与全仓 mypy(17 个文件)均报告 0 问题;ruff check、快速预合并门禁(3/3 canaries)和公私边界扫描均通过;相关 11 个测试集跑出 1044 passed,且其余 9 处失败已独立证明在未改动的基线 origin/main@6844005820 上完全复现。若放任不管,核心会话绑定契约将继续处于静态类型盲区并缺乏防膨胀棘轮保护。
非目标边界:本 PR 不更改 conversation-bindings.json 持久化结构、核心规则协议、既有报错字符串、测试兼容猴子补丁接口或 origin/main 上既有的 test_listener_* / test_bound_owner_web_input.py 问题,也不授予自动合入权限。
改动思路 / Approach
全部强类型化与结构瘦身严格限定在既有的 loopx/capabilities/native_chat/conversation_bindings.py 与 loopx/canary/module_metric_baseline.json 所有者边界内完成,复用标准库 object、Mapping[str, object]、TypedDict、Sequence[object] 与 TYPE_CHECKING 协议接口收敛外部协作依赖,未引入任何平行模块、运行时开关或接口破坏性重构。
当前 PR 边界:范围聚焦于 conversation_bindings.py 的零 Any 收敛、跨方法重复窄化/发布/文件校验辅助抽提以及 module_metric_baseline.json 棘轮基线注册;对外部尚无严格类型签名的 inbox 底层模块及 tests/ 既有主干基线缺陷保持独立修复边界,不混改无关文件。
- 类型系统边界收口:使用
JsonDict/JsonMap别名、TypedDict(_AgentObservation)与本地TYPE_CHECKINGProtocol 描述控制器、项目上下文、原生 Peer 会话与异步事件接收器,并在入参/内部 JSON 解码处用显式运行期类型收窄函数替代Any透传。 - 重复流程辅助聚合:抽提
_need、_as_dict、_dict_or_empty、_dict_list、_find_binding/_require_binding、_session_mentions_binding、_iter_open_session_turns、_host_observation_fields、_publish_state、_verify_unchanged、_resolve_source、_path/_entry_path/_lock_request/_write_verified/_validate_current,保留原有方法签名、猴子补丁点(如self.resolve(...)与二参_atomic_write_json默认路径)及全部注释文档。
具体改动 / Changes
本次 diff 仅修改 2 个文件(640 insertions(+), 697 deletions(-),净减 57 行):
loopx/capabilities/native_chat/conversation_bindings.py(+635 / -697行,全文件1155 -> 1093行,69 Any -> 0,mypy --strict错误73 -> 0):清除全部Any,抽提共享窄化/校验/发布/请求文件操作辅助函数,完整保留原有 docstring、注释与异常文案。loopx/canary/module_metric_baseline.json(+5 / -0行,L32-36):按字典序插入"loopx/capabilities/native_chat/conversation_bindings.py": {"any_count": 0, "dict_any_count": 0, "lines": 1108}。
本文档基线检查按 spec_basis = no_spec 处理:无独立外部规范文档,验收对照严格基于既有类型安全契约、测试兼容面与棘轮基线规则。
关键代码讲解
_need/_as_dict/_dict_or_empty/_dict_list(loopx/capabilities/native_chat/conversation_bindings.py:61-78):统一封装运行期isinstance(..., kind)类型收窄与稳定错误信息,在消除Any透传的同时维持原有TypeError/ValueError契约与object边界校验。ChatConversationBindings._publish_state与_verify_unchanged(L132-146):收敛绑定变更后的原子持久化、_atomic_write_json兼容参数传递(仅在显式preserve_mode=True时透传preserve_mode,保留现有二参测试替身兼容性)以及 provider IO 之后的精确绑定一致性复核。ChatConversationBindings._resolve_source(L147-157):将输入/会话来源拼装收敛为单入口并显式经由self.resolve(...)委派,从而兼容测试对实例resolve方法的拦截替换,避免静默绕过授权链路。OriginalConversationRequests._write_verified与_validate_current(L737-742、L1015-1022):合并多处状态校验写入回读确认以及原会话请求访问/状态检查路径,减少条件分支漂移。
对主干的风险 / Risks
- 测试兼容性与基线回归隔离:针对
conversation_bindings.py相关 11 个测试文件实测跑出1044 passed,另9项失败(tests/control_plane/test_bound_owner_web_input.py::test_http_binding_discovery_preserves_duplicate_observations_for_the_typed_owner[file|sqlite]共 2 项,以及tests/test_chat_conversation_bindings.py中 7 项test_listener_*用例);经在干净基线工作树origin/main@6844005820同条件复跑确认,这9项在合入前主干即完全失败(9 failed, 180 deselected in 11.72s),属于既有主干缺陷而非本 PR 引入的回归。 - 调用方类型契约与副作用边界:静态类型收窄未改变任何对外返回字典键名、错误消息文本或持久化写入协议;全仓
mypy(17 个文件)与mypy --strict --follow-imports=silent均 0 错误,确认无跨模块调用签名撕裂。 - 完整验证矩阵(exact head
e254a70dbf03dbbac04524df12c9e35ba838b0be):module_metrics: PASS —{'lines': 1093, 'any_count': 0, 'dict_any_count': 0}(基线lines=1155, any_count=69)uv run --extra test mypy --strict --follow-imports=silent loopx/capabilities/native_chat/conversation_bindings.py&uv run --extra test mypy: PASS — 各自0 issues(17 个追踪模块全部通过)uv run --extra test ruff check loopx/capabilities/native_chat/conversation_bindings.py tests/canary/test_maintainability_ratchet.py: PASS —All checks passed!- 11 个核心/契约/棘轮/词表漂移 pytest 套件: PASS on changed scope —
1044 passed;其余9项失败已于未改动origin/main@6844005820独立复现为既有主干故障 uv run --extra test loopx canary premerge --tier quick --from-git-diff --git-diff-base origin/main: PASS —ok=true, selected=3, failures=0(control-plane-maintainability-ratchet-smoke.py、semantic-vocabulary-drift-smoke.py、catalog-planner-smoke.py全过)loopx check --scan-path ...: PASS —public boundary scan clean: 2 files,errors=0, warnings=0- GitHub 远端诊断 CI(提交后即时读取):
Sign-off、changes、inspect-pr-diff、dependency-review、loopx-codex-provider-routing、loopx-repo-health、loopx-obelisk、Summary为 PASS;kernel-static-checks、loopx-core、build、prepare尚在运行中(UNVERIFIED,不阻断审查结论)。
我的整体评价 / Verdict
- Long-horizon 影响:
improved— 彻底消除conversation_bindings.py内的69处Any与73处严格模式报错,净减62行并将any_count=0, dict_any_count=0, lines=1108纳入棘轮约束,稳固后续长程迭代的静态安全底线。 - User-experience 影响:
not_applicable— 纯内部能力层类型硬化、辅助函数收敛与棘轮基线注册,外部交互界面与输出文案均无变化;visual_review为not_applicable。 - 可观测语义 / 代码体积 / 词表边界:
observable_semantics为equivalent,repository_reuse为reused,code_volume判为necessary且完整保持旧签名与二参测试兼容,change_proportionality为proportionate,default_off_isolation为isolated,authority_semantics与semantic_alignment均为aligned(candidate_decision="reuse_existing",未新增词汇或权限边界)。
本 PR 为作者自有并触及 capabilities/**,合规交付仍需维护者最终审查与合并授权。
English verdict: APPROVE exact head e254a70 (author-owned COMMENTED approval review); eliminates all 69 Any occurrences and 73 mypy --strict errors while slimming loopx/capabilities/native_chat/conversation_bindings.py (1155 -> 1093 lines) and registering a zero-Any baseline ratchet, with zero PR regressions verified by strict/repo mypy (0 issues across 17 files), ruff, quick premerge canary (3/3), public boundary check, and 1044 passing pytest cases (all 9 failures reproduced identically on unmodified origin/main@6844005820).
Signed-off-by: huangruiteng <[email protected]>
|
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 |
…dit-chat-retry-feedback-8729-20261119 Signed-off-by: LoopX Agent <[email protected]>
Signed-off-by: LoopX Agent <[email protected]>
e254a70 to
34f71f0
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)
已针对 PR #8970 rebase 后 exact head 34f71f02529f7ca6f79f277296bd42c8876d4756 完成完整审查与本地验证(审查结论:APPROVE,无 P0/P1/P2 阻塞问题;PR 保持 OPEN,不执行合并)。
动机 / Motivation
受影响调用方与维护者:所有依赖 loopx/capabilities/native_chat/conversation_bindings.py 管理外部会话授权绑定、输入准入、Steward 执行器对齐以及原生 Peer 会话请求的协调控制路径,以及 loopx/canary/ 可维护性棘轮检查。
修改前(origin/main@ff90543766):loopx/capabilities/native_chat/conversation_bindings.py 体积达到 1,155 行,内部散布 69 处 Any / dict[str, Any] / Mapping[str, Any] 宽松标注,在 mypy --strict --follow-imports=silent 下产生 131 个类型错误,且尚未登记入 loopx/canary/module_metric_baseline.json;字段收窄、状态发布、前置绑定复核与原子写入校验也重复分散在多个分支中。修改后(rebased head 34f71f0252):全模块净减 62 行至 1,093 行,any_count 与 dict_any_count 均降至 0,mypy --strict 错误清零,并在保留主干 #9072 注释调整的同时于 module_metric_baseline.json 锁定 lines <= 1108, any_count = 0, dict_any_count = 0。
可观测结果:已验证 module_metrics 为 {'lines': 1093, 'any_count': 0, 'dict_any_count': 0},mypy --strict --follow-imports=silent 与全仓 mypy(17 个文件)均报告 0 问题,ruff check、标准预合并门禁(13/13 checks,ok=true)与公私边界扫描均通过;相关 13 个目标 pytest 套件共跑出 1,258 passed,包括 test_chat_conversation_bindings.py(117/117)、test_original_conversation_peer.py(40/40)、test_chat_manager_model_adoption.py(38/38)、test_semantic_vocabulary_drift.py(124/124)、test_lark_private_conversations.py + test_native_steward_private.py(648/648)及 5 项辅助套件(208/208)全通过,而 test_maintainability_ratchet.py 中 1 项与 test_bound_owner_web_input.py 中 2 项失败已在未改动的 origin/main@ff90543766 同条件复现。
非目标边界:本 PR 不更改 conversation-bindings.json 持久化结构、核心规则协议、既有报错文案、测试兼容猴子补丁接口,也不修复 origin/main 上既有的 interaction_contract.py 决策函数长度超限或 test_bound_owner_web_input.py 既有失败,且不授予自动合并权限。
改动思路 / Approach
全部强类型化与结构瘦身严格限定在既有的 loopx/capabilities/native_chat/conversation_bindings.py 与 loopx/canary/module_metric_baseline.json 所有者边界内完成,复用标准库 object、Mapping[str, object]、TypedDict、Sequence[object] 与 TYPE_CHECKING 协议接口收敛外部协作依赖,未引入平行模块、运行时开关或接口破坏性重构,因此保留在既有文件所有者边界内。
当前 PR 边界:范围聚焦于 conversation_bindings.py 的零 Any 收敛、跨方法重复窄化/发布/文件校验辅助抽提以及 module_metric_baseline.json 棘轮基线注册;对外部尚无严格类型签名的 inbox 底层模块及 origin/main 既有基线缺陷保持独立修复边界,不混改无关文件。
- 类型系统边界收口:使用
JsonDict/JsonMap别名、TypedDict(_AgentObservation)与本地TYPE_CHECKING协议(_ProjectContexts、_BindingController、_NativePeerSession、_RequestLockFn、_RecordResultFn)描述协作边界,并在入参和持久化解码处通过显式运行期窄化辅助替代Any透传。 - 重复流程收敛与主干兼容性:抽提
_need、_as_dict、_dict_or_empty、_dict_list、_find_binding、_require_binding、_session_mentions_binding、_iter_open_session_turns、_host_observation_fields、_publish_state、_verify_unchanged、_resolve_source、_path、_entry_path、_lock_request、_write_verified、_validate_current,完整保留原有签名、测试猴子补丁点(如self.resolve(...)与二参_atomic_write_json默认路径)以及origin/main#9072的注释更新(L479与L805)。
具体改动 / Changes
本次 rebase 至 origin/main@ff90543766 的 diff 仅涉及 2 个文件(640 insertions(+), 697 deletions(-),净减 57 行):
loopx/capabilities/native_chat/conversation_bindings.py(+635 / -697行,全文件1155 -> 1093行,69 Any -> 0,mypy --strict错误131 -> 0):清除全部Any,抽提共享窄化/校验/发布/请求文件操作辅助函数,完整保留原有异常文案、持久化格式及#9072注释调整。loopx/canary/module_metric_baseline.json(+5 / -0行,L47-51):按字典序插入"loopx/capabilities/native_chat/conversation_bindings.py": {"any_count": 0, "dict_any_count": 0, "lines": 1108}。
本文档基线检查按 spec_basis = no_spec 处理:无独立外部规范文档,验收对照严格基于既有会话绑定行为契约、调用方兼容面、mypy --strict 与可维护性棘轮基线规则。
关键代码讲解
_need/_as_dict/_dict_or_empty/_dict_list(loopx/capabilities/native_chat/conversation_bindings.py:61-77):统一封装运行期isinstance(..., kind)类型收窄与稳定ValueError报错信息,避免Any透传同时保持对非对象 JSON 字段的确定性拒绝。ChatConversationBindings._publish_state与_verify_unchanged(loopx/capabilities/native_chat/conversation_bindings.py:132-145):收敛绑定变更后的原子持久化、_atomic_write_json兼容参数传递(仅在显式preserve_mode=True时传入preserve_mode,兼容二参测试替身)以及外部 IO 后的精确绑定一致性复核。ChatConversationBindings._resolve_source(loopx/capabilities/native_chat/conversation_bindings.py:147-156):将来源上下文构造收敛为单入口并显式经由self.resolve(...)委派,确保测试对实例resolve方法的拦截替换继续生效。OriginalConversationRequests._write_verified与_validate_current(loopx/capabilities/native_chat/conversation_bindings.py:737-741、L1015-1021):合并状态持久化写入回读确认与原会话请求当前状态/权限校验逻辑,减少条件分支漂移。
对主干的风险 / Risks
- 基线测试失败归因隔离:在 rebased head
34f71f0252运行 13 个目标套件共取得1,258 passed(test_chat_conversation_bindings.py117/117、test_original_conversation_peer.py40/40、test_chat_manager_model_adoption.py38/38、test_semantic_vocabulary_drift.py124/124、test_lark_private_conversations.py+test_native_steward_private.py648/648、test_private_chat_backlog_projection.py+test_chat_http_runtime_scope.py+test_lark_private_compatibility.py+test_chat_file_discovery.py+test_native_steward_reports.py208/208、test_maintainability_ratchet.py13/14、test_bound_owner_web_input.py70/72);仅tests/canary/test_maintainability_ratchet.py::test_current_repository_debt_is_reviewed_without_line_count_pins(1 项,因origin/main上loopx/control_plane/work_items/interaction_contract.py决策函数达 96 语句超阈值)与tests/control_plane/test_bound_owner_web_input.py::test_http_binding_discovery_preserves_duplicate_observations_for_the_typed_owner[file|sqlite](2 项,返回 200 而非 409)失败,且经在未改动origin/main@ff90543766独立 worktree 复跑确认这 3 项完全同因复现(3 failed in 17.87s),与本 PR 无关。 - 运行期类型收窄与调用方兼容风险:所有运行期
_need/_as_dict收窄仅针对原有必选或已知结构的字段,其余可选字段通过_dict_or_empty安全回退,且直接探针验证了二参_atomic_write_json替身、self.resolve(...)委派及错误消息保真;全仓mypy(17 个文件)和mypy --strict --follow-imports=silent均为 0 错误。 - 完整验证矩阵(exact head
34f71f02529f7ca6f79f277296bd42c8876d4756):module_metrics: PASS —{'lines': 1093, 'any_count': 0, 'dict_any_count': 0}(origin/main@ff90543766基线为lines=1155, any_count=69)mypy --strict --follow-imports=silent loopx/capabilities/native_chat/conversation_bindings.py& 全仓mypy: PASS —0issues(主干同文件为131errors,追踪 17 文件全过)ruff check&scripts/check_rfc_bilingual.py --base origin/main --head HEAD&git diff --check: PASS- 直接行为与 AST 探针(
_need、_atomic_write_json二参兼容、_resolve_source委派、AST 零Any): PASS loopx canary premerge --tier standard --from-git-diff --git-diff-base origin/main: PASS —ok=true, selected=13, executed=13, failures=0(含advisory_inherited_failure=1自动降级主干interaction_contract.py棘轮项)loopx check --scan-path ...: PASS —public boundary scan clean: 2 files,errors=0, warnings=0- 13 个目标
pytest套件: PASS on changed scope —1,258 passed,仅上述 3 项已在origin/main@ff90543766独立复现的既有故障除外 - 远端 CI 策略(
wait_for_ci=false/ci_policy=not_consulted):按 Goal 配置不等待也不依赖远端 GitHub Actions CI(UNVERIFIED,不阻断本地验证与评审结论)
我的整体评价 / Verdict
- Long-horizon 影响:
improved— 消除conversation_bindings.py内全部69处Any与131处mypy --strict报错,净减62行并将any_count=0, dict_any_count=0, lines=1108纳入棘轮约束,稳固核心会话绑定路径的静态类型安全与防膨胀下限。 - User-experience 影响:
not_applicable— 纯内部能力层类型硬化与棘轮基线注册,无前端或可见渲染界面变更。(visual_review为not_applicable,unverified_scope:none)。 - 可观测语义 / 代码体积 / 词表边界:
observable_semantics为equivalent,repository_reuse为reused,code_volume判为necessary(compatibility_assessment:retain,保留既有持久化和测试猴子补丁契约),change_proportionality为proportionate,default_off_isolation为isolated,authority_semantics与semantic_alignment均为aligned(candidate_decision="reuse_existing",未新增词表、持久化 schema 或权限边界)。 - 剩余风险与合并门禁:核心行为与类型契约已通过本地标准 premerge、mypy 与 1,258 项测试通过证明,唯一未在本次单独全量重放的是独立外部模块
inbox内部的未加类型边界;本 PR 为作者自有并触及capabilities/**,需按维护者授权流程再行处理合并(本次操作按要求保持 PR OPEN)。
English verdict: APPROVE exact head 34f71f0 (author-owned COMMENTED approval review); cleanly rebased onto origin/main@ff90543766 preserving #9072 comment edits, eliminates all 69 Any occurrences and 131 mypy --strict errors while slimming conversation_bindings.py (1155 -> 1093 lines) and locking a zero-Any baseline ratchet, verified passing by strict/repo mypy (0 issues across 17 files), ruff, direct behavioral probes, standard premerge canary (13/13), public boundary check, and 1258 passing pytest cases across 13 suites with the 3 failing cases independently reproduced on unmodified origin/main@ff90543766.
|
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 |
Signed-off-by: LoopX Agent <[email protected]>
34f71f0 to
fd1d5e7
Compare
…le monitor recovery, and cache private delivery scans (#9093) Signed-off-by: LoopX Agent <[email protected]>
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 #8970 rebase 至最新主干 origin/main@b927e20bfb 后的 exact head fd1d5e7004c91d00c1c7572a060430157d929ef8 完成完整审查与本地验证(审查结论:APPROVE,无 P0/P1/P2 阻塞问题;按当前任务要求保持 PR 为 OPEN,不执行合入)。
动机 / Motivation
- 受影响调用方与维护者:所有通过
loopx/capabilities/native_chat/conversation_bindings.py管理外部会话授权绑定、输入准入、Steward 执行器对齐以及原生 Peer 会话请求的控制面与运行时路径(包括project_context.py、external_conversations.py、steward_turn.py、codex_adapter.py、steward_monitor.py、queued_admission.py、transports.py),以及依赖loopx/canary/module_metric_baseline.json执行可维护性棘轮检查的维护者。 - 修改前后的具体场景与成本:在修改前(
origin/main@b927e20bfb),loopx/capabilities/native_chat/conversation_bindings.py体积达到1,155行,包含69处Any/dict[str, Any]/Mapping[str, Any]标注,在mypy --strict --follow-imports=silent下触发131个类型错误,且尚未登记进入loopx/canary/module_metric_baseline.json防回归棘轮;运行时重复的 JSON 字段收窄、绑定查找、状态回读验证与原会话请求写入分散在多个方法中,且旧分支与已合入主干的#8911在module_metric_baseline.json上存在相邻行冲突。修改并 rebase 后(fd1d5e7004c91d00c1c7572a060430157d929ef8),全文件净缩减62行至1,093行,any_count与dict_any_count均降至0,mypy --strict错误清零,并在保留#8911对external_conversations.py2k 行上限退场与#9072注释更新的同时,将conversation_bindings.py锁定在lines <= 1108, any_count = 0, dict_any_count = 0。 - 可观测改善与边界:本地验证已证明
module_metrics实测为{'lines': 1093, 'any_count': 0, 'dict_any_count': 0},mypy --strict --follow-imports=silent与ruff check均 0 错误,9 个核心绑定/Peer/棘轮测试套件跑出346/346全通过,24 套件并行全量验证跑出1,775 passed(仅 1 项并行超时在单跑时16/16全通过,2 项失败已在未改动的origin/main@b927e20bfb上同因复现),TS 控制面conversation_binding.test.ts63/63通过,Goal 绑定 CQR(cqr_83cd3d314c9b80ecc01a)与canary premerge --tier quick(3/3)全通过。若不做本次清理与棘轮登记,核心绑定模块会继续暴露在静态类型盲区与后续行数/Any 回弹风险中。 - 非目标边界:本 PR 不修改
conversation-bindings.json持久化 schema、核心裁决语义(effect_runtime_result)、报错文案、测试猴子补丁兼容接口,不修改external_conversations.py(完整保留#8911的结构调整与基线退场),也不负责修复origin/main上既有的test_bound_owner_web_input.py发现用例或interaction_contract.py既有 mypy 问题,且不授予合并权限。
改动思路 / Approach
本切片严格在既有的 loopx/capabilities/native_chat/conversation_bindings.py 与 loopx/canary/module_metric_baseline.json 所有者边界内实施结构收敛与类型硬化:调用入口仍经由 ChatConversationBindings 与 OriginalConversationRequests 暴露给既有调用方,权威状态仍归属 conversation-bindings.json 与 inbox 请求目录,所有策略/准入决策继续委托给 TypeScript effect_runtime_result(collaboration.conversation.* / collaboration.project.* / collaboration.source.* / collaboration.request.*),未新增平行控制面、配置开关或持久化字段。
在架构评估与复用权衡上(change_proportionality.architecture_assessment: retain):所抽提的 _need、_as_dict、_dict_or_empty、_dict_list、_find_binding、_require_binding、_publish_state、_verify_unchanged、_resolve_source、OriginalConversationRequests._path / _entry_path / _lock_request / _write_verified / _validate_current 均属于模块内局部辅助(local_helper),直接服务于 Python IO 包装层的运行期类型收窄与重复读/写/锁验证模板收敛,不改变任何外部契约或默认故障恢复链路(provider IO 失败或绑定变更仍立即抛出原有 ValueError / OSError)。外部 inbox 底层模块仍保持原有未强类型化签名,本 PR 仅在调用边界使用局部 TYPE_CHECKING 协议与 cast 收口,避免把 PR 范围扩散到跨子系统类型重写。
具体改动 / Changes
本次 base-to-head diff(origin/[email protected])仅涉及 2 个文件(640 insertions(+), 697 deletions(-),净减 57 行):
loopx/capabilities/native_chat/conversation_bindings.py(+635 / -697行,全文件1,155 -> 1,093行,69 Any -> 0,mypy --strict错误131 -> 0):使用object、JsonDict(dict[str, object])、JsonMap(Mapping[str, object])、TypedDict(_AgentObservation)与局部TYPE_CHECKING协议替换全部Any,收敛重复字段收窄、绑定查找、状态发布校验与原会话请求读写验证逻辑,同时完整保留#9072的注释精简与既有异常信息。loopx/canary/module_metric_baseline.json(+5 / -0行):在module_metric_ceilings中按字典序注册"loopx/capabilities/native_chat/conversation_bindings.py": {"any_count": 0, "dict_any_count": 0, "lines": 1108};rebase 解决冲突时完整保留#8911对"loopx/capabilities/native_chat/external_conversations.py"棘轮条目的移除。
规格依据(spec_basis):按 no_spec(spec_source=none)处理——本 PR 属于不改变协议 schema 与外部契约的内部类型硬化和棘轮基线锁定,无独立外部 RFC 或新增规格文档,验收标准直接对应既有会话绑定运行时契约、mypy --strict 与可维护性棘轮检查。
关键代码讲解
_need/_as_dict/_dict_or_empty/_dict_list与_find_binding/_require_binding(loopx/capabilities/native_chat/conversation_bindings.py:61-90):在object/JsonMap边界统一执行isinstance运行期类型收窄与绑定列表查找;必选字段类型不符直接抛出稳定ValueError,可选字典字段通过_dict_or_empty安全回退,既消除Any透传又维持原有异常契约。ChatConversationBindings._publish_state与_verify_unchanged(loopx/capabilities/native_chat/conversation_bindings.py:132-145):合并所有绑定修改后的条件原子写入与读回一致校验;显式区分preserve_mode=True与默认二参_atomic_write_json(self.path, state)调用,确保不破坏测试替身的二参签名兼容性,并在 provider IO 后复核绑定未被并发撤销或替换。ChatConversationBindings._resolve_source(loopx/capabilities/native_chat/conversation_bindings.py:147-156):将input_context、session_context、adopt_created_goal中的来源参数校验与拼装统一收口并经由self.resolve(...)委派,确保测试在实例上猴子补丁resolve时拦截逻辑依然生效。OriginalConversationRequests._write_verified与_validate_current(loopx/capabilities/native_chat/conversation_bindings.py:737-741、L1015-1021):收敛策略/路由/请求条目写后回读校验以及validate_turn/_complete_answer/start_guard中的collaboration.project.request与可选original_conversation_access复验流程,消除分支漂移。
对主干的风险 / Risks
无 P0/P1/P2 阻塞发现。主要兼容与基线风险分析如下:
- 调用方与测试替身兼容边界(
scope_fit与反例验证):全部生产调用方(project_context.py、external_conversations.py、steward_turn.py、codex_adapter.py、steward_monitor.py、steward_reports.py、queued_admission.py、transports.py、session_queue.py、steward_managed_mode.py)签名与返回值结构均未改变;直接行为探针已证实二参_atomic_write_json替身、preserve_mode=True路径、self.resolve(...)委派以及_need错误类型/文案均按预期工作。负向与撤销路径(如绑定撤销后OriginalConversationRequests.control拒绝revise仍允许inspect/cancel、绑定在观察期间变更时_verify_unchanged抛出ValueError)在test_chat_conversation_bindings.py与test_original_conversation_peer.py中全部通过。 - 既有主干基线失败归因隔离:
- 在 24 套件并行全量验证中(
1,775 passed, 3 failed),tests/control_plane/test_bound_owner_web_input.py::test_http_binding_discovery_preserves_duplicate_observations_for_the_typed_owner[file|sqlite](2 项,断言 409 实得 200)已在未改动origin/main@b927e20bfb独立复现(2 failed, 70 deselected in 81.28s),原因是主干_observe_local_sessions早先已改用store.iter_session_metadata()而该测试仍猴子补丁store.list_sessions,与本 PR 无关。 - 另
tests/test_native_steward_reports.py::test_report_quota_failure_continues_once_after_native_no_effects_and_available_allowance[current_context-True-False-sqlite]在-n 4高并发长跑下出现 1 次 15s 等待超时,独立单跑该测试集(-k覆盖 16 项变体)全部通过(16 passed)。 - 全仓
uv run --extra test python -m mypy(对应pyproject.toml#tool.mypy的 17 个文件)在origin/main的loopx/control_plane/work_items/interaction_contract.py:1004存在 1 项既有类型错误(conversation_bindings.py不在其中,而针对变更文件自身的mypy --strict --follow-imports=silent为 0 错误)。
- 在 24 套件并行全量验证中(
- 比例性与治理边界:改动仅限单一重构模块与棘轮登记(
change_proportionality:proportionate),无特性开关与默认行为变化(default_off_isolation:not_applicable,未更改既有默认路径),公共持久化与协议名称保持不变(authority_semantics:aligned),semantic_alignment为aligned(candidate_decision="reuse_existing",未引入新词汇或修改现有约束语义,仅登记既有模块度量棘轮)。 - 验证矩阵(exact head
fd1d5e7004c91d00c1c7572a060430157d929ef8):module_metrics& ASTAny扫描:PASS —{'lines': 1093, 'any_count': 0, 'dict_any_count': 0},AST Any count: 0(origin/main@b927e20bfb基线为lines=1155, any_count=69)uv run --extra test python -m mypy --strict --follow-imports=silent loopx/capabilities/native_chat/conversation_bindings.py:PASS —Success: no issues found in 1 source file(origin/main@b927e20bfb基线为131errors)uv run --extra test python -m mypy:FAIL (pre-existing unrelated) — 1 error onorigin/mainloopx/control_plane/work_items/interaction_contract.py:1004uv run --extra test ruff check loopx/capabilities/native_chat/conversation_bindings.py tests/canary/test_maintainability_ratchet.py:PASS —All checks passed!- 直接行为探针(
_need/_as_dict/_dict_or_empty/_dict_list、_publish_state二参与preserve_mode、_resolve_source委派):PASS - 核心绑定/Peer/棘轮 9 套件 pytest:PASS —
346 passed(test_chat_conversation_bindings.py、test_original_conversation_peer.py、test_maintainability_ratchet.py、test_chat_manager_model_adoption.py、test_private_chat_backlog_projection.py、test_chat_http_runtime_scope.py、test_lark_private_compatibility.py、test_chat_file_discovery.py、test_peer_source_store.py) - 24 套件全面回归 pytest(
-n 4):PASS on changed scope —1,775 passed, 3 failed(其中 1 项并发超时单跑16/16通过,另 2 项在origin/main@b927e20bfb同因复现) tests/control_plane_ts/conversation_binding.test.ts:PASS —63 passed, 0 failed- Goal 绑定 CQR(
change-quality verify --goal-id personal-loopx-maintenance):PASS —receipt_id=cqr_83cd3d314c9b80ecc01a,receipt_valid=true,decision=pass loopx canary premerge --tier quick --from-git-diff --git-diff-base origin/main --goal-id personal-loopx-maintenance:PASS —ok=true,direct_checks=6/6,selected_canaries=3/3(含control-plane-maintainability-ratchet-smoke.py、semantic-vocabulary-drift-smoke.py、catalog-planner-smoke.py)loopx check --scan-path ...&scripts/check_rfc_bilingual.py&git diff --check:PASS —public boundary scan clean: 2 files,errors=0, warnings=0- 远端 CI 策略(
wait_for_ci=false/ci_policy=not_consulted):按 Goal 配置不等待也不咨询远端 GitHub Actions CI(UNVERIFIED,不影响本地审查结论)。
我的整体评价 / Verdict
- Long-horizon 影响:
improved— 彻底消除conversation_bindings.py全部69处Any与131个mypy --strict错误,净缩减62行并将any_count=0, dict_any_count=0, lines=1108锁定入棘轮基线,同时在 rebase 中完整保留#8911的external_conversations.py瘦身与基线退场成果,显著降低后续长程演进的类型漂移与回归风险。 - User-experience 影响:
not_applicable— 纯内部能力模块类型收口与可维护性棘轮登记,未改变任何前端页面、交互流程或 CLI 输出格式(visual_review为not_applicable,原因:仅修改内部 Python 会话绑定模块与度量基线 JSON,无渲染或可见界面变更;unverified_scope:none)。 - 可观测语义 / 代码体积 / 词表边界:
observable_semantics为equivalent(全部签名、报错、持久化写入和猴子补丁兼容保持不变);code_volume为necessary(compatibility_assessment:retain,保留既有存储协议与二参测试替身兼容);change_proportionality为proportionate(architecture_assessment:retain);default_off_isolation为not_applicable;authority_semantics为aligned;semantic_alignment为aligned(candidate_decision="reuse_existing",未新增词表或权限边界)。 - 剩余风险与合并状态:仅外部未严格类型化的
inbox底层模块依赖边界保留局部cast收窄;本次已于 exact headfd1d5e7004c91d00c1c7572a060430157d929ef8完成 CQR 验真(cqr_83cd3d314c9b80ecc01a)与本地预合并门禁验证,按本次任务约束保持 PR #8970 为OPEN,不执行合并。
English verdict: APPROVE exact head fd1d5e7 (author-owned COMMENTED approval review); cleanly rebased onto origin/main@b927e20bfb preserving #8911 external_conversations ceiling retirement and #9072 comment edits, eliminates all 69 Any occurrences and 131 mypy --strict errors while slimming conversation_bindings.py (1155 -> 1093 lines) and locking a zero-Any baseline ratchet, verified passing by strict mypy, ruff, direct probes, 346 core pytest cases, 1775/1778 broader pytest cases (with the 1 timeout passing 16/16 standalone and the 2 bound_owner failures reproduced identically on origin/main@b927e20bfb), 63 TS control-plane tests, Goal-bound CQR (cqr_83cd3d314c9b80ecc01a), public boundary check, and quick premerge canary (3/3); left OPEN per task instructions.
loopx-agent
left a comment
There was a problem hiding this comment.
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
Reviewed head fd1d5e7004c91d00c1c7572a060430157d929ef8
Reviewer: model_agent · gpt-6.2-sol · OpenAI (runtime_reported, max)
请修正新 Protocol 和现有 ChatRuntimeController 的兼容性。运行对照通过的路径无需改动。
动机 / Motivation
在 App 或原生聊天里回到已绑定会话的人,需要在同一条会话恢复未完成的工作。维护这些入口的人也必须能用类型检查确认它们调用同一套实际支持的接口。
原模块混用宽泛字典和重复的读取代码。它很难提示哪个字段由会话、授权或请求 owner 提供。当前尝试在保留原始会话、排队和结果归还的同时,把这些边界收成明确类型。
本地运行对照观察到同样的连接、停止、重放和回执。当前模块自身的类型诊断消失,但两个实际入口在传入现有 controller 时仍被新的类型声明拒绝。
当前变更只重整 Python 适配器和模块指标,处理会话授权、请求及结果的现行 owner 继续负责其生产判定。
改动思路 / Approach
现有 TypeScript Core 决定授权和原会话请求身份。Python 负责有序锁、读取以及原 host 启停,类型声明应准确描述实际依赖。 本 PR 可独立完成会话绑定适配器的类型收敛,验收范围包含已部署 API 的两处真实 Python 入口。 模块保留源、Goal、binding、request、Session 的栅栏顺序。未确认 stop 仍让用户用原 binding 重试。类型检查需要由调用者的真实类型覆盖这条链。
具体改动 / Changes
两个路径共 +640 / −697。生产模块减少 62 行,另补零 Any 的模块指标条目。
依据 docs/architecture/rfcs/app-conversation-and-async-inbox-v0.md(b927e20bfbe60817570bceb8654e2bfbc96abadf)。retained-stop 已实现,撤权后可用原 binding 重试确认。original-route 已实现,受理与归还仍核对现行 scope。replay-without-rerun 已实现,恢复沿用原请求和持久结果。 接受的 RFC
关键代码讲解
-
_BindingController是两个正式入口使用的新 Protocol。当前可写的project_contexts声明使实际 controller 无法通过检查。 接口 · Runtime · HTTP -
_stop_revoked_binding用同一 helper 读取未终止的队列和活跃 Turn,只停止受该 binding 约束的工作。未确认时,恢复仍留在原 binding。 停止与恢复 -
OriginalConversationRequests._fenced复用已有 source 和 binding 栅栏。原工作在写入及重放时保留 requester、recipient 与当前授权。 并发边界 · 提交与重放
对主干的风险 / Risks
新 _BindingController 把 project_contexts 声明为可写的 _ProjectContexts 属性。真实 ChatRuntimeController 把该属性定型为 ChatProjectContexts。mypy 会对可写 Protocol 属性做不变性检查,因此入口传入真实 controller 时类型不匹配。 使用同一 strict 命令审查模块和两个真实入口,目标模块从 73 个诊断降到 0;当前两个真实调用点仍报 arg-type。基线相同调用点的诊断是 no-untyped-call。
把协议中只读使用的 project_contexts 声明为 @Property,或使用现有调用方真正满足的窄接口。用同一命令覆盖目标模块与两个真实入口,确认调用点的 arg-type 消失。隔离源码验证只改为只读 property 即消除两处诊断。 复核命令为 python -m mypy --strict --follow-imports=silent loopx/capabilities/native_chat/conversation_bindings.py loopx/chat_runtime.py loopx/chat_server.py。
同一四份聚焦测试在两版各 149 passed;原会话 peer 额外用例中 FIFO、撤权、同意图恢复、已保存结果归还和最终读回均验证。刻意去掉活跃 Turn 分支时,既有 HTTP 复测两组由应有的 400 变为 200,说明该测试能发现丢失 stop recovery。 额外用例在 base 和 head 都是 110 pass / 2 fail。两个红项向 list_sessions 注入重复值,但两版实际发现入口都已读 iter_session_metadata。保留旧用例结果,并在实际读取点另做四组配对验证:普通发现 HTTP 200 且返回一个会话,重复观测 HTTP 409 且无列表。
标准预合并检查有一项失败:interaction catalog 的 IP-030 没列出 steward_memory。在精确基线和当前提交直接运行同一 smoke,断言相同,且本次 diff 没有修改 catalog 或 namespace 配置。
语义与 CI 对齐
沿用已有会话授权及请求状态词汇。标准验证中的 catalog 红项在可比基线确认,当前需要修改的是该适配器的静态类型合约。
我的整体评价 / Verdict
运行对照证明已验证范围内的原会话恢复和用户读回保持。请先修好两个调用点使用的类型合约,再提交新 head 复审。检查了 native_chat 模块与现有 Settings 由 HTTP 提供的读回。当前只修改后端代码与模块指标基线,页面组件、卡片模板和展示格式无改动。当前验证使用真实本地 Core HTTP / 存储及合成 host,未验证实际安装包、真实 Lark 账号链路和远端宿主。
English verdict: REQUEST_CHANGES. The new writable project_contexts protocol member rejects the real controller at both production call sites. A read-only property removes both diagnostics.
| store: ChatSessionStore | ||
| coordination_runtime_root: Path | ||
| registry_path: Path | None | ||
| project_contexts: _ProjectContexts |
There was a problem hiding this comment.
[P2] Preserve the real ChatRuntimeController caller contract
这里把 project_contexts 声明成可写的 _ProjectContexts。两处正式调用传入的是带 ChatProjectContexts 属性的 ChatRuntimeController。mypy 对可写 Protocol 成员做不变性检查,所以 chat_runtime.py:924 和 chat_server.py:1585 都报 arg-type。当前构造器只读这个对象。把 Protocol 成员声明为只读 property 后,用同一条 strict 命令检查模块及两个调用方,两处诊断均消失。
…very lookups (#9096) Signed-off-by: LoopX Agent <[email protected]>
…-execution-pr-20261114 Recover the original Session and Turn from a confirmed Chat task
…rrupt observations (#9098) Signed-off-by: LoopX Agent <[email protected]>
…y event summaries (#9100) Signed-off-by: LoopX Agent <[email protected]>
Signed-off-by: LoopX Agent <[email protected]>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google DeepMind · self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
已针对 PR #8970 exact head 479be65dc325946c9edc554e3f476ba7908df5fe 完成完整只读核查、调用方类型复核与等价验证(审查结论:APPROVE,前次 fd1d5e7004 遗留的 P2 阻塞问题已在 479be65dc3 实质修复,无未解决 P0/P1/P2 代码问题;遵循只读要求保持 PR OPEN,不合并且不代为关闭旧评论线程)。
动机 / Motivation
在 App 或原生聊天中围绕已绑定会话执行授权控制、排队准入与结果归还的协同控制路径(如 ChatRuntimeController、chat_server.py),以及执行零 Any 与模块行数上限校验的可维护性棘轮与类型检查调用方。
合入前基线(8e9a28a866)的 conversation_bindings.py 达 1,155 行并含 69 处宽泛 Any 标注,同时前一待审版本 fd1d5e7 把 _BindingController.project_contexts 声明为可写属性导致 chat_runtime.py 与 chat_server.py 在严格类型检查下均报出 arg-type 冲突;修正至 479be65 后,module_metrics 收敛至 1,094 行与 0 个 Any,并改为只读 @Property 与实参兼容。
单文件 mypy --strict 通过且两处生产调用方的 OriginalConversationRequests arg-type 冲突归零(三文件严格错误从 49 降至 47,较主干 eb552a8 的 129 显著收敛),同时 372 项聚焦 Python 测试、75 项 TS 测试、可维护性棘轮及等价运行探针全部维持行为等价。
本 PR 仅收敛 Python 传输适配层类型边界、抽取重复窄化辅助并更新模块指标基线,不改变 TypeScript 控制面授权与生命周期语义,也不负责清理 chat_runtime.py 与 chat_server.py 其余 47 个既有严格类型错误或主干既有的重复观测用例失败与陈旧 PR base 引用。
若不落地该整理并保持只读协议一致性,每次涉及外部会话绑定与原生 Peer 请求的改动要么继续被宽泛 Any 掩盖结构错误,要么因接口协议与真实 ChatRuntimeController 协变语义冲突而阻碍严格检查推广。
改动思路 / Approach
入口与权威边界:外部会话绑定与原生 Peer 请求的执行仍由 chat_runtime.py(ChatRuntimeController)和 chat_server.py 传入真实宿主控制器驱动 ChatConversationBindings 与 OriginalConversationRequests,权限策略、准入围栏与协作状态仍由既有的 TypeScript/Python 控制面组件与 collaboration_goal_scope、source_policy_fence、effect_runtime 负责。
通过 TypedDict/TypeAlias(JsonDict、JsonMap)与只读 @Property Protocol(_BindingController)消除隐式 Any 并匹配真实调用方只读使用边界,同时将重复字典校验与锁定写入收敛为局部私有窄化辅助,既保住 TypeScript 核心决定权,又无需新增第二套决策层或同步状态。
仅重构 loopx/capabilities/native_chat/conversation_bindings.py 内部类型与私有辅助并在 module_metric_baseline.json 记录零 Any 与 1,108 行天花板,不改变公开 HTTP/CLI 接口、持久化格式或未涉及其余文件的严格类型 debt。
关于差异范围与旧审查线程的独立核实:虽然 GitHub UI 因 PR base SHA 仍停留在较早的 b927e20bfbe60817570bceb8654e2bfbc96abadf(mergeState=BEHIND)而显示 27 个文件 +2831/-831,但 479be65dc3 已合并 8e9a28a866,实测 git diff origin/main...479be65dc3 与 GitHub eb552a8bb0...479be65dc3 均仅包含 2 个文件(conversation_bindings.py +636/-697 与 module_metric_baseline.json +5/-0)。在 fd1d5e7004 上由评审提出的 P2 发现(discussion_r4633615936)指出 _BindingController.project_contexts 声明为可写属性会导致 ChatRuntimeController 触发 arg-type 失败;当前 479be65dc3 已改为 @property def project_contexts(self) -> _ProjectContexts: ... 且未改动任何运行时可执行 AST(剔除 TYPE_CHECKING 后与 fd1d5e7004 AST 完全一致)。
具体改动 / Changes
本 PR 相对 origin/main 共涉及 2 个文件(+641/-697,净减 56 行;其中 conversation_bindings.py 从 1,155 行、69 处 Any 降为 1,094 行、0 处 Any),无外部书面协议变更(spec_basis = no_spec:本次重构保持外部会话绑定与 Peer 请求既有契约等价,已核对相关 RFC docs/architecture/rfcs/app-conversation-and-async-inbox-v0.md 未改变持久化或 HTTP schema)。
loopx/capabilities/native_chat/conversation_bindings.py(+636 / -697,生产代码):以JsonDict = dict[str, object]、JsonMap = Mapping[str, object]、类型变量_T、TYPE_CHECKING专用协议(_ProjectContexts、_BindingController、_NativePeerSession等)及精确TypedDict替代全部 69 处Any;提取共享运行时窄化函数(_need、_as_dict、_dict_or_empty、_dict_list、_find_binding、_require_binding等)与类内辅助(_publish_state、_verify_unchanged、_resolve_source、_entry_path、_lock_request、_write_verified、_policy、_observation、_recipient、_validate_current等)收拢重复字典检查与锁/写入样板代码,并在479be65dc3将_BindingController.project_contexts收紧为只读@property以匹配真实ChatRuntimeController。loopx/canary/module_metric_baseline.json(+5 / -0,构建与棘轮基线):注册loopx/capabilities/native_chat/conversation_bindings.py的可维护性基线条目(any_count: 0、dict_any_count: 0、lines: 1108),以防后续回归。
关键代码讲解
_BindingController.project_contexts(loopx/capabilities/native_chat/conversation_bindings.py:37-42):在TYPE_CHECKING块下声明控制器最小契约,project_contexts于479be65dc3修正为只读@property def project_contexts(self) -> _ProjectContexts: ...;因 Python mypy 对 Protocol 普通属性按可写成员执行不变性检查,而ChatRuntimeController.project_contexts为ChatProjectContexts实例,改为只读属性后直接消除chat_runtime.py:924与chat_server.py:1585两处arg-type诊断。_need/_as_dict/_dict_or_empty/_dict_list(loopx/capabilities/native_chat/conversation_bindings.py:62-84):替代先前isinstance(..., dict)后的隐式Any访问与分散重复报错;direct_probes_8970验证对合法dict保留透传语义,对类型不匹配输入保持失败快速拒绝(抛出TypeError)。ChatConversationBindings._publish_state(loopx/capabilities/native_chat/conversation_bindings.py:133-147):统一封装加锁后的状态重读、_resolve_source调用以及与既有双参/多参_atomic_write_json签名(含测试 monkeypatch 兼容)的发布路径,在保持既有 File/SQLite 持久化和错误提示一致的同时消除重复写入片段。OriginalConversationRequests._validate_current与execute(loopx/capabilities/native_chat/conversation_bindings.py:1016-1094):将请求准入校验、策略围栏校验、工作区写入和结果归还收束到明确返回类型与私有辅助方法中,保障并发变更阻断与中断恢复行为与重构前等价。
对主干的风险 / Risks
未发现当前 exact head 479be65dc3 引入的 P0/P1/P2 代码阻塞缺陷;兼容性、边界探针及主干合入前外部限制披露如下:
- 调用方契约、AST 等价与正反边界验证:
scope_fit检查确认_BindingController、_publish_state、_validate_current与execute均由chat_runtime.py与chat_server.py直接在生产路径调用;fd1d5e7004至479be65dc3剔除TYPE_CHECKING后运行时 AST 完全一致;direct_probes_8970确认_publish_state在仅接受位置参数的简化_atomic_write_json测试替身下仍可回退调用,且窄化辅助在畸形输入与正常输入下行为符合契约。未开启新特性开关(default_off_isolation与authority_semantics均属not_applicable),无新增状态词表或门控标签(semantic_alignment为not_applicable)。 - 验证矩阵与既有失败归因(exact head
479be65dc325946c9edc554e3f476ba7908df5fe):mypy --strict --follow-imports=silent loopx/capabilities/native_chat/conversation_bindings.py:PASS —Success: no issues found in 1 source file。- 三文件联合严格类型检查(
conversation_bindings.py+chat_runtime.py+chat_server.py):主干origin/main@eb552a8bb0报 129 errors in 3 files;修复前fd1d5e7004报 49 errors in 2 files(含chat_runtime.py:924与chat_server.py:1585两处arg-type);当前479be65dc3降至 47 errors in 2 files,conversation_bindings.py维持 0 错误且上述两处OriginalConversationRequests冲突完全消除(余下 47 处属既有未重构代码)。 ruff check与可维护性棘轮:RuffAll checks passed!;module_metrics实测lines: 1094(<=1108)、any_count: 0、dict_any_count: 0,collect_module_metric_findings为空列表,control-plane-maintainability-ratchet-smoke.py返回ok: true(unreviewed_count: 0、stale_exception_count: 0、magnitude_regression_count: 0)。- 聚焦 Python 与 TypeScript 回归测试:PASS — 12 项覆盖绑定、原始会话 Peer、HTTP 运行时域、私聊待办、经理模型采用、Lark 兼容、文件发现、Peer Source Store 与普通项目的 pytest 套件共 372 passed in 105.00s(且于 merge-base
8e9a28a866对跑核心 2 套件取得 157 passed in 187.14s 等价);TS 侧conversation_binding.test.ts(63 passed)与steward_managed_mode.test.ts(12 passed)通过。 tests/control_plane/test_bound_owner_web_input.py:FAIL (pre_existing_unrelated) —70 passed, 2 failed in 31.98s,两项失败均为test_http_binding_discovery_preserves_duplicate_observations_for_the_typed_owner[file]与[sqlite](断言200 == 409);于未改动的origin/main@eb552a8bb0同命令复跑得到完全相同的 2 failed (200 == 409), 70 deselected in 3.68s,归因于主干既有问题,与本 PR 无关。- 其余预检与环境边界:
loopx check --scan-path ...(2 文件公私边界 clean)、scripts/check_rfc_bilingual.py、git diff --check、py_compile、module_ceiling_colocation与catalog-planner-smoke.py均 PASS;canary premerge中的examples/semantic-vocabulary-drift-smoke.py因隔离复核 worktree 未安装 npmtypescript包未执行完整 TS AST 扫描(已人工核对全部 diff 无任何新词表、枚举或Literal变动)。git merge-tree --write-tree origin/main 479be65dc3退出码 0,无文本冲突;但注意本地origin/main在eb552a8bb0曾微调第 442 行一处注释(当前分支沿用8e9a28a866文本),且远端 PR 仍存在 1 条来自fd1d5e7004的未解决 outdated 评审线程PRRT_kwDOStEbEs65qYnv与陈旧 PR baseb927e20bfb(mergeState: BEHIND),按 Goal 设置wait_for_ci=false(ci_policy=not_consulted),远端 CI 未等待亦未依赖。
我的整体评价 / Verdict
- Long-horizon 影响:
preserved— 保留既有外部会话绑定、并发校验、排队准入、主动中断与原始会话结果归还语义,372 项 Python 回归测试与基线8e9a28a866157 项对照及运行时 AST 验证均未出现状态丢失、重试退化或副作用漂移。 - User-experience 影响:
preserved— 外部会话授权读写、HTTP/Lark 绑定发现及原有错误反馈均与主干保持等价,未新增交互轮次或改变出错恢复路径。(visual_review:not_applicable— 本 PR 相对当前主干与合入基线的真实净改动仅涉及后台 Python 模块 conversation_bindings.py 与指标配置文件 module_metric_baseline.json,不改变任何前端渲染或页面交互(GitHub 页面因陈旧基准 b927e20 显示的 3 个前端文件均已随 8e9a28a 合入 main),故视觉审查为不适用。;unverified_scope:none)。 - 可观测语义 / 代码体积 / 词表边界:
observable_semantics为equivalent(对照基线8e9a28a866与fd1d5e7004已确认类型收紧与协议只读修正不改变任何运行时对外接口或持久化读回结果);code_volume为necessary(compatibility_assessment:retain,保留_atomic_write_json旧测试兼容签名及既定外露接口,同时净减 56 行代码并将Any清零且锁定于module_metric_baseline.json);change_proportionality为proportionate(architecture_assessment:retain);default_off_isolation与authority_semantics为not_applicable;semantic_alignment为not_applicable(未新增或改写任何共享状态词表、错误码或协议字段)。 - 剩余风险与合入前提示:
479be65dc3代码层面的审查条件已满足,但合并前仍需项目维护者按需处理两项流程阻塞——关闭/处置已过时的 GitHub 审查线程PRRT_kwDOStEbEs65qYnv、刷新落后基准(b927e20bfb->main)并留意主干既有的test_http_binding_discovery_preserves_duplicate_observations_for_the_typed_owner基线红项。遵循本次只读审查边界,PR #8970 保持OPEN。
English verdict: APPROVE exact head 479be65 (author-owned COMMENTED approval review); confirms _BindingController.project_contexts is now a read-only @Property eliminating both ChatRuntimeController arg-type failures in chat_runtime.py:924 and chat_server.py:1585 while shrinking conversation_bindings.py to 1,094 lines with 0 Any and registering its maintainability baseline, verified by mypy --strict, ruff, maintainability ratchet, 372 focused Python tests, 75 TS tests, base equivalence checks on 8e9a28a, and pre-existing attribution of test_bound_owner_web_input.py duplicate-observation failures on origin/main (leaving outdated GitHub thread dismissal and stale PR base handling to the maintainer).
|
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)
[P2] 原会话管理页会漏掉读回期间刚完成的修订结果。 修订完成与一次管理读取交错时,候选会把合法结果从响应里滤掉。对每份已读结果重新获取原请求,或通过同一所有者读取一致的请求和结果快照。用 File 和 SQLite 覆盖此交错。 候选结果读取 基线逐条校验 Core 修订核对
动机 / Motivation
在原项目会话管理委派并读回结果的本地所有者。 收紧 Native Chat 绑定适配层的类型,保留来源隔离、原会话与已有结果读回。 管理读取得修订 1 后,在查询其队列 Turn 期间,原来源合法完成修订 2 并写入新结果。 同一管理响应枚举到修订 2 的文件,却用修订 1 的请求校验并静默略过。该次响应只显示修订 1,下一次读取显示两者。 使用真实本地 CLI/HTTP、原请求、队列与结果存储,模型回复采用确定性 transport。正式桌面 App、线上 Feishu 和真实模型未验证。未查询托管 CI。 旧评审指出的 project_contexts 可写协议与两个生产调用方不兼容,已通过只读 property 修复。单模块 strict mypy 通过,三文件检查从 49 项降至 47 项,减少的正是原报告中的两处诊断。 协议修复 旧评审
改动思路 / Approach
保留 TypeScript Core 的决策与 Python 原适配层的 IO,复用原 binding/source/Goal/request fences 与结果存储。 本 PR 的实际生产边界在 loopx/capabilities/native_chat/conversation_bindings.py。管理读回将请求读取提前到结果枚举前,校验后来出现的结果时沿用了旧请求。 原来源锁 结果写入
具体改动 / Changes
精确头 479be65。GitHub 返回的 base 比当前主干共同祖先旧,显示 27 个文件。按共同祖先 8e9a28a 对照,实际新增两个 DCO 提交,改动绑定适配器及指标目录,新增 641 行、删除 697 行。精确头绑定、HTTP 和 backlog 131 项通过,原会话 Peer 40 项通过,额外项目和旧记录 7 项通过。 真实 CLI/loopback 用例验证绑定授权、准确 Goal instance、原 Session 和原发件人结果读回。 CLI 用例 既有修订恢复
对主干的风险 / Risks
revision-result-readback。同一交错在 File 与 SQLite 上,基线两项通过,精确头及本地整合树各两项失败,单行恢复对照两项通过。 基线和单行恢复对照在同一次管理读取显示 [1, 2]。候选及整合对照只显示 [1],紧接着再读才显示 [1, 2]。复用 test_original_conversation_peer.py 的 File/SQLite fixture。初始修订完成后,在 management_view 查询队列 Turn 时提交修订 2 并等待结果完成。断言该次管理读取与下一次读取都含修订 [1, 2]。 另与主干 5e2c896 在指标 JSON 上有文本冲突。仅在隔离的整合树保留主干删除和本 PR 新预算后,原有套件 133 项通过,交错仍失败。使用真实本地 CLI/HTTP、原请求、队列与结果存储,模型回复采用确定性 transport。正式桌面 App、线上 Feishu 和真实模型未验证。未查询托管 CI。
我的整体评价 / Verdict
REQUEST_CHANGES。 保留类型修复,恢复原管理路径对合法新结果的读回。请保留已提交的修订与结果原路径,并用 File 和 SQLite 在一次交错读取里验证修订 1 和 2 同时可见。
English verdict: REQUEST_CHANGES at 479be65. Both reported type diagnostics are resolved. The owner management read can omit a newly committed revision result on File and SQLite. Restoring the canonical request read fixes the reproduced omission.
Problem and result
The conversation-binding refactor removed broad
Anyannotations, but its new writable_BindingController.project_contextsmember rejected the realChatRuntimeControllerin bothchat_runtime.pyandchat_server.py. The protocol now declares the member as a read-only property, matching how the adapter actually uses it. This addresses the production-caller review finding.The original refactor remains: typed controller/project/session and inbox interfaces, shared binding validation and persistence helpers, and a zero-
Anymaintainability baseline. The resulting module has 1,094 lines and noAnyannotations. The scope is the Python transport adapter; TypeScript Core retains authorization, request identity and lifecycle decisions. No new state vocabulary, configuration, frontend journey or permission is introduced.The latest main (
8e9a28a866da06cc6fd63e78709910fe35dad564) and the original PR head (fd1d5e7004c91d00c1c7572a060430157d929ef8) were integrated with a normal merge, preserving source history. The original branch was advanced without a force push. Final head:479be65dc325946c9edc554e3f476ba7908df5fe.Validation
python -m mypy --strict --follow-imports=silent loopx/capabilities/native_chat/conversation_bindings.py: passes.loopx/chat_runtime.pyandloopx/chat_server.pyreports 49 errors before this correction and 47 afterward. Exactly the two controller-to-OriginalConversationRequestsincompatibilities disappear; no diagnostic is added. The remaining 47 errors are outside this correction. The three-file strict check does not pass.pytest -q tests/test_chat_conversation_bindings.py tests/test_chat_http_runtime_scope.py tests/test_private_chat_backlog_projection.py: 131 passed. These exercise local binding, HTTP, revocation, queued/active stop recovery and readback, including the existing File/SQLite fixtures and synthetic hosts. Installed App, live Lark and remote-host adoption were not tested.TYPE_CHECKINGblock from the original and corrected modules produces identical runtime ASTs. The correction changes no executable runtime statements.Anymaintainability ratchet, semantic-vocabulary scan, bilingual RFC diff check and the two-file public-boundary scan pass.loopx canary premerge --from-git-diff --git-diff-base origin/main: catalog 5/5, risk checks 7/8, direct checks pass. The remaining failure isinteraction-pattern-catalog-smoke.py: IP-030 omitssteward_memory. The same assertion fails on unmodified main at8e9a28a866da06cc6fd63e78709910fe35dad564. This is an outstanding merge-validation limitation, not a passed gate.The bounded refactoring pass is applied in the existing adapter and corrected against both actual callers. Further unrelated type errors and catalog cleanup are deferred to their owning work. This proposal is complete for independent re-review; it remains open, with no self-merge or readiness claim.
GitHub readback limitation: the PR still reports base SHA
b927e20bfbe60817570bceb8654e2bfbc96abadfformainand therefore shows 27 files. The actual main ref is8e9a28a866da06cc6fd63e78709910fe35dad564; the exact main-to-head comparison contains only the intended 2 files. Treat the stale PR baseline as a separate review/merge limitation; no branch retarget or force update was performed.