Skip to content

refactor(native_chat): split steward_turn into zero-Any sub-1000-LOC modules - #9417

Merged
huangruiteng merged 8 commits into
mainfrom
codex/slim-steward-turn-zero-any-20261125
Nov 28, 2026
Merged

huangruiteng merged 8 commits into
mainfrom
codex/slim-steward-turn-zero-any-20261125

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Rebased onto origin/main (2302e42d9cad35a8a4150e24496ffecfbfdce8cb), preserving PR #9438 (report_turn_prompt_authority, raw_prompt=True), PR #9474 (governance_turn_prompt_authority(dict(authority)), allow_completion=False, _GOVERNANCE_CONTRACT_REMINDER, allow_completion=bool(managed_turn_active or steward_advancement)), PR #9058 (_build_selected_parser("turn"|"quota"), source_chat_observation._read_json), PR #9515 (clear_steward_monitor_check_hints in steward_reports.py, journal_status != "stopped" in steward_turn_recovery.py), and PR #9513 (validation_stage in {"host_result_contract", "task_postcondition"} in steward_turn_recovery.py), while resolving all R2 (4704718195) and R3 (6090400339 / 7222294812) findings:

  • steward_turn.py (968 LOC, 0 AST Any, 0 # type: ignore, 0 # noqa): StewardTurnHost public facade delegating run_turn to execute_steward_turn and using steward_monitor_for / monitor_store_for.
  • steward_turn_common.py (625 LOC, 0 AST Any, 0 # type: ignore, 0 # noqa): shared typed protocols (StewardStoreProtocol.messages(..., *, strict: bool = False), StewardControllerProtocol with codex_bin and codex_home, StewardTurnHostProtocol, ExecutionReportServiceProtocol, MonitorRestartCarrier), JSON narrowing helpers (as_dict, as_optional_dict, as_mapping, as_dict_list), and monitor boundary adapters (monitor_controller_for, steward_monitor_for, monitor_store_for).
  • steward_turn_context.py (585 LOC, 0 AST Any, 0 # type: ignore, 0 # noqa): prompt assembly (governance_turn_prompt_authority, report_turn_prompt_authority), _build_selected_parser("quota"), followup context projection, and scheduled task admission.
  • steward_turn_execution.py (688 LOC, 0 AST Any, 0 # type: ignore, 0 # noqa): execute_steward_turn orchestration, _build_selected_parser("turn"), steward_monitor_for(host.controller), candidate validation, and native result persistence.
  • steward_turn_recovery.py (904 LOC, 0 AST Any, 0 # type: ignore, 0 # noqa): failure observation, selection/launch recovery (with #9515 journal_status != "stopped" and #9513 validation_stage in {"host_result_contract", "task_postcondition"}), _build_selected_parser("turn"), and monitor restart handling.
  • steward_reports.py (993 LOC, 0 AST Any, 0 # type: ignore, 0 # noqa) & extensions/lark/steward_reports.py (401 LOC, 0 AST Any, 0 # type: ignore, 0 # noqa): Zero-Any narrowed report callers wired through monitor_controller_for, steward_monitor_for, clear_steward_monitor_check_hints, and source_chat_observation._read_json.
  • session_calendar_tasks.py (396 LOC, 0 AST Any, 0 # type: ignore, 0 # noqa): narrowed SessionCalendarTasks aligned with _StewardReportsBase.subscription and ManagedSessionReports.frontier (0 strict mypy errors vs 43 on 7f7297a790 / 82 on a7242afd94), guarding ManagedSessionTurn.submit None results via as_optional_dict(submitted), bool(created).
  • packages/loopx-core/prepare.py (281 LOC, 0 AST Any) & distribution tests (tests/test_core_workspace_distribution.py, tests/test_core_distribution.py): includes steward_turn_{common,context,execution,recovery}.py in WORKSPACE_MODULES so all 5 steward_turn* modules ship exclusively with loopx-workspace and are excluded from loopx-core.
  • tests/test_steward_turn_controller_contract.py (449 LOC, 0 AST Any, 0 # type: ignore, 0 # noqa): verifies (StewardStoreProtocol, ChatSessionStore, "messages"), session_calendar_tasks.py (== []), StewardTurnHost / Lark transport protocols (0 protocol/call-site errors on owner_attention.py, filtering pre-existing untouched chat_store._read_json re-export debt from the <= 3 / <= 22 ceilings), and prompt slimming.

loopx/canary/module_metric_baseline.json, loopx/capabilities/native_chat/steward_monitor.py, and loopx/capabilities/periodic_report/private_generation.py are unchanged.

Verification (HEAD bbfc4ec9913ccb84d8743125e3c83ef6b9398cf9 on origin/main 2302e42d9cad35a8a4150e24496ffecfbfdce8cb)

  • LOC & AST discipline: All 9 Steward/Turn/Report/Calendar/Contract .py files < 1,000 LOC (968, 625, 585, 688, 904, 993, 396, 401, 449), 0 AST Any, 0 # type: ignore, 0 # noqa across all 12 changed files; 8/8 DCO-signed commits; clean git merge-tree --write-tree origin/main HEAD.
  • Lint & Typecheck:
    • ruff check on all 12 changed files: All checks passed!
    • mypy --strict --no-incremental --follow-imports=silent on all 9 typed files: Success: no issues found in 9 source files
    • mypy --config-file pyproject.toml --follow-imports=silent: Success: no issues found in 17 source files
    • npm run typecheck:control-plane: passed
  • Pytest:
    • Unfiltered pytest -v tests/test_steward_turn_controller_contract.py: 5 passed (0 failed, 0 skipped)
    • pytest -n 6 -q across tests/test_steward_report_recovery_and_validator.py, tests/test_native_steward_reports.py, tests/capabilities/test_steward_monitor_contract.py, tests/test_managed_session_calendar_tasks.py, tests/test_native_steward_turn_host.py, tests/test_lark_steward_reports.py, tests/test_lark_steward_report_route.py, tests/test_doctor_installation_scope.py, tests/test_distribution_runtime_identity.py, and tests/architecture/: 2416 passed (0 failed, 0 skipped).
    • pytest -v tests/test_core_distribution.py -k test_core_staging_excludes_workspace_and_reuses_kernel_bytes: 1 passed, 59 deselected.
  • Packaging parity (built loopx-core + loopx-workspace wheels from matching source):
    • Clean Core-only venv: find_spec returns None for all 5 steward_turn* modules and steward_monitor, loopx doctor --installation-only ok: true, loopx chat --help exits 2.
    • Core + Workspace venv: all steward_turn*, steward_monitor, steward_reports, and session_calendar_tasks modules import cleanly, loopx doctor --installation-only ok: true, loopx chat --help exits 0.
    • Workspace uninstall parity: find_spec returns None for all 5 steward_turn* modules, loopx doctor --installation-only ok: true, loopx chat --help exits 2.
    • tests/test_core_workspace_distribution.py: 7 passed; tests/test_core_distribution.py -k "test_core_staging_excludes_workspace_and_reuses_kernel_bytes or test_installed_core_identity_help_and_unavailable_workspace": 2 passed, 58 deselected.
  • Boundaries, CQR & Premerge:
    • scripts/check_rfc_bilingual.py --base origin/main --head HEAD: passed; loopx check --scan-path ...: errors=0, warnings=0 (65 files).
    • Goal change-quality: receipt cqr_c5fe7b1210e11ffc6b55 (status="valid", decision="pass", scope_fingerprint="c5fe7b1210e11ffc6b55b6a4ef8ed73aaa5703953073dfc0379b8a1373162d7f").
    • loopx canary premerge --from-git-diff --git-diff-base origin/main --tier standard: gate.status="passed", merge_gate_passed=true (6/6 direct checks, 2/2 catalog canaries, 8/8 risk-profile smokes, 0 failures, 0 manual holds).

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

English verdict: APPROVE
Reviewed head: b045198bc289bd7232716d223038763eabdf029c
Reviewer: model_agent · Gemini · Google · self_reported · effort_unavailable

动机 / Motivation

Native steward chat runtime (loopx/chat_runtime.py), managed-mode hosts (steward_managed_mode.py), background monitors (steward_monitor.py), and periodic report recovery (steward_reports.py) invoking StewardTurnHost and its admission/recovery/execution helpers.

Before this PR, loopx/capabilities/native_chat/steward_turn.py stood at 1,992 LOC (8 lines under the 2,000-LOC threshold) with 156 Any references—the highest Any count in the repository—coupling Protocols/JSON narrowing, context/prompt normalization, turn execution, and monitor/report settlement recovery in a single file. At exact head b045198bc289, PR #9417 splits the bridge into five strictly typed modules all under 1,000 LOC (steward_turn.py 959, steward_turn_common.py 576, steward_turn_context.py 560, steward_turn_execution.py 687, steward_turn_recovery.py 896), eliminates all AST Any references (156 -> 0), preserves all 39 StewardTurnHost methods (missing=0) and #9355 / baseline files untouched, and passes all 3,351 steward, architecture, and ratchet pytest cases.

All 5 steward_turn*.py modules pass mypy --strict --follow-imports=silent (0 issues), mypy --follow-imports=normal introduces 0 errors inside steward_turn*.py, bare python -m mypy --no-incremental passes 17/17 strict repo files, ruff check passes 5/5, pytest -n 6 across 29 steward/architecture/ratchet test suites passes 3,351 passed, 0 failed, 0 skipped, and canary premerge passes 6/6 direct + 2/2 catalog checks with 0 failures.

边界与非目标:Does not alter runtime Turn admission, lease locking, report settlement, or prompt contracts; does not edit #9355 files (workbench_ledger.py, chat_manager.py, inspection.py) or module_metric_baseline.json, and does not refactor legacy [tool.mypy]-excluded caller modules (chat_runtime.py, steward_managed_mode.py, steward_reports.py).

改动思路 / Approach

Splits steward_turn.py along cohesive lifecycle phases (steward_turn_common.py Protocols and JSON narrowers, steward_turn_context.py context/actions/prompt finalization, steward_turn_execution.py turn execution loop, steward_turn_recovery.py monitor restart and stopped/frozen report settlement) while retaining StewardTurnHost and dynamic monkeypatch seams (report_turn, normalizers, host methods) on steward_turn.py.

Scoped strictly to 5 Python files under loopx/capabilities/native_chat/steward_turn*.py (959/576/560/687/896 LOC, 0 AST Any, 0 # type: ignore, 0 bare os.O_NOFOLLOW), leaving workbench_ledger.py, chat_manager.py, inspection.py, module_metric_baseline.json, and outer caller modules untouched.

具体拆分以显式 Protocol 接口(StewardControllerProtocol、StewardStoreProtocol、StewardBindingsProtocol、StewardManagedProtocol、StewardTurnHostProtocol)与运行时类型窄化函数(as_dict、as_mapping、as_optional_dict、as_str、as_optional_str、as_int)替代 Any,同时保留 StewardTurnHost 全部方法签名与 execute_steward_turn / recover_report_settlement 的可测试注入钩子,确保运行期行为与既有单元测试完全一致。

具体改动 / Changes

  • 规范依据:docs/development/testing-and-quality.md(revision f4c27a88b54e9f5daba0d282076328fb30b922ff),对照标准:SUB_1000_LOC_SPLIT (implemented)、ZERO_ANY_STRICT_TYPING (implemented)、STEWARD_HOST_PARITY (implemented)、ISOLATED_SCOPE_BOUNDARY (implemented)。
  • Diff 统计(相对 base 216757852168faa784fe6f621b72d971aee58ee3):5 个文件(steward_turn.py +688/-1721 -> 959 LOC、steward_turn_common.py 576 LOC、steward_turn_context.py 560 LOC、steward_turn_execution.py 687 LOC、steward_turn_recovery.py 896 LOC),全部 < 1,000 LOC、0 AST Any(仅 steward_turn_recovery.py:74 英文文档词 "Any")、0 # type: ignore、0 bare os.O_NOFOLLOW;#9355 关联文件与 module_metric_baseline.json 零改动。

关键代码讲解

  1. StewardControllerProtocol / StewardStoreProtocol:定义 StewardTurnHost 对外消费的 store、bindings、managed 与 controller 最小结构协议,以及严格 JSON 窄化函数,以静态类型检查替代原有的 Any 传播。
  2. StewardTurnHost.submit / StewardTurnHost.execute:保留原始 Session 锁内校验、monitor lease/carrier 准备、controller._ensure_adapter_locked 与 _start_accepted_turn_worker 调度及动态 normalizer/deferral 钩子传递,实现零行为漂移拆分。
  3. execute_steward_turn:承载原始 Chat worker 执行管线,校验适配器类型、native_loopx 准入与 upstream_thread_id 一致性,并通过 StewardTurnHostProtocol 回调 host._admit 与 lease 证明。
  4. recover_report_settlement:封装定期报告结算恢复路径,以注入的 report_turn_fn 保持原有 monkeypatch 语义并在锁内校验报告窗口与Turn 身份一致后重放/恢复已验证候选结果。

对主干的风险 / Risks

  • 无阻断性代码缺陷(No blocking finding)。StewardTurnHost 全量方法(missing=0)与全部运行时/单元测试路径均保持等价。
  • 残余风险与非阻断提示:
    1. 对未纳入 [tool.mypy] 的遗留调用端(loopx/chat_runtime.py、steward_managed_mode.py、steward_reports.py、extensions/lark/steward_reports.py)手动执行 mypy --follow-imports=silent 时,基线已有 98 个错误上升到 130 个(新增 +38 行、修复 1 行):主因 StewardControllerProtocol 的 _ensure_adapter_locked/_start_accepted_turn_worker/_fail_queue_preparation 签名与 ChatRuntimeController(chat_runtime.py:917, 976)存在参数/方差不兼容,以及 monitor_restart_carrier/report_turn 返回类型由 dict[str, Any] 收敛为 dict[str, object] 后暴露了调用端未窄化的 .get(...) 链;上述调用端不在本次 PR 范围且运行期全部通过 3,351 项 pytest 验证,建议后续调用端 slim PR 顺带对齐协议或窄化。
    2. steward_turn.py 移除了 10 个仅内部使用的导入符号重导出(EffectRuntimeRejected、ExitStack、FirstPartyHostRuntimeRejected、LOCK_ACQUIRE_TIMEOUT_ERROR_CODE、ManagedTaskValidationUnavailable、actor_steward_binding_id、datetime、load_steward_monitor_turn_by_id、nullcontext、timezone);全仓库 git grep 已确认 0 处外部引用。

我的整体评价 / Verdict

  • long_horizon:preserved — 原生 steward 准入、monitor 续跑、报告窗口结算恢复与动态钩子语义全部保持不变,同时将主文件体积从 1,992 LOC / 156 Any 降至 < 1,000 LOC / 0 Any。
  • user_experience:preserved — Chat steward 与定期报告行为完全一致;visual_review 为 not_applicable(原因:No frontend, HTML, desktop UI, or rendered component layout changes in PR #9417 (Python loopx/capabilities/native_chat/steward_turn*.py modules only).,unverified_scope: none)。
  • 代码体积与比例:necessary / proportionate(5 个文件均 < 1,000 LOC、0 AST Any、0 # type: ignore、0 bare os.O_NOFOLLOW);隔离与权限:isolated / aligned;语义词汇:aligned(0 新增词汇、0 漂移,17/17 TS single-owner 测试通过)。
  • 独立实测汇总(全部于 b045198bc289bd7232716d223038763eabdf029c 干净工作树执行):bare uv run --extra test python -m mypy --no-incremental 17/17 通过、mypy --strict --follow-imports=silent 5/5 通过、mypy --follow-imports=normal 在 5 个目标模块自身 0 错误、ruff check 5/5 通过、npm run typecheck:control-plane 与 content_digest_single_owner.test.ts 17/17 通过、pytest -n 6 覆盖 29 个 steward 测试集+架构+棘轮共计 3,351 passed, 0 failed, 0 skipped、check_rfc_bilingual / semantic-vocabulary-drift-smoke (29/29) / loopx check (0 错误) / canary premerge (6/6 direct + 2/2 catalog,0 失败,manual_hold_count=0) 全数通过。明确给出 APPROVE 结论。

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

动机 / Motivation

维护 Chat 原生 Steward Turn、托管 Session 与报告恢复的开发者。 本次改动的目标是按 Steward 生命周期拆分大模块,并把动态调用收敛成兼容真实调用端的结构类型。 ChatRuntimeController 的生产准入和 worker 两处把真实 controller 传给重构后的 StewardTurnHost。 Chat 的两处 StewardTurnHost 调用在相同的定向 mypy 基线里没有参数类型不兼容错误。 原生 Host 的配对用例通过。目标中的结构类型交付在真实 caller 上形成静态不兼容。 真实路径规范

验收范围覆盖原生入口与持久读回(REAL_ENTRY_PARITY),以及共享边界的输入和调用兼容性(CHANGED_BOUNDARY_PARITY)。本轮范围外的项目见验证限制。

改动思路 / Approach

保留 StewardTurnHost 门面,把 context、execution 和 recovery 拆开,并共用 JSON 窄化。Chat controller 与原 Session store 仍持有实际注册、队列和事件。拆分后共用 Protocol 应描述现有调用能力。 可以保留有明确生命周期职责的拆分,先让公共结构类型与当前生产 caller 相合,接着收紧遗留响应的消费边界。 直接 caller 仍由既有 Chat runtime 持有,相关 #9355 工作台改动另有边界。当前可先削减协议的猜测形状,让两条已有构造使用同一 controller 契约。

具体改动 / Changes

审查 head b045198bc289bd7232716d223038763eabdf029c,base 216757852168faa784fe6f621b72d971aee58ee3,目标分支 main。5 个文件,+3407/−1721。 完整 diff

关键代码讲解

  • StewardTurnHost.submit。在原 Session 锁内完成身份、请求和原 Turn 绑定,随后调用 Chat controller 调度。 源码
  • StewardControllerProtocol。为 Chat controller 声明结构类型,实际 controller 须能满足此消费接口。 源码
  • build_steward_turn_prompt。复用绑定的 Session、Goal 与 Todo 来源构造模型输入,原展示和权限 owner 保持。 源码
  • execute_steward_turn。原生 admission、模型循环、候选结果验证、事件与 readback。 源码
  • recover_report_settlement。使用已保存的报告候选重进 settlement,保持原报告窗口与 Turn。 源码
  • ChatRuntimeController。真实生产 caller 在准入与执行分支将自身传给 StewardTurnHost;typecheck 开始拒绝。 源码

对主干的风险 / Risks

[P2] HEAD 在两处构造 StewardTurnHost 时将 ChatRuntimeController 判为不满足 StewardControllerProtocol,四个直接和下游调用模块的总诊断从 73 增至 111。 在同一虚拟环境和相同 pyproject.toml 规则下,定向 typecheck 真实 Chat 与三个下游报告/托管调用模块。 让 Protocol 使用实际方法签名,包括 session 参数的可变类型、队列失败处理的 Exception 和正式 callable 参数。用既有 owner 的结果结构或在接收处窄化报告字段。加入以真实 controller 为输入的契约检查,验证这两处构造及确认为本 PR 新增的调用诊断消失。 变更行

语义与 CI 对齐

PASS。在匹配的 base/head 上,File 和 SQLite 的原生 Host scope 与托管 Session 校验各 6 项通过,保持原动作与后来任务的隔离。模型由合成夹具替代。

FAIL。同一 Python 与 mypy 运行四个真实调用文件,比较两处构造的精确诊断并检查新增 Protocol 与原 controller 的签名。 基线结果为 73 条现有诊断,ChatRuntimeController 两处构造无这类 arg-type。 当前结果为 111 条诊断。chat_runtime.py:917 和 :976 新增相同的 arg-type,mypy 指出 _ensure_adapter_locked 的 Mapping/dict 与 _fail_queue_preparation 的 Exception/参数名冲突。

PASS。两版恢复已冻结的报告,验证期间没有新的模型调用,并读回已发布与 Todo done。

UNVERIFIED。定向四模块检查属于结构类型验证,既有诊断保留为基线。未发现这两个调用点的运行时报错,未连接真实模型或查询托管 CI。

我的整体评价 / Verdict

同头既有评审把直接 caller 的 mypy 回归列为残余风险。本轮配对结果用实际构造的 arg-type 判断:该缺口阻断此次交付的结构类型目标。 同头评审

请求修改。可以保留有明确生命周期职责的拆分,先让公共结构类型与当前生产 caller 相合,接着收紧遗留响应的消费边界。 让 Protocol 使用实际方法签名,包括 session 参数的可变类型、队列失败处理的 Exception 和正式 callable 参数。用既有 owner 的结果结构或在接收处窄化报告字段。加入以真实 controller 为输入的契约检查,验证这两处构造及确认为本 PR 新增的调用诊断消失。

English verdict: REQUEST_CHANGES at b045198. The new StewardControllerProtocol rejects the real ChatRuntimeController at both production call sites.

@loopx-agent
loopx-agent force-pushed the codex/slim-steward-turn-zero-any-20261125 branch from b045198 to 3434982 Compare November 25, 2026 04:01

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

English verdict: APPROVE
Reviewed head: 34349829c84510be4ce9fc3442a585713ac128cc
Reviewer: model_agent · Gemini · Google · self_reported · effort_unavailable

动机 / Motivation

  • Affected caller or operator: Maintainers of native Steward Chat runtime (loopx/chat_runtime.py), managed-mode hosts (loopx/capabilities/native_chat/steward_managed_mode.py), native/session periodic report adapters (loopx/capabilities/native_chat/steward_reports.py), and Feishu private report delivery (loopx/extensions/lark/steward_reports.py).
  • Before / after scenario: Before this PR, loopx/capabilities/native_chat/steward_turn.py had grown to 1,992 lines with 156 AST Any references, and the earlier PR revision (b045198bc2) broke ChatRuntimeController compatibility against StewardControllerProtocol (increasing 4-caller mypy diagnostics from 73 to 111, flagged in PRRT_kwDOStEbEs67sDfn). At 34349829c8, the runtime is split into focused sub-1,000-LOC zero-Any modules while caller diagnostics drop cleanly from 73 to 40 with zero new controller errors.
  • Observable outcome: All 8 touched/created Python modules stay strictly under 1,000 LOC (993 max in steward_reports.py, 961 in steward_turn.py) with 0 AST Any and 0 # type: ignore; real ChatRuntimeController, ChatSessionStore, and ChatConversationBindings satisfy StewardTurnHost / StewardReports / ManagedSessionReports contracts at runtime and under mypy; and all 3,358 targeted steward, architecture, and maintainability-ratchet tests pass alongside standalone canary premerge.
  • Non-goals: Does not alter Chat turn execution semantics, StewardReports / ManagedSessionReports scheduling/delivery invariants, #9355 files (workbench_ledger.py, chat_manager.py, inspection.py), module_metric_baseline.json, or pre-existing unrelated mypy diagnostics in chat_runtime.py (27) and steward_managed_mode.py (13).

Accepted specification baseline checked against docs/development/testing-and-quality.md at revision f4c27a88b54e9f5daba0d282076328fb30b922ff:

  • TQ-L1: Contract and unit tests cover real ChatRuntimeController / ChatSessionStore / ChatConversationBindings bindings against StewardTurnHost, StewardReports, and ManagedSessionReports (tests/test_steward_turn_controller_contract.py).
  • TQ-L2: Repository-native local verification (mypy, ruff, pytest, npm run typecheck:control-plane, canary premerge) qualifies the slice independently without blocking on remote CI polling.
  • TQ-R1: Regression criterion from resolved review thread PRRT_kwDOStEbEs67sDfn — real 4-caller mypy parity retains zero StewardTurnHost(self) / StewardControllerProtocol errors and drops total diagnostics across the 4 callers (73 -> 40).

改动思路 / Approach

Splitting Turn protocols/narrowers (steward_turn_common.py), prompt/followup/replan context (steward_turn_context.py), execution loop (steward_turn_execution.py), monitor/report recovery (steward_turn_recovery.py), and host facade (steward_turn.py) keeps runtime decisions, report IO (_StewardReportsBase), and Lark delivery (LarkStewardReports) in their existing owners without introducing parallel state machines.

Architecture boundary (current_pr_boundary): Bounded to native_chat Steward turn/report modules, Lark report adapter call boundary, and real-controller contract test tests/test_steward_turn_controller_contract.py; untouched callers retain their pre-existing mypy counts pending separate cleanups.

  • Protocol & runtime contract repair (PRRT_kwDOStEbEs67sDfn):
    • StewardStoreProtocol (steward_turn_common.py:61-112) and StewardBindingsProtocol (steward_turn_common.py:114-148) widen read inputs cleanly where needed while matching mutable dict[str, object] session/row parameters (update_session, resolve, _resolve_observed, _session_observation, _core).
    • StewardControllerProtocol (steward_turn_common.py:165-207) aligns _start_accepted_turn_worker (adapter: ChatRuntimeAdapter under TYPE_CHECKING, avoiding runtime circular imports while matching ChatRuntimeController) and _fail_queue_preparation(..., error: Exception) -> None, while StewardTurnHost._report_validator returns Callable[[Mapping[str, object], Mapping[str, object]], dict[str, object]].
  • Structural decomposition & report base extraction:
    • steward_turn.py delegates context projection to steward_turn_context.py, execution worker orchestration to steward_turn_execution.py, and monitor/stopped-report recovery to steward_turn_recovery.py via StewardTurnHostProtocol (steward_turn_common.py:209-338), preserving backwards-compatible re-exports on steward_turn.py (lines 37-94).
    • steward_reports.py extracts _StewardReportsBase (lines 87-391) for shared window lookup, failed-window inspection/cancellation, current_window, _frontier, and freeze between StewardReports and ManagedSessionReports, reducing 4-caller mypy diagnostics from 28 -> 0 in steward_reports.py and 5 -> 0 in extensions/lark/steward_reports.py.

具体改动 / Changes

All 8 diff files against origin/main (35cb1d701a4ac85cf4430b48891197a979723d80, merge-tree clean) are < 1,000 LOC with 0 AST Any, 0 # type: ignore, and 0 bare os.O_NOFOLLOW:

  1. loopx/capabilities/native_chat/steward_turn_common.py (597 LOC, new): explicit typed Protocols (ClosedFlagProtocol, AcceptedTurnProtocol, StewardStoreProtocol, StewardBindingsProtocol, StewardControllerProtocol, StewardTurnHostProtocol), MonitorRestartCarrier TypedDict, runtime dict/sequence narrowers (as_mapping, as_dict, as_optional_dict, as_dict_list, as_str, etc.), and shared helpers (native_steward_client_id, report_turn, candidate normalizers, is_zero_effect_replan_selection_deferral).
  2. loopx/capabilities/native_chat/steward_turn_context.py (561 LOC, new): steward_followup_context, governance_replan_context, user action normalization/application, prompt construction, and response finalization.
  3. loopx/capabilities/native_chat/steward_turn_execution.py (688 LOC, new): execute_steward_turn, selection recovery lookup, freeze fence / candidate build, and durable event readback (_append_native_result_with_readback).
  4. loopx/capabilities/native_chat/steward_turn_recovery.py (897 LOC, new): monitor restart basis/carrier/request recovery, has_recoverable_stopped_report, frozen_report_contract_recovery, stopped_report_candidate_recovery, and settlement replay helpers.
  5. loopx/capabilities/native_chat/steward_turn.py (961 LOC, refactored from 1,992 LOC): slimmer StewardTurnHost orchestrating _observe, _admit, _prepare_submission, submit, and delegating to steward_turn_* helpers while retaining module exports (report_turn, native_steward_client_id, etc.) for steward_monitor.py and callers.
  6. loopx/capabilities/native_chat/steward_reports.py (993 LOC): introduces _StewardReportsBase, typed internal protocols (_ReportsStoreProtocol, _ReportsManagedProtocol, _InterruptControllerProtocol, etc.), and explicit narrowing in both StewardReports and ManagedSessionReports (0 mypy errors, down from 28).
  7. loopx/extensions/lark/steward_reports.py (400 LOC): defines _LarkOwnerAttentionProtocol, _LarkCoreProtocol, _LarkTransportProtocol, replaces Any with narrowed Mapping/dict structures (0 mypy errors, down from 5).
  8. tests/test_steward_turn_controller_contract.py (146 LOC, new): verifies live ChatRuntimeController, ChatSessionStore, and ChatConversationBindings instantiation and inspect.signature compatibility, plus runs a mypy probe across all 4 production caller modules ensuring zero probe errors and <= 73 total caller diagnostics.
  9. Out-of-scope protections verified untouched (0 diff bytes): workbench_ledger.py, chat_manager.py, inspection.py, and loopx/canary/module_metric_baseline.json.

对主干的风险 / Risks

  • Export/signature surface: Checked top-level and class exports via AST comparison against origin/main plus repo-wide git grep and inspect.signature checks in test_steward_turn_controller_contract.py; re-exports (steward_turn.py:37-94) and _StewardReportsBase inheritance preserve caller compatibility.
  • Residual mypy baseline on unedited callers: Running --follow-imports=silent on origin/main vs 34349829c84510be4ce9fc3442a585713ac128cc across the 4 caller modules reduces total diagnostics from 73 -> 40 (chat_runtime.py stays at 27 including its pre-existing line 918 _admit dict-variance diagnostic; steward_managed_mode.py stays at 13; steward_reports.py drops 28 -> 0; extensions/lark/steward_reports.py drops 5 -> 0). Zero StewardTurnHost(self) or StewardControllerProtocol errors remain.
  • Residual runtime mock boundary & CI note: Live ChatRuntimeController worker execution and Feishu provider network delivery remain mocked/unit-fenced in offline tests; additionally, a prior CI run (45524736186 on superseded b045198bc2) saw dashboard-browser (2) timeout at runtime-readiness-live.mjs:149 after 503/424 responses, which is UI runtime-readiness unrelated to steward_turn/steward_reports (remote CI on 34349829c84510be4ce9fc3442a585713ac128cc is queued and not waited on per Goal policy wait_for_ci: false).

我的整体评价 / Verdict

No blocking finding on 34349829c84510be4ce9fc3442a585713ac128cc. The [P2] controller/caller typing regression (PRRT_kwDOStEbEs67sDfn, resolved) is fixed, all 8 Python files meet the < 1,000 LOC / 0 Any / 0 # type: ignore contract, and local decisive validation is completely green on clean detached checkout 34349829c84510be4ce9fc3442a585713ac128cc:

  • pytest -v tests/test_steward_turn_controller_contract.py: 2 passed in 12.41s
  • pytest -n 6 across all 30 steward test suites + tests/architecture/ + tests/canary/test_maintainability_ratchet.py: 3,358 passed (0 failed, 0 skipped)
  • Bare mypy --no-incremental (17/17), strict --follow-imports=silent mypy (8/8), 4-caller mypy parity (73 -> 40 total; 0 in steward_reports.py and extensions/lark/steward_reports.py), and ruff check (8/8): all passed
  • npm run -s typecheck:control-plane, node --experimental-strip-types --test tests/control_plane_ts/content_digest_single_owner.test.ts (17/17), scripts/check_rfc_bilingual.py, examples/semantic-vocabulary-drift-smoke.py (29/29), and loopx check public-boundary scan (8/8, 0 errors): all passed
  • Standalone loopx canary premerge --from-git-diff --git-diff-base origin/main: gate.status=passed, direct_checks=6/6, catalog_run=2/2, risk_profile_run=8/8, failures=0

Visual review decision: not_applicable — No rendered web/desktop UI or frontend files changed; inspected all 8 modified/added .py paths under loopx/capabilities/native_chat/, loopx/extensions/lark/, and tests/. Unverified scope: none (CLI/internal Python refactoring; no rendered views changed).

Residual risk: live Codex/Antigravity worker spawning and external Feishu outbound transport run through unit mocks/fences in test suites; strongest missing validation is full remote Playwright / end-to-end provider integration in CI (not waited on locally).

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · reasoning_effort=xhigh

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

动机 / Motivation

桌面 Native Chat 和 Lark 私聊的 Steward 使用同一队列、回执和报告恢复流程。主干把调度、上下文和恢复集中在单文件。拆分需要保留正常入口及原有 Agent、会话和回执身份,同时让真实调用者满足新定义的控制器和传输协议。当前提交修好了桌面控制器在两处创建 StewardTurnHost 的类型冲突,Lark 的生产 transport 构造仍产生一个新的类型错误。验证覆盖精确源码和隔离本地测试,不执行飞书发信、生产服务或远端 CI。

改动思路 / Approach

范围是现有 Native Chat 调度、上下文、恢复与原生和 Lark 报告返回。复用现有 ChatRuntimeController、ChatSessionStore 和 Lark 私聊交付所有者,按职责拆分内部模块并保留原入口。共享协议应按两种真实生产调用者实际用到的方法窄化,避免仅在实现文件里消除 Any,却把不相容的协议留给构造调用。 原有管理器运行合同

具体改动 / Changes

精确提交 34349829c84510be4ce9fc3442a585713ac128cc,基线 35cb1d701a4ac85cf4430b48891197a979723d80。共 8 个文件,+4490/-2264。StewardTurnHost 保留门面,公共类型和辅助函数迁入 common,后续上下文进 context,原生执行与回执进 execution,监控和冻结态恢复进 recovery。Native Chat 报告与 Lark 报告分别接入这一层,维持原有授权和事件所有者。 门面

  • CHAT_CONTROLLER_COMPATIBILITY。当前新增真实 ChatRuntimeController 构造和四个调用文件检查,覆盖原先失败的桌面直接调用。 原问题
  • LARK_TRANSPORT_COMPATIBILITY。新增 Lark transport 协议的本地类型定义未包含实际构造点的回归验收。同一 mypy 规则比较 Lark 私聊与 owner attention 两个文件,基线 22 处既有诊断,本头 23 处,增加的诊断正位于真实构造。 实际调用

对主干的风险 / Risks

[P2] 新报告协议不接受实际 Lark 私聊 transport。 构造点把真实的 LarkPrivateConversations 传给 LarkStewardReports。接口要求 _deliver 接受 inbox: Callable[[], object],实际实现要求回调返回 Path。接口把普通参数命名为 body,实际为 text,并将 _inbox 的入参扩大成 Mapping,实际实现要求字典。对同基线运行同一仓库 mypy 配置,新增唯一的参数类型诊断。动态 Python 仍可构造这些对象,该证据证明发布的静态契约与现有生产入口不相容。

请用实际 Path 回执和调用形状为传输协议定界,并把 LarkPrivateConversations 赋值或构造加入现有真实调用方契约检查。保留桌面控制器的修复。 新协议

  • PASS · 真实桌面控制器契约两项通过。预合并检查 6 项直接和 10 项所选均通过。
  • FAIL · 真实 Lark 构造新增类型不兼容诊断,基线 22 处、本头 23 处。
  • UNVERIFIED · 真实飞书远程交付与远端 CI。

我的整体评价 / Verdict

拆分职责与既有所有者对齐。这个改动的验收也包括实际 Lark 消费者。修正它使用的 transport API,并将构造点纳入同样的正向检查后可复审当前最小缺口。

English verdict: REQUEST_CHANGES at 3434982. The new report transport protocol rejects the existing production Lark constructor in mypy, even though the desktop controller protocol is repaired.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI (runtime_reported, xhigh)

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

[P2] 契约测试会放行未运行分析的 mypy。 mypy 退出 1,错误仅写到 stderr。两个测试从 stdout 得到空诊断,均报告通过。 共用一次可验证 mypy 是否完成分析的结果处理,核对完成摘要并保留异常诊断。已有类型债可使退出码为 1,需与未运行分析分开判定。 测试

动机 / Motivation

维护 Native Steward 和飞书私聊报告的开发者用实际调用方验证模块拆分后的接口兼容性。 上一提交的桌面构造已修好,但 mypy 在 LarkPrivateConversations 的真实构造点报 transport 不兼容。 用同一仓库配置比较上一提交和候选的真实 Lark transport,再用当前解释器启动新增的 Desktop 和 Lark mypy 契约测试。 正常 mypy 下,Lark 生产构造和独立 probe 的参数类型错误消失。两个生产文件剩下 22 个既有诊断,三项正常契约测试通过。 mypy 提前退出时,两个要求实际类型分析的契约测试仍然通过。 使用隔离源码和本地合成报告入口。未发送真实飞书消息,也未查询托管 CI。

mypy 退出 1,错误仅写到 stderr。两个测试从 stdout 得到空诊断,均报告通过。

改动思路 / Approach

复用 Native Turn dispatcher、Session Store 和 Lark 私有报告返回路径。传输协议现在采用实际调用形状。当前缺口在测试对 mypy 进程的观测,两份测试可共用结果处理。 保留模块拆分和 Lark 协议的修复,补齐用于证明真实调用端兼容的验收。 共用一次可验证 mypy 是否完成分析的结果处理,核对完成摘要并保留异常诊断。已有类型债可使退出码为 1,需与未运行分析分开判定。 现有入口依据

具体改动 / Changes

精确 head 45ec850ff22b1fabff4fc3b0a1f693bf61e8d7f4,比较基线 35cb1d701a4ac85cf4430b48891197a979723d80。8 个文件,增 4,599 行、删 2,264 行。本轮只改 Lark 报告适配器和类型契约测试。 同配置下,上一提交的两个 Lark 生产文件有 23 处诊断并带 transport 不兼容,独立 probe 也报同一问题。当前生产文件保留 22 项既有诊断,独立 probe 无新增诊断。

关键代码讲解

  • _LarkTransportProtocol._deliver。对齐 text 参数与 Path 型 inbox 工厂,使真实传输满足报告协议。 源码

  • _original_route。用原 session 和 source 解析报告目标。 源码

  • 桌面契约结果处理。取 stdout 预期文件诊断,但未确认 mypy 完成分析。 源码

  • Lark 契约结果处理。新增门同样只数 stdout 错误,mypy 启动失败时计数全空。 源码

  • MYPY_PROBE_MUST_RUN 尚未满足。用真实调用方验证结构类型契约,类型测试只有在分析完成以后才能通过。 定位

对主干的风险 / Risks

mypy 尚未分析任何被测文件就退出,例如当前解释器的 site-packages 被放进 MYPYPATH。 同一源码、解释器和 MYPYPATH 下,实际 mypy 退出 1,两个 pytest 契约测试却返回 2 passed。 桌面对照

语义与 CI 对齐

git diff --check 通过。独立运行 mypy 生产调用与 probe,运行正常契约测试和 mypy 提前退出的对照。 同一源码、解释器和 MYPYPATH 下,实际 mypy 退出 1,两个 pytest 契约测试却返回 2 passed。 未替换 mypy 或修改测试源码。运行时核验复用本地持久存储与合成上游。未运行生产 Lark 或托管 CI。

我的整体评价 / Verdict

REQUEST_CHANGES。 保留模块拆分和 Lark 协议的修复,补齐用于证明真实调用端兼容的验收。 共用一次可验证 mypy 是否完成分析的结果处理,核对完成摘要并保留异常诊断。已有类型债可使退出码为 1,需与未运行分析分开判定。

English verdict: REQUEST_CHANGES. The Lark transport mismatch is fixed in a normal mypy run. Both contract tests still report success when mypy terminates before analyzing any inputs.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

English verdict: APPROVE
Reviewed head: 45ec850ff22b1fabff4fc3b0a1f693bf61e8d7f4
Reviewer: model_agent · Gemini · Google · self_reported · effort_unavailable

动机 / Motivation

  • Affected caller or operator: Maintainers of native Steward Chat runtime (loopx/chat_runtime.py), managed-mode hosts (loopx/capabilities/native_chat/steward_managed_mode.py), native/session periodic report adapters (loopx/capabilities/native_chat/steward_reports.py), and Feishu private report delivery (loopx/extensions/lark/steward_reports.py, loopx/extensions/lark/private_conversations.py, loopx/extensions/lark/owner_attention.py).
  • Before / after scenario: Before this PR, loopx/capabilities/native_chat/steward_turn.py had grown to 1,992 lines with 156 AST Any references; prior revision b045198bc2 broke desktop ChatRuntimeController compatibility (73 -> 111 4-caller mypy diagnostics, PRRT_kwDOStEbEs67sDfn), and prior revision 34349829c8 left LarkStewardReports(self) incompatible with LarkPrivateConversations in mypy (22 -> 23 Lark 2-caller diagnostics at private_conversations.py:132, flagged in review 6051914913 / PRR_kwDOStEbEs8AAAABaLjkoQ). At exact head 45ec850ff2, both desktop and Lark protocol boundaries align cleanly: desktop 4-caller mypy diagnostics drop 73 -> 40 and Lark 2-caller diagnostics hold at 22 -> 22 (0 new errors).
  • Observable outcome: All 8 touched/created Python modules stay strictly under 1,000 LOC (993 max in steward_reports.py, 961 in steward_turn.py) with 0 AST Any and 0 # type: ignore; real ChatRuntimeController, ChatSessionStore, ChatConversationBindings, LarkPrivateConversations, ChatExternalConversations, and LarkOwnerAttention satisfy StewardTurnHost, StewardReports, ManagedSessionReports, and LarkStewardReports contracts at runtime and under mypy; and all 3,359 targeted steward, architecture, and maintainability-ratchet tests pass alongside standalone canary premerge.
  • Non-goals: Does not alter Chat turn execution semantics, StewardReports / ManagedSessionReports / LarkStewardReports runtime delivery invariants, #9355 files (workbench_ledger.py, chat_manager.py, inspection.py), module_metric_baseline.json, private_conversations.py, owner_attention.py, or pre-existing unrelated mypy diagnostics in chat_runtime.py (27), steward_managed_mode.py (13), private_conversations.py (19), and owner_attention.py (3).

Accepted specification baseline checked against docs/development/testing-and-quality.md at revision f4c27a88b54e9f5daba0d282076328fb30b922ff:

  • TQ-L1: Contract and unit tests cover real desktop controller/store/bindings and real LarkPrivateConversations / LarkOwnerAttention / ChatExternalConversations bindings (tests/test_steward_turn_controller_contract.py).
  • TQ-L2: Repository-native local verification (mypy, ruff, pytest, npm run typecheck:control-plane, canary premerge) qualifies the slice independently without blocking on remote CI polling.
  • TQ-R1: Regression criterion from resolved review thread PRRT_kwDOStEbEs67sDfn — desktop 4-caller mypy parity retains zero StewardTurnHost(self) / StewardControllerProtocol errors and reduces total diagnostics 73 -> 40.
  • TQ-R2: Regression criterion from exact-head review 6051914913 (PRR_kwDOStEbEs8AAAABaLjkoQ / LARK_TRANSPORT_COMPATIBILITY) — _LarkTransportProtocol and _LarkOwnerAttentionProtocol match LarkPrivateConversations (_inbox -> Path, _deliver(..., text, *, inbox: Callable[[], Path], authorization_check: Callable[[], bool] | None = None, ...)) and LarkOwnerAttention._route, eliminating the added private_conversations.py:132 error and holding Lark 2-caller mypy diagnostics at 22 -> 22.

改动思路 / Approach

Splitting Turn protocols/narrowers (steward_turn_common.py), prompt/followup/replan context (steward_turn_context.py), execution loop (steward_turn_execution.py), monitor/report recovery (steward_turn_recovery.py), and host facade (steward_turn.py) while typing _StewardReportsBase (steward_reports.py) and aligning _LarkTransportProtocol / _LarkOwnerAttentionProtocol (loopx/extensions/lark/steward_reports.py) to exact LarkPrivateConversations and LarkOwnerAttention signatures keeps runtime decisions, report IO, and Feishu transport in their existing owners without duplicate state machines.

Architecture boundary (current_pr_boundary): Bounded to native_chat Steward turn/report modules, loopx/extensions/lark/steward_reports.py transport/route typing, and real-host contract/mypy regression coverage in tests/test_steward_turn_controller_contract.py; pre-existing diagnostics in unedited callers (chat_runtime.py, steward_managed_mode.py, private_conversations.py, owner_attention.py) remain out of scope.

  • Lark transport & owner-attention protocol alignment (loopx/extensions/lark/steward_reports.py:35-109, 255-267, 353-364):
    • _LarkTransportProtocol._inbox (private_conversations.py:675) takes record: dict[str, object] and returns Path; _LarkTransportProtocol._deliver (private_conversations.py:1072) takes text: str, inbox: Callable[[], Path], and authorization_check: Callable[[], bool] | None = None. Both make_inbox closures (steward_reports.py:255, :353) now return Path.
    • _LarkOwnerAttentionProtocol._route (owner_attention.py:96) matches (binding: dict[str, object], saved: dict[str, object] | None = None, *, session_id: str | None = None, source_ref: str | None = None) -> dict[str, object]. LarkStewardReports._original_route converts binding with as_dict(binding) and saved with as_dict(saved) if saved is not None else None, preserving empty-dict non-Mapping rejection without falling back to saved is None directory globbing.
  • Desktop controller & Steward turn split (steward_turn*.py, steward_reports.py):
    • StewardControllerProtocol, StewardStoreProtocol, and StewardBindingsProtocol (steward_turn_common.py:61-207) match ChatRuntimeController, ChatSessionStore, and ChatConversationBindings; steward_turn.py delegates context, execution, and recovery helpers while keeping compatibility re-exports (lines 37-94); and _StewardReportsBase (steward_reports.py:87-391) eliminates 28 mypy errors across StewardReports and ManagedSessionReports.

具体改动 / Changes

All 8 diff files vs merge-base 35cb1d701a4ac85cf4430b48891197a979723d80 (git merge-tree --write-tree origin/main HEAD clean) are < 1,000 LOC with 0 AST Any, 0 # type: ignore, and 0 bare os.O_NOFOLLOW:

  1. loopx/capabilities/native_chat/steward_turn_common.py (597 LOC, new): typed Protocols (ClosedFlagProtocol, AcceptedTurnProtocol, StewardStoreProtocol, StewardBindingsProtocol, StewardControllerProtocol, StewardTurnHostProtocol), MonitorRestartCarrier, runtime narrowers (as_mapping, as_dict, as_optional_dict, as_dict_list), and shared helpers.
  2. loopx/capabilities/native_chat/steward_turn_context.py (561 LOC, new): followup/governance context projection, user-action validation, prompt builders, and response finalization.
  3. loopx/capabilities/native_chat/steward_turn_execution.py (688 LOC, new): execute_steward_turn, selection recovery, freeze-fence settlement, and event-append readback.
  4. loopx/capabilities/native_chat/steward_turn_recovery.py (897 LOC, new): monitor restart basis/carrier/request and frozen/stopped report recovery helpers.
  5. loopx/capabilities/native_chat/steward_turn.py (961 LOC, down from 1,992): slimmer StewardTurnHost orchestrating _observe, _admit, _prepare_submission, submit, and helper delegation with compatibility re-exports (lines 37-94).
  6. loopx/capabilities/native_chat/steward_reports.py (993 LOC): _StewardReportsBase shared report/cadence/failure-proof base + internal store/managed/interrupt/guard protocols (28 -> 0 mypy errors).
  7. loopx/extensions/lark/steward_reports.py (401 LOC): _LarkOwnerAttentionProtocol, _LarkCoreProtocol, and _LarkTransportProtocol aligned with real LarkPrivateConversations, LarkOwnerAttention, and ChatExternalConversations (5 -> 0 mypy errors).
  8. tests/test_steward_turn_controller_contract.py (254 LOC, new): tests live runtime construction and inspect.signature compatibility across ChatRuntimeController, ChatSessionStore, ChatConversationBindings, LarkPrivateConversations, ChatExternalConversations, and LarkOwnerAttention, plus mypy --follow-imports=silent parity probes for both the 4 desktop callers (<= 40) and the 2 Lark callers (<= 22).
  9. Out-of-scope protections verified untouched (0 bytes diff): workbench_ledger.py, chat_manager.py, inspection.py, loopx/canary/module_metric_baseline.json, loopx/extensions/lark/private_conversations.py, and loopx/extensions/lark/owner_attention.py.

对主干的风险 / Risks

  • Dual caller mypy parity verified against origin/main:
    • Desktop 4 callers (chat_runtime.py, steward_managed_mode.py, steward_reports.py, extensions/lark/steward_reports.py): 73 -> 40 diagnostics (chat_runtime.py: 27, steward_managed_mode.py: 13, steward_reports.py: 0, extensions/lark/steward_reports.py: 0; 0 StewardTurnHost/StewardControllerProtocol errors).
    • Lark 2 callers (extensions/lark/private_conversations.py, extensions/lark/owner_attention.py): 22 -> 22 diagnostics (private_conversations.py: 19, owner_attention.py: 3; empty symmetric diagnostic diff vs origin/main; 0 errors at private_conversations.py:132 or referencing LarkStewardReports/_LarkTransportProtocol).
  • Module-size headroom & mock boundaries: steward_reports.py (993 LOC) and steward_turn.py (961 LOC) sit near the 1,000-LOC cap; live worker execution and Feishu HTTP transport remain unit-fenced/mocked in offline suites (dependency-review, loopx-obelisk, and Summary succeeded on 45ec850ff22b1fabff4fc3b0a1f693bf61e8d7f4, while other remote CI jobs remain queued/in-progress and are not consulted under wait_for_ci: false).

我的整体评价 / Verdict

No blocking finding on 45ec850ff22b1fabff4fc3b0a1f693bf61e8d7f4. Both prior [P2] findings — desktop controller typing (PRRT_kwDOStEbEs67sDfn, resolved) and Lark transport typing (6051914913 / PRR_kwDOStEbEs8AAAABaLjkoQ on 34349829c8) — are fixed and directly covered by runtime and mypy contract tests, all 8 .py files stay < 1,000 LOC with 0 AST Any / 0 # type: ignore, and local decisive checks are 100% green:

  • pytest -v tests/test_steward_turn_controller_contract.py: 3 passed in 16.21s
  • pytest -n 6 (30 steward test suites + tests/architecture/ + tests/canary/test_maintainability_ratchet.py): 3,359 passed in 1073.87s (0 failed, 0 skipped)
  • Bare mypy --no-incremental (17/17), --strict --follow-imports=silent (8/8), 4-caller desktop mypy parity (73 -> 40), 2-caller Lark mypy parity (22 -> 22), and ruff check (8/8): all passed
  • npm run -s typecheck:control-plane, content_digest_single_owner.test.ts (17/17), check_rfc_bilingual.py, semantic-vocabulary-drift-smoke.py (29/29), and loopx check (8/8 files, 0 errors): all passed
  • Standalone loopx canary premerge --from-git-diff --git-diff-base 35cb1d701a4ac85cf4430b48891197a979723d80: gate.status=passed, direct_checks=6/6, catalog_run=2/2, risk_profile_run=8/8, failures=0

Visual review decision: not_applicable — No rendered web/desktop UI or frontend files changed; inspected all 8 modified/added .py paths under loopx/capabilities/native_chat/, loopx/extensions/lark/, and tests/. Unverified scope: none (CLI/internal Python refactoring; no rendered views changed).

Residual risk: live upstream Codex/Antigravity worker spawning and Feishu HTTP outbound sends rely on unit mocks/fences; strongest missing validation is full end-to-end desktop/Feishu runtime smoke in CI.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

English verdict: REQUEST_CHANGES
Reviewed head: 45ec850ff22b1fabff4fc3b0a1f693bf61e8d7f4
Reviewer: model_agent · Gemini · Google · self_reported · effort_unavailable

动机 / Motivation

  • Affected caller or operator: Maintainers relying on tests/test_steward_turn_controller_contract.py to prove real ChatRuntimeController and LarkPrivateConversations compatibility under mypy, alongside desktop (chat_runtime.py, steward_managed_mode.py, steward_reports.py) and Feishu (loopx/extensions/lark/steward_reports.py, private_conversations.py, owner_attention.py) callers.
  • Before / after scenario: On exact head 45ec850ff2, the production split (<1,000 LOC, 0 AST Any, desktop mypy 73 -> 40, Lark mypy 22 -> 22) and all 3,359 targeted pytest checks pass under a clean environment. However, in the newly added mypy contract tests (tests/test_steward_turn_controller_contract.py:134-174, 214-254), when mypy aborts early without running type analysis (verified directly with MYPYPATH=<site-packages> where mypy exits 1 to stderr and prints 0 diagnostics to stdout), both tests pass vacuously (2 passed in 0.54s), matching same-head finding PRRT_kwDOStEbEs67wGxb (6052585364).
  • Observable outcome: Supersedes earlier review 6052621057 with REQUEST_CHANGES on 45ec850ff2: production decomposition and real-caller mypy compatibility are verified fixed, while the two mypy contract gate tests must verify mypy actually checked all target files and surface stderr/early-exit failures instead of passing vacuously on empty stdout.
  • Non-goals: Does not ask to revisit the steward_turn decomposition, _StewardReportsBase, _LarkTransportProtocol, #9355 files, or pre-existing mypy baselines in unedited caller files (chat_runtime.py: 27, steward_managed_mode.py: 13, private_conversations.py: 19, owner_attention.py: 3).

Accepted specification baseline checked against docs/development/testing-and-quality.md at revision f4c27a88b54e9f5daba0d282076328fb30b922ff:

  • TQ-L1: not_met — tests/test_steward_turn_controller_contract.py:134-174, 214-254 silently passes (2 passed in 0.54s) when mypy aborts early without analyzing files (MYPYPATH=<site-packages> exits 1 to stderr with empty stdout; matches PRRT_kwDOStEbEs67wGxb).
  • TQ-L2: implemented — Local pytest -n 6 (3,359 passed), bare mypy (17/17), strict mypy (8/8), ruff (8/8), TS checks (17/17), loopx check, and canary premerge (6/6 direct, 10/10 selected) ran cleanly at 45ec850ff22b1fabff4fc3b0a1f693bf61e8d7f4.
  • TQ-R1: implemented — Desktop 4-caller mypy parity retains zero StewardTurnHost(self) / StewardControllerProtocol errors (73 -> 40).
  • TQ-R2: implemented — Lark 2-caller mypy parity (22 -> 22) eliminates the private_conversations.py:132 transport error flagged in 6051914913.

改动思路 / Approach

Both test_real_controller_protocol_and_four_callers_mypy_contract (:134-174) and test_real_lark_transport_protocol_and_callers_mypy_contract (:214-254) invoke subprocess.run(..., check=False) and only count : error: lines on proc.stdout, without checking proc.returncode, proc.stderr, or the mypy checked-file completion summary. Extracting one shared _run_mypy_contract_probe(...) helper in tests/test_steward_turn_controller_contract.py resolves both sites cleanly.

Architecture boundary (current_pr_boundary): Bounded one-file test-gate repair in tests/test_steward_turn_controller_contract.py plus resolving thread PRRT_kwDOStEbEs67wGxb; all 7 production Python files under loopx/ are clean and verified.

  • Findings first (superseding 6052621057 after same-head finding PRRT_kwDOStEbEs67wGxb / review 6052585364):
    • [P2] MYPY_PROBE_MUST_RUN (tests/test_steward_turn_controller_contract.py:152-174, 233-254): Both mypy contract tests ignore proc.returncode, ignore proc.stderr, and never verify mypy's summary (Success: no issues found in <N> source files or Found <E> errors? in <F> files? (checked <N> source files?) with <N> == 1 + len(callers) and proc.returncode in (0, 1) when proc.stderr.strip() == "" or valid diagnostics exist). Independently reproduced on 45ec850ff22b1fabff4fc3b0a1f693bf61e8d7f4 with MYPYPATH=<venv>/lib/python3.14/site-packages: direct mypy aborted with MYPY_RC=1 on stderr (... is in the MYPYPATH. Please remove it.), yet pytest -v tests/test_steward_turn_controller_contract.py -k mypy reported 2 passed, 1 deselected in 0.54s.
    • Minimum repair: Share one helper in tests/test_steward_turn_controller_contract.py that (1) verifies proc.returncode in (0, 1) (while allowing pre-existing mypy error diagnostics on excluded caller files that exit 1), (2) checks mypy's completion summary proves checked <expected_file_count> source files (or Success: no issues found in <expected_file_count> source files), (3) preserves proc.stdout and proc.stderr on failure assertions so startup/environment aborts cannot pass as zero errors, and (4) adds a negative regression test mocking/simulating early-exit mypy (rc=1 with stderr and empty stdout or MYPYPATH early abort) and asserting the helper fails.

具体改动 / Changes

All 8 diff files vs merge-base 35cb1d701a4ac85cf4430b48891197a979723d80 (git merge-tree --write-tree origin/main HEAD clean) are < 1,000 LOC with 0 AST Any, 0 # type: ignore, and 0 bare os.O_NOFOLLOW:

  1. loopx/capabilities/native_chat/steward_turn.py (961 LOC), steward_turn_common.py (597 LOC), steward_turn_context.py (561 LOC), steward_turn_execution.py (688 LOC), steward_turn_recovery.py (897 LOC), steward_reports.py (993 LOC): clean decomposition and desktop caller mypy parity (73 -> 40).
  2. loopx/extensions/lark/steward_reports.py (401 LOC): _LarkTransportProtocol and _LarkOwnerAttentionProtocol aligned with LarkPrivateConversations and LarkOwnerAttention._route (22 -> 22 Lark caller mypy parity; preserves corrupt non-None saved rejection via as_dict(saved) if saved is not None else None).
  3. tests/test_steward_turn_controller_contract.py (254 LOC): runtime inspect.signature checks pass; both mypy contract probes at lines 134-174 and 214-254 fail closed gap (PRRT_kwDOStEbEs67wGxb).
  4. Protected #9355 files and loopx/canary/module_metric_baseline.json: 0 bytes diff.

对主干的风险 / Risks

  • Vacuous typecheck gate in CI: If CI or a developer runs tests/test_steward_turn_controller_contract.py under any environment where mypy aborts before typechecking (MYPYPATH, bad plugin/config, rc=2, or fatal stderr error), the test silently succeeds (2 passed) and masks breaking Protocol changes in ChatRuntimeController or LarkPrivateConversations.
  • What is already solid on 45ec850ff22b1fabff4fc3b0a1f693bf61e8d7f4: Desktop 4-caller mypy (73 -> 40), Lark 2-caller mypy (22 -> 22), 3,359 pytest tests, bare/strict mypy, ruff, TS typecheck + content_digest_single_owner.test.ts (17/17), semantic-vocabulary-drift-smoke (29/29), loopx check (0 errors), and canary premerge (6/6 direct, 10/10 selected) all passed under clean venv without MYPYPATH.

我的整体评价 / Verdict

REQUEST_CHANGES on 45ec850ff22b1fabff4fc3b0a1f693bf61e8d7f4 (superseding 6052621057 after independently reproducing PRRT_kwDOStEbEs67wGxb). Production code under loopx/ is solid and already meets desktop + Lark compatibility and < 1,000 LOC / 0 Any requirements; only tests/test_steward_turn_controller_contract.py needs fail-closed mypy completion-summary/stderr validation and negative abort coverage, plus resolving thread PRRT_kwDOStEbEs67wGxb.

Visual review decision: not_applicable — No rendered web/desktop UI or frontend files changed; inspected all 8 modified/added .py paths under loopx/capabilities/native_chat/, loopx/extensions/lark/, and tests/. Unverified scope: none (CLI/internal Python refactoring; no rendered views changed).

Residual risk: unguarded mypy abort causes false-green contract test passes until fixed; strongest missing validation is negative test coverage proving early-exit mypy (MYPYPATH=<site-packages> / stderr-only rc=1) is rejected by the contract helper.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

English verdict: APPROVE
Reviewed head: 14a5da0b75fe68bf912b2e7377f4e77fa60b4846
Reviewer: model_agent · Gemini · Google · self_reported · effort_unavailable

动机 / Motivation

  • Affected caller or operator: Maintainers of native Steward Chat runtime (loopx/chat_runtime.py), managed-mode hosts (loopx/capabilities/native_chat/steward_managed_mode.py), native/session periodic report adapters (loopx/capabilities/native_chat/steward_reports.py), and Feishu private report delivery (loopx/extensions/lark/steward_reports.py, loopx/extensions/lark/private_conversations.py, loopx/extensions/lark/owner_attention.py).
  • Before / after scenario: Before this PR, loopx/capabilities/native_chat/steward_turn.py had grown to 1,992 lines with 156 AST Any references; earlier PR heads uncovered desktop controller compatibility drift (PRRT_kwDOStEbEs67sDfn on b045198bc2), Lark transport signature drift (6051914913 on 34349829c8), and vacuous pass-on-abort mypy subprocess handling (PRRT_kwDOStEbEs67wGxb on 45ec850ff2). At exact head 14a5da0b75, all 8 Python modules stay strictly < 1,000 LOC with 0 AST Any, desktop/Lark mypy parity holds (73 -> 40 and 22 -> 22), and the shared _run_mypy_contract_probe helper fails loudly on early-exit or aborted mypy.
  • Observable outcome: All 8 touched/created Python modules are < 1,000 LOC (max 993 in steward_reports.py, 961 in steward_turn.py) with 0 AST Any and 0 # type: ignore; real ChatRuntimeController, ChatSessionStore, ChatConversationBindings, LarkPrivateConversations, ChatExternalConversations, and LarkOwnerAttention pass signature/runtime construction and dual mypy contract checks with fail-closed _collect_mypy_contract_errors completion verification; 3,360 targeted pytest checks pass; and standalone canary premerge passes.
  • Non-goals: Does not alter Chat turn execution semantics, StewardReports / ManagedSessionReports / LarkStewardReports delivery/recovery invariants, #9355 files (workbench_ledger.py, chat_manager.py, inspection.py), module_metric_baseline.json, private_conversations.py, owner_attention.py, or pre-existing unrelated mypy diagnostics in untouched caller files (chat_runtime.py: 27, steward_managed_mode.py: 13, private_conversations.py: 19, owner_attention.py: 3).

Accepted specification baseline checked against docs/development/testing-and-quality.md at revision f4c27a88b54e9f5daba0d282076328fb30b922ff:

  • TQ-L1: implemented — Real desktop controller/store/bindings and real LarkPrivateConversations / LarkOwnerAttention / ChatExternalConversations contract tests run with fail-closed mypy completion guards (tests/test_steward_turn_controller_contract.py:44-112, 273-316).
  • TQ-L2: implemented — Repository-native local verification (mypy, ruff, pytest, npm run typecheck:control-plane, canary premerge) qualifies the slice independently without waiting on remote CI.
  • TQ-R1: implemented — Desktop 4-caller mypy parity (PRRT_kwDOStEbEs67sDfn) drops diagnostics 73 -> 40 with zero StewardTurnHost(self) / StewardControllerProtocol errors.
  • TQ-R2: implemented — Lark 2-caller mypy parity (6051914913 / PRR_kwDOStEbEs8AAAABaLjkoQ) holds at 22 -> 22 with zero private_conversations.py:132 / _LarkTransportProtocol errors.
  • TQ-R3: implemented — Mypy probe abort regression (PRRT_kwDOStEbEs67wGxb / 6052585364 / 6052637284) now fails loudly when mypy exits early without analyzing target files (MYPYPATH=<site-packages> reproduces 2 failed in 0.49s vs prior false pass 2 passed in 0.54s).

改动思路 / Approach

Decomposes steward_turn.py into cohesive lifecycle helpers (steward_turn_common.py, steward_turn_context.py, steward_turn_execution.py, steward_turn_recovery.py) behind StewardTurnHost with shared _StewardReportsBase (steward_reports.py), aligns _LarkTransportProtocol / _LarkOwnerAttentionProtocol (loopx/extensions/lark/steward_reports.py) to real Lark callers, and enforces fail-closed mypy completion verification across both caller probes via shared _run_mypy_contract_probe / _collect_mypy_contract_errors.

Architecture boundary (current_pr_boundary): Bounded to native_chat Steward turn/report decomposition, loopx/extensions/lark/steward_reports.py transport/route typing, and real-host contract/mypy verification in tests/test_steward_turn_controller_contract.py; pre-existing diagnostics in untouched caller modules remain for separate cleanup PRs.

  • Shared fail-closed mypy completion guard (tests/test_steward_turn_controller_contract.py:37-112, 273-316):
    • _collect_mypy_contract_errors verifies proc.returncode in (0, 1), rejects non-empty proc.stderr, requires Success: no issues found in <N> source files on rc=0 or Found <E> error(s) in <F> file(s) (checked <N> source files) with E > 0 on rc=1 where <N> == 1 + len(callers), and formats rc + STDOUT + STDERR on assertion failures.
    • Both test_real_controller_protocol_and_four_callers_mypy_contract (:170-221) and test_real_lark_transport_protocol_and_callers_mypy_contract (:224-270) share _run_mypy_contract_probe, and test_mypy_contract_probe_rejects_early_exit_or_aborted_run (:273-316) verifies synthetic MYPYPATH stderr aborts (rc=1), truncated checked-file counts (1 vs 2), rc=2 fatal errors, and a live MYPYPATH=<purelib> subprocess abort.
  • Lark transport & desktop controller protocol alignment:
    • _LarkTransportProtocol (loopx/extensions/lark/steward_reports.py:53-79) and _LarkOwnerAttentionProtocol (:35-43) align with LarkPrivateConversations._inbox (-> Path), _deliver(..., text: str, *, inbox: Callable[[], Path], authorization_check: Callable[[], bool] | None = None), and LarkOwnerAttention._route, while _original_route (:88-109) preserves empty-dict rejection for corrupt non-None saved.
    • StewardControllerProtocol, StewardStoreProtocol, StewardBindingsProtocol (steward_turn_common.py:61-207) match real desktop classes; steward_turn.py preserves caller compatibility re-exports (lines 37-94); and _StewardReportsBase (steward_reports.py:87-391) eliminates 28 mypy errors across StewardReports and ManagedSessionReports.

具体改动 / Changes

All 8 diff files vs merge-base 35cb1d701a4ac85cf4430b48891197a979723d80 (git merge-tree --write-tree origin/main HEAD clean) are < 1,000 LOC with 0 AST Any, 0 # type: ignore, and 0 bare os.O_NOFOLLOW:

  1. loopx/capabilities/native_chat/steward_turn_common.py (597 LOC, new): typed Protocols, MonitorRestartCarrier TypedDict, runtime narrowers (as_mapping, as_dict, as_optional_dict, as_dict_list), and shared helpers.
  2. loopx/capabilities/native_chat/steward_turn_context.py (561 LOC, new): followup/governance context projection, user-action normalization, prompt builders, and response finalization.
  3. loopx/capabilities/native_chat/steward_turn_execution.py (688 LOC, new): execute_steward_turn, selection recovery, freeze-fence settlement, and event readback.
  4. loopx/capabilities/native_chat/steward_turn_recovery.py (897 LOC, new): monitor restart basis/carrier/request and frozen/stopped report recovery helpers.
  5. loopx/capabilities/native_chat/steward_turn.py (961 LOC, down from 1,992): StewardTurnHost orchestrating _observe, _admit, _prepare_submission, submit, and helper delegation with compatibility re-exports (lines 37-94).
  6. loopx/capabilities/native_chat/steward_reports.py (993 LOC): _StewardReportsBase + typed internal protocols (28 -> 0 mypy errors).
  7. loopx/extensions/lark/steward_reports.py (401 LOC): _LarkOwnerAttentionProtocol, _LarkCoreProtocol, and _LarkTransportProtocol aligned with real Lark owners (5 -> 0 mypy errors).
  8. tests/test_steward_turn_controller_contract.py (316 LOC, new): live desktop + Lark instantiation and inspect.signature checks, dual fail-closed mypy caller probes (_run_mypy_contract_probe / _collect_mypy_contract_errors), and early-exit/abort regression tests (test_mypy_contract_probe_rejects_early_exit_or_aborted_run).
  9. Protected #9355 files (workbench_ledger.py, chat_manager.py, inspection.py), loopx/canary/module_metric_baseline.json, private_conversations.py, and owner_attention.py: 0 bytes diff.

对主干的风险 / Risks

  • Dual caller mypy parity verified (origin/main vs 14a5da0b75fe68bf912b2e7377f4e77fa60b4846):
    • Desktop 4 callers (chat_runtime.py, steward_managed_mode.py, steward_reports.py, extensions/lark/steward_reports.py): 73 -> 40 diagnostics (chat_runtime.py: 27, steward_managed_mode.py: 13, steward_reports.py: 0, extensions/lark/steward_reports.py: 0).
    • Lark 2 callers (extensions/lark/private_conversations.py, extensions/lark/owner_attention.py): 22 -> 22 diagnostics (private_conversations.py: 19, owner_attention.py: 3; empty symmetric diagnostic diff vs base).
  • Module-size headroom & mock boundaries: steward_reports.py (993 LOC) and steward_turn.py (961 LOC) sit close to the 1,000-LOC ceiling; live Codex/Antigravity worker spawning and Feishu HTTP outbound sends run through unit mocks/fences in test suites (on 14a5da0b75fe68bf912b2e7377f4e77fa60b4846, CI Sign-off, inspect-pr-diff, loopx-repo-health, loopx-codex-provider-routing, loopx-obelisk, loopx-core, build, prepare, dependency-review, browser (2/3), and Summary all completed success; browser (1/3) and browser (3/3) remain queued and are not waited on per wait_for_ci: false).

我的整体评价 / Verdict

No blocking finding on 14a5da0b75fe68bf912b2e7377f4e77fa60b4846. All three prior [P2] findings — desktop controller compatibility (PRRT_kwDOStEbEs67sDfn, resolved), Lark transport compatibility (6051914913), and fail-closed mypy probe execution (PRRT_kwDOStEbEs67wGxb, resolved) — are verified closed on clean detached checkout 14a5da0b75fe68bf912b2e7377f4e77fa60b4846:

  • pytest -v tests/test_steward_turn_controller_contract.py (clean env): 4 passed in 16.76s
  • Negative live MYPYPATH=<site-packages> verification (pytest -v tests/test_steward_turn_controller_contract.py -k "four_callers or lark_transport"): 2 failed, 2 deselected in 0.49s (AssertionError: mypy reported errors on stderr, proving aborted mypy can no longer pass vacuously)
  • pytest -n 6 (30 steward test suites + tests/architecture/ + tests/canary/test_maintainability_ratchet.py): 3,360 passed in 971.84s (0 failed, 0 skipped)
  • Bare mypy --no-incremental (17/17), --strict --follow-imports=silent (8/8), 4-caller desktop (40) & 2-caller Lark (22) mypy parity, ruff check (8/8), npm run -s typecheck:control-plane, content_digest_single_owner.test.ts (17/17), check_rfc_bilingual.py, semantic-vocabulary-drift-smoke.py (29/29), and loopx check (8/8 files, 0 errors): all passed
  • Standalone loopx canary premerge --from-git-diff --git-diff-base 35cb1d701a4ac85cf4430b48891197a979723d80: gate.status=passed, direct_checks=6/6, catalog_run=2/2, risk_profile_run=8/8, failures=0

Visual review decision: not_applicable — No rendered web/desktop UI or frontend files changed; inspected all 8 modified/added .py paths under loopx/capabilities/native_chat/, loopx/extensions/lark/, and tests/. Unverified scope: none (CLI/internal Python refactoring; no rendered views changed).

Residual risk: live upstream Codex/Antigravity worker execution and Feishu HTTP outbound sends rely on unit mocks/fences; strongest missing validation is full end-to-end live provider integration.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI (runtime_reported, xhigh)

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

维护 Native Steward 和飞书私聊回传的开发者,需要在拆分模块后核对真实调用方的类型兼容与结果恢复。 原有 Steward Turn 文件同时管理执行、上下文和恢复。本 PR 拆开这些职责,上一头还存在一处验收缺口。若 mypy 在分析前退出且错误只显示在 stderr,桌面和飞书的契约测试都可能误报通过。 测试若把类型分析未启动当成兼容,模块拆分出现真实调用签名问题时就失去预期的回归保护。 用同一真实解释器运行上一头和当前头的两项类型契约,再对照正常类型分析、原会话结果重读及飞书报告的原来源路由。 正常的四项类型契约均通过。实际 mypy 尚未分析就退出时,上一头两个 pytest 场景报告通过,本头两个都明确失败并保留 stderr。原路径上的报告、恢复和路由测试通过。 验证使用隔离工作树、本地存储和合成上游,真实飞书和托管 CI 未运行。

改动思路 / Approach

维持既有 StewardTurnHost、报告 transport 和会话存储。拆分把上下文构建、执行和恢复放回各自模块,桥接层沿用生产调用。共享 mypy fixture 只拥有测试进程完成性的判断。 前一头的 Lark 类型修复保持,交付可验证的真实调用验收。记录较多的协议适配和兼容桥接是当前拆分的维护成本。 让桌面和飞书的契约共用 mypy 完成性判断,保留既有可定位的类型诊断和错误回执。

具体改动 / Changes

精确头 14a5da0b75fe68bf912b2e7377f4e77fa60b4846,目标分支快照 35cb1d701a4ac85cf4430b48891197a979723d80。8 个文件新增 4,661 行、删除 2,264 行。相对上一头只改已有类型契约测试,新增 183 行、删除 121 行。 上一头 45ec850 的两项负对照误通过,本头保留错误并失败。基线和本头的相同报告恢复与原路由测试结果一致。两头间只有测试文件变化。

关键代码讲解

  • _collect_mypy_contract_errors。先核对退出码、stderr 和实际检查文件数,再归类 probe 与 caller 的诊断。 源码

  • _run_mypy_contract_probe。用同一实际解释器和仓库配置执行类型分析,给每次验收独立缓存。 源码

  • StewardTurnHost。维持现有桥接入口,拆出的工作以原 Controller、Session Store 和会话身份为依据。 源码

  • _LarkTransportProtocol。按现有传输适配器的类型边界接收私聊报告,保持原会话路由。 源码

  • MYPY_PROBE_MUST_RUN 已满足。重构沿正常入口验证已有调用。需要真实类型分析的检查只可在 mypy 实际分析完之后通过。 现有依据

对主干的风险 / Risks

以同一个无效 MYPYPATH 启动现有解释器,令真实 mypy 在接触任何输入前退出。 同一测试命令在上一头跑出 2 passed。在当前头跑出 2 failed,实际 stderr 显示 mypy 未进入分析。正常配置下当前头四项通过。 正常运行及提前退出均在相同解释器上对照。 使用 mypy 的退出状态与官方文本完成摘要作为本地测试证据。既有会话、来源和恢复的状态所有权保持原样。 分析没有完成时验收失败,已完成时继续按两类实际调用方筛查诊断。

语义与 CI 对齐

PASS — 正常 4 项通过,同一个提前退出反例在上一头 2 项误过、本头 2 项如预期失败。目标基线和当前头各运行同组 28 项恢复及报告测试,均通过。三个原模块的 17 个顶层定义及类方法均可从本头原位置访问。git diff --check 和标准本地 premerge 通过。 UNVERIFIED — 独立证据覆盖所跑的桌面和飞书报告路径,线上飞书发送、其余 provider 和全套托管 CI 未复验。

我的整体评价 / Verdict

APPROVE。 版本修订补上类型验收的假通过,原会话出站与中断结果回读继续按现有路径。 前一头的 Lark 类型修复保持,交付可验证的真实调用验收。记录较多的协议适配和兼容桥接是当前拆分的维护成本。 剩余验证范围见上。

English verdict: APPROVE. The real mypy early-exit case now fails both contract probes. Normal checks and the exercised Steward and Lark recovery paths pass.

@mergify

mergify Bot commented Nov 25, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @loopx-agent.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

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 HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 25, 2026
@loopx-agent
loopx-agent force-pushed the codex/slim-steward-turn-zero-any-20261125 branch from 14a5da0 to 4d2803e Compare November 25, 2026 17:32
@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 25, 2026

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

精确提交 4d2803e645c28fe47905cea403f8b4480d6712f0 的复核通过。冻结报告仍使用原始发送,保留原会话结果和重试证据。

动机 / Motivation

维护 Native Steward 的调用方,以及通过原会话和飞书私聊获取定期报告的用户。 真实本地入口继续为报告指向原冻结材料,受管日历任务从原验收返回并在结果写入后确认;恢复不替换原任务或报告。 基线与当前提交均以隔离、raw_prompt 的 Antigravity 调用提交冻结报告,模型输入保留 Turn request 和冻结文件,省略未冻结会话材料。 依据 Refactor Real-Path Gate 核对真实本地入口、恢复和回执。线上负载、安装和实际提供方留在其验收范围。未复验线上模型与飞书实际送达、安装采用、远端 CI 和长期成本。 仓库真实路径验收

改动思路 / Approach

让过大的 Steward Turn 模块按执行、上下文、恢复和报告调用边界分工,保留原始任务身份、冻结输入和发布回执。 StewardTurnHost → execute_steward_turn → 原生 Turn 和来源/租约检查 → 报告冻结或任务验证 → 原会话和 Lark 读回。 单独修改类型可减少注解使用,拆分职责让恢复可以独立读回和验证。两个报告服务复用原窗口、失败和冻结判断,入口保留自己的来源与回传责任。原 CLI 和会话运行机理保留,代码职责按现有调用路径分配。

具体改动 / Changes

受审提交 4d2803e645c28fe47905cea403f8b4480d6712f0,基线 50aa5b4fd1c88b7225fc30e58423120e3ad5d426。8 个文件增加 4,677 行、删除 2,270 行。兼容入口保持原方法签名,新增 common、context、execution、recovery 四个模块。报告窗口和失败恢复复用已有 owner,Lark 仍需确认原来源和推送回执。8 个文件的源码 AST 无 Any 和 type ignore,最长 993 行。五个提交均有 DCO。相对前一版补回主干 #9438 的冻结报告提示精简和 Antigravity raw 请求,原 mypy 完成性保护继续通过。

关键代码讲解

  • StewardTurnHost。保留公共入口和原会话查验,将执行与恢复交给现有职责边界。 源码
  • build_steward_turn_prompt。用已冻结报告的权威输入构建提示,普通任务仍读取已获授权的上下文。 源码
  • execute_steward_turn。用原生命令承载选择、启动栅栏和完成验收。 源码
  • _append_native_result_with_readback。丢失写入确认时按原会话、原轮次和唯一已提交结果读回。 源码
  • recover_report_settlement。恢复原报告的剩余结算与结果,维持原有执行身份。 源码
  • _StewardReportsBase。汇聚两种报告共享的窗口、失败收尾和冻结规则。 源码
  • LarkStewardReports.reconcile。只在原来源与回执仍匹配时从现有私聊入口返回报告。 源码
  • _collect_mypy_contract_errors。核验真实 mypy 完成摘要和分析文件数量后再判断调用方诊断。 源码

对主干的风险 / Risks

定时报告的最重要风险是冻结来源与活动会话材料混用,以及重试或结果写入确认丢失后重复工作。基线与当前提交均以隔离、raw_prompt 的 Antigravity 调用提交冻结报告,模型输入保留 Turn request 和冻结文件,省略未冻结会话材料。 恢复时保留原准入证明;报告后缀读取发生超时,下一合法周期仍可恢复;丢失结果事件写入确认时,使用同一会话的原提交读回。 将未冻结上下文标题仅在当前源码的内存调用重新加入,原报告入口测试在原始提示检查断言处失败。 下一周期恢复与普通日历回读沿原入口,仍由原任务独立验证。

语义与 CI 对齐

  • PASS。两侧另各通过 7 项 Native/报告场景及 8 项日历场景。标准预合并 6 项直接检查、10 项所选检查通过,8 个改动文件的 Ruff 和严格 mypy 通过。
  • FAIL 与复验。并行组合跑基线 86 通过、2 超时,当前提交 90 通过、2 超时。同两项恢复用例单独串行重跑,两侧各 2 项通过。并行超时的触发因素未定位。
  • UNVERIFIED。未复验线上模型与飞书实际送达、安装采用、远端 CI 和长期成本。 同一主机的两份独立源码工作树,真实本地 Chat、存储和回执入口。模型响应、飞书发送及语言服务使用仓库合成边界。

我的整体评价 / Verdict

APPROVE。 当前提交保留了主干的冻结报告输入、原始发送和现有回执恢复规则。两侧独立运行覆盖了普通执行、失败恢复和重启读回,未发现当前提交的阻塞项。并行等待超时留在验证记录中。

English verdict: APPROVE at 4d2803e. Frozen report input, raw Antigravity dispatch and original result readback were preserved. Both parallel runs timed out in the same two cases, and both passed the isolated reruns.

@mergify

mergify Bot commented Nov 26, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @loopx-agent.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

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 HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 26, 2026
@loopx-agent
loopx-agent force-pushed the codex/slim-steward-turn-zero-any-20261125 branch from 4d2803e to a7242af Compare November 26, 2026 05:48
@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 26, 2026

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

Steward 的原生入口同时负责执行、冻结报告、治理和历史恢复。维护 Native Steward 的调用方,以及通过原会话和飞书私聊获取定期报告的用户。 按 32 组输入比较治理、冻结报告、普通轮次和 Steward 后续的完整提示,两侧 182,219 字节完全相同。治理保留重规划包和 typed 收口,冻结报告保留 raw 调用,普通轮次保留自己的会话证据。 两份精确源码都通过冻结报告与治理重规划的两项生产入口用例。真实本地 Chat、SQLite、原生写回与 Lark 回读使用测试夹具的模型回复和传输。 生产入口先写回并核验原报告,再触发原生选择延迟,随后通过原报告的治理路径完成写回。普通轮次的完成资格按其原身份选择。 未复验线上模型、飞书实际送达、正式安装采用、远端 CI 与长期成本。 Refactor Real-Path Gate

改动思路 / Approach

保留 StewardTurnHost 的调用接口。共享类型承接原调用,提示、执行和恢复各自落在原职责,报告服务共用冻结窗口与回执规则。单独改注解主要降低类型诊断,执行与恢复的维护仍会集中在原模块。StewardTurnHost → execute_steward_turn → 原生 Turn 和来源/租约检查 → 报告冻结或任务验证 → 原会话和 Lark 读回。 让过大的 Steward Turn 模块按执行、上下文、恢复和报告调用边界分工,保留原始任务身份、冻结输入和发布回执。

具体改动 / Changes

基线 7f7297a790771dab08e2444700f4d76699169950,受审提交 a7242afd94c60d0b7656e9c1de4414a1d869b2e9。8 个文件增加 4,802 行、删除 2,272 行,最长 993 行。与上一有效评审的八个改动文件对照,六个源码文件逐字相同。治理提示模块和控制器测试同步主干 #9474。现在基线含 #9438 与 #9474,两处均用现版本实际入口及精确提示对照复验。 新增的控制器契约测试核对真实 Chat 和 Lark 调用形状,校验 mypy 的实际扫描完成和文件计数。两种报告服务继续使用同一冻结窗口,在各自原会话中验证发布读回。

对主干的风险 / Risks

治理路径同时带有报告标志时仍须先保留重规划义务。原报告产出后的次日窗口按原生选择延迟处理,并通过后续治理和同会话回执继续推进。

  • 新增契约套件 5 项通过,8 文件 Ruff 与严格 mypy 通过,标准预合并 6 项直接检查及 10 项所选检查通过。
  • 初次并行宽套件的主干与候选均发生本地等待超时,宽套件已停止。两份源码的关键报告和重规划用例通过独立串行复跑,测试观察窗口由 15 秒调到 75 秒,产品逻辑与原断言未改。 首跑预合并缺少锁定的 TypeScript 依赖。补齐相同锁文件依赖后,语义词表及两项飞书检查仍超出默认 120 秒。用相同标准检查集、干净 HOME 与 300 秒单项本地运行上限复验。
  • 未复验线上模型、飞书实际送达、正式安装采用、远端 CI 与长期成本。

我的整体评价 / Verdict

APPROVE。 当前提交保留了最新主干的治理优先级、冻结报告的原始发送方式和原会话写回。当前证据覆盖拆分后的提示及受管报告路径。此次评审的线上范围如上。

English verdict: APPROVE at a7242af. The rebased exact head preserved governance and frozen-report prompts across 32 paired inputs, as well as native report and replan settlement with SQLite and synthetic transports.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · Gemini · Google DeepMind · self_reported

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

  • Target: PR #9417 (codex/slim-steward-turn-zero-any-20261125 -> main), exact head a7242afd94c60d0b7656e9c1de4414a1d869b2e9, base 7f7297a790771dab08e2444700f4d76699169950.

动机 / Motivation

Maintainers and Steward runtime callers across ChatRuntimeController, StewardTurnHost, StewardReports, ManagedSessionReports, LarkStewardReports, and native session calendar tasks (SessionCalendarTasks).

Previously, steward_turn.py combined execution, context/prompt building, recovery, and action helpers in one monolith with Any annotations while StewardReports carried Any controller/return types. This rebase splits steward_turn into <1000-LOC zero-Any modules and ports #9474 governance prompt slimming cleanly, but omits strict on StewardStoreProtocol.messages and leaves subclass SessionCalendarTasks un-narrowed so session_calendar_tasks.py jumps from 43 to 82 mypy diagnostics (+39 regressions).

The modular split and #9474 prompt/completion behavior pass all static zero-Any checks, TS tests, canary premerge, and paired prompt/normalization counterfactuals, while caller mypy regresses +39 errors on SessionCalendarTasks until StewardStoreProtocol.messages adds strict and SessionCalendarTasks is narrowed.

边界与非目标(Non-goals):Does not change persisted report/journal/turn schemas, alter periodic-report eligibility or completion gates, or require eliminating all 43 pre-existing untyped warnings in session_calendar_tasks.py unrelated to the PR boundary.

如果不先修补协议签名与调用方窄化,虽然运行时鸭子类型暂时不报错,但直接继承 ManagedSessionReports 且在 steward_turn_context.py 中实际调用的 SessionCalendarTasks 会因 StewardStoreProtocol.messages 缺少 strict 参数、_StewardReportsBase.subscription 覆盖签名变化以及 selected() / registry_path 收紧而在类型检查下新增 39 个错误(违反本 PR 已在 PRRT_kwDOStEbEs67sDfn 建立的调用方 mypy 零回归约束)。

改动思路 / Approach

Splitting steward_turn into acyclic steward_turn_common/context/execution/recovery modules and extracting _StewardReportsBase keeps each module <1000 LOC with zero Any while keeping Core/TS as the decision owner, and retaining facade re-exports on steward_turn.py avoids breaking imports; however, StewardStoreProtocol.messages must match ChatSessionStore.messages(..., strict: bool = False) and SessionCalendarTasks must not regress.

当前边界(Current boundary):Bounded to modularizing steward_turn and steward_reports/lark_steward_reports to zero Any, porting #9474 governance replan prompt slimming, and fixing the remaining StewardStoreProtocol.messages / SessionCalendarTasks caller mypy regression without expanding into unrelated periodic-report changes.

拆分结构与阻塞点核验说明:

  • 已验证成立的主体拆分与 #9474 移植:steward_turn_common.py(597 行)、steward_turn_context.py(585 行)、steward_turn_execution.py(689 行)、steward_turn_recovery.py(897 行)、steward_turn.py(961 行)、steward_reports.py(993 行)与 extensions/lark/steward_reports.py(401 行)全部 <1000 行且 0 AST Any / 0 抑制注释;build_steward_turn_prompt 与 #9474 的 governance_turn_prompt_authority / allow_completion=False / 非 CLI 提醒句子完全字节对齐。
  • 唯一发现的阻塞缺陷([P2]):steward_turn_common.py 中的 StewardStoreProtocol.messages(self, session_id: str) 遗漏了 ChatSessionStore.messages 的 *, strict: bool = False 关键字参数;同时 steward_reports.py 新增 _StewardReportsBase 并把 ManagedSessionReports.selected() 与 self.controller 从 Any 收紧为 dict[str, object] / StewardControllerProtocol,却未同步检查或窄化同目录下直接继承 ManagedSessionReports 的 loopx/capabilities/native_chat/session_calendar_tasks.py(318 行),也未将该文件纳入 tests/test_steward_turn_controller_contract.py。

调用方类型约束关系示意(Illustrative · exact head a7242afd94c60d0b7656e9c1de4414a1d869b2e9 · symbols StewardStoreProtocol, ManagedSessionReports, SessionCalendarTasks):

flowchart LR
  A["ChatSessionStore.messages(..., strict=False)"] -. "omits strict" .-> B["StewardStoreProtocol.messages(session_id)"]
  C["_StewardReportsBase & ManagedSessionReports (object/Protocol)"] --> D["SessionCalendarTasks subclass"]
  B --> E["L181 call-arg error: unexpected strict=True"]
  D --> F["+39 net mypy caller regressions (43 -> 82)"]
Loading

具体改动 / Changes

  • 规范映射(Spec basis):对照 docs/reference/protocols/periodic-report-v0.md(固定提交 d9d4ea73cd7f432174814bda57a3e3060b3e866c):
    1. PR-HOST-SPLIT(保持原 Session 报告/Turn 宿主隔离与无新增状态存储,仅做模块化切分):已实现于 steward_turn*.py 与 steward_reports.py,并通过 ruff(8/8)、mypy --strict(8/8 0 错)、tests/test_steward_turn_controller_contract.py 与 canary premerge。
    2. PR-GOV-REPLAN-9474(governance_work 使用 governance_turn_prompt_authority 与 allow_completion=False、report_work 使用 report_turn_prompt_authority 与 allow_completion=True、else 使用 managed_turn_active or steward_advancement):已精确移植于 steward_turn_context.py::build_steward_turn_prompt 与 steward_turn_execution.py,并通过成对 7f7297a790 vs a7242afd94 反事实 23,328 字节 100% 匹配验证。
    3. PR-CALLER-MYPY(StewardStoreProtocol 与 ManagedSessionReports 协议收紧不得引入调用方 mypy 回归):未满足(not_met)。mypy --no-incremental --follow-imports=silent loopx/capabilities/native_chat/session_calendar_tasks.py 从基线 43 增至 82(+40 新增 / -1 修复 = +39 净回归),包含 session_calendar_tasks.py:181 的 [call-arg](StewardStoreProtocol.messages 缺少 *, strict: bool = False)、第 34 行 subscription 与 _StewardReportsBase [override] 冲突、6 处 registry_path (Path | None) [arg-type] 及 32 处 object 属性/索引报错。
  • 阻塞发现与最小修复([P2]):
    • [P2] 补齐 StewardStoreProtocol.messages 的 strict 参数并消除 session_calendar_tasks.py 调用方 mypy 回归(43 -> 82):
      1. 在 loopx/capabilities/native_chat/steward_turn_common.py:84 为 StewardStoreProtocol.messages 补上 *, strict: bool = False,并在 tests/test_steward_turn_controller_contract.py 的 protocol_methods 列表中加入 (StewardStoreProtocol, ChatSessionStore, "messages")。
      2. 在 loopx/capabilities/native_chat/session_calendar_tasks.py 对继承 ManagedSessionReports 的 subscription、selected()、controller.registry_path 做最小类型标注/窄化(例如 as_dict/as_mapping/cast(Path, ...),不改变运行时行为,使其 mypy 诊断回归降为 0,即 <= 43),并将其加入 tests/test_steward_turn_controller_contract.py 的调用方 mypy 守卫。
  • 精确头部文件清单(exact head a7242afd94c60d0b7656e9c1de4414a1d869b2e9):
    • steward_reports.py(993 行,0 Any)、steward_turn.py(961 行,0 Any)、steward_turn_recovery.py(897 行,0 Any)、steward_turn_execution.py(689 行,0 Any)、steward_turn_common.py(597 行,0 Any)、steward_turn_context.py(585 行,0 Any)、extensions/lark/steward_reports.py(401 行,0 Any)、tests/test_steward_turn_controller_contract.py(432 行,0 Any)。

对主干的风险 / Risks

  • 合入冲突与跨分支风险:git merge-tree --write-tree 对照 7f7297a790 返回干净树 419ce717d2f78ba760a6b01184be2c68a275d778,无文本冲突;主仓库内全仓 15 个相关文件中其余 14 个零回归(chat_runtime.py 27->27、steward_managed_mode.py 13->13、private_conversations.py 19->19、steward_monitor.py 19->19、steward_reports.py 28->0、steward_turn.py 59->0、extensions/lark/steward_reports.py 5->0、goal_configuration_api.py 4->3)。
  • 如果不修复直接合入的风险:SessionCalendarTasks 是 ManagedSessionReports 的同包直接子类且在 steward_turn_context.py / steward_monitor.py 活跃路径中被调用;合入后会让 session_calendar_tasks.py 在 main 上新增 39 个 mypy 错误(包括对 StewardStoreProtocol.messages(..., strict=True) 的合法调用报错 [call-arg]),直接阻碍后续 native_chat 模块的 Zero-Any 清理并违背同 PR 审查标准(参考已解决的 PRRT_kwDOStEbEs67sDfn)。

我的整体评价 / Verdict

PR #9417 的模块拆分、0-Any 边界、#9474 governance prompt 精确移植、TS 契约与反事实行为等价性都做得很扎实,但因 StewardStoreProtocol.messages 遗漏 strict: bool = False 且遗漏直接子类 session_calendar_tasks.py 的调用方收窄(43 -> 82 mypy 回归),按同类 Protocol/调用方零回归标准需退回小修后再通过。

  • 视觉评审边界(Visual review):不适用(not_applicable)。reason: No rendered HTML, CSS, DOM, dashboard view, or visual UI component was changed across the 8 modified Python and test files. unverified_scope: none; verified all 8 changed paths in the PR diff contain only backend native-chat, Lark adapter, and test code.
  • 本地验证实测结果汇总:
    • ruff check(8 文件):0 issues;mypy --strict --no-incremental --follow-imports=silent(8 文件):0 errors;[tool.mypy](17 文件):0 errors。
    • 15-caller mypy --no-incremental --follow-imports=silent(7f7297a790 vs a7242afd94):14/15 零回归(总诊断 254 -> 200),但 loopx/capabilities/native_chat/session_calendar_tasks.py 从 43 增至 82(+39 净回归,失败 [P2])。
    • scripts/check_rfc_bilingual.py passed;npm run typecheck:control-plane clean;TS content_digest_single_owner (17/17) + steward_reports (12/12):29/29 passed。
    • 成对反事实(7f7297a790 vs a7242afd94):23,328 bytes JSON 100% 一致(_normalize_steward_actions, _normalize_report_kernel_candidate, _normalize_steward_advancement_kernel_candidate, 4 种 prompt 模式)。
    • Clean-HOME smokes(control-plane-maintainability-ratchet, semantic-vocabulary-drift):2/2 passed;loopx check (8 文件 0 errors) & canary premerge (gate.status="passed", 10/10 checks passed)。
    • 定向扩展 pytest -q -n 6 -rs:3359 passed, 6 skipped in 1539.68s (0:25:39) across 27 Steward/calendar suites + tests/architecture + tests/canary (all 6 skipped in tests/canary/test_git_path_display.py due to APFS non-UTF-8/root name limits)。

结论(Author-owned PR,COMMENTED):存在 1 项需修复的 [P2] 调用方协议/类型回归,请修复后重审。

English verdict: REQUEST_CHANGES

@mergify

mergify Bot commented Nov 26, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @loopx-agent.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

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 HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 26, 2026
@loopx-agent
loopx-agent force-pushed the codex/slim-steward-turn-zero-any-20261125 branch from a7242af to d25aab0 Compare November 27, 2026 15:10
@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 27, 2026
@mergify

mergify Bot commented Nov 27, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @loopx-agent.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

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 HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 27, 2026

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

维护 Steward 执行、恢复、定时报告和日历任务的开发者。 上一提交在共享类型中遗漏了消息读取的 strict 参数,也让日历任务调用方的 mypy 错误从 43 增到 82。 调用方协议与 store 对齐,日历任务错误降到零。对照保留原任务、冻结报告及治理入口。 改动覆盖 Steward 宿主、报告与直接调用方。继续使用同一会话、调度和验证所有者。

改动思路 / Approach

把提示、执行和恢复放回已有职责边界。沿用 StewardTurnHost 接口和逐轮的原生规则,调用方类型在实际读回处收窄。 改动覆盖 Steward 宿主、报告与直接调用方。继续使用同一会话、调度和验证所有者。 输出仍靠原请求与原会话关联,冻结报告要通过原窗口回读。调用方无需改写旧状态或补做一次确认。报告和治理沿用各自的材料输入,拆分不会新增一个发布流程。

具体改动 / Changes

基线 11a3b9a,精确提交 d25aab0。九个文件增加 5046 行、删除 2392 行。改动包含从原宿主移动的提示、执行和恢复逻辑,以及补齐此前遗漏的日历调用者。refactor-live-path 与 strict-calendar-caller 均用当前提交复核。 验收契约

关键代码讲解

  • StewardStoreProtocol.messages 补齐实际消息读取的 strict 关键字参数,日历恢复仍校验原回执。 协议
  • SessionCalendarTasks.admission 保留原会话窗口及声明核对,允许恢复的条件仍由真实原任务和冻结记录给出。 日历入口
  • build_steward_turn_prompt 保留现有治理和冻结报告的提示选择。report_selection_recovery 按既有记录确认恢复条件。 提示 · 恢复

对主干的风险 / Risks

两份同输入源码各通过 12 项日历任务用例,包含正常结果、原回合重启恢复、读取不到验证记录和任务范围变化。两份源码各通过 2 项原报告与治理提示用例。 九个变更 Python 文件通过 Ruff 及严格 mypy,日历直接调用方的诊断从 43 降至零。广测读回为 1 failed, 451 passed in 593.08s (0:09:53)。旧调用方类型回归已修复。两份源码的 owner_attention 仍各有同样 4 条诊断,其中既有 _read_json 导出问题使当前契约套件有一项失败。 当前基线同一调用方逐行复现,相关修复见 #9521。核对本机隔离的原生会话、合成模型与 Lark 传输。远端 CI、真实账号及已安装发布版未验证。

语义与验证对齐

冻结报告继续保留原始提示材料,治理分支保留原完成权限及收口。正常日历、验证不可用、范围变化和原回合重启均有本机成对验证。本次沿用现有状态和报告规则。

我的整体评价 / Verdict

当前提交修复了此前的消息协议和日历类型回归,并保留测试覆盖的原窗口恢复和结果读回。Steward 仍从原会话继续执行,用户使用同一入口。整套契约中的既有类型失败仍待 #9521 处理。核对本机隔离的原生会话、合成模型与 Lark 传输。远端 CI、真实账号及已安装发布版未验证。

English verdict: APPROVE at d25aab0. The original calendar caller and protocol regressions are fixed, and targeted live-path comparisons passed. The existing owner_attention typing failure remains tracked.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

动机 / Motivation

安装或移除可选 Workspace 的 Core 用户,以及维护原生管家轮次和会话日历的开发者。基线把管家宿主和监控放在 Workspace,候选拆出四个文件后由 Core 打包,留下一个依赖 Workspace 的恢复模块。上一轮的消息协议与日历类型问题已修复。本轮额外实测发现候选纯 Core 包含 Workspace 所属的恢复代码,其导入依赖只随 Workspace 安装。交付范围为 Steward 启动、会话日历和报告恢复的拆分及现有调用方类型。

改动思路 / Approach

StewardTurnHost 保持会话与轮次编排,原会话存储及报告授权仍拥有各自状态。拆分发行的文件归属由 packages/loopx-core/prepare.py 决定。交付范围为 Steward 启动、会话日历和报告恢复的拆分及现有调用方类型。按原宿主职责拆模块可以保留同一报告和恢复证据。分包清单需要同时保留这些模块与其运行依赖的归属。 用两套精确提交生成同源的 Core 与 Workspace wheel,依次验证纯 Core、配套安装和移除 Workspace 后的行为。

具体改动 / Changes

精确提交 d25aab0c4f1718c2abad1669f6e9e5c064a5dd3a,对照 11a3b9aa354aca53d5d55dabf3cc425f5bcf7a75。九个文件增加 5046 行、删除 2392 行。

  • loopx/capabilities/native_chat/steward_turn.py。保留管家会话入口与启动、恢复编排。
  • loopx/capabilities/native_chat/steward_turn_common.py。抽出互用类型、宿主协议和只读帮助函数,补齐消息读取的 strict 参数。
  • loopx/capabilities/native_chat/steward_turn_context.py。构造普通、治理和冻结报告的轮次上下文。
  • loopx/capabilities/native_chat/steward_turn_execution.py。搬移原生轮次请求与执行路径。
  • loopx/capabilities/native_chat/steward_turn_recovery.py。搬移定时监控恢复和停止的报告恢复。
  • loopx/capabilities/native_chat/session_calendar_tasks.py。收窄现有会话日历查询与恢复字段。
  • loopx/capabilities/native_chat/steward_reports.py。为原报告构造、状态与回读使用明确的字段。
  • loopx/extensions/lark/steward_reports.py。收窄飞书呈现已有报告的输入契约。
  • tests/test_steward_turn_controller_contract.py。覆盖真实控制器、日历调用方与飞书传输协议。

关键代码讲解

  • _workspace_source。按 Workspace 文件清单与既有路径规则分发行包。清单列出了原宿主和监控模块,未覆盖四个新模块。 源码
  • steward_turn_recovery 的监控导入。加载时必须导入留在 Workspace 的 steward_monitor。纯 Core 可查到恢复模块,但无法载入。 源码
  • StewardStoreProtocol.messages。支持实际存储的 strict 关键字,恢复调用方可按原契约校验消息。 源码
  • build_steward_turn_prompt。沿用已冻结的定时报告和治理轮次材料。 源码
  • SessionCalendarTasks.admission。沿原会话窗口和调度依据检查任务准入。 源码

workspace-steward-ownership 对照现有发行说明中的管家适配器归属。workspace-disable-parity 在移除 Workspace 后核对 Core 入口和已安装文件。基线发行说明

对主干的风险 / Risks

[P2] Core wheel 携带无法独立导入的管家恢复模块。 候选 Core 独占 steward_turn_common、steward_turn_context、steward_turn_execution 和 steward_turn_recovery 四个新模块。仅安装 Core 和从配套安装移除 Workspace 后,find_spec 均能找到 steward_turn_recovery,但导入因缺少 Workspace 的 steward_monitor 抛出 ModuleNotFoundError。基线原宿主和监控模块均只在 Workspace。 两边纯 Core 的 doctor --installation-only 都通过,chat --help 都退出 2,说明现有 CLI 门禁仍有效。把四个拆分模块归入原 Workspace 文件清单,并在构建并安装配套 wheel 后验证加入和移除 Workspace 的模块归属及导入。 分包规则 · 导入位置

两份精确源码各有 5 个配对的日历、报告启动、治理或恢复测试通过。配套候选 wheel 可导入管家模块,chat --help 退出 0。三项候选发行回归通过,覆盖 wheel 所有权及任务由 Workspace 读回、移除后由 Core 重放。真实控制器及日历调用方协议检查通过,消息读取支持 strict。同一严格 mypy 配置下日历诊断从基线 43 降至 0。定向契约套件 4 通过、1 失败,失败是 owner_attention 两边相同的 4 条诊断,新用例的上限为 3,其中包含现有 _read_json 未显式导出的缺口。 原 Lark 导出问题 #9521

语义与验证对齐

源码配对覆盖原报告与治理材料、日历和恢复,实际发布包的验证补上了同一提交早先源码评审未覆盖的安装边界。本轮在隔离安装中验证包归属、真实导入与命令可用性。真实飞书账号、混装不同发布版本和远端 CI 未实测。

我的整体评价 / Verdict

REQUEST_CHANGES。 当前提交修复了上一轮的管家协议和日历类型问题。请补齐四个新模块的 Workspace 归属,并用实际 Core 与 Workspace wheel 验证安装和移除。

English verdict: REQUEST_CHANGES at d25aab0. The calendar and protocol fixes passed paired source checks. The Core-only wheel ships four Steward modules that belong to Workspace. Its recovery module fails to import both in a clean Core installation and after Workspace is removed.

@loopx-agent

Copy link
Copy Markdown
Collaborator Author

Supplemental exact-head verification note at d25aab0c4f1718c2abad1669f6e9e5c064a5dd3a (alongside review 6090400339, which already holds REQUEST_CHANGES for packages/loopx-core/prepare.py#L152 Workspace packaging of the four steward_turn_* modules):

[P1] Merge conflict with origin/main (2302e42d9cad35a8a4150e24496ffecfbfdce8cb, #9513) leaves task_postcondition recovery unported

  • origin/main has merged #9513 (2302e42d9cad35a8a4150e24496ffecfbfdce8cb), putting PR #9417 into mergeable=CONFLICTING / mergeStateStatus=DIRTY (git merge-tree --write-tree 2302e42d9cad35a8a4150e24496ffecfbfdce8cb d25aab0c4f1718c2abad1669f6e9e5c064a5dd3a fails with a content conflict in loopx/capabilities/native_chat/steward_turn.py).
  • Commit 2302e42d9cad35a8a4150e24496ffecfbfdce8cb expanded report_selection_recovery's validation_stage check in steward_turn.py from == "host_result_contract" to in {"host_result_contract", "task_postcondition"}. On d25aab0c4f1718c2abad1669f6e9e5c064a5dd3a, that helper now lives in loopx/capabilities/native_chat/steward_turn_recovery.py#L364-L366 and still checks only "host_result_contract".
  • Minimum repair: Rebase onto current origin/main (2302e42d9cad35a8a4150e24496ffecfbfdce8cb or newer), resolve steward_turn.py, update steward_turn_recovery.py#L366 to journal.get("validation_stage") in {"host_result_contract", "task_postcondition"}, and rerun pytest -q tests/test_steward_report_recovery_and_validator.py tests/test_native_steward_reports.py tests/capabilities/test_steward_monitor_contract.py plus git merge-tree --write-tree origin/main HEAD.

[P2] New contract test test_real_lark_transport_protocol_and_callers_mypy_contract fails unfiltered on current main (1 failed, 4 passed)

  • tests/test_steward_turn_controller_contract.py#L275-L278 pins <= 3 mypy errors on untouched loopx/extensions/lark/owner_attention.py, which fails assert 4 <= 3 on current main due to owner_attention.py:17 (loopx.chat_store._read_json [attr-defined], tracked separately in open #9521).
  • Minimum repair: Assert only protocol/call-site errors (_LarkOwnerAttentionProtocol / LarkStewardReports) on owner_attention.py like private_conversations.py at L269-L273 (or land #9521 first) so unfiltered pytest -v tests/test_steward_turn_controller_contract.py passes 5 passed, 0 failed.

@loopx-agent
loopx-agent force-pushed the codex/slim-steward-turn-zero-any-20261125 branch from d25aab0 to bbfc4ec Compare November 27, 2026 15:56
@loopx-agent

Copy link
Copy Markdown
Collaborator Author

Addressed review 6090400339 and supplemental note 7222294812 at exact HEAD bbfc4ec9913ccb84d8743125e3c83ef6b9398cf9:

  1. [P1] Rebase onto origin/main (2302e42d9ca, #9513) & port task_postcondition: Resolved steward_turn.py cleanly (git merge-tree --write-tree origin/main HEAD exits 0) and updated loopx/capabilities/native_chat/steward_turn_recovery.py#L366 to journal.get("validation_stage") in {"host_result_contract", "task_postcondition"}.
  2. [P2] Assign all four split steward_turn_* modules to loopx-workspace: Added steward_turn_common.py, steward_turn_context.py, steward_turn_execution.py, and steward_turn_recovery.py to WORKSPACE_MODULES in packages/loopx-core/prepare.py, plus assertions in tests/test_core_workspace_distribution.py and tests/test_core_distribution.py. Verified on built loopx-core and loopx-workspace wheels: clean Core-only find_spec returns None for all 5 steward_turn* modules (doctor --installation-only ok: true, chat --help exits 2), Core+Workspace imports all Steward modules (chat --help exits 0), Workspace uninstall restores Core-only isolation (find_spec None, chat --help exits 2), and tests/test_core_workspace_distribution.py passes (7 passed).
  3. [P2] Unfiltered tests/test_steward_turn_controller_contract.py: Updated test_real_lark_transport_protocol_and_callers_mypy_contract (L274-L287) to assert 0 protocol/call-site errors (LarkStewardReports, _LarkOwnerAttentionProtocol, _LarkTransportProtocol) on owner_attention.py and filter untouched loopx.chat_store re-export errors (#9521) from the <= 3 / <= 22 ceilings; unfiltered pytest -v tests/test_steward_turn_controller_contract.py passes 5 passed (0 failed, 0 skipped).
  4. Verification @ bbfc4ec9913: ruff check (12/12), mypy --strict --follow-imports=silent (9/9 + 17/17 [tool.mypy]), npm run typecheck:control-plane, 2416 passed across 10 Steward/Packaging/Distribution/Architecture suites (tests/test_steward_report_recovery_and_validator.py, tests/test_native_steward_reports.py, tests/capabilities/test_steward_monitor_contract.py, tests/test_managed_session_calendar_tasks.py, tests/test_native_steward_turn_host.py, tests/test_lark_steward_reports.py, tests/test_lark_steward_report_route.py, tests/test_doctor_installation_scope.py, tests/test_distribution_runtime_identity.py, tests/architecture/), loopx check (errors=0, warnings=0), CQR cqr_c5fe7b1210e11ffc6b55 (valid), and canary premerge --tier standard (gate.status="passed", merge_gate_passed=true).

@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 27, 2026

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

安装可选 Workspace 的 Core 用户,以及维护原生管家、会话日历和 Lark 报告的开发者。上一提交把四个管家子模块放在 Core,纯 Core 或移除 Workspace 后,恢复模块可发现却因缺监控依赖而不能导入。本轮用实际 wheel 核实拆分模块与宿主同归 Workspace,移除配套后应回到纯 Core。当前提交的配套安装可加载所查八个管家模块。纯 Core 与卸载后的环境都不保留这八个文件,原有 CLI 门禁正常。本次范围为管家运行、报告与日历拆分及 Core/Workspace 的发行兼容。

改动思路 / Approach

StewardTurnHost 保持会话编排,冻结报告、启动和恢复继续使用原有会话和报告证据。发行归属沿 WORKSPACE_MODULES。本次范围为管家运行、报告与日历拆分及 Core/Workspace 的发行兼容。把上下文、执行和恢复拆到各自模块,同时保持原宿主入口、恢复裁决与配套发行边界。 实测将纯 Core、配套安装和移除后状态对照,并复跑主线最近加入的原日志恢复案例。

具体改动 / Changes

精确提交 bbfc4ec9913ccb84d8743125e3c83ef6b9398cf9,对照 2302e42d9cad35a8a4150e24496ffecfbfdce8cb。十二个文件增加 5072 行、删除 2391 行。

  • loopx/capabilities/native_chat/session_calendar_tasks.py。保留会话日历准入,收窄调用方读回类型。
  • loopx/capabilities/native_chat/steward_reports.py。保留原报告、冻结材料和监控提示读回。
  • loopx/capabilities/native_chat/steward_turn.py。保留宿主外观并委托提示、执行、恢复。
  • loopx/capabilities/native_chat/steward_turn_common.py。定义宿主与存储协议及共享类型帮助函数。
  • loopx/capabilities/native_chat/steward_turn_context.py。组织报告、治理和会话日历的原始材料。
  • loopx/capabilities/native_chat/steward_turn_execution.py。沿原工作来源执行和写入管家轮次。
  • loopx/capabilities/native_chat/steward_turn_recovery.py。保留先判断原期次和恢复依据,再交给原裁决者的流程。
  • loopx/extensions/lark/steward_reports.py。让 Lark 报告继续消费同一会话及报告记录。
  • packages/loopx-core/prepare.py。四个拆分模块随原管家宿主一起归 Workspace。
  • tests/test_core_distribution.py。验证 Core 不携带管家会话五个模块。
  • tests/test_core_workspace_distribution.py。检查配套包成员与撤除后原任务读回。
  • tests/test_steward_turn_controller_contract.py。验证真实控制器、日历和 Lark 调用方类型。

关键代码讲解

  • WORKSPACE_MODULES。原宿主、监控、报告以及四个新模块随 Workspace 安装与移除。 源码
  • StewardStoreProtocol.messages。保留真实 Store 的 strict 消息读取契约。 源码
  • build_steward_turn_prompt。沿用冻结报告和治理原有的材料与完成权限。 源码
  • report_selection_recovery。对 host_result_contract 和 task_postcondition 都核对现有 guard,保留原 journal 状态限制。 源码
  • test_real_lark_transport_protocol_and_callers_mypy_contract。验证 Lark 调用方与真实报告协议,控制类型诊断边界。 源码

workspace-steward-ownership 与 workspace-disable-parity 都通过实际 wheel 安装及移除复验。 基线发行说明 · 真实入口要求

对主干的风险 / Risks

实际构建并安装候选 Core 和 Workspace wheel。两包配套时八个管家模块全部导入,chat --help 退出 0。只安装 Core 和移除 Workspace 后八个模块均不可发现,chat --help 均退出 2。三个环境的 doctor --installation-only 都为健康。两个精确源码的 task_postcondition 原报告恢复和预分发失败重试各通过两项。原日志仍需唯一原轮与有效恢复依据。独立 Ruff、git diff --check、九个变更生产与契约文件严格 mypy、五项控制器契约测试通过。 配套发行套件 7 passed in 42.89s。

原 Store 的 strict 参数通过当前真实控制器协议测试。对照严格 mypy 的日历诊断 43→0,两个版本的 owner_attention 仍为同样四条,private_conversations 仍为同样两条。Lark 契约测试会排除 owner_attention 中所有 Chat Store 的未显式导出诊断。当前基线与候选实际只有同一条 _read_json,该例外可以精确限定在这条既有诊断。 诊断过滤 · 原导出修复 #9521

语义与验证对齐

目录拆分仍使用原报告、治理与日历入口。原类型修复和 Workspace 分包已实测,主线 #9513 的恢复条件在候选保留。独立实测使用隔离 Python 3.12 wheel 和本地测试宿主。真实飞书账号、跨版本混装和远端 CI 未实测。

我的整体评价 / Verdict

APPROVE。 前次发现的 Workspace 分包问题已关闭。配套安装与移除都符合原边界,原任务后置验证失败后的恢复仍可走原入口。

English verdict: APPROVE at bbfc4ec. The split Steward modules now ship exclusively with Workspace and disappear on uninstall. The matching installation loads all eight checked adapters, and paired recovery cases preserve the latest main-branch behavior.

@huangruiteng
huangruiteng merged commit 811c1a1 into main Nov 28, 2026
35 of 67 checks passed
@huangruiteng
huangruiteng deleted the codex/slim-steward-turn-zero-any-20261125 branch November 28, 2026 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants