Skip to content

fix(plan): 完成门只拦 executing plan,不拦 approved-only(修死锁) - #21

Merged
1-ztc merged 1 commit into
mainfrom
feature/plan-gate-approved-fix
Jul 26, 2026
Merged

fix(plan): 完成门只拦 executing plan,不拦 approved-only(修死锁)#21
1-ztc merged 1 commit into
mainfrom
feature/plan-gate-approved-fix

Conversation

@1-ztc

@1-ztc 1-ztc commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Bug

完成门拦了 approved-但-未-start 的 plan,导致死锁崩 run。

死锁链:

plan approved (0/N, 未 start)
  → 完成门否决(approved 也算"未完成")
    → correction 让模型 plan_step skip 剩余步骤
      → skipStep: plan.status !== executing → 拒(step 必须 in_progress)
        → 模型重试 → tool-loop guard → run is_error:true 崩

发现方式: critic 真 A/B 裸跑时,模型 approve 了 plan 后按指令不执行就 end_turn,触发完成门,模型想 skip 兜底,skip 报错,崩 run。真实模型场景暴露,非单测能覆盖。

Fix

完成门只拦 status === executing,不拦 approved(plan-completion-gate.ts:51)。

理由: 完成门职责是"执行中没做完不许声称完成"。approved-未-start 是"计划已批、还没开始执行",这种状态下 end_turn 不是"执行到一半偷懒",是模型还没开始/选择不执行——完成门拦它越界。且拦了就死锁(skip 在非 executing 拒)。executing(已 start,0/N)仍照拦,不变。

测试

  • Case 10(新增):approved-only plan → 放行(修复前红,修复后绿)
  • 4 个回归 spec 全过(含 plan-completion-gate-integ 集成测试,它用 approve+start 进 executing,仍被拦,证明 executing 路径没受影响)
  • build + typecheck 干净

关联

🤖 Generated with Claude Code

…only

An approved-but-not-started plan (status=approved, steps still pending) was
blocked by the gate, which then told the model to plan_step skip the remaining
steps. But skipStep rejects plans that aren't executing (a step must be
in_progress), so the model retried until the tool-loop guard halted the run
-> crashed runs (is_error:true). Discovered end-to-end with a real model.

Fix: the gate fires only on status==='executing'. An approved-only plan
hasn't begun execution, so ending there isn't mid-run slacking — and the gate
must not create the deadlock. Executing plans (started, 0/N) are still guarded.

Verified: Case 10 (approved-only -> pass); 4 regression specs pass; typecheck clean.

Co-Authored-By: Claude <noreply@anthropic.com>
@1-ztc
1-ztc merged commit b6b111a into main Jul 26, 2026
3 checks passed
1-ztc added a commit that referenced this pull request Jul 26, 2026
The regex /(?:supported|available)\s+models?\s*[:\-]?\s*([^\n.]{5,})/i (added
in 44a03d9) used \- inside a character class, which eslint no-useless-escape
flags. \- is unnecessary there (a trailing - in [] is literal). CI failed on
main after merging #21 because that commit was the first to run the full
lint pipeline over 44a03d9's change. Change [:\-]? -> [:-]? — identical
match behavior (optional : or -), just no useless escape.

Co-authored-by: Claude <noreply@anthropic.com>
@1-ztc
1-ztc deleted the feature/plan-gate-approved-fix branch July 27, 2026 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant