feat(req-test-gate): 集成 Harness Engineering 工程约束方法论
将项目级的 Ratchet/约定检测方法论融入 req-test-gate 技能, 通过 /req 流程三个节点自动触发(dev 环境检测、cr 约定建议、test Gate 0B), 无需手动记忆执行。 新增文档:harness-engineering.md、ratchet-pattern.md、convention-flow.md、 project-bootstrap.md 及 4 个模板(ratchet/convention 脚本、GATES.md、pre-commit)。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
---
|
||||
name: req-test-gate
|
||||
description: 测试与质量门禁制度。覆盖需求级测试(Gates 1-5,含前后端联调+视觉验证)、部署级验证(Deploy Gates)、持续回归(Regression)。
|
||||
description: 测试与质量门禁制度。覆盖需求级测试(Gates 1-5)、部署级验证(Deploy Gates)、持续回归(Regression)、Harness Engineering 工程约束方法论(Ratchet、约定建立、门禁层级)。当用户提到质量门禁、架构约束、约定检查、ratchet、harness 相关任务时自动激活。
|
||||
arguments: <subcommand> [args]
|
||||
---
|
||||
|
||||
# 测试与质量门禁制度 (req-test-gate) v2.1
|
||||
@@ -36,12 +37,13 @@ Gate 5: 回归贡献检查(按 scope 区分贡献形式)
|
||||
通过 → 允许 /req next 推进到待部署池
|
||||
```
|
||||
|
||||
## Gate 0: Scope 分级(自动)
|
||||
## Gate 0: Scope 分级 + 约定检查(自动)
|
||||
|
||||
**从 `git diff` 自动推断变更范围,决定后续 Gate 的裁剪策略。**
|
||||
**两件事**:① 从 `git diff` 推断变更范围;② 运行项目内所有约定检查脚本。
|
||||
|
||||
### 0A: Scope 分级
|
||||
|
||||
```bash
|
||||
# 自动推断逻辑
|
||||
git diff main...HEAD --name-only | classify_scope
|
||||
```
|
||||
|
||||
@@ -56,6 +58,43 @@ git diff main...HEAD --name-only | classify_scope
|
||||
|
||||
**scope 影响全部后续 Gate**,在测试报告中必须标注。
|
||||
|
||||
### 0B: 约定检查(Harness 自动执行)
|
||||
|
||||
**自动发现并运行项目内所有 `scripts/check-*.sh` 脚本。**
|
||||
|
||||
```bash
|
||||
# 自动执行逻辑
|
||||
for script in scripts/check-*.sh; do
|
||||
[ -x "$script" ] && bash "$script" --ci
|
||||
done
|
||||
```
|
||||
|
||||
| 结果 | 处理 |
|
||||
|------|------|
|
||||
| 全部 PASS | Gate 0 通过,继续 Gate 1 |
|
||||
| 有 FAIL | **阻塞**,按下方「失败处理」修复后重新 `/req test` |
|
||||
| 无 scripts/check-*.sh | 跳过(项目未建立约定检查) |
|
||||
|
||||
**失败处理**(区分脚本类型):
|
||||
|
||||
| 脚本类型 | 判断方法 | 修复方式 |
|
||||
|---------|---------|---------|
|
||||
| Hard wall(纯检测) | 脚本无 baseline 文件 | 修改代码消除违规 |
|
||||
| Ratchet(基线对比) | 脚本有 `.*-baseline.json` | 修改代码降低违规数,**或**确认是故意增加 → `./scripts/check-{name}.sh baseline` 更新基线 + AskUserQuestion 确认 |
|
||||
|
||||
> 更新基线是有意识的决策(如重构导致临时增加),不能静默执行。
|
||||
|
||||
**报告格式**:
|
||||
```
|
||||
### 约定检查 (Gate 0B)
|
||||
| 脚本 | 结果 | 详情 |
|
||||
|------|------|------|
|
||||
| check-architecture.sh | ✅ PASS | 5 rules, all within baseline |
|
||||
| check-modal-safety.sh | ✅ PASS | 0 violations |
|
||||
```
|
||||
|
||||
> 这样 Harness 建立的约定脚本会在每次 `/req test` 时自动运行,无需手动执行 `/harness report`。
|
||||
|
||||
---
|
||||
|
||||
## Gate 1: 前置条件检查
|
||||
@@ -437,9 +476,10 @@ DG6: 生产部署(不可跳过) → 健康检查+文档
|
||||
### `/req test` 增强
|
||||
|
||||
```
|
||||
v1: Gate 1 → Gate 2 → Gate 3 → Gate 4
|
||||
v1: Gate 1 → Gate 2 → Gate 3 → Gate 4
|
||||
v2: Gate 1 → Gate 2(2A→2B→2C→2D→2E) → Gate 3 → Gate 4 → Gate 5
|
||||
v2.1: Gate 0(scope) → Gate 1 → Gate 2(2A→2B→2C→2D→2E→2F,按scope裁剪) → Gate 3 → Gate 4 → Gate 5
|
||||
v2.1: Gate 0(scope) → Gate 1 → Gate 2(2A→2B→2C→2D→2E→2F) → Gate 3 → Gate 4 → Gate 5
|
||||
v3: Gate 0A(scope) + 0B(约定检查) → Gate 1 → Gate 2(按scope裁剪) → Gate 3 → Gate 4 → Gate 5
|
||||
```
|
||||
|
||||
### `/req next` testing→staging 门禁
|
||||
@@ -449,3 +489,52 @@ v2.1: Gate 0(scope) → Gate 1 → Gate 2(2A→2B→2C→2D→2E→2F,按scope
|
||||
### `/req deploy` 部署门禁
|
||||
|
||||
在 req-deploy 流程前增加 Deploy Gates (DG1-DG6) 检查。
|
||||
|
||||
---
|
||||
|
||||
## Harness Engineering — 工程约束方法论
|
||||
|
||||
**项目级基础设施**的建立和维护方法论,与上述需求级门禁互补。
|
||||
|
||||
> 详见 [harness-engineering.md](harness-engineering.md) 完整文档。
|
||||
|
||||
### 核心理念
|
||||
|
||||
**建立自动化护栏防止新违规,同时允许渐进式清理遗留问题。**
|
||||
|
||||
三大支柱:
|
||||
1. **Ratchet** — 遗留违规数只能减不能增 → [ratchet-pattern.md](ratchet-pattern.md)
|
||||
2. **约定建立** — 每个 bug 修复后立即建立约定和检测 → [convention-flow.md](convention-flow.md)
|
||||
3. **门禁层级** — 按项目成熟度逐级引入 → [project-bootstrap.md](project-bootstrap.md)
|
||||
|
||||
### `/harness` 命令集(手动可用 + 自动嵌入)
|
||||
|
||||
| 命令 | 手动 | 自动触发 |
|
||||
|------|------|---------|
|
||||
| `/harness assess` | 随时 | 首次 `/req dev` |
|
||||
| `/harness init [level]` | 随时 | — |
|
||||
| `/harness convention [name]` | 随时 | `/req cr` + bug 类型需求 |
|
||||
| `/harness report` | 随时 | `/req test` Gate 0B |
|
||||
|
||||
### 模板
|
||||
|
||||
`templates/` 目录提供可复用的脚本模板:
|
||||
- [ratchet-script.md](templates/ratchet-script.md) — Ratchet 脚本模板(check/baseline/report 三命令)
|
||||
- [convention-script.md](templates/convention-script.md) — 约定检测脚本模板(grep 模式匹配)
|
||||
- [gates-doc.md](templates/gates-doc.md) — GATES.md 文档模板
|
||||
- [pre-commit-config.md](templates/pre-commit-config.md) — husky + lint-staged 配置(Node.js/Go/Monorepo)
|
||||
|
||||
### 与需求级门禁的关系
|
||||
|
||||
```
|
||||
Harness(项目级护栏) req-test-gate(需求级门禁)
|
||||
├── .husky/ pre-commit ├── Gate 0A: scope 分级
|
||||
├── CI lint workflow ├── Gate 0B: 运行 harness 的 check-*.sh ←─ 连接点
|
||||
├── scripts/check-*.sh ├── Gate 1: 前置条件
|
||||
├── CLAUDE.md 约定 ├── Gate 2: 测试执行
|
||||
│ ├── Gate 3: 质量验证
|
||||
│ ├── Gate 4: 文档持久化
|
||||
│ └── Gate 5: 回归贡献
|
||||
```
|
||||
|
||||
> Harness 不使用 Gate 编号。它的产出物(check-*.sh 脚本)通过 Gate 0B 接入 req-test-gate 流程。
|
||||
|
||||
Reference in New Issue
Block a user