# Conversation Session Background E2E Coverage Matrix 本文记录会话区 background runtime task 的 E2E 枚举边界。它补充主矩阵里的 `BG` 分组,只覆盖当前已经实现并确认的桌面端主链路。 > **覆盖状态说明**:历史综合 spec `conversation-session-background.test.ts` 当前位于 > `manual-review/pending`,因此 BG01–BG24 的 `covered by` 表示候选 spec 已有对应断言, > 不表示它们属于默认 E2E 门禁。当前默认目录中的 V4 background spec 只覆盖各自行内明确引用的 case。 ## Feature Summary | Field | Value | | --- | --- | | Change | 为 background Agent、background Bash、already-background task stop control、TaskStop、goal verifier defer/wake、running subagent SendMessage steer、background child tool mirror fake-loading/parent anchoring 回归、foreground loading 对照、background running 时普通输入直发、main turn 结束后 queued prompt drain、active goal + background Agent 的 idle 直发与 verifier terminal queue drain、background 结果轮普通 retry 边界,以及 background Agent 429 terminal failure 的 result/hover/restore 建立 E2E 覆盖,并枚举 nested runtime 后续边界 | | User-visible surfaces | assistant tool block、统一 background control UI、runtime status、goal 状态、可见 user message 过滤、assistant fork/retry actions、底部 ChatLoading、renderer toolCall store、background Agent 子工具聚合、foreground long-running loading、composer queue count、queued prompt Send now | | Provider-visible surfaces | `` 作为 model-only user-like input;active-loop 合流或 idle wake fallback 的 request 顺序;TaskStop tool call/result;goal verifier request 顺序;subagent coordinator message | | Existing docs | `docs/bash-background-parity.md`、`docs/agent-background-subagent-join.md` | | Existing code owners | `apps/zcode-cli/packages/core/src/runtime/methods/runtime-command-queue.ts`、`apps/zcode-cli/packages/core/src/runtime/methods/target.ts`、`apps/zcode-cli/packages/core/src/subagent/runner.ts`、`apps/zcode-cli/packages/core/src/tool/executor/background-tasks.ts` | | Out of scope | 手动 foreground-to-background controls、手机 replayable 恢复、Workflow 完整 output-file artifact、Bash 单一 output-file provider surface 收敛 | ## Boundary Decisions | Boundary | Decision | Includes | Excludes / prunes | Source | | --- | --- | --- | --- | --- | | Client mode | 只做 `desktop-continuous` | renderer/host/agent 正常桌面链路 | `web-remote-replayable` accepted command 恢复 | `docs/architecture/message-flow.md` | | Task sources | 覆盖共有主能力 | `local_agent`、`local_bash` | Workflow artifact/provider surface 后续单独收敛 | 当前 background 实现 | | Notification carrier | 必须验证 provider-visible request | `` 进入最近合法 active-loop roundtrip,或 runtime idle 时作为 task-notification command wake;`source=background_task` synthetic persistence | UI 可见真实 user 气泡 | runtime command queue / visible content tests | | Goal interaction | 验证 defer + notification 后 verifier | background running 时不发 verifier;notification turn 后才 verifier | 手动 stop/cancel active goal 的全排列 | `target.ts` | | Goal queue terminal | explicit pass 代表 | main idle 输入直发;verifier in-flight 输入排队;target complete 后立即重评 queue | fail-open/cancel、typed goal/compact、手机 replayable 另走专项矩阵 | H08/G1-10 + 用户报告 session runtime 轨迹 | | Nested background | accepted as cleanup-only child lifecycle | child runtime 内 background Bash terminal cleanup、timeout、cancel cleanup | nested Bash result 回写 parent Agent output;main/goal 等待 nested Bash | runtime-local queue 设计与 owner-scoped lifecycle 语义 | | Stop control | already-background task stop only | UI `session/cancelBackgroundTask` stop、model-facing `TaskStop` stop | Ctrl+B / foreground-to-background、TaskOutput、手动读取 output artifact | `TaskStop` / runtime background stop dispatcher | | Result-turn actions | 普通 retry 只属于真实用户触发的最新 assistant turn | 先锁定全时间线最新 assistant,再校验同 turn `origin=realUser` canonical cause;background result 可独立按稳定历史判断 fork | background/synthetic 结果轮普通 retry;跳过最新 background assistant 恢复旧轮 retry | `latestAssistantRetryOnly` | ## State Owners | State / fact | Authority | Mirrors / caches | Evidence | | --- | --- | --- | --- | | background task terminal state | `RuntimeTaskRegistry` / execution adapter / subagent runner | UI projection background task card、session events | provider request、tool block、runtime logs | | notification command order | runtime command queue | session store synthetic user notice | captured `/messages` request index | | user-visible history | shared visible-content filter + UI projection | DOM message list | `getMessages("user")` | | active goal verification | agent runtime target methods | UI target summary | provider request containing verifier prompt and target status | | assistant row actions | CLI `ProductProjection` | UI 只消费 `row.actions` | live/cold projection rows + component DOM | ## Dimensions | Dimension | Values / equivalence classes | Include? | Reason | | --- | --- | --- | --- | | background source | Agent, Bash, Workflow | Agent/Bash yes; Workflow no | Workflow provider artifact surface尚未和主线收敛 | | active goal | none, active | yes | goal verifier defer 是 background 主风险 | | completion timing | before parent turn idle, after parent turn idle | representative yes | Bash 可很快完成并覆盖 active-loop 合流;Agent 用 replay delay 稳定覆盖 idle wake | | nested runtime | parent only, child runtime | parent surface automated; child runtime cleanup-only | background subagent 首轮 child turn complete 后完成并通知父会话;child 后续 background Bash terminal 只做 child runtime cleanup,不回写已完成的 Agent output | | client delivery | desktop continuous, web replayable | desktop only | replayable 是独立远控恢复需求 | | terminal status | completed, failed/lost | completed 主路径;429 failed 单例进入 E2E;其它 failed/lost 留在 core tests | 429 单例证明 result、hover 与 restore 的跨层错误保真,其它异常不做全排列 | | coordinator message | SendMessage while child running at tool batch or text-only model step, SendMessage after child terminal | running child tool-batch E2E yes;text-only 与 terminal resume core yes | tool-batch 后和正常 text-only 后都以 user-role coordinator input 续发 child provider request;terminal resume 继续由 core tests 覆盖 | | stop source | UI control, model TaskStop, runtime cleanup | UI control and TaskStop yes; runtime cleanup in focused tests | cleanup 是内部生命周期收口,不需要用户路径 E2E | runtime dispatcher tests | | parent loading state | foreground subagent child tool, background subagent child tool, foreground Bash tool | yes | background child tool update 只更新 Agent 卡片详情,不应把 parent idle UI 变成 streaming;foreground subagent 和普通 foreground Bash 仍保持原 streaming / ChatLoading 语义 | UI task stream tests + BG13/BG14 | | child tool placement | parent Agent message before later main reply, later main reply exists before child update | yes | mirrored child tool update 的归属必须由 `parentToolUseId` 决定,不能落到当前最新 assistant message | BG18 | | result-turn trigger | real user input, background Agent wake, background Bash wake | real user + one representative background wake in projection tests;Agent/Bash 共用 origin invariant | retry 资格取决于 canonical cause,不与 task kind 做全排列 | BG33 | | goal background input timing | main idle while child running, verifier in-flight | yes | 两个窗口分别决定 startNow 与 enqueue/auto-drain,正是本次竞态边界 | BG34 | | idle notification drain cardinality | first notification request in-flight, multiple pending at next drain, arrival after claim | yes | next-available 严格快照决定一个 outer batch 对应一个首个 model request;claim 后迟到项留给下一次合法 drain,tool continuation 时允许既有 active-loop 在同一 turn 的下一 provider step 合流 | BG36 + focused core tests | | claimed batch terminal outcome | success, provider retry exhausted, stop/abort | focused only | command claim 保持 at-most-once;query 前持久化的 batch input 在 failure/stop 后仍留在 transcript,后续请求不得丢失或重复注入 | core runtime/persistence tests | | Bash admission mode | explicit background, eligible timeout promotion, first-token `sleep` hard timeout | yes | 三条路径决定 deadline 是立即清除、到点提交后台还是到点 kill | BG37-BG39 | | Bash parent abort timing | spawn/commit 前、commit 后 | yes | commit 是 foreground ownership 转后台 ownership 的边界;只允许 commit 前继承 parent abort | BG38 + focused adapter race tests | ## Accepted Cases | Case ID | Setup | Action | Assertions | Evidence layers | E2E status | | --- | --- | --- | --- | --- | --- | | BG01 | 普通会话,模型调用 `Agent(run_in_background=true)` | 子 agent delayed completion | 父 turn 先回 idle;idle wake notification request 含 `` 和子结果;UI 不显示 notification user 气泡 | UI + provider capture + runtime status | covered by `conversation-session-background.test.ts` | | BG02 | 普通会话,模型调用 `Bash(run_in_background=true)` | Bash 进程完成 | Bash tool block 可见;completion 赶上 active loop 时 notification 合进后续 provider request,否则 idle wake;foreground progress 不把完成 tool block 重新标 running | UI + provider capture | covered by `conversation-session-background.test.ts` | | BG03 | `/goal` continuation 中调用 background Agent | 子 agent 完成前 goal loop 准备 verifier | verifier request index 必须晚于 notification request;最终 target complete | provider capture + UI target status | covered by `conversation-session-background.test.ts` | | BG04 | background notification 在 active tool loop 仍有后续 roundtrip 时入队 | runtime command queue priority intake | 同 session 不并发模型请求;已有 active query 的后续 roundtrip 前按 priority 消费 notification,E2E 断言同一次 provider request 同时包含上一轮 Bash tool result 和 ``;idle 时作为 task-notification command 串行唤醒 | core runtime tests + BG provider capture | covered by `conversation-session-background.test.ts` and `runtime-tool-loop.test.ts` | | BG05 | notification 已写入 session store | UI 刷新/投影 | model-only synthetic input 不出现在可见 user messages,也不参与标题 | shared/UI unit tests + BG DOM assertion | covered | | BG06 | background subagent 内启动 background Bash;subagent 首轮 child turn 已完成 | 子 Bash 完成或超时 | parent 只收到一次 Agent completion notification;child Bash terminal 不再触发 child provider request;child registry/event/artifact terminal cleanup 完成;UI 不出现 parent fake-running | core runtime tests + replay E2E parent surface | covered by `conversation-session-background.test.ts` | | BG07 | 普通会话,父模型先调用 `Agent(run_in_background=true)`,子 agent 正在执行本地 Bash tool;core 相邻代表覆盖 child model step 正常 text-only 收口 | 父模型在 Agent launch tool result 后调用 `SendMessage` | SendMessage tool result 为 delivered;完整 Bash tool batch 后或正常 text-only assistant 后,子 agent 下一次 provider request 都含 user-role `Message from coordinator` 和 message payload;不得降级成未唤醒的 future queue;最终父 notification 消费子结果 | provider capture + UI tool block + core runtime test | covered by `conversation-session-background.test.ts` + `subagent-explore.test.ts` | | BG08 | 普通会话,模型调用长时间 `Bash(run_in_background=true)` | 用户在统一 background control UI 点击 stop | Bash stop 经 `session/cancelBackgroundTask` 进入 runtime dispatcher;provider request 含 stopped/killed ``;UI running row 消失;notification 不重复 | UI control + provider capture + runtime tests | covered by `conversation-session-background.test.ts` | | BG09 | 普通会话,模型调用长时间 `Agent(run_in_background=true)` | 用户在统一 background control UI 点击 stop | local_agent stop 经同一 dispatcher;child runtime abort;provider request 含 stopped ``;UI running row 消失;main 回 idle | UI control + provider capture + runtime tests | covered by `conversation-session-background.test.ts` | | BG10 | 普通会话,模型调用 `Agent(run_in_background=true)` 后继续调用 `TaskStop` | TaskStop 停止 running local_agent task | provider-visible `TaskStop` tool call/result 使用 task id;stopped notification 通过 runtime command queue 消费;不新增第二套 kill/notification path | provider capture + runtime tests | covered by `conversation-session-background.test.ts` | | BG11 | 普通会话,模型调用 eligible foreground Bash 且设置短 `timeout` | Bash timeout 先于命令完成 | foreground Bash timeout auto-background;tool result 返回 backgrounded;统一 background control UI 出现该 Bash task;完成后 notification 进入 provider request | UI control + provider capture + runtime tests | covered by `conversation-session-background.test.ts` | | BG12 | 普通会话,统一 background control UI 已显示 running Bash task | Bash background task 自然完成 | UI control row 在 completed notification 后消失;不残留 running row、不需要刷新、不重复展示 | UI control + provider capture + UI tests | covered by `conversation-session-background.test.ts` | | BG13 | 普通会话,模型分别调用 foreground Agent 和 `Agent(run_in_background=true)` | child Agent 执行一个 Bash tool 并向父 UI mirror tool update | foreground child tool update 期间 main chat root 保持 streaming 且底部 `chat-loading` 出现;background Agent control 仍显示 running,renderer store 收到 mirrored child Bash toolCall,但 main chat root 不进入 streaming、底部 `chat-loading` 不出现;Agent 完成后仍按标准 `` 收口 | UI DOM/store + provider capture + UI tests | covered by `conversation-session-background.test.ts` | | BG14 | 普通会话,模型调用普通 foreground 长时间 Bash,且命令在 timeout 前完成 | Bash tool running | main chat root 保持 streaming;底部 `chat-loading` 出现;命令完成后 provider continuation 收口,main 回 idle;不触发 background control row | UI DOM/store + provider capture | covered by `conversation-session-background.test.ts` | | BG15 | 普通会话,background Bash 仍 running,但 main turn 已 idle | 用户主动发送普通文本 | 该文本立即成为新的 provider request;发送后 `queueCount` 保持 0;background task control row 仍可单独 stop 并通过 notification 收口 | UI DOM + provider capture + queue count | covered by `conversation-session-background.test.ts` | | BG16 | 普通会话,background subagent child Bash tool update 已让 raw runtime running,但 main turn 已 idle;测试桥构造一条 held queued prompt | 用户点击 queued prompt “立即发送” | 不调用 stop 当前 background task;held queue stop 标记被清掉;queued prompt 直接成为 provider request;background Agent 后续自然完成并通过标准 `` 收口 | UI DOM + provider capture + queue count | covered by `conversation-session-background.test.ts` | | BG17 | 普通会话,main turn 已调用 `Agent(run_in_background=true)`,background Agent 已在统一 control UI 中 running,父 turn launch ack 仍未收口 | 父 turn active 时连续发送 Q2/Q3/Q4;父 turn 收口后 queue 自动 drain | background running 不阻止父 turn active 期间普通消息进入 renderer queue;父 turn 收口后 Q2 继续 drain;Q2 active 时 Q3/Q4 仍必须留在 queue;Q3/Q4 drain 后必须渲染为可见 user message;Q2/Q3/Q4 依次 FIFO drain;background Agent completion notification 仍按标准链路消费 | UI DOM + provider capture + background control | covered by `conversation-session-background.test.ts` | | BG18 | 普通会话,background Agent 已启动且原 Agent tool card 位于较早 assistant message;child Bash tool_use 被延迟 | 父会话 idle 后用户发送后续主消息并收到新 assistant 回复,随后 child Bash tool update 到达父 renderer | child Bash toolCall 的 `messageId` 必须与原 Agent toolCall 相同,且 `parentToolUseId` 指向原 Agent;不能挂到后续主回复 assistant 下;Agent 完成后仍按标准 `` 收口 | UI renderer store + provider capture + background control | covered by `conversation-session-background.test.ts` | | BG19 | 普通会话,background task running 且 main idle | 用户手动 `/compact`,随后 background task 完成 | compact 不应因 background running 被拒绝;background completion notification 在 compact 后仍唤醒 main;provider request 同时包含 compact 摘要和 `` terminal status | UI DOM + provider capture + compact marker | covered by `conversation-session-background.test.ts` | | BG20 | guide 模式,background Agent launch tool result 已产生但父 turn 仍 active | 用户发送引导文本 | guide 文本不走普通 future queue;后续 provider request 同时包含 `Async agent launched successfully` tool result 和引导文本 | UI queue/projection + provider capture | covered by `conversation-session-background-guide-steer.test.ts` | | BG21 | 普通会话,background Agent 的 child Bash tool card 已经在原 Agent 卡片下显示,随后用户切到其他 session/draft | child Bash 在父 session 不可见期间完成,background Agent completion notification 也被消费 | 切回原 session 后 child Bash 仍聚合在原 Agent 卡片下,工具名/description/output 不丢,状态必须从 running 收口为 terminal;不能退化成 Unknown、Bash 泛名或一直“执行中” | UI renderer store + provider capture + session switch | covered by `conversation-session-background.test.ts` | | BG22 | 普通会话,background Agent 的 child Bash tool card 已经在原 Agent 卡片下显示且仍 running,随后用户切到其他 session/draft 又切回 | 切回原 session 时 child Bash 还没完成,之后 completion update 在可见状态到达 | 切回时 child Bash 仍聚合在原 Agent 卡片下并保持 running/non-terminal;完成后同一个 tool block 更新为 terminal,工具名/命令/output 不丢,不能退化成 Unknown 或一直“执行中” | UI renderer store + DOM status + provider capture + session switch | covered by `conversation-session-background.test.ts` | | BG23 | 普通会话,右上角 background control 面板已显示两个 running Bash task | 第一个 background Bash 自然完成并触发 terminal update / snapshot 校准,第二个仍在 running;随后 stop 第二个 task | terminal task 状态胜出并从右上角面板消失;仍 running 的 task 必须继续保留,不能因为 partial/stale update 或 snapshot 缺失而闪没;stop 后最后一个 active row 后续可正常消失 | UI DOM + provider capture + task-notification | covered by `conversation-session-background.test.ts` | | BG24 | 普通会话,右上角 background control 面板已显示一个长跑 Agent 和三个短跑 Agent task | 第二个 Agent completion notification request 已开始但仍 in-flight 时切到其它 session/draft,再切回原 task;随后第三个 Agent 完成,第三个 notification turn 内模型执行 `TodoWrite`,长跑 Agent 仍 running;renderer presence probe 连续覆盖 restore/live overlap 到 main idle | notification 处理中切回后的 live update 及第三个 notification/TodoWrite 处理中,仍 running 的 Agent row 必须持续可见;terminal Agent 可收口;stop 剩余 Agent 后最后一个 active row 后续可正常消失 | UI DOM continuous visibility probe + provider capture + delayed task-notification + in-flight session restore | covered by `conversation-session-background.test.ts` | | BG25 | background Agent 正在长程任务,父模型已经通过 `SendMessage` 注入 coordinator question | child 在下一次 model step 调用 `RespondToCoordinator`,并在同一 response 继续普通工作 tool | parent provider request 消费 model-only ``;顶层 user messages 不显示 response marker;parent Agent card 保留 nested response tool block;child 继续工作并最终正常 completion;该独立 BG25 spec 不混入 compact divider | provider capture + UI projection + core runtime ordering tests | covered by `conversation-session-subagent-respond-to-coordinator.test.ts` | | BG26 | 普通会话,模型调用 `Agent(run_in_background=true)`;child-only provider marker 稳定返回 429 | child 重试耗尽并发送 failed ``;用户检查 Agent 卡片并切换任务后返回 | provider-visible summary 为 `Agent ... failed. ` 且 `` 为同一原文;renderer store/live DOM 为 failed;“执行失败”可 hover 原文;切回 snapshot 后状态、输出、hover 都保持;main idle | provider fixture + notification request + renderer store + DOM hover + session restore | covered by `conversation-session-background-subagent-rate-limit.test.ts` | | BG27 | 普通会话,background Agent completion 在 main idle 后触发独立 model-only wake | notification turn live 渲染并刷新冷恢复 | Agent description 作为结构化 title 显示;总结永久全展开,无“已工作 N 秒”和折叠控件;刷新后 title 不丢;navigator 数量不增加 | runtime metadata + projection rows + UI DOM + session restore | partial:runtime/product/cold/UI focused tests 已覆盖;pending manual-review 已补断言,但现有场景仍依赖旧 `chat-input` helper,尚未完成 V4 runtime 晋级 | | BG28 | 普通会话,background Bash completion 在 main idle 后触发独立 model-only wake | notification turn live 渲染并刷新冷恢复 | 既有 Bash title resolver 结果作为结构化 title 显示;总结永久全展开,无耗时和折叠控件;旧 session 缺 metadata 时不猜测 | runtime metadata + projection rows + UI DOM + session restore | partial:runtime/product/cold/UI focused tests 已覆盖;pending manual-review 已补断言,但现有场景仍依赖旧 `chat-input` helper,尚未完成 V4 runtime 晋级 | | BG29 | 当前 session 有 running Bash;typed-count focused test 另覆盖 Subagent only 与 Bash + Subagent | 用户 hover / 点击 Composer 模式选择右侧后台入口 | Composer 宽布局显示对应类型计数与类型化 tooltip;一次点击同时展开 Status panel 与所有非空“终端/智能体”区块,明细按 kind 分区;不聚合其它 session/workspace | V4 formal UI DOM + focused component tests | covered by `conversation-session-v4-background-work.test.ts` + UI tests | | BG30 | 当前 snapshot 混合 running 与 terminal work;正式场景有一个 running Bash | Bash 被 cancel 并完成 terminal 收口 | 只统计 running;零类型不占位并重置对应 open state;最后一个 running work 收口后 Composer 入口立即消失 | V4 formal UI DOM + focused component/state tests | covered by `conversation-session-v4-background-work.test.ts` + UI tests | | BG31 | Composer 容器宽度 `<= 480px` 且有 running work | 用户点击合并 Activity 入口 | 显示 Activity + running 总数;面板 overlay 展开并直接显示所有非空后台类型区块;没有 desktop inline offset 或横向溢出 | narrow viewport WDIO + focused responsive tests | partial:desktop continuous 覆盖;手机 replayable 恢复独立保留 | | BG32 | Goal/Todo/Git 等主状态与 running work 并存;focused test 另覆盖无主状态的 Bash only、Subagent only 与混合类型 | Status panel 收起为 capsule | 胶囊有主状态时只显示主状态,不追加后台活动;无主状态时分别使用 terminal/Bot/Activity 图标与 running 总数兜底 | focused component tests | covered by UI focused tests | | BG33 | 真实用户 Q1/A1 已完成,随后 background completion 在 main idle 时触发独立 model-only result turn B1;冷恢复读取同一历史 | B1 完成后检查 assistant actions;再完成真实用户 Q2/A2 | B1 不显示普通 retry;A1 不因 B1 无资格而恢复 retry;稳定 B1 的 fork 不受影响;A2 成为全时间线最新且具 real-user cause 后独占 retry;live/cold 与 UI 一致 | product projection + transcript hydration + UI component DOM | covered by `product-projection.test.ts`、`transcript-hydration.test.ts`、`v4ConversationTurnGroup.test.ts` | | BG34 | `/goal` continuation 启动 delayed background Agent;launch ack 后 main idle、child running;notification turn 后 verifier controlled in-flight | main idle 时发送 Q2,再在 verifier request 已开始但未返回时发送 Q3 | Q2 立即进入 provider request 且 queue=0;Q3 在 verifier 中只进入 future queue且 pass 前无 provider request;verifier pass 先写 target `complete`,随后 Q3 自动 drain、渲染真实 user row、queue 清空 | UI queue/target + provider request order + runtime event callback | partial:`manual-review/pending/conversation-session-v4-goal-background-queue.test.ts` 已用 replay fixture 验证通过,待人工验收后晋级 formal | | BG35 | 显式 background Agent 的 child tool mirror 已是 running,parent turn 允许先 terminal | parent `TurnComplete(success)` 先到,child tool terminal 后到 | parent 收口不生成 `fault.runtime.toolLifecycleIncomplete`;parent phase completed 后仍用后到真实结果收口同一 child tool row;前台缺 terminal 兜底不变 | core mirror provenance + product projection/profile convergence | covered by `subagent-tool-events.test.ts` + `product-projection.test.ts` | | BG36 | provider-visible launch request 中三个 Agent tool use 均为 `run_in_background=true`,三个 child provider request 均已开始;父 launch turn terminal 后,V4 `control.canStop=false` 稳定保持且第一条 notification request 尚未出现;随后第一条 notification 通过 outer drain 启动 model-only provider request,另外两个 Agent 在该 request in-flight 期间完成并进入同优先级 runtime command queue | 第一条 request terminal,outer drain 再次可用 | background-only 窗口先用 provider admission + V4 `canStop` 证明 main idle,不把异步 Subagent 目录计数当 admission 真相源;下一次 request 的最新 model-only user input 按 admission 顺序同时包含两个 ``;只增加一个 request;对应 notification 只持久化成一条 synthetic message,两个 ledger 输入 promoted 到同一 message ID;复用首个成员 source/workId 并按顺序合成 title 的普通 `originMeta`,live/cold 一致;最终 V4 `canStop=false`、queue 为空且 UI 无 synthetic user 气泡 | provider launch/child requests + V4 `canStop` + runtime batch log + session message/ledger + UI DOM | covered by `conversation-session-background-notification-batch.test.ts` + core queue/runtime/hydration tests;人工 review 已确认 artifact `desktop-e2e-20260717-084002-026` 并完成 formal promotion;合并后 formal case-local/default replay artifacts 为 `desktop-e2e-20260717-092331-514`、`desktop-e2e-20260717-092428-959` | | BG37 | 普通会话,模型调用 explicit background Bash,命令 timeout 明显短于实际耗时 | Bash 越过原 timeout 后自然完成 | tool result 立即返回 background task ID;control row 在原 timeout 后仍 running;最终 completed notification 被 provider 消费,且 started/terminal/notification 各一次 | UI control + provider capture + runtime process test | covered by formal `conversation-session-background.test.ts` | | BG38 | explicit Bash task ID 与 control row 已提交,parent turn 随后 stop/abort | parent abort 与后台进程并发 | 已提交任务继续运行并自然 completed;无 orphan/重复 row/重复 notification;adapter focused test 同时覆盖 commit 前 abort 不留 task | UI control + provider capture + adapter/core race tests | covered by formal `conversation-session-background.test.ts` | | BG39 | 普通会话,模型调用首 token 为 `sleep` 的 foreground Bash,timeout 短于命令耗时 | foreground hard timeout | tool result 为 aborted/timed-out 语义;无 background task ID、control row 或 task notification | UI DOM + provider capture + runtime process test | covered by formal `conversation-session-background.test.ts` | | BG40 | background Bash 的直接 shell 退出,孙进程继续继承 stdout/stderr;代表样本另覆盖脱离原进程组的后代 | session/CLI 正常 close | execution 在 pipe 未 EOF 时保持 ownership;teardown 不再触发 provider wake;原组后代被终止,逃逸后代的本端 pipe 被销毁;Browser/Execution/MCP 任一 close 悬空都不能阻断其它清理;CLI 有界退出 | adapter process-group/pipe integration + runtime shutdown admission + CLI watchdog focused tests | focused coverage,不新增 GUI E2E | ## Pruning Decisions | Decision ID | Pruned combinations | Guard/invariant | Product reason | Representative coverage | | --- | --- | --- | --- | --- | | BG-P01 | Workflow full artifact/provider shape | background source boundary | workflow output-file 和 provider-visible surface 后续单独做,不混进 Agent/Bash background 范围 | core workflow task registry tests | | BG-P02 | 手机 replayable reconnect / accepted command | client delivery boundary | replayable 恢复不是桌面 continuous background 主链路 | web remote command queue docs/tests | | BG-P03 | foreground-to-background controls | unsupported product surface | 本轮只支持 already-background task stop,不实现 Ctrl+B / `background_tasks` | docs/bash-background-parity.md | | BG-P04 | 除 429 代表样本外的 failed/lost 异常 E2E | terminal status pruning | BG26 单例证明产品交互与错误保真;其它错误类型继续由 focused tests 覆盖,避免异常全排列 | BG26 + runtime/tool-loop background tests | | BG-P05 | background subagent 内部再等待 background Bash 后回写父 Agent result | nested runtime lifecycle | parent Agent completion 与 child background Bash terminal cleanup 是两个 lifecycle;BG06 只接受 cleanup-only,不接受 parent output 二次回写 | BG06 cleanup-only boundary | | BG-P06 | completed/failed/stopped 三种 terminal 状态逐个做 title E2E | display-state equivalence | title 来源与 terminal 状态正交;代表性 E2E 加 focused state tests 即可,避免状态全排列 | BG27/BG28 + runtime/UI unit | | BG-P07 | 手机窄屏 turn navigator 交互 | responsive visibility boundary | 手机不显示 rail;只验证 replayable row metadata 守恒,不复制桌面 rail 点击/hover case | protocol snapshot tests + TN05 desktop representative | | BG-P08 | Bash only、Subagent only、混合类型 × 宽/窄 viewport × terminal status 的全排列 | projection/display equivalence | typed count 用 focused tests 穷举;正式 E2E 用真实 Bash 覆盖入口、展开与归零主链路,避免重复昂贵 runtime 场景 | BG29-BG31 + UI focused tests | | BG-P09 | 手机 `web-remote-replayable` reconnect 后 Composer 入口恢复 | client delivery boundary | 本功能只消费既有 snapshot,不改变 gap/snapshot/queue;手机恢复继续由远控专项矩阵验证,且 Running row 仍禁止打开 Subagent 侧栏 | web remote coverage matrix + BG31 desktop representative | | BG-P10 | Agent/Bash × completed/failed/stopped × live/cold 的 retry 全排列 | canonical trigger equivalence | 普通 retry 只看全时间线最新 assistant 是否有 `origin=realUser` canonical cause;task kind 与 terminal status 不改变该资格 | BG33 product/cold/UI representative | | BG-P11 | explicit pass/fail-open/cancel × text/goal/compact × desktop/mobile | goal terminal + client delivery equivalence | 本轮用 desktop continuous 的 explicit-pass + text 代表锁定 callback;其余由 G1-10/G1-14 专项覆盖,禁止把 desktop callback 扩散为 mobile replayable 旁路 | BG34 + goal-specific matrix | | BG-P12 | background Agent child tool success/error × desktop/mobile × live/cold 全排列 | explicit background provenance + canonical terminal projection | 用 desktop continuous 的 success 代表锁定父 turn 先结束和迟到 terminal;error 共用同一 terminal reducer,mobile replayable 用 profile convergence 证明不丢终态,不复制 GUI 组合 | BG35 + TLT-02 focused tests | | BG-P13 | Agent/Bash × completed/failed/stopped × `N >= 2` 数量 × desktop/mobile/remote | runtime command mode + delivery boundary | 进入 queue 后统一为 `task-notification`;batch membership 只由 mode/priority/claim 时点决定,与来源和 terminal status 正交。desktop Agent 三任务代表 provider-visible 主链路;Bash/status/late/goal/prompt 以及 batch request 的 terminal failure/stop durable-input 边界用 focused tests,mobile replayable 与 remote workspace 不改变 snapshot/gap/identity 合同 | BG36 desktop Agent representative + core queue/runtime/hydration tests | | BG-P14 | inherited-pipe shutdown × desktop continuous / mobile replayable / remote workspace / GUI 展示 | execution ownership 与 client delivery 正交 | 修复位于 session host 的资源关闭边界,不修改 protocol、snapshot、queue 或 renderer;GUI 全排列不能增加 PID、PGID、pipe handle 证据 | BG40 focused process/runtime/CLI tests | ## E2E Handoff Notes - Provider fixture: `packages/desktop/test/e2e/fixtures/upstream/conversation-session/conversation-session-background.json` - Case manifest: `packages/desktop/test/e2e/fixtures/cases/conversation-session/conversation-session-background.json` - Formal spec: `packages/desktop/test/e2e/conversation-session/conversation-session-background.test.ts` - Timing strategy: parent launch ACK 使用确定性 replay;需要断言 running 的 child Bash 使用 case-local 文件 barrier,由目标交互完成后释放,不依赖固定 sleep 或机器速度。 - Validation: 先跑 `e2e:fixture:check`,再跑该 spec 的 WDIO replay,最后跑 E2E typecheck。 ### BG36 handoff - Provider fixture: `packages/desktop/test/e2e/fixtures/upstream/conversation-session/conversation-session-background-notification-batch.json` - Case manifest: `packages/desktop/test/e2e/fixtures/cases/conversation-session/conversation-session-background-notification-batch.json` - Formal spec: `packages/desktop/test/e2e/conversation-session/conversation-session-background-notification-batch.test.ts` - Timing strategy: 三个真实 background Agent;父 launch ack 后先从 provider request 断言三个 tool use 均为 `run_in_background=true`、三个 child request 已开始,再用 V4 `control.canStop=false` 的稳定采样证明 background-only idle,并确认第一条 notification request 尚未出现。不能使用异步 `subagents.list` 目录计数证明 runtime admission。第一个 child 使用加长受控延迟保留稳定可观测窗口,第一条 notification response 继续保持 in-flight,另外两个 child 在该窗口内完成。fixture/manifest 必须记录 `syntheticReason`。 - Promotion evidence: artifact `desktop-e2e-20260717-084002-026` 已完成人工 review;promotion 已按 `--reviewed` dry-run 后 apply;合并后 formal case-local/default replay artifacts 为 `desktop-e2e-20260717-092331-514`、`desktop-e2e-20260717-092428-959`,capture 不作为正式 fixture 合同。