plan-06: turn 生命周期收敛 — 取消传播 + 后台任务收割 + 出站配额 - #503
Merged
Milhouszhang merged 8 commits intoJul 8, 2026
Merged
Conversation
Interaction-timeout smoke coverage shipped as the late-resolve-rejection variant (daemon_rejects_resolve_after_turn_finished) plus the Task 2 TurnScope unit tests, per the plan's fallback; the mock SSE stream was not extended to emit AskUserQuestion tool_use.
… fallback Rust corbina suite green (112 passed incl. REGISTERED_TAURI_COMMANDS meta-test). Playwright E2E not run here (needs a built frontend + browsers); the change is behavior-preserving for the fake-daemon tests, which already exercised the error-propagation path since canInvokeTauri() is false in the browser context.
…er::stop finish_turn shared the turn's CancelToken with its TurnScope, and TurnScope::finish already flips the token for every non-Complete reason, so the explicit handle.cancel.cancel() in finish_turn was dead duplication — removed, with cancellation ownership documented on scope. BackgroundTaskManager::stop had no production callers: real stops route through request_stop / stop_scoped_by_turn -> stop_one (which cancels the token and kills the process). The bare stop only flipped status, orphaning the worker/process — a footgun the owner-aware system replaced. Removed it and reworked the two unit tests that relied on it to exercise the real convergence paths (request_stop + complete -> Stopped; complete frees a slot). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes agentenv/monorepo#768.
背景
turn 的中断/出错不向其派生的等待点和后台任务传播——turn 已死但"遗产"继续存活(#671 阻塞会话、#522 无限等待、#593 Gmail 无法停止、#621 无主发送循环 + TaskStop 报 unknown)。根因统一:turn 缺少"终止时收割全部子资源"的生命周期契约。
改动(8 commits)
CurrentTurnContext→AppState:每个 turn 可归属自己的后台任务/出站动作。TurnScope:收敛 pending permission/question map,bounded 交互等待,finish立即解阻塞并标 late-resolve 为 expired/finished。BackgroundTaskManager:owner turn/session + durability + cancel token;request_stop/stop_scoped_by_turn(stop→drain→abandon)真实停止(cancel token + 杀进程),terminal 单调。finish_turn:唯一移除 live turn 的路径,收割 scoped 子任务 + 清 turn 出站配额 + 解 pending 交互;替换 10+ 处散落 remove。验证(81 checks green / 0 failed)
单元 44 · 集成 11(daemon_turn_smoke,真实 daemon + mock provider)· 活 daemon RPC 3(真实 WS socket)· E2E 23(interrupt-clears-question / outbound-gate / tasks)。#768 测试矩阵 6 行全覆盖并通过。
🤖 Generated with Claude Code