Class WithdrawOperation

java.lang.Object
cloud.opencode.base.flow.operation.WithdrawOperation

public final class WithdrawOperation extends Object
Withdraw action (v4 §8.6). Two policies are supported, captured once from opencode.base.flow.withdraw-policy at construction time (D22):
  • strict (default): refuse withdraw if any task is DONE
  • loose: cancel every task (PENDING + DONE), mark as WITHDRAWN
撤回操作 —— 构造时一次性读取策略;strict 拒绝带 DONE task 的撤回,loose 全部取消。
Since:
JDK 25, opencode-base-flow V1.0.5
Author:
Leon Soo
  • Field Details

  • Constructor Details

    • WithdrawOperation

      public WithdrawOperation(FlowRepository repo, HistoryWriter history)
      Construct a withdraw operation with the policy read once from system properties. 构造撤回操作;构造时一次性读取策略。
      Parameters:
      repo - persistence facade — 持久化门面
      history - history writer — 历史追加器
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • WithdrawOperation

      public WithdrawOperation(FlowRepository repo, HistoryWriter history, String policy)
      Test-only constructor with explicit policy. 测试用构造器(显式策略)。
      Parameters:
      repo - persistence facade — 持久化门面
      history - history writer — 历史追加器
      policy - "strict" or "loose" — 策略
      Since:
      JDK 25, opencode-base-flow V1.0.5
  • Method Details

    • execute

      public void execute(FlowInstance instance, String initiatorId, String reason)
      Execute the withdraw action. Caller must have already validated that the initiatorId matches the instance's initiator. 执行撤回;调用方需先校验 initiatorId == instance.initiatorId。

      R1 S-5: the body (cancel-loop + instance UPDATE + history) runs inside FlowRepository.runInTransaction(Runnable); nested calls join the outer transaction.

      R1 S-5:整段(cancel 循环 + 实例 UPDATE + history)置于 FlowRepository.runInTransaction(Runnable);嵌套自动并入外层。

      Parameters:
      instance - instance to withdraw — 待撤回实例
      initiatorId - initiator user id — 发起人
      reason - sanitised reason (nullable) — 已清洗理由
      Since:
      JDK 25, opencode-base-flow V1.0.5