Skip to content

fix(workflows): make terminal delivery recoverable - #208

Merged
tt-a1i merged 3 commits into
openpi-dev:mainfrom
somewan820:fix/issue-71-workflow-recovery
Aug 28, 2026
Merged

tt-a1i merged 3 commits into
openpi-dev:mainfrom
somewan820:fix/issue-71-workflow-recovery

Conversation

@somewan820

Copy link
Copy Markdown
Collaborator

Summary

Fixes #71. Makes Workflow terminal state and completion delivery recoverable across persistence, transport, and session lifecycle failures.

  • Publish terminal execution facts before dependent artifacts so a partial artifact failure cannot leave an unexplained running manifest.
  • Preserve pending completion envelopes before persistence/send attempts and retry them with stable delivery ids.
  • Flush deferred completions at shutdown and restore pending deliveries on reload.
  • Preserve aborted status and original cancellation reason when artifact persistence also fails.
  • Add a shared minimal ResultDeliveryQueue contract for Subagent, Background Terminal, and Workflow delivery implementations.

Validation

  • bun run check
  • Workflow tests: node --test --experimental-strip-types tests/extensions/workflows/*.test.ts (240/240)
  • Full suite: Node 910/910 and Vitest 30/30 passed in the validated run

The local environment could not refresh origin/main because the SSH connection was closed; the branch was created from the local main checkout and pushed to the fork.

@somewan820
somewan820 requested a review from tt-a1i August 27, 2026 12:05

@tt-a1i tt-a1i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The terminal-first persistence and durable delivery queue are solid improvements, and the Workflow suite plus both CI jobs pass. One terminal-state ownership bug remains blocking:

[P1] Preserve the terminal status already chosen by runScript()/terminalize(). When a detached or released-inline Workflow is canceled, appendArtifactPersistenceFailure() correctly keeps details.status === "aborted" if the final artifact flush also fails, but that persistence error rejects completion. The catch in settleForLaterDelivery() (extensions/workflows/index.ts, currently around line 2156) then unconditionally rewrites the status to failed. The envelope is persisted and delivered with the wrong terminal cause, contradicting this PR's cancellation-preservation contract. Only synthesize failed there if the status is still running (or let the run owner remain authoritative), and add an end-to-end regression covering cancellation plus final persistence failure through the detached/released-inline delivery path rather than only testing the persistence helper directly.

@somewan820

Copy link
Copy Markdown
Collaborator Author

已根据 review 修复并推送 commit 0e8c7fc。settleForLaterDelivery() 现在仅在状态仍为 running 时合成 failed,并保留已有终态及 finishedAt。新增 detached workflow 端到端回归,覆盖取消、最终 artifact 持久化失败、runScript() rejection 和 completion delivery,确认磁盘 manifest 与 delivered envelope 均保留 aborted 及原取消原因/持久化错误。验证:workflow tests 241/241;bun run check 通过(仅有既有 file-search Effect warnings);bun run test 911 Node + 30 Vitest 全部通过。

@somewan820
somewan820 requested a review from tt-a1i August 27, 2026 13:22
@somewan820
somewan820 force-pushed the fix/issue-71-workflow-recovery branch 2 times, most recently from 7158600 to 8a3ed53 Compare August 28, 2026 11:18
Comment thread extensions/shared/result-delivery.ts Resolved

@tt-a1i tt-a1i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上一轮 P1 已修复:取消加最终 artifact 持久化失败时,磁盘 manifest 和 delivered envelope 都会保留 aborted 与原取消原因;初始 outbox persistence failure、发送失败重试、terminal-first 持久化也有有效覆盖。当前仍有两个 P2:reload E2E 复用了同一实例的内存 pending map,没有证明从持久化状态进行新实例恢复;共享 ResultDeliveryQueue 也没有约束 stable id、receipt、retry、restore 等核心 at-least-once 语义。请按行级评论补齐。当前 head 的本地相关测试 30/30、bun run check 通过,远端两路 CI 通过,但 PR 落后 main。

@tt-a1i
tt-a1i force-pushed the fix/issue-71-workflow-recovery branch from 8a3ed53 to b5c17b4 Compare August 28, 2026 17:13

@tt-a1i tt-a1i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review on b5c17b4: both requested changes are closed. Reload recovery now constructs a fresh extension instance and proves the persisted pending envelope is sufficient for one delivery. Shared contracts now distinguish consumable one-shot queues from durable at-least-once queues and type stable ids, receipts, restore, and retry. The branch is rebased onto current main. Local bun run check passed; full suite passed with 941 Node and 30 Vitest tests. Remote Node 22.19 and Node 24 CI both passed.

@tt-a1i
tt-a1i merged commit 44210c7 into openpi-dev:main Aug 28, 2026
2 checks passed
agnitum2009 pushed a commit to agnitum2009/openpi that referenced this pull request Aug 29, 2026
* fix(workflows): make terminal delivery recoverable

* fix(workflows): preserve aborted terminal delivery

* fix(workflows): close durable delivery review gaps

---------

Co-authored-by: tt-a1i <[email protected]>
(cherry picked from commit 44210c7)
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.

Workflow:终态持久化失败与完成通知失败会留下不可恢复的不一致

2 participants