Skip to content

fix: 退回候选节点改为基于执行历史并收紧退回校验 (#270) - #271

Merged
xlorne merged 1 commit into
devfrom
feature/issue-270-return-node-control
Nov 16, 2026
Merged

xlorne merged 1 commit into
devfrom
feature/issue-270-return-node-control

Conversation

@xlorne

@xlorne xlorne commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

问题

退回(RETURN)候选节点由前端从流程定义的全量节点(FlowContent.nodes)中截取到当前节点为止,存在三个问题(issue #270):

  1. 当前节点位于条件/并行块内时,顶层节点列表中匹配不到当前节点,候选退化为全部节点,可以选择当前节点之后的节点;
  2. 服务端 ActionManager.verifySession() 只校验"非结束 / 非当前 / 非下游 / 类型白名单",并行、条件分支中"结构上不是下游但从未执行"的节点仍可退回;
  3. 候选列表按定义顺序输出(A、B),而不是最近优先(B、A);
  4. 开始节点被配置了退回动作时(设计器「按钮配置」页签对所有节点开放),按钮会展示,但提交必然失败。

改动

  • FlowContent 新增 backNodes:只包含当前记录真实执行过的历史节点,倒序去重保证最近优先;没有候选时不向展示按钮集合下发 RETURN(nodes 字段保持不变)。
  • BackNodeHelper 新增 historyBackNodes(...):按记录 id 正序倒序遍历历史记录,同一节点多次执行只保留最近一次,未执行的分支节点天然被排除。
  • ActionManager 收紧 RETURN 校验:开始节点不支持退回;退回目标必须存在于当前记录的历史执行链。
  • FlowStateException 新增 nodeNotSupportReturn / backNodeNotInHistory。
  • BaseAction.show 兼容缺少 display 配置的旧流程数据,避免详情接口空指针。
  • 新增 FlowIssue270ReturnNodeControlTest:历史候选与最近优先、未执行分支拒绝、开始节点不展示退回。

验证

  • ./mvnw -o -pl flow-engine-framework test:375 个用例全部通过(含新增 3 个)
  • ./mvnw -o install -DskipTests:全模块编译通过

Closes #270

- FlowContent 新增 backNodes:只包含当前记录真实执行过的历史节点,
  倒序去重保证"最近经过的节点"优先(停留在 C 时为 B、A),
  且没有候选时不向展示按钮集合下发 RETURN,修正开始节点
  "退回按钮可点但提交必然失败"的错误交互(issue #270)
- BackNodeHelper 新增 historyBackNodes,按记录 id 正序倒序遍历历史记录,
  同一节点多次执行只保留最近一次,未执行的分支节点天然被排除
- ActionManager 收紧 RETURN 校验:开始节点不支持退回;
  退回目标必须存在于当前记录的历史执行链(并行/条件分支中
  "结构上不是下游但从未执行"的节点同样被拒绝)
- FlowStateException 新增 nodeNotSupportReturn / backNodeNotInHistory
- BaseAction.show 兼容缺少 display 配置的旧流程数据,避免详情接口空指针
- 新增 FlowIssue270ReturnNodeControlTest(历史候选、最近优先、未执行分支拒绝、开始节点)

Closes #270
@codecov

codecov Bot commented Nov 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.03704% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.76%. Comparing base (eeba200) to head (0bbe3ac).

Files with missing lines Patch % Lines
...com/codingapi/flow/node/helper/BackNodeHelper.java 85.00% 0 Missing and 3 partials ⚠️
...java/com/codingapi/flow/manager/ActionManager.java 85.71% 1 Missing and 1 partial ⚠️
...ain/java/com/codingapi/flow/action/BaseAction.java 0.00% 0 Missing and 1 partial ⚠️
.../com/codingapi/flow/pojo/response/FlowContent.java 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                dev     #271      +/-   ##
============================================
+ Coverage     74.58%   74.76%   +0.18%     
- Complexity     1871     1895      +24     
============================================
  Files           238      238              
  Lines          7670     7717      +47     
  Branches        895      903       +8     
============================================
+ Hits           5721     5770      +49     
+ Misses         1510     1502       -8     
- Partials        439      445       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xlorne
xlorne merged commit b42a66e into dev Nov 16, 2026
3 checks passed
@xlorne
xlorne deleted the feature/issue-270-return-node-control branch November 16, 2026 15:46
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