fix(desktop): 用当前 generation 终态证据回收残留 activeTurn - #3383
Conversation
…minal proof When a PI turn already observed its product terminal, the live Session and desktop tracker can both be idle while coordinator still holds a dispatched activeTurn. send_to_session then keeps queueing, and no retry timer is armed. Reclaim that leftover only when Session reports the current generation has already fanned out a terminal. The PI prompt-accepted to agent_start gap stays fail-closed. Signed-off-by: zqchris <chrisz83@gmail.com>
|
| Filename | Overview |
|---|---|
| packages/maker-core/src/session.ts | 新增 generation 级终态快照、reservation 回调及拒绝派发时的终态证据恢复逻辑。 |
| apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts | 将 active turn 绑定到 vendor generation,并依据匹配的 done/error 证据执行残留回收或错误恢复。 |
| apps/desktop/src/main/maker-ipc/register.ts | 接入 Session 终态探针,并标记计划内 daemon upgrade 产生的静默 terminal error。 |
| apps/desktop/src/main/maker-ipc/makerSendTransaction.ts | 将 coordinator 的 reservation-generation 回调透传到 Session.send。 |
| apps/desktop/src/main/maker-ipc/tests/agent-input-coordinator.test.ts | 覆盖 generation 匹配、探针失败、配对 done、计划内关闭和错误恢复等 coordinator 场景。 |
| packages/maker-core/src/session-control.test.ts | 覆盖终态快照在连续派发、拒绝回滚和 reservation 窗口中的行为。 |
Sequence Diagram
sequenceDiagram
participant C as Desktop Coordinator
participant S as maker-core Session
participant P as Provider
C->>S: send(message, onTurnReserved)
S->>S: reserve generation N
S-->>C: onTurnReserved(N)
S->>P: dispatch turn
P-->>S: done / terminal error
S->>S: record terminal evidence for N
Note over C,S: coordinator callback may be missed
C->>S: probe live state and terminal evidence
alt done matches bound generation N
C->>C: reclaim leftover activeTurn
C->>C: continue draining queue
else error matches bound generation N
C->>C: enter recovery / retry state
else evidence unavailable or mismatched
C->>C: fail closed and retain activeTurn
end
Reviews (10): Last reviewed commit: "fix: address review — keep planned-upgra..." | Re-trigger Greptile
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1d50ffa354
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Observed terminal probes now carry done vs error. Successful leftover reclaim still drains the queue; a current-generation terminal error keeps active-turn recovery and Retry. A paired done tail cannot rewrite that error. Signed-off-by: zqchris <chrisz83@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6b542024d4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@zqchris 👋 这个 PR 还有 1 条 review conversation 没 resolve(packages/maker-core/src/session.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
Cache the listener-redacted error text, and redact again when exposing the
snapshot or synthesizing onTurnEvent('error'). Recovery/Retry stays on the
error path; Authorization secrets must not reach the input projection.
Signed-off-by: zqchris <chrisz83@gmail.com>
Windows CI
这不是本 PR 回归:
按范围纪律不把无关 Windows 超时并进本 PR。新 head 会再跑一轮 CI。 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ba710f14bb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@zqchris 👋 这个 PR 还有 2 条 review conversation 没 resolve(apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts / packages/maker-core/src/session.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
Capture the dispatched maker-core generation on activeTurn and only accept matching terminal evidence. Error snapshots now keep reason/sdkError/status so empty-response can still auto-resume, without leaking Authorization text. Signed-off-by: zqchris <chrisz83@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 69a77e21cc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Ignore background terminals, bind vendor generation at Session reservation, and restore the snapshot when a later send rolls back. Reclaim still requires a matching foreground done/error; Authorization text stays redacted. Signed-off-by: zqchris <chrisz83@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a36246b920
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A prior-generation done/error can arrive while a later send is reserved and then rejected. Promote that window snapshot on rollback so leftover activeTurn can still reclaim by terminal type. Signed-off-by: zqchris <chrisz83@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2d152b6731
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
If the coordinator misses a terminal error, the paired done must not clear leftover activeTurn as success. Same-generation error snapshots go through existing recovery/Retry; mismatched generations stay fail-closed. Signed-off-by: zqchris <chrisz83@gmail.com>
|
Windows |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8997ebcde5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Write the steer-start vendor generation onto accepted activeTurn instead of re-reading after ACK. Treat a missing or throwing terminal probe as unavailable and fail-closed, distinct from an explicit none snapshot. Signed-off-by: zqchris <chrisz83@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2ce6d76d33
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Do not adopt a reserved generation until provider dispatch, and keep error-over-done scoped to the same generation. A settled turn late terminal cannot become N+1 leftover error evidence. Signed-off-by: zqchris <chrisz83@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f3218bc46
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Record the host-suppressed remote_daemon_closed disposition when register skips onTurnEvent(error). Paired done and leftover reclaim must not re-synthesize that snapshot as a Retry banner. Signed-off-by: zqchris <chrisz83@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7bb441a911
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
当前 head |
|
stall 再核对(live head 仍是
结论不变:红灯是 launch fence 并发超时,不属于 generation 终态回收目标,不并入本 PR。若该超时稳定复现,应独立 issue/PR。 |
这次改了什么
摘要
PI 任务正常结束后,后续
send_to_session/ HANDOFF 会被错判成目标仍忙,消息只进队列,队列最终停在 paused。根因不是模型异常中断,而是 coordinator 残留了一份已派发的activeTurn:live Session 和 desktop tracker 都已 idle,但 #3240 只覆盖「Session 已卸载」和「tracker 假忙」,漏了「只有 coordinator 残留」这一支。本 PR 让 Session 暴露当前 generation 是否已观察到产品终态;coordinator 只在这份证据为真时回收残留并继续派发。变更类型
fix缺陷修复feat新功能refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
activeTurnonTurnEvent(done)为何被漏的全部入口agent_start空窗中的排队语义不变UI 变化
怎么验证的
自动验证
当前 head checks(与本 PR 目标无关)
head
7bb441a9当前Windows unit tests (1/2)/ 汇总Windows unit tests为 FAILURE。标注指向packages/maker-core/src/agents/pi/__tests__/pi-subagent-runs.test.ts的 launch fence 5s 超时。这不是 generation 终态回收问题:
pi-subagent-runs.test.ts手工验证
不涉及。本改动在 main 进程状态机,当前宿主无法用这份 worktree 热更正式包。
用户可执行验证:更新到含本 PR 的包后,等一个 PI 任务正常结束后立刻
send_to_session/ 投递 HANDOFF,应直接开新 turn,而不是停在「任务已停止,队列暂停」。未执行的验证
onTurnEvent(done)为何没进 coordinator。那是另一条漏,本 PR 用 Session 终态证据做回收兜底。风险
风险分类
session.ts只读终态观察 API)。该改动服务于回收判据,不是顺手重构。影响与回滚
activeTurn的第三条路径;maker-core Session 新增只读方法。提交前检查
git commit -s,见 DCO)远程连接 / 手机版适配
不涉及。本 PR 只改本机 coordinator / Session 终态回收,不改 device-link wire protocol、不改 mobile runtime。
意图契约
activeTurn时,仅当当前 turn generation 已观察到终态事件,才回收该残留并继续派发队列。agent_start空窗。