fix(goal): retry ESC pause persistence before giving up the goal - #284
Merged
Conversation
A transient DB failure during pauseForUserCancel would silently lose the pause: the turnDriven mark cleared, the pause never persisted, and the next idle event resurrected the goal against the user's explicit ESC (shouldPreempt cannot catch ESC — it adds no user message). Retry the pause up to twice with 50ms backoff (Effect.exit captures defects, unlike typed retry); on exhausted retries log loudly instead of warning, so a resurrecting goal is never invisible. No clean fault-injection seam for the retry branch (test DB is :memory:, pauseAndPublish is a layer closure over drizzle orDie) — happy path covered by test/goal/turn-scope.test.ts; seam absence recorded per diagnosis policy.
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.
Problem
审计发现 F5:
pauseForUserCancel(ESC 暂停 goal)若遇到瞬时 DB 写失败,会静默丢失暂停——turnDriven 标记已清、暂停未落库,下一个 idle 事件让 goal 违背用户明确的 ESC 意图而复活。shouldPreempt无法捕获 ESC(ESC 不产生 user 消息,lastUser 必早于 assistant)。Fix
pauseForUserCancel改为显式重试循环:最多 3 次尝试(初次 + 2 次重试,50ms 退避)。用Effect.exit捕获完整 Cause(含 defect,避开Effect.retry对 defect 的歧义);成功才 unregister lease;重试用尽改为logError高亮记录——goal 即使复活也绝不隐形。Evidence
test/goal103 pass(happy-path 由 turn-scope.test.ts 覆盖):memory:,pauseAndPublish是 drizzleorDie之上的 layer 闭包。按诊断纪律记录缝隙缺失,未硬造测试。上下文
继 GOAL-FP-01-17(#283)后的收尾。goal-loop 静默失败面收敛计划的一环。