父 issue
背景
#713 的 E 阶段已经完成:
progress 剩余 direct map access 主要集中在:
turnPlanSnapshots
mcpToolCallProgress
turnFileChanges
turnDiffSnapshots
下一片选择 turnPlanSnapshots,而不是 MCP tool progress:
turnPlanSnapshots direct access 更少,集中在 plan update upsert/dedup 和 turn cleanup。
MCP tool progress 还牵涉 exec progress entry 生成、final/non-final item progress、transport 节流与 tool status,验证面更大。
turnFileChanges / turnDiffSnapshots 当前已有较多 runtime method,后续可另行评估是否需要结构测试收口。
目标
把 progress.turnPlanSnapshots 的 upsert/dedup 和 cleanup 收口到 serviceProgressRuntime / Service facade,避免业务路径继续直接读写该 map。
非目标
完成标准
生产代码中除 runtime owner/facade 文件外,不再直接访问 s.progress.turnPlanSnapshots。
新增结构测试防止该 map direct access 回归。
plan update dedup、turn completed cleanup、turn artifact cleanup 相关测试通过。
若触及 remote surface 状态机逻辑 carrier,完成 remote-state-machine guardrail 复核,并记录是否需要更新 canonical doc。
子 issue 结果回卷到 调研核心大包与高耦合结构拆分方案 #713 后再关闭。
依赖
信息索引
相关文件:
internal/core/orchestrator/service_runtime_clusters.go
internal/core/orchestrator/service_plan_update.go
internal/core/orchestrator/service.go
internal/core/orchestrator/service_routing_request_state.go
docs/general/remote-surface-state-machine.md
扫描命令:
rg -n " turnPlanSnapshots|deleteMatchingTurnPlanSnapshots" internal/core/orchestrator --glob ' *.go'
建议范围
先加结构测试,允许 owner/facade 文件访问 turnPlanSnapshots,预期红灯列出当前 offenders。
在 serviceProgressRuntime 增加 plan snapshot upsert/dedup 和 delete matching 方法。
迁移 applyTurnPlanUpdate、turn completed cleanup、clear turn artifacts。
跑目标测试和全量测试,完成 guardrail/issue close-out。
执行决策
实现参考
service_runtime_clusters.go 保持 runtime map owner。
可新增 service_progress_plan_snapshot.go 或类似文件承载 Service 语义 facade。
结构测试应禁止非 owner/facade 文件直接出现 .progress.turnPlanSnapshots。
现有 deleteMatchingTurnPlanSnapshots(records, ...) 接收底层 map,应收口为 runtime/facade 方法,避免继续泄露存储。
需要保持的关键行为:
相同 TurnPlanSnapshot 重复事件仍不投影新 event。
新 plan snapshot 仍按 surface/instance/thread/turn 维度缓存。
turn completed 和 clear turn artifacts 仍清理对应 snapshot。
检查参考
建议验证命令:
go test ./internal/core/orchestrator -run ' PlanUpdate|TurnCompleted|Routing|Snapshot|Progress' -count=1
go test ./internal/core/orchestrator -count=1
go test ./internal/core/orchestrator ./internal/core/control ./internal/app/daemon -count=1
go test ./...
bash scripts/check/go-file-length.sh && git diff --check
Guardrail:
触及 remote-surface state-machine logic carrier 时,运行 remote-state-machine guardrail。
若确认只是 facade 化且行为不变,记录 canonical doc 无需更新的理由。
收尾参考
把完成结果、验证结果、verifier 结果和 commit 写回 调研核心大包与高耦合结构拆分方案 #713 总调度表/子 issue 回卷。
关闭本 issue 前运行 issuectl close-plan。
使用 issuectl finish --close 关闭。
提交并通过 ./safe-push.sh 推送。
执行快照
当前阶段:close-out
当前执行点:close-out tail;verifier 已完成,下一步确认 调研核心大包与高耦合结构拆分方案 #713 回卷后 commit/push/close。
已完成:TDD 结构测试红灯确认 offenders;新增 service_progress_plan_snapshot.go facade;生产 direct access 已迁移;remote-state-machine guardrail 已复核。
下一步:提交并通过 safe-push 推送,然后运行 close-plan / finish --close。
当前阻塞:无。
最近改变的假设:无;MCP progress、file change/diff 仍不混入本切片。
最后一致状态:rg -n "\.progress\.turnPlanSnapshots|deleteMatchingTurnPlanSnapshots" internal/core/orchestrator --glob '*.go' 只剩结构测试自身;全量测试、文件长度与 diff check 均通过;remote-state-machine canonical doc 已覆盖 plan update / plan proposal 语义,行为未变不需更新。
未完成尾项:commit、safe-push、close-plan、finish --close。
恢复步骤:读取本 issue与当前 diff;确认 调研核心大包与高耦合结构拆分方案 #713 已回卷后提交推送并关闭 收口 orchestrator turn plan snapshot facade #722 。
验证记录
RED:go test ./internal/core/orchestrator -run TestProgressPlanSnapshotMapStaysBehindFacade -count=1 失败,offenders 为 service.go、service_plan_update.go、service_routing_request_state.go。
GREEN:go test ./internal/core/orchestrator -run 'PlanUpdate|TurnCompleted|Routing|Snapshot|Progress' -count=1 通过。
包级:go test ./internal/core/orchestrator -count=1 通过。
相关包:go test ./internal/core/orchestrator ./internal/core/control ./internal/app/daemon -count=1 通过。
全量:go test ./... 通过。
收尾检查:bash scripts/check/go-file-length.sh、git diff --check 通过。
Guardrail:已复核 docs/general/remote-surface-state-machine.md 中 plan update / completed plan item / 提案计划相关条目;本次只收口 owner/facade,未改变状态迁移或用户可见语义,不需要更新 canonical doc。
父 issue
背景
#713 的 E 阶段已经完成:
progress剩余 direct map access 主要集中在:turnPlanSnapshotsmcpToolCallProgressturnFileChangesturnDiffSnapshots下一片选择
turnPlanSnapshots,而不是 MCP tool progress:turnPlanSnapshotsdirect access 更少,集中在 plan update upsert/dedup 和 turn cleanup。turnFileChanges/turnDiffSnapshots当前已有较多 runtime method,后续可另行评估是否需要结构测试收口。目标
把
progress.turnPlanSnapshots的 upsert/dedup 和 cleanup 收口到serviceProgressRuntime/Servicefacade,避免业务路径继续直接读写该 map。非目标
mcpToolCallProgress、turnFileChanges、turnDiffSnapshots。完成标准
s.progress.turnPlanSnapshots。依赖
信息索引
相关文件:
internal/core/orchestrator/service_runtime_clusters.gointernal/core/orchestrator/service_plan_update.gointernal/core/orchestrator/service.gointernal/core/orchestrator/service_routing_request_state.godocs/general/remote-surface-state-machine.md扫描命令:
建议范围
turnPlanSnapshots,预期红灯列出当前 offenders。serviceProgressRuntime增加 plan snapshot upsert/dedup 和 delete matching 方法。applyTurnPlanUpdate、turn completed cleanup、clear turn artifacts。执行决策
turnPlanSnapshotsfacade。实现参考
service_runtime_clusters.go保持 runtime map owner。service_progress_plan_snapshot.go或类似文件承载 Service 语义 facade。.progress.turnPlanSnapshots。deleteMatchingTurnPlanSnapshots(records, ...)接收底层 map,应收口为 runtime/facade 方法,避免继续泄露存储。需要保持的关键行为:
TurnPlanSnapshot重复事件仍不投影新 event。检查参考
建议验证命令:
Guardrail:
收尾参考
issuectl close-plan。issuectl finish --close关闭。./safe-push.sh推送。执行快照
service_progress_plan_snapshot.gofacade;生产 direct access 已迁移;remote-state-machine guardrail 已复核。rg -n "\.progress\.turnPlanSnapshots|deleteMatchingTurnPlanSnapshots" internal/core/orchestrator --glob '*.go'只剩结构测试自身;全量测试、文件长度与 diff check 均通过;remote-state-machine canonical doc 已覆盖 plan update / plan proposal 语义,行为未变不需更新。验证记录
go test ./internal/core/orchestrator -run TestProgressPlanSnapshotMapStaysBehindFacade -count=1失败,offenders 为service.go、service_plan_update.go、service_routing_request_state.go。go test ./internal/core/orchestrator -run 'PlanUpdate|TurnCompleted|Routing|Snapshot|Progress' -count=1通过。go test ./internal/core/orchestrator -count=1通过。go test ./internal/core/orchestrator ./internal/core/control ./internal/app/daemon -count=1通过。go test ./...通过。bash scripts/check/go-file-length.sh、git diff --check通过。docs/general/remote-surface-state-machine.md中 plan update / completed plan item / 提案计划相关条目;本次只收口 owner/facade,未改变状态迁移或用户可见语义,不需要更新 canonical doc。