Skip to content

fix(dag): harden replan verdict gate — string-output bypass + transient pause strand - #331

Merged
LeXwDeX merged 1 commit into
devfrom
fix/dag-gate-harden
Aug 17, 2026
Merged

fix(dag): harden replan verdict gate — string-output bypass + transient pause strand#331
LeXwDeX merged 1 commit into
devfrom
fix/dag-gate-harden

Conversation

@LeXwDeX

Copy link
Copy Markdown
Owner

问题(Closes#330

审计 #327 裁决门后的两条 SOFT 发现:

SOFT-2(门绕过):门判定只解码 object 输出。报告型检查点若无 output_schema、或以纯文本回复 {"verdict":"replan"}(replan 片段新增的检查点不走 authoring 检查,可不带 schema),node.output 为字符串 → 解码 None → 门不触发 → 复现 #322 整图空转

SOFT-3(静默搁浅):门触发时 dag.pause 瞬态失败(如并发长 replan 持锁致 WORKFLOW_LOCK_TIMEOUT),原实现记日志 + setPaused(false) + 跳过 spawnReady——不重试、不唤醒父会话,workflow 卡死到无关事件。

修法

src/dag/runtime/loop.ts

  1. 字符串输出先经 parseJsonOptionSchema.UnknownFromJsonString,与 dag.ts:228 同型)解析,再匹配 GateReplanVerdict——字符串 verdict 不再绕过门。
  2. 门 pause 重试一次,仍失败则回读持久状态兜底——永不静默搁浅。

验证

  • 新增回归:无 output_schema 的 report_to_parent 检查点提交字符串 {"verdict":"replan"} → workflow paused、下游保持 pending。
  • test/dag/dag-loop-guards.test.ts 8 pass(含既有 object-verdict pause/continue/resume 回归)。
  • test/dag/561 pass / 0 fail
  • packages/opencode bun typecheck 干净。
  • 本地提交钩子因 codeload 对 ghostty-web 的 429 限流(外部依赖、与本改动无关)无法跑全工作区 typecheck,经确认以 --no-verify 提交、由 CI 作门禁。

记录在案、本 PR 不处置

  • SOFT-1(STEPPING 被 replan-resume 降级为 RUNNING)、SOFT-4(WorkflowReplanned 不刷新 paused 标志的既有竞态)→ 另行评估。
  • SOFT-5(condition 最左 LHS 的罕见误报,fail-closed 可辩护)、SOFT-6(paused 沉降的日志噪音,良性)→ 保留。

…ransient pause failure
Audit follow-up to #327/#322. (1) Parse a string-typed checkpoint output as JSON before matching the replan verdict, so a report_to_parent gate without output_schema (or a string-typed child reply, reachable via replan fragments which skip the authoring check) cannot bypass the pause gate and reproduce the #322 spin. (2) Retry the gate pause once before falling back to the durable status, so a transient pause failure (e.g. the workflow lock held by a concurrent long replan) never silently strands the workflow with no spawn round and no parent wake.
@LeXwDeX
LeXwDeX merged commit f1c2c8c into devAug 17, 2026
5 checks passed
@LeXwDeX
LeXwDeX deleted the fix/dag-gate-harden branch August 17, 2026 23:04
Sign up for freeto 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

@LeXwDeX