feat: workflow exit codes & kill mechanism #121

Closed
opened 2026-04-25 03:40:52 +00:00 by xiaoju · 0 comments
Owner

背景

目前 workflow run 只有 started/completed/crashed 三个状态,无法区分成功/失败原因,也没有主动停止运行中 workflow 的机制。

方案

借鉴 Unix 进程退出码语义,为 workflow run 引入 exit code:

Exit Code 含义 触发场景
0 成功 正常走到 END
1 Role 错误 某个 role 主动报错退出
2 maxRounds 耗尽 超过配置的最大轮次
137 SIGKILL (128+9) nerve workflow kill 强杀
142 SIGALRM (128+14) 超时
255 crash 未捕获异常导致 worker 崩溃

改动范围

  1. DB schema: workflow_runs 表新增 exit_code INTEGER, status 扩展为 started/completed/failed/killed
  2. workflow-worker: role 出错 exit_code=1, maxRounds 耗尽 exit_code=2, crash exit_code=255, kill-thread IPC exit_code=137
  3. CLI: nerve workflow kill , nerve workflow list 显示 exit_code
  4. 统计(后续): nerve workflow stats 成功率/耗时/exit_code 分布

退出码采用 Unix 信号惯例(128 + signal number)。

小橘 🍊(NEKO Team)

## 背景 目前 workflow run 只有 started/completed/crashed 三个状态,无法区分成功/失败原因,也没有主动停止运行中 workflow 的机制。 ## 方案 借鉴 Unix 进程退出码语义,为 workflow run 引入 exit code: | Exit Code | 含义 | 触发场景 | |-----------|------|----------| | 0 | 成功 | 正常走到 END | | 1 | Role 错误 | 某个 role 主动报错退出 | | 2 | maxRounds 耗尽 | 超过配置的最大轮次 | | 137 | SIGKILL (128+9) | nerve workflow kill 强杀 | | 142 | SIGALRM (128+14) | 超时 | | 255 | crash | 未捕获异常导致 worker 崩溃 | ## 改动范围 1. DB schema: workflow_runs 表新增 exit_code INTEGER, status 扩展为 started/completed/failed/killed 2. workflow-worker: role 出错 exit_code=1, maxRounds 耗尽 exit_code=2, crash exit_code=255, kill-thread IPC exit_code=137 3. CLI: nerve workflow kill <runId>, nerve workflow list 显示 exit_code 4. 统计(后续): nerve workflow stats 成功率/耗时/exit_code 分布 退出码采用 Unix 信号惯例(128 + signal number)。 小橘 🍊(NEKO Team)
This repo is archived. You cannot comment on issues.
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/nerve#121