docs: split inbox test plans into case files

This commit is contained in:
2026-03-19 11:29:17 +08:00
parent 9beb7e93eb
commit 5f59350577
70 changed files with 1820 additions and 1606 deletions
+8 -109
View File
@@ -1,111 +1,10 @@
# Inbox `fail` Test Plan
# Inbox `fail` Test Plan Index
## Scope
## Case Files
This document covers failure terminal completion via `inbox fail`.
Shared conventions live in [../_shared/README.md](../_shared/README.md).
## case: fail-marks-thread-failed
### 用例意义
验证租约拥有者可以把线程推进到 `failed` 终态,并生成失败结果消息。
### 前置条件
- `worker-b` 已成功 `claim` 线程 `THREAD_ID`
### 输入
```bash
inbox --db TMPDIR/coord.db --json fail --agent worker-b --thread THREAD_ID --summary "Migration failed" --body "The migration cannot proceed because the prior schema is inconsistent."
```
### 预期输出
- 命令退出码为 `0`
- `thread.status == "failed"`
- `message.kind == "result"`
### 断言结论
- `fail``done` 共享结果消息模型,但进入的是失败终态
## case: fail-persists-failure-body-and-artifact
### 用例意义
验证 `fail` 能持久化失败说明与附件。
### 前置条件
- `worker-b` 已成功 `claim` 线程 `THREAD_ID`
- `TMPDIR/failure.md` 已存在
### 输入
```bash
inbox --db TMPDIR/coord.db --json fail --agent worker-b --thread THREAD_ID --summary "Migration failed" --body-file TMPDIR/failure.md --artifact TMPDIR/failure.md --artifact-kind report
inbox --db TMPDIR/coord.db --json show --thread THREAD_ID
```
### 预期输出
- `fail` 成功
- 最终结果消息 `body` 等于文件内容
- 结果消息包含 1 个 `report` artifact
### 断言结论
- 失败终态同样要能完整交付排障材料
## case: fail-rejects-non-owner
### 用例意义
验证非租约拥有者不能把线程标记为失败。
### 前置条件
- `worker-b` 已成功 `claim` 线程 `THREAD_ID`
### 输入
```bash
inbox --db TMPDIR/coord.db --json fail --agent worker-x --thread THREAD_ID --summary "Migration failed"
```
### 预期输出
- 退出码为 `20`
- JSON 错误码为 `lease_conflict`
### 断言结论
- `fail``done` 一样受 lease owner 约束
## case: fail-rejects-on-terminal-thread
### 用例意义
验证已进入终态的线程不能再次执行 `fail`
### 前置条件
- 线程 `THREAD_ID` 已经是 `done``failed``cancelled`
### 输入
```bash
inbox --db TMPDIR/coord.db --json fail --agent worker-b --thread THREAD_ID --summary "Migration failed"
```
### 预期输出
- 退出码为 `30`
- JSON 错误码为 `invalid_state`
### 断言结论
- `fail` 对终态线程不会重复成功
| Case Slug | File | Coverage Note |
| --- | --- | --- |
| `fail-marks-thread-failed` | [fail-marks-thread-failed.md](./fail-marks-thread-failed.md) | marks a claimed thread as `failed` with a result message |
| `fail-persists-failure-body-and-artifact` | [fail-persists-failure-body-and-artifact.md](./fail-persists-failure-body-and-artifact.md) | persists failure body and artifacts for diagnosis |
| `fail-rejects-non-owner` | [fail-rejects-non-owner.md](./fail-rejects-non-owner.md) | rejects `fail` from non-owner agent |
| `fail-rejects-on-terminal-thread` | [fail-rejects-on-terminal-thread.md](./fail-rejects-on-terminal-thread.md) | rejects `fail` on terminal thread states |
@@ -0,0 +1,33 @@
# Case: `fail-marks-thread-failed`
## 用例意义
验证租约拥有者可以把线程推进到 `failed` 终态,并生成失败结果消息。
## 前置条件
- `worker-b` 已成功 `claim` 线程 `THREAD_ID`
## 输入
```bash
inbox --db TMPDIR/coord.db --json fail --agent worker-b --thread THREAD_ID --summary "Migration failed" --body "The migration cannot proceed because the prior schema is inconsistent."
```
## 预期输出
- 命令退出码为 `0`
- `thread.status == "failed"`
- `message.kind == "result"`
## 断言结论
- `fail``done` 共享结果消息模型,但进入的是失败终态
- 成功 `fail` 后会释放当前活跃 lease,避免线程停留在失败终态却仍显示被占用
## 补充约束
-`--agent` 未显式提供时,可以回退使用根级 `--agent`
- `fail` 生成的 `result` 消息会发回线程创建者,而不是发给当前执行者自己
- 如果线程没有活跃 lease`fail` 应返回 `invalid_state`,而不是 `lease_conflict`
@@ -0,0 +1,34 @@
# Case: `fail-persists-failure-body-and-artifact`
## 用例意义
验证 `fail` 能持久化失败说明与附件。
## 前置条件
- `worker-b` 已成功 `claim` 线程 `THREAD_ID`
- `TMPDIR/failure.md` 已存在
## 输入
```bash
inbox --db TMPDIR/coord.db --json fail --agent worker-b --thread THREAD_ID --summary "Migration failed" --body-file TMPDIR/failure.md --artifact TMPDIR/failure.md --artifact-kind report
inbox --db TMPDIR/coord.db --json show --thread THREAD_ID
```
## 预期输出
- `fail` 成功
- 最终结果消息 `body` 等于文件内容
- 结果消息包含 1 个 `report` artifact
## 断言结论
- 失败终态同样要能完整交付排障材料
## 补充约束
- `--payload-json` 需要是合法 JSON;空值会按 `{}` 处理
- `--body``--body-file` 互斥;不可读的 `--body-file` 属于 `invalid_input`
- `artifact-kind``artifact-metadata-json` 不能脱离 `--artifact` 单独使用,且多值数量必须满足“一次全量应用”或“逐 artifact 对齐”
@@ -0,0 +1,25 @@
# Case: `fail-rejects-non-owner`
## 用例意义
验证非租约拥有者不能把线程标记为失败。
## 前置条件
- `worker-b` 已成功 `claim` 线程 `THREAD_ID`
## 输入
```bash
inbox --db TMPDIR/coord.db --json fail --agent worker-x --thread THREAD_ID --summary "Migration failed"
```
## 预期输出
- 退出码为 `20`
- JSON 错误码为 `lease_conflict`
## 断言结论
- `fail``done` 一样受 lease owner 约束
@@ -0,0 +1,25 @@
# Case: `fail-rejects-on-terminal-thread`
## 用例意义
验证已进入终态的线程不能再次执行 `fail`
## 前置条件
- 线程 `THREAD_ID` 已经是 `done``failed``cancelled`
## 输入
```bash
inbox --db TMPDIR/coord.db --json fail --agent worker-b --thread THREAD_ID --summary "Migration failed"
```
## 预期输出
- 退出码为 `30`
- JSON 错误码为 `invalid_state`
## 断言结论
- `fail` 对终态线程不会重复成功