From 46820f8a4b39ba1944b88dd63d4160009766564e Mon Sep 17 00:00:00 2001 From: "lusendong.6789" Date: Sun, 15 Nov 2026 14:51:33 +0800 Subject: [PATCH] Defer report providers during Turn reads Signed-off-by: lusendong.6789 Signed-off-by: lusendong.6789 Co-authored-by: TRAE CLI --- .../rfcs/monorepo-distribution-split-v0.md | 26 +++++++++++++++++++ .../monorepo-distribution-split-v0.zh-CN.md | 18 +++++++++++++ .../periodic_report/pending_intent.py | 15 ++++++----- loopx/cli_commands/turn.py | 3 ++- 4 files changed, 55 insertions(+), 7 deletions(-) diff --git a/docs/architecture/rfcs/monorepo-distribution-split-v0.md b/docs/architecture/rfcs/monorepo-distribution-split-v0.md index 5a9652dc3c..3df17f5403 100644 --- a/docs/architecture/rfcs/monorepo-distribution-split-v0.md +++ b/docs/architecture/rfcs/monorepo-distribution-split-v0.md @@ -4425,3 +4425,29 @@ view shows its independently checked result in the same conversation. or execute/replay imports. It reuses C1's existing composition and owners; complete D2/D5 closure, actual-model adoption, comparable full costs, R1/M3, C1 cutover and full original-goal regression remain open. + +### 2026-11-15 — Defer fresh decisions and report production on Turn reads + +- **Gap:** journal inspection imported the fresh Turn decision owner, while + pending-report inspection imported progress snapshots and publication helpers + before those operations were selected. +- **Delta:** retain the existing decision and report owners, loading them at + their actual call sites. Approval retries still read the original Todo source; + publication imports occur only on execution, before any report artifact write. + Report admission, subscription checks, recovery and public exports retain + their existing contracts. No new dispatcher, state vocabulary or decision + owner is introduced. +- **Evidence:** fresh source-checkout CLI processes on `main@c5ff8fdc32b6`, + running the existing Core workload on File and SQLite with `checkpoint=None`, + reduce execution imports from 515 to + 512, replay from 432 to 429, and journal inspection from 363 to 211 LoopX + modules. Execution RPC counts remain 223 for File and 222 for SQLite; replay + remains 12 and inspection remains one. Replay still loads the original Turn + decision module. These are measured loading deltas, not a total latency or + complete-cost improvement or standalone/split-package qualification. +- **Composition and boundary:** the slice composes with C1 #8266 at + `638b7e3c23f0` through its existing complete-source, selected-work, admission, + context and settlement owners. Installed package size, model adoption, + complete D2/D5 closure, comparable full costs, R1/M3 and C1 cutover remain + unqualified. Preserve prior failures and the original ten requirements; full + original-goal regression still precedes completion and EdgeBench preparation. diff --git a/docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md b/docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md index 035ebf82a1..76b912063e 100644 --- a/docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md +++ b/docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md @@ -3428,3 +3428,21 @@ workspace 批准和脚本模型工作。桌面视图在采用检查后显示原 - **边界:**本次减少配置加载,不减少安装包大小或 execute/replay 的导入。 复用 C1 的既有组合和 owner;完整 D2/D5 闭包、真实模型采纳、可比完整成本、 R1/M3、C1 切换及完整原目标回归仍未完成。 + +### 2026-11-15 — Turn 读取时按需加载新决策与报告生产函数 + +- **缺口:**查看 journal 时会导入新 Turn 决策 owner;检查待处理报告时,也会在 + 未选择相应操作前导入进展 snapshot 和发布函数。 +- **增量:**保留既有决策和报告 owner,在实际调用点加载。审批重试仍读取原 Todo + 来源;发布函数仅在执行时导入,并早于任何报告产物写入。报告准入、订阅检查、 + 恢复和公开导出继续使用原契约,不新增 dispatcher、状态词汇或决策 owner。 +- **证据:**以 `main@c5ff8fdc32b6` 为基线,新 source-checkout CLI 进程使用 + 既有 Core 工作负载、File 和 SQLite、`checkpoint=None`,执行的 LoopX 导入图由 + 515 降至 512,回放由 + 432 降至 429,journal 查看由 363 降至 211 个模块。执行 RPC 数保持 File 223、 + SQLite 222;回放保持 12,查看保持一次。回放仍加载原 Turn 决策模块。这些结果 + 证明加载范围减少,未证明总延迟、完整成本改善或 standalone/拆包资格。 +- **组合与边界:**本切片与 C1 #8266 的 `638b7e3c23f0` 版本组合,复用其既有 + complete-source、selected-work、准入、context 和结算 owner。安装包大小、模型 + 采纳、完整 D2/D5 闭包、可比完整成本、R1/M3 与 C1 切换保持未验证。保留历史失败 + 和原十项要求;完成前仍需完整原目标回归,随后才准备 EdgeBench。 diff --git a/loopx/capabilities/periodic_report/pending_intent.py b/loopx/capabilities/periodic_report/pending_intent.py index c1164f0093..6c3e746d2a 100644 --- a/loopx/capabilities/periodic_report/pending_intent.py +++ b/loopx/capabilities/periodic_report/pending_intent.py @@ -19,7 +19,6 @@ from ...control_plane.digest_envelope import sha256_envelope from ...history import load_registry from .field_shapes import REPORT_IDENTITY_PATTERN -from .todo_source import read_report_todo_source from ...registry import ( atomic_write_json, find_registry_goal, @@ -37,11 +36,6 @@ request_entry_for_intent, settle_periodic_report_request, ) -from .project_progress_snapshot import build_project_progress_snapshot -from .incremental import ( - build_periodic_report_publication_candidate, - write_periodic_report_publication_candidate, -) from .machine_defaults import ( build_periodic_report_delivery_authority, resolve_active_goal_periodic_report_subscription, @@ -175,6 +169,8 @@ def _superseding_approval_revision( approval_scope = str(receipt.get("approval_scope") or "") if receipt.get("status") != "approval_pending" or not approval_scope: return None + from .todo_source import read_report_todo_source + _, items = read_report_todo_source( registry_path=registry_path, goal_id=goal_id, runtime_root=runtime_root ) @@ -513,6 +509,8 @@ def _progress_facts( available_capabilities: Any = None, allow_empty: bool = False, ) -> list[dict[str, Any]]: + from .project_progress_snapshot import build_project_progress_snapshot + from ...control_plane.todos.todo_index import ( MAX_TODO_INDEX_ROLLOUT_EVENTS_PER_GOAL, ) @@ -1317,6 +1315,11 @@ def _consume_pending_periodic_report_intent( if not execute: return result + from .incremental import ( + build_periodic_report_publication_candidate, + write_periodic_report_publication_candidate, + ) + receipt_path = _receipt_path( runtime_root, goal_id, diff --git a/loopx/cli_commands/turn.py b/loopx/cli_commands/turn.py index 7bbf6e0205..8f5f220dfa 100644 --- a/loopx/cli_commands/turn.py +++ b/loopx/cli_commands/turn.py @@ -20,7 +20,6 @@ build_loopx_turn_plan, load_loopx_turn_plan_from_journal, ) -from .turn_decision import build_fresh_turn_decision_owner from .turn_inspection import handle_turn_journal_inspection from .turn_registration import register_turn_commands as register_turn_commands from .turn_rendering import ( @@ -310,6 +309,8 @@ def execution_preparer(decision: Mapping[str, Any]) -> str | None: from ..capabilities.explore.turn_context import turn_context_projector def read_decision_owner(): + from .turn_decision import build_fresh_turn_decision_owner + return build_fresh_turn_decision_owner( args, registry_path=registry_path,